Skip to content

Commit abe9f92

Browse files
tsaloeffigies
authored andcommitted
Support multi-echo SBRefs.
1 parent ba645d0 commit abe9f92

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,29 +166,22 @@ def init_func_preproc_wf(bold_file):
166166
'Memory resampled/largemem=%.2f/%.2f GB.',
167167
ref_file, mem_gb['filesize'], bold_tlen, mem_gb['resampled'], mem_gb['largemem'])
168168

169-
sbref_file = None
170169
# Find associated sbref, if possible
171170
entities = layout.parse_file_entities(ref_file)
171+
if multiecho:
172+
# Remove echo entity to collect all echoes
173+
_ = entities.pop('echo', None)
172174
entities['suffix'] = 'sbref'
173175
entities['extension'] = ['nii', 'nii.gz'] # Overwrite extensions
174-
files = layout.get(return_type='file', **entities)
176+
177+
sbref_files = layout.get(return_type='file', **entities)
175178
refbase = os.path.basename(ref_file)
176179
if 'sbref' in config.workflow.ignore:
177180
config.loggers.workflow.info("Single-band reference files ignored.")
178-
elif files and multiecho:
179-
config.loggers.workflow.warning(
180-
"Single-band reference found, but not supported in "
181-
"multi-echo workflows at this time. Ignoring.")
182-
elif files:
183-
sbref_file = files[0]
184-
sbbase = os.path.basename(sbref_file)
185-
if len(files) > 1:
186-
config.loggers.workflow.warning(
187-
"Multiple single-band reference files found for {}; using "
188-
"{}".format(refbase, sbbase))
189-
else:
190-
config.loggers.workflow.info("Using single-band reference file %s.",
191-
sbbase)
181+
elif sbref_files:
182+
sbbase = ','.join([os.path.basename(sbf) for sbf in sbref_files])
183+
config.loggers.workflow.info("Using single-band reference file(s) %s.",
184+
sbbase)
192185
else:
193186
config.loggers.workflow.info("No single-band-reference found for %s.",
194187
refbase)
@@ -234,9 +227,11 @@ def init_func_preproc_wf(bold_file):
234227
't1w2fsnative_xfm', 'fsnative2t1w_xfm']),
235228
name='inputnode')
236229
inputnode.inputs.bold_file = bold_file
237-
if sbref_file is not None:
230+
if sbref_files is not None:
238231
from niworkflows.interfaces.images import ValidateImage
239-
val_sbref = pe.Node(ValidateImage(in_file=sbref_file), name='val_sbref')
232+
val_sbref = pe.MapNode(ValidateImage(), name='val_sbref',
233+
iterfield=['in_file'])
234+
val_sbref.inputs.in_file = sbref_files
240235

241236
outputnode = pe.Node(niu.IdentityInterface(
242237
fields=['bold_t1', 'bold_t1_ref', 'bold_mask_t1', 'bold_aseg_t1', 'bold_aparc_t1',
@@ -298,7 +293,7 @@ def init_func_preproc_wf(bold_file):
298293
# Generate a tentative boldref
299294
bold_reference_wf = init_bold_reference_wf(omp_nthreads=omp_nthreads)
300295
bold_reference_wf.inputs.inputnode.dummy_scans = config.workflow.dummy_scans
301-
if sbref_file is not None:
296+
if sbref_files is not None:
302297
workflow.connect([
303298
(val_sbref, bold_reference_wf, [('out_file', 'inputnode.sbref_file')]),
304299
])

0 commit comments

Comments
 (0)