30
30
from packaging .version import Version
31
31
32
32
33
+ DEFAULT_BIDS_QUERIES = {
34
+ "bold" : {"datatype" : "func" , "suffix" : "bold" , "part" : ["mag" , None ]},
35
+ "dwi" : {"suffix" : "dwi" },
36
+ "flair" : {"datatype" : "anat" , "suffix" : "FLAIR" , "part" : ["mag" , None ]},
37
+ "fmap" : {"datatype" : "fmap" },
38
+ "pet" : {"suffix" : "pet" },
39
+ "roi" : {"datatype" : "anat" , "suffix" : "roi" },
40
+ "sbref" : {"datatype" : "func" , "suffix" : "sbref" , "part" : ["mag" , None ]},
41
+ "t1w" : {"datatype" : "anat" , "suffix" : "T1w" , "part" : ["mag" , None ]},
42
+ "t2w" : {"datatype" : "anat" , "suffix" : "T2w" , "part" : ["mag" , None ]},
43
+ }
44
+
45
+
33
46
class BIDSError (ValueError ):
34
47
def __init__ (self , message , bids_root ):
35
48
indent = 10
@@ -151,11 +164,13 @@ def collect_participants(
151
164
def collect_data (
152
165
bids_dir ,
153
166
participant_label ,
154
- session_id = Query . OPTIONAL ,
167
+ session_id = None ,
155
168
task = None ,
156
169
echo = None ,
170
+ group_echos = True ,
157
171
bids_validate = True ,
158
172
bids_filters = None ,
173
+ queries = None ,
159
174
):
160
175
"""
161
176
Uses pybids to retrieve the input data for a given participant
@@ -223,19 +238,10 @@ def collect_data(
223
238
'return_type' : 'file' ,
224
239
'subject' : participant_label ,
225
240
'extension' : ['.nii' , '.nii.gz' ],
226
- 'session' : session_id ,
241
+ 'session' : session_id or Query . OPTIONAL ,
227
242
}
228
243
229
- queries = {
230
- "fmap" : {"datatype" : "fmap" },
231
- "bold" : {"datatype" : "func" , "suffix" : "bold" , "part" : ["mag" , None ]},
232
- "sbref" : {"datatype" : "func" , "suffix" : "sbref" , "part" : ["mag" , None ]},
233
- "flair" : {"datatype" : "anat" , "suffix" : "FLAIR" , "part" : ["mag" , None ]},
234
- "t2w" : {"datatype" : "anat" , "suffix" : "T2w" , "part" : ["mag" , None ]},
235
- "t1w" : {"datatype" : "anat" , "suffix" : "T1w" , "part" : ["mag" , None ]},
236
- "roi" : {"datatype" : "anat" , "suffix" : "roi" },
237
- "pet" : {"suffix" : "pet" }
238
- }
244
+ queries = queries or DEFAULT_BIDS_QUERIES
239
245
bids_filters = bids_filters or {}
240
246
for acq , entities in bids_filters .items ():
241
247
queries [acq ].update (entities )
@@ -256,7 +262,11 @@ def collect_data(
256
262
}
257
263
258
264
# Special case: multi-echo BOLD, grouping echos
259
- if any (["_echo-" in bold for bold in subj_data ["bold" ]]):
265
+ if (
266
+ group_echos
267
+ and "bold" in subj_data
268
+ and any (["_echo-" in bold for bold in subj_data ["bold" ]])
269
+ ):
260
270
subj_data ["bold" ] = group_multiecho (subj_data ["bold" ])
261
271
262
272
return subj_data , layout
0 commit comments