# Drawing Circle on CT Image

**URL:** <https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387>\
**Category:** Support\
**Created:** [October 27, 2021, 2:12pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387 "2021-10-27T14:12:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckbow](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@ckbow](https://discourse.slicer.org/u/ckbow)\
**Post date:** [October 27, 2021, 2:12pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/1 "2021-10-27T14:12:01Z")

</div>

Is it possible to draw a circle (markup) on a CT image? I initially tried using the Closed Curve Markup, but I do not know how to make or adjust it into a circle. I need to be able to align the perimeter of the circle with the cortices of the bone, while having a visible midpoint to determine the bone’s midline (as shown).

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/f/8f3fbd42a344f53a092a9a8fd8bcca857eedd8cb.jpeg)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 27, 2021, 4:24pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/2 "2021-10-27T16:24:59Z")

</div>

In Slicer we focus on 3D operations and don’t have much support for drawing 2D shapes like circles. Instead you could use a 3D fiducial (point with radius) to fit the 3D shape of the bone. Then you could use a 3D line for the bone axis. See the [Markups module](https://slicer.readthedocs.io/en/latest/user_guide/modules/markups.html).

---

<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:** [October 28, 2021, 12:55pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/3 "2021-10-28T12:55:33Z")

</div>

> [@pieper](#):
>
> Instead you could use a 3D fiducial (point with radius) to fit the 3D shape of the bone.

You can also use 2 points of a markups fiducial node to specify a circle by copy-pasting a few lines of code to into the Python console as shown in [this example](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#define-edit-a-circular-region-of-interest-in-a-slice-viewer).

I’ve created a modified script that allows you to place 2 circles by specifying 6 points on the circumference: [Compute bone axis in 3D Slicer by specifying two circles. · GitHub](https://gist.github.com/lassoan/99514fb5edf98e1e3dda926253dc9742)

You can use this by placing one fiducial list containing 6 points then copy-pasting into the Python console:

[![](https://img.youtube.com/vi/1DG3y1TqWvw/maxresdefault.jpg "Custom interactive measurement using Python scripting") ](https://www.youtube.com/watch?v=1DG3y1TqWvw)

---

<div class="post-metadata">

**Author:** ![ckbow](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@ckbow](https://discourse.slicer.org/u/ckbow)\
**Post date:** [October 29, 2021, 4:25pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/4 "2021-10-29T16:25:33Z")

</div>

> [@pieper](#):
>
> Instead you could use a 3D fiducial (point with radius) to fit the 3D shape of the bone.

With this approach, I have managed to get a circular region of interest. However, I am not able to get a separate circle when I run the code again with a new set of fiducial points.

> [@lassoan](#):
>
> I’ve created a modified script that allows you to place 2 circles by specifying 6 points on the circumference

With this approach, I am running into a similar issue. I am able to get the first set of two circles, but I am not able to get the second set of two circles on a different bone. (I need two circles to define each bone axis, as well as two bone axes to measure joint flexion angle).

---

<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:** [October 29, 2021, 4:34pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/5 "2021-10-29T16:34:10Z")

</div>

> [@ckbow](#):
>
> With this approach, I am running into a similar issue. I am able to get the first set of two circles, but I am not able to get the second set of two circles on a different bone. (I need two circles to define each bone axis, as well as two bone axes to measure joint flexion angle).

Yes, sure, based on the workflow you want to implement you need to tune the script.

For example, you can add a keyboard shortcut to call a function that adds measurement results to a table node and clears the fiducial points so that you can place the points again. This is a quick solution if you are the only person who performs these measurements.

You can also write a Slicer Python scripted module that observes markups fiducial lists that the module adds to the scene and add the model nodes as needed. See the [Baffle Planner module in SlicerHeart extension](https://github.com/SlicerHeart/SlicerHeart/tree/master/BafflePlanner) as an example. This requires more work than just crafting a python script in the Python console, but it is worth it if you want to create user-friendly tool that other people can use, too.

The most sophisticated level is to create a custom widget representation, which renders the fiducial list as two circles and a line. This should be quite simple to do in C++ (you can define a new markup type by deriving from an existing type and override anything in it), but we have not made the classes customizable in Python yet.

---

<div class="post-metadata">

**Author:** ![reynvw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/reynvw/32/17375_2.png) [@reynvw](https://discourse.slicer.org/u/reynvw)\
**Post date:** [November 17, 2022, 2:34pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/6 "2022-11-17T14:34:27Z")

</div>

Hi,

I have come across this section because I need to use a circle as well in 2D (with a central point, because I want to be able to calculate the radius) and your first suggestion works perfectly for that. However, I have problems removing the circle from my image, if I remove the control points the circle stays and I can not move it anymore. Is there any solution for that?

Also, is there an option to view the radius of the created circle? That way I don’t have to go and measure it for every circle I make.

Thanks a lot,  
from a medical student

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [November 17, 2022, 3:10pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/7 "2022-11-17T15:10:16Z")

</div>

If you can build Slicer, you may build [this](https://github.com/chir-set/ExtraMarkups) extension. It has a custom markups that will do what you want. (It’s somehow funny because it is this very opening post that prompted me to write this extension). If you can’t build software, it’s not the right tool for you.

---

<div class="post-metadata">

**Author:** ![reynvw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/reynvw/32/17375_2.png) [@reynvw](https://discourse.slicer.org/u/reynvw)\
**Post date:** [November 17, 2022, 3:42pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/8 "2022-11-17T15:42:22Z")

</div>

I don’t know almost anything about coding or building software so I am not sure. The provided code is actually already perfectly what I need, it’s just annoying sometimes that the yellow circle stays in all my 2D planes when I don’t need it anymore.

Thanks for your reply though!

---

<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:** [November 17, 2022, 5:34pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/9 "2022-11-17T17:34:15Z")

</div>

> [@chir.set](#):
>
> If you can build Slicer, you may build [this](https://github.com/chir-set/ExtraMarkups) extension. It has a custom markups that will do what you want. (It’s somehow funny because it is this very opening post that prompted me to write this extension). If you can’t build software, it’s not the right tool for you.

@chir.set This looks useful, particularly the label one. Is there a reason why you are not making this part of the extension catalog (like the surface markup add on is)?

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [November 17, 2022, 5:48pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/10 "2022-11-17T17:48:28Z")

</div>

> [@muratmaga](#):
>
> Is there a reason why you are not making this part of the extension catalog

1. It did not trigger much interest on previous evaluation requests.

2. Bureaucracy is significant when submitting an extension. We have to interact with robots and it’s not an easy one. But it’s not a hard blocker as such.

---

<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 17, 2022, 7:20pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/11 "2022-11-17T19:20:49Z")

</div>

> [@chir.set](#):
>
> It did not trigger much interest on previous evaluation requests

It seems that there is some interest, so you may reconsider now.

> [@chir.set](#):
>
> Bureaucracy is significant when submitting an extension. We have to interact with robots and it’s not an easy one. But it’s not a hard blocker as such.

This is the checklist you need to complete:

> <https://github.com/Slicer/ExtensionsIndex/blob/main/.github/PULL_REQUEST_TEMPLATE.md>

As I see, you can check out almost all the boxes, so it should not be a lot of extra work.

Slicer extensions submission process is not very automated, so dealing with robots should not be a big issue. Usually the main challenge is availability of reviewers, but we do our best.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [November 17, 2022, 7:57pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/12 "2022-11-17T19:57:39Z")

</div>

> [@lassoan](#):
>
> we do our best

I don’t have any doubt about that.

> [@lassoan](#):
>
> so you may reconsider now

I’ll start preparing the work for the extension catalog ASAP.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [November 20, 2022, 6:21pm UTC](https://discourse.slicer.org/t/drawing-circle-on-ct-image/20387/13 "2022-11-20T18:21:38Z")

</div>

> [@muratmaga](#):
>
> making this part of the extension catalog

The PR is [here](https://github.com/Slicer/ExtensionsIndex/pull/1897) in the extension index. I don’t know how it is further processed, wait and see.
