Skip to content

AnriiGegliuk/ANTsPy

 
 

Repository files navigation

Advanced Normalization Tools in Python

Coverage Status PyPI - Downloads Nightly Build ci-pytest ci-docker Docker Pulls Contributor Covenant PubMed


ANTsPy is a Python library which wraps the well-established C++ biomedical image processing library ANTs. It includes blazing-fast reading and writing of medical images, algorithms for registration, segmentation, and statistical learning, as well as functions to create publication-ready visualizations.

If you are looking to train deep learning models on your medical images, you might be interested in ANTsPyNet which provides tools for training and visualizing deep learning models. ANTsPy and ANTsPyNet seamlessly integrate with the greater Python community, particularly deep learning libraries, scikit-learn, and numpy.


Installation

We recommend that users install the latest pre-compiled binaries, which takes ~1 minute.

For MacOS and Linux:

pip install antspyx

Because of limited storage space, pip binaries are not available for every combination of python version and platform. Additionally, we are required to remove outdated wheels. If we do not have releases for your platform, you can check the Github Releases page or build from source with:

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.

Installing specific versions

We cannot store the entire history of releases because storage space on pip is limited. If you need an older release, you can check the Github Releases page or build from source. To install a specific version from source, you can try the following:

pip install 'antspyx @ git+https://github.com/ANTsX/[email protected]'

which will attempt to build from source (requires a machine with developer tools).

Recent wheels

Non-release commits have wheels built automatically, which are available for download for a limited period. Look under the Actions tab. Then click on the commit for the software version you want. Recent commits will have wheels stored as "artifacts".

Wheels are built locally like this:

rm -r -f build/ antspymm.egg-info/ dist/
python3 setup.py sdist bdist_wheel
pipx run twine upload dist/*

Docker images

Available on Docker Hub. To build ANTsPy docker images, see the (installation tutorial)(https://github.com/ANTsX/ANTsPy/blob/master/tutorials/InstallingANTsPy.md#docker-installation).



Quickstart

Here is an example of reading in an image, using various utility functions such as resampling and masking, then performing three-class Atropos segmentation.

from ants import atropos, get_ants_data, image_read, resample_image, get_mask
img   = image_read(get_ants_data("r16"))
img   = resample_image(img, (64,64), 1, 0 )
mask  = get_mask(img)
segs1 = 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


Other notes on compilation

In some cases, you may need some other libraries if they are not already installed eg if cmake says something about a missing png library or a missing Python.h file.

sudo apt-get install libblas-dev liblapack-dev
sudo apt-get install gfortran
sudo apt-get install libpng-dev
sudo apt-get install python3-dev  # for python3.x installs

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

Releases

No releases published

Packages

No packages published

Languages

  • Python 39.7%
  • Jupyter Notebook 37.9%
  • C++ 19.8%
  • Shell 0.9%
  • CMake 0.7%
  • PowerShell 0.4%
  • Other 0.6%