How Can I Do Fiducial Registration using Python?

I want to merge a DICOM and STL file with the Fiducial Registration method in Python. The files will be opened in an interface, an equal number of points will be placed on the models and merged based on those points. Is it possible to do this in Python? Is there any repo, keyword etc. that you can recommend?

I would recommend to use SlicerIGT module’s Fiducial Registration Wizard module to do this. All you need to do is to add the input markup fiducial list nodes, the output transform node, and a vtkMRMLFiducialRegistrationWizardNode to the scene and set their parameters.

Thank you for your answer.

Is it possible to run this in a separate Python script from the Slicer programme? I’m working on a web based project where Fiducial Registration is a part of it, so I can’t use Slicer directly. Is it possible to install Slicer in a virtual environment? If not, what do you recommend as a separate method?

I also converted two STL files to PCD and merged them with the ICP algorithm, but I think this method is not useful. Because I want to merge a DICOM and STL file, not convert it to PCD.

Thank you again for your help!

Yes, you can use all Slicer features without using the GUI. For example, you can run Slicer in a docker container (or directly on the host) and use its REST API to execute any commands. Using the REST API has the advantage that you can achieve interactive update rates (dozens of command executions per second) even when you operate on large, complex data. If you start Slicer executable or a CLI module for each operation then you need to perform several additional time-consuming steps (write the inputs to file, wait for the executable to start, read data, and after the computation write data to file, and read the results from file). Slicer provides its own virtual Python environment, so you don’t need to install any Python distributions.

For more complex operations, you can also expose the entire interactive Slicer GUI in the web browser using novnc and websockets.

I’m relatively new to these topics. The project I’m working on will be developed using Django. Unfortunately, I don’t have an environment where I can run 3D Slicer. I need to set up my own virtual environment, install Slicer, and be able to invoke and use it. I also need to definite points on 3D images within Django. Fiducial registration should also be done within Django. Additionally, I require a tool in Django that allows me to view the results in the Axial, Sagittal, and Frontal planes.

What is your environment? Why do you think you cannot run 3D Slicer in your environment?

As I described above, you don’t need to run Slicer as an interactive a GUI application, but you can use it as a web service.


below there is a link to a python implementation of the rigid body transformation algorithm (with reference to the paper). I implemented this long ago, but the code is simple (it may be still python 2 code), maybe you can make use of it