Reorienting dwi data and bvecs

Hello!
After acquiring diffusion weighted MRI data, and converting the DICOM to .nii.gz files, we found that the axes in our volumes are wrong: when displaying the .nii.gz volumes, the y- and z-axis are exchanged and the z-axis has a flipped sign. :flushed: We are now trying to reorient the images while maintaining the correct b-vectors. Our code is the following:

mrconvert -json_import dwidata.json -fslgrad dwidata.bvec dwidata.bval dwidata.nii.gz dwidata.mif
mrconvert -axes 0,2,1,3 dwidata.mif dwidata_axisswap.mif
mrtransform -flip 2 dwidata_axisswap.mif dwidata_axisswap_flip.mif
mrconvert -strides 1,2,3,4 dwidata_axisswap_flip.mif dwidata_axisswap_flip_strides.mif

If we now extract the bval and bvec and re-convert the data to nifti

mrconvert -export_grad_fsl reorient.bvec reorient.bval dwidata_axisswap_flip_strides.mif dwidata_axisswap_flip_strides.nii.gz

and run dtifit on the data

dtifit -k dwidata_axisswap_flip_strides.nii.gz -r reorient.bvec -b reorient bval -m mask mask.nii.gz -o reorient

the principal diffusion direction do not seem to be correct!

grafik

(this is the V1-file from the dtifit overlaid on the FA-volume)

So it seems that the bvecs were not transformed correspondingly with the image axes…

We are happy about any suggestions, ideas, comments!

Dear @LauraNeuro,

There is a simple method to output the correct gradient directions:

  1. run dwigradcheck on your original data and export the corrected diffusion table -
for_each */ : dwigradcheck IN/dwi/dwi.mif -export_grad_mrtrix IN/dwi/fixed_bvecs.txt
  1. run mrconvert using the fixed gradient table -
for_each */ : mrconvert IN/dwi/dwi.mif IN/dwi/dwi_fixed.mif -grad IN/dwi/fixed_bvecs.txt

Hope this helps,

Nick

2 Likes

I’d double-check the Dicom export by directly converting the Dicom to .mif: DICOM handling — MRtrix 3.0 documentation. You might find that you do not need any adjustments.

1 Like

I didn’t explain: both images have now correct labels thanks to axes switchs and flips through mrtrix commands but in one case (top picture) there was a flip in the bvec which was not present (bottom picture) when using the dwigradcheck command suggested by Nick

Hi Nick, great tip, thank you! Thanks to you, we could go from this situation:

to this:

1 Like

Great, thanks to @bjeurissen who made this nifty tool!

1 Like

@rsmith did the implementation in MRtrix!

2 Likes