# Skull / Skin of head segmentation rotation

**URL:** <https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607>\
**Category:** Development\
**Tags:** python\
**Created:** [February 10, 2025, 4:58pm UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607 "2025-02-10T16:58:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxtt](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@mxtt](https://discourse.slicer.org/u/mxtt)\
**Post date:** [February 10, 2025, 4:58pm UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607/1 "2025-02-10T16:58:15Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/b/3b4edd78c022b5a7efc32fd1a0f561fedc99af4e.png)

So I have this segmentation of the skin of a head, I also have the skull (not displayed here). Does anyone have an intelligent way to rotate it so that is is positioned correctly - by correctly I essentially mean rotated so that the eyes fall on an equal, horizontal plane. You can see in the image the head is rotated slightly in the CT and I essentially want it straightened.

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:** [February 11, 2025, 10:03am UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607/2 "2025-02-11T10:03:07Z")

</div>

Just to confirm, because you posted in the development category (but I don’t find any clue about this in your text), do you want to do this automatically using Python code?

---

<div class="post-metadata">

**Author:** ![mxtt](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@mxtt](https://discourse.slicer.org/u/mxtt)\
**Post date:** [February 11, 2025, 4:59pm UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607/3 "2025-02-11T16:59:01Z")

</div>

Yes I would like to do this automatically through python development. I am writing a script and would like this feature implemented so that it auto rotates the head to the so that it lines up with the orthogonal planes.

I was hoping someone might have a good way to do this as I couldn’t find much.

---

<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:** [February 12, 2025, 1:35pm UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607/4 "2025-02-12T13:35:48Z")

</div>

The only thing that occurs to me is to try to run TotalSegmentator (or other model that works for the head), get the eyeball centers and do a rotation around the AP axis.

---

<div class="post-metadata">

**Author:** ![mxtt](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@mxtt](https://discourse.slicer.org/u/mxtt)\
**Post date:** [February 12, 2025, 4:30pm UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607/5 "2025-02-12T16:30:51Z")

</div>

If I use a semi-automated approach where I place at least 2 fiducials on the corner of the eye and the nasion, do you think this would be sufficient?

Also how might I do the rotation through python?

Thank you for all the input!

---

<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:** [February 13, 2025, 9:10am UTC](https://discourse.slicer.org/t/skull-skin-of-head-segmentation-rotation/41607/6 "2025-02-13T09:10:39Z")

</div>

> [@mxtt](#):
>
> If I use a semi-automated approach where I place at least 2 fiducials on the corner of the eye and the nasion, do you think this would be sufficient?

Absolutely.

> [@mxtt](#):
>
> Also how might I do the rotation through python?

You can fit a plane on the points, calculate its normal, construct a transformation matrix so that the plane normal is the new IS axis, then set the transform node containing this matrix to the volume as parent.
