ANTsX
ANTsPy
Python

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.

Last updated Jul 6, 2026
878
Stars
179
Forks
46
Issues
+2
Stars/day
Attention Score
69
Language breakdown
Python 69.7%
C++ 28.9%
Shell 0.5%
Batchfile 0.3%
CMake 0.3%
C 0.1%
โ–ธ Files click to expand
README

Advanced Normalization Tools in Python

PyPI version Conda downloads Nightly Build ci-pytest ci-docker Coverage Status docs Docker Pulls Downloads Contributor Covenant PubMed

The ANTsPy library wraps the well-established C++ biomedical image processing framework 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 medical imaging datasets, you might be interested in ANTsPyNet which provides tools for training and visualizing deep learning models.


Installation

Pre-compiled binaries

The easiest way to install ANTsPy is via the latest pre-compiled binaries from PyPI.

pip install antspyx
Or alternatively from conda:
conda install conda-forge::antspyx

Because of limited storage space, pip binaries are not available for every combination of python version and platform. We also have had to delete older releases to make space. If you cannot find a binary you need on PyPI, you can check the Releases page for archived binaries.

Some Mac OS Python installations have compatibility issues with the pre-compiled binaries. This means pip will not install binaries targeted for the current Mac OS version, and will instead try to compile from source. The compatibility checks can be disabled by setting the environment variable SYSTEMVERSIONCOMPAT=0. More details on the wiki.

Windows users will need a compatible Microsoft Visual C++ Redistributable installation.

Building from source

In some scenarios, it can make sense to build from source. In general, you can build ANTsPy as you would any other Python package.

git clone https://github.com/antsx/antspy
cd antspy
python -m pip install .

Further details about installing ANTsPy or building it from source can be found in the Installation Tutorial.


Quickstart

Here is a basic overview of some of the things you can do with ANTsPy. The main functionality includes reading / writing images, basic and advanced image operations, segmentation, registration, and visualization.

import ants

read / write images

img = ants.image_read('path/to/image.nii.gz') ants.image_write(img, 'path/to/image.nii.gz')

basic operations

img + img2 img - img2 img[:20,:20,:20] # indexing returns an image

advanced operations

img = ants.smooth_image(img, 2) img = ants.resample_image(img, (3,3,3)) img.smoothimage(2).resampleimage((3,3,3)) # chaining

convert to or from numpy

arr = img.numpy() img2 = ants.from_numpy(arr * 2)

segmentation

result = ants.atropos(a=img, m='[0.2,1x1]', c='[2,0]', i='kmeans[3]', x=ants.get_mask(img))

registration

result = ants.registration(fixedimage, movingimage, typeoftransform = 'SyN' )

plotting

ants.plot(img, overlay = img > img.mean())


Tutorials

Resources for learning about ANTsPy can be found in the tutorials folder. A selection of especially useful tutorials is presented below.

  • Basic overview [Link]
  • Composite registrations [Link]
  • Multi-metric registration [Link]
  • Image math operations [Link]
  • Wrapping ITK code [Link]
More tutorials can be found in the ANTs repository.


Contributing

If you have a question or bug report the best way to get help is by posting an issue on the GitHub page. We welcome any new contributions and ideas. If you want to add code, the best way to get started is by reading the contributors guide that runs through the structure of the project and how we go about wrapping ITK and ANTs code in C++.

You can support our work by starring the repository, citing our methods when relevant, or suggesting new features in the issues tab. These actions help increase the project's visibility and community reach.


References

The main references can be found at the main ANTs repo. A Google Scholar search also reveals plenty of explanation of methods and evaluation results by the community and by ourselves.

ยฉ 2026 GitRepoTrend ยท ANTsX/ANTsPy ยท Updated daily from GitHub