Skip to content

Commit 8d45151

Browse files
authored
Merge pull request #273 from effigies/fix/target-entities
fix: Include target entities in exact match check
2 parents 6a0acd5 + fa67843 commit 8d45151

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/files/inheritance.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,22 @@ Deno.test('walkback inheritance tests', async (t) => {
7272
assertEquals(rootElectrodes.path, '/space-talairach_electrodes.tsv')
7373
},
7474
)
75+
await t.step(
76+
'The presence of target entities does not trigger exact match logic',
77+
async () => {
78+
const rootFileTree = pathsToTree([
79+
'/sub-01/ieeg/sub-01_task-rest_ieeg.edf',
80+
'/sub-01/ieeg/sub-01_task-rest_space-anat_electrodes.tsv',
81+
'/sub-01/ieeg/sub-01_task-rest_space-MNI_electrodes.tsv',
82+
])
83+
const dataFile = rootFileTree.get('sub-01/ieeg/sub-01_task-rest_ieeg.edf') as BIDSFile
84+
const electrodes = walkBack(dataFile, true, ['.tsv'], 'electrodes', ['space'])
85+
const localElectrodes: BIDSFile[] = electrodes.next().value
86+
assert(Array.isArray(localElectrodes))
87+
assertEquals(localElectrodes.map((f) => f.path), [
88+
'/sub-01/ieeg/sub-01_task-rest_space-anat_electrodes.tsv',
89+
'/sub-01/ieeg/sub-01_task-rest_space-MNI_electrodes.tsv',
90+
])
91+
},
92+
)
7593
})

src/files/inheritance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function* walkBack<T extends string[]>(
5050
if (candidates.length > 1) {
5151
const exactMatch = candidates.find((file) => {
5252
const { entities } = readEntities(file.name)
53-
return Object.keys(sourceParts.entities).every((entity) =>
53+
return [...Object.keys(sourceParts.entities), ...(targetEntities ?? [])].every((entity) =>
5454
entities[entity] === sourceParts.entities[entity]
5555
)
5656
})

0 commit comments

Comments
 (0)