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

Gael Varoquaux gael.varoquaux at normalesup.org
Sat May 16 09:11:31 EDT 2020


https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.ndimage.measurements.center_of_mass.html
is a useful function to do such a thing.

G

On Sat, May 16, 2020 at 12:30:31PM +0000, Christopher Markiewicz wrote:
> 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

> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging


-- 
    Gael Varoquaux
    Research Director, INRIA		  Visiting professor, McGill 
    http://gael-varoquaux.info            http://twitter.com/GaelVaroquaux


More information about the Neuroimaging mailing list