How to rotate bvecs of a monkey data in Sphinx position

Hi mrtrix experts,

I am using Mrtrix to observe fiber tracts of a monkey, however, the monkey was in Sphinx position. I have to use ITK-snap to reorient the data. My question is that the rotation may change the spatial relationship between the data and the bvecs. And I cannot get the reorientation matrix to reorient the bvecs as well.

Is there any tip to resolve this problem?


The left is the data in the sphinx position, and the right one is the reoriented one.
The corresponding headers of the data are shown below.
The first one is the sphinx position data.
The second one is the sphinx reoriented data.

image

Thanks,
Feihong

You can use the method described in Automated correction of improperly rotated diffusion gradient orientations in diffusion weighted MRI - PubMed to correct your gradient directions as follows:

dwigradcheck RL_4d.nii.gz -fslgrad bvecs bvals -export_grad_mrtrix grad.txt
mrconvert RL_4d.nii.gz -grad grad.txt RL_4d.mif

RL_4d.mif should now contain the correct gradient orientations in its header. Any subsequent commands (dwi2fod, tckgen, etc) can now read the gradient information directly from the .mif file without need to specify the gradient information using -grad or -fslgrad.

If you want to read up on how MRtrix deals with gradient information, consult Diffusion gradient scheme handling — MRtrix 3.0 documentation.

Hi Ben,

Thanks for your answers, your paper, and your method ‘dwigradcheck’.
Because I did not get the expected results, so I take some time to read your paper.

I have three questions, maybe they are silly because of my little knowledge of diffusion MRI data preprocessing.

  1. I used ITK-snap to reorientate the data, maybe, I switched the y and z axes. As my expectation, in this case, the gradient table should also switch the y and z axes. However, I cannot see that after using your method as the case below,
    dwigradcheck RL.nii -fslgrad ../RL_20211125/RL_bvecs ../RL_20211125/RL_bvals export_grad_fsl RL_bvecs_rot RL_bvals_rot
  2. I checked your paper, I find that the claim of your paper is to rotate the gradient table by exploiting fiber length. But, dwigradcheck is really fast, I even cannot believe it can be finished in less than 2 minutes. That’s amazing! How do you make that?
  3. Because my results, i.e., the gradient table was not switched, and I neither see the switching capability as claimed in your paper, I am wondering that is switching necessary?

Thanks,
Feihong Liu

 The rotated results are listed below:

cat LR_bvecs_rot
0 0 0 0 0 -0.9999938215 -0.9999938215 -0.9999938215 -0.9999938215 -0.9999938215 -0.01154420436 -0.01154420436 -0.01154420436 -0.01154420436 -0.01154420436 0.02939010441 0.02939010441 0.02939010441 0.02939010441 0.02939010441 -0.8643049237 -0.8643049237 -0.8643049237 -0.8643049237 -0.8643049237 -0.8400132596 -0.8400132596 -0.8400132596 -0.8400132596 -0.8400132596 -0.8345002892 -0.8345002892 -0.8345002892 -0.8345002892 -0.8345002892 -0.8557680928 -0.8557680928 -0.8557680928 -0.8557680928 -0.8557680928 -0.8240328422 -0.8240328422 -0.8240328422 -0.8240328422 -0.8240328422 -0.5591720188 -0.5591720188 -0.5591720188 -0.5591720188 -0.5591720188 -0.4805499561 -0.4805499561 -0.4805499561 -0.4805499561 -0.4805499561 -0.5279356794 -0.5279356794 -0.5279356794 -0.5279356794 -0.5279356794 -0.4011021543 -0.4011021543 -0.4011021543 -0.4011021543 -0.4011021543 -0.4818517727 -0.4818517727 -0.4818517727 -0.4818517727 -0.4818517727 -0.3924419832 -0.3924419832 -0.3924419832 -0.3924419832 -0.3924419832 -0.5146098834 -0.5146098834 -0.5146098834 -0.5146098834 -0.5146098834 -0.4661230976 -0.4661230976 -0.4661230976 -0.4661230976 -0.4661230976 -0.5519697417 -0.5519697417 -0.5519697417 -0.5519697417 -0.5519697417 -0.1134189801 -0.1134189801 -0.1134189801 -0.1134189801 -0.1134189801 -0.1177839883 -0.1177839883 -0.1177839883 -0.1177839883 -0.1177839883 -0.04296541811 -0.04296541811 -0.04296541811 -0.04296541811 -0.04296541811
0 0 0 0 0 -9.880128237e-05 -9.880128237e-05 -9.880128237e-05 -9.880128237e-05 -9.880128237e-05 0.01827350691 0.01827350691 0.01827350691 0.01827350691 0.01827350691 -0.5845750877 -0.5845750877 -0.5845750877 -0.5845750877 -0.5845750877 0.1574279861 0.1574279861 0.1574279861 0.1574279861 0.1574279861 -0.4487111386 -0.4487111386 -0.4487111386 -0.4487111386 -0.4487111386 -0.4609811597 -0.4609811597 -0.4609811597 -0.4609811597 -0.4609811597 0.1374750149 0.1374750149 0.1374750149 0.1374750149 0.1374750149 0.5663808916 0.5663808916 0.5663808916 0.5663808916 0.5663808916 0.7256330244 0.7256330244 0.7256330244 0.7256330244 0.7256330244 0.3078389719 0.3078389719 0.3078389719 0.3078389719 0.3078389719 -0.265117839 -0.265117839 -0.265117839 -0.265117839 -0.265117839 -0.7516882892 -0.7516882892 -0.7516882892 -0.7516882892 -0.7516882892 -0.8762175866 -0.8762175866 -0.8762175866 -0.8762175866 -0.8762175866 -0.7720759669 -0.7720759669 -0.7720759669 -0.7720759669 -0.7720759669 -0.2975929326 -0.2975929326 -0.2975929326 -0.2975929326 -0.2975929326 0.2736070573 0.2736070573 0.2736070573 0.2736070573 0.2736070573 0.7081876686 0.7081876686 0.7081876686 0.7081876686 0.7081876686 0.9531348331 0.9531348331 0.9531348331 0.9531348331 0.9531348331 0.9639719039 0.9639719039 0.9639719039 0.9639719039 0.9639719039 0.6169962601 0.6169962601 0.6169962601 0.6169962601 0.6169962601
-0 -0 -0 -0 -0 0.003513849373 0.003513849373 0.003513849373 0.003513849373 0.003513849373 -0.9997663779 -0.9997663779 -0.9997663779 -0.9997663779 -0.9997663779 -0.8108071217 -0.8108071217 -0.8108071217 -0.8108071217 -0.8108071217 -0.4776959578 -0.4776959578 -0.4776959578 -0.4776959578 -0.4776959578 -0.3050180942 -0.3050180942 -0.3050180942 -0.3050180942 -0.3050180942 0.3018371046 0.3018371046 0.3018371046 0.3018371046 0.3018371046 0.4987600541 0.4987600541 0.4987600541 0.4987600541 0.4987600541 0.01351149741 0.01351149741 0.01351149741 0.01351149741 0.01351149741 -0.4009780135 -0.4009780135 -0.4009780135 -0.4009780135 -0.4009780135 -0.821161925 -0.821161925 -0.821161925 -0.821161925 -0.821161925 -0.8068435101 -0.8068435101 -0.8068435101 -0.8068435101 -0.8068435101 -0.5235282014 -0.5235282014 -0.5235282014 -0.5235282014 -0.5235282014 -0.007849206297 -0.007849206297 -0.007849206297 -0.007849206297 -0.007849206297 0.4998879786 0.4998879786 0.4998879786 0.4998879786 0.4998879786 0.8041238178 0.8041238178 0.8041238178 0.8041238178 0.8041238178 0.8413491761 0.8413491761 0.8413491761 0.8413491761 0.8413491761 0.440226794 0.440226794 0.440226794 0.440226794 0.440226794 0.2804819509 0.2804819509 0.2804819509 0.2804819509 0.2804819509 -0.2385059762 -0.2385059762 -0.2385059762 -0.2385059762 -0.2385059762 -0.7857923313 -0.7857923313 -0.7857923313 -0.7857923313 -0.7857923313
And the gradient table before rotation is shown below,
cat ../LR_20211125/LR_bvecs
0 0 0 0 0 0.999994 0.999994 0.999994 0.999994 0.999994 0.0115442 0.0115442 0.0115442 0.0115442 0.0115442 -0.0293901 -0.0293901 -0.0293901 -0.0293901 -0.0293901 0.864305 0.864305 0.864305 0.864305 0.864305 0.840013 0.840013 0.840013 0.840013 0.840013 0.8345 0.8345 0.8345 0.8345 0.8345 0.855768 0.855768 0.855768 0.855768 0.855768 0.824033 0.824033 0.824033 0.824033 0.824033 0.559172 0.559172 0.559172 0.559172 0.559172 0.48055 0.48055 0.48055 0.48055 0.48055 0.527936 0.527936 0.527936 0.527936 0.527936 0.401102 0.401102 0.401102 0.401102 0.401102 0.481852 0.481852 0.481852 0.481852 0.481852 0.392442 0.392442 0.392442 0.392442 0.392442 0.51461 0.51461 0.51461 0.51461 0.51461 0.466123 0.466123 0.466123 0.466123 0.466123 0.55197 0.55197 0.55197 0.55197 0.55197 0.113419 0.113419 0.113419 0.113419 0.113419 0.117784 0.117784 0.117784 0.117784 0.117784 0.0429654 0.0429654 0.0429654 0.0429654 0.0429654
0 0 0 0 0 -9.88013e-05 -9.88013e-05 -9.88013e-05 -9.88013e-05 -9.88013e-05 0.0182735 0.0182735 0.0182735 0.0182735 0.0182735 -0.584575 -0.584575 -0.584575 -0.584575 -0.584575 0.157428 0.157428 0.157428 0.157428 0.157428 -0.448711 -0.448711 -0.448711 -0.448711 -0.448711 -0.460981 -0.460981 -0.460981 -0.460981 -0.460981 0.137475 0.137475 0.137475 0.137475 0.137475 0.566381 0.566381 0.566381 0.566381 0.566381 0.725633 0.725633 0.725633 0.725633 0.725633 0.307839 0.307839 0.307839 0.307839 0.307839 -0.265118 -0.265118 -0.265118 -0.265118 -0.265118 -0.751688 -0.751688 -0.751688 -0.751688 -0.751688 -0.876218 -0.876218 -0.876218 -0.876218 -0.876218 -0.772076 -0.772076 -0.772076 -0.772076 -0.772076 -0.297593 -0.297593 -0.297593 -0.297593 -0.297593 0.273607 0.273607 0.273607 0.273607 0.273607 0.708188 0.708188 0.708188 0.708188 0.708188 0.953135 0.953135 0.953135 0.953135 0.953135 0.963972 0.963972 0.963972 0.963972 0.963972 0.616996 0.616996 0.616996 0.616996 0.616996
0 0 0 0 0 0.00351385 0.00351385 0.00351385 0.00351385 0.00351385 -0.999766 -0.999766 -0.999766 -0.999766 -0.999766 -0.810807 -0.810807 -0.810807 -0.810807 -0.810807 -0.477696 -0.477696 -0.477696 -0.477696 -0.477696 -0.305018 -0.305018 -0.305018 -0.305018 -0.305018 0.301837 0.301837 0.301837 0.301837 0.301837 0.49876 0.49876 0.49876 0.49876 0.49876 0.0135115 0.0135115 0.0135115 0.0135115 0.0135115 -0.400978 -0.400978 -0.400978 -0.400978 -0.400978 -0.821162 -0.821162 -0.821162 -0.821162 -0.821162 -0.806844 -0.806844 -0.806844 -0.806844 -0.806844 -0.523528 -0.523528 -0.523528 -0.523528 -0.523528 -0.00784921 -0.00784921 -0.00784921 -0.00784921 -0.00784921 0.499888 0.499888 0.499888 0.499888 0.499888 0.804124 0.804124 0.804124 0.804124 0.804124 0.841349 0.841349 0.841349 0.841349 0.841349 0.440227 0.440227 0.440227 0.440227 0.440227 0.280482 0.280482 0.280482 0.280482 0.280482 -0.238506 -0.238506 -0.238506 -0.238506 -0.238506 -0.785792 -0.785792 -0.785792 -0.785792 -0.785792

Oh, I also have another question.
I found your codes detected the axis permutations, however, I did not see the switching.
And I also find there are a lot of information, can you provide me more information about that?

You have to thank @rsmith for the MRtrix implementation!

Because of the antipodal symmetry of gradient directions, switching both the y- and z-axis is equivalent to switching just the x-axis.

dwigradcheck is fast because tckgen (the fiber tracking command from MRtrix) is fast.

If you look carefully at the bvecs file before vs after correction you can see that the sign of the first row has been flipped. So it did correct your gradient table. This is also what you can tell from the first line of the output:

“Axis flipped: 0” indicates that the sign of the first axis needed to be flipped, whereas “Permutation: (0, 1, 2)” indicates that no permutation was needed.

The knowledge of antipodal symmetry of gradient directions is really new to me. Thanks for your explanation in more detail, which let me learn easily. Also many thanks to the MRtrix team, especially for @rsmith