Skip to content
forked from ANTsX/ANTsPy

Advanced Normalization Tools in Python

License

Notifications You must be signed in to change notification settings

tongji-cdi/ANTsPy

 
 

Repository files navigation

Advanced Normalization Tools in Python

img

CircleCI Build Status Coverage Status Documentation Status

Contributor Covenant Binder

About ANTsPy

Search ANTsPy documentation at read the docs.

ANTsPy is a Python library which wraps the C++ biomedical image processing library ANTs, matches much of the statistical capabilities of ANTsR, and allows seamless integration with numpy, scikit-learn, and the greater Python community.

ANTsPy includes blazing-fast IO (~40% faster than nibabel for loading Nifti images and converting them to numpy arrays), registration, segmentation, statistical learning, visualization, and other useful utility functions.

ANTsPy also provides a low-barrier opportunity for users to quickly wrap their ITK (or general C++) code in Python without having to build an entire IO/plotting/wrapping code base from scratch - see C++ Wrap Guide for a succinct tutorial.

If you want to contribute to ANTsPy or simply want to learn about the package architecture and wrapping process, please read the extensive contributors guide.

If you have any questions or feature requests, feel free to open an issue or email Nick (ncullen at pennmedicine dot upenn dot edu).

Installation

We recommend that users install the latest pre-compiled binaries, which takes ~1 minute. Note that ANTsPy is not currently tested for Python 2.7 support. Copy the following command and paste it into your bash terminal:

For MacOS and Linux:

pip install antspyx

If we do not have releases for your platform, then use:

git clone https://github.com/ANTsX/ANTsPy
cd ANTsPy
python3 setup.py install

if you want more detailed instructions on compiling ANTsPy from source, you can read the installation tutorial.

NOTE: we are hoping to relatively soon release windows wheels via pip. If they are not yet available, please check the discussion in the issues for how to build from source on windows machines.


ANTsR Comparison

Here is a quick example to show the similarity with ANTsR:

ANTsR code:

library(ANTsR)
img   <- antsImageRead(getANTsRData("r16"))
img   <- resampleImage(img, c(64,64), 1, 0 )
mask  <- getMask(img)
segs1 <- atropos(a=img, m='[0.2,1x1]', c='[2,0]', i='kmeans[3]', x=mask )

ANTsPy code:

import ants
img   = ants.image_read(ants.get_ants_data("r16"))
img   = ants.resample_image(img, (64,64), 1, 0 )
mask  = ants.get_mask(img)
segs1 = ants.atropos(a=img, m='[0.2,1x1]', c='[2,0]', i='kmeans[3]', x=mask )

Tutorials

We provide numerous tutorials for new users: https://github.com/ANTsX/ANTsPy/tree/master/tutorials

5 minute Overview

Nibabel Speed Comparison

Composite registrations

Build documentation

cd docs
sphinx-apidoc -o source/ ../
make html

References

  1. See references at the main ANTs page.

  2. Google scholar search reveals plenty of explanation of methods and evaluation results by ourselves

  3. ANTs evaluation and comparison by other authors

About

Advanced Normalization Tools in Python

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 40.7%
  • Jupyter Notebook 37.6%
  • C++ 19.5%
  • Shell 0.9%
  • CMake 0.6%
  • PowerShell 0.4%
  • Other 0.3%