Skip to content

Commit 80942f0

Browse files
committed
rf: Populate buffers with precomputed derivatives early
1 parent 70b716c commit 80942f0

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

fmriprep/workflows/bold/fit.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ def init_bold_fit_wf(
304304
niu.IdentityInterface(fields=['boldref', 'boldmask']), name='regref_buffer'
305305
)
306306

307+
# Set default buffer values; can be overridden by workflows
308+
hmcref_buffer.inputs.boldref = precomputed.get('hmc_boldref')
309+
fmapref_buffer.inputs.sbref_files = sbref_files
310+
hmc_buffer.inputs.hmc_xforms = hmc_xforms
311+
fmapreg_buffer.inputs.boldref2fmap_xfm = boldref2fmap_xform
312+
regref_buffer.inputs.boldref = precomputed.get('coreg_boldref')
313+
307314
summary = pe.Node(
308315
FunctionalSummary(
309316
distortion_correction='None', # Can override with connection
@@ -342,7 +349,6 @@ def init_bold_fit_wf(
342349
output_dir=config.execution.fmriprep_dir,
343350
)
344351

345-
# fmt:off
346352
workflow.connect([
347353
(hmcref_buffer, outputnode, [
348354
('boldref', 'hmc_boldref'),
@@ -371,8 +377,7 @@ def init_bold_fit_wf(
371377
('boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
372378
]),
373379
(summary, func_fit_reports_wf, [('out_report', 'inputnode.summary_report')]),
374-
])
375-
# fmt:on
380+
]) # fmt:skip
376381

377382
# Stage 1: Generate motion correction boldref
378383
hmc_boldref_source_buffer = pe.Node(
@@ -413,7 +418,6 @@ def init_bold_fit_wf(
413418
]) # fmt:skip
414419
else:
415420
config.loggers.workflow.info('Found HMC boldref - skipping Stage 1')
416-
hmcref_buffer.inputs.boldref = precomputed['hmc_boldref']
417421

418422
validation_and_dummies_wf = init_validation_and_dummies_wf(bold_file=bold_file)
419423

@@ -451,15 +455,13 @@ def init_bold_fit_wf(
451455
]) # fmt:skip
452456
else:
453457
config.loggers.workflow.info('Found motion correction transforms - skipping Stage 2')
454-
hmc_buffer.inputs.hmc_xforms = hmc_xforms
455458

456459
# Stage 3: Create coregistration reference
457460
# Fieldmap correction only happens during fit if this stage is needed
458461
if not have_coregref:
459462
config.loggers.workflow.info('Stage 3: Adding coregistration boldref workflow')
460463

461464
# Select initial boldref, enhance contrast, and generate mask
462-
fmapref_buffer.inputs.sbref_files = sbref_files
463465
if sbref_files and nb.load(sbref_files[0]).ndim > 3:
464466
raw_sbref_wf = init_raw_boldref_wf(
465467
name='raw_sbref_wf',
@@ -523,7 +525,6 @@ def init_bold_fit_wf(
523525
)
524526
ds_fmapreg_wf.inputs.inputnode.source_files = [bold_file]
525527

526-
# fmt:off
527528
workflow.connect([
528529
(enhance_boldref_wf, fmapreg_wf, [
529530
('outputnode.bias_corrected_file', 'inputnode.target_ref'),
@@ -536,10 +537,7 @@ def init_bold_fit_wf(
536537
(fmapreg_wf, itk_mat2txt, [('outputnode.target2fmap_xfm', 'in_xfms')]),
537538
(itk_mat2txt, ds_fmapreg_wf, [('out_xfm', 'inputnode.xform')]),
538539
(ds_fmapreg_wf, fmapreg_buffer, [('outputnode.xform', 'boldref2fmap_xfm')]),
539-
])
540-
# fmt:on
541-
else:
542-
fmapreg_buffer.inputs.boldref2fmap_xfm = boldref2fmap_xform
540+
]) # fmt:skip
543541

544542
unwarp_wf = init_unwarp_wf(
545543
free_mem=config.environment.free_mem,
@@ -598,7 +596,6 @@ def init_bold_fit_wf(
598596
]) # fmt:skip
599597
else:
600598
config.loggers.workflow.info('Found coregistration reference - skipping Stage 3')
601-
regref_buffer.inputs.boldref = precomputed['coreg_boldref']
602599

603600
# TODO: Allow precomputed bold masks to be passed
604601
# Also needs consideration for how it interacts above

0 commit comments

Comments
 (0)