Bvecs handling

Hello hello, i recently have started playing around with some transformations of images and i was curious if it was possible to apply the same spatial transformation that I have conducted on an image to the bvecs file. If so, what would be the best method to go about doing so for easy use in MrTrix. Thank you in advance!

If your transformation is rigid, you can embed the bvecs in a dMRI .mif file using mrconvert -fslgrad and transform that file using mrtransform. The gradient table is handled appropriately and can be exported using mrinfo -export_grad_fsl.

For non-rigid transformations, the issues Rob describes here apply.

1 Like

Lovely! I appreciate it.

1 Like

So after doing some digging, this should also be possible through mrtransform; link:https://mrtrix.readthedocs.io/en/latest/reference/commands/mrtransform.html. However, when trying to implement it the options for exporting the grad files is not available. Did mrtrix just stop supporting this?

No, it’s still supported! What commands did you try to run exactly?

mrtransform <options (-export_grad_mrtrix & -export_grad_fsl> . When i remove the export function calls from the command line mrtransform does run.

So what im currently trying to do is apply a spatial transformation on my bvecs file since i am converting the Diffusion Weighted image into fmri space and I want to bring the bvecs along. I guess an additional question is this even issue, does MRtrix normalize the bvecs during tckgen to fit the image at hand? Im conducting tractography in fmri space to conserve memory and computational cost in an analysis im conducting later down the line. Any insight much appreciated :).

Is that the full command as you typed into the terminal? That definitely won’t work…

What I’d expect to work is something like this:

mrtransform in.nii -fslgrad bvecs_in bvals_in -linear transform.txt out.nii -export_grad_fsl bvecs_out bvals_out

You need the first -fslgrad import option to associate the relevant bvecs & bvals with your input DWI, and the second -export_grad_fsl export option to ensure the modified bvecs & bvals are written out to the relevant files.

It’s pretty clunky, which is one of the main reasons we advocate the use of the MRtrix .mif format, where all this is stored in the image header so you don’t need to keep track of which bvecs/bvals belong to which DWI.

right right yes i used the -fslgrad option as well and the linear transform. I guess i want to extract the bvecs bvals of the transformed image–> if that makes sense

You’ll find all the relevant information about this in the docs. But I’m not sure what you mean by ‘to fit the image at hand’…? The normalisation is independent of the image itself, though the orientations are defined with respect to the image axes.

So are you saying that adding the -export_grad_fsl bvecs_out bvals_out didn’t work…?

exactly, it did not work nor did it show on the mrtransform documentation when you simply wanna look at the commands

Ok, you might be using an old version. What does mrtransform -version report?

mrtransform 3.0-RC3-51

Yep, earliest official version with that option was 3.0.0 – with this commit.

If you need to stick with the same version, something like this:

mrtransform in.nii -fslgrad bvecs_in bvals_in -linear transform.txt - | mrconvert - out.nii -export_grad_fsl bvecs_out bvals_out