Bayalign
🛠️ work-in-progress 🛠️
Bayalign is a lightweight JAX-based library for rigid point cloud registration using efficient Bayesian inference via geodesic slice sampling on the sphere (GeoSSS) for inference. See the package geosss for details.
The package is tailored for any rigid registration problem (currently doesn't support translation estimation) and has mainly been motivated from a scientific application such as Cryo-EM where the goal is to estimate the rotation of a 3D structure that best aligns with noisy or partial 2D projections.
Features
- Supports 3D-2D and 3D-3D rigid registration
- GPU acceleration, Automatic differentiation via JAX
- Fast inference via GeoSSS
- Uses Gaussian Mixture Models (GMM) for scoring the rigid poses
Installation
pip install bayalign
Quickstart
A basic example of 3D-to-2D registration:
import jax.numpy as jnp
from bayalign.pointcloud import PointCloud, RotationProjection
from bayalign.score import GaussianMixtureModel
from bayalign.inference import ShrinkageSphericalSliceSampler
from bayalign.sphere_utils import sample_sphere
# Define 2D target and 3D source point clouds
target_2d = PointCloud(positions, weights) # shape (N, 2)
source_3d = RotationProjection(positions, weights) # shape (M, 3)
# Define a target probability model using GMM
target_pdf = GaussianMixtureModel(target_2d, source_3d, sigma=1.0, k=20)
# Sample from the posterior over 3D rotations (quaternions)
init_q = sample_sphere(random.key(645), d=3) # initial quaternion (4,)
sampler = ShrinkageSphericalSliceSampler(target_pdf, init_q, seed=123)
samples = sampler.sample(n_samples=100, burnin=0.2)
# Find the best rotation
log_probs = jnp.asarray([target_pdf.log_prob(q) for q in samples])
best_rot = samples[jnp.argmax(log_probs)]
transformed_source = source.transform_positions(best_rot)
For 3D-3D registration, use PointCloud for both target and source. Check out the examples directory for detailed use cases using synthetic and cryo-EM data.
To run the examples, you need to install some optional dependencies. Follow one of the methods below to set up your environment.
Development
Clone the repository and navigate to the root.
git clone https://github.com/ShantanuKodgirwar/bayalign.git
cd bayalign
Option 1: Using uv (recommended!)
The package bayalign and all its locked dependencies are maintained by uv and can be installed within a virtual environment as:
uv sync --extra all
Option 2: Using pip
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip install -e . --no-deps
Issues
If you encounter any problems, have questions, please feel free to open an issue.
Metadata
Release files for bayalign 0.1.2
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 |
|---|---|---|---|---|
| bayalign-0.1.2.tar.gz | 23.7 kB | Without provenance | Details for bayalign-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bayalign-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for bayalign-0.1.2-py3-none-any.whl |
Total release size: 46.2 kB
Release files / bayalign-0.1.2.tar.gz
| Download URL | bayalign-0.1.2.tar.gz |
|---|---|
| Size | 23.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df3312856e954117bc62f28dcd79c30efd0b13e3a0739673de7b49f848e98a56
|
|
BLAKE2b-256 checksum How to use checksums |
d80dd238f2f528ce5797efb0e63c542dc8c8534b0f106ba37d955923af02c3c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / bayalign-0.1.2-py3-none-any.whl
| Download URL | bayalign-0.1.2-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c22a860a4240940ca1ac587b7c818ae2f331e0c52dcdc9e831cf3e17804c717
|
|
BLAKE2b-256 checksum How to use checksums |
3150f418f93989b31c741ecd52c79551d6659df70ae069a9c166c5ad219b765c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for bayalign 0.1.2
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.