How can I draw a coordinate system on the image?

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

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

image

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

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.

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

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?

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

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.

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

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.

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

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

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

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.

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

Thanks!
Andrea

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.

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.

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.

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

These works for me. Thanks for your answer.

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.
1 Like

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.

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

image

1 Like