ANTsPy Repo Skill
Use this repo skill when a task involves the Python package distributed as antspyx and imported as ants: medical image IO, ANTsImage objects, preprocessing, registration, transforms, segmentation, labels, plotting, interoperability, or ANTsPy learning/deeplearn helper utilities.
Start Here
- Install the package with
pip install antspyxorconda install conda-forge::antspyx. - Verify the public import with
python -c "import ants; print(ants.__name__)". - Run scripts/antspy_environment_check.py for a tiny import/API smoke check.
- Read references/package-overview.md for package scope, compiled-backend caveats, and workflow boundaries.
- Read references/troubleshooting.md when installation, import, compiled libraries, physical-space metadata, optional dependencies, or expensive algorithms fail.
- Check references/repo-provenance.md before deciding whether this skill is stale for a newer ANTsPy checkout.
Route by Task
| User task | Read |
| --- | --- |
| Create, read, write, clone, index, compare, or validate ants.ANTsImage objects and physical metadata | image-core |
| Smooth, denoise, mask, crop, pad, slice, resample, threshold, run iMath, compute image metrics, or use morphology | image-ops-math |
| Register images, apply transforms to images or points, inspect transform files, build templates, run motion correction, or compute Jacobians | registration-transforms |
| Run Atropos, k-means, Otsu, priors, joint label fusion, label stats, overlap, geometry, label matrices, centroids, or point images | segmentation-labels |
| Save plots headlessly, build overlays/grids/movies, handle RGB/vector channels, convert image lists/matrices, or interoperate with nibabel/SimpleITK | visualization-interop |
| Use sparse/eigen learning helpers, patch extraction/reconstruction, one-hot labels, random augmentation, simulated bias fields, or learning-oriented crop/pad helpers | learning-deeplearn |
Cross-Cutting Rules
- Import with
import ants; do not importantspyxas a module. - ANTsPy wraps compiled ANTs/ITK code. A successful
pip installis not enough if importingantsfails; run the environment check script before debugging workflow code. ANTsImagevalues and physical metadata are both important. Validateshape,dimension,origin,spacing, anddirectionbefore mixing images, masks, labels, transforms, overlays, or matrices.- Use label-safe interpolation such as
nearestNeighbororgenericLabelfor labels and masks. Use linear-style interpolation for intensity images unless the workflow requires otherwise. - Prefer small synthetic images for smoke checks and troubleshooting. Full nonlinear registration, joint label fusion, high-resolution 3-D operations, and template building can be expensive.
- Keep ANTsPyNet, neural-network model training, and application-specific medical pipelines outside this skill unless the task only uses ANTsPy helper utilities.
Shared References and Scripts
- Package overview: package identity, public workflow map, data model, optional dependencies, and version caveats.
- API index: quick map from common
ants.*functions to the owning sub-skill and detailed reference. - Troubleshooting: install/import failures, wheel/source-build problems, shadowed imports, physical-space errors, optional dependencies, and expensive workflow triage.
- Repo provenance: source commit, dirty-state baseline, package versions, and evidence paths used for this generated skill.
- Routing metadata: structured scenario metadata consumed by the managed
repo-skills-routerduring import. - Environment check: tiny import/API smoke check for
antspyx. - Smoke suite: runs the bundled sub-skill smoke scripts with the current Python interpreter.