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

Infer the appropriate MNIInfant cohort based on the participant's age #856

Merged
merged 5 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ Command-Line Arguments
:nodefaultconst:


Infant mode
===========

If ``--infant`` is used, the pipeline will select an MNIInfant template with the
appropriate cohort based on the participant's age.

``--infant`` is only compatible with ``--subject-anatomical-reference sessionwise``.

.. note::

QSIPrep's cohort selection is derived from Nibabies.

Participant Ages
----------------

QSIPrep will attempt to automatically extract participant ages (in months) from the BIDS layout. Specifically, these two files will be checked:

Sessions file: <bids-root>/<subject>/subject_sessions.tsv

Participants file: <bids-root>/participants.tsv

Either file should include age (or if you wish to be more explicit: age_months) columns, and it is recommended to have an accompanying JSON file to further describe these fields, and explicitly state the values are in months.


Note on using CUDA
==================

Expand Down
14 changes: 12 additions & 2 deletions qsiprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ def _bids_filter(value, parser):
"parts of the workflow (a space delimited list)",
)
g_conf.add_argument(
"--infant", action="store_true", help="configure pipelines to process infant brains"
"--infant",
action="store_true",
help="Configure pipelines to process infant brains. "
"If using this parameter, the anatomical-template will be changed to MNIInfant. "
"The appropriate MNIInfant cohort will be selected based on the participant's age.",
)
g_conf.add_argument(
"--longitudinal",
Expand Down Expand Up @@ -649,11 +653,17 @@ def parse_args(args=None, namespace=None):
opts = parser.parse_args(args, namespace)

# Change anatomical_template based on infant parameter
opts.anatomical_template = "MNI152NLin2009cAsym"
if opts.infant:
config.loggers.cli.info(
"Infant processing mode enabled. Changing anatomical template to MNIInfant cohort-2."
"Infant processing mode enabled. "
"Inferring the subject's age and selecting the appropriate MNIInfant cohort."
)
opts.anatomical_template = "MNIInfant"
if opts.subject_anatomical_reference != "sessionwise":
config.loggers.cli.error(
"Infant processing requires --subject-anatomical-reference sessionwise"
)

if opts.config_file:
skip = {} if opts.reports_only else {"execution": ("run_uuid",)}
Expand Down
3 changes: 1 addition & 2 deletions qsiprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,7 @@ class workflow(_Config):
anat_only = False
"""Execute the anatomical preprocessing only."""
anatomical_template = None
"""Keeps the :py:class:`~niworkflows.utils.spaces.SpatialReferences`
instance keeping standard and nonstandard spaces."""
"""Anatomical template to use. This field doesn't include the cohort."""
b0_threshold = None
"""Any value in the .bval file less than this will be considered a b=0 image."""
b0_motion_corr_to = None
Expand Down
18 changes: 11 additions & 7 deletions qsiprep/interfaces/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ def clip_values(values):


class _GetTemplateInputSpec(BaseInterfaceInputSpec):
template_name = traits.Enum(
"MNI152NLin2009cAsym",
"MNIInfant",
template_spec = traits.Str(
desc="Template specification of the form <template>[+<cohort>]",
mandatory=True,
)
anatomical_contrast = traits.Enum("T1w", "T2w", "none")
Expand All @@ -221,17 +220,22 @@ def _run_interface(self, runtime):
LOGGER.info("Using T1w modality template for ACPC alignment")
anatomical_contrast = "T1w"

template_name = self.inputs.template_spec
cohort = None
if "+" in template_name:
template_name, cohort = template_name.split("+")

template_path = get_template(
self.inputs.template_name,
cohort=[None, "2"],
template_name,
cohort=cohort,
resolution="1",
desc=None,
suffix=anatomical_contrast,
extension=".nii.gz",
)
mask_path = get_template(
self.inputs.template_name,
cohort=[None, "2"],
template_name,
cohort=cohort,
resolution="1",
desc="brain",
suffix="mask",
Expand Down
7 changes: 4 additions & 3 deletions qsiprep/interfaces/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
\t\t<li>Structural images: {n_t1s:d} T1-weighted {t2w}</li>
\t\t<li>Diffusion-weighted series: inputs {n_dwis:d}, outputs {n_outputs:d}</li>
{groupings}
\t\t<li>Resampling targets: T1wACPC
\t\t<li>Resampling targets: T1wACPC</li>
\t\t<li>Transform targets: {output_spaces}</li>
\t</ul>
"""

Expand Down Expand Up @@ -146,7 +147,7 @@ class SubjectSummaryInputSpec(BaseInterfaceInputSpec):
session_id = Str(desc="Session ID")
dwi_groupings = traits.Dict(desc="groupings of DWI files and their output names")
output_spaces = traits.List(desc="Target spaces")
template = traits.Enum("MNI152NLin2009cAsym", "MNIInfant", desc="Template space")
template = Str(desc="Template space")
freesurfer_status = traits.Enum("Not run", "Partial", "Full", desc="FreeSurfer status")


Expand Down Expand Up @@ -206,7 +207,7 @@ def _generate_segment(self):
n_dwis=n_dwis,
n_outputs=n_outputs,
groupings=groupings,
output_spaces="T1wACPC",
output_spaces=["T1wACPC", self.inputs.template],
)


Expand Down
Loading