Extracting Regions of Interest

Hi,
Given the mask, what’s the best tool out there to extract the region covered by the mask?

Thanks!

I don’t know if this is the best tool. But it worked.
fslmaths input -mas mask output

An answer from gitter: " if mask is a binary 3d array (True/False for within/outside the region of interest) and data is a 4D array containing diffusion data, then *data[np.where(mask)]* should be a 2D array with each row being a voxel and each column being a direction of measurement."

I think most of the major neuroimaging packages have different options to apply a mask to an image.

In our python based nltools package, it is very easy with the apply_mask method.

masked_data = data.apply_mask(mask)


We have a more detailed tutorial on some of our other masking options.

I also recommend the apply_mask function from nilearn nilearn, which can be directly applied to nibabel instances

masked_data = apply_mask(func_filename, mask_img)
1 Like

This is owesome! Will you do an online workshop or something to introduce nltools? Handy tools are very useful. Thank you.

We could definitely do an online workshop at some point if there is sufficient interest. We have also created practical online tutorials for this exact purpose using this toolbox to perform basic neuroimaging data analysis on dartbrains and more advanced analyses used in naturalistic data analysis. We could definitely add more tutorials for other types of analyses, but this already covers the majority of what I would imagine people would like to do (e.g., univariate glm, connectivity, prediction, pca, rsa, isc, functional alignment, etc).