# Mrcalc true and false statements

**URL:** <https://community.mrtrix.org/t/mrcalc-true-and-false-statements/6390>\
**Category:** Uncategorized\
**Created:** [February 10, 2023, 7:10pm UTC](https://community.mrtrix.org/t/mrcalc-true-and-false-statements/6390 "2023-02-10T19:10:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liliana\_wu](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liliana\_wu](https://community.mrtrix.org/u/liliana_wu)\
**Post date:** [February 10, 2023, 7:10pm UTC](https://community.mrtrix.org/t/mrcalc-true-and-false-statements/6390/1 "2023-02-10T19:10:46Z")

</div>

Hi,

I’m quite a new user so please bear with me.

I am having trouble trying to apply a lesion mask onto reconstructed tracts of MS patients using mrcalc

Essentially, I want the output.mif to result from when tract.mif is true and lesion.mif is false

i’ve tried:

mrcalc tract.mif lesion.mif -not -if output.mif  
mrcalc tract.mif lesion.mif -not output.mif

But I keep getting the following errors (respectively):  
mrcalc: [ERROR] not enough operands in stack for operation “if”  
mrcalc: [ERROR] too many operands left on stack

All the help is appreciated!

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [February 15, 2023, 12:32pm UTC](https://community.mrtrix.org/t/mrcalc-true-and-false-statements/6390/2 "2023-02-15T12:32:20Z")

</div>

If I understand correctly, you’re trying to do this:

```auto
mrcalc tract.mif lesion.mif -not -and output.mif

```

which performs the operation `tract.mif & (!lesion.mif)`.

But that will produce as binary mask, and depends on whether `tract.mif` is a binary mask – which is probably not what you wanted?

* * *

If what you’re actually trying to do is to set regions in the `tract.mif` image to zero where the `lesion.mif` mask is non-zero, then this is actually what you’re after:

```auto
mrcalc tract.mif lesion.mif -not -mult output.mif

```

which performs the operation `tract.mif × (!lesion.mif)`.

* * *

You can also do this using the `-if` statement if you prefer:

```auto
mrcalc lesion.mif 0 tract.mif -if output.mif

```

which performs the operation `lesion.mif ? 0 : tract.mif`.
