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

ENH: initialize ANTsImage with pointer only #634

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

ncullen93
Copy link
Member

Currently, you have to manually input a bunch of extra information when creating an ANTsImage internally from an ITK pointer, e.g.:

img = iio.ANTsImage(pixeltype='float', dimension=2, components=1, pointer=itk_image)

Information such as pixeltype, dimension, components, is_rgb, etc is not only redundant to what is contained in the pointer, it is also vulnerable to bugs because it is not coupled to the one source of truth (the pointer to the actual image). If someone input the wrong dimension.. it would not be caught.

This PR makes it so ANTsImage instances are created from only the pointer and all that extra info is extracted from the pointer. It is more robust and also makes it eventually easier to refactor the internal import system. The above line would be replaced with this:

img = iio2.from_pointer(itk_image)

All of the info is still available as usual - no changes there.

@coveralls
Copy link

Coverage Status

coverage: 80.907% (+0.07%) from 80.836%
when pulling 264c0ef on image-from-pointer
into 75f7392 on master.

@ncullen93 ncullen93 merged commit 447acce into master May 16, 2024
2 checks passed
@ncullen93 ncullen93 deleted the image-from-pointer branch May 16, 2024 15:41
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