# SetInitialDisplacementField not working properly for MultiResolutionPDEDeformableRegistration

**URL:** https://discourse.itk.org/t/setinitialdisplacementfield-not-working-properly-for-multiresolutionpdedeformableregistration/979
**Category:** Engineering
**Created:** [June 4, 2018, 7:40pm UTC](https://discourse.itk.org/t/setinitialdisplacementfield-not-working-properly-for-multiresolutionpdedeformableregistration/979 "2018-06-04T19:40:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![adjuric](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@adjuric](https://discourse.itk.org/u/adjuric)
#### Post date: [June 4, 2018, 7:40pm UTC](https://discourse.itk.org/t/setinitialdisplacementfield-not-working-properly-for-multiresolutionpdedeformableregistration/979/1 "2018-06-04T19:40:40Z")

</div>

I’m attempting to perform diffeomorphic demons registration of two images using the corresponding filter and the MultiResolutionPDEDeformableRegistration class. I compute an affine transform of the the two images beforehand to register them to the same physical space and create a displacement field using this transform. Then I use this field as the initial displacement field to the MultiResolutionPDEDeformableRegistration object. However, upon running the code I get the following error:

```
itk::ExceptionObject (0x1231130)
Location: "void itk::ImageToImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() [with TInputImage = itk::Image<itk::Vector<float, 3u>, 3u>; TOutputImage = itk::Image<itk::Vector<float, 3u>, 3u>]" 
File: /home/parallels/Desktop/Slicer-SuperBuild/ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx
Line: 241
Description: itk::ERROR: DiffeomorphicDemonsRegistrationFilter(0x13870b0): Inputs do not occupy the same physical space! 
InputImage Origin: [7.9639916e+01, -1.1042095e+02, -1.0426932e+02], InputImageMovingImage Origin: [-8.8678563e+01, -1.4923204e+02, 1.2193930e+02]
    Tolerance: 1.5000000e-05
InputImage Spacing: [1.5000000e+01, 1.5000000e+01, 1.9199951e+01], InputImageMovingImage Spacing: [1.5154560e+01, 1.5108180e+01, 1.9319538e+01]
    Tolerance: 1.5000000e-05
InputImage Direction: 1.5926319e-08 1.4070701e-08 -1.0000000e+00
9.9237583e-01 -1.2324859e-01 1.4070700e-08
1.2324859e-01 9.9237583e-01 1.5926320e-08
, InputImageMovingImage Direction: -0.0000000e+00 5.5205551e-10 1.0000000e+00
5.5205551e-10 1.0000000e+00 -5.5205553e-10
-1.0000000e+00 5.5205551e-10 0.0000000e+00

    Tolerance: 1.0000000e-06

```

I’ve figured out that the error arises because the affine transform is not being applied before the demons registration takes place. I double checked that this is true by commenting out the code where the initial displacement field is applied. I end up getting the exact same error. Additionally, when I apply the affine transform to the input before running the demons registration, it **works** error free.

I’m using the following [file](https://github.com/BIC-MNI/EZminc/blob/master/diff_demons/DemonsRegistration.cxx) as the base for the code I’m creating so it can act as a good approximate of what I’m trying to accomplish. Been working on this issue for a while and would really appreciate any advice.

---

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [June 5, 2019, 6:02am UTC](https://discourse.itk.org/t/setinitialdisplacementfield-not-working-properly-for-multiresolutionpdedeformableregistration/979/2 "2019-06-05T06:02:40Z")

</div>

Is this problem solved for you? Im working on the same code and got stuck at the same error.
