I used the commands dwi2tensor and subsequently tensor2metric in order to compute tensor components (the fa of the tensor and the mean diffusivity of the tensor) from dwi.mif files.
When I subsequently used the output from these operations for my next step of analysis (using SPM12 embedded in Matlab), I noticed that there are NaNs in the images (both in the fa and in the adc images) and this messes up the steps.
I am wondering whether there is an option to exclude NaNs right from the beginning because otherwise I have to tackle them at a later stage and it would seem very handy to be able to do that from the very start.
tensor2metric -fa - when specifying the option> adding a specification about excluding non-numerical values?
Maybe that is a bit of an unusual question, but I would be very curious to know if you can recommend a workaround this issue?
To confirm, you are asking specifically about changing the NaN values present in the FA / MD images to some other finite value?
(I want to clarify as there’s been prior discussion about the exclusion of implausible values in the DWIs when performing the tensor fit; so this would be influencing whether or not the outcome of the tensor fit is reasonable, rather than trying to mitigate the effects of an unreasonable tensor fit after the fact)
If that is the case, then there’s nothing specifically within tensor2metric, but you can replace non-finite values with some other value after the fact:
mrcalc FA.mif -finite FA.mif 0.0 -if FA_nonan.mif
This places the value 0.0 in any voxel where the value of image FA.mif is not finite. For MD you however have the issue of determining an appropriate replacement value; it’s not a matter of “excluding non-numerical values” so much as substituting.
I want to change NaN values present in the FA/MD images to a finite value (I guess), just to be different than the value 0. I will try with the mrcalc solution you suggested and get back to the discussion in case this is useful for someone else too.
As for the MD, would you suggest trying to substitute non-numerical values with a command such as mrdegibbs.
I tried running the mrcalc solution you suggested, using the nii. files I have got (not mif.) but I get an error code: Could not interpret string “fa_nii.” (file I am using) as either an image path or a numerical value.
I tried changing the name of the respective file and calling the command from the folder where the file is located in (in order not to specify the whole directory’s name, but only the file name) but the command still did not get accepted.
Thank you for this advice. The file is called ‘fa_sub07ses1.nii’ and I tried renaming it to remove the underscore or numbers and I still get the error. When I tried to run it in debug mode, it came up with the following:
mrinfo: [INFO] reading config file “/etc/mrtrix.conf”…
mrinfo: [DEBUG] reading key/value file “/etc/mrtrix.conf”…
mrinfo: [DEBUG] No config file found at “/home/ivana/.mrtrix.conf”
mrinfo: [INFO] opening image “fa_sub07ses1.nii”…
mrinfo: [DEBUG] memory-mapping file “fa_sub07ses1.nii”…
mrinfo: [DEBUG] file “fa_sub07ses1.nii” mapped at 0x7fdbe8201000, size 4587872 (read-only)
mrinfo: [DEBUG] transforms_match: FOV difference in scanner coordinates: 0.024943885309450468
mrinfo: [DEBUG] unmapping file “fa_sub07ses1.nii”
mrinfo: [DEBUG] sanitising image information…
mrinfo: [INFO] Axes and transform of image “fa_sub07ses1.nii” altered to approximate RAS coordinate system
mrinfo: [DEBUG] searching for suitable phase encoding data…
mrinfo: [INFO] image “fa_sub07ses1.nii” opened with dimensions 128x128x70, voxel spacing 1.75x1.75x2, datatype Float32LE
Dimensions: 128 x 128 x 70
Voxel size: 1.75 x 1.75 x 2
Data strides: [ -1 2 3 ]
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9992 -0.03874 1.455e-11 -105.6
0.03874 0.9992 -0.004538 -113.9
0.0001758 0.004534 1 -107.2
Any further advice on this would be greatly appreciated.
Actually the file name was the above one from the very beginning (the fa_nii thing was just to try and shorten providing my full path directories for the sake of brevity > but not a good exemplar name indeed!)