Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: MRIQC for DWI #1113

Merged
merged 13 commits into from May 24, 2023
6 changes: 4 additions & 2 deletions mriqc/cli/parser.py
Expand Up @@ -197,6 +197,8 @@ def _bids_filter(value):
"-m",
"--modalities",
action="store",
choices=config.SUPPORTED_SUFFIXES,
default=config.SUPPORTED_SUFFIXES,
nargs="*",
help="Filter input dataset by MRI type.",
)
Expand Down Expand Up @@ -440,7 +442,7 @@ def parse_args(args=None, namespace=None):
from logging import DEBUG
from contextlib import suppress

from ..utils.bids import collect_bids_data
from mriqc.utils.bids import collect_bids_data

parser = _build_parser()
opts = parser.parse_args(args, namespace)
Expand Down Expand Up @@ -538,7 +540,7 @@ def parse_args(args=None, namespace=None):
)

# Check no DWI or others are sneaked into MRIQC
unknown_mods = set(config.workflow.inputs.keys()) - set(("T1w", "T2w", "bold"))
unknown_mods = set(config.workflow.inputs.keys()) - set(config.SUPPORTED_SUFFIXES)
if unknown_mods:
parser.error(
"MRIQC is unable to process the following modalities: "
Expand Down
3 changes: 1 addition & 2 deletions mriqc/cli/run.py
Expand Up @@ -195,14 +195,13 @@ def main():
# Set up group level
if "group" in config.workflow.analysis_level:
from mriqc.reports.group import gen_html as group_html
from ..utils.bids import DEFAULT_TYPES
from ..utils.misc import generate_tsv # , generate_pred

config.loggers.cli.info(messages.GROUP_START)

# Generate reports
mod_group_reports = []
for mod in config.execution.modalities or DEFAULT_TYPES:
for mod in config.execution.modalities or config.SUPPORTED_SUFFIXES:
output_dir = config.execution.output_dir
dataframe, out_tsv = generate_tsv(output_dir, mod)
# If there are no iqm.json files, nothing to do.
Expand Down
6 changes: 4 additions & 2 deletions mriqc/config.py
Expand Up @@ -130,6 +130,8 @@
logging.addLevelName(25, "IMPORTANT") # Add a new level between INFO and WARNING
logging.addLevelName(15, "VERBOSE") # Add a new level between INFO and DEBUG

SUPPORTED_SUFFIXES = ("T1w", "T2w", "bold", "dwi")

DEFAULT_MEMORY_MIN_GB = 0.01
DSA_MESSAGE = """\
IMPORTANT: Anonymized quality metrics (IQMs) will be submitted to MRIQC's metrics \
Expand Down Expand Up @@ -443,10 +445,10 @@ def init(cls):
# Ignore all modality subfolders, except for func/ or anat/
re.compile(
r"^/sub-[a-zA-Z0-9]+(/ses-[a-zA-Z0-9]+)?/"
r"(beh|dwi|fmap|pet|perf|meg|eeg|ieeg|micr|nirs)"
r"(beh|fmap|pet|perf|meg|eeg|ieeg|micr|nirs)"
),
# Ignore all files, except for the supported modalities
re.compile(r"^.+(?<!(_T1w|_T2w|bold))\.(json|nii|nii\.gz)$"),
re.compile(r"^.+(?<!(_T1w|_T2w|bold|_dwi))\.(json|nii|nii\.gz)$"),
]

if cls.participant_label:
Expand Down
77 changes: 77 additions & 0 deletions mriqc/data/bootstrap-dwi.yml
@@ -0,0 +1,77 @@
# Copyright 2023 The NiPreps Developers <nipreps@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# We support and encourage derived works from this project, please read
# about our expectations at
#
# https://www.nipreps.org/community/licensing/
#
###########################################################################
# Reports bootstrap file
# ======================
# This is a YAML-formatted file specifying how the NiReports assembler
# will search for "reportlets" and compose them into a report file,
# typically in HTML format.
###########################################################################

packagename: mriqc
title: '{filename} :: Diffusion MRI MRIQC report'
sections:
- name: Summary
reportlets:
- bids: {datatype: figures, desc: summary, extension: [.html]}
- name: DWI shells
ordering: bval
reportlets:
- bids: {datatype: figures, desc: zoomedavg}
caption: This panel shows a mosaic of the brain. This mosaic is the most suitable to
screen head-motion intensity inhomogeneities, global/local noise, signal leakage
(for example, from the eyeballs and across the phase-encoding axis), etc.
subtitle: Voxel-wise average across volumes in this <em>DWI shell</em>,
zoomed-in covering just the brain
- bids: {datatype: figures, desc: zoomedstd}
caption: This panel shows a mosaic of the brain. This mosaic is the most suitable to
screen within-volume head-motion (e.g., missing slices) and reconstruction ghosts
such as those intrinsic to SMS parallelization.
subtitle: Voxel-wise standard deviation calculated across volumes in this <em>DWI shell</em>,
zoomed-in covering just the brain
- bids: {datatype: figures, desc: background}
caption: This panel shows a mosaic enhancing the background around the head.
Artifacts usually unveil themselves in the air surrounding the head, where no signal
sources are present.
subtitle: View of the background of the voxel-wise average of this <em>DWI shell</em>

- name: About
nested: true
reportlets:
- custom: errors
path: '{reportlets_dir}/{run_uuid}'
captions: <em>MRIQC</em> may have recorded failure conditions.
title: Errors
- metadata: "input"
settings:
# By default, only the first dictionary will be expanded.
# If folded is true, all will be folded. If false all expanded.
folded: true
# If an ID is not provided, one should be generated automatically
id: 'about-metadata'
caption: |
Thanks for using <em>MRIQC</em>. The following information may assist in
reconstructing the provenance of the corresponding derivatives.
title: Reproducibility and provenance information

# Rating widget
plugins:
- module: nireports.assembler
path: data/rating-widget/bootstrap.yml
2 changes: 1 addition & 1 deletion mriqc/data/tests/gh1086-ds004134.oracle
@@ -1 +1 @@
180
182