Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor antsTransformInfo to add some error handling and compute determinant #1712

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gdevenyi
Copy link
Contributor

@gdevenyi gdevenyi commented Apr 2, 2024

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:

  • I don't know how to automatically handle the 2D vs 3D transforms. The previous simple read/print code didn't seem to need it whereas this version does.

@cookpa
Copy link
Member

cookpa commented Apr 2, 2024

Once the transform is read, I think you can call GetInputSpaceDimension() on it to determine the dimensionality

@cookpa
Copy link
Member

cookpa commented Apr 2, 2024

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?

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Apr 2, 2024

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...

@cookpa
Copy link
Member

cookpa commented Apr 2, 2024

If you run antsRegistration with --output-composite-transform, it will read the resulting transform file.

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Apr 2, 2024

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.

@cookpa
Copy link
Member

cookpa commented Apr 17, 2024

From the discourse, seems like dynamic casting to MatrixOffsetTransformBase would be sufficient. If that's not null, you can call GetMatrix() on the result

@gdevenyi
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants