[Neuroimaging] extract center of mass with nibabel/nilearn/numpy

Christopher Markiewicz markiewicz at stanford.edu
Sat May 16 08:30:31 EDT 2020


Assuming that you're using standard center of mass, and are content with them sometimes lying outside the region if it is nonconvex, then it should be pretty simple:

Retrieve the indices for a region with numpy.where and average in each dimension. That will give you the index (though possibly non integral). If you need it in world coordinates, nibabel's apply_affine function can be passed the atlas affine and COM index.

Best,
Chris

On May 15, 2020 21:36, Sam W <samfmri at gmail.com> wrote:
Hello,
I have an atlas with voxel numbers between 1 and 40 that correspond to different ROIs. I would like to extract the center of mass of each ROI, is there a way to do this with nibabel/nilearn/numpy?
Best regards,
Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20200516/cd7eaa90/attachment.html>


More information about the Neuroimaging mailing list