@@ -5,7 +5,7 @@ import type { BIDSFile } from '../types/filetree.ts'
55import type { BIDSContext } from './context.ts'
66import { loadTSV } from '../files/tsv.ts'
77import { parseBvalBvec } from '../files/dwi.ts'
8- import { walkBack } from '../files/inheritance.ts'
8+ import { readSidecars , walkBack } from '../files/inheritance.ts'
99import { evalCheck } from './applyRules.ts'
1010import { 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
8899export 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