Hi message board,
I’ve got some code running in SimpleITK v4.13.1 that I would like to make compatible with SimpleITK 5.1.1. (This is old code that I’m updating to run with Ubuntu 20.0 and the default SimpleITK version that comes from the package repositories). The code is registering a 2D image (fixed) to a 3D volume (moving) with the multilevel algorithm. The size of the images is: fixed - (178, 164, 1), moving - (147, 133, 138)
Here’s the snippet:
#Create a registration method, fixed and moving are the eventual input images
registration_method = sitk.ImageRegistrationMethod()
# Set the initial transform
initial_transform = sitk.VersorRigid3DTransform()
moving_sitkTmp = fixed
initial_transform = sitk.CenteredTransformInitializer(
fixed,
moving_sitkTmp,
initial_transform,
sitk.CenteredTransformInitializerFilter.GEOMETRY
)
registration_method.SetInitialTransform( initial_transform, inPlace=True)
#Set masks
# Recasting avoids problems which can occur for some images
registration_method.SetMetricMovingMask( sitk.Cast(moving_mask, fixed_mask.GetPixelIDValue()) )
registration_method.SetMetricFixedMask(fixed_mask)
# Settings
registration_method.SetInterpolator(sitk.sitkLinear)
registration_method.SetMetricAsCorrelation()
registration_method.SetOptimizerAsConjugateGradientLineSearch( learningRate = 1, numberOfIterations = 100, lineSearchUpperLimit= 2)
registration_method.SetOptimizerScalesFromJacobian()
registration_method.SetShrinkFactorsPerLevel(shrinkFactors=np.array([3,2,1]))
registration_method.SetSmoothingSigmasPerLevel( smoothingSigmas=np.array([1.5,1.0,0.0]))
registration_method.SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()
registration_transform_sitk = registration_method.Execute( fixed, moving)
The relevant error message when I call the execute method is:
RuntimeError: Exception thrown in SimpleITK ImageRegistrationMethod_Execute: /tmp/SimpleITK-build/ITK-prefix/include/ITK-5.1/itkSmoothingRecursiveGaussianImageFilter.hxx:217:
itk::ERROR: itk::ERROR: SmoothingRecursiveGaussianImageFilter(0x6411d750): The number of pixels along dimension 2 is less than 4. This filter requires a minimum of four pixels along the dimension to be processed.
I think in 4.13 there was no attempt to smooth along dimension 2 but in 5.1 there is now an attempt at smoothing along dimension 2 but not enough pixels in my fixed image.