Skip to content

Commit 9e0379b

Browse files
slimnsouroesteban
authored andcommitted
Added default trt fallback and eddy reportlet
1 parent fa11357 commit 9e0379b

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

dmriprep/workflows/dwi/base.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
6969
7070
"""
7171
from ...interfaces.vectors import CheckGradientTable
72+
from niworkflows.interfaces import SimpleBeforeAfter
7273
from .util import init_dwi_reference_wf
7374
from .outputs import init_reportlets_wf
7475
from .eddy import init_eddy_wf
@@ -205,6 +206,23 @@ def _bold_reg_suffix(fallback):
205206
# Eddy distortion correction
206207
eddy_wf = init_eddy_wf(debug=config.execution.debug)
207208
eddy_wf.inputs.inputnode.metadata = layout.get_metadata(str(dwi_file))
209+
210+
ds_report_eddy = pe.Node(
211+
DerivativesDataSink(
212+
base_directory=str(config.execution.output_dir),
213+
desc="eddy_corrected",
214+
datatype="figures",
215+
),
216+
name="ds_report_eddy",
217+
run_without_submitting=True,
218+
)
219+
220+
eddy_report = pe.Node(
221+
SimpleBeforeAfter(before_label="Distorted", after_label="Eddy Corrected",),
222+
name="eddy_report",
223+
mem_gb=0.1,
224+
)
225+
208226
# fmt:off
209227
workflow.connect([
210228
(dwi_reference_wf, eddy_wf, [
@@ -215,6 +233,10 @@ def _bold_reg_suffix(fallback):
215233
("in_bvec", "inputnode.in_bvec"),
216234
("in_bval", "inputnode.in_bval")
217235
]),
236+
(dwi_reference_wf, eddy_report, [("outputnode.dwi_file", "before")]),
237+
(eddy_wf, eddy_report, [('outputnode.out_eddy', 'after')]),
238+
(dwi_reference_wf, ds_report_eddy, [("outputnode.dwi_file", "source_file")]),
239+
(eddy_report, ds_report_eddy, [("out_report", "in_file")]),
218240
])
219241
# fmt:on
220242

dmriprep/workflows/dwi/eddy.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,18 @@ def gen_eddy_textfiles(in_file, in_meta):
4343
fsl_pe["ijk".index(pe_dir[0])] = "-1" if pe_dir.endswith("-") else "1"
4444

4545
# Write to the acqp file
46-
Path(out_acqparams).write_text(
47-
f"{' '.join(fsl_pe)} {get_trt(in_meta, in_file=in_file):0.7f}"
48-
)
46+
try:
47+
Path(out_acqparams).write_text(
48+
f"{' '.join(fsl_pe)} {get_trt(in_meta, in_file=in_file):0.7f}"
49+
)
50+
except ValueError:
51+
config.loggers.workflow.warning(
52+
f"'TotalReadoutTime' not found for <{dwi_file}>, using"
53+
f"a default value of 0.05 instead."
54+
)
55+
Path(out_acqparams).write_text(
56+
f"{' '.join(fsl_pe)} {0.05}"
57+
)
4958

5059
out_index = fname_presuffix(in_file, suffix="_index.txt", use_ext=False,)
5160
Path(out_index).write_text(f"{' '.join(['1'] * nb.load(in_file).shape[3])}")

0 commit comments

Comments
 (0)