# Center of femoral head

**URL:** <https://discourse.slicer.org/t/center-of-femoral-head/14858>\
**Category:** Support\
**Created:** [December 2, 2020, 11:49pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858 "2020-12-02T23:49:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![felix2609](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@felix2609](https://discourse.slicer.org/u/felix2609)\
**Post date:** [December 2, 2020, 11:49pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/1 "2020-12-02T23:49:26Z")

</div>

Hello everyone,

is there any possibility to mark the center of the femoral head? In planning softwares you can draw a circle around the contour of the femoral head, but i see no possibility to draw a circle and mark its center.

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [December 3, 2020, 12:02am UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/2 "2020-12-03T00:02:42Z")

</div>

I am not sure how you define the contour of the femoral head, but if you are planning in 3D view, you can easily trace it via the closed curve markups tool and calculate its centroid.

---

<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:** [December 3, 2020, 5:56am UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/3 "2020-12-03T05:56:22Z")

</div>

We provide general tools in Slicer and you can easily handcraft your specialized tools using Python scripting. For example, you can specify a sphere using markups fiducials, either directly determining the optimal sphere from multiple points and/or manually positioning a sphere by adjusting a few control points.

You can get a best-fit sphere if you place a couple of markups fiducial points on the femur head surface (either in slice views or in 3D) then copy-paste this code snippet into the Python console:  
~~[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Specify\_a\_sphere\_by\_multiple\_of\_markups\_points](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Specify_a_sphere_by_multiple_of_markups_points)~~ [https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#specify-a-sphere-by-multiple-control-points](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#specify-a-sphere-by-multiple-control-points)

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

If you prefer interactive adjustment then you can place one fiducial in the sphere’s center, one at the sphere’s boundary and copy-paste this code snippet in the Python console: ~~[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How\_to\_define.2Fedit\_a\_circular\_region\_of\_interest\_in\_a\_slice\_viewer.3F](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_define.2Fedit_a_circular_region_of_interest_in_a_slice_viewer.3F)~~ [https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#define-edit-a-circular-region-of-interest-in-a-slice-viewer](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#define-edit-a-circular-region-of-interest-in-a-slice-viewer)

You can make out a Slicer module from these code snippets (and anything else you need to do in your workflow) - see tutorials [here](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials).

---

<div class="post-metadata">

**Author:** ![felix2609](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@felix2609](https://discourse.slicer.org/u/felix2609)\
**Post date:** [December 5, 2020, 3:27pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/4 "2020-12-05T15:27:06Z")

</div>

thank you for your help! do you know how to calculate the center of a 2d circle segmentation and get a center point?

---

<div class="post-metadata">

**Author:** ![felix2609](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@felix2609](https://discourse.slicer.org/u/felix2609)\
**Post date:** [December 5, 2020, 3:29pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/5 "2020-12-05T15:29:35Z")

</div>

thank you very much! works good but i can´t remove the circle once it´s set. How can i remove 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:** [December 5, 2020, 3:44pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/6 "2020-12-05T15:44:09Z")

</div>

> [@felix2609](#):
>
> do you know how to calculate the center of a 2d circle segmentation and get a center point?

You can use Segment Statistics module to get bounding box center and size. You can use the GUI or this script: ~~[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get\_size.2C\_position.2C\_and\_orientation\_of\_each\_segment](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_size.2C_position.2C_and_orientation_of_each_segment)~~[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#get-size-position-and-orientation-of-each-segment](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-size-position-and-orientation-of-each-segment)

What kind of data do you work with? What would you like to achieve?

> [@felix2609](#):
>
> can´t remove the circle once it´s set

You can remove the node or hide it or not even create a model node for displaying the sphere.

---

<div class="post-metadata">

**Author:** ![eliagre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eliagre/32/18509_2.png) [@eliagre](https://discourse.slicer.org/u/eliagre)\
**Post date:** [February 21, 2023, 4:34pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/7 "2023-02-21T16:34:14Z")

</div>

> [@lassoan](#):
>
> You can get a best-fit sphere if you place a couple of markups fiducial points on the femur head surface (either in slice views or in 3D) then copy-paste this code snippet into the Python console: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Specify\_a\_sphere\_by\_multiple\_of\_markups\_points](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Specify_a_sphere_by_multiple_of_markups_points)

Hello, I’m trying to apply your code to define my best-fit sphere. When I enter the code, I get the following error message:  
“Traceback (most recent call last):  
File “”, line 37, in   
NameError: name ‘markups’ is not defined”

I’m not familiar with python, so I don’t know how to fix this. Could you help me out, please?  
The code I applied was found on this webpage, under " Specify a sphere by multiple control points": [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html)

Operating system: win11  
Slicer 5.2.1

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [February 21, 2023, 5:26pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/8 "2023-02-21T17:26:23Z")

</div>

There is a typo in the script. Replace the markups with pointListNode and it should work.

@lassoan can you fix?

---

<div class="post-metadata">

**Author:** ![eliagre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eliagre/32/18509_2.png) [@eliagre](https://discourse.slicer.org/u/eliagre)\
**Post date:** [February 21, 2023, 5:31pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/9 "2023-02-21T17:31:54Z")

</div>

It worked perfectly now, thank you!

---

<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:** [February 21, 2023, 6:13pm UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/10 "2023-02-21T18:13:10Z")

</div>

Thanks, fixed [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#specify-a-sphere-by-multiple-control-points).

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [February 22, 2023, 6:05am UTC](https://discourse.slicer.org/t/center-of-femoral-head/14858/11 "2023-02-22T06:05:46Z")

</div>

For reference, the corresponding documentation fix has also been backported to the `5.2` maintenance branch.
