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.
- Structural MRI Processing: T1w and FLAIR image processing
- Diffusion MRI Processing: Complete pipeline for DWI processing
- Brain Extraction: HD-BET for robust skull stripping
- 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
- Modular Design: Components can be used independently or as a complete pipeline
- Flexible Configuration: Via command line arguments or YAML configuration files
- Python 3.9, 3.10, or 3.11
# Clone the repository
git clone https://github.com/MICA-Lab/micaflow.git
cd micaflow
# Install the package
pip install -e .
# Verify installation
micaflow --help
MicaFlow can be used as a complete pipeline or as individual modules:
# 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 \
--out-dir /output/path --cores 4 --cpu
# 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 --out-dir /output/path \
--cores 4 --cpu
# 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 \
--run-dwi --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 \
--out-dir /output/path --cores 4 --cpu
Each module can be used independently:
micaflow bet --input t1w.nii.gz --output brain.nii.gz --output-mask mask.nii.gz
micaflow synthseg --i t1w.nii.gz --o segmentation.nii.gz --parc --fast --threads 4
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
micaflow apply_warp --moving image.nii.gz --reference target.nii.gz \
--warp warp.nii.gz --affine affine.mat --output warped.nii.gz
# 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 --bval dwi.bval --bvec dwi.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
micaflow texture_generation --input image.nii.gz --mask mask.nii.gz --output texture_features
The pipeline performs the following processing steps:
- Brain Extraction: Using HD-BET for T1w, FLAIR, and DWI
- 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
- Quality Control: Calculating quality metrics
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 Jaccard indices
│ ├── textures/ # Texture features
│ └── xfm/ # Transformation matrices and warps
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
- 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
- NIfTI (.nii, .nii.gz)
- BIDS-compatible directory structures
For issues, questions or feature requests, please open an issue on the GitHub repository.