Best way to build combined ROIs from an atlas

I’m building some regions-of-interest by combining regions defined in some atlas. For example, I want to build a region called ‘hippocampus’, but I need to combine a lot of smaller regions defined by my atlas (e.g. CA1, dentate gyrus, etc.). Each region in the atlas is defined with a particular number.

To do this, I’ve been using fslmaths to threshold by a specific value and binarising in order to get the individual sub-regions I want, and then adding all those sub-regions together to build the mask with all of the combined values. Is there a better (faster, and requiring fewer images to be generated) way?

Hi @Benjamin_Zimmerman,

fslmaths is a great tool to do this kind of work, but I agree that it can quickly create a lot of intermediate files. A great alternative is nilearn, in particular it’s image module (nilearn.image). For your particular question, I think I would look into math_img. It allows you to treat NIfTI images like numpy objects.

And I wouldn’t be surprised if nilearn already provides a one-liner command that does exactly what you want. Perhaps nilearn.regions.connected_label_regions?

1 Like