# Get Centroid from Script

**URL:** <https://discourse.slicer.org/t/get-centroid-from-script/13191>\
**Category:** Support\
**Created:** [August 27, 2020, 10:51am UTC](https://discourse.slicer.org/t/get-centroid-from-script/13191 "2020-08-27T10:51:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)\
**Post date:** [August 27, 2020, 10:51am UTC](https://discourse.slicer.org/t/get-centroid-from-script/13191/1 "2020-08-27T10:51:24Z")

</div>

I tried to get the centroid from

obb\_centroid = np.array(stats[segmentId,“LabelmapSegmentStatisticsPlugin.centroid\_ras”])

but it gives KeyError.

Can someone help me how to do that properly ?

thanks

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 27, 2020, 1:53pm UTC](https://discourse.slicer.org/t/get-centroid-from-script/13191/2 "2020-08-27T13:53:52Z")

</div>

You need to enable the `LabelmapSegmentStatisticsPlugin` plugin and the computation of the `centroid_ras` value.

---

<div class="post-metadata">

**Author:** ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)\
**Post date:** [August 27, 2020, 6:05pm UTC](https://discourse.slicer.org/t/get-centroid-from-script/13191/3 "2020-08-27T18:05:27Z")

</div>

Thanks you Prof Lasso. Thi
