MicaFlow MRI processing pipeline
Project description
MICAFlow: Accessible, fast, and pythonic MRI processing pipeline
MICAFlow is a comprehensive neuroimaging pipeline designed for processing structural and diffusion MRI data. It offers modular components that can be used as part of a cohesive workflow or as standalone tools.
Overview
MICAFlow provides a robust and flexible framework for neuroimaging processing. By chaining together deep learning-based segmentation and advanced numerical solutions, it generates precise outputs even for modalities with low signal-to-noise ratio or strong geometric distortions.
Features
- Structural MRI Processing: T1w and FLAIR image processing
- Diffusion MRI Processing: Complete pipeline for DWI processing
- Brain Extraction: SynthSeg-based brain extraction with optional cerebellum removal
- Deep Learning Segmentation: SynthSeg for brain segmentation and parcellation
- Image Registration: Multi-modal coregistration and spatial normalization to standard spaces
- Texture Features: Advanced texture feature generation
- Quality Control: Built-in QC metrics and visualization
- Batch Processing: Automated BIDS directory scanning and processing
- Brain-Extracted Outputs: Optional dedicated directory for all skull-stripped images
- Temporary File Management: Option to preserve intermediate files for debugging
- Modular Design: Components can be used independently or as a complete pipeline
- Flexible Configuration: Via command line arguments or YAML configuration files
Installation
pip install
# Verify installation
micaflow
Usage
MICAFlow can be used as a complete pipeline or as individual modules:
Running the Full Pipeline
# Basic usage with T1w only
micaflow pipeline --subject sub-001 --session ses-01 \
--data-directory /path/to/data --t1w-file sub-001_ses-01_T1w.nii.gz \
--output /output/path --cores 4
# With FLAIR image
micaflow pipeline --subject sub-001 --session ses-01 \
--data-directory /path/to/data --t1w-file sub-001_ses-01_T1w.nii.gz \
--flair-file sub-001_ses-01_FLAIR.nii.gz --output /output/path \
--cores 4
# With diffusion data
micaflow pipeline --subject sub-001 --session ses-01 \
--data-directory /path/to/data --t1w-file sub-001_ses-01_T1w.nii.gz \
--dwi-file sub-001_ses-01_dwi.nii.gz \
--bval-file sub-001_ses-01_dwi.bval --bvec-file sub-001_ses-01_dwi.bvec \
--inverse-dwi-file sub-001_ses-01_acq-PA_dwi.nii.gz \
--output /output/path --cores 4
Batch Processing (BIDS)
To process an entire BIDS dataset automatically using the batch command:
micaflow bids --bids-dir /path/to/bids_root --output-dir /path/to/derivatives \
--cores 4 --gpu
This command will:
- Scan the BIDS directory for valid subjects and sessions.
- Automatically identify T1w, FLAIR (optional), and DWI (optional) files based on suffixes.
- Run the pipeline sequentially for each session found.
- Generate a
micaflow_runs_summary.jsonin the output directory tracking execution status.
key arguments:
--bids-dir: Root path to the BIDS dataset.--output-dir: Path where derivatives will be saved.--participant-label: (Optional) Space-separated list of subject IDs to process (e.g.,001 002).--session-label: (Optional) Space-separated list of session IDs to process.--t1w-suffix,--dwi-suffix, etc.: Customize matching patterns for input files.
Using Individual Modules
Each module can be used independently:
Brain Extraction
micaflow bet --input t1w.nii.gz --output brain.nii.gz --parcellation segmentation.nii.gz --output-mask mask.nii.gz
Brain Segmentation (SynthSeg)
micaflow synthseg --i t1w.nii.gz --o segmentation.nii.gz --parc --fast --threads 4
Image Registration
micaflow coregister --fixed-file target.nii.gz --moving-file source.nii.gz \
--output registered.nii.gz --warp-file warp.nii.gz --affine-file affine.mat
Apply Transformations
micaflow apply_warp --moving image.nii.gz --reference target.nii.gz \
--warp warp.nii.gz --affine affine.mat --output warped.nii.gz
Diffusion Processing
# Denoise DWI data
micaflow denoise --input dwi.nii.gz --bval dwi.bval --bvec dwi.bvec --output denoised_dwi.nii.gz
# Motion correction
micaflow motion_correction --denoised denoised_dwi.nii.gz --input-bvecs dwi.bvec --output-bvecs corrected.bvec --output motion_corrected_dwi.nii.gz
# Susceptibility distortion correction
micaflow SDC --input motion_corrected_dwi.nii.gz --reverse-image reverse_phase_dwi.nii.gz \
--output corrected_dwi.nii.gz --output-warp sdc_warpfield.nii.gz
# Compute DTI metrics
micaflow compute_fa_md --input preprocessed_dwi.nii.gz --bval dwi.bval --bvec dwi.bvec \
--output-fa fa_map.nii.gz --output-md md_map.nii.gz
Texture Feature Extraction
micaflow texture_generation --input image.nii.gz --mask mask.nii.gz --output texture_features
Pipeline Workflow
The pipeline performs the following processing steps:
- Brain Extraction: Using SynthSeg-based segmentation for T1w, FLAIR, and DWI
- Optionally remove cerebellum with
--rm-cerebellum
- Optionally remove cerebellum with
- Bias Field Correction: Using N4 bias field correction
- Brain Segmentation: Using SynthSeg for T1w and FLAIR
- Registration:
- FLAIR to T1w space
- T1w to MNI152 standard space
- DWI Processing (if enabled):
- Denoising with Patch2Self
- Motion correction
- Susceptibility distortion correction
- Tensor fitting and DTI metrics calculation
- Registration to T1w space
- Texture Feature Generation: On normalized images
- Brain-Extracted Outputs (if
--extract-brainenabled):- Creates skull-stripped versions of all outputs in dedicated directory
- Normalized versions also created
- Quality Control: Calculating quality metrics
- Cleanup: Removes temporary files (unless
--keep-tempis specified)
Output Structure
The pipeline creates a structured output directory:
output/
├── <subject>/
│ └── <session>/
│ ├── anat/ # Anatomical images (brain-extracted, bias-corrected)
│ ├── dwi/ # Processed diffusion data and DTI metrics
│ ├── metrics/ # Quality metrics and DICE scores
│ ├── textures/ # Texture features
│ └── xfm/ # Transformation matrices and warps
Configuration
MICAFlow can be configured via:
- Command Line Arguments: For quick setup and individual module usage
- Configuration File: YAML file for complex setups (specify with
--config-file) - Default Configuration: Located in config.yaml
System Requirements
- CPU: Multi-core recommended for parallel processing
- RAM: 8GB minimum, 16GB+ recommended
- GPU: Optional but recommended for faster processing (CUDA compatible)
- Disk Space: Depends on dataset size, minimum 10GB recommended
Supported Image Formats
- NIfTI (.nii, .nii.gz)
- BIDS-compatible directory structures
Support and Contact
For issues, questions or feature requests, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file micaflow-1.0.2.tar.gz.
File metadata
- Download URL: micaflow-1.0.2.tar.gz
- Upload date:
- Size: 131.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08955db31bec58756d5092d8d7be1806430d5a4682ee4e13ec366993a596d0cb
|
|
| MD5 |
b2aadd1772b19b6488796f894c8b0218
|
|
| BLAKE2b-256 |
1f050248d09245b71b603f63380a7c53d971354cfa9212eead93710eb5f8bb0d
|
File details
Details for the file micaflow-1.0.2-cp310-cp312-win_amd64.whl.
File metadata
- Download URL: micaflow-1.0.2-cp310-cp312-win_amd64.whl
- Upload date:
- Size: 139.1 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
384619ae9ef87a31114b5ce376fbbc383054b14ac9ce52521000e093f84e0733
|
|
| MD5 |
5a16404897500d9461bb227809446ddc
|
|
| BLAKE2b-256 |
dcd04b48f79c25b642fe8eb9f61a19f1389c22282fcff6c934bdb89553ab80f3
|
File details
Details for the file micaflow-1.0.2-cp310-cp312-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: micaflow-1.0.2-cp310-cp312-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 138.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48bc98bab7a5a8601a6eb6f70a05219ae9a4c3267d113097e49fc3a195f7eaf4
|
|
| MD5 |
189462a2ed3d64ba603569d3173b5a7e
|
|
| BLAKE2b-256 |
9f4e04105dfb7458dd35bb908ad88fa5b717ed54059cc09db2d91bbf16cedea0
|
File details
Details for the file micaflow-1.0.2-cp310-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: micaflow-1.0.2-cp310-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 138.8 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f47f507f87e71afe6924dc46e7750f46d4766c010b9e678de13b9bb29d94fae9
|
|
| MD5 |
ab1b53f1b5321be5ffd60474f2334435
|
|
| BLAKE2b-256 |
13216f3d7f8b4f548aa249b3f4e91280f84555607cb4c45c63042e46fd9ce64f
|