Hi,
I’m trying to save and load a transform but keep getting an error when I try to open it:
ITK ERROR: HDF5TransformIOTemplate(0x55708c136680): Could not create an instance of “MatrixOffsetTransformBase_double_3_3”
The usual cause of this error is not registering the transform with TransformFactory
Here is the relevant python code:
fixedImage = itk.imread('fixed_file.tif', itk.F)
movingImage = itk.imread('moving_file.tif', itk.F)
init_transform = itk.VersorRigid3DTransform[itk.D].New()
init_transform.SetIdentity()
transform_initializer = itk.CenteredVersorTransformInitializer[
type(fixedImage), type(movingImage)
].New()
transform_initializer.SetFixedImage(fixedImage)
transform_initializer.SetMovingImage(movingImage)
transform_initializer.SetTransform(init_transform)
transform_initializer.GeometryOn()
transform_initializer.ComputeRotationOff()
transform_initializer.InitializeTransform()
init_transform = init_transform.GetInverseTransform()
TRANSPATH = os.path.join(DATA, 'init-transform.h5')
itk.transformwrite([init_transform], TRANSPATH)
# saves the file
# now open in another program
saved_init_transform = itk.transformread(TRANSPATH)[0] # this causes the error