diff --git a/fmriprep/workflows/base.py b/fmriprep/workflows/base.py index 75cbc7c9d..2f0a92e93 100644 --- a/fmriprep/workflows/base.py +++ b/fmriprep/workflows/base.py @@ -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'), diff --git a/fmriprep/workflows/bold/base.py b/fmriprep/workflows/bold/base.py index 9423c9089..a750e951d 100644 --- a/fmriprep/workflows/bold/base.py +++ b/fmriprep/workflows/bold/base.py @@ -188,6 +188,7 @@ def init_bold_wf( "t1w_preproc", "t1w_mask", "t1w_dseg", + "t1w_tpms", "subjects_dir", "subject_id", "fsnative2t1w_xfm", @@ -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( + 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([ + (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"): @@ -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: diff --git a/fmriprep/workflows/bold/confounds.py b/fmriprep/workflows/bold/confounds.py index 4284561cb..1bcf091e1 100644 --- a/fmriprep/workflows/bold/confounds.py +++ b/fmriprep/workflows/bold/confounds.py @@ -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 diff --git a/fmriprep/workflows/bold/fit.py b/fmriprep/workflows/bold/fit.py index 3855d4256..82eec267a 100644 --- a/fmriprep/workflows/bold/fit.py +++ b/fmriprep/workflows/bold/fit.py @@ -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 -------- @@ -267,6 +273,8 @@ def init_bold_fit_wf( "motion_xfm", "boldref2anat_xfm", "boldref2fmap_xfm", + "movpar_file", + "rmsd_file", ], ), name="outputnode", @@ -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") @@ -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"), @@ -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")]), @@ -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: diff --git a/fmriprep/workflows/bold/hmc.py b/fmriprep/workflows/bold/hmc.py index b1de41f33..01be7940b 100644 --- a/fmriprep/workflows/bold/hmc.py +++ b/fmriprep/workflows/bold/hmc.py @@ -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