Metadata for ANTs transform objects
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aind_ants_transform_sidecar-0.1.0.tar.gz.
File metadata
- Download URL: aind_ants_transform_sidecar-0.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e84b88c855044b816e5912d9d160887e796454a9b0b8931fd4b96bb56215228d
|
|
| MD5 |
8508068248580bfa45e6eff2d7d19e4b
|
|
| BLAKE2b-256 |
214caa2b8164afb43a79aa176f2f3c055ce4ec5821833a09c63261f66c6e1d7a
|
File details
Details for the file aind_ants_transform_sidecar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aind_ants_transform_sidecar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07a4123fbc740f08dbff569ea7bb936eec79153721b72ff0b5ab778213ee84a9
|
|
| MD5 |
1a5e4627199ff11a5f3ec34e17a5ea32
|
|
| BLAKE2b-256 |
7716536e004cfd2f939edc15078a2c0a1dbf1e17f3d3d63198f809131090229a
|