# Draw principal axes

**URL:** <https://discourse.slicer.org/t/draw-principal-axes/27144>\
**Category:** Support\
**Created:** [January 9, 2023, 10:49pm UTC](https://discourse.slicer.org/t/draw-principal-axes/27144 "2023-01-09T22:49:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![soukup.la](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/soukup.la/32/17954_2.png) [@soukup.la](https://discourse.slicer.org/u/soukup.la)\
**Post date:** [January 9, 2023, 10:49pm UTC](https://discourse.slicer.org/t/draw-principal-axes/27144/1 "2023-01-09T22:49:44Z")

</div>

Hello,  
I would like to draw Principal axes (segment statistic) using Python console. Is it possible please?

thank you!

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 11, 2023, 1:07pm UTC](https://discourse.slicer.org/t/draw-principal-axes/27144/2 "2023-01-11T13:07:53Z")

</div>

You can create line or curve markups for the axes and have a control point at (0,0,0) and the other in the coordinate of the axis you got from Segment Statistics.

---

<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:** [January 11, 2023, 5:52pm UTC](https://discourse.slicer.org/t/draw-principal-axes/27144/3 "2023-01-11T17:52:54Z")

</div>

[There is an example in the script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#markups-roi) that draws the principal axes using ROI markup. It should not be hard to modify it to use lines instead.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/9/59074851448c694c723545756da8d709daa2dc74.jpeg)

---

<div class="post-metadata">

**Author:** ![MdeBo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mdebo/32/77259_2.png) [@MdeBo](https://discourse.slicer.org/u/MdeBo)\
**Post date:** [July 9, 2024, 7:36am UTC](https://discourse.slicer.org/t/draw-principal-axes/27144/4 "2024-07-09T07:36:28Z")

</div>

Hi,  
Thanks for the suggestion given above. I found the Python code and I believe I should change some string names. However, I am not sure with what name I can call the principal axes.  
For example: what should I put instead of `obb_direction_ras_x` within `"LabelmapSegmentStatisticsPlugin.obb_direction_ras_x"` to obtain the principal x axes?

In the end I would like to obtain a figure as in [this post](https://discourse.slicer.org/t/new-segment-statistics-oriented-bounding-box-diameter-and-more/10203), in the **Principal axes and moments** figure.

Thanks in advance!

---

<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:** [July 11, 2024, 4:44am UTC](https://discourse.slicer.org/t/draw-principal-axes/27144/5 "2024-07-11T04:44:42Z")

</div>

The referenced [script](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#markups-roi) to generate the bounding boxes still works well. There is no need to change anything. The principal x axis is saved into the `obb_direction_ras_x` variable.
