Adding fiducial marks and determining RAS coordinates

Hello everyone,
Is there anyway to add fiducial markers to a stl data without the markups module? I want to add fiducial markers manually to the module I am working on. I’d like to display the RAS coordinates to the module GUI.

Hi,
You can take advantage of the markups module in your own module, without using the markups module in a visible way. There are examples in the script repository how to use module functions (including markups) from your module: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Switching_to_markup_fiducial_placement_mode
I hope this helps,
Tamas

Hello Tamas,
Thank you for your reply! This is written in python but I am extending a cxx file. Can the same thing be done in C++ along with the QT framework? If it can be done, I am really counting on your suggestions.

Best regards,
Anish

Yes, the Markups module is written in C++, so you should be able to use the same functions in a C++ loadable module too.
I think it is very rare that people use C++ to write Slicer modules nowadays. If an application-specific workflow needs to be supported by a custom Slicer module, Python seems to be a more efficient choice.

Thank you for your reply. Is there any example to do that? Cause I researched on the internet but I did not find a solution.

If you are looking for an example C++ module that uses fiducials for registration, this one comes to mind:


This is a convenience module that keeps track of two fiducial lists and computes registration between them. The result is stored in a transform node that can be used by other modules.

Thank you very much for your reply! I really had a hard time understanding the module. As I said earlier, I’d only want to display the fiducial point with RAS coordinates. I am new to VTK and 3D slicer. Therefore, I’d really appreciate your help.

Why don’t you use the Markups module? If you expand the “Control Points” section of the Markups module widget, you can see the RAS coordinates there.

I think what you are wanting is exactly what the qSlicerSimpleMarkupsWidget provides.

simple_markups = slicer.qSlicerSimpleMarkupsWidget()
simple_markups.setMRMLScene(slicer.mrmlScene)

image

Or the Markups module

In this case I would strongly recommend to use Python while you are getting to know the libraries (VTK, ITK, Qt, CTK, Slicer, etc.). Once you know how things work and what exactly you need, you can easily switch back to C++. We often use Python, even for prototyping new Slicer core features that are in the end ported to C++.

Thank you very much for your reply! I wanted to deliver the same functionality as control points section of the markups module widget.

Thank you very much for your reply! I will try it and let you know.

Thank you very much for your suggestions. I have basic knowledge of C++ programming and the project that I am working on right now demands the use of C++. Therefore, I’d like to have a good grasp of development of a module with c++. It’d be nice if you could recommend me some resources that I can rely on.

Majority of Slicer core is implemented in C++ and there are a number of extensions that use C++ (SlicerRT, SlicerIGT, SlicerOpenIGTLink, SlicerIGSIO, SlicerDMRI, SlicerAstro, SlicerFreeSurfer, GelDosimetry, PerkTutor, etc.) that you can use as examples.

Hello everyone,
I am now able to put fiducial points with mouse click. I have used QTableWidget to write the fiducial points in the widget. But I’d like to display the points in real time in the widget. Whenever I place the fiducial point I need it to display in the widget. I went through the Markpus Module but did not understand how they achieved the functionality.

Instead of redeveloping a table widget for displaying markups control points from scratch, I would recommend to use the widget as @jamesobutler suggested above. It is quite configurable, so it should be able to do exactly what you need, but if you cannot figure out how to achieve something then let us know.

Hi Andras,
I am trying to access the class qslicerSimpleMarkupsWidget. As I am doing it with c++, I am now confused about accessing the widget. I suppose James called it using scripted module. Can I convert the scripted code to c++ code somehow?

Best regards,
Anish

Hello,
I have found that the fiducial points can be placed with the help of a button using scripted module. But how can I achieve the same functionality using the loadable module?

w=slicer.qSlicerMarkupsPlaceWidget()
w.setMRMLScene(slicer.mrmlScene)
markupsNodeID = slicer.modules.markups.logic().AddNewFiducialNode()
w.setCurrentNode(slicer.mrmlScene.GetNodeByID(markupsNodeID))
# Hide all buttons and only show place button
w.buttonsVisible=False
w.placeButton().show()
w.show()

Best regards,
Anish

Do you mean that you would like to translate the Python code above to C++?

Hello Andras,
Thank you for the reply. Yes exactly! I read somewhere in the forum that I can add an observer to the fiducial node to monitor the changes and display it in the table widget. But I do not know how to proceed it with c++ code. Therefore, it would be easy for me to display by accessing the qSlicerSimpleMarkupsModule with c++ from my module.

Best regards,
Anish