Skip to content

Commit

Permalink
ENH: Restore confound regressor generation as part of full
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 3, 2023
1 parent aad77d3 commit 44bd647
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
1 change: 1 addition & 0 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def init_single_subject_wf(subject_id: str):
('outputnode.t1w_preproc', 'inputnode.t1w_preproc'),
('outputnode.t1w_mask', 'inputnode.t1w_mask'),
('outputnode.t1w_dseg', 'inputnode.t1w_dseg'),
('outputnode.t1w_tpms', 'inputnode.t1w_tpms'),
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
('outputnode.subject_id', 'inputnode.subject_id'),
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),
Expand Down
40 changes: 28 additions & 12 deletions fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def init_bold_wf(
"t1w_preproc",
"t1w_mask",
"t1w_dseg",
"t1w_tpms",
"subjects_dir",
"subject_id",
"fsnative2t1w_xfm",
Expand Down Expand Up @@ -441,6 +442,33 @@ def init_bold_wf(
(bold_std_wf, ds_bold_std_wf, [('outputnode.bold_file', 'inputnode.bold')]),
]) # fmt:skip

bold_confounds_wf = init_bold_confs_wf(

Check warning on line 445 in fmriprep/workflows/bold/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/bold/base.py#L445

Added line #L445 was not covered by tests
mem_gb=mem_gb["largemem"],
metadata=all_metadata[0],
freesurfer=config.workflow.run_reconall,
regressors_all_comps=config.workflow.regressors_all_comps,
regressors_fd_th=config.workflow.regressors_fd_th,
regressors_dvars_th=config.workflow.regressors_dvars_th,
name="bold_confounds_wf",
)

workflow.connect([

Check warning on line 455 in fmriprep/workflows/bold/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/bold/base.py#L455

Added line #L455 was not covered by tests
(inputnode, bold_confounds_wf, [
('t1w_tpms', 'inputnode.t1w_tpms'),
('t1w_mask', 'inputnode.t1w_mask'),
]),
(bold_fit_wf, bold_confounds_wf, [
('outputnode.bold_mask', 'inputnode.bold_mask'),
('outputnode.movpar_file', 'inputnode.movpar_file'),
('outputnode.rmsd_file', 'inputnode.rmsd_file'),
('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
('outputnode.dummy_scans', 'inputnode.skip_vols'),
]),
(bold_native_wf, bold_confounds_wf, [
('outputnode.bold_native', 'inputnode.bold'),
]),
]) # fmt:skip

# Fill-in datasinks of reportlets seen so far
for node in workflow.list_node_names():
if node.split(".")[-1].startswith("ds_report"):
Expand Down Expand Up @@ -677,18 +705,6 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
name="outputnode",
)

# get confounds
bold_confounds_wf = init_bold_confs_wf(
mem_gb=mem_gb["largemem"],
metadata=metadata,
freesurfer=freesurfer,
regressors_all_comps=config.workflow.regressors_all_comps,
regressors_fd_th=config.workflow.regressors_fd_th,
regressors_dvars_th=config.workflow.regressors_dvars_th,
name="bold_confounds_wf",
)
bold_confounds_wf.get_node("inputnode").inputs.t1_transform_flags = [False]

# SURFACES ##################################################################################
# Freesurfer
if freesurfer and freesurfer_spaces:
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/bold/confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def init_bold_confs_wf(
movpar_file
SPM-formatted motion parameters file
rmsd_file
Framewise displacement as measured by ``fsl_motion_outliers``.
Root mean squared deviation as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
skip_vols
number of non steady state volumes
t1w_mask
Expand Down
29 changes: 25 additions & 4 deletions fmriprep/workflows/bold/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def init_bold_fit_wf(
boldref2fmap_xfm
Affine transform mapping from BOLD reference space to the fieldmap
space, if applicable.
movpar_file
MCFLIRT motion parameters, normalized to SPM format (X, Y, Z, Rx, Ry, Rz)
rmsd_file
Root mean squared deviation as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
dummy_scans
The number of dummy scans declared or detected at the beginning of the series.
See Also
--------
Expand Down Expand Up @@ -267,6 +273,8 @@ def init_bold_fit_wf(
"motion_xfm",
"boldref2anat_xfm",
"boldref2fmap_xfm",
"movpar_file",
"rmsd_file",
],
),
name="outputnode",
Expand All @@ -276,7 +284,8 @@ def init_bold_fit_wf(
workflow.add_nodes([inputnode])

hmcref_buffer = pe.Node(
niu.IdentityInterface(fields=["boldref", "bold_file"]), name="hmcref_buffer"
niu.IdentityInterface(fields=["boldref", "bold_file", "dummy_scans"]),
name="hmcref_buffer",
)
fmapref_buffer = pe.Node(niu.Function(function=_select_ref), name="fmapref_buffer")
hmc_buffer = pe.Node(niu.IdentityInterface(fields=["hmc_xforms"]), name="hmc_buffer")
Expand Down Expand Up @@ -313,13 +322,20 @@ def init_bold_fit_wf(

# fmt:off
workflow.connect([
(hmcref_buffer, outputnode, [("boldref", "hmc_boldref")]),
(hmcref_buffer, outputnode, [
("boldref", "hmc_boldref"),
("dummy_scans", "dummy_scans"),
]),
(regref_buffer, outputnode, [
("boldref", "coreg_boldref"),
("boldmask", "bold_mask"),
]),
(fmapreg_buffer, outputnode, [("boldref2fmap_xfm", "boldref2fmap_xfm")]),
(hmc_buffer, outputnode, [("hmc_xforms", "motion_xfm")]),
(hmc_buffer, outputnode, [
("hmc_xforms", "motion_xfm"),
("movpar_file", "movpar_file"),
("rmsd_file", "rmsd_file"),
]),
(inputnode, func_fit_reports_wf, [
("bold_file", "inputnode.source_file"),
("t1w_preproc", "inputnode.t1w_preproc"),
Expand Down Expand Up @@ -360,6 +376,7 @@ def init_bold_fit_wf(
(hmc_boldref_wf, hmcref_buffer, [
("outputnode.bold_file", "bold_file"),
("outputnode.boldref", "boldref"),
("outputnode.skip_vols", "dummy_scans"),
]),
(hmcref_buffer, ds_hmc_boldref_wf, [("boldref", "inputnode.boldref")]),
(hmc_boldref_wf, summary, [("outputnode.algo_dummy_scans", "algo_dummy_scans")]),
Expand Down Expand Up @@ -403,7 +420,11 @@ def init_bold_fit_wf(
("bold_file", "inputnode.bold_file"),
]),
(bold_hmc_wf, ds_hmc_wf, [("outputnode.xforms", "inputnode.xforms")]),
(ds_hmc_wf, hmc_buffer, [("outputnode.xforms", "hmc_xforms")]),
(bold_hmc_wf, hmc_buffer, [
("outputnode.xforms", "hmc_xforms"),
("outputnode.movpar_file", "movpar_file"),
("outputnode.rmsd_file", "rmsd_file"),
]),
])
# fmt:on
else:
Expand Down
4 changes: 2 additions & 2 deletions fmriprep/workflows/bold/hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def init_bold_hmc_wf(mem_gb: float, omp_nthreads: int, name: str = 'bold_hmc_wf'
ITKTransform file aligning each volume to ``ref_image``
movpar_file
MCFLIRT motion parameters, normalized to SPM format (X, Y, Z, Rx, Ry, Rz)
rms_file
Framewise displacement as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
rmsd_file
Root mean squared deviation as measured by ``fsl_motion_outliers`` [Jenkinson2002]_.
"""
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
Expand Down

0 comments on commit 44bd647

Please sign in to comment.