BIDS app and Snakemake workflow for diffusion-weighted imaging (DWI) pre-processing.
snakedwi is a comprehensive workflow for preprocessing diffusion MRI data following the BIDS (Brain Imaging Data Structure) standard. The workflow includes:
- Denoising - Optional MP-PCA denoising
- Susceptibility distortion correction (SDC) - Multiple methods including TOPUP, SynthSR, SDCFlows, and SynB0
- Eddy current correction - FSL's eddy with optional GPU acceleration and slice-to-volume correction
- Brain masking - Multiple methods including BET, SyN registration, and SynthStrip
- Gradient non-linearity correction - Optional scanner-specific correction
- Registration to T1w - Rigid and deformable registration options
- Quality control - Automatic QC reports with eddy_quad
- pixi - A fast package manager
- Clone the repository:
git clone https://github.com/khanlab/snakedwi.git
cd snakedwi- Install dependencies with pixi:
pixi installThis will install snakedwi and all its dependencies in an isolated environment.
Run the workflow with Apptainer (recommended for using containerized tools):
pixi run snakedwi /path/to/bids/dir /path/to/output/dir participant --use-apptainerTo see what the workflow will do without running it:
pixi run snakedwi /path/to/bids/dir /path/to/output/dir participant --use-apptainer -npTo use all available cores:
pixi run snakedwi /path/to/bids/dir /path/to/output/dir participant --use-apptainer --cores all--use-apptainer: Use Apptainer/Singularity containers for tool dependencies--participant_label: Process specific subject(s), e.g.,--participant_label 001 002--sdc_method: Choose susceptibility distortion correction method (optimal,topup,synthsr,sdcflow,synb0,none)--masking_method: Brain masking method (b0_BET,b0_SyN,b0_synthstrip)--cores: Number of cores to use (e.g.,--cores 8or--cores all)-np: Dry-run mode (show what will be executed without running)
pixi run snakedwi /path/to/bids/dir /path/to/output/dir participant \
--use-apptainer \
--participant_label 001 \
--sdc_method topup \
--masking_method b0_synthstrip \
--cores 8Your input data must be organized according to the BIDS specification, specifically:
- DWI data in
sub-*/dwi/with.nii.gzimages and corresponding.jsonsidecar files - Optional T1w anatomical images in
sub-*/anat/ - Metadata including
PhaseEncodingDirectionin JSON files
Processed DWI data will be saved in the specified output directory following the BIDS derivatives format, including:
- Preprocessed DWI images
- Brain masks
- QC reports
- Transformation matrices
- Processing metadata
For detailed documentation, visit: https://snakedwi.readthedocs.io
To run the test suite:
pixi run test_allTo format code:
pixi run quality_fixTo check code quality:
pixi run quality_checkIf you use snakedwi in your research, please cite:
Khan, A. R. (2024). snakedwi: BIDS app and Snakemake workflow for DWI pre-processing.
https://github.com/khanlab/snakedwi
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs or request features at GitHub Issues
- Documentation: https://snakedwi.readthedocs.io
- Repository: https://github.com/khanlab/snakedwi
snakedwi is developed and maintained by the Khan Lab at Western University.