Skip to content

Commit ad9f868

Browse files
committed
ENH: Restore confound regressor generation as part of full
1 parent e7672df commit ad9f868

File tree

5 files changed

+57
-19
lines changed

5 files changed

+57
-19
lines changed

fmriprep/workflows/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ def init_single_subject_wf(subject_id: str):
503503
('outputnode.t1w_preproc', 'inputnode.t1w_preproc'),
504504
('outputnode.t1w_mask', 'inputnode.t1w_mask'),
505505
('outputnode.t1w_dseg', 'inputnode.t1w_dseg'),
506+
('outputnode.t1w_tpms', 'inputnode.t1w_tpms'),
506507
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
507508
('outputnode.subject_id', 'inputnode.subject_id'),
508509
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),

fmriprep/workflows/bold/base.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def init_bold_wf(
188188
"t1w_preproc",
189189
"t1w_mask",
190190
"t1w_dseg",
191+
"t1w_tpms",
191192
"subjects_dir",
192193
"subject_id",
193194
"fsnative2t1w_xfm",
@@ -441,6 +442,33 @@ def init_bold_wf(
441442
(bold_std_wf, ds_bold_std_wf, [('outputnode.bold_file', 'inputnode.bold')]),
442443
]) # fmt:skip
443444

445+
bold_confounds_wf = init_bold_confs_wf(
446+
mem_gb=mem_gb["largemem"],
447+
metadata=all_metadata[0],
448+
freesurfer=config.workflow.run_reconall,
449+
regressors_all_comps=config.workflow.regressors_all_comps,
450+
regressors_fd_th=config.workflow.regressors_fd_th,
451+
regressors_dvars_th=config.workflow.regressors_dvars_th,
452+
name="bold_confounds_wf",
453+
)
454+
455+
workflow.connect([
456+
(inputnode, bold_confounds_wf, [
457+
('t1w_tpms', 'inputnode.t1w_tpms'),
458+
('t1w_mask', 'inputnode.t1w_mask'),
459+
]),
460+
(bold_fit_wf, bold_confounds_wf, [
461+
('outputnode.bold_mask', 'inputnode.bold_mask'),
462+
('outputnode.movpar_file', 'inputnode.movpar_file'),
463+
('outputnode.rmsd_file', 'inputnode.rmsd_file'),
464+
('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
465+
('outputnode.dummy_scans', 'inputnode.skip_vols'),
466+
]),
467+
(bold_native_wf, bold_confounds_wf, [
468+
('outputnode.bold_native', 'inputnode.bold'),
469+
]),
470+
]) # fmt:skip
471+
444472
# Fill-in datasinks of reportlets seen so far
445473
for node in workflow.list_node_names():
446474
if node.split(".")[-1].startswith("ds_report"):
@@ -677,18 +705,6 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
677705
name="outputnode",
678706
)
679707

680-
# get confounds
681-
bold_confounds_wf = init_bold_confs_wf(
682-
mem_gb=mem_gb["largemem"],
683-
metadata=metadata,
684-
freesurfer=freesurfer,
685-
regressors_all_comps=config.workflow.regressors_all_comps,
686-
regressors_fd_th=config.workflow.regressors_fd_th,
687-
regressors_dvars_th=config.workflow.regressors_dvars_th,
688-
name="bold_confounds_wf",
689-
)
690-
bold_confounds_wf.get_node("inputnode").inputs.t1_transform_flags = [False]
691-
692708
# SURFACES ##################################################################################
693709
# Freesurfer
694710
if freesurfer and freesurfer_spaces:

fmriprep/workflows/bold/confounds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def init_bold_confs_wf(
121121
movpar_file
122122
SPM-formatted motion parameters file
123123
rmsd_file
124-
Framewise displacement as measured by ``fsl_motion_outliers``.
124+
Root mean squared deviation as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
125125
skip_vols
126126
number of non steady state volumes
127127
t1w_mask

fmriprep/workflows/bold/fit.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ def init_bold_fit_wf(
177177
boldref2fmap_xfm
178178
Affine transform mapping from BOLD reference space to the fieldmap
179179
space, if applicable.
180+
movpar_file
181+
MCFLIRT motion parameters, normalized to SPM format (X, Y, Z, Rx, Ry, Rz)
182+
rmsd_file
183+
Root mean squared deviation as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
184+
dummy_scans
185+
The number of dummy scans declared or detected at the beginning of the series.
180186
181187
See Also
182188
--------
@@ -267,6 +273,8 @@ def init_bold_fit_wf(
267273
"motion_xfm",
268274
"boldref2anat_xfm",
269275
"boldref2fmap_xfm",
276+
"movpar_file",
277+
"rmsd_file",
270278
],
271279
),
272280
name="outputnode",
@@ -276,7 +284,8 @@ def init_bold_fit_wf(
276284
workflow.add_nodes([inputnode])
277285

278286
hmcref_buffer = pe.Node(
279-
niu.IdentityInterface(fields=["boldref", "bold_file"]), name="hmcref_buffer"
287+
niu.IdentityInterface(fields=["boldref", "bold_file", "dummy_scans"]),
288+
name="hmcref_buffer",
280289
)
281290
fmapref_buffer = pe.Node(niu.Function(function=_select_ref), name="fmapref_buffer")
282291
hmc_buffer = pe.Node(niu.IdentityInterface(fields=["hmc_xforms"]), name="hmc_buffer")
@@ -313,13 +322,20 @@ def init_bold_fit_wf(
313322

314323
# fmt:off
315324
workflow.connect([
316-
(hmcref_buffer, outputnode, [("boldref", "hmc_boldref")]),
325+
(hmcref_buffer, outputnode, [
326+
("boldref", "hmc_boldref"),
327+
("dummy_scans", "dummy_scans"),
328+
]),
317329
(regref_buffer, outputnode, [
318330
("boldref", "coreg_boldref"),
319331
("boldmask", "bold_mask"),
320332
]),
321333
(fmapreg_buffer, outputnode, [("boldref2fmap_xfm", "boldref2fmap_xfm")]),
322-
(hmc_buffer, outputnode, [("hmc_xforms", "motion_xfm")]),
334+
(hmc_buffer, outputnode, [
335+
("hmc_xforms", "motion_xfm"),
336+
("movpar_file", "movpar_file"),
337+
("rmsd_file", "rmsd_file"),
338+
]),
323339
(inputnode, func_fit_reports_wf, [
324340
("bold_file", "inputnode.source_file"),
325341
("t1w_preproc", "inputnode.t1w_preproc"),
@@ -360,6 +376,7 @@ def init_bold_fit_wf(
360376
(hmc_boldref_wf, hmcref_buffer, [
361377
("outputnode.bold_file", "bold_file"),
362378
("outputnode.boldref", "boldref"),
379+
("outputnode.skip_vols", "dummy_scans"),
363380
]),
364381
(hmcref_buffer, ds_hmc_boldref_wf, [("boldref", "inputnode.boldref")]),
365382
(hmc_boldref_wf, summary, [("outputnode.algo_dummy_scans", "algo_dummy_scans")]),
@@ -403,7 +420,11 @@ def init_bold_fit_wf(
403420
("bold_file", "inputnode.bold_file"),
404421
]),
405422
(bold_hmc_wf, ds_hmc_wf, [("outputnode.xforms", "inputnode.xforms")]),
406-
(ds_hmc_wf, hmc_buffer, [("outputnode.xforms", "hmc_xforms")]),
423+
(bold_hmc_wf, hmc_buffer, [
424+
("outputnode.xforms", "hmc_xforms"),
425+
("outputnode.movpar_file", "movpar_file"),
426+
("outputnode.rmsd_file", "rmsd_file"),
427+
]),
407428
])
408429
# fmt:on
409430
else:

fmriprep/workflows/bold/hmc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def init_bold_hmc_wf(mem_gb: float, omp_nthreads: int, name: str = 'bold_hmc_wf'
7575
ITKTransform file aligning each volume to ``ref_image``
7676
movpar_file
7777
MCFLIRT motion parameters, normalized to SPM format (X, Y, Z, Rx, Ry, Rz)
78-
rms_file
79-
Framewise displacement as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
78+
rmsd_file
79+
Root mean squared deviation as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
8080
8181
"""
8282
from niworkflows.engine.workflows import LiterateWorkflow as Workflow

0 commit comments

Comments
 (0)