Checks whether DWI bvecs need to be flipped along x, y or z by comparing slice-wise diffusion signal directionality with the gradient directions, using DIPY and NiBabel.
Checks whether DWI bvecs need to be flipped along x, y or z by comparing slice-wise diffusion signal directionality with the gradient directions, using DIPY and NiBabel.
Reads the DWI, bvals and bvecs, selects volumes whose gradients point along diagonal directions and compares the signal in each slice to detect whether the bvec polarity is consistent with the image, reporting the result and image header information in product.json. Use it as a quick QC check before tensor fitting or tractography; incorrect bvec polarity leads to wrong fibre orientations. It does not modify the data.
| Inputs | neuro/dwi |
| Container | brainlife/dipy:1.1.1 |
| Resources | 1 CPUs |
| Run it | doi.org/10.25663/bl.app.85 |
| Input | Datatype | Required | Description |
|---|---|---|---|
dwi |
neuro/dwi |
yes | Diffusion-weighted image with bvals and bvecs to check. |
Open the App at doi.org/10.25663/bl.app.85, choose neuro/dwi from your project and press Execute.
You need Singularity/Apptainer (the App runs in brainlife/dipy:1.1.1), jq.
-
Clone this repository.
-
Create
config.jsonwith the paths to your inputs and the parameters:{ "dwi": "/path/to/dwi/dwi", "bvecs": "/path/to/dwi/bvecs", "bvals": "/path/to/dwi/bvals" } -
Run
./main.
If you don't have your own input file, you can download sample datasets from Brainlife.io, or you can use Brainlife CLI.
npm install -g brainlife
bl login
mkdir input
bl dataset download 5a050a00eec2b300611abff3 && mv 5a050a00eec2b300611abff3 input/dwi
This plot shows that most slices has very low evidence of no flip.
This plot shows that the image does not seem to be flipped, however, X/Y and Y/Z are close to being inconclusive. The image might be blurry, or has low SNR.
This plot shows that x/y, y/z are flipped. Since the common axis on x/y and y/z are y, we conclude that y axis is flipped in bvecs. However the flip evidence is close to inconclusiv. The image might be blurry, or has low SNR.
This App also generates plotly graphs showing the arrangements of gradient vectors.
If you use this App, please cite it, the software it builds on and brainlife.io:
- Check Gradient Flip. brainlife.io App. doi:10.25663/bl.app.85
- Garyfallidis et al. Dipy, a library for the analysis of diffusion MRI data. Frontiers in Neuroinformatics 8 (2014). doi:10.3389/fninf.2014.00008
- Hayashi S, Caron BA, Heinsfeld AS, et al. brainlife.io: a decentralized and open-source cloud platform to support neuroscience research. Nature Methods 21:809–813 (2024). doi:10.1038/s41592-024-02237-2
- Avesani P, McPherson B, Hayashi S, et al. The open diffusion data derivatives, brain data upcycling via integrated publishing of derivatives and reproducible open cloud services. Scientific Data 6:69 (2019). doi:10.1038/s41597-019-0073-y
- Soichi Hayashi
Project directors
- Franco Pestilli (@francopestilli)
brainlife.io is publicly funded, and acknowledging that support helps keep it running. This App was developed with support from Wellcome, the U.S. National Institutes of Health (including the BRAIN Initiative BRAIN CONNECTS program: The Axonal Projectome EXchange, U24NS140384, and the Center for Mesoscale Connectomics, UM1NS132207) and the U.S. National Science Foundation.
See LICENSE.



