i’m trying to transform 3D points using inverse displacement field of Bspline transformation.
after calculating the transformation i’m creating the inverse as suggested here : Inverse of BSpline transform
this is my code:
disp_filter = sitk.TransformToDisplacementFieldFilter()
disp_img = disp_filter.Execute(outx)
inv_disp_filter = sitk.InverseDisplacementFieldImageFilter()
inv_disp_img = inv_disp_filter.Execute(disp_img)
return sitk.DisplacementFieldTransform(inv_disp_img), disp_img
however, when trying to use TransformPoint nothing happens (point is not transformed). the points are inside the Domain. what am i doing wrong?
The problem is due to missing settings for the
disp_filter which is using defaults.
To create a displacement field from a transformation we need to define its physical bounds (origin, size, spacing, direction cosine matrix). This is because the transformation can be a global/unbounded transformation and a displacement field is bounded. When this isn’t done explicitly default values are used (to see this add
print(disp_img.GetSize() to your code).
Modify the code to something like this:
sitk.TransformToDisplacementField(outx, outputPixelType=sitk.sitkVectorFloat64, size=output_size, outputOrigin=outx.GetTransformDomainOrigin(), outputSpacing=output_spacing, outputDirection=outx.GetTransformDomainDirection())
For additional details on inverting bounded transforms see the Transforms jupyter notebook. Highly recommend skimming the SimpleITK notebooks repository to see the various examples. If you have the time, it is also worth going over the online tutorial.
thank you very much for the quick answer!