Registry / ai-ml / antspyx

antspyx

JSON →
library0.6.3pypypi✓ verified 84d ago

ANTsPy is a Python library for medical image analysis, providing algorithms for registration, segmentation, and visualization. Current version is 0.6.3, released in 2024. It wraps ANTs (Advanced Normalization Tools) and is actively maintained.

pip install antspyx
INSTALL
IMPORT
SIG · ANTSPYX
A
antspyx
ai-mlpythonv0.6.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ants
import ants
import antspy
The correct import is 'ants', not 'antspy' or 'antspyx'.
ANTsImage
from ants.core import ANTsImage
ANTsImage is the core image object.

Basic ANTsPy usage: image loading, registration, and segmentation.

import ants # Load an image image_path = ants.get_data('r16') img = ants.image_read(image_path) print(img.shape) # Registration example moving = ants.image_read(ants.get_data('r16')) fixed = ants.image_read(ants.get_data('r85')) registration = ants.registration(fixed, moving, type_of_transform='SyN') # Apply transformation warped = registration['warpedmovout'] # Segmentation seg = ants.atropos(a_image=img, mask=img > 0, number_of_phases=3) print(seg['segmentation'].unique())
Debug
Known issues
breakingIn antspyx 0.4+ the import path changed from 'antspy' to 'ants'. Old code using `import antspy` will fail.
fix
Change imports to `import ants`.
affects: >=0.4
gotchaantspyx is the PyPI package name, but the import is 'ants'. Many users mistakenly try to `import antspy` or `import antspyx`.
fix
Use `import ants`.
affects: all
deprecatedSome functions like `ants.segment()` have been deprecated in favor of `ants.atropos()` and `ants.kmeans_segmentation()`.
fix
Replace `ants.segment(...)` with `ants.atropos(...)` or `ants.kmeans_segmentation(...)`.
affects: >=0.5
gotchaImage reading expects a file path; passing a numpy array will fail silently or raise confusing errors. Use `ants.from_numpy()` to create an ANTsImage from a numpy array.
fix
Convert numpy array to ANTsImage with `ants = ants.from_numpy(numpy_array)` before processing.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'antspy'
Attempting to import 'antspy' after installing antspyx (which provides the 'ants' module).
fix
Use `import ants` instead of `import antspy`.
AttributeError: module 'ants' has no attribute 'image_new'
The function `image_new` was removed or renamed in newer versions.
fix
Use `ants.new_image_like()` or `ants.from_numpy()` to create an ANTsImage.
RuntimeError: Invalid image: array must have dimension in {2,3,4}
Passing a 1D or 5+nD numpy array to functions expecting an image.
fix
Ensure your numpy array is 2D (grayscale) or 3D (volumetric). For 4D, check the documentation.
Upgrade
Version history
0.6.3latest on PyPI · released Feb 24, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
32
OpenAI (training)
1
Resources
antspyx — pip install antspyx · libregistry