Skip to content

[ENH] Add native FLAIR Support to MRIQC#1438

Open
cooper-sharp wants to merge 6 commits intonipreps:masterfrom
cooper-sharp:enh/add-flair
Open

[ENH] Add native FLAIR Support to MRIQC#1438
cooper-sharp wants to merge 6 commits intonipreps:masterfrom
cooper-sharp:enh/add-flair

Conversation

@cooper-sharp
Copy link
Copy Markdown

Overview

This PR adds native FLAIR support to MRIQC, allowing _FLAIR BIDS-named files to be processed directly. FLAIR images are routed through the existing anatomical QC workflow and produce the same reports and IQMs as T1w and T2w.

Related Issue

Requirements

These instructions assume Docker is already installed on your system. See https://docs.docker.com/get-docker/ for installation guidance.

Building the Docker image

After cloning this branch, build the development image from the repo root:

docker build --no-cache -f Dockerfile_devel -t mriqc_devel --build-arg VERSION=24.0.2 .

Usage

mriqc /data /out participant -m FLAIR T1w

No additional environment variables are required.

Files Changed

File Change
mriqc/config.py Added 'FLAIR' to SUPPORTED_SUFFIXES; updated BIDS ignore regex; added 'FLAIR' to IMTYPES in utils/misc.py
mriqc/cli/parser.py Updated description string to include FLAIR
mriqc/workflows/core.py Added 'flair' to ANATOMICAL_KEYS
mriqc/workflows/anatomical/base.py Added 'flair' to dataset/metadata/entities collection; added _get_norm_mod to map FLAIR → T2w for ANTs spatial normalization; wired modality into StructuralQC node
mriqc/interfaces/anatomical.py Added modality input to StructuralQCInputSpec; replaced MRIQC_ALLOW_EMPTY_N4 env var check with modality-aware N4 fallback
mriqc/utils/misc.py Added 'flair' to volmax check; added 'FLAIR' to IMTYPES

Key Implementation Details

N4 bias correction fallback

FLAIR images frequently cause N4 to converge to a near-empty output due to the inverted CSF contrast. When modality == 'FLAIR' and the N4-corrected image is effectively empty, the pipeline substitutes the original uncorrected image and logs
a warning. For all other modalities (T1w, T2w) the original RuntimeError is raised as before. This fallback is strictly FLAIR-only.

Spatial normalization

ANTs RobustMNINormalization does not accept 'FLAIR' as a valid reference value. FLAIR is mapped to 'T2w' for the purposes of normalization only, via _get_norm_mod. The modality label remains 'FLAIR' everywhere else in the pipeline (datasink, provenance, IQM output).


Testing

The following steps reproduce a minimal end-to-end test using a single subject from
OpenNeuro dataset [ds007486](https://openneuro.org/datasets/ds007486), which contains FLAIR acquisitions.

1. Download the dataset

If you have DataLad installed:

datalad clone https://github.com/OpenNeuroDatasets/ds007486.git /path/to/ds007486
cd /path/to/ds007486
datalad get sub-10562/anat/

If you do not have DataLad, use the AWS CLI instead (no credentials required):

# Install if needed
pip install awscli

# Create the destination directory
mkdir -p /path/to/ds007486/sub-10562/anat

# Download the subject's anatomical data
aws s3 sync \
  --no-sign-request \
  s3://openneuro.org/ds007486/sub-10562/anat/ \
  /path/to/ds007486/sub-10562/anat/

2. Create output directory

mkdir -p /path/to/ds007486/derivatives/mriqc/logs

3. Run MRIQC

docker run --rm \
  -v /path/to/ds007486:/data \
  -v /path/to/ds007486/derivatives/mriqc:/out \
  -v /tmp/scratch:/scratch \
  -e TEMPLATEFLOW_HOME=/tmp/templateflow \
  mriqc_devel \
  /data /out participant \
  --participant_label 10562 \
  --no-datalad-get \
  --no-sub \
  -m FLAIR \
  --bids-database-wipe \
  -w /scratch

Replace /path/to/ds007486 with the actual path on your system.

4. Expected output

On success you should see a FLAIR IQM JSON file and visual report at:

/path/to/ds007486/derivatives/mriqc/sub-10562/anat/sub-10562_FLAIR.json
/path/to/ds007486/derivatives/mriqc/sub-10562/anat/sub-10562_FLAIR.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant