Combining masks into 1 image

@ThijsDhollander Yep that solved my problem. Thanks a lot.

Another quick question.

Is there a way to combine multiple ROI masks in mrtrix ?

I have two masks one for left and right region, I would like to combine them together as a final combined mask for further processing of diffusion image.

Cheers

Hi again @isAarya,

I moved your new question into a new topic (again so other users can more easily benefit finding questions and answers in the future :slight_smile:).

Yes, this can easily be done. The key to combining existing images and potentially doing several operations/calculations with them is the mrcalc command! In this case, you’d be after an “AND” kind of logical binary operator to combine them, but mrcalc doesn’t have that explicitly. However, ROI masks being represented as binary images with zeros and ones, the equivalent would be the “max” operator. This should work for your scenario with 2 masks:

mrcalc roi_one.mif roi_two.mif -max roi_combined.mif

…which essentially takes the voxelwise maximum of the values in the one and the other image. Does that make sense? :slight_smile:

If it does, definitely mark this post as an answer again!

Cheers,
Thijs

1 Like