diff --git a/qsiprep/config.py b/qsiprep/config.py index 188aac66..48baf409 100644 --- a/qsiprep/config.py +++ b/qsiprep/config.py @@ -446,7 +446,6 @@ class execution(_Config): """Write out the computational graph corresponding to the planned preprocessing.""" dataset_links = {} """A dictionary of dataset links to be used to track Sources in sidecars.""" - aggr_ses_reports = 4 _layout = None diff --git a/qsiprep/data/reports-spec-anat.yml b/qsiprep/data/reports-spec-anat.yml deleted file mode 100644 index 1c4189e5..00000000 --- a/qsiprep/data/reports-spec-anat.yml +++ /dev/null @@ -1,51 +0,0 @@ -package: qsiprep -title: Anatomical report for participant '{subject}' - QSIPrep -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: ['qsiprep', 'data/boilerplate.bib'] - caption: | -

We kindly ask to report results preprocessed with this tool using the following boilerplate.

- - title: Methods - - custom: errors - path: '{out_dir}/sub-{subject}/log/{run_uuid}' - captions: NiReports may have recorded failure conditions. - title: Errors diff --git a/qsiprep/data/reports-spec-dwi.yml b/qsiprep/data/reports-spec-dwi.yml deleted file mode 100644 index 0f01ee14..00000000 --- a/qsiprep/data/reports-spec-dwi.yml +++ /dev/null @@ -1,173 +0,0 @@ -package: qsiprep -title: Diffusion report for participant '{subject}', session '{session}' - QSIPrep -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: Functional - ordering: session,task,acquisition,ceagent,reconstruction,direction,run,echo - reportlets: - - bids: {datatype: figures, desc: summary, suffix: dwi} - - bids: {datatype: figures, desc: validation, suffix: dwi} - - bids: {datatype: figures, desc: fmapCoreg, suffix: dwi} - caption: | - The estimated fieldmap was aligned to the corresponding EPI reference - with a rigid-registration process of the fieldmap reference image, - using antsRegistration. - Overlaid on top of the co-registration results, the final DWI mask is represented - with a red contour for reference. - static: false - subtitle: Alignment between the anatomical reference of the fieldmap and the target EPI - - bids: {datatype: figures, desc: fieldmap, suffix: dwi} - caption: | - Estimated fieldmap, as reconstructed on the target DWI 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: dwi} - caption: | - Results of performing susceptibility distortion correction (SDC) on the - DWI reference image. The "distorted" image is the image that would be used to - align to the anatomical reference if SDC were not applied. The "corrected" - image is the image that was used. - static: false - subtitle: Susceptibility distortion correction - - bids: {datatype: figures, desc: forcedsyn, suffix: dwi} - 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: t2scomp, suffix: dwi} - caption: | - A T2* map was calculated from the echos. Here, we show the comparison - of the T2* map and the DWI reference map used for DWI-T1w coregistration. - The red contour shows the anatomical gray-matter mask resampled into DWI space. - static: false - subtitle: T2* map - - bids: {datatype: figures, desc: t2starhist, suffix: dwi} - caption: | - A histogram of estimated T2* values within the anatomically-derived gray-matter mask - shown in the previous plot. Note that values are clipped at 100ms, so any extreme outliers will - appear in the 100ms bin. - static: false - subtitle: T2* gray-matter values - - bids: {datatype: figures, desc: coreg, suffix: dwi} - caption: | - This panel shows the alignment of the reference EPI (DWI) image to the - anatomical (T1-weighted) image. - The reference EPI has been contrast enhanced and susceptibility-distortion - corrected (if applicable) for improved anatomical fidelity. - The anatomical image has been resampled into EPI space, as well as the - anatomical white matter mask, which appears as a red contour. - static: false - subtitle: Alignment of functional and anatomical MRI data (coregistration) - - bids: {datatype: figures, desc: rois, suffix: dwi} - caption: | - Brain mask calculated on the DWI 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.
- The anatomical CompCor ROI (magenta contour) is a mask combining - CSF and WM (white-matter), where voxels containing a minimal partial volume - of GM have been removed.
- The temporal CompCor ROI (blue contour) contains the top 2% most - variable voxels within the brain mask.
- The brain edge (or crown) ROI (green contour) picks signals - outside but close to the brain, which are decomposed into 24 principal components. - subtitle: Brain mask and (anatomical/temporal) CompCor ROIs - - bids: - datatype: figures - desc: '[at]compcor' - extension: [.html] - suffix: dwi - - bids: {datatype: figures, desc: 'compcorvar', suffix: dwi} - caption: | - The cumulative variance explained by the first k components of the - t/aCompCor decomposition, plotted for all values of k. - The number of components that must be included in the model in order to - explain some fraction of variance in the decomposition mask can be used - as a feature selection criterion for confound regression. - subtitle: Variance explained by t/aCompCor components - - bids: {datatype: figures, desc: carpetplot, suffix: dwi} - caption: | - Summary statistics are plotted, which may reveal trends or artifacts - in the DWI data. Global signals calculated within the whole-brain (GS), within - the white-matter (WM) and within cerebro-spinal fluid (CSF) show the mean DWI - signal in their corresponding masks. DVARS and FD show the standardized DVARS - and framewise-displacement measures for each time point.
- A carpet plot shows the time series for all voxels within the brain mask, - or if --cifti-output was enabled, all grayordinates. - See the figure legend for specific color mappings. - "Ctx" = cortex, "Cb" = cerebellum, "WM" = white matter, "CSF" = cerebrospinal fluid. - "d" and "s" prefixes indicate "deep" and "shallow" relative to the cortex. - "Edge" indicates regions just outside the brain. - subtitle: DWI Summary - - bids: {datatype: figures, desc: 'confoundcorr', suffix: dwi} - caption: | - Left: Heatmap summarizing the correlation structure among confound variables. - (Cosine bases and PCA-derived CompCor components are inherently orthogonal.) - Right: magnitude of the correlation between each confound time series and the - mean global signal. Strong correlations might be indicative of partial volume - effects and can inform decisions about feature orthogonalization prior to - confound regression. - subtitle: Correlations among nuisance regressors -- name: About - reportlets: - - bids: {datatype: figures, desc: about, suffix: T1w} diff --git a/qsiprep/reports/core.py b/qsiprep/reports/core.py index 003daf41..ffc69ff1 100644 --- a/qsiprep/reports/core.py +++ b/qsiprep/reports/core.py @@ -24,7 +24,7 @@ from nireports.assembler.report import Report -from .. import config, data +from .. import data def run_reports( @@ -73,25 +73,18 @@ def generate_reports( ---------- output_level {"sessionwise", "unbiased", "first-alphabetically"} """ - errors = [] for subject_label, session_list in processing_list: - subject_id = subject_label[4:] if subject_label.startswith("sub-") else subject_label - n_ses = len(session_list) if bootstrap_file is not None: # If a config file is precised, we do not override it html_report = "report.html" - elif n_ses <= config.execution.aggr_ses_reports: + else: # If there are only a few session for this subject, # we aggregate them in a single visual report. bootstrap_file = data.load("reports-spec.yml") html_report = "report.html" - else: - # Beyond a threshold, we separate the anatomical report from the functional. - bootstrap_file = data.load("reports-spec-anat.yml") - html_report = f'sub-{subject_label.lstrip("sub-")}_anat.html' # We only make this one if it's all the sessions or just the anat and not sessionwise if output_level != "sessionwise": @@ -109,7 +102,7 @@ def generate_reports( if report_error is not None: errors.append(report_error) - if n_ses > config.execution.aggr_ses_reports or output_level == "sessionwise": + else: # Beyond a certain number of sessions per subject, # we separate the dwi reports per session # If output_level is "sessionwise", @@ -117,16 +110,9 @@ def generate_reports( session_list = [ses[4:] if ses.startswith("ses-") else ses for ses in session_list] for session_label in session_list: - - if output_level == "sessionwise": - bootstrap_file = data.load("reports-spec.yml") - suffix = "" - session_dir = output_dir / f"sub-{subject_id}" / f"ses-{session_label}" - html_report = f"sub-{subject_id}_ses-{session_label}.html" - else: - bootstrap_file = data.load("reports-spec-dwi.yml") - suffix = "_dwi" - html_report = "report.html" + bootstrap_file = data.load("reports-spec.yml") + session_dir = output_dir / f"sub-{subject_id}" / f"ses-{session_label}" + html_report = f"sub-{subject_id}_ses-{session_label}.html" report_error = run_reports( session_dir, @@ -135,7 +121,7 @@ def generate_reports( bootstrap_file=bootstrap_file, out_filename=html_report, reportlets_dir=output_dir, - errorname=f"report-{run_uuid}-{subject_label}-{session_label}{suffix}.err", + errorname=f"report-{run_uuid}-{subject_label}-{session_label}.err", subject=subject_label, session=session_label, )