Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/files/inheritance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,22 @@ Deno.test('walkback inheritance tests', async (t) => {
assertEquals(rootElectrodes.path, '/space-talairach_electrodes.tsv')
},
)
await t.step(
'The presence of target entities does not trigger exact match logic',
async () => {
const rootFileTree = pathsToTree([
'/sub-01/ieeg/sub-01_task-rest_ieeg.edf',
'/sub-01/ieeg/sub-01_task-rest_space-anat_electrodes.tsv',
'/sub-01/ieeg/sub-01_task-rest_space-MNI_electrodes.tsv',
])
const dataFile = rootFileTree.get('sub-01/ieeg/sub-01_task-rest_ieeg.edf') as BIDSFile
const electrodes = walkBack(dataFile, true, ['.tsv'], 'electrodes', ['space'])
const localElectrodes: BIDSFile[] = electrodes.next().value
assert(Array.isArray(localElectrodes))
assertEquals(localElectrodes.map((f) => f.path), [
'/sub-01/ieeg/sub-01_task-rest_space-anat_electrodes.tsv',
'/sub-01/ieeg/sub-01_task-rest_space-MNI_electrodes.tsv',
])
},
)
})
2 changes: 1 addition & 1 deletion src/files/inheritance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function* walkBack<T extends string[]>(
if (candidates.length > 1) {
const exactMatch = candidates.find((file) => {
const { entities } = readEntities(file.name)
return Object.keys(sourceParts.entities).every((entity) =>
return [...Object.keys(sourceParts.entities), ...(targetEntities ?? [])].every((entity) =>
entities[entity] === sourceParts.entities[entity]
)
})
Expand Down
Loading