# ITK Registrationv4 and PDEDeformableRegistration

**URL:** https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535
**Category:** Uncategorized
**Created:** [October 29, 2021, 12:14pm UTC](https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535 "2021-10-29T12:14:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Anurag\_Ranjak](https://discourse.itk.org/user_avatar/discourse.itk.org/anurag_ranjak/32/2343_2.png) [@Anurag\_Ranjak](https://discourse.itk.org/u/Anurag_Ranjak)
#### Post date: [October 29, 2021, 12:14pm UTC](https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535/1 "2021-10-29T12:14:49Z")

</div>

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

```auto
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

```auto

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

```

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [November 11, 2021, 12:16am UTC](https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535/2 "2021-11-11T00:16:08Z")

</div>

Hi @Anurag_Ranjak ,

Welcome to the ITK community! 🌞

With [this patch](https://github.com/InsightSoftwareConsortium/ITK/pull/1584), 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.

---

<div class="post-metadata">

### Author: ![Anurag\_Ranjak](https://discourse.itk.org/user_avatar/discourse.itk.org/anurag_ranjak/32/2343_2.png) [@Anurag\_Ranjak](https://discourse.itk.org/u/Anurag_Ranjak)
#### Post date: [November 11, 2021, 11:16am UTC](https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535/3 "2021-11-11T11:16:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [November 11, 2021, 2:25pm UTC](https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535/4 "2021-11-11T14:25:32Z")

</div>

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](https://itkpythonpackage.readthedocs.io/en/master/Build_ITK_Python_packages.html#build-a-wheel-for-a-custom-version-of-itk).

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).

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [November 12, 2021, 3:08pm UTC](https://discourse.itk.org/t/itk-registrationv4-and-pdedeformableregistration/4535/5 "2021-11-12T15:08:57Z")

</div>

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