Fa color maps

Hi All,

I am just wondering, how can I create colored FA maps for diffusion data ?


1 Like

Yes, amazingly this isn’t actually documented explicitly in the documentation… This should get you going:

dwi2tensor dwi.mif tensor.mif
tensor2metric tensor.mif -vec dec.mif

You can also do it in one go using Unix pipes:

dwi2tensor dwi.mif - | tensor2metric - -vec dec.mif

if you want to clean up your results, you can also supply a mask to either command using the -mask option. And if you want other types of tensor metrics, you can use e.g. the -fa, -adc, -ad, rd, etc. options to tensor2metric.

1 Like

There is a critical piece missing, the command tensor2metric produces positive and negative values. Many MRI tools such as the popular ITKSnap will not display such FAC maps correctly, as they distinguish positive and negative.
I am actually not certain negative vector directions are meaningful in this context?
To correct this one would need to add a command such as fslmaths -abs, i.e. the total pipeline would be something like

dwi2tensor dwi.mif - | tensor2metric - -vec dec.nii
fslmaths dec.nii -abs fac.nii

I know it seems almost trivial, but believe me finding it out can be extremely frustrating and time consuming, and computing FAC maps seems like a common starting point when dipping one’s toe into the DWI world.

Hi all,

Just adding to this discussion in case my input can be of help. I also wanted to generate FA maps for my analysis, and struggled with negative values that didn’t seem to carry meaningful information given that FA values range from 0 to 1.

So what I did was introduce this step to my processing script - mrcalc fa_sub0?ses1.nii -finite fa_sub0?ses1_mask.nii to make sure I am looking at finite values. For me, this fixed the issue and I no longer kept obtaining negative values for parameters that in theory should be positive.

Hope this helps.

Best regards,

Hi Mark,

This output can actually be used as input for tractography (using the FACT algorithm in tckgen), and so them being allowed to be negative is actually important. We could provide another command-line option that produces output that is only intended for RGB display, but I wouldn’t want to modify the -vec option itself for that reason. I appreciate your frustration when feeding these data into other software packages though – I just don’t think issues like this can be avoided, particularly when dealing with diffusion directions, given the different conventions assumed by different packages.

One option however is to add an additional, dedicated -dec option that would take the absolute values before storing the output. This is a relatively trivial addition, and I encourage you to submit a feature request for it.

As a minor aside, you can easily achieve the same as your command using mrcalc:

dwi2tensor dwi.mif - | tensor2metric - -vec - | mrcalc - -abs fac.nii
1 Like

Yes, this issue can arise and has been discussed a few times before (e.g. here and here). We’ve thought about constraining the fit before, but never really took it further than that. If you have a use case where these things really matter, please let us know so we can figure out whether there’s anything we can or should do about it.

I note however that the command you mention (mrcalc -finite) wouldn’t fix FA<0 or FA>1 issues. It would only detect voxels that don’t contain not-a-number (NaN) or infinities, which is a different problem. These can be caused by negative values in the input DWI to dwi2tensor, but this shouldn’t happen with recent versions of MRtrix3 (since this commit in 2015). Please let me know if you still encounter NaNs or Infs in your outputs with recent versions of the software.

Thanks, avoiding to save the intermediate image seems more elegant.

Hi Donald
Something is wrong with the command you send me. Or I am making a stupid mistake of course, but I have limited experience with piping so it’s entirely possible.

I suspect, however, it is something wrong, I receive the error message "mrmath: [ERROR] unknown option “-abs” "
Suggesting mrmath interprets ‘-abs’ as an option not an operation.

Most exactly, I tried the following command:
$ dwi2tensor sub-02_ses-14_run-01_dwi_prepro.mif - | tensor2metric - -vec - | mrmath - -abs sub-02_ses-14_run-01_FAC.nii

but I also tried a more simplified version as I do want to keep the tensor file…

$ tensor2metric sub-02_ses-14_run-01_tensor.mif -vec - | mrmath - -abs sub-02_ses-14_run-01_FAC.nii

Anyhow, both give the same error message…
I am not sure a dedicated -dec option is required, maybe just adding one or two sentences explaining in the help section of tensor2metric -vec is all that would be required.

Hi Mark,

you should use mrcalc instead of mrmath. (I have taken the liberty to update the reply of @jdtournier above).


Oops… Sorry! :grimacing:

Thanks for your help. I used these command lines to generate a colored FA map, which contains red, green and blue components, corresponding to the intensity within each voxel. However, this RGB color scheme might not be friendly for the color-blinded readers. Is it possible to change another color scheme in MRtrix? Similarly, tck. file contains fiber tracking result, which also use RGB to encode the orientation of fiber tracts. Is it also possible to change another color scheme to show the tractography result? Thanks again for your help.