Mtnormalise nan values as balance factors

Dear expert,

I am currently processing diffusion HCP data and I’m getting an error in a few subjects with the mtnormalise command:

mtnormalise: [100%] performing log-domain intensity normalisation
mtnormalise: [ERROR] Non-positive tissue balance factor was computed. Balance factors: -nan -nan -nan

Is there anything I can do to solve this issue? Would removing the nan values in the FODs solve this?

Thank you,

Stefanie

Hi Stefanie,

It’s difficult to know from the error alone what exactly has driven the nonsensical result, so will require a bit of probing the data to diagnose. The first thing you can do is re-run the command with the -debug flag and post the results here, and we’ll see if it yields anything informative.

Would removing the nan values in the FODs solve this?

Not sure to what extent the nature of this question is actually intentional. If you have FOD images that do actually contain NaN values (which would be the exception to the rule), and the compulsory mask input to mtnormalise includes voxels for which there are NaN values in the FOD coefficients, then that could at least conceivably lead to such an error, depending on the intricacies of the code. But something would have to be putting NaN values into the FOD images… So if that turned out to be the case, while we could modify mtnormalise to ignore non-finite values, you’d also want to backtrace exactly how those NaN values made their way into your images, and how whatever mechanism you used to derive your mask image still included such voxels.

Cheers
Rob

1 Like

Hi Rob,

Thanks a lot for the quick reply.

I re-ran the command with the -debug flag and this is the output:

mtnormalise -mask /data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz wm_fod.mif wm_fod_norm.mif gm_scalar.mif gm_scalar_norm.mif csf_scalar.mif csf_scalar_norm.mif -debug 
mtnormalise: [DEBUG] No config file found at "/etc/mrtrix.conf"
mtnormalise: [DEBUG] No config file found at "/home/remoteuser/treste/.mrtrix.conf"
mtnormalise: [INFO] opening image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz"...                                                                                         
mtnormalise: [DEBUG] transforms_match: FOV difference in scanner coordinates: 0
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] Axes and transform of image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz" altered to approximate RAS coordinate system                                 
mtnormalise: [DEBUG] searching for suitable phase encoding data...
mtnormalise: [INFO] image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz" opened with dimensions 145x174x145, voxel spacing 1.25x1.25x1.25, datatype Float32LE               
mtnormalise: [DEBUG] loading image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz"...                                                                                        
mtnormalise: [100%] uncompressing image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz"
mtnormalise: [DEBUG] image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz" loaded                                                                                            
mtnormalise: [DEBUG] image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz" initialised with strides = [ -1 145 25230 ], start = 144, using indirect IO                       
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [DEBUG] allocating scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" loaded
mtnormalise: [DEBUG] image "index" initialised with strides = [ -1 145 25230 ], start = 144, using direct IO
mtnormalise: [INFO] mask image contains 767938 voxels
mtnormalise: [DEBUG] image "/data/neuralabc/treste/Mult_dim_quant_WM/source/108525/T1w/Diffusion/nodif_brain_mask.nii.gz" unloaded                                                                                          
mtnormalise: [INFO] opening image "wm_fod.mif"...
mtnormalise: [DEBUG] reading key/value file "wm_fod.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "wm_fod.mif" opened with dimensions 145x174x145x45, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE                                                                                            
mtnormalise: [DEBUG] memory-mapping file "wm_fod.mif"...
mtnormalise: [DEBUG] file "wm_fod.mif" mapped at 0x7efc40f02000, size 658503000 (read-only)
mtnormalise: [DEBUG] image "wm_fod.mif" loaded
mtnormalise: [DEBUG] image "wm_fod.mif" initialised with strides = [ -45 6525 1135350 1 ], start = 6480, using direct IO                                                                                                    
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 28 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "wm_fod.mif"
mtnormalise: [DEBUG] image "wm_fod.mif" unloaded
mtnormalise: [INFO] opening image "gm_scalar.mif"...
mtnormalise: [DEBUG] reading key/value file "gm_scalar.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "gm_scalar.mif" opened with dimensions 145x174x145x1, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE                                                                                          
mtnormalise: [DEBUG] memory-mapping file "gm_scalar.mif"...
mtnormalise: [DEBUG] file "gm_scalar.mif" mapped at 0x7efc67508000, size 14633400 (read-only)
mtnormalise: [DEBUG] image "gm_scalar.mif" loaded
mtnormalise: [DEBUG] image "gm_scalar.mif" initialised with strides = [ -1 145 25230 145 ], start = 144, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 28 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "gm_scalar.mif"
mtnormalise: [DEBUG] image "gm_scalar.mif" unloaded
mtnormalise: [INFO] opening image "csf_scalar.mif"...
mtnormalise: [DEBUG] reading key/value file "csf_scalar.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "csf_scalar.mif" opened with dimensions 145x174x145x1, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "csf_scalar.mif"...
mtnormalise: [DEBUG] file "csf_scalar.mif" mapped at 0x7efc67503000, size 14633400 (read-only)
mtnormalise: [DEBUG] image "csf_scalar.mif" loaded
mtnormalise: [DEBUG] image "csf_scalar.mif" initialised with strides = [ -1 145 25230 145 ], start = 144, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 28 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "csf_scalar.mif"
mtnormalise: [DEBUG] image "csf_scalar.mif" unloaded
mtnormalise: [INFO] initialising basis...
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 28 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [INFO]   outlier rejection quartiles: [ -inf -inf ]
mtnormalise: [INFO] Iteration: 1
mtnormalise: [DEBUG] Balance and outlier rejection iteration 1 starts.
mtnormalise: [100%] performing log-domain intensity normalisation
mtnormalise: [DEBUG] deleting scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" unloaded
mtnormalise: [ERROR] Non-positive tissue balance factor was computed. Balance factors: -nan -nan -nan

I think there’s clearly an issue here:

It looks like it hasn’t performed the first iteration yet, and already the outlier detection has gone funny. I suspect the handling of non-finite values might need to be updated…

Can I also confirm which version of mtnormalise you’re running? Use the mtnormalise -version command to find out.

Cheers,
Donald.

Yes this is the version:

== mtnormalise 3.0.2 ==

This has been an issue on only 4 subjects out of 1065 so it’s a bit strange.

Thanks for your help,

Stefanie

Hi,

I was wondering if you got a chance to update the handling of non-finite values in mtnormalise?

Best,

Stefanie

OK, I had a quick look this morning, and it looks like a simple fix. We’ll hopefully be able to merge this to master within the next few hours.

The basic problem is that there are (I expect) non-finite values in your data for voxels that are included in your mask. So the simplest fix while you’re waiting is simply to make sure such voxels are not included in your mask. How you do this will depend on how you generated the mask in the first place though…

Hi,
Thank you for the great toolbox!
I am pretty new at DTI, and I am trying to use mrtrix3. Everything seems to work great, but I am getting this error : mtnormalise: [ERROR] Non-positive tissue balance factor was computed. Balance factors: -nan -nan -nan
I have checked out and used jdtournier branch from github, with the fix, and I am getting the same error (even with a binary mask created with the fsl “bet -m” command) and I am not sure why…I am wondering if there are any new suggestions on this issue?
Thank you very much!
Milly

Hi Milly,

If you’ve tried code that includes the fix (and are confident that you are in fact invoking the version of the command compiled with the updated code and not some other version of the same command on your system), and are still encountering that error message, but are not sure how to experiment with the data to try to diagnose the source of the problem, then making some example data available to us so that we can replicate the issue would be the best approach.

Cheers
Rob

Hi,

I’m having similar issues.

Here is my info and debugging:

mtnormalise: [WARNING] existing output files will be overwritten
mtnormalise: [DEBUG] No config file found at "/etc/mrtrix.conf"
mtnormalise: [DEBUG] No config file found at "/home/erin/.mrtrix.conf"
mtnormalise: [INFO] opening image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz"... 
mtnormalise: [DEBUG] transforms_match: FOV difference in scanner coordinates: 9.6965914718647911e-07
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] Axes and transform of image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz" altered to approximate RAS coordinate system
mtnormalise: [DEBUG] searching for suitable phase encoding data...
mtnormalise: [INFO] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz" opened with dimensions 192x192x118, voxel spacing 1.25x1.25x1.25, datatype Int16LE
mtnormalise: [DEBUG] loading image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz"...
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz" loaded
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz" initialised with strides = [ -1 192 36864 ], start = 191, using indirect IO   mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [DEBUG] allocating scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" loaded
mtnormalise: [DEBUG] image "index" initialised with strides = [ -1 192 36864 ], start = 191, using direct IO
mtnormalise: [INFO] mask image contains 775600 voxels
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/merged_dwi_cleaned_dwis_denoised_unringed_upsampled_bet_mask.nii.gz" unloaded
mtnormalise: [INFO] opening image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz"...mtnormalise: [DEBUG] transforms_match: FOV difference in scanner coordinates: 9.6965914718647911e-07
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] Axes and transform of image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz" altered to approximate RAS coordinate system
mtnormalise: [DEBUG] searching for suitable phase encoding data...
mtnormalise: [INFO] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz" opened with dimensions 192x192x118x45, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mtnormalise: [DEBUG] loading image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz"...
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz" loaded
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz" initialised with strides = [ -1 192 36864 4349952 ], start = 191, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 8 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_wmfod.nii.gz" unloaded
mtnormalise: [INFO] opening image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz"...
mtnormalise: [DEBUG] transforms_match: FOV difference in scanner coordinates: 9.6965914718647911e-07
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] Axes and transform of image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz" altered to approximate RAS coordinate system
mtnormalise: [DEBUG] searching for suitable phase encoding data...
mtnormalise: [INFO] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz" opened with dimensions 192x192x118x1, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mtnormalise: [DEBUG] loading image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz"...
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz" loaded
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz" initialised with strides = [ -1 192 36864 4349952 ], start = 191, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 8 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_gm.nii.gz" unloaded
mtnormalise: [INFO] opening image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz"...
mtnormalise: [DEBUG] transforms_match: FOV difference in scanner coordinates: 9.6965914718647911e-07
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] Axes and transform of image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz" altered to approximate RAS coordinate system
mtnormalise: [DEBUG] searching for suitable phase encoding data...
mtnormalise: [INFO] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz" opened with dimensions 192x192x118x1, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mtnormalise: [DEBUG] loading image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz"...
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz" loaded
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz" initialised with strides = [ -1 192 36864 4349952 ], start = 191, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 8 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] image "/home/erin/research/research/ftd/sd_cohort/DTI/DTI_01-0148/FBA_3/all_csf.nii.gz" unloaded
mtnormalise: [INFO] initialising basis...
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 8 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [INFO]   outlier rejection quartiles: [ -1.629735070318463 -1.0509951994563367 ]
mtnormalise: [INFO] Iteration: 1
mtnormalise: [DEBUG] Balance and outlier rejection iteration 1 starts.
mtnormalise: [100%] performing log-domain intensity normalisation
mtnormalise: [DEBUG] deleting scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" unloaded
mtnormalise: [ERROR] Non-positive tissue balance factor was computed. Balance factors: -nan -nan -nan

Any advise on how to troubleshoot would be very helpful! Thank you!

Best wishes,
Erin

I have a similar problem. I got the same message with -nan balance factors and used the -debug to try and identify the problem. I am quite sure it has to do with my data but I’m an newby and I’m not sure how to trace back to the error so that I can fix it. I would be most grateful if you had any suggestion that I could follow in order to fix this. Thanks in advance for you time!


mtnormalise: [DEBUG] No config file found at "/etc/mrtrix.conf"

mtnormalise: [DEBUG] No config file found at "/home/cluster/acubil/.mrtrix.conf"

mtnormalise: [INFO] opening image "output/02-0213_output_Oct21/mask.mif"...

mtnormalise: [DEBUG] reading key/value file "output/02-0213_output_Oct21/mask.mif"...

mtnormalise: [DEBUG] sanitising image information...

mtnormalise: [INFO] image "output/02-0213_output_Oct21/mask.mif" opened with dimensions 128x128x62, voxel spacing 2x2x2, datatype Bit

mtnormalise: [DEBUG] memory-mapping file "output/02-0213_output_Oct21/mask.mif"...

mtnormalise: [DEBUG] file "output/02-0213_output_Oct21/mask.mif" mapped at 0x7fb26d4cc000, size 126976 (read-only)

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/mask.mif" loaded

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/mask.mif" initialised with strides = [ -1 128 16384 ], start = 127, using direct IO

mtnormalise: [DEBUG] sanitising image information...

mtnormalise: [DEBUG] allocating scratch buffer for image "index"...

mtnormalise: [DEBUG] image "index" loaded

mtnormalise: [DEBUG] image "index" initialised with strides = [ -1 128 16384 ], start = 127, using direct IO

mtnormalise: [INFO] mask image contains 170993 voxels

mtnormalise: [DEBUG] unmapping file "output/02-0213_output_Oct21/mask.mif"

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/mask.mif" unloaded

mtnormalise: [INFO] opening image "output/02-0213_output_Oct21/wmfod.mif"...

mtnormalise: [DEBUG] reading key/value file "output/02-0213_output_Oct21/wmfod.mif"...

mtnormalise: [DEBUG] sanitising image information...

mtnormalise: [INFO] image "output/02-0213_output_Oct21/wmfod.mif" opened with dimensions 128x128x62x45, voxel spacing 2x2x2x1, datatype Float32LE

mtnormalise: [DEBUG] memory-mapping file "output/02-0213_output_Oct21/wmfod.mif"...

mtnormalise: [DEBUG] file "output/02-0213_output_Oct21/wmfod.mif" mapped at 0x7fb261e9e000, size 182845440 (read-only)

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/wmfod.mif" loaded

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/wmfod.mif" initialised with strides = [ -45 5760 737280 1 ], start = 5715, using direct IO

mtnormalise: [DEBUG] initialising threads...

mtnormalise: [DEBUG] launching 8 threads "loop threads"...

mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...

mtnormalise: [DEBUG] threads "loop threads" completed OK

mtnormalise: [DEBUG] unmapping file "output/02-0213_output_Oct21/wmfod.mif"

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/wmfod.mif" unloaded

mtnormalise: [INFO] opening image "output/02-0213_output_Oct21/gmfod.mif"...

mtnormalise: [DEBUG] reading key/value file "output/02-0213_output_Oct21/gmfod.mif"...

mtnormalise: [DEBUG] sanitising image information...

mtnormalise: [INFO] image "output/02-0213_output_Oct21/gmfod.mif" opened with dimensions 128x128x62x1, voxel spacing 2x2x2x1, datatype Float32LE

mtnormalise: [DEBUG] memory-mapping file "output/02-0213_output_Oct21/gmfod.mif"...

mtnormalise: [DEBUG] file "output/02-0213_output_Oct21/gmfod.mif" mapped at 0x7fb26c91b000, size 4063232 (read-only)

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/gmfod.mif" loaded

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/gmfod.mif" initialised with strides = [ -1 128 16384 128 ], start = 127, using direct IO

mtnormalise: [DEBUG] initialising threads...

mtnormalise: [DEBUG] launching 8 threads "loop threads"...

mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...

mtnormalise: [DEBUG] threads "loop threads" completed OK

mtnormalise: [DEBUG] unmapping file "output/02-0213_output_Oct21/gmfod.mif"

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/gmfod.mif" unloaded

mtnormalise: [INFO] opening image "output/02-0213_output_Oct21/csffod.mif"...

mtnormalise: [DEBUG] reading key/value file "output/02-0213_output_Oct21/csffod.mif"...

mtnormalise: [DEBUG] sanitising image information...

mtnormalise: [INFO] image "output/02-0213_output_Oct21/csffod.mif" opened with dimensions 128x128x62x1, voxel spacing 2x2x2x1, datatype Float32LE

mtnormalise: [DEBUG] memory-mapping file "output/02-0213_output_Oct21/csffod.mif"...

mtnormalise: [DEBUG] file "output/02-0213_output_Oct21/csffod.mif" mapped at 0x7fb26a534000, size 4063232 (read-only)

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/csffod.mif" loaded

mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/csffod.mif" initialised with strides = [ -1 128 16384 128 ], start = 127, using direct IO

mtnormalise: [DEBUG] initialising threads...

mtnormalise: [DEBUG] launching 8 threads "loop threads"...

mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...

mtnormalise: [DEBUG] threads "loop threads" completed OK

mtnormalise: [DEBUG] unmapping file "output/02-0213_output_Oct21/csffod.mif"
mtnormalise: [DEBUG] image "output/02-0213_output_Oct21/csffod.mif" unloaded
mtnormalise: [INFO] initialising basis...
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 8 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [INFO]   outlier rejection quartiles: [ -1.1796164265695872 -0.90274727668229637 ]
mtnormalise: [INFO] Iteration: 1
mtnormalise: [DEBUG] Balance and outlier rejection iteration 1 starts.
]
mtnormalise: [DEBUG] deleting scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" unloaded
mtnormalise: [ERROR] Non-positive tissue balance factor was computed. Balance factors: -nan -nan -nan

Hi @edrazich & @Amaval,

If those errors were generated using 3.0.3, which includes this bug fix, then the terminal logs are not adequate for us to provide any further feedback and we would need access to raw data with which we could reproduce the fault.

Rob

Dear Mrtrix experts,

I wonder if you can help here. I am using the new version of mtnormalise (mtnormalise 3.0.3) and I’m still facing the same issue heighted in this post with ERROR] Non-positive tissue balance factor was computed. Balance factors: nan nan nan. In an attempt to understand where the error is coming from, I ran the mtnormalise command in each tissue type alone (i.e grey matter alone, white matter alone and CFS alone) and it ran with no errors. I then started to combine tissue types together and the error seems to be associated with the grey matter, as it works fine when wm and csf combined, but with anyother combination that involves gm. I might be wrong, but it seems the are issues with estimating the FOD for grey matter. Please see below a snapshot of the gmfod. Please note I’m new to the DTI analysis and Mrtrix community, so please forgive my nativity here.

Many thanks,

Sally

mtnormalise: [DEBUG] No config file found at "/etc/mrtrix.conf"
mtnormalise: [DEBUG] No config file found at "/Users/sallyeldeghaidy/.mrtrix.conf"
mtnormalise: [INFO] opening image "mask_dwi_den_unr_preproc_unb.mif"...
mtnormalise: [DEBUG] reading key/value file "mask_dwi_den_unr_preproc_unb.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "mask_dwi_den_unr_preproc_unb.mif" opened with dimensions 144x144x48, voxel spacing 1.5555600000000001x1.5555600000000001x2.2000000000000002, datatype Bit
mtnormalise: [DEBUG] memory-mapping file "mask_dwi_den_unr_preproc_unb.mif"...
mtnormalise: [DEBUG] file "mask_dwi_den_unr_preproc_unb.mif" mapped at 0x10684e000, size 124416 (read-only)
mtnormalise: [DEBUG] image "mask_dwi_den_unr_preproc_unb.mif" loaded
mtnormalise: [DEBUG] image "mask_dwi_den_unr_preproc_unb.mif" initialised with strides = [ -1 144 20736 ], start = 143, using direct IO
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [DEBUG] allocating scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" loaded
mtnormalise: [DEBUG] image "index" initialised with strides = [ -1 144 20736 ], start = 143, using direct IO
mtnormalise: [INFO] mask image contains 247658 voxels
mtnormalise: [DEBUG] unmapping file "mask_dwi_den_unr_preproc_unb.mif"
mtnormalise: [DEBUG] image "mask_dwi_den_unr_preproc_unb.mif" unloaded
mtnormalise: [INFO] opening image "wmfod.mif"...
mtnormalise: [DEBUG] reading key/value file "wmfod.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "wmfod.mif" opened with dimensions 144x144x48x45, voxel spacing 1.5555600000000001x1.5555600000000001x2.2000000000000002x2.0057200000000002, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "wmfod.mif"...
mtnormalise: [DEBUG] file "wmfod.mif" mapped at 0x10712a000, size 179159040 (read-only)
mtnormalise: [DEBUG] image "wmfod.mif" loaded
mtnormalise: [DEBUG] image "wmfod.mif" initialised with strides = [ -45 6480 933120 1 ], start = 6435, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 12 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "wmfod.mif"
mtnormalise: [DEBUG] image "wmfod.mif" unloaded
mtnormalise: [INFO] opening image "gmfod.mif"...
mtnormalise: [DEBUG] reading key/value file "gmfod.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "gmfod.mif" opened with dimensions 144x144x48x1, voxel spacing 1.5555600000000001x1.5555600000000001x2.2000000000000002x2.0057200000000002, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "gmfod.mif"...
mtnormalise: [DEBUG] file "gmfod.mif" mapped at 0x10712a000, size 3981312 (read-only)
mtnormalise: [DEBUG] image "gmfod.mif" loaded
mtnormalise: [DEBUG] image "gmfod.mif" initialised with strides = [ -1 144 20736 144 ], start = 143, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 12 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "gmfod.mif"
mtnormalise: [DEBUG] image "gmfod.mif" unloaded
mtnormalise: [INFO] opening image "csffod.mif"...
mtnormalise: [DEBUG] reading key/value file "csffod.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "csffod.mif" opened with dimensions 144x144x48x1, voxel spacing 1.5555600000000001x1.5555600000000001x2.2000000000000002x2.0057200000000002, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "csffod.mif"...
mtnormalise: [DEBUG] file "csffod.mif" mapped at 0x1074f8000, size 3981312 (read-only)
mtnormalise: [DEBUG] image "csffod.mif" loaded
mtnormalise: [DEBUG] image "csffod.mif" initialised with strides = [ -1 144 20736 144 ], start = 143, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 12 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "csffod.mif"
mtnormalise: [DEBUG] image "csffod.mif" unloaded
mtnormalise: [INFO] initialising basis...
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 12 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [INFO]   outlier rejection quartiles: [ -1.237060759174478 -1.0284206104424731 ]
mtnormalise: [INFO] Iteration: 1
mtnormalise: [DEBUG] Balance and outlier rejection iteration 1 starts.
mtnormalise: [100%] performing log-domain intensity normalisation
mtnormalise: [DEBUG] deleting scratch buffer for image "index"...
mtnormalise: [DEBUG] image "index" unloaded
mtnormalise: [ERROR] Non-positive tissue balance factor was computed. Balance factors: nan nan nan

Hi @seldeghaidy,

Your GM FOD image seems to contain strictly negative or zero values, which can’t be right. mtnormalise will perform a log transform of the data, which will be problematic with negative signal values – I expect this is the problem with this particular step. However, negative densities don’t make sense and shouldn’t happen, so I expect something must have gone wrong earlier in the processing chain. How was your GM FOD generated? And can you provide details on your acquisition so we can double-check whether the processing steps were appropriate?

All the best,
Donald

Hi Donald,

Many thanks for the prompt response. Below is the 1) scan parameters for the DTI scan, and 2) the analysis process. Please note unfortunately we did not acquire a blip scan, hence distortion correction process was skipped .

Many thanks,
Sally

1) scan Parameters

Scan Proto enable =		"no";
Patient weight [kg] =		55;
SmartSelect =			"yes";
Coil 1  (exclude) =		"None";
Uniformity =			"CLEAR";
FOV          RL (mm) =		224;
             AP (mm) =		224;
             FH (mm) =		105.600006;
ACQ voxel size   RL (mm) =	2.20000005;
             AP (mm) =		2.20000005;
Slice thickness (mm) =		2.20000005;
Recon voxel size RL (mm) =	1.55555558;
             AP (mm) =		1.55555558;
Fold-over suppression =		"no";
Reconstruction matrix =		144;
SENSE =				"yes";
    P reduction (AP) =		1.29999995;
MB SENSE =			"yes";
    MB Factor =			3;
    MB Shift =			"default";
    RF Phase opt =		"default";
CS-SENSE =			"no";
k-t Acceleration =		"no";
Stacks =			1;
    type =			"parallel";
    slices =			48;
    slice gap =			"user defined";
          gap (mm) =		0;
    slice orientation =		"transverse";
    fold-over direction =	"AP";
    fat shift direction =	"P";
Stack Offc. AP (P=+mm) =	-11.3460064;
            RL (L=+mm) =	-2.79287601;
            FH (H=+mm) =	58.6840401;
      Ang.  AP (deg) =		0;
            RL (deg) =		-0;
            FH (deg) =		-0;
      Free rotatable =		"no";
Minimum number of packages =	1;
Slice scan order =		"default";
Add offset =			"no";
Large table movement =		"no";
PlanAlign =			"no";
REST slabs =			0;
Interactive positioning =	"no";
Patient position =		"head first";
Patient body position =		"head first";
Patient orientation =		"supine";
Patient body orientation =	"supine";
Scan type =			"Imaging";
Scan mode =			"MS";
    technique =			"SE";
Modified SE =			"no";
Acquisition mode =		"cartesian";
Fast Imaging mode =		"EPI";
    shot mode =			"single-shot";
Echoes =			1;
    partial echo =		"no";
TE =				"shortest";
Flip angle (deg) =		90;
TR =				"shortest";
Halfscan =			"yes";
    factor =			0.600000024;
Water-fat shift =		"minimum";
RF Shims =			"fixed";
Shim =				"auto";
mDIXON =			"no";
Fat suppression =		"SPIR";
   strength =			"strong";
   frequency offset =		"default";
Grad Rev Fat suppr =		"no";
Water suppression =		"no";
BB pulse =			"no";
MTC =				"no";
Research prepulse =		"no";
MDME =				"no";
Diffusion mode =		"DTI";
    sequence =			"SE";
    gradient overplus =		"no";
    directional resolution =	"opt 64";
    nr of b-factors =		2;
    b-factor order =		"ascending";
    max b-factor =		1000;
    average high b =		"user defined";
+ allow phase to be saved =	"no";
        b-factor averages =	"(0) 1",
				"(1000) 1", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "", "", "", "", "",
				"", "", "";
T1 mapping =			"no";
Transmit channels =		"both";
SAR mode =			"high";
B1 mode =			"default";
SAR allow first level =		"yes";
  Patient pregnancy =		"no";
  Patient WB SAR [W/kg] =	0;
  Patient Head SAR [W/kg] =	0;
  Patient max. dB/dt [T/s] =	0;
  Max slewrate [T/m/s] =	0;
  Max. B1+rms [uT] =		0;
PNS mode =			"high";
Gradient mode =			"maximum";
SofTone mode =			"no";
Cardiac synchronization =	"no";
Heart rate > 250 bpm =		"no";
Respiratory compensation =	"no";
Navigator respiratory comp =	"no";
Flow compensation =		"no";
Temporal slice spacing =	"default";
NSA =				1;
MRE enable =			"no";
Manual start =			"no";
Dynamic study =			"no";
    dyn stabilization =		"regular";
Arterial Spin labeling =	"no";
Preparation phases =		"auto";
Interactive F0 =		"no";
Quick Survey =			"default";
SmartPlan survey =		"no";
B0 field map =			"no";
B1 field map =			"no";
MIP/MPR =			"no";
Images =			"M", (3) "no";
Autoview image =		"M";
Calculated images =		(4) "no";
Reference tissue =		"White matter";
Recon compression =		"No";
Preset window contrast =	"soft";
Reconstruction mode =		"immediate";
Save raw data =			"no";
Hardcopy protocol =		"no";
Image filter =			"system default";
Uniformity correction =		"no";
Geometry correction =		"default";
IF_info_seperator =		2000;
Research Options used =		"51";
Total scan duration =		"02:14.4";
Rel. SNR =			0.0646339282;
Act. TR (ms) =			"1993";
Act. TE (ms) =			"84";
ACQ matrix M x P =		"104 x 100";
ACQ voxel MPS (mm) =		"2.15 / 2.24 / 2.20";
REC voxel MPS (mm) =		"1.56 / 1.56 / 2.20";
Scan percentage (%) =		96.25;
Packages =			1;
Min. slice gap (mm) =		-0;
EPI factor =			77;
WFS (pix) / BW (Hz) =		"21.415 / 20.3";
BW in EPI freq. dir. (Hz) =	"2034.6";
Local torso SAR =		"<  64 %";
Whole body SAR / level =	"< 2.1 W/kg / 1st level";
SED =				"< 0.3 kJ/kg";
Coil Power =			"61 %";
Max B1+rms =			"1.84 uT";
PNS / level =			"84 % / 1st level";
dB/dt =				"124.8 T/s";
Sound Pressure Level (dB) =	20.6376553;
Boil-off (hPa/h) =		11.2246542;
Max Boil-off (hPa/h) =		11.2247782;
Boil-off (hPa) =		0.418958157;

2) Analysis steps

#image conversion

mrconvert RAW_DWI.nii DWI_raw.mif -fslgrad bvec.bvec bval.bval

dwiextract DWI_raw.mif - -bzero | mrmath - mean mean_b0_PA.mif -axis 3

mrconvert -datatype uint32 aparc+aseg.mgz aparc+aseg_ut.mif

#preprocessing DWI images

#In this step, we will run denoising, removing gibbs artifacts, eddy correction, motion correction, and bias correction using MRTrix3, FSL

dwidenoise DWI_raw.mif dwi_den.mif -noise noise.mif

mrcalc DWI_raw.mif dwi_den.mif -subtract residual.mif

mrdegibbs dwi_den.mif dwi_den_unr.mif -axes 0,1

mrcalc dwi_den.mif dwi_den_unr.mif -subtract residualUnringed.mif

dwifslpreproc dwi_den_unr.mif dwi_den_unr_preproc.mif -pe_dir AP -rpe_none -eddy_options " --slm=linear" -topup_options " --estmov=0"

dwibiascorrect fsl dwi_den_unr_preproc.mif dwi_den_unr_preproc_unbiased.mif -bias bias.mif

#create a binary mask and extract mean b0 image using preprocessed DWI image

dwi2mask dwi_den_unr_preproc_unbiased.mif mask_dwi_den_unr_preproc_unb.mif

dwiextract dwi_den_unr_preproc_unbiased.mif - -bzero | mrmath - mean mean_b0_preprocessed.mif -axis 3

mrconvert mean_b0_preprocessed.mif mean_b0_preprocessed.nii.gz

#response function estimation for white matter, grey matter and CSF

#estimate fibre orientation distribution

dwi2response dhollander dwi_den_unr_preproc_unbiased.mif wm.txt gm.txt csf.txt -voxels voxels.mif

dwi2fod msmt_csd dwi_den_unr_preproc_unbiased.mif -mask mask_dwi_den_unr_preproc_unb.mif wm.txt wmfod.mif gm.txt gmfod.mif csf.txt csffod.mif

#normalisation

mtnormalise wmfod.mif wmfod_norm.mif gmfod.mif gmfod_norm.mif csffod.mif csffod_norm.mif -mask mask_dwi_den_unr_preproc_unb.mif

Yes, it looks like you have single-shell data (b = 0 & 1,000 s/mm²), which can’t directly support a 3-tissue decomposition – but your dwi2fod call does request 3 tissue types. This is why the GM segment is coming out all wrong (though I would have expected it to come out closer to straight zeros…).

There are thankfully other options for dealing with single-shell data:

  • use the original single-shell CSD method (i.e. dwif2fod csd). This will only rely on the b=1,000 s/mm² data.
  • use the new MSMT-CSD solver, but using only one tissue type and one shell (i.e. a 1S1T CSD). This is essentially the same as the regular CSD above, but imposes a stricter constraint on negative values in the FODs produced, at the expense of some loss of angular resolution. This is what is currently recommended in the docs for single-shell data, though I have been planning to update that for a while.
  • perform a limited 2-tissue MSMT-CSD decomposition (i.e. 2S2T CSD), using the fact that even a single-shell acquisition actually contains 2 b-values (including b=0), and that’s enough to fit two tissue types – though not the full WM/GM/CSF trio (at least not with that particular command). You’ll find this described at various points on the forum (e.g. here).
  • use the SS3T approach noting that this is not part of this project, and not something that we will provide support for).

Hope this helps,
Donald.

1 Like