Skip to main content

PyPI version Python versions License Discord

voxreg

Batched physical-space image registration with PyTorch and ConfUSIus VoxelData.

  • Translation, rigid, affine and symmetric nonlinear (SyN) registration.
  • Single image pairs or motion correction of recordings, on CPU or CUDA.
  • Independent fixed/moving grids, with original intensities and dtype retained.

Installation

Requires Python 3.11–3.14.

pip install voxreg

For development, from a source checkout:

git clone https://github.com/confusius-tools/voxreg.git
cd voxreg
uv sync

ConfUSIus provides the VoxelData model; registration itself runs in PyTorch. CUDA requires a compatible GPU and PyTorch installation.

Quick start

import confusius as cf
import voxreg

recording = cf.load("recording.nii.gz").compute()
result = voxreg.register(recording)

corrected = result.registered
valid = result.valid
print(result.diagnostics)

For a recording, the first frame is the default reference and is preserved exactly. For a single image pair, pass voxreg.register(moving, fixed). Select device="cuda" to use a GPU.

voxreg.register

result = voxreg.register(
    moving,
    fixed=None,
    transform="rigid",
    intensity_scaling="db",
    device="cpu",
    return_transforms=False,
)
Argument Purpose
moving, fixed NumPy-backed VoxelData in mm: (k, j, i) images or (time, k, j, i) recordings. fixed is spatial-only and required for a single image.
transform "translation", "rigid" (default), "affine" or "syn". Slices use k=1; volumes have at least two samples on each axis.
initialization Optional "center_geometry", "center_moments", "align_planes" or a fixed→moving world matrix. Defaults to identity.
intensity_scaling "db" (default) for nonnegative power, or "none" for already-prepared/signed data. Affects fitting only.
batch_size Maximum frames fitted together; automatic by default. Full returned images still occupy CPU memory.
max_iterations Per-frame update limit; default 100. Inspect diagnostics rather than assuming convergence.
device, progress "cpu" or "cuda"; progress defaults to "auto", or use False to silence it.
return_transforms Opt into forward and inverse maps: linear matrices or SyN displacement fields. Dense fields can be much larger than the images.

The result contains registered intensities and a boolean valid support mask on the fixed grid, plus diagnostics with per-frame status and objective. Inputs are not modified; output retains the moving dtype and time labels. Use valid to exclude out-of-bounds padding from analysis.

With return_transforms=True, forward_transforms are physical pulls: moving_world = matrix @ fixed_world, in z/y/x, mm. Linear models return matrices and their inverses; SyN returns complete forward displacements on the fixed grid and inverse displacements on the moving grid. Both attributes are None by default. transforms remains a compatibility alias for forward_transforms.

Pass original linear intensities when using center_moments; logarithms and other nonlinear preprocessing change its centroid weights. Noncoplanar slice pairs need compatible initialization. SyN does not support mixed slice/volume inputs; Dask-backed inputs and multiresolution fitting are not supported.

For all options, including optimizer controls and callbacks, use help(voxreg.register) or read the API docstring.

Apply transforms offline

voxreg.resample applies exported maps without fitting, on CPU or CUDA. For a spatial image pair:

result = voxreg.register(moving, fixed, return_transforms=True)
resampled, valid = voxreg.resample(moving, fixed, result.forward_transforms, device="cuda")
reverse, reverse_valid = voxreg.resample(fixed, moving, result.inverse_transforms, device="cuda")

The reference must be spatial-only; for a recording use a spatial frame as the reference. Displacement fields must match that grid exactly. Original dtype and time labels are retained; use interpolation="nearest" for labels or masks. See help(voxreg.resample) for broadcasting, batching and support conventions.

Development and benchmarks

uv run pytest
uv run prek run --all-files

# List configurations; see BENCHMARK.md before starting the full matrix.
uv run --extra examples python examples/benchmark_register.py --list
uv run --extra examples python examples/benchmark_resample.py --list

Metadata

Release files for voxreg 0.0.1

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

Source distribution (sdist)

Source distribution for voxreg 0.0.1
File Size Uploaded Provenance Actions
voxreg-0.0.1.tar.gz 49.6 kB Without provenance Details for voxreg-0.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 104.2 kB

Release files / voxreg-0.0.1.tar.gz

Download URL voxreg-0.0.1.tar.gz
Size 49.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6c15bf4d90cd02ea852b71b4f9dbe756d78ff82846c3f19471e0136c5fabb5a4
BLAKE2b-256 checksum
How to use checksums
b8920074f42c2a32eb8f27d3bc99ba6367a1e58a03e7598ea7f4731e9d7aedf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / voxreg-0.0.1-py3-none-any.whl

Download URL voxreg-0.0.1-py3-none-any.whl
Size 54.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb6e98a0259e65c6ba784d03ef8ed5b498d5951f022f39fe1b267034b603258c
BLAKE2b-256 checksum
How to use checksums
b19bd1631dbd93bdb961f94b4e1bd2a89199e181d1c3eda6dd106a33eda12a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for voxreg 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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