Multi-resolution registration

I am very new to python and the use of SimpleITK. I have tried to construct python code to register 2 image modalities that have different spatial resolutions. I could not perform registration between 2 images if one of the image has a higher resolution, but I could perform the registration only when I downgraded the higher resolution image to be at very similar resolution). (I used the exact same code for both cases). Here I also showed some of my code that I tried to construct.

def registration(fixed_image, moving_image, parameter_map):

FixedImage = sitk.GetImageFromArray(fixed_image)
MovingImage = sitk.GetImageFromArray(moving_image)

ParameterMap = sitk.GetDefaultParameterMap(parameter_map)

elastixImageFilter = sitk.ElastixImageFilter()

ResultImage = elastixImageFilter.GetResultImage()
TransParameterMap = elastixImageFilter.GetTransformParameterMap()

ResultArray = sitk.GetArrayFromImage(ResultImage)
FixedArray = sitk.GetArrayFromImage(FixedImage)
MovingArray = sitk.GetArrayFromImage(MovingImage)

return ResultArray, FixedArray, MovingArray, TransParameterMap

def registration_plot(ResultArray, FixedArray, MovingArray):

ResultArrayNorm = ResultArray/np.amax(ResultArray)
FixedArrayNorm = FixedArray/np.amax(FixedArray)
MovingArrayNorm = MovingArray/np.amax(MovingArray)

ax = plt.subplot(1, 5, 1)
plt.imshow(FixedArray, cmap='Blues')
plt.title('Fixed Image')
ax = plt.subplot(1, 5, 2)
plt.imshow(MovingArray, cmap='Reds')
plt.title('Moving Image')
ax = plt.subplot(1, 5, 3)
plt.imshow(ResultArray, cmap='Reds')
plt.title('Result Image')
ax = plt.subplot(1, 5, 4)
plt.imshow(FixedArrayNorm, cmap='Blues', alpha=0.8)
plt.imshow(MovingArrayNorm, cmap='Reds', alpha=0.4)
plt.title('Before optimization')
ax = plt.subplot(1, 5, 5)
plt.imshow(FixedArrayNorm, cmap='Blues', alpha=0.8)
plt.imshow(ResultArrayNorm, cmap='Reds', alpha=0.4)
plt.title ('After optimization')

Before performing the registration, I had to resize (downgrade) the resolution of the image first, even though I could not run the code, and it said some error as shown below.

RuntimeError: Exception thrown in SimpleITK ElastixImageFilter_Execute: C:\dafne\SimpleElastix\Code\Elastix\src\sitkElastixImageFilterImpl.cxx:259:
itk::ExceptionObject (000000F2E75E78B0)
Location: “unknown”
File: c:\dafne\simpleelastix\build3.9\elastix\core\main\elxElastixFilter.hxx
Line: 253
Description: itk::ERROR: ElastixFilter(00000240605747B0): Internal elastix error: See elastix log (use LogToConsoleOn() or LogToFileOn()).

Please anyone help me to figure this out how I can perform multiresolution registration.
Thank you very much

Hello @maxtj,

The reason you are struggling to register images with different spacing is that the code above does not contain that information as part of the input to the registration function. The function is receiving numpy arrays and not SimpleITK images. The fixed_image and moving_image should be SimpleITK images which were read from disk. You pass these to the elastixImageFilter.

Please familiarize yourself with the fundamental concepts of ITK/SimpleITK before continuing with your work. Possibly read the registration overview, though you are using the SimpleElastix registration and not the ITK/SimpleITK registration framework. The basic concepts are similar, so if you understand the basic ITK/SimpleITK framework it will be easier for you to understand the SimpleElastix framework.