Creating a mask

Hello, I have an anatomical VOI that I created using BrainVoyager and have exported to nii format. I would like to use this VOI as a mask. Can I use this file directly as a mask, or do I need to change it first?

For example, if I want to use this VOI as a mask when fitting a glm:
glm = FirstLevelModel(mask_img=masker)
Can “masker” be the original VOI file or a does it need to be a converted file?

Any help would be greatly appreciated!

Typically masks are binarized files (1s in the VOI and 0s outside). Also, the file should have the same dimensions as the other images in your pipeline. If this is already the case, great! If not, there are a few things we can do:

Binarize : fslmaths has a -bin which should conveniently binarize the image. You may need to use fslstats and threshold to make sure that all voxels outside your VOI are 0.

Dimensions: You can use AFNIs 3dresample to resmaple your VOI to a target image (like an fmri volume you want to analyze using that mask)

Please let me know if you need any more help or something does not make sense.

Best,
Steven

Hi Steven, thanks so much for your explanation and solution!

I was wondering if there was also a way to do this using nibabel or nilearn?

Please check the image orientation and the alignment of the exported file. BV does not know the meaning of a header. Please check carefully the right / left orientation (radiologist vs neurologist).
I did it the other way around and transformed Freesurfer label into BV VOIs.