Skip to content

Commit a99d9ec

Browse files
committed
ENH: Calculate fieldwarps in reference space in unwarp_wf
1 parent 8df8458 commit a99d9ec

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

sdcflows/workflows/apply/correction.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def init_unwarp_wf(*, free_mem=None, omp_nthreads=1, debug=False, name="unwarp_w
5151
------
5252
distorted
5353
the target EPI image.
54+
distorted_ref
55+
the distorted reference EPI image to which each volume has been motion corrected
5456
metadata
5557
dictionary of metadata corresponding to the target EPI image
5658
fmap_coeff
@@ -72,6 +74,16 @@ def init_unwarp_wf(*, free_mem=None, omp_nthreads=1, debug=False, name="unwarp_w
7274
the target EPI reference image, after applying unwarping.
7375
corrected_mask
7476
a fast mask calculated from the corrected EPI reference.
77+
fieldmap_ref
78+
the actual B\ :sub:`0` inhomogeneity map (also called *fieldmap*)
79+
interpolated from the B-Spline coefficients into the reference EPI's
80+
grid, given in Hz units.
81+
No motion is taken into account.
82+
fieldwarp_ref
83+
the displacements field interpolated from the B-Spline coefficients
84+
and scaled by the appropriate parameters (readout time of the EPI
85+
target and voxel size along PE).
86+
No motion is taken into account.
7587
7688
"""
7789
from niworkflows.interfaces.images import RobustAverage
@@ -84,7 +96,7 @@ def init_unwarp_wf(*, free_mem=None, omp_nthreads=1, debug=False, name="unwarp_w
8496
workflow = Workflow(name=name)
8597
inputnode = pe.Node(
8698
niu.IdentityInterface(
87-
fields=["distorted", "metadata", "fmap_coeff", "hmc_xforms"]
99+
fields=["distorted", "distorted_ref", "metadata", "fmap_coeff", "hmc_xforms"]
88100
),
89101
name="inputnode",
90102
)
@@ -96,6 +108,8 @@ def init_unwarp_wf(*, free_mem=None, omp_nthreads=1, debug=False, name="unwarp_w
96108
"corrected",
97109
"corrected_ref",
98110
"corrected_mask",
111+
"fieldwarp_ref",
112+
"fieldmap_ref",
99113
]
100114
),
101115
name="outputnode",
@@ -121,6 +135,8 @@ def init_unwarp_wf(*, free_mem=None, omp_nthreads=1, debug=False, name="unwarp_w
121135
name="resample",
122136
)
123137

138+
resample_ref = pe.Node(ApplyCoeffsField(), mem_gb=mem_per_thread, name="resample_ref")
139+
124140
merge = pe.Node(MergeSeries(), name="merge")
125141
average = pe.Node(RobustAverage(mc_method=None), name="average")
126142

@@ -135,12 +151,18 @@ def init_unwarp_wf(*, free_mem=None, omp_nthreads=1, debug=False, name="unwarp_w
135151
("hmc_xforms", "in_xfms")]),
136152
(rotime, resample, [("readout_time", "ro_time"),
137153
("pe_direction", "pe_dir")]),
154+
(inputnode, resample_ref, [("distorted_ref", "in_data"),
155+
("fmap_coeff", "in_coeff")]),
156+
(rotime, resample_ref, [("readout_time", "ro_time"),
157+
("pe_direction", "pe_dir")]),
138158
(resample, merge, [("out_corrected", "in_files")]),
139159
(merge, average, [("out_file", "in_file")]),
140160
(average, brainextraction_wf, [("out_file", "inputnode.in_file")]),
141161
(merge, outputnode, [("out_file", "corrected")]),
142162
(resample, outputnode, [("out_field", "fieldmap"),
143163
("out_warp", "fieldwarp")]),
164+
(resample_ref, outputnode, [("out_field", "fieldmap_ref"),
165+
("out_warp", "fieldwarp_ref")]),
144166
(brainextraction_wf, outputnode, [
145167
("outputnode.out_file", "corrected_ref"),
146168
("outputnode.out_mask", "corrected_mask"),

0 commit comments

Comments
 (0)