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: simpler imports, image decorator, and better code organization #637

Merged
merged 15 commits into from
May 18, 2024

Conversation

ncullen93
Copy link
Member

This PR signifcantly simplifies the import system, adds a clearer method for creating partial image functions (e.g., img.dosomething() instead of ants.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:

from ants.decorators import image_method

@image_method
def myfunc(image):
    return image + 2

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, the math folder is for any functions that take in an image and calculate some value, and the ops 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.

@coveralls
Copy link

coveralls commented May 17, 2024

Coverage Status

coverage: 81.148% (+0.2%) from 80.917%
when pulling 0a5bf5f on better-imports
into fe4fbbb on master.

@ncullen93 ncullen93 merged commit 3b5383e into master May 18, 2024
2 checks passed
@ncullen93 ncullen93 deleted the better-imports branch May 18, 2024 14:09
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.

2 participants