Opening FA color map created by MRtrix in other software

Hi everyone,

We have calculated the FA (colored) map with dwi2tensor and tensor2metric. However, when opening it with other viewers for .nii files, such as MRIcro, it is a greyscale image. It looks like the vector information is saved in layers and only MRview can visualize it as a color map (there it looks normal). Also, Trackvis is unable to open the file (unknown error). How can we solve this?

Many thanks in advance!

Klara

Hi Klara,

Directionally-encoded colour (DEC) data are stored as 4D images with three volumes; the non-negative values in each of these volumes correspond to the red, green and blue components of the colour / intensity of each voxel. This should be evident in the output of mrinfo.

Assuming the data have been generated correctly, which should be the case if mrview shows it correctly, I can think of two things that may conceivably lead to issues:

  • Other softwares may require that the values stored within a DEC image lie within the range [0, 1], and fail to display as such / produce an error if this is not the case. FA values may exceed 1 in the presence of negative eigenvalues. You could try running mrstats on the image, and check the minimum / maximum values.

  • I was going to suggest that other softwares may have been expecting a NIfTI Intent Code to display a DEC image; but there doesn’t actually appear to be an intent code for such…

In MRIcro, is it a greyscale FA image that is shown, or the first volume of the image (i.e. the left-right component of the first eigenvector, scaled by FA)? You can visualise the latter in mrview by changing the colour map from RGB to greyscale.

Rob

I know it’s been a while, but I just happened to be looking through the NIfTI specification for some other reason, and came across their suggestion as to how these kinds of data should be stored. It looks like they expect a 5D image with dimensions X×Y×Z×1×3, with the NIfTI intent code set to NIFTI_INTENT_VECTOR. MRtrix3 won’t set the intent code, but I’m guessing (hoping?) most other software packages will probably ignore them like we do…

So in your case, it might be sufficient to insert an extra singleton dimension along the 4th axis – assuming that’s what other packages expect. In this case, this should do the trick:

mrconvert dec.mif -axes 0,1,2,-1,3 dec.nii

but unfortunately this won’t work until this pull request is reviewed and merged, and you update your installation to match – there’s a bug in the handling of this specific scenario… :blush:

If you’re impatient, you can always make the relevant one-line change to your own installation directly, invoke ./build to re-compile, and you should be good to go.

I suppose that would’ve been using tensor2metric -vector.

This is not 100% correct then: there will be negative values in there for sure. mrview automatically deals with this by ignoring the sign (i.e. taking the absolute value) when using the RGB colour map. The RGB colour map itself is automatically selected when opening a 3-volume 4D image.

So apart from getting it recognised correctly as an RGB image by other software, you might also want to perform an mrcalc -abs on it beforehand.

That must be something different altogether though. I don’t have experience with Trackvis, but maybe it simply doesn’t open 4D images in general? Apart from the intended RGB interpretation of the image, it’s “simply” a regular 4D image after all, so it should at least open in viewers that allow for 4D images. The only possible incompatibility I can think of there (again, based on zero experience, just guessing how other software might be picky about something particular), might be the “voxel size” for the 4th axis? Since it’s not a physical axis, some software might expect a special value there, or some software might not be able to deal with seeing a 4th number for the voxel size at all… Or finally, maybe an expected order of strides, maybe in particular for the 4th axis. Again, all just random guesses. But beyond all that, it’s simply a 4D image, with no other special properties beyond that.