`mtnormalize` NaN error

I got nan error when doing mtnormalize. I used -debug option to figure out what went wrong. Could anyone please tell me how I can solve this?

(base) MacBook-Pro-2:solve_mtnoramlize eunmi$ mtnormalise ./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif sub-160666_space-T1w_desc-preproc_dwi_wm_mtnorm.mif ./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif sub-160666_space-T1w_desc-preproc_dwi_gm_mtnorm.mif ./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif sub-160666_space-T1w_desc-preproc_dwi_csf_mtnorm.mif -check_mask inliers.nii.gz -mask ./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz -check_norm norm.nii.gz -nthreads 14 -debug
mtnormalise: [DEBUG] No config file found at "/etc/mrtrix.conf"
mtnormalise: [DEBUG] No config file found at "/Users/eunmi/.mrtrix.conf"
mtnormalise: [INFO] opening image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz"...
mtnormalise: [DEBUG] transforms_match: FOV difference in scanner coordinates: 0
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] Axes and transform of image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz" altered to approximate RAS coordinate system
mtnormalise: [DEBUG] searching for suitable phase encoding data...
mtnormalise: [INFO] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz" opened with dimensions 162x193x164, voxel spacing 1.2000000476837158x1.2000000476837158x1.2000000476837158, datatype Float32LE
mtnormalise: [DEBUG] loading image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz"...
mtnormalise: [100%] uncompressing image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz"
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz" loaded
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz" initialised with strides = [ -1 -162 31266 ], start = 31265, 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 -162 31266 ], start = 31265, using direct IO
mtnormalise: [INFO] mask image contains 392086 voxels
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/sub-160666_desc-brain_mask_resample.nii.gz" unloaded
mtnormalise: [INFO] opening image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif"...
mtnormalise: [DEBUG] reading key/value file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif" opened with dimensions 162x193x164x45, voxel spacing 1.2x1.2x1.2x0, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif"...
mtnormalise: [DEBUG] file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif" mapped at 0x109317000, size 922972320 (read-only)
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif" loaded
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif" initialised with strides = [ -45 -7290 1406970 1 ], start = 1406925, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 14 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif"
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_wm.mif" unloaded
mtnormalise: [INFO] opening image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif"...
mtnormalise: [DEBUG] reading key/value file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif" opened with dimensions 162x193x164x45, voxel spacing 1.2x1.2x1.2x0, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif"...
mtnormalise: [DEBUG] file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif" mapped at 0x109317000, size 922972320 (read-only)
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif" loaded
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif" initialised with strides = [ -45 -7290 1406970 1 ], start = 1406925, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 14 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif"
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_gm.mif" unloaded
mtnormalise: [INFO] opening image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif"...
mtnormalise: [DEBUG] reading key/value file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif"...
mtnormalise: [DEBUG] sanitising image information...
mtnormalise: [INFO] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif" opened with dimensions 162x193x164x45, voxel spacing 1.2x1.2x1.2x0, datatype Float32LE
mtnormalise: [DEBUG] memory-mapping file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif"...
mtnormalise: [DEBUG] file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif" mapped at 0x109317000, size 922972320 (read-only)
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif" loaded
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif" initialised with strides = [ -45 -7290 1406970 1 ], start = 1406925, using direct IO
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 14 threads "loop threads"...
mtnormalise: [DEBUG] waiting for completion of threads "loop threads"...
mtnormalise: [DEBUG] threads "loop threads" completed OK
mtnormalise: [DEBUG] unmapping file "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif"
mtnormalise: [DEBUG] image "./sub-160666_mrtrix_multishell_msmt_hsvs/sub_160666_space_T1w_desc_preproc_recon_wf/msmt_csd/estimate_fod/sub-160666_space-T1w_desc-preproc_dwi_csf.mif" unloaded
mtnormalise: [INFO] initialising basis...
mtnormalise: [DEBUG] initialising threads...
mtnormalise: [DEBUG] launching 14 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.4154708805422054 -1.2310470826045279 ]
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
1 Like

the mask used was :

dwi_mf.mif was :

dwi_csf.mif was :

for additional information, the

dwi_gm.mif was :

Hi,

The mask looks strange, it includes the background right? I would say that is the problem, try using a mask that includes only the brain. I hope this helps.

Best regards,

Manuel

1 Like

Thank you for the response! You mentioned that masks might be wrong, but because this was made using QSIPREP, I am not 100% sure which mask I should be improving. I don’t know the details of how QSIPREP works, but I do know that I put in freesurfer results into the qsiprep as input. Could the T1w masks that are generated using freesurfer be the faulty ones?

Hi,

I’m not sure about that. What you can do is to run dwi2mask in your diffusion data, then use that mask for the mtnormalise step.

Best regards,

Manuel