visualization of fitted thin plate spline from vtkThinPlateSplineTransform

Hello, I’m currently using the vtkThinPlateSplineTransform to do data augmentation on a mesh of a heart in Python. I would like to visualize the Thin Plate Spline i have fitted to a set of source and target points such that i can view the applied distortion as a plotted function in 3D.
The code i have is currently is:

transform = vtk.vtkThinPlateSplineTransform()
transform.SetSourceLandmarks(p1)
transform.SetTargetLandmarks(p2)
transform.SetBasisToR2LogR()
transform.Update()
transform_filter = vtk.vtkTransformPolyDataFilter()
transform_filter.SetTransform(transform)
transform_filter.SetInputData(pd)
transform_filter.Update()

where p1 is the source points and p2 are the target points.

Is there any way i can exctract the fitted functions from the transform variable? Can i visualize the function with any VTK render functions or can i perhaps do it with matplotlib?
I’m a mere novice with this amazing software so doing simple things like this is not that easy.

Thanks,
Bjørn Hansen

One way to visualize a deformable transform is to draw a grid of vectors, with each vector showing the direction and magnitude of the deformation at a point on the grid.

A transform can be sampled to create a vector grid with vtkTransformToGrid. The vector grid can be visualized with e.g. vtkGlyph3DMapper. There are a couple missing steps that you would have to figure out (and don’t make the mistake of thinking it’s simple, because it definitely isn’t).

A lot of the visualization modes are implemented with a user interface in Slicer if you want to avoid writing the code yourself.

https://slicer.readthedocs.io/en/latest/user_guide/modules/transforms.html?highlight=transform#visualization-modes