Skip to content

Commit 5a08a86

Browse files
committed
enh: finalize connections and generate reports
1 parent fcf5654 commit 5a08a86

File tree

3 files changed

+65
-11
lines changed

3 files changed

+65
-11
lines changed

dmriprep/config/reports-spec.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,30 @@ sections:
2727
overlaid on the participant's T1w template.
2828
subtitle: Surface reconstruction
2929
- name: Fieldmaps
30-
ordering: session,run
30+
ordering: session,run,fmapid
3131
reportlets:
32+
- bids: {datatype: figures, desc: mapped, suffix: fieldmap}
33+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
34+
along the phase-encoding direction of the image. Some scanners produce a <em>B<sub>0</sub></em>
35+
mapping of the field, using Spiral Echo Imaging (SEI) or postprocessing a "phase-difference"
36+
acquisition. The plot below shows an anatomical "magnitude" reference and the corresponding
37+
fieldmap.
38+
description: Hover on the panels with the mouse pointer to also visualize the intensity of the
39+
inhomogeneity of the field in Hertz.
40+
static: false
41+
subtitle: "Susceptibility-derived Distortion Correction (SDC): field inhomogeneity estimation"
42+
- bids: {datatype: figures, desc: phasediff, suffix: fieldmap}
43+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
44+
along the phase-encoding direction of the image. A Gradient-Recalled Echo scheme for the
45+
mapping of the <em>B<sub>0</sub></em> inhomogeneities by subtracting the phase maps obtained at
46+
two subsequent echoes. The plot below shows an anatomical "magnitude" reference and the corresponding
47+
fieldmap.
48+
description: Hover on the panels with the mouse pointer to also visualize the intensity of the
49+
inhomogeneity of the field in Hertz.
50+
static: false
51+
subtitle: "Susceptibility-derived Distortion Correction (SDC): field inhomogeneity estimation"
3252
- bids: {datatype: figures, desc: pepolar, suffix: fieldmap}
33-
caption: Inhomogeneities of the *B0* field introduce (oftentimes severe) spatial distortions
53+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
3454
along the phase-encoding direction of the image. Utilizing two or more images with different
3555
phase-encoding polarities (PEPolar) or directions, it is possible to estimate the inhomogeneity
3656
of the field. The plot below shows a reference EPI (echo-planar imaging) volume generated
@@ -44,11 +64,16 @@ sections:
4464
reportlets:
4565
- bids: {datatype: figures, desc: validation, suffix: dwi}
4666
- bids: {datatype: figures, desc: brain, suffix: mask}
47-
caption: Average b=0 that serves for reference in early preprocessing steps.
48-
descriptions: The reference b=0 is obtained as the voxel-wise median across
49-
all b=0 found in the dataset, after accounting for signal drift.
50-
The red contour shows the brain mask calculated using this reference b=0.
51-
subtitle: Reference b=0 and brain mask
67+
caption: Average <em>b=0</em> that serves for reference in early preprocessing steps.
68+
descriptions: The reference <em>b=0</em> is obtained as the voxel-wise median across
69+
all <em>b=0</em> found in the dataset, after accounting for signal drift.
70+
The red contour shows the brain mask calculated using this reference <em>b=0</em>.
71+
subtitle: Reference <em>b=0</em> and brain mask
72+
- bids: {datatype: figures, desc: sdc, suffix: dwi}
73+
caption: Susceptibility distortions correction (SDC).
74+
description: The reportlet shows a <em>b=0</em> reference <em>before</em> and <em>after</em> correction.
75+
static: false
76+
subtitle: Unwarping of susceptibility distortions
5277
- bids: {datatype: figures, desc: coreg, suffix: dwi}
5378
caption: Diffusion-weighted data and anatomical data (EPI-space and T1w-space)
5479
were aligned with <code>mri_coreg</code> (FreeSurfer).

dmriprep/workflows/dwi/base.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ def _bold_reg_suffix(fallback):
202202
# fmt: on
203203

204204
# REPORTING ############################################################
205-
reportlets_wf = init_reportlets_wf(str(config.execution.output_dir))
205+
reportlets_wf = init_reportlets_wf(
206+
str(config.execution.output_dir),
207+
sdc_report=has_fieldmap,
208+
)
206209
# fmt: off
207210
workflow.connect([
208211
(inputnode, reportlets_wf, [("dwi_file", "inputnode.source_file")]),
@@ -225,6 +228,7 @@ def _bold_reg_suffix(fallback):
225228
# fmt: on
226229
return workflow
227230

231+
from niworkflows.interfaces import SimpleBeforeAfter
228232
from niworkflows.interfaces.utility import KeySelect
229233
from sdcflows.workflows.apply.registration import init_coeff2epi_wf
230234
from sdcflows.workflows.apply.correction import init_unwarp_wf
@@ -252,6 +256,12 @@ def _bold_reg_suffix(fallback):
252256
f"'IntendedFor' <{dwi_file}>, using {estimator_key[0]}"
253257
)
254258

259+
sdc_report = pe.Node(
260+
SimpleBeforeAfter(before_label="Distorted", after_label="Corrected",),
261+
name="sdc_report",
262+
mem_gb=0.1,
263+
)
264+
255265
# fmt: off
256266
workflow.connect([
257267
(inputnode, output_select, [("fmap", "fmap"),
@@ -269,7 +279,12 @@ def _bold_reg_suffix(fallback):
269279
(dwi_reference_wf, unwarp_wf, [("outputnode.ref_image", "inputnode.distorted")]),
270280
(coeff2epi_wf, unwarp_wf, [
271281
("outputnode.fmap_coeff", "inputnode.fmap_coeff")]),
272-
(unwarp_wf, outputnode, [("outputnode.corrected", "dwi_reference")]),
282+
(dwi_reference_wf, sdc_report, [("outputnode.ref_image", "before")]),
283+
(unwarp_wf, sdc_report, [("outputnode.corrected", "after"),
284+
("outputnode.corrected_mask", "wm_seg")]),
285+
(sdc_report, reportlets_wf, [("out_report", "inputnode.sdc_report")]),
286+
(unwarp_wf, outputnode, [("outputnode.corrected", "dwi_reference"),
287+
("outputnode.corrected_mask", "dwi_mask")]),
273288
])
274289
# fmt: on
275290

dmriprep/workflows/dwi/outputs.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from ...interfaces import DerivativesDataSink
66

77

8-
def init_reportlets_wf(output_dir, name="reportlets_wf"):
8+
def init_reportlets_wf(output_dir, sdc_report=False, name="reportlets_wf"):
99
"""Set up a battery of datasinks to store reports in the right location."""
1010
from niworkflows.interfaces.masks import SimpleShowMaskRPT
1111

1212
workflow = Workflow(name=name)
1313

1414
inputnode = pe.Node(
1515
niu.IdentityInterface(
16-
fields=["source_file", "dwi_ref", "dwi_mask", "validation_report"]
16+
fields=["source_file", "dwi_ref", "dwi_mask", "validation_report", "sdc_report"]
1717
),
1818
name="inputnode",
1919
)
@@ -44,4 +44,18 @@ def init_reportlets_wf(output_dir, name="reportlets_wf"):
4444
(mask_reportlet, ds_report_mask, [("out_report", "in_file")]),
4545
])
4646
# fmt:on
47+
if sdc_report:
48+
ds_report_sdc = pe.Node(
49+
DerivativesDataSink(
50+
base_directory=output_dir, desc="sdc", suffix="dwi", datatype="figures"
51+
),
52+
name="ds_report_sdc",
53+
run_without_submitting=True,
54+
)
55+
# fmt:off
56+
workflow.connect([
57+
(inputnode, ds_report_sdc, [("source_file", "source_file"),
58+
("sdc_report", "in_file")]),
59+
])
60+
# fmt:on
4761
return workflow

0 commit comments

Comments
 (0)