diff --git a/fmriprep/workflows/bold/apply.py b/fmriprep/workflows/bold/apply.py index 5dd1baf66..38f8a2db0 100644 --- a/fmriprep/workflows/bold/apply.py +++ b/fmriprep/workflows/bold/apply.py @@ -80,6 +80,9 @@ def init_bold_volumetric_resample_wf( ------- bold_file The ``bold_file`` input, resampled to ``target_ref_file`` space. + resampling_reference + An empty reference image with the correct affine and header for resampling + further images into the BOLD series' space. """ workflow = pe.Workflow(name=name) @@ -102,12 +105,17 @@ def init_bold_volumetric_resample_wf( "boldref2anat_xfm", # Template "anat2std_xfm", + # Entity for selecting target resolution + "resolution", ], ), name='inputnode', ) - outputnode = pe.Node(niu.IdentityInterface(fields=["bold_file"]), name='outputnode') + outputnode = pe.Node( + niu.IdentityInterface(fields=["bold_file", "resampling_reference"]), + name='outputnode', + ) gen_ref = pe.Node(GenerateSamplingReference(), name='gen_ref', mem_gb=0.3) @@ -120,6 +128,7 @@ def init_bold_volumetric_resample_wf( ('bold_ref_file', 'moving_image'), ('target_ref_file', 'fixed_image'), ('target_mask', 'fov_mask'), + (('resolution', _is_native), 'keep_native'), ]), (inputnode, boldref2target, [ ('boldref2anat_xfm', 'in1'), @@ -130,6 +139,7 @@ def init_bold_volumetric_resample_wf( (gen_ref, resample, [('out_file', 'ref_file')]), (boldref2target, bold2target, [('out', 'in2')]), (bold2target, resample, [('out', 'transforms')]), + (gen_ref, outputnode, [('out_file', 'resampling_reference')]), (resample, outputnode, [('out_file', 'bold_file')]), ]) # fmt:skip @@ -190,3 +200,7 @@ def _gen_inverses(inlist: list) -> list[bool]: if not inlist: return [True] return [True] + [False] * len(listify(inlist)) + + +def _is_native(value): + return value == "native" diff --git a/fmriprep/workflows/bold/base.py b/fmriprep/workflows/bold/base.py index 6a3f43099..c0bcb9f00 100644 --- a/fmriprep/workflows/bold/base.py +++ b/fmriprep/workflows/bold/base.py @@ -426,16 +426,16 @@ def init_bold_wf( ds_bold_t1_wf.inputs.inputnode.space = 'T1w' workflow.connect([ - (inputnode, ds_bold_t1_wf, [ - ('t1w_preproc', 'inputnode.ref_file'), - ]), (bold_fit_wf, ds_bold_t1_wf, [ ('outputnode.bold_mask', 'inputnode.bold_mask'), ('outputnode.coreg_boldref', 'inputnode.bold_ref'), ('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'), ]), (bold_native_wf, ds_bold_t1_wf, [('outputnode.t2star_map', 'inputnode.t2star')]), - (bold_anat_wf, ds_bold_t1_wf, [('outputnode.bold_file', 'inputnode.bold')]), + (bold_anat_wf, ds_bold_t1_wf, [ + ('outputnode.bold_file', 'inputnode.bold'), + ('outputnode.resampling_reference', 'inputnode.ref_file'), + ]), ]) # fmt:skip if spaces.cached.get_spaces(nonstandard=False, dim=(3,)): @@ -462,6 +462,7 @@ def init_bold_wf( ("std_t1w", "inputnode.target_ref_file"), ("std_mask", "inputnode.target_mask"), ("anat2std_xfm", "inputnode.anat2std_xfm"), + ('std_resolution', 'inputnode.resolution'), ("fmap_ref", "inputnode.fmap_ref"), ("fmap_coeff", "inputnode.fmap_coeff"), ("fmap_id", "inputnode.fmap_id"), @@ -476,7 +477,6 @@ def init_bold_wf( ("outputnode.motion_xfm", "inputnode.motion_xfm"), ]), (inputnode, ds_bold_std_wf, [ - ('std_t1w', 'inputnode.ref_file'), ('anat2std_xfm', 'inputnode.anat2std_xfm'), ('std_space', 'inputnode.space'), ('std_resolution', 'inputnode.resolution'), @@ -488,7 +488,10 @@ def init_bold_wf( ('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'), ]), (bold_native_wf, ds_bold_std_wf, [('outputnode.t2star_map', 'inputnode.t2star')]), - (bold_std_wf, ds_bold_std_wf, [('outputnode.bold_file', 'inputnode.bold')]), + (bold_std_wf, ds_bold_std_wf, [ + ('outputnode.bold_file', 'inputnode.bold'), + ('outputnode.resampling_reference', 'inputnode.ref_file'), + ]), ]) # fmt:skip if config.workflow.run_reconall and freesurfer_spaces: