Fslgrad vs grad format

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 - the code suggests that FSL assumes a LHS coordinate system 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);

I think your information may be a little out of date…? All relevant commands, including dwi2tensor support both formats seamlessly, and have done so for quite some time… :wink:

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

1 Like

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 relatively new documentation page.