@@ -243,6 +243,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
243
243
'Memory resampled/largemem=%.2f/%.2f GB.' ),
244
244
ref_file , mem_gb ['filesize' ], bold_tlen , mem_gb ['resampled' ], mem_gb ['largemem' ])
245
245
246
+ sbref_file = None
246
247
# For doc building purposes
247
248
if layout is None or bold_file == 'bold_preprocesing' :
248
249
LOGGER .log (25 , 'No valid layout: building empty workflow.' )
@@ -260,6 +261,28 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
260
261
run_stc = True
261
262
multiecho = False
262
263
else :
264
+ # Find associated sbref, if possible
265
+ entities = layout .parse_file_entities (ref_file )
266
+ entities ['type' ] = 'sbref'
267
+ files = layout .get (** entities )
268
+ refbase = os .path .basename (ref_file )
269
+ if 'sbref' in ignore :
270
+ LOGGER .info ("Single-band reference files ignored." )
271
+ elif files and multiecho :
272
+ LOGGER .warning ("Single-band reference found, but not supported in "
273
+ "multi-echo workflows at this time. Ignoring." )
274
+ elif files :
275
+ sbref_file = files [0 ].filename
276
+ sbbase = os .path .basename (sbref_file )
277
+ if len (files ) > 1 :
278
+ LOGGER .warning (
279
+ "Multiple single-band reference files found for {}; using "
280
+ "{}" .format (refbase , sbbase ))
281
+ else :
282
+ LOGGER .log (25 , "Using single-band reference file {}" .format (sbbase ))
283
+ else :
284
+ LOGGER .log (25 , "No single-band-reference found for {}" .format (refbase ))
285
+
263
286
metadata = layout .get_metadata (ref_file )
264
287
265
288
# Find fieldmaps. Options: (phase1|phase2|phasediff|epi|fieldmap|syn)
@@ -313,13 +336,15 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
313
336
"""
314
337
315
338
inputnode = pe .Node (niu .IdentityInterface (
316
- fields = ['bold_file' , 'subjects_dir' , 'subject_id' ,
339
+ fields = ['bold_file' , 'sbref_file' , ' subjects_dir' , 'subject_id' ,
317
340
't1_preproc' , 't1_brain' , 't1_mask' , 't1_seg' , 't1_tpms' ,
318
341
't1_aseg' , 't1_aparc' ,
319
342
't1_2_mni_forward_transform' , 't1_2_mni_reverse_transform' ,
320
343
't1_2_fsnative_forward_transform' , 't1_2_fsnative_reverse_transform' ]),
321
344
name = 'inputnode' )
322
345
inputnode .inputs .bold_file = bold_file
346
+ if sbref_file is not None :
347
+ inputnode .inputs .sbref_file = sbref_file
323
348
324
349
outputnode = pe .Node (niu .IdentityInterface (
325
350
fields = ['bold_t1' , 'bold_mask_t1' , 'bold_aseg_t1' , 'bold_aparc_t1' , 'cifti_variant' ,
@@ -443,7 +468,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
443
468
# MAIN WORKFLOW STRUCTURE #######################################################
444
469
workflow .connect ([
445
470
# Generate early reference
446
- (inputnode , bold_reference_wf , [('bold_file' , 'inputnode.bold_file' )]),
471
+ (inputnode , bold_reference_wf , [('bold_file' , 'inputnode.bold_file' ),
472
+ ('sbref_file' , 'inputnode.sbref_file' )]),
447
473
# BOLD buffer has slice-time corrected if it was run, original otherwise
448
474
(boldbuffer , bold_split , [('bold_file' , 'in_file' )]),
449
475
# HMC
@@ -551,7 +577,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
551
577
# Replace reference with the echo selected with FirstEcho
552
578
workflow .disconnect ([
553
579
(inputnode , bold_reference_wf , [
554
- ('bold_file' , 'inputnode.bold_file' )]),
580
+ ('bold_file' , 'inputnode.bold_file' ),
581
+ ('sbref_file' , 'inputnode.sbref_file' )]),
555
582
(bold_reference_wf , boldbuffer , [
556
583
('outputnode.bold_file' , 'bold_file' )]),
557
584
])
0 commit comments