ENH: simpler imports, image decorator, and better code organization #637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR signifcantly simplifies the import system, adds a clearer method for creating partial image functions (e.g.,
img.dosomething()
instead ofants.dosomething(img)
), and organizes the code a bit more into semantic groups.For imports, all internal functions can now be used by calling
import ants
at the. top. This works because all functions are imported when ants is imported.Now, to make a function available as a partial method to the ANTsImage class you can do the following:
That will let you use this function as a chain on ANTsImage instances - e.g.,
image.myfunc()
.Finally, there is a bit more code organization with some additional folders added -- label, math, and ops. The
label
folder is for anything with label images, themath
folder is for any functions that take in an image and calculate some value, and theops
folder is for anything that takes in an image, manipulates it in some way, then returns an image.All in all, these changes simplify development and help both users and potential contributors to better conceptualize the package. The contributors document will also be updated.