Error when using from .mif to .nii transformed FA-maps

Dear Mrtrix community,

I am trying to use FA-maps generated in MrTrix for FSL-based registration (fslflirt). I am a bit worried, because I get fa.nii files with only nan values independent from the mode how I generate them (from .mif before or after dwipreproc). Did anybody have a similar problem or could give me an advice how to solve this issue?

Thank you very much!

Kind regards,

Could you provide the exact commands you used to generate the images? Maybe that’ll give us a hint as to where the problem might be…

Please find attached the code and corresponding images… Thank you for all your help and support!

create dwi.mif from DICOMs

mrconvert DICOMs dwi.mif

preprocess dwi.mif

dwipreproc dwi.mif dwi_preproc.mif -rpe_header
mrconvert dwi_preproc.mif dwi_preproc.nii

pictures of dwi_preproc_mif und dwi_preproc_nii:

create mask.mif

dwi2mask dwi_preproc.mif mask.mif

create dt.mif

dwi2tensor dwi_preproc.mif dt.mif

create fa and adc images

tensor2metric -fa fa.mif -adc adc.mif -mask mask.mif dt.mif

convert mifs to niis

mrconvert dt.mif dt.nii
mrconvert fa.mif fa.nii
mrconvert adc.mif adc.nii

pictures of dt_mif.png, dt_nii.png; fa_mif.png und fa_nii.png:

register dt (or fa or adc) to dwi_preproc

flirt -in dt.nii -ref dwi_preproc.nii -out dt2dwi_preproc.nii

fsl output:

"Final result:

nan nan nan nan

nan nan nan nan

nan nan nan nan

nan nan nan nan"

picture of dt2dwi_preproc:

register dt (or fa or adc) to brain extracted T1

flirt -in dt.nii -ref t1_brain_extracted.nii -out dt2t1.nii

fsl output:

"Final result:

nan nan nan nan

nan nan nan nan

nan nan nan nan

nan nan nan nan"

picture of dt2t1_brainextracted:

OK, looking at your outputs, there’s a few things to mention:

  • clearly your dt.mif image contains NaNs (‘not a number’; the obvious black holes), as well as very large outliers in the background noise. NaNs (or Infs) would show up as intensity ‘?’ in the bottom left of the display when you place the crosshairs on that location. I’m a bit surprised to see NaNs in your results, given the checks that have been put in place to prevent this (the only reason I can think of that would lead to NaNs is that the input DWI contains negative values, since the log() is undefined). The only way I can see this failing is if the original DWI itself contained NaNs to begin with; or all the intensities for that voxel happened to be negative across all volumes - something that seems unlikely in general. In any event, you can reduce that problem by using the -mask option at the dwi2tensor stage.

  • given my concerns above, can I check whether you’re running a recent version of MRtrix3? What does dwi2tensor -version report?

  • the display in mrview is scaled to the minimum & maximum values in the slice displayed (at least in the default single-slice view mode, when locked to axes…). When there are extreme values in your data, like those you show, you’ll need to adjust the intensity window accordingly. If right-click & drag isn’t sufficient to get back in a sensible operating point, try the View tool: you can type the minimum and maximum values in there directly.

  • If you have NaNs in your images, it’s not entirely unexpected that subsequent commands such as flirt might fail - NaNs have an annoying tendency to propagate through any calculation they’re involved in… If needed, you can try removing these values using mrcalc, using a command like this:

    $ mrcalc dt.mif -finite dt.mif 0 -if dt_out.mif
    mrcalc: [100%] computing: (finite (dt.mif) ? dt.mif : 0)
  • I don’t see that trying to register the dt.mif image to anything makes much sense: it’s a 4D, multi-volume image, with directionally-dependent signal. I expect only the first volume will be used anyway. You’re better off using the (3D, scalar) FA map for these purposes, if you have to.

  • Why are you trying to register the DT/FA/ADC map to the DWI data they were generate from? They’re already inherently aligned… (?).

  • Registering the T1 to the FA makes sense, but be wary of registering the FA to the T1: while that may work, applying the resulting transformation to the DWI or DT data may invalidate the DW gradient information if you’re not careful, since any rotation or shear in the affine transform will need to be reflected in the DW directions too.

Hopefully some of these suggestions will help…

Even when not present in the raw data, this can definitely be introduced by dwidenoise or dwipreproc (and commonly is, in fact)…

EDIT: typically at the edges of the brain, that is

@Frederike: you can check for the presence of these negative intensitites easily by:

mrstats dwi.mif

mrstats dwi_preproc.mif

Check the min column of the stats: you may find that it’s all zeros (as I would expect) for dwi.mif, but potentially small negative values for dwi_preproc.mif.