diff --git a/fmriprep/workflows/bold/fit.py b/fmriprep/workflows/bold/fit.py index ed752492b..319ce24a3 100644 --- a/fmriprep/workflows/bold/fit.py +++ b/fmriprep/workflows/bold/fit.py @@ -397,6 +397,8 @@ def init_bold_fit_wf( # fmt:off workflow.connect([ (inputnode, bold_reg_wf, [ + ("t1w_preproc", "inputnode.t1w_preproc"), + ("t1w_mask", "inputnode.t1w_mask"), ("t1w_dseg", "inputnode.t1w_dseg"), # Undefined if --fs-no-reconall, but this is safe ("subjects_dir", "inputnode.subjects_dir"), diff --git a/fmriprep/workflows/bold/registration.py b/fmriprep/workflows/bold/registration.py index c643bc7cf..7f4c9e57a 100644 --- a/fmriprep/workflows/bold/registration.py +++ b/fmriprep/workflows/bold/registration.py @@ -149,7 +149,8 @@ def init_bold_reg_wf( niu.IdentityInterface( fields=[ 'ref_bold_brain', - 't1w_brain', + 't1w_preproc', + 't1w_mask', 't1w_dseg', 'subjects_dir', 'subject_id', @@ -186,8 +187,10 @@ def init_bold_reg_wf( ('fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'), ('subjects_dir', 'inputnode.subjects_dir'), ('subject_id', 'inputnode.subject_id'), + ('t1w_preproc', 'inputnode.t1w_brain'), + ('t1w_mask', 'inputnode.t1w_mask'), ('t1w_dseg', 'inputnode.t1w_dseg'), - ('t1w_brain', 'inputnode.t1w_brain')]), + ]), (bbr_wf, outputnode, [('outputnode.itk_bold_to_t1', 'itk_bold_to_t1'), ('outputnode.itk_t1_to_bold', 'itk_t1_to_bold'), ('outputnode.fallback', 'fallback')]), @@ -526,13 +529,14 @@ def init_bbreg_wf( niu.IdentityInterface( [ 'in_file', - 'fsnative2t1w_xfm', + 'fsnative2t1w_xfm', # BBRegister 'subjects_dir', - 'subject_id', # BBRegister + 'subject_id', + 't1w_preproc', # FLIRT BBR + 't1w_mask', 't1w_dseg', - 't1w_brain', ] - ), # FLIRT BBR + ), name='inputnode', ) outputnode = pe.Node( @@ -736,6 +740,7 @@ def init_fsl_bbr_wf( from niworkflows.engine.workflows import LiterateWorkflow as Workflow from niworkflows.interfaces.freesurfer import PatchedLTAConvert as LTAConvert from niworkflows.interfaces.freesurfer import PatchedMRICoregRPT as MRICoregRPT + from niworkflows.interfaces.nibabel import ApplyMask from niworkflows.interfaces.reportlets.registration import FLIRTRPT from niworkflows.utils.images import dseg_label as _dseg_label @@ -757,13 +762,14 @@ def init_fsl_bbr_wf( niu.IdentityInterface( [ 'in_file', - 'fsnative2t1w_xfm', + 'fsnative2t1w_xfm', # BBRegister 'subjects_dir', - 'subject_id', # BBRegister + 'subject_id', + 't1w_preproc', # FLIRT BBR + 't1w_mask', 't1w_dseg', - 't1w_brain', ] - ), # FLIRT BBR + ), name='inputnode', ) outputnode = pe.Node( @@ -780,6 +786,9 @@ def init_fsl_bbr_wf( if bold2t1w_init == "header": raise NotImplementedError("Header-based registration initialization not supported for FSL") + # Mask T1w_preproc with T1w_mask to make T1w_brain + mask_t1w_brain = pe.Node(ApplyMask(), name='mask_t1w_brain') + mri_coreg = pe.Node( MRICoregRPT( dof=bold2t1w_dof, sep=[4], ftol=0.0001, linmintol=0.01, generate_report=not use_bbr @@ -809,12 +818,14 @@ def init_fsl_bbr_wf( ) # fmt:off workflow.connect([ - (inputnode, mri_coreg, [('in_file', 'source_file'), - ('t1w_brain', 'reference_file')]), - (inputnode, fsl2itk_fwd, [('t1w_brain', 'reference_file'), - ('in_file', 'source_file')]), - (inputnode, fsl2itk_inv, [('in_file', 'reference_file'), - ('t1w_brain', 'source_file')]), + (inputnode, mask_t1w_brain, [('t1w_preproc', 'in_file'), + ('t1w_mask', 'in_mask')]), + (inputnode, mri_coreg, [('in_file', 'source_file')]), + (inputnode, fsl2itk_fwd, [('in_file', 'source_file')]), + (inputnode, fsl2itk_inv, [('in_file', 'reference_file')]), + (mask_t1w_brain, mri_coreg, [('out_file', 'reference_file')]), + (mask_t1w_brain, fsl2itk_fwd, [('out_file', 'reference_file')]), + (mask_t1w_brain, fsl2itk_inv, [('out_file', 'source_file')]), (mri_coreg, lta_to_fsl, [('out_lta_file', 'in_lta')]), (invt_bbr, fsl2itk_inv, [('out_file', 'transform_file')]), (fsl2itk_fwd, outputnode, [('itk_transform', 'itk_bold_to_t1')]),