Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: ME | Revise SDC compute graph #2610

Merged
merged 10 commits into from
Oct 22, 2021
72 changes: 28 additions & 44 deletions fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,15 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
(meepi_echos, bold_stc_wf, [("bold_file", "inputnode.bold_file")]),
])
# fmt:on
elif not multiecho: # STC is too short or False

# bypass STC from original BOLD in both SE and ME cases
elif not multiecho: # SE and skip-STC
# fmt:off
# bypass STC from original BOLD to the splitter through boldbuffer
workflow.connect([
(initial_boldref_wf, boldbuffer, [("outputnode.bold_file", "bold_file")]),
])
# fmt:on
else:
else: # ME and skip-STC
# for meepi, iterate over all meepi echos to boldbuffer
boldbuffer.iterables = ("bold_file", bold_file)

Expand Down Expand Up @@ -640,9 +641,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
(join_echos, bold_t2s_wf, [("bold_files", "inputnode.bold_file")]),
(bold_t2s_wf, split_opt_comb, [("outputnode.bold", "in_file")]),
(split_opt_comb, bold_t1_trans_wf, [("out_files", "inputnode.bold_split")]),
(bold_t2s_wf, bold_final, [
("outputnode.bold", "bold"),
]),
(bold_t2s_wf, bold_final, [("outputnode.bold", "bold")]),
])
# fmt:on

Expand Down Expand Up @@ -985,30 +984,22 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
(bold_hmc_wf, bold_bold_trans_wf, [
("outputnode.xforms", "inputnode.hmc_xforms"),
]),
(bold_bold_trans_wf, final_boldref_wf, [
("outputnode.bold", "inputnode.bold_file"),
]),
oesteban marked this conversation as resolved.
Show resolved Hide resolved
])
# fmt:on

# fmt:off
workflow.connect(
[
(bold_bold_trans_wf, final_boldref_wf, [
("outputnode.bold", "inputnode.bold_file"),
]),
(bold_bold_trans_wf, bold_final, [
("outputnode.bold", "bold"),
]),
] if not multiecho
else [
(bold_bold_trans_wf, join_echos, [
("outputnode.bold", "bold_files"),
]),
(join_echos, final_boldref_wf, [("bold_files", "inputnode.bold_file")]),
# use reference image mask used by bold_bold_trans_wf
(bold_bold_trans_wf, bold_t2s_wf, [
(("outputnode.bold_mask", pop_file), "inputnode.bold_mask"),
]),
]
)
workflow.connect([
(bold_bold_trans_wf, bold_final, [("outputnode.bold", "bold")]),
] if not multiecho else [
(bold_bold_trans_wf, join_echos, [("outputnode.bold", "bold_files")]),
# use reference image mask used by bold_bold_trans_wf
(bold_bold_trans_wf, bold_t2s_wf, [
(("outputnode.bold_mask", pop_file), "inputnode.bold_mask"),
]),
])
# fmt:on
return workflow

Expand Down Expand Up @@ -1087,6 +1078,8 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
("outputnode.xforms", "inputnode.hmc_xforms")]),
(initial_boldref_wf, sdc_report, [
("outputnode.ref_image", "before")]),
(bold_split, unwarp_wf, [
("out_files", "inputnode.distorted")]),
(unwarp_wf, final_boldref_wf, [
("outputnode.corrected_ref", "inputnode.bold_file"),
]),
Expand All @@ -1096,32 +1089,23 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
(inputnode, ds_report_sdc, [("bold_file", "source_file")]),
(sdc_report, ds_report_sdc, [("out_report", "in_file")]),
# remaining workflow connections
(unwarp_wf, bold_std_trans_wf, [
(unwarp_wf, bold_t1_trans_wf, [
# TEMPORARY: For the moment we can't use frame-wise fieldmaps
(("outputnode.fieldwarp", _pop), "inputnode.fieldwarp"),
]),
(unwarp_wf, bold_final, [("outputnode.corrected", "bold")]),
(unwarp_wf, bold_t1_trans_wf, [
(unwarp_wf, bold_std_trans_wf, [
# TEMPORARY: For the moment we can't use frame-wise fieldmaps
(("outputnode.fieldwarp", _pop), "inputnode.fieldwarp"),
]),
])
# fmt:on

if not multiecho:
# fmt:off
workflow.connect([
(bold_split, unwarp_wf, [
("out_files", "inputnode.distorted")]),
])
# fmt:on
else:
# fmt:off
workflow.connect([
(split_opt_comb, unwarp_wf, [
("out_files", "inputnode.distorted")])
])
# fmt:on
# Connect corrected ouputs depending on whether it is SE or ME
workflow.connect([
(unwarp_wf, bold_final, [("outputnode.corrected", "bold")]),
] if not multiecho else [
(unwarp_wf, join_echos, [("outputnode.corrected", "bold_files")]),
])
# fmt:on

return workflow

Expand Down