# Fslgrad vs grad format

**URL:** https://community.mrtrix.org/t/fslgrad-vs-grad-format/1189
**Category:** Uncategorized
**Created:** [September 23, 2017, 7:58pm UTC](https://community.mrtrix.org/t/fslgrad-vs-grad-format/1189 "2017-09-23T19:58:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Chris\_Rorden](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/d9b06d/32.png) [@Chris\_Rorden](https://community.mrtrix.org/u/Chris_Rorden)
#### Post date: [September 23, 2017, 7:58pm UTC](https://community.mrtrix.org/t/fslgrad-vs-grad-format/1189/1 "2017-09-23T19:58:45Z")

</div>

Hello, I want to use **dwi2tensor** in an existing pipeline where dcm2niix was used to create NIfTI images as well as FSL format bval/bvec files. While **dwipreproc** supports **-fslgrad** , tools like **dwi2tensor** only supports the grad file format. Is the conversion [still complex](http://community.mrtrix.org/t/bug-in-fsl-bvecs-handling/165) - the code suggests that [FSL assumes a LHS coordinate system](https://github.com/MRtrix3/mrtrix3/blob/master/src/dwi/gradient.cpp) whereas MRtrix does not. My niave Matlab code (below) seems to work with my examples, but I am not sure if this is a universal solution. In brief, is there an easy way to convert FSL bvec/bval files to MRtrix when the images are in NIfTI format, and if not is there a chance that **dwi2tensor** could be upgraded to support the **-fslgrad** arguments?

> bval=load(bval\_nam);  
> bvec=load(bvec\_nam);  
> %create MRTrix compatible grad file: size [ndwis, 4], format: [gx, gy, gx, b]  
> grad = [bvec; bval]';  
> fid = fopen(grad\_nam,‘w’);  
> for i = 1 : size(grad,1)  
> fprintf(fid, ‘%g %g %g %g\n’, grad(i,1), grad(i,2), grad(i,3), grad(i,4));  
> end;  
> fclose(fid);

---

<div class="post-metadata">

### Author: ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)
#### Post date: [September 23, 2017, 8:53pm UTC](https://community.mrtrix.org/t/fslgrad-vs-grad-format/1189/2 "2017-09-23T20:53:43Z")

</div>

> [@Chris\_Rorden](#):
>
> While dwipreproc supports -fslgrad, tools like dwi2tensor only supports the grad file format.

I think your information may be a little out of date…? All relevant commands, including [dwi2tensor](http://mrtrix.readthedocs.io/en/latest/reference/commands/dwi2tensor.html#dw-gradient-table-import-options) support both formats seamlessly, and have done so [for quite some time](https://github.com/MRtrix3/mrtrix3/pull/61)… 😉

---

<div class="post-metadata">

### Author: ![Chris\_Rorden](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/d9b06d/32.png) [@Chris\_Rorden](https://community.mrtrix.org/u/Chris_Rorden)
#### Post date: [September 23, 2017, 9:08pm UTC](https://community.mrtrix.org/t/fslgrad-vs-grad-format/1189/3 "2017-09-23T21:08:27Z")

</div>

Terrific, I missed that. Thanks for the terrific set of tools.

---

<div class="post-metadata">

### Author: ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)
#### Post date: [September 28, 2017, 1:40pm UTC](https://community.mrtrix.org/t/fslgrad-vs-grad-format/1189/4 "2017-09-28T13:40:34Z")

</div>

Just for the sake of completeness / accuracy:

The difference between the FSL `bvecs` / `bvals` format and the _MRtrix3_ gradient table format is _not_ just LAS vs. RAS orientations: the former is defined with respect to image space, whereas the latter is in real / scanner space. Therefore, if the image transform is anything other than an identity matrix, your script will actually perform an _incorrect_ conversion.

Some more details in [this](http://mrtrix.readthedocs.io/en/latest/concepts/dw_scheme.html) relatively new documentation page.
