<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta content="text/html; charset=utf-8">
</head>
<body>
<div dir="auto">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:
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">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.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Best,</div>
<div dir="auto">Chris</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On May 15, 2020 21:36, Sam W <samfmri@gmail.com> wrote:<br type="attribution">
</div>
</div>
<div>
<div dir="ltr">
<div>Hello, <br>
</div>
<div>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?</div>
<div>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>Best regards,</div>
<div>Sam<br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>