@@ -242,6 +242,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
242
242
'Memory resampled/largemem=%.2f/%.2f GB.' ),
243
243
ref_file , mem_gb ['filesize' ], bold_tlen , mem_gb ['resampled' ], mem_gb ['largemem' ])
244
244
245
+ sbref_file = None
245
246
# For doc building purposes
246
247
if layout is None or bold_file == 'bold_preprocesing' :
247
248
LOGGER .log (25 , 'No valid layout: building empty workflow.' )
@@ -259,6 +260,28 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
259
260
run_stc = True
260
261
multiecho = False
261
262
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
+
262
285
metadata = layout .get_metadata (ref_file )
263
286
264
287
# Find fieldmaps. Options: (phase1|phase2|phasediff|epi|fieldmap|syn)
@@ -312,13 +335,15 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
312
335
"""
313
336
314
337
inputnode = pe .Node (niu .IdentityInterface (
315
- fields = ['bold_file' , 'subjects_dir' , 'subject_id' ,
338
+ fields = ['bold_file' , 'sbref_file' , ' subjects_dir' , 'subject_id' ,
316
339
't1_preproc' , 't1_brain' , 't1_mask' , 't1_seg' , 't1_tpms' ,
317
340
't1_aseg' , 't1_aparc' ,
318
341
't1_2_mni_forward_transform' , 't1_2_mni_reverse_transform' ,
319
342
't1_2_fsnative_forward_transform' , 't1_2_fsnative_reverse_transform' ]),
320
343
name = 'inputnode' )
321
344
inputnode .inputs .bold_file = bold_file
345
+ if sbref_file is not None :
346
+ inputnode .inputs .sbref_file = sbref_file
322
347
323
348
outputnode = pe .Node (niu .IdentityInterface (
324
349
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,
441
466
# MAIN WORKFLOW STRUCTURE #######################################################
442
467
workflow .connect ([
443
468
# 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' )]),
445
471
# BOLD buffer has slice-time corrected if it was run, original otherwise
446
472
(boldbuffer , bold_split , [('bold_file' , 'in_file' )]),
447
473
# HMC
@@ -549,7 +575,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
549
575
# Replace reference with the echo selected with FirstEcho
550
576
workflow .disconnect ([
551
577
(inputnode , bold_reference_wf , [
552
- ('bold_file' , 'inputnode.bold_file' )]),
578
+ ('bold_file' , 'inputnode.bold_file' ),
579
+ ('sbref_file' , 'inputnode.sbref_file' )]),
553
580
(bold_reference_wf , boldbuffer , [
554
581
('outputnode.bold_file' , 'bold_file' )]),
555
582
])
0 commit comments