I’m working on trying to extend the antsTransformInfo tool to print the Determinant of a transform if its Linear as part of its summary information.
The existing implementation is very very simple, a copy of an ITK example:
The transform IO seems to not need to know anything about the transform, not the dimension, nor the type, and immediately supports all the ITK transform types, and can print a summary.
I implemented a partial version for linear transforms, and I’ve already had to instantiate 2D and 3D handlers separately, and this doesn’t support unpacking a composite transform at the least, and probably has other corner cases where it will fall over.
Am I going about this the wrong way? Is there a better way? I want this to support reading arbitrary ITK transforms and print the summary object, and if it’s Linear, add the Determinant.
Or, is the better solution to add the Determinant to all Linear transform summaries in ITK?
using ReadCompositeTransformType =
itk::CompositeTransform<ReadScalarType, Dimension>;
auto it = transforms->begin();
if (!strcmp((*it)->GetNameOfClass(), "CompositeTransform"))
{
ReadCompositeTransformType::Pointer compositeRead =
static_cast<ReadCompositeTransformType *>((*it).GetPointer());
compositeRead->Print(std::cout);
}
Thanks everyone. I’ve managed to successfully handle affine vs composite transforms, however, I can’t find a way to “unpack” a composite transform.
I expected it to also be a GetTransformList but that doesn’t seem to be the case.
Is there a way to get an iterator for a CompositeTransform like I do for a list?
const TransformReaderType::TransformListType * transforms = reader->GetTransformList();
for (auto it = transforms->begin(); it != transforms->end(); ++it)
See a full composite transform reader implementation in 3D Slicer here:
It builds a VTK transformation pipeline from the ITK transform file that can be directly used for visualization (displaying warped images, meshes, segmentations, annotations, etc.).