Skip to content

Commit

Permalink
gradunwarp to resampling: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cneuromod_bot committed Aug 1, 2023
1 parent c7b366b commit 71845e5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 1 addition & 3 deletions fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ def _slice_time_ref(value, parser):
g_conf.add_argument(
"--gradunwarp-file",
metavar="PATH",
type=Path,
help="Path to vendor file for gradunwarp gradient distortion "
"correction.",
help="Path to vendor file for gradunwarp gradient distortion correction.",
)
g_conf.add_argument(
"--output-spaces",
Expand Down
1 change: 1 addition & 0 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def init_single_subject_wf(subject_id: str):
spaces=spaces,
t1w=subject_data['t1w'],
t2w=subject_data['t2w'],
flair=subject_data['flair'],
gradunwarp_file=config.workflow.gradunwarp_file,
cifti_output=config.workflow.cifti_output,
)
Expand Down
16 changes: 12 additions & 4 deletions fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,13 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
# Gradient unwarping
if config.workflow.gradunwarp_file:
gradunwarp_wf = init_gradunwarp_wf()
gradunwarp_wf.inputs.inputnode.grad_file = gradunwarp_file
workflow.connect(
[(initial_boldref_wf, gradunwarp_wf, [('raw_ref_image', 'in_file')])]
)
gradunwarp_wf.inputs.inputnode.grad_file = config.workflow.gradunwarp_file
# input corrected file, raw not necessary, only uses acquisition matrix size
# unless mask/ref are used for sdcflows
workflow.connect([
(initial_boldref_wf, gradunwarp_wf, [
('outputnode.raw_ref_image', 'inputnode.input_file')]),
])

# HMC on the BOLD
bold_hmc_wf = init_bold_hmc_wf(
Expand Down Expand Up @@ -649,6 +652,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
("mask", "inputnode.ref_bold_mask"),
("boldref", "inputnode.ref_bold_brain"),
]),
(gradunwarp_wf, bold_t1_trans_wf, [('outputnode.warp_file', 'inputnode.gradient_warp')]),
(bold_t1_trans_wf, outputnode, [
("outputnode.bold_t1", "bold_t1"),
("outputnode.bold_t1_ref", "bold_t1_ref"),
Expand Down Expand Up @@ -814,6 +818,9 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
("outputnode.bold_std_ref", "bold_std_ref"),
("outputnode.bold_mask_std", "bold_mask_std"),
]),
(gradunwarp_wf, bold_std_trans_wf, [
('outputnode.warp_file', 'inputnode.gradient_warp')
]),
])
# fmt:on

Expand Down Expand Up @@ -1033,6 +1040,7 @@ def _last(inlist):
(bold_hmc_wf, bold_bold_trans_wf, [
("outputnode.xforms", "inputnode.hmc_xforms"),
]),
(gradunwarp_wf, bold_bold_trans_wf, [('outputnode.warp_file', 'inputnode.gradient_warp')]),
])

workflow.connect([
Expand Down
4 changes: 3 additions & 1 deletion fmriprep/workflows/bold/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def init_bold_t1_trans_wf(
't1w_aparc',
'bold_split',
'fieldwarp',
'gradient_warp',
'hmc_xforms',
'itk_bold_to_t1',
]
Expand Down Expand Up @@ -400,7 +401,7 @@ def init_bold_t1_trans_wf(

# Merge transforms placing the head motion correction last
merge_xforms = pe.Node(
niu.Merge(3),
niu.Merge(4),
name='merge_xforms',
run_without_submitting=True,
mem_gb=DEFAULT_MEMORY_MIN_GB,
Expand All @@ -409,6 +410,7 @@ def init_bold_t1_trans_wf(
workflow.connect([
(inputnode, merge, [('name_source', 'header_source')]),
(inputnode, merge_xforms, [
('fieldwarp', 'in4'), # May be 'identity' if no gradunwarp applied
('hmc_xforms', 'in3'), # May be 'identity' if HMC already applied
('fieldwarp', 'in2'), # May be 'identity' if SDC already applied
('itk_bold_to_t1', 'in1')]),
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/bold/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ def init_bold_preproc_trans_wf(
)

merge_xforms = pe.Node(
niu.Merge(2),
niu.Merge(3),
name="merge_xforms",
run_without_submitting=True,
mem_gb=DEFAULT_MEMORY_MIN_GB,
Expand Down

0 comments on commit 71845e5

Please sign in to comment.