Using LandmarkBasedTransformInitializer for BSpline registrations

Hi all,

I originally posted this question on SimpleITK’s GitHub issues page, but became reminded about the Discourse forum while watching a SITK tutorial (somehow I completely forgot that the forum exists!). I’m re-posting it here hoping to reach a wider audience (and hopefully someone who’s done this before and knows where I’m going wrong).

I am aware of sitk.BSplineTransformInitializer(image1, transformDomainMeshSize, order) for performing BSpline registrations, but I am trying to initialize the registration using LandmarkBasedTransformInitializer.

Following is how I attempt to obtain a landmark-based transform for a ‘rigid’, ‘affine’ or ‘bspline’ transforms:

def GetLandmarkTx(FixIm, MovIm, FixPts, MovPts, 
                  Transform='rigid', NumControlPts=8):
    import SimpleITK as sitk
    if Transform == 'rigid':
        SitkTransform = sitk.VersorRigid3DTransform()
    elif Transform == 'affine':
        SitkTransform = sitk.AffineTransform(FixIm.GetDimension())
    elif Transform == 'bspline':
        SitkTransform = sitk.BSplineTransform(FixIm.GetDimension())
        msg = "Transform must be either 'rigid', 'affine' or 'bspline'."
        raise Exception(msg)
    if Transform == 'bspline':
        LandmarkTx = sitk.LandmarkBasedTransformInitializer(transform=SitkTransform, 
        LandmarkTx = sitk.LandmarkBasedTransformInitializer(transform=SitkTransform, 

    return LandmarkTx

The above works fine for ‘rigid’ and ‘affine’, but the following error occurs for ‘bspline’:

Exception thrown in SimpleITK LandmarkBasedTransformInitializer: C:...itkMultiThreader.cxx:395:
itk::ERROR: MultiThreader: Exception occurred during SingleMethodExecute

Unfortunately I’ve not been able to find any examples that use LandmarkBasedTransformInitializer for non-rigid registrations, so I’m not sure if I’m taking the correct approach. Any advice would be much appreciated.