Skip to content

Commit

Permalink
fix: ME | Revise SDC compute graph
Browse files Browse the repository at this point in the history
Although I brought up the issue within #2530 and got some mildly opposed initial
opinion from @effigies
(#2530 (comment)),
I've come to think that we should provide the T2star workflow with
HMC'ed and SDC'ed echos (confirmation awaiting:
#2608 (review)).

This comes as an issue related to #2606.

This PR proposes that individual echoes are HMC'ed (and SDC'ed when
fieldmaps are available) before calculating the optimal combination
and the T2star map.

I believe this may be beneficial when we combine SDC with modulation by
the Jacobian of the distortion (nipreps/sdcflows#238) because that might
help restore some (little, admittedly) of the dropout of the later
echoes in distorted regions. I would expect more voxels will be deemed
as acceptable for the exponential fitting for this reason.

It also conceptually simplifies a little, as both SE and ME paths look
more alike, and only the little hacks to generate ME iterables and the
``boldbuffer`` are now necessary. Otherwise, SDC would be inserted at a
much later stage for ME only.
  • Loading branch information
oesteban committed Oct 20, 2021
1 parent a9b3502 commit 0ad307b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 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 @@ -999,9 +1000,6 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
]),
] 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, [
Expand Down Expand Up @@ -1087,6 +1085,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,12 +1096,11 @@ 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"),
]),
Expand All @@ -1111,15 +1110,15 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
if not multiecho:
# fmt:off
workflow.connect([
(bold_split, unwarp_wf, [
("out_files", "inputnode.distorted")]),
(unwarp_wf, bold_final, [("outputnode.corrected", "bold")]),
])
# fmt:on
else:
# fmt:off
workflow.connect([
(split_opt_comb, unwarp_wf, [
("out_files", "inputnode.distorted")])
(unwarp_wf, join_echos, [
("outputnode.outputnode", "bold_files"),
]),
])
# fmt:on

Expand Down

0 comments on commit 0ad307b

Please sign in to comment.