deformable PointSet to PointSet registration with python

Hello all,
I am trying to implement a deformable registration for two pointsets in python-itk.

Being a newbie I started with the itk.PointSetToPointSetRegistrationMethod, but got stuck when trying to set the metric for it (registration.setMetric(metric)), getting the following error:
TypeError: in method 'itkPointSetToPointSetRegistrationMethodREGF3F3_SetMetric', argument 2 of type 'itkPointSetToPointSetMetricPSF3 *

Following this blog post I used this metric:
‘registration_method = itk.PointSetToPointSetRegistrationMethod.REGF3F3.New()’
when it didn’t work I kind of brute forced through every PointSet to PointSet metric defined here:

metric = itk.PointSetToPointSetMetric[type(fixed_set), type(fixed_set)].New()
metric = itk.PointSetToPointSetMetricv4[type(fixed_set)].New()
metric = itk.PointSetToPointSetMetricWithIndexv4[type(fixed_set)].New()
metric = itk.ExpectationBasedPointSetToPointSetMetricv4[type(fixed_set)].New()
metric = itk.EuclideanDistancePointSetToPointSetMetricv4[type(fixed_set)].New()

Am I doing something wrong or should I maybe use a different registration method?
In addition, I have trouble to decide which optimizer I should use.
I would be thankful for any help.

Backstory:
I want to register two stl-objects (S_sphere.stl and S_ellipsoid.stl). The code I have so far is in the testfile.py file.
testfile.py (1.5 KB)
S_ellipsoid.stl (82.1 KB)
S_sphere.stl (82.1 KB)

I don’t know what these point set metrics can do, but if you want to register 3D shapes (defined by closed surface or labelmap) then you can robustly compute the transform by registering the distance map images of the 3D shapes.

If you want to try it with a convenient GUI before implementing anything then you can use the SegmentRegistration extension in 3D Slicer. You can find the algorithm fully implemented in Python using ITK and VTK here.

1 Like

A useful point set registration example in Python can be found in the SlicerMorph extension.