Skip to content

Commit f3e95d9

Browse files
celprovoestebaneffigies
authored
ENH: separate anatomical and functional reports per session for densely sampled dataset (#3191)
enh: beyond a certain number of session for a single subject (4), we separate the anatomical report from the functional and we separate the functional reports per session. For fewer sessions than 4, we keep the original behavior of aggregating all sessions and the anatomical in one report. enh: find the suitable bootstrapfile within generate_reports rather than before enh: add session_list argument to generate_reports Builds on top of #3177 Closes #3080 --------- Co-authored-by: Oscar Esteban <[email protected]> Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 4d21c37 commit f3e95d9

File tree

63 files changed

+1061
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1061
-29
lines changed

fmriprep/cli/parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ def _slice_time_ref(value, parser):
446446
help="Output individual echo time series with slice, motion and susceptibility "
447447
"correction. Useful for further Tedana processing post-fMRIPrep.",
448448
)
449+
g_outputs.add_argument(
450+
"--aggregate-session-reports",
451+
dest="aggr_ses_reports",
452+
action="store",
453+
type=PositiveInt,
454+
default=4,
455+
help="Maximum number of sessions aggregated in one subject's visual report. "
456+
"If exceeded, visual reports are split by session.",
457+
)
449458
g_outputs.add_argument(
450459
"--medial-surface-nan",
451460
required=False,

fmriprep/cli/run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ def main():
202202
_copy_any(dseg_tsv, str(config.execution.fmriprep_dir / "desc-aparcaseg_dseg.tsv"))
203203
errno = 0
204204
finally:
205-
from .. import data
206-
207205
# Code Carbon
208206
if config.execution.track_carbon:
209207
emissions: float = tracker.stop()
@@ -214,11 +212,15 @@ def main():
214212
from fmriprep.reports.core import generate_reports
215213

216214
# Generate reports phase
215+
session_list = (
216+
config.execution.get().get('bids_filters', {}).get("bold", {}).get("session")
217+
)
218+
217219
failed_reports = generate_reports(
218220
config.execution.participant_label,
219221
config.execution.fmriprep_dir,
220222
config.execution.run_uuid,
221-
config=data.load("reports-spec.yml"),
223+
session_list=session_list,
222224
)
223225
write_derivative_description(config.execution.bids_dir, config.execution.fmriprep_dir)
224226
write_bidsignore(config.execution.fmriprep_dir)

fmriprep/cli/workflow.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ def build_workflow(config_file, retval):
8686
# Called with reports only
8787
if config.execution.reports_only:
8888
build_log.log(25, "Running --reports-only on participants %s", ", ".join(subject_list))
89+
session_list = (
90+
config.execution.bids_filters.get("bold", {}).get("session")
91+
if config.execution.bids_filters
92+
else None
93+
)
94+
8995
failed_reports = generate_reports(
9096
config.execution.participant_label,
9197
config.execution.fmriprep_dir,
9298
config.execution.run_uuid,
93-
config=data.load("reports-spec.yml"),
99+
session_list=session_list,
94100
)
95101
if failed_reports:
96102
config.loggers.cli.error(

fmriprep/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ class execution(_Config):
417417
"""Folder where derivatives will be stored."""
418418
me_output_echos = False
419419
"""Output individual echo time series with slice, motion and susceptibility correction"""
420+
aggr_ses_reports = None
421+
"""Maximum number of sessions aggregated in one subject's visual report."""
420422
output_layout = None
421423
"""Layout of derivatives within output_dir."""
422424
output_spaces = None

fmriprep/data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
.. autoclass:: Loader
1212
"""
13+
1314
from __future__ import annotations
1415

1516
import atexit

fmriprep/data/reports-spec-anat.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package: fmriprep
2+
sections:
3+
- name: Summary
4+
reportlets:
5+
- bids: {datatype: figures, desc: summary, suffix: T1w}
6+
- name: Anatomical
7+
reportlets:
8+
- bids:
9+
datatype: figures
10+
desc: conform
11+
extension: [.html]
12+
suffix: T1w
13+
- bids: {datatype: figures, suffix: dseg}
14+
caption: This panel shows the final, preprocessed T1-weighted image,
15+
with contours delineating the detected brain mask and brain tissue segmentations.
16+
subtitle: Brain mask and brain tissue segmentation of the T1w
17+
- bids: {datatype: figures, space: .*, suffix: T1w, regex_search: True}
18+
caption: Spatial normalization of the T1w image to the <code>{space}</code> template.
19+
description: Results of nonlinear alignment of the T1w reference one or more template
20+
space(s). Hover on the panels with the mouse pointer to transition between both
21+
spaces.
22+
static: false
23+
subtitle: Spatial normalization of the anatomical T1w reference
24+
- bids: {datatype: figures, desc: reconall, suffix: T1w}
25+
caption: Surfaces (white and pial) reconstructed with FreeSurfer (<code>recon-all</code>)
26+
overlaid on the participant's T1w template.
27+
subtitle: Surface reconstruction
28+
- name: About
29+
reportlets:
30+
- bids: {datatype: figures, desc: about, suffix: T1w}
31+
- custom: boilerplate
32+
path: '{out_dir}/logs'
33+
bibfile: ['fmriprep', 'data/boilerplate.bib']
34+
caption: |
35+
<p>We kindly ask to report results preprocessed with this tool using the following boilerplate.</p>
36+
<p class="alert alert-info" role="alert">
37+
<strong>Copyright Waiver</strong>.
38+
The boilerplate text was automatically generated by <em>NiReports</em> with the
39+
express intention that users should copy and paste this text into their manuscripts <em>unchanged</em>.
40+
It is released under the
41+
<a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">CC0 license</a>.
42+
</p>
43+
title: Methods
44+
- custom: errors
45+
path: '{out_dir}/sub-{subject}/log/{run_uuid}'
46+
captions: <em>NiReports</em> may have recorded failure conditions.
47+
title: Errors

fmriprep/data/reports-spec-func.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
package: fmriprep
2+
sections:
3+
- name: Summary
4+
reportlets:
5+
- bids: {datatype: figures, desc: summary, suffix: T1w}
6+
- name: <em>B<sub>0</sub></em> field mapping
7+
ordering: session,acquisition,run,fmapid
8+
reportlets:
9+
- bids: {datatype: figures, desc: mapped, suffix: fieldmap}
10+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
11+
along the phase-encoding direction of the image. Some scanners produce a <em>B<sub>0</sub></em>
12+
mapping of the field, using Spiral Echo Imaging (SEI) or postprocessing a "phase-difference"
13+
acquisition. The plot below shows an anatomical "magnitude" reference and the corresponding
14+
fieldmap.
15+
description: Hover over the panels with the mouse pointer to also visualize the intensity of the
16+
field inhomogeneity in Hertz.
17+
static: false
18+
subtitle: "Preprocessed <em>B<sub>0</sub></em> mapping acquisition"
19+
- bids: {datatype: figures, desc: phasediff, suffix: fieldmap}
20+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
21+
along the phase-encoding direction of the image. A Gradient-Recalled Echo (GRE) scheme was included for the
22+
mapping of the <em>B<sub>0</sub></em> inhomogeneities by subtracting the phase maps obtained at
23+
two subsequent echoes. The plot below shows an anatomical "magnitude" reference and the corresponding
24+
fieldmap.
25+
description: Hover over the panels with the mouse pointer to also visualize the intensity of the
26+
field inhomogeneity in Hertz.
27+
static: false
28+
subtitle: "Preprocessed mapping of phase-difference acquisition"
29+
- bids: {datatype: figures, desc: pepolar, suffix: fieldmap}
30+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
31+
along the phase-encoding direction of the image. Utilizing two or more images with different
32+
phase-encoding polarities (PEPolar) or directions, it is possible to estimate the inhomogeneity
33+
of the field. The plot below shows a reference EPI (echo-planar imaging) volume generated
34+
using two or more EPI images with varying phase-encoding blips.
35+
description: Hover on the panels with the mouse pointer to also visualize the intensity of the
36+
inhomogeneity of the field in Hertz.
37+
static: false
38+
subtitle: "Preprocessed estimation with varying Phase-Encoding (PE) blips"
39+
- bids: {datatype: figures, desc: anat, suffix: fieldmap}
40+
caption: Inhomogeneities of the <em>B<sub>0</sub></em> field introduce (oftentimes severe) spatial distortions
41+
along the phase-encoding direction of the image. Utilizing an <em>anatomically-correct</em> acquisition
42+
(for instance, T1w or T2w), it is possible to estimate the inhomogeneity of the field by means of nonlinear
43+
registration. The plot below shows a reference EPI (echo-planar imaging) volume generated
44+
using two or more EPI images with the same PE encoding, after alignment to the anatomical scan.
45+
description: Hover on the panels with the mouse pointer to also visualize the intensity of the
46+
inhomogeneity of the field in Hertz.
47+
static: false
48+
subtitle: "Preprocessed estimation by nonlinear registration to an anatomical scan (&ldquo;<em>fieldmap-less</em>&rdquo;)"
49+
50+
- name: Functional
51+
ordering: session,task,acquisition,ceagent,reconstruction,direction,run,echo
52+
reportlets:
53+
- bids: {datatype: figures, desc: summary, suffix: bold}
54+
- bids: {datatype: figures, desc: validation, suffix: bold}
55+
- bids: {datatype: figures, desc: fmapCoreg, suffix: bold}
56+
caption: The estimated fieldmap was aligned to the corresponding EPI reference
57+
with a rigid-registration process of the fieldmap reference image,
58+
using <code>antsRegistration</code>.
59+
Overlaid on top of the co-registration results, the final BOLD mask is represented
60+
with a red contour for reference.
61+
static: false
62+
subtitle: Alignment between the anatomical reference of the fieldmap and the target EPI
63+
- bids: {datatype: figures, desc: fieldmap, suffix: bold}
64+
caption: Estimated fieldmap, as reconstructed on the target BOLD run space to allow
65+
the assessment of its alignment with the distorted data.
66+
The anatomical reference is the fieldmap's reference moved into the target EPI's grid through
67+
the estimated transformation.
68+
In other words, this plot should be equivalent to that of the
69+
<em>Preprocessed estimation with varying Phase-Encoding (PE) blips</em> shown above in the
70+
fieldmap section.
71+
Therefore, the fieldmap should be positioned relative to the anatomical reference exactly
72+
as it is positioned in the reportlet above.
73+
static: false
74+
subtitle: "Reconstructed <em>B<sub>0</sub></em> map in the corresponding run's space (debug mode)"
75+
- bids: {datatype: figures, desc: sdc, suffix: bold}
76+
caption: Results of performing susceptibility distortion correction (SDC) on the
77+
BOLD reference image. The "distorted" image is the image that would be used to
78+
align to the anatomical reference if SDC were not applied. The "corrected"
79+
image is the image that was used.
80+
static: false
81+
subtitle: Susceptibility distortion correction
82+
- bids: {datatype: figures, desc: forcedsyn, suffix: bold}
83+
caption: The dataset contained some fieldmap information, but the argument <code>--force-syn</code>
84+
was used. The higher-priority SDC method was used. Here, we show the results
85+
of performing SyN-based SDC on the EPI for comparison.
86+
static: false
87+
subtitle: Experimental fieldmap-less susceptibility distortion correction
88+
- bids: {datatype: figures, desc: t2scomp, suffix: bold}
89+
caption: A T2* map was calculated from the echos. Here, we show the comparison
90+
of the T2* map and the BOLD reference map used for BOLD-T1w coregistration.
91+
The red contour shows the anatomical gray-matter mask resampled into BOLD space.
92+
static: false
93+
subtitle: T2* map
94+
- bids: {datatype: figures, desc: t2starhist, suffix: bold}
95+
caption: A histogram of estimated T2* values within the anatomically-derived gray-matter mask
96+
shown in the previous plot. Note that values are clipped at 100ms, so any extreme outliers will
97+
appear in the 100ms bin.
98+
static: false
99+
subtitle: T2* gray-matter values
100+
- bids: {datatype: figures, desc: coreg, suffix: bold}
101+
caption: This panel shows the alignment of the reference EPI (BOLD) image to the
102+
anatomical (T1-weighted) image.
103+
The reference EPI has been contrast enhanced and susceptibility-distortion
104+
corrected (if applicable) for improved anatomical fidelity.
105+
The anatomical image has been resampled into EPI space, as well as the
106+
anatomical white matter mask, which appears as a red contour.
107+
static: false
108+
subtitle: Alignment of functional and anatomical MRI data (coregistration)
109+
- bids: {datatype: figures, desc: rois, suffix: bold}
110+
caption: Brain mask calculated on the BOLD signal (red contour), along with the
111+
regions of interest (ROIs) used for the estimation of physiological and movement
112+
confounding components that can be then used as nuisance regressors in analysis.<br />
113+
The <em>anatomical CompCor</em> ROI (magenta contour) is a mask combining
114+
CSF and WM (white-matter), where voxels containing a minimal partial volume
115+
of GM have been removed.<br />
116+
The <em>temporal CompCor</em> ROI (blue contour) contains the top 2% most
117+
variable voxels within the brain mask.<br />
118+
The <em>brain edge</em> (or <em>crown</em>) ROI (green contour) picks signals
119+
outside but close to the brain, which are decomposed into 24 principal components.
120+
subtitle: Brain mask and (anatomical/temporal) CompCor ROIs
121+
- bids:
122+
datatype: figures
123+
desc: '[at]compcor'
124+
extension: [.html]
125+
suffix: bold
126+
- bids: {datatype: figures, desc: 'compcorvar', suffix: bold}
127+
caption: The cumulative variance explained by the first k components of the
128+
<em>t/aCompCor</em> decomposition, plotted for all values of <em>k</em>.
129+
The number of components that must be included in the model in order to
130+
explain some fraction of variance in the decomposition mask can be used
131+
as a feature selection criterion for confound regression.
132+
subtitle: Variance explained by t/aCompCor components
133+
- bids: {datatype: figures, desc: carpetplot, suffix: bold}
134+
caption: Summary statistics are plotted, which may reveal trends or artifacts
135+
in the BOLD data. Global signals calculated within the whole-brain (GS), within
136+
the white-matter (WM) and within cerebro-spinal fluid (CSF) show the mean BOLD
137+
signal in their corresponding masks. DVARS and FD show the standardized DVARS
138+
and framewise-displacement measures for each time point.<br />
139+
A carpet plot shows the time series for all voxels within the brain mask,
140+
or if <code>--cifti-output</code> was enabled, all grayordinates.
141+
See the figure legend for specific color mappings.
142+
"Ctx" = cortex, "Cb" = cerebellum, "WM" = white matter, "CSF" = cerebrospinal fluid.
143+
"d" and "s" prefixes indicate "deep" and "shallow" relative to the cortex.
144+
"Edge" indicates regions just outside the brain.
145+
subtitle: BOLD Summary
146+
- bids: {datatype: figures, desc: 'confoundcorr', suffix: bold}
147+
caption: |
148+
Left: Heatmap summarizing the correlation structure among confound variables.
149+
(Cosine bases and PCA-derived CompCor components are inherently orthogonal.)
150+
Right: magnitude of the correlation between each confound time series and the
151+
mean global signal. Strong correlations might be indicative of partial volume
152+
effects and can inform decisions about feature orthogonalization prior to
153+
confound regression.
154+
subtitle: Correlations among nuisance regressors
155+
- name: About
156+
reportlets:
157+
- bids: {datatype: figures, desc: about, suffix: T1w}

fmriprep/data/reports-spec.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,23 @@ sections:
176176
confound regression.
177177
subtitle: Correlations among nuisance regressors
178178
- name: About
179+
nested: true
179180
reportlets:
180181
- bids: {datatype: figures, desc: about, suffix: T1w}
182+
- custom: boilerplate
183+
path: '{out_dir}/logs'
184+
bibfile: ['fmriprep', 'data/boilerplate.bib']
185+
caption: |
186+
<p>We kindly ask to report results preprocessed with this tool using the following boilerplate.</p>
187+
<p class="alert alert-info" role="alert">
188+
<strong>Copyright Waiver</strong>.
189+
The boilerplate text was automatically generated by <em>NiReports</em> with the
190+
express intention that users should copy and paste this text into their manuscripts <em>unchanged</em>.
191+
It is released under the
192+
<a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">CC0 license</a>.
193+
</p>
194+
title: Methods
195+
- custom: errors
196+
path: '{out_dir}/sub-{subject}/log/{run_uuid}'
197+
captions: <em>NiReports</em> may have recorded failure conditions.
198+
title: Errors

0 commit comments

Comments
 (0)