# OBB Not Aligned with Segmentde

**URL:** <https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746>\
**Category:** Development\
**Created:** [November 11, 2023, 6:22pm UTC](https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746 "2023-11-11T18:22:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamieawren](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jamieawren](https://discourse.slicer.org/u/jamieawren)\
**Post date:** [November 11, 2023, 6:22pm UTC](https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746/1 "2023-11-11T18:22:18Z")

</div>

Hi Everyone,

I’m calculating a bounding box for a segment, and the output’s measurement appear to be correct, i.e. I’m using a 20mm paint brush and the height and width are 20mm. When I use the code found here ([Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#markups-roi)) to view the box though, it’s not aligned with the segment.

Any thoughts? Is the just an annoying fluke, or is it affecting the calculation of the bounding box?

 ![Screenshot 2023-11-11 at 1.17.40 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/2/22f9d017dd59182062252810ccd16c7c1e4675f9.jpeg)

Thank you!

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [November 11, 2023, 8:15pm UTC](https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746/2 "2023-11-11T20:15:38Z")

</div>

Is the original segmentation transformed? If so, perhaps the SegmentStatistics calculations ignore any parent transforms. Try applying the same parent transform of the original segmentation to the bounding box ROI object and see if it lines up then.

---

<div class="post-metadata">

**Author:** ![jamieawren](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jamieawren](https://discourse.slicer.org/u/jamieawren)\
**Post date:** [November 11, 2023, 8:28pm UTC](https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746/3 "2023-11-11T20:28:16Z")

</div>

The original segmentation isn’t transformed, so I’m not quite sure.

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [November 11, 2023, 8:54pm UTC](https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746/4 "2023-11-11T20:54:44Z")

</div>

I don’t have time to test independently at the moment, but in that case it may be a bug. If you can reproduce with a minimal example and share the scene here, that would help anyone trying to debug it.

---

<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:** [November 11, 2023, 11:38pm UTC](https://discourse.slicer.org/t/obb-not-aligned-with-segmentde/32746/5 "2023-11-11T23:38:20Z")

</div>

I’ve just tested and the script still works well. The problem was that you used a Slicer version that is 2.5 years old (Slicer-4.11) with the documentation of the latest Slicer version (Slicer-5.5).

I would recommend to use the current Slicer version as we implemented hundreds of fixes and improvements since Slicer-4.11 was released.
