diff --git a/aslprep/cli/parser.py b/aslprep/cli/parser.py
index 86d736f9c..08ea75f05 100644
--- a/aslprep/cli/parser.py
+++ b/aslprep/cli/parser.py
@@ -544,6 +544,17 @@ def _bids_filter(value, parser):
)
g_other = parser.add_argument_group("Other options")
+ g_other.add_argument(
+ "--aggregate-session-reports",
+ dest="aggr_ses_reports",
+ action="store",
+ type=PositiveInt,
+ default=4,
+ help=(
+ "Maximum number of sessions aggregated in one subject's visual report. "
+ "If exceeded, visual reports are split by session."
+ ),
+ )
g_other.add_argument("--version", action="version", version=verstr)
g_other.add_argument(
"-v",
diff --git a/aslprep/cli/run.py b/aslprep/cli/run.py
index a9d4013c3..877d2b5f5 100644
--- a/aslprep/cli/run.py
+++ b/aslprep/cli/run.py
@@ -174,27 +174,33 @@ def main():
_copy_any(dseg_tsv, str(config.execution.aslprep_dir / "desc-aparcaseg_dseg.tsv"))
errno = 0
finally:
- from fmriprep.reports.core import generate_reports
+ from aslprep.reports.core import generate_reports
- from aslprep import data
+ # Generate reports phase
+ session_list = (
+ config.execution.get().get("bids_filters", {}).get("bold", {}).get("session")
+ )
# Generate reports phase
failed_reports = generate_reports(
config.execution.participant_label,
config.execution.aslprep_dir,
config.execution.run_uuid,
- config=data.load("reports-spec.yml"),
- packagename="aslprep",
+ session_list=session_list,
)
write_derivative_description(config.execution.bids_dir, config.execution.aslprep_dir)
write_bidsignore(config.execution.aslprep_dir)
- if sentry_sdk is not None and failed_reports:
- sentry_sdk.capture_message(
- f"Report generation failed for {failed_reports} subjects",
- level="error",
+ if failed_reports:
+ msg = (
+ "Report generation was not successful for the following participants "
+ f': {", ".join(failed_reports)}.'
)
- sys.exit(int((errno + failed_reports) > 0))
+ config.loggers.cli.error(msg)
+ if sentry_sdk is not None:
+ sentry_sdk.capture_message(msg, level="error")
+
+ sys.exit(int((errno + len(failed_reports)) > 0))
if __name__ == "__main__":
diff --git a/aslprep/cli/workflow.py b/aslprep/cli/workflow.py
index 873902782..b2ebfd1ae 100644
--- a/aslprep/cli/workflow.py
+++ b/aslprep/cli/workflow.py
@@ -12,12 +12,12 @@
def build_workflow(config_file, retval):
"""Create the Nipype Workflow that supports the whole execution graph."""
- from fmriprep.reports.core import generate_reports
from fmriprep.utils.bids import check_pipeline_version
from niworkflows.utils.bids import collect_participants
from niworkflows.utils.misc import check_valid_fs_license
from aslprep import config, data
+ from aslprep.reports.core import generate_reports
from aslprep.utils.misc import check_deps
from aslprep.workflows.base import init_aslprep_wf
diff --git a/aslprep/config.py b/aslprep/config.py
index 7170c7c69..06ba5f277 100644
--- a/aslprep/config.py
+++ b/aslprep/config.py
@@ -388,6 +388,8 @@ class execution(_Config):
"""Debug mode(s)."""
aslprep_dir = None
"""Root of ASLPrep BIDS Derivatives dataset."""
+ aggr_ses_reports = None
+ """Maximum number of sessions aggregated in one subject's visual report."""
fs_license_file = _fs_license
"""An existing file containing a FreeSurfer license."""
fs_subjects_dir = None
diff --git a/aslprep/data/reports-spec-anat.yml b/aslprep/data/reports-spec-anat.yml
new file mode 100644
index 000000000..8edf66a67
--- /dev/null
+++ b/aslprep/data/reports-spec-anat.yml
@@ -0,0 +1,47 @@
+package: aslprep
+sections:
+- name: Summary
+ reportlets:
+ - bids: {datatype: figures, desc: summary, suffix: T1w}
+- name: Anatomical
+ reportlets:
+ - bids:
+ datatype: figures
+ desc: conform
+ extension: [.html]
+ suffix: T1w
+ - bids: {datatype: figures, suffix: dseg}
+ caption: This panel shows the final, preprocessed T1-weighted image,
+ with contours delineating the detected brain mask and brain tissue segmentations.
+ subtitle: Brain mask and brain tissue segmentation of the T1w
+ - bids: {datatype: figures, space: .*, suffix: T1w, regex_search: True}
+ caption: Spatial normalization of the T1w image to the {space}
template.
+ description: Results of nonlinear alignment of the T1w reference one or more template
+ space(s). Hover on the panels with the mouse pointer to transition between both
+ spaces.
+ static: false
+ subtitle: Spatial normalization of the anatomical T1w reference
+ - bids: {datatype: figures, desc: reconall, suffix: T1w}
+ caption: Surfaces (white and pial) reconstructed with FreeSurfer (recon-all
)
+ overlaid on the participant's T1w template.
+ subtitle: Surface reconstruction
+- name: About
+ reportlets:
+ - bids: {datatype: figures, desc: about, suffix: T1w}
+ - custom: boilerplate
+ path: '{out_dir}/logs'
+ bibfile: ['aslprep', 'data/boilerplate.bib']
+ caption: |
+
We kindly ask to report results preprocessed with this tool using the following boilerplate.
++ Copyright Waiver. + The boilerplate text was automatically generated by NiReports with the + express intention that users should copy and paste this text into their manuscripts unchanged. + It is released under the + CC0 license. +
+ title: Methods + - custom: errors + path: '{out_dir}/sub-{subject}/log/{run_uuid}' + captions: NiReports may have recorded failure conditions. + title: Errors diff --git a/aslprep/data/reports-spec-perf.yml b/aslprep/data/reports-spec-perf.yml new file mode 100644 index 000000000..6c7807ee5 --- /dev/null +++ b/aslprep/data/reports-spec-perf.yml @@ -0,0 +1,212 @@ +package: aslprep +sections: +- name: B0 field mapping + ordering: session,acquisition,run,fmapid + reportlets: + - bids: {datatype: figures, desc: mapped, suffix: fieldmap} + caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions + along the phase-encoding direction of the image. Some scanners produce a B0 + mapping of the field, using Spiral Echo Imaging (SEI) or postprocessing a "phase-difference" + acquisition. The plot below shows an anatomical "magnitude" reference and the corresponding + fieldmap. + description: Hover over the panels with the mouse pointer to also visualize the intensity of the + field inhomogeneity in Hertz. + static: false + subtitle: "Preprocessed B0 mapping acquisition" + - bids: {datatype: figures, desc: phasediff, suffix: fieldmap} + caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions + along the phase-encoding direction of the image. A Gradient-Recalled Echo (GRE) scheme was included for the + mapping of the B0 inhomogeneities by subtracting the phase maps obtained at + two subsequent echoes. The plot below shows an anatomical "magnitude" reference and the corresponding + fieldmap. + description: Hover over the panels with the mouse pointer to also visualize the intensity of the + field inhomogeneity in Hertz. + static: false + subtitle: "Preprocessed mapping of phase-difference acquisition" + - bids: {datatype: figures, desc: pepolar, suffix: fieldmap} + caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions + along the phase-encoding direction of the image. Utilizing two or more images with different + phase-encoding polarities (PEPolar) or directions, it is possible to estimate the inhomogeneity + of the field. The plot below shows a reference EPI (echo-planar imaging) volume generated + using two or more EPI images with varying phase-encoding blips. + description: Hover on the panels with the mouse pointer to also visualize the intensity of the + inhomogeneity of the field in Hertz. + static: false + subtitle: "Preprocessed estimation with varying Phase-Encoding (PE) blips" + - bids: {datatype: figures, desc: anat, suffix: fieldmap} + caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions + along the phase-encoding direction of the image. Utilizing an anatomically-correct acquisition + (for instance, T1w or T2w), it is possible to estimate the inhomogeneity of the field by means of nonlinear + registration. The plot below shows a reference EPI (echo-planar imaging) volume generated + using two or more EPI images with the same PE encoding, after alignment to the anatomical scan. + description: Hover on the panels with the mouse pointer to also visualize the intensity of the + inhomogeneity of the field in Hertz. + static: false + subtitle: "Preprocessed estimation by nonlinear registration to an anatomical scan (“fieldmap-less”)" + +- name: Arterial Spin Labeling + ordering: session,task,acquisition,ceagent,reconstruction,direction,run,echo + reportlets: + - bids: {datatype: figures, desc: summary, suffix: asl} + - bids: {datatype: figures, desc: validation, suffix: asl} + - bids: {datatype: figures, desc: fmapCoreg, suffix: asl} + caption: | + The estimated fieldmap was aligned to the corresponding EPI reference + with a rigid-registration process of the anatomical reference of the fieldmap, + usingantsRegistration
.
+ Overlaid on top of the co-registration results, the final BOLD mask is represented
+ with a red contour for reference.
+ static: false
+ subtitle: Alignment between the anatomical reference of the fieldmap and the target EPI (debug mode)
+ - bids: {datatype: figures, desc: fieldmap, suffix: asl}
+ caption: |
+ Estimated fieldmap, as reconstructed on the target BOLD run space to allow
+ the assessment of its alignment with the distorted data.
+ The anatomical reference is the fieldmap's reference moved into the target EPI's grid through
+ the estimated transformation.
+ In other words, this plot should be equivalent to that of the
+ Preprocessed estimation with varying Phase-Encoding (PE) blips shown above in the
+ fieldmap section.
+ Therefore, the fieldmap should be positioned relative to the anatomical reference exactly
+ as it is positioned in the reportlet above.
+ static: false
+ subtitle: "Reconstructed B0 map in the corresponding run's space (debug mode)"
+ - bids: {datatype: figures, desc: sdc, suffix: asl}
+ caption: |
+ Results of performing susceptibility distortion correction (SDC) on the EPI
+ static: false
+ subtitle: Susceptibility distortion correction
+ - bids: {datatype: figures, desc: forcedsyn, suffix: asl}
+ caption: |
+ The dataset contained some fieldmap information, but the argument --force-syn
+ was used. The higher-priority SDC method was used. Here, we show the results
+ of performing SyN-based SDC on the EPI for comparison.
+ static: false
+ subtitle: Experimental fieldmap-less susceptibility distortion correction
+ - bids: {datatype: figures, desc: flirtnobbr, suffix: asl}
+ caption: |
+ mri_coreg
(FreeSurfer) was used to generate transformations
+ from EPI space to T1 Space - BBR refinement using FSL flirt
rejected.
+ Note that Nearest Neighbor interpolation is used in the reportlets in order to
+ highlight potential spin-history and other artifacts, whereas final images are
+ resampled using Lanczos interpolation.
+ static: false
+ subtitle: Alignment of functional and anatomical MRI data (volume based)
+ - bids: {datatype: figures, desc: coreg, suffix: asl}
+ caption: |
+ mri_coreg
(FreeSurfer) was used to generate transformations
+ from EPI space to T1 Space - bbregister
refinement rejected. Note
+ that Nearest Neighbor interpolation is used in the reportlets in order to highlight
+ potential spin-history and other artifacts, whereas final images are resampled
+ using Lanczos interpolation.
+ static: false
+ subtitle: Alignment of functional and anatomical MRI data (volume based)
+ - bids: {datatype: figures, desc: flirtbbr, suffix: asl}
+ caption: |
+ FSL flirt
was used to generate transformations from EPI-space
+ to T1w-space - The white matter mask calculated with FSL fast
(brain
+ tissue segmentation) was used for BBR. Note that Nearest Neighbor interpolation
+ is used in the reportlets in order to highlight potential spin-history and other
+ artifacts, whereas final images are resampled using Lanczos interpolation.
+ static: false
+ subtitle: Alignment of functional and anatomical MRI data (surface driven)
+ - bids: {datatype: figures, desc: bbregister, suffix: asl}
+ caption: |
+ bbregister
was used to generate transformations from EPI-space
+ to T1w-space. Note that Nearest Neighbor interpolation is used in the reportlets
+ in order to highlight potential spin-history and other artifacts, whereas final
+ images are resampled using Lanczos interpolation.
+ static: false
+ subtitle: Alignment of functional and anatomical MRI data (surface driven)
+ - bids: {datatype: figures, desc: rois, suffix: asl}
+ caption: |
+ Brain mask calculated on the BOLD signal (red contour), along with the
+ regions of interest (ROIs) used for the estimation of physiological and movement
+ confounding components that can be then used as nuisance regressors in analysis.{space}
template.
- description: |
- Results of nonlinear alignment of the T1w reference one or more template
+ description: Results of nonlinear alignment of the T1w reference one or more template
space(s). Hover on the panels with the mouse pointer to transition between both
spaces.
static: false
subtitle: Spatial normalization of the anatomical T1w reference
- bids: {datatype: figures, desc: reconall, suffix: T1w}
- caption: |
- Surfaces (white and pial) reconstructed with FreeSurfer (recon-all
)
+ caption: Surfaces (white and pial) reconstructed with FreeSurfer (recon-all
)
overlaid on the participant's T1w template.
subtitle: Surface reconstruction
@@ -35,50 +31,42 @@ sections:
ordering: session,acquisition,run,fmapid
reportlets:
- bids: {datatype: figures, desc: mapped, suffix: fieldmap}
- caption: |
- Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
+ caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
along the phase-encoding direction of the image. Some scanners produce a B0
mapping of the field, using Spiral Echo Imaging (SEI) or postprocessing a "phase-difference"
acquisition. The plot below shows an anatomical "magnitude" reference and the corresponding
fieldmap.
- description: |
- Hover over the panels with the mouse pointer to also visualize the intensity of the
+ description: Hover over the panels with the mouse pointer to also visualize the intensity of the
field inhomogeneity in Hertz.
static: false
subtitle: "Preprocessed B0 mapping acquisition"
- bids: {datatype: figures, desc: phasediff, suffix: fieldmap}
- caption: |
- Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
+ caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
along the phase-encoding direction of the image. A Gradient-Recalled Echo (GRE) scheme was included for the
mapping of the B0 inhomogeneities by subtracting the phase maps obtained at
two subsequent echoes. The plot below shows an anatomical "magnitude" reference and the corresponding
fieldmap.
- description: |
- Hover over the panels with the mouse pointer to also visualize the intensity of the
+ description: Hover over the panels with the mouse pointer to also visualize the intensity of the
field inhomogeneity in Hertz.
static: false
subtitle: "Preprocessed mapping of phase-difference acquisition"
- bids: {datatype: figures, desc: pepolar, suffix: fieldmap}
- caption: |
- Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
+ caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
along the phase-encoding direction of the image. Utilizing two or more images with different
phase-encoding polarities (PEPolar) or directions, it is possible to estimate the inhomogeneity
of the field. The plot below shows a reference EPI (echo-planar imaging) volume generated
using two or more EPI images with varying phase-encoding blips.
- description: |
- Hover on the panels with the mouse pointer to also visualize the intensity of the
+ description: Hover on the panels with the mouse pointer to also visualize the intensity of the
inhomogeneity of the field in Hertz.
static: false
subtitle: "Preprocessed estimation with varying Phase-Encoding (PE) blips"
- bids: {datatype: figures, desc: anat, suffix: fieldmap}
- caption: |
- Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
+ caption: Inhomogeneities of the B0 field introduce (oftentimes severe) spatial distortions
along the phase-encoding direction of the image. Utilizing an anatomically-correct acquisition
(for instance, T1w or T2w), it is possible to estimate the inhomogeneity of the field by means of nonlinear
registration. The plot below shows a reference EPI (echo-planar imaging) volume generated
using two or more EPI images with the same PE encoding, after alignment to the anatomical scan.
- description: |
- Hover on the panels with the mouse pointer to also visualize the intensity of the
+ description: Hover on the panels with the mouse pointer to also visualize the intensity of the
inhomogeneity of the field in Hertz.
static: false
subtitle: "Preprocessed estimation by nonlinear registration to an anatomical scan (“fieldmap-less”)"
diff --git a/aslprep/reports/__init__.py b/aslprep/reports/__init__.py
new file mode 100644
index 000000000..f6a0561b6
--- /dev/null
+++ b/aslprep/reports/__init__.py
@@ -0,0 +1 @@
+"""Report-generation tools for ASLPrep."""
diff --git a/aslprep/reports/core.py b/aslprep/reports/core.py
new file mode 100644
index 000000000..83f0d8abb
--- /dev/null
+++ b/aslprep/reports/core.py
@@ -0,0 +1,150 @@
+# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
+# vi: set ft=python sts=4 ts=4 sw=4 et:
+#
+# Copyright The NiPreps Developers