SimpleITK: demons registration filter requere the size of fixed/moving image to be the same

I want to use the demons registration method of SimpleITK between two images with different image size. For example, a 64X64X64 (moving image) and 128X128X128 (fixed image).

import SimpleITK as sitk
import numpy as np
fixedImg = sitk.GetImageFromArray(np.random.random(size=[128, 128, 128]))
movingImg = sitk.GetImageFromArray(np.random.random(size=[64, 64, 64]))
demons_filter = sitk.FastSymmetricForcesDemonsRegistrationFilter()
# Regularization (update field - viscous, total field - elastic).

displacement_field = demons_filter.Execute(fixedImg,

However, a bug is reported:

Traceback (most recent call last):
  File "C:/Users/MLoong/Desktop/medpro/Demo/", line 12, in <module>
  File "D:\Anaconda3\envs\gitlab_medpro\lib\site-packages\SimpleITK\", line 25809, in Execute
    return _SimpleITK.FastSymmetricForcesDemonsRegistrationFilter_Execute(self, *args)
RuntimeError: Exception thrown in SimpleITK FastSymmetricForcesDemonsRegistrationFilter_Execute: D:\a\1\sitk\Code\BasicFilters\src\sitkImageFilter.cxx:63:
sitk::ERROR: Input "movingImage" for "FastSymmetricForcesDemonsRegistrationFilter" has size of [ 64, 64, 64 ] which does not match the primary input's size of [ 128, 128, 128 ]!

Should I resample the moving image to be the same size of fixed image before demons_filter.Execute?

Hello @zhang-qiang-github,

Yes, you need to resample. Please see “Warning” in the FastSymmetricForcesDemonsRegistrationFilter documentation.