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

**URL:** https://community.mrtrix.org/t/how-does-mrcalc-a-b-max-c-command-process-with-the-overlapping-voxels/7257
**Category:** Uncategorized
**Tags:** preprocessing
**Created:** [January 2, 2024, 3:05pm UTC](https://community.mrtrix.org/t/how-does-mrcalc-a-b-max-c-command-process-with-the-overlapping-voxels/7257 "2024-01-02T15:05:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Roger1219](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/r/7ba0ec/32.png) [@Roger1219](https://community.mrtrix.org/u/Roger1219)
#### Post date: [January 2, 2024, 3:05pm UTC](https://community.mrtrix.org/t/how-does-mrcalc-a-b-max-c-command-process-with-the-overlapping-voxels/7257/1 "2024-01-02T15:05:29Z")

</div>

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).

 ![截屏2024-01-02 23.04.23](https://community.mrtrix.org/uploads/default/original/2X/4/4258cf5c62efd39dc9cce0e16503469b57eed45c.jpeg)  
Figure1

 ![截屏2024-01-02 23.04.36](https://community.mrtrix.org/uploads/default/original/2X/6/627de968a244e7eee5a5f2655ef5fcfce592fb7b.jpeg)

Figure2  
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.

Best,

Roger

---

<div class="post-metadata">

### Author: ![j-tseng](https://community.mrtrix.org/user_avatar/community.mrtrix.org/j-tseng/32/3096_2.png) [@j-tseng](https://community.mrtrix.org/u/j-tseng)
#### Post date: [January 2, 2024, 5:12pm UTC](https://community.mrtrix.org/t/how-does-mrcalc-a-b-max-c-command-process-with-the-overlapping-voxels/7257/2 "2024-01-02T17:12:45Z")

</div>

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`).

---

<div class="post-metadata">

### Author: ![Roger1219](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/r/7ba0ec/32.png) [@Roger1219](https://community.mrtrix.org/u/Roger1219)
#### Post date: [January 3, 2024, 1:44am UTC](https://community.mrtrix.org/t/how-does-mrcalc-a-b-max-c-command-process-with-the-overlapping-voxels/7257/3 "2024-01-03T01:44:40Z")

</div>

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. .
