module 'SimpleITK' has no attribute 'GetDefaultParameterMap'

I tried to do image registration which worked well before but after a while, I will get this error with the same code that worked before. Please anyone know what is the problem and how to fix it?
Example of code:

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
fixed_image = A_image
moving_image = B_image
parameter_map = 'affine'
ResultArray, FixedArray, MovingArray, TransParameterMap = registration(fixed_image, moving_image, parameter_map)

# Generate registration images
registration_plot(ResultArray, FixedArray, MovingArray)

Hello @jdoungchawee,

The registration you are using is part of SimpleElastix. The official SimpleITK binaries do not include the SimplElastix components. To include those you will need to build SimpleITK from source (use the SuperBuild) and set the CMake SimpleITK_USE_ELASTIX flag to on.

The resulting binary will include the SimpleElastix components.

1 Like