AIND ANTs Transform Sidecar
Metadata for ANTs transform objects
Overview
This package provides metadata "sidecars" for ANTs (Advanced Normalization Tools) transform objects. ANTs produces spatial transformations (affine matrices and displacement fields) for medical image registration, but the transform files alone don't document important context like:
- The spatial domains (bounding boxes, spacing, voxel dimensions) of the fixed and moving images
- The coordinate system and units being used
- How to correctly chain and apply multiple transformation steps
This package provides Pydantic models that bundle ANTs transform file paths with their spatial metadata, enabling:
- Easy domain comparison: Hash functions make it simple to verify domains match
- Documentation: Clear specification of coordinate frames (LPS), units (mm), and domain definitions
- Interoperability: Standardized JSON format for sharing transformation metadata
- Convenience: Easy conversion to ANTsPy function arguments for applying transforms
Installation
If you choose to clone the repository, you can install the package by running the following command from the root directory of the repository:
pip install .
Otherwise, you can use pip:
pip install aind-ants-transform-sidecar
Usage
from aind_ants_transform_sidecar import (
TransformSidecarV1,
Domain,
BBox,
SynTriplet,
load_package,
dump_package,
)
# Define spatial domains for fixed and moving images
fixed_domain = Domain(
spacing_LPS=(0.5, 0.5, 0.5),
bbox=BBox(L=(-50.0, 50.0), P=(-50.0, 50.0), S=(-50.0, 50.0)),
shape_canonical=(200, 200, 200),
)
moving_domain = Domain(
spacing_LPS=(0.5, 0.5, 0.5),
bbox=BBox(L=(-50.0, 50.0), P=(-50.0, 50.0), S=(-50.0, 50.0)),
shape_canonical=(200, 200, 200),
)
# Create sidecar for ANTs SyN registration output
sidecar = TransformSidecarV1(
fixed_domain=fixed_domain,
moving_domain=moving_domain,
transform=SynTriplet(
affine="0GenericAffine.mat",
warp="1Warp.nii.gz",
inverse_warp="1InverseWarp.nii.gz",
),
)
# Serialize to JSON
json_str = dump_package(sidecar)
# Load from JSON
loaded = load_package(json_str)
# Get transformation chains
forward_chain = loaded.forward_chain() # moving → fixed
inverse_chain = loaded.inverse_chain() # fixed → moving
# Convert to ANTsPy arguments
transforms, whichtoinvert = forward_chain.antspy_apply_transforms_args()
Development
To develop the code, run:
uv sync
Development
Please test your changes using the full linting and testing suite:
./scripts/run_linters_and_checks.sh -c
Or run individual commands:
uv run --frozen ruff format # Code formatting
uv run --frozen ruff check # Linting
uv run --frozen mypy # Type checking
uv run --frozen interrogate -v # Documentation coverage
uv run --frozen codespell --check-filenames # Spell checking
uv run --frozen pytest --cov # Tests with coverage
Documentation
sphinx-build -b html docs/source/ docs/build/html
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for aind-ants-transform-sidecar 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aind_ants_transform_sidecar-0.1.0.tar.gz | 17.4 kB | Without provenance | Details for aind_ants_transform_sidecar-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aind_ants_transform_sidecar-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for aind_ants_transform_sidecar-0.1.0-py3-none-any.whl |
Total release size: 26.0 kB
Release files / aind_ants_transform_sidecar-0.1.0.tar.gz
| Download URL | aind_ants_transform_sidecar-0.1.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e84b88c855044b816e5912d9d160887e796454a9b0b8931fd4b96bb56215228d
|
|
BLAKE2b-256 checksum How to use checksums |
214caa2b8164afb43a79aa176f2f3c055ce4ec5821833a09c63261f66c6e1d7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.24
|
Release files / aind_ants_transform_sidecar-0.1.0-py3-none-any.whl
| Download URL | aind_ants_transform_sidecar-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07a4123fbc740f08dbff569ea7bb936eec79153721b72ff0b5ab778213ee84a9
|
|
BLAKE2b-256 checksum How to use checksums |
7716536e004cfd2f939edc15078a2c0a1dbf1e17f3d3d63198f809131090229a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.24
|
Security for aind-ants-transform-sidecar 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.