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!
1 Like
If I understand correctly, you’re trying to do this:
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:
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:
mrcalc lesion.mif 0 tract.mif -if output.mif
which performs the operation lesion.mif ? 0 : tract.mif
.