How does "mrcalc A B -max C" command process with the overlapping voxels?

Hi experts,

The mask images A.nii and B.nii are in the same space. When I use mrcalc A.nii B.nii -max C.nii, I found that in the unoverlapped voxels, the value in C.nii is exactly the larger value between A and B. But in the overlapping voxels, the value in C.nii is neither the value of voxel in A, nor in B, but a new value larger than both of them (not equal to the sum of A and B) (Figure 1). Sometimes, value in C is really the larger one between A and B (neither equal to 0) (Figure 2).


Considering that in most of situations, the purpose of this command is to merge two masks, I think there is a reason. But I don’t know what it is. So could you please tell me the calculation mechanism behind mrcalc?

Thanks in advance.



Hey Roger - make sure you examine these images in mrview with interpolate off (bottom of the Overlay panel) for both mask files and the mrcalc output mask file. If you ran mrcalc -max on two binary mask files, the resulting file should also be binary.

With interpolation on, the mask overlay images will be interpolated to the grid of the underlying image (your T1 in this case) which can cause the partial values you’re seeing. It doesn’t reflect the actual values in the actual mrcalc output file (C.nii).

Hi j-tseng, thank you for your help. When I turn off the interpolate, the value in C.nii is exactly the larger value between A and B. By the way, these masks are generated from white matter tract, which are tracked by Mrtrix3. And the value of edging voxels is between 0 and 1. .

1 Like