How to obtain x,y,z points from fiducial points and insert them into vtkPoints

vtk
python

(Chad Paik) #1

Hello

I am trying to get the point values of fiducial points and put them into a vtkPoints.

The end goal is to create a tps transformation using these fiducial points.

tps = vtk.vtkThinPlateSplineTransform()
tps.SetSourceLandmarks()
tps.SetTargetLandmarks()

I was using this function and it requires me to input a vtkPoints.

I would appreciate it if you can help me.

Thank you


(Adam Rankin) #2
n = slicer.util.getNode('F')

points = vtk.vtkPoints()

for i in range(0, n.GetNumberOfFiducials()):
  point = [0,0,0]
  n.GetMarkupPoint(i,0,point)
  points.InsertNextPoint(point[0], point[1], point[2])

print('Yay!')

(Chad Paik) #3

Thank you! That is exactly what I needed!


(Andras Lasso) #4

SlicerIGT extension’s Fiducial Registration wizard module does exactly this and much more. It offers a nice GUI, allows preview of results, real-time updates, helps collection of landmarks, can automatically match landmarks (even if their order is mixed up or the number of source and landmarks is not the same), compute residual error, etc.


(Chad Paik) #5

Hi Andras

Thank you, I tried it out and it gives me the result I need. Is there a place where I can find more information on how to use the functions in a script?

Thank you

Chad Paik


(Andras Lasso) #6

See documentation in header files:

See examples of manipulating MRML nodes and using various module logics from Python in script repository: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository

Let us know if you have any specific questions.


(Chad Paik) #7

Hi Andras

Is there any code that used the Fiducial Registration Wizard in their script? I could not find one in the repository.

I am just having trouble getting started in how to use the module. I want to to go through multiple fiducial mark up sets and find warping transform from one to another. How would I get started?

Thank you

Chad Paik


(Andras Lasso) #8

All you need to do is to add a fiducial registration wizard node to the scene and set its input markup nodes and output transform nodes, registration mode, etc. Output is automatically updated if yiy enable autó-update or call the module logic’s Update Calibration method.