Closed gdevenyi closed 5 months ago
Once the transform is read, I think you can call GetInputSpaceDimension()
on it to determine the dimensionality
The program as written is not restricted to affine transforms, it will read any supported transform file. Assuming affine transforms would actually restrict its functionality.
Maybe the determinant computation would be better added to iMath or something?
The program as written is not restricted to affine transforms,
Can you give an example? I tried this on Warpfields and it falls over, I don't know of any other transform types which couldn't be cast to an affine...
If you run antsRegistration
with --output-composite-transform
, it will read the resulting transform file.
Got it.
Looks like I need to read all transforms as composite transforms and then figure out how to unpack it back into a list and loop over the unpacked components, checking the type.
From the discourse, seems like dynamic casting to MatrixOffsetTransformBase would be sufficient. If that's not null, you can call GetMatrix() on the result
This now will unpack transform lists as well as CompositeTransforms and print the determinant in addition to the PrintSelf for every transform in the whole stack.
Thanks - I'm going to be out of the office, so might be some time before I get to this
Context of this work is I use affine determinants in steps of https://github.com/CoBrALab/optimized_antsMultivariateTemplateConstruction
And currently I have to do this by using antsApplyTransforms to produce a warp field from the affine and then a Jacobian file from that. This will allow me to just compute the the jacobian determinant with antsTransformInfo and extract it from the text output.
I didn't verify the determinant values but it appears to work with the supported transform types
Thanks for this @gdevenyi
I have tested the output values using MINC affine transforms, where the I can generate arbitrary transforms with param2xfm
(giving a known determinant) and then compute the determinant using both MINC tools and antsTransformInfo :+1:
I'd like to be able to easily extract the determinant of affine transforms and antsTransformInfo seems like the right place.
The function has been refactored to handle reading errors.
Based primarily off https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/IO/TransformReadWrite.cxx
Things that aren't done: