Skip to content

Commit 250661b

Browse files
committed
chore: Add physio loader that builds its sidecar
1 parent 5ff6708 commit 250661b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/schema/associations.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { BIDSFile } from '../types/filetree.ts'
55
import type { BIDSContext } from './context.ts'
66
import { loadTSV } from '../files/tsv.ts'
77
import { parseBvalBvec } from '../files/dwi.ts'
8-
import { walkBack } from '../files/inheritance.ts'
8+
import { readSidecars, walkBack } from '../files/inheritance.ts'
99
import { evalCheck } from './applyRules.ts'
1010
import { expressionFunctions } from './expressionLanguage.ts'
1111

@@ -83,6 +83,17 @@ const associationLookup = {
8383
sampling_frequency: columns.get('sampling_frequency'),
8484
}
8585
},
86+
physio: async (
87+
file: BIDSFile,
88+
options: any,
89+
): Promise<{ path: string; sidecar: Record<string, unknown> }> => {
90+
const sidecars = await readSidecars(file)
91+
return {
92+
path: file.path,
93+
// Note ordering here gives precedence to the more specific sidecar
94+
sidecar: sidecars.values().reduce((acc, json) => ({ ...json, ...acc }), {}),
95+
}
96+
},
8697
}
8798

8899
export async function buildAssociations(
@@ -124,12 +135,8 @@ export async function buildAssociations(
124135
if (Array.isArray(file)) {
125136
file = file[0]
126137
}
127-
} catch (error) {
128-
if (
129-
error && typeof error === 'object' && 'code' in error &&
130-
error.code === 'MULTIPLE_INHERITABLE_FILES'
131-
) {
132-
// @ts-expect-error
138+
} catch (error: any) {
139+
if (error?.code === 'MULTIPLE_INHERITABLE_FILES') {
133140
context.dataset.issues.add(error)
134141
break
135142
} else {

0 commit comments

Comments
 (0)