# How can I draw a coordinate system on the image?

**URL:** <https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205>\
**Category:** Development\
**Created:** [March 19, 2019, 11:47am UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205 "2019-03-19T11:47:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 19, 2019, 11:47am UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/1 "2019-03-19T11:47:27Z")

</div>

Hi everyone,

I am currently working on a project related to pelvic floor MRI images recognition. I have already recognized a feature point and a reference line in a scripted module. And I’m trying to build a new coordinate system by setting the point as origin and the line as x-axis.  
I want to draw the two-dimensional cartesian coordinate system on the image but I can’t find a way to plot it. Does anyone have any idea?  
Please help me out.

Thanks,  
Andrea

---

<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:** [March 19, 2019, 12:39pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/2 "2019-03-19T12:39:12Z")

</div>

You can enable coordinate system axes orientation marker in the slice view controller:

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

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 19, 2019, 1:04pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/3 "2019-03-19T13:04:35Z")

</div>

> [@lassoan](#):
>
> axes orientation marke

Hi Andras,  
Thank you for the quick response! This is a function I haven’t noticed before and thanks for pointing out. However, I want to move the coordinate system’s origin to a specific point and also change the direction of the axis. If possible, I want to mark the coordinate value on the axis. Is there anyway to accomplish this?

Thank you for your time!  
Andrea

---

<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:** [March 19, 2019, 1:14pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/4 "2019-03-19T13:14:57Z")

</div>

I don’t remember this has ever come up as a need. What would you like to achieve with this? There may be alternative, more commonly used solutions for your problem.

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 19, 2019, 1:49pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/5 "2019-03-19T13:49:21Z")

</div>

Hi Andras,

Thanks for your answer. In this module I created, users can mark fiducial points according to their needs, and the points are given new coordinate values in a new coordinate system(by setting new coordinate system helps better diagnose of a disease). I want to help the users get a better view of the position. I’ll look for alternatives. Do you have any recommendations?

Thanks  
Andrea

---

<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:** [March 19, 2019, 2:01pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/6 "2019-03-19T14:01:45Z")

</div>

Are you trying to find the relationship between two coordinate systems? If so, what are these two coordinate systems and what they are defined by? Would it make sense to perform registration such as landmark registration?

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 19, 2019, 2:58pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/7 "2019-03-19T14:58:03Z")

</div>

Hi Csaba,  
Thanks for answering. I have found the relationship between the two coordinate systems. One of them is defined by the MRI image feature points (got from a deep learning model), the other one is the RAS coordinate Slicer-provided. So I think I have already used landmark registration.

Thanks for your time!  
Andrea

---

<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:** [March 19, 2019, 3:44pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/8 "2019-03-19T15:44:05Z")

</div>

Now I’m even more confused about what you would like to achieve. Visualize something, or get user input, register, … Anyway, there are many readily available tools in Slicer for doing such things, so if you can describe what you would like to do (not so much how exactly you would like to do it) then we should be able to help.

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 20, 2019, 3:12am UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/9 "2019-03-20T03:12:48Z")

</div>

Hi, Andras

Thanks for answering! Sorry for the confusion here. What I want to do is to visualize the new coordinate system I have already set on the image. If that is not possible, maybe I can draw something else as a replacement.  
Is there a way to draw a line between two fiducial points? (the points already existed)

Thank you for your time!  
Andrea

---

<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:** [March 20, 2019, 4:54am UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/10 "2019-03-20T04:54:48Z")

</div>

> [@ZiyunLiang](#):
>
> Is there a way to draw a line between two fiducial points?

Yes. You can use MarkupsToModel extension to draw lines between markup fiducials (enable slice intersection display to show in slice views). In recent nightly versions of Slicer, there are curve and line markups that you can use, but this part of the code is still actively developed, so it is not that stable.

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 20, 2019, 1:05pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/11 "2019-03-20T13:05:02Z")

</div>

Hi Andras  
Thank you for answering. I tried to use MarkupsToModel extension. But when I use the code  
`markupsToModel = slicer.mrmlScene.AddNode(slicer.vtkMRMLMarkupsToModelNode())`  
I got the error

```
Traceback (most recent call last):File "<console>" line 1, in <module>

AttributeError: 'module' object has no attribute 'vtkMRMLMarkupsToModelNode'

```

Do you know how to fix this bug?

Thank you for your time!  
Andrea

---

<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:** [March 20, 2019, 1:17pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/12 "2019-03-20T13:17:29Z")

</div>

The line above works well for me. You need to install MarkupsToModel extension and restart Slicer.

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 20, 2019, 1:22pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/13 "2019-03-20T13:22:10Z")

</div>

Hi Andras, after restarting the Slicer, it worked. Thank you for your help!

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 20, 2019, 1:51pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/14 "2019-03-20T13:51:34Z")

</div>

Hi, sorry to bother you again, but I want to know if there is a way to stop updating the line even after I keep adding new fiducial points.

> [@lassoan](#):
>
> In recent nightly versions of Slicer, there are curve and line markups that you can use, but this part of the code is still actively developed, so it is not that stable.

And I’m sorry I didn’t understand this. Do you mean there are changes in MarkupsToModel in the recent nighty version?

Thanks!  
Andrea

---

<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:** [March 20, 2019, 1:57pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/15 "2019-03-20T13:57:20Z")

</div>

> [@ZiyunLiang](#):
>
> if there is a way to stop updating the line even after I keep adding new fiducial points.

You can disable automatic updates or delete the MarkupsToModel and your input markups completely if you don’t want to allow your lines to be moved anymore.

> [@ZiyunLiang](#):
>
> Do you mean there are changes in MarkupsToModel in the recent nighty version?

Yes. Huge changes, tons of new features. For example, you can display a “markups line”, which you can position programmatically or by interacting on the GUI. It can be also locked if you don’t want to allow the user to move it.

---

<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:** [March 20, 2019, 2:58pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/16 "2019-03-20T14:58:47Z")

</div>

It would help to know why you want to “display the coordinate system”.  
Usually it is not needed because everything is brought to a common coordinate system using registration. So if you explain your use case from a higher level, then we may offer a solution that does not require implementing something that otherwise would not be needed.

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 21, 2019, 9:28am UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/17 "2019-03-21T09:28:23Z")

</div>

> [@lassoan](#):
>
> Huge changes

I looked over the new version and these are indeed awesome changes. Thanks for pointing it out.

> [@lassoan](#):
>
> You can disable automatic updates or delete the MarkupsToModel and your input markups completely if you don’t want to allow your lines to be moved anymore.

These works for me. Thanks for your answer.

---

<div class="post-metadata">

**Author:** ![ZiyunLiang](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@ZiyunLiang](https://discourse.slicer.org/u/ZiyunLiang)\
**Post date:** [March 21, 2019, 9:46am UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/18 "2019-03-21T09:46:05Z")

</div>

Hi Csaba,  
Thanks for your time. I want to display a new coordinate system for the following reasons:

1. in pelvic floor POP diagnose, a new system(PICS system) would help a lot. To implement this, there will be a new x-axis with every image. So there will be a new coordinate system and the coordinate system will be at different position every time.
2. I want to plot is because I want to visualize the new coordinate system and it can give users a better understanding of where does the coordinates came from.

---

<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:** [March 21, 2019, 12:27pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/19 "2019-03-21T12:27:12Z")

</div>

> [@ZiyunLiang](#):
>
> display a new coordinate system

Can you describe what you’d like the display to look like? Is it the three orthogonal arrows like the axis display in the lower right corner? You could create a Model node that has those same kinds of arrows and just move it where you want, for example using the transform you calculate. Or maybe it would be clearer to your uses if you make some other kind of model, like a grid (like graph paper). In any case, you can either write a small program to generate the model using slicer/vtk or you can make a model in an external program like Blender.

---

<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:** [March 21, 2019, 12:54pm UTC](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205/20 "2019-03-21T12:54:04Z")

</div>

Yes, and you can do this by just using existing modules: You may generate a coordinate system model by using SlicerIGT extension’s CreateModels module. Then apply a transform to this coordinate system model using Transforms module and visualize it in slice views as projection using Models module.

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

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/2/42fb02be75ca7b773b9cd6caee3bcaca0010937f.png)

[Next page](https://discourse.slicer.org/t/how-can-i-draw-a-coordinate-system-on-the-image/6205.md?page=2)
