@@ -36,8 +36,8 @@ const associationLookup = {
3636 suffix : 'events' ,
3737 extensions : [ '.tsv' ] ,
3838 inherit : true ,
39- load : async ( file : BIDSFile ) : Promise < Events > => {
40- const columns = await loadTSV ( file )
39+ load : async ( file : BIDSFile , options : { maxRows : number } ) : Promise < Events > => {
40+ const columns = await loadTSV ( file , options . maxRows )
4141 . catch ( ( e ) => {
4242 return new Map ( )
4343 } )
@@ -53,8 +53,9 @@ const associationLookup = {
5353 inherit : true ,
5454 load : async (
5555 file : BIDSFile ,
56+ options : { maxRows : number } ,
5657 ) : Promise < Aslcontext > => {
57- const columns = await loadTSV ( file )
58+ const columns = await loadTSV ( file , options . maxRows )
5859 . catch ( ( e ) => {
5960 return new Map ( )
6061 } )
@@ -69,31 +70,31 @@ const associationLookup = {
6970 suffix : 'm0scan' ,
7071 extensions : [ '.nii' , '.nii.gz' ] ,
7172 inherit : false ,
72- load : ( file : BIDSFile ) : Promise < M0Scan > => {
73+ load : ( file : BIDSFile , options : any ) : Promise < M0Scan > => {
7374 return Promise . resolve ( { path : file . path } )
7475 } ,
7576 } ,
7677 magnitude : {
7778 suffix : 'magnitude' ,
7879 extensions : [ '.nii' , '.nii.gz' ] ,
7980 inherit : false ,
80- load : ( file : BIDSFile ) : Promise < Magnitude > => {
81+ load : ( file : BIDSFile , options : any ) : Promise < Magnitude > => {
8182 return Promise . resolve ( { path : file . path } )
8283 } ,
8384 } ,
8485 magnitude1 : {
8586 suffix : 'magnitude1' ,
8687 extensions : [ '.nii' , '.nii.gz' ] ,
8788 inherit : false ,
88- load : ( file : BIDSFile ) : Promise < Magnitude1 > => {
89+ load : ( file : BIDSFile , options : any ) : Promise < Magnitude1 > => {
8990 return Promise . resolve ( { path : file . path } )
9091 } ,
9192 } ,
9293 bval : {
9394 suffix : 'dwi' ,
9495 extensions : [ '.bval' ] ,
9596 inherit : true ,
96- load : async ( file : BIDSFile ) : Promise < Bval > => {
97+ load : async ( file : BIDSFile , options : any ) : Promise < Bval > => {
9798 const contents = await file . text ( )
9899 const rows = parseBvalBvec ( contents )
99100 return {
@@ -109,7 +110,7 @@ const associationLookup = {
109110 suffix : 'dwi' ,
110111 extensions : [ '.bvec' ] ,
111112 inherit : true ,
112- load : async ( file : BIDSFile ) : Promise < Bvec > => {
113+ load : async ( file : BIDSFile , options : any ) : Promise < Bvec > => {
113114 const contents = await file . text ( )
114115 const rows = parseBvalBvec ( contents )
115116
@@ -128,8 +129,8 @@ const associationLookup = {
128129 suffix : 'channels' ,
129130 extensions : [ '.tsv' ] ,
130131 inherit : true ,
131- load : async ( file : BIDSFile ) : Promise < Channels > => {
132- const columns = await loadTSV ( file )
132+ load : async ( file : BIDSFile , options : { maxRows : number } ) : Promise < Channels > => {
133+ const columns = await loadTSV ( file , options . maxRows )
133134 . catch ( ( e ) => {
134135 return new Map ( )
135136 } )
@@ -145,7 +146,7 @@ const associationLookup = {
145146 suffix : 'coordsystem' ,
146147 extensions : [ '.json' ] ,
147148 inherit : true ,
148- load : ( file : BIDSFile ) : Promise < Coordsystem > => {
149+ load : ( file : BIDSFile , options : any ) : Promise < Coordsystem > => {
149150 return Promise . resolve ( { path : file . path } )
150151 } ,
151152 } ,
@@ -154,6 +155,7 @@ const associationLookup = {
154155export async function buildAssociations (
155156 source : BIDSFile ,
156157 issues : DatasetIssues ,
158+ maxRows : number = - 1 ,
157159) : Promise < Associations > {
158160 const associations : Associations = { }
159161
@@ -177,7 +179,7 @@ export async function buildAssociations(
177179
178180 if ( file ) {
179181 // @ts -expect-error Matching load return value to key is hard
180- associations [ key ] = await load ( file ) . catch ( ( error ) => {
182+ associations [ key ] = await load ( file , { maxRows } ) . catch ( ( error ) => {
181183 if ( error . key ) {
182184 issues . add ( { code : error . key , location : file . path } )
183185 }
0 commit comments