Skip to content

Commit 4647b6e

Browse files
committed
FIX: Correctly generate resampling reference, pass to downstream resamplers
1 parent b323eb0 commit 4647b6e

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

fmriprep/workflows/bold/apply.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def init_bold_volumetric_resample_wf(
8080
-------
8181
bold_file
8282
The ``bold_file`` input, resampled to ``target_ref_file`` space.
83+
resampling_reference
84+
An empty reference image with the correct affine and header for resampling
85+
further images into the BOLD series' space.
8386
8487
"""
8588
workflow = pe.Workflow(name=name)
@@ -102,12 +105,17 @@ def init_bold_volumetric_resample_wf(
102105
"boldref2anat_xfm",
103106
# Template
104107
"anat2std_xfm",
108+
# Entity for selecting target resolution
109+
"resolution",
105110
],
106111
),
107112
name='inputnode',
108113
)
109114

110-
outputnode = pe.Node(niu.IdentityInterface(fields=["bold_file"]), name='outputnode')
115+
outputnode = pe.Node(
116+
niu.IdentityInterface(fields=["bold_file", "resampling_reference"]),
117+
name='outputnode',
118+
)
111119

112120
gen_ref = pe.Node(GenerateSamplingReference(), name='gen_ref', mem_gb=0.3)
113121

@@ -120,6 +128,7 @@ def init_bold_volumetric_resample_wf(
120128
('bold_ref_file', 'moving_image'),
121129
('target_ref_file', 'fixed_image'),
122130
('target_mask', 'fov_mask'),
131+
(('resolution', _is_native), 'keep_native'),
123132
]),
124133
(inputnode, boldref2target, [
125134
('boldref2anat_xfm', 'in1'),
@@ -130,6 +139,7 @@ def init_bold_volumetric_resample_wf(
130139
(gen_ref, resample, [('out_file', 'ref_file')]),
131140
(boldref2target, bold2target, [('out', 'in2')]),
132141
(bold2target, resample, [('out', 'transforms')]),
142+
(gen_ref, outputnode, [('out_file', 'resampling_reference')]),
133143
(resample, outputnode, [('out_file', 'bold_file')]),
134144
]) # fmt:skip
135145

@@ -190,3 +200,7 @@ def _gen_inverses(inlist: list) -> list[bool]:
190200
if not inlist:
191201
return [True]
192202
return [True] + [False] * len(listify(inlist))
203+
204+
205+
def _is_native(value):
206+
return value == "native"

fmriprep/workflows/bold/base.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,16 @@ def init_bold_wf(
426426
ds_bold_t1_wf.inputs.inputnode.space = 'T1w'
427427

428428
workflow.connect([
429-
(inputnode, ds_bold_t1_wf, [
430-
('t1w_preproc', 'inputnode.ref_file'),
431-
]),
432429
(bold_fit_wf, ds_bold_t1_wf, [
433430
('outputnode.bold_mask', 'inputnode.bold_mask'),
434431
('outputnode.coreg_boldref', 'inputnode.bold_ref'),
435432
('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
436433
]),
437434
(bold_native_wf, ds_bold_t1_wf, [('outputnode.t2star_map', 'inputnode.t2star')]),
438-
(bold_anat_wf, ds_bold_t1_wf, [('outputnode.bold_file', 'inputnode.bold')]),
435+
(bold_anat_wf, ds_bold_t1_wf, [
436+
('outputnode.bold_file', 'inputnode.bold'),
437+
('outputnode.resampling_reference', 'inputnode.ref_file'),
438+
]),
439439
]) # fmt:skip
440440

441441
if spaces.cached.get_spaces(nonstandard=False, dim=(3,)):
@@ -462,6 +462,7 @@ def init_bold_wf(
462462
("std_t1w", "inputnode.target_ref_file"),
463463
("std_mask", "inputnode.target_mask"),
464464
("anat2std_xfm", "inputnode.anat2std_xfm"),
465+
('std_resolution', 'inputnode.resolution'),
465466
("fmap_ref", "inputnode.fmap_ref"),
466467
("fmap_coeff", "inputnode.fmap_coeff"),
467468
("fmap_id", "inputnode.fmap_id"),
@@ -476,7 +477,6 @@ def init_bold_wf(
476477
("outputnode.motion_xfm", "inputnode.motion_xfm"),
477478
]),
478479
(inputnode, ds_bold_std_wf, [
479-
('std_t1w', 'inputnode.ref_file'),
480480
('anat2std_xfm', 'inputnode.anat2std_xfm'),
481481
('std_space', 'inputnode.space'),
482482
('std_resolution', 'inputnode.resolution'),
@@ -488,7 +488,10 @@ def init_bold_wf(
488488
('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
489489
]),
490490
(bold_native_wf, ds_bold_std_wf, [('outputnode.t2star_map', 'inputnode.t2star')]),
491-
(bold_std_wf, ds_bold_std_wf, [('outputnode.bold_file', 'inputnode.bold')]),
491+
(bold_std_wf, ds_bold_std_wf, [
492+
('outputnode.bold_file', 'inputnode.bold'),
493+
('outputnode.resampling_reference', 'inputnode.ref_file'),
494+
]),
492495
]) # fmt:skip
493496

494497
if config.workflow.run_reconall and freesurfer_spaces:

0 commit comments

Comments
 (0)