Import of ITK transform file failed

Hi,

I am trying to import an affine transform that was computed with ANTs. I cannot attach the transform file, but it is a simple textfile with a .txt file ending. You can reproduce the error by copy&pasting the contents below into a transform.txt file and loading it into Slicer. On my system, the file was first interpreted as a “Color” file in the file loading dialog. After changing the file type to “Transform”, the error message is:

Could not create an instance of “MatrixOffsetTransformBase_double_3_3”
The usual cause of this error is not registering the transform with TransformFactory

The funny thing is that I can usually load transforms (linear and non-linear) that were generated by ANTs. Not sure why this suddenly does not work anymore (by the way, I tried Slicer 4.9.0 and the 4.11.0 nightly from 2019-06-02). Any help with this is appreciated!
Here are the contents of the transform file:

#Insight Transform File V1.0
#Transform 0
Transform: MatrixOffsetTransformBase_double_3_3
Parameters: 1.0133883914175723 -0.007097997510931725 0.010305303746152204 0.006178933359632762 1.040581088926752 -0.05537898237481463 -0.01029277753621562 0.041969790000422336 0.9962926407286504 0.25692648074325647 0.26014893150818796 -0.08923845189838553
FixedParameters: 0.34716075829563664 0.4464191942953437 -0.7178585998314816

Cheers,
Ahmad

Can you load the file if you save it in .h5 file format? Or, if you convert the transform to AffineTransform_double_3_3 before saving it?

Hi Andras,
thx for the quick response.
If I change the “Transform” tag in the txt file to “AffineTransform_double_3_3”, it correctly load the transform. The problem is that this txt file is part of the output from ANTs template building. I could manually correct this tag in all the files (e.g. with a script), but in the past, these files were loaded without error. In fact, I remember that I had this error before, and back then, it was identified as a bug and it was fixed.
Would you recommend me to change this tag in all files?

MatrixOffsetTransformBase is not registered in the ITK transform factory.

By executing these factory registrations, we could make MatrixOffsetTransformBase transform load:

itk::TransformFactory< itk::MatrixOffsetTransformBase<float, 3> >::RegisterTransform();
itk::TransformFactory< itk::MatrixOffsetTransformBase<double, 3> >::RegisterTransform();

However, I’m not sure that registering transform factory for this base class is the right thing to do. Probably it was not left out from itkTransformFactoryBaseRegister by accident, but because it is not supposed to be instantiated. Could you please clarify with ANTs/ITK developers why the transform is written to file as MatrixOffsetTransformBase instead of some concrete child class?

Thanks a lot :slight_smile: I will post my problem and your question in the ANTs forum.
For future reference and others who might be having this problem: Following your suggestion, I searched the ANTs forum for the MatrixOffsetTransformBase tag, and found this thread. It pointed me to a utility program I didn’t know about before, “ConvertTransformFile”. It can convert the .txt file to an affine .mat transform, by using the flag --convertToAffineType. Citing the documentation, “this is useful for using transforms in programs that do not register all available Transform factory types”. After conversion, Slicer loads the transform file.
Thanks again for the help!

If MatrixOffsetTransformBase is a valid choice then it should be added to the list of transforms registered by ITK by default. If ITK developers think that it is not appropriate to write this base class to file then ANTS should be changed to write it as affine (or other concrete transform class that is registered by ITK by default).