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) 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?
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.
The original segmentation isn’t transformed, so I’m not quite sure.
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.
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.