ITK Registrationv4 and PDEDeformableRegistration

Is it possible to use itk registration v4 algorithms such as SyN or Time Varying Velocity Field transforms in the ITKPython package. I installed the itk package and am doing something like this

primary_image_path = "fix.png"

reader = itk.ImageFileReader[itk.Image.SS2].New()
reader.SetFileName(primary_image_path)
reader.Update()
primary_image = reader.GetOutput()
secondary_image_path = "mov.png"
reader = itk.ImageFileReader[itk.Image.SS2].New()
reader.SetFileName(secondary_image_path)
reader.Update()
secondary_image = reader.GetOutput()
filt = itk.PDEDeformableRegistrationFilter[itk.Image.SS2, itk.Image.SS2, itk.Image.VF22].New()
filt.SetFixedImage(primary_image)
filt.SetMovingImage(secondary_image)
filt.Update()

This throws a runtime error


RuntimeError: /work/ITK-source/ITK/Modules/Registration/PDEDeformable/include/itkPDEDeformableRegistrationFilter.hxx:198:
ITK ERROR: PDEDeformableRegistrationFilter(0x558f99fafec0): FiniteDifferenceFunction not of type PDEDeformableRegistrationFilterFunction

Hi @Anurag_Ranjak ,

Welcome to the ITK community! :sun_with_face:

With this patch, the SyN image registration method will be available in itk-5.3rc3. If there are other itk registration v4 algorithm classes that you would like wrapped, please let us know.

Hey Matt

Thanks a lot for your work. It is going to be immensely useful for me. I will try to install it. I should build the python wheels for itk using this repository as the itk source right

I just merged that PR. If you don’t want to wait for pip-installable version which includes this, you can compile ITK yourself.

One way is by using itkpythonpackage.

The other is normal build with Python wrapping enabled, then symlink or copy C:\Dev\ITK-build\Wrapping\Generators\Python\WrapITK.pth into C:\Program Files\Python37\Lib\site-packages\WrapITK.pth (or equivalent).

Binary packages with wrapping for these classes will also be available in the upcoming itk-5.3rc3 release.