Skip to content

Commit 71845e5

Browse files
author
cneuromod_bot
committed
gradunwarp to resampling: wip
1 parent c7b366b commit 71845e5

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

fmriprep/cli/parser.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,7 @@ def _slice_time_ref(value, parser):
282282
g_conf.add_argument(
283283
"--gradunwarp-file",
284284
metavar="PATH",
285-
type=Path,
286-
help="Path to vendor file for gradunwarp gradient distortion "
287-
"correction.",
285+
help="Path to vendor file for gradunwarp gradient distortion correction.",
288286
)
289287
g_conf.add_argument(
290288
"--output-spaces",

fmriprep/workflows/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ def init_single_subject_wf(subject_id: str):
319319
spaces=spaces,
320320
t1w=subject_data['t1w'],
321321
t2w=subject_data['t2w'],
322+
flair=subject_data['flair'],
322323
gradunwarp_file=config.workflow.gradunwarp_file,
323324
cifti_output=config.workflow.cifti_output,
324325
)

fmriprep/workflows/bold/base.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,13 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
484484
# Gradient unwarping
485485
if config.workflow.gradunwarp_file:
486486
gradunwarp_wf = init_gradunwarp_wf()
487-
gradunwarp_wf.inputs.inputnode.grad_file = gradunwarp_file
488-
workflow.connect(
489-
[(initial_boldref_wf, gradunwarp_wf, [('raw_ref_image', 'in_file')])]
490-
)
487+
gradunwarp_wf.inputs.inputnode.grad_file = config.workflow.gradunwarp_file
488+
# input corrected file, raw not necessary, only uses acquisition matrix size
489+
# unless mask/ref are used for sdcflows
490+
workflow.connect([
491+
(initial_boldref_wf, gradunwarp_wf, [
492+
('outputnode.raw_ref_image', 'inputnode.input_file')]),
493+
])
491494

492495
# HMC on the BOLD
493496
bold_hmc_wf = init_bold_hmc_wf(
@@ -649,6 +652,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
649652
("mask", "inputnode.ref_bold_mask"),
650653
("boldref", "inputnode.ref_bold_brain"),
651654
]),
655+
(gradunwarp_wf, bold_t1_trans_wf, [('outputnode.warp_file', 'inputnode.gradient_warp')]),
652656
(bold_t1_trans_wf, outputnode, [
653657
("outputnode.bold_t1", "bold_t1"),
654658
("outputnode.bold_t1_ref", "bold_t1_ref"),
@@ -814,6 +818,9 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
814818
("outputnode.bold_std_ref", "bold_std_ref"),
815819
("outputnode.bold_mask_std", "bold_mask_std"),
816820
]),
821+
(gradunwarp_wf, bold_std_trans_wf, [
822+
('outputnode.warp_file', 'inputnode.gradient_warp')
823+
]),
817824
])
818825
# fmt:on
819826

@@ -1033,6 +1040,7 @@ def _last(inlist):
10331040
(bold_hmc_wf, bold_bold_trans_wf, [
10341041
("outputnode.xforms", "inputnode.hmc_xforms"),
10351042
]),
1043+
(gradunwarp_wf, bold_bold_trans_wf, [('outputnode.warp_file', 'inputnode.gradient_warp')]),
10361044
])
10371045

10381046
workflow.connect([

fmriprep/workflows/bold/registration.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ def init_bold_t1_trans_wf(
325325
't1w_aparc',
326326
'bold_split',
327327
'fieldwarp',
328+
'gradient_warp',
328329
'hmc_xforms',
329330
'itk_bold_to_t1',
330331
]
@@ -400,7 +401,7 @@ def init_bold_t1_trans_wf(
400401

401402
# Merge transforms placing the head motion correction last
402403
merge_xforms = pe.Node(
403-
niu.Merge(3),
404+
niu.Merge(4),
404405
name='merge_xforms',
405406
run_without_submitting=True,
406407
mem_gb=DEFAULT_MEMORY_MIN_GB,
@@ -409,6 +410,7 @@ def init_bold_t1_trans_wf(
409410
workflow.connect([
410411
(inputnode, merge, [('name_source', 'header_source')]),
411412
(inputnode, merge_xforms, [
413+
('fieldwarp', 'in4'), # May be 'identity' if no gradunwarp applied
412414
('hmc_xforms', 'in3'), # May be 'identity' if HMC already applied
413415
('fieldwarp', 'in2'), # May be 'identity' if SDC already applied
414416
('itk_bold_to_t1', 'in1')]),

fmriprep/workflows/bold/resampling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ def init_bold_preproc_trans_wf(
11841184
)
11851185

11861186
merge_xforms = pe.Node(
1187-
niu.Merge(2),
1187+
niu.Merge(3),
11881188
name="merge_xforms",
11891189
run_without_submitting=True,
11901190
mem_gb=DEFAULT_MEMORY_MIN_GB,

0 commit comments

Comments
 (0)