Skip to main content

syntx

syntx is a high-performance Python package focusing on symmetric diffeomorphic (SyN) and affine image registration methods, built on top of PyTorch and JAX for GPU/MPS acceleration and auto-differentiation capabilities.

Ported from the registration modules of the sulceye package, syntx is designed for distribution on PyPI and works seamlessly with standard medical image types, particularly ANTsImage from the antspyx library.


⚠️ Disclaimer & Differences from ants.registration

[!IMPORTANT] Validation Status: The deep-learning feature-space similarity metrics (VGG19, DINOv2, Swin UNETR) in this repository are experimental and have not been deeply validated on large-scale clinical cohorts. They are intended strictly for research and exploration.

Key Differences from ants.registration:

  1. GPU Acceleration: Unlike standard ants.registration (which runs on CPU via ITK C++), Syntx supports PyTorch and JAX optimization backends for fast GPU/MPS execution.
  2. Optimizers: Syntx uses Adam/Rprop for the affine stage and greedy composition steps scaling by ITK-style CFL (Courant-Friedrichs-Lewy) max voxel displacement bounds, while ANTs relies on C++ variants of L-BFGS or regularized gradient descent.
  3. Velocity-Field & Elastic Smoothing: Separable Gaussian filters are implemented natively in JAX/PyTorch to perform fluid-like smoothing of update fields and elastic-like smoothing of composed fields, matching ITK's Gaussian regularization on the GPU.
  4. Multi-Resolution Pyramid: Downsampling is performed dynamically using bilinear/trilinear grid interpolation in PyTorch/JAX to build image pyramids, rather than ITK's C++ downsampling filters.
  5. Feature-Space Metrics: Similarity is evaluated on multi-scale feature representations (from vision transformers or CNNs) via zero-copy DLPack autograd sharing, rather than raw intensity maps.

Key Features

  • Auto-Differentiation Backends: Choose between 'pytorch' and 'jax' for core computations.
  • Symmetric Normalization (SyN): Fully symmetric greedy optimization matching classic ITK/ANTs SyN implementations.
  • Interoperability: Seamless conversions between PyTorch/JAX coordinate spaces and ITK physical coordinate matrices.
  • Direct PyPy/PyPI Packaging: Implemented cleanly with minimum external dependencies.

Installation

To install syntx locally from the repository:

pip install -e .

Dependencies

  • numpy
  • scipy
  • matplotlib
  • antspyx
  • torch
  • jax
  • jaxlib

Usage Example

syntx exposes a high-level syn and registration API that mirrors ants.registration:

import ants
import syntx

# Load ANTs images
fixed = ants.image_read( ants.get_data('r16') )
moving = ants.image_read( ants.get_data('r64')  )

# Run registration using PyTorch (default)
result = syntx.syn(
    fixed=fixed,
    moving=moving,
    type_of_transform='SyNTo',
    backend='pytorch',
    reg_iterations=[100, 100, 50],
    affine_iterations=[100, 50, 20],
)

# Access the warped moving output image
warped_moving = result['warpedmovout']

# Access transform files (saved to temporary paths for ANTs compatibility)
forward_transforms = result['fwdtransforms']
inverse_transforms = result['invtransforms']

For JAX backend acceleration:

result = syntx.syn(
    fixed=fixed,
    moving=moving,
    type_of_transform='SyNTo',
    backend='jax',
    reg_iterations=[100, 100, 50],
    affine_iterations=[100, 50, 20],
)

Running the Examples and Generating Reports

An example comparing classic ANTs, PyTorch, and JAX registration is included under examples/. It generates a comparison report summarizing Mutual Information, Jacobian Determinants (topological safety), and Execution Speed.

To run the comparison:

python examples/generate_ants_2d_comparison_report.py

This generates an HTML report under reports/ants_2d_syn_comparison.html.


Running Tests

Tests can be executed via pytest:

pytest

Makefile Automation

A Makefile is included to automate standard development tasks:

  • Install (install package in editable mode):
    make install
    
  • Test (run test suite in Fast mode, skipping slow 3D registrations, and printing a code coverage table):
    make test
    
  • Test All (run the full test suite including slow 3D registrations, with coverage):
    make test-all
    
  • Clean (remove build artifacts, cached directories, and temporary files):
    make clean
    
  • Release (clean, build sdist and wheel packages, and upload to PyPI using twine):
    make release
    

It automatically detects and prioritizes the active python virtual environment (VIRTUAL_ENV).

Release

make clean 
python -m build .
python -m twine upload --config-file ~/.pypirc dist/*

Metadata

Release files for syntx 0.1.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for syntx 0.1.25
File Size Uploaded
syntx-0.1.25.tar.gz 103.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for syntx 0.1.25
File Interpreter ABI Platform
syntx-0.1.25-py3-none-any.whl Python 3 none any Details

Total release size: 178.5 kB

Release files / syntx-0.1.25.tar.gz

Download URL syntx-0.1.25.tar.gz
Size 103.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3ac519a160d8be3ec9b583f769127d49a6771a83db287170abae44b189645209
BLAKE2b-256 checksum
How to use checksums
d98e1d66cf6eba24dfba5fa1a267b0ebcd6d62a169d8c94235843e902b99401a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / syntx-0.1.25-py3-none-any.whl

Download URL syntx-0.1.25-py3-none-any.whl
Size 74.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1b0fbb95001acb726d9389abbbc373a0fcca52e40491c27a13341bb144e737b
BLAKE2b-256 checksum
How to use checksums
2923a40d1e8f3e46227d113ef588c7148971c76b9cf6d11b944816aea22eb4e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

5.4.15

2 release files

5.1.0

2 release files

1.0.4

2 release files

1.0.1

2 release files

0.1.28

2 release files

This release

0.1.25 This release

2 release files

0.1.21

2 release files

0.1.19

2 release files

0.1.16

2 release files

0.1.8

2 release files

0.1.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page