@@ -242,6 +242,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
242242 'Memory resampled/largemem=%.2f/%.2f GB.' ),
243243 ref_file , mem_gb ['filesize' ], bold_tlen , mem_gb ['resampled' ], mem_gb ['largemem' ])
244244
245+ sbref_file = None
245246 # For doc building purposes
246247 if layout is None or bold_file == 'bold_preprocesing' :
247248 LOGGER .log (25 , 'No valid layout: building empty workflow.' )
@@ -259,6 +260,28 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
259260 run_stc = True
260261 multiecho = False
261262 else :
263+ # Find associated sbref, if possible
264+ entities = layout .parse_file_entities (ref_file )
265+ entities ['type' ] = 'sbref'
266+ files = layout .get (** entities )
267+ refbase = os .path .basename (ref_file )
268+ if 'sbref' in ignore :
269+ LOGGER .info ("Single-band reference files ignored." )
270+ elif files and multiecho :
271+ LOGGER .warning ("Single-band reference found, but not supported in "
272+ "multi-echo workflows at this time. Ignoring." )
273+ elif files :
274+ sbref_file = files [0 ].filename
275+ sbbase = os .path .basename (sbref_file )
276+ if len (files ) > 1 :
277+ LOGGER .warning (
278+ "Multiple single-band reference files found for {}; using "
279+ "{}" .format (refbase , sbbase ))
280+ else :
281+ LOGGER .log (25 , "Using single-band reference file {}" .format (sbbase ))
282+ else :
283+ LOGGER .log (25 , "No single-band-reference found for {}" .format (refbase ))
284+
262285 metadata = layout .get_metadata (ref_file )
263286
264287 # Find fieldmaps. Options: (phase1|phase2|phasediff|epi|fieldmap|syn)
@@ -312,13 +335,15 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
312335"""
313336
314337 inputnode = pe .Node (niu .IdentityInterface (
315- fields = ['bold_file' , 'subjects_dir' , 'subject_id' ,
338+ fields = ['bold_file' , 'sbref_file' , ' subjects_dir' , 'subject_id' ,
316339 't1_preproc' , 't1_brain' , 't1_mask' , 't1_seg' , 't1_tpms' ,
317340 't1_aseg' , 't1_aparc' ,
318341 't1_2_mni_forward_transform' , 't1_2_mni_reverse_transform' ,
319342 't1_2_fsnative_forward_transform' , 't1_2_fsnative_reverse_transform' ]),
320343 name = 'inputnode' )
321344 inputnode .inputs .bold_file = bold_file
345+ if sbref_file is not None :
346+ inputnode .inputs .sbref_file = sbref_file
322347
323348 outputnode = pe .Node (niu .IdentityInterface (
324349 fields = ['bold_t1' , 'bold_mask_t1' , 'bold_aseg_t1' , 'bold_aparc_t1' , 'cifti_variant' ,
@@ -441,7 +466,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
441466 # MAIN WORKFLOW STRUCTURE #######################################################
442467 workflow .connect ([
443468 # Generate early reference
444- (inputnode , bold_reference_wf , [('bold_file' , 'inputnode.bold_file' )]),
469+ (inputnode , bold_reference_wf , [('bold_file' , 'inputnode.bold_file' ),
470+ ('sbref_file' , 'inputnode.sbref_file' )]),
445471 # BOLD buffer has slice-time corrected if it was run, original otherwise
446472 (boldbuffer , bold_split , [('bold_file' , 'in_file' )]),
447473 # HMC
@@ -549,7 +575,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
549575 # Replace reference with the echo selected with FirstEcho
550576 workflow .disconnect ([
551577 (inputnode , bold_reference_wf , [
552- ('bold_file' , 'inputnode.bold_file' )]),
578+ ('bold_file' , 'inputnode.bold_file' ),
579+ ('sbref_file' , 'inputnode.sbref_file' )]),
553580 (bold_reference_wf , boldbuffer , [
554581 ('outputnode.bold_file' , 'bold_file' )]),
555582 ])
0 commit comments