# biocpd
Coherent Point Drift (CPD) registration in pure NumPy/SciPy with fast variants:
- Rigid and Affine CPD
- Deformable CPD with low-rank (randomized SVD) and k-d tree accelerated E-step
- Constrained Deformable CPD with correspondence priors
- Atlas/SSM-based CPD (`AtlasRegistration`) optimized in coefficient space
## Why biocpd?
- Fast: sparse k-NN E-step, low-rank kernels, and efficient linear solvers
- Flexible: rigid, affine, unconstrained and constrained deformable, and SSM/atlas-based
- Simple: pure NumPy/SciPy implementation; easy to read and extend
## Install
```bash
pip install -r requirements.txt
# optional (recommended for building)
pip install build wheel
```
## Build wheel
```bash
# From repository root
python -m build
# or legacy
python setup.py sdist bdist_wheel
```
## Quickstart
```python
import numpy as np
from biocpd import RigidRegistration, AffineRegistration, DeformableRegistration, ConstrainedDeformableRegistration, AtlasRegistration
rng = np.random.default_rng(0)
X = rng.normal(size=(200, 3)) # target
Y = X + 0.05 * rng.normal(size=(200,3)) # source (noisy)
# Rigid CPD
rig = RigidRegistration(X=X, Y=Y, max_iterations=50, use_kdtree=True, k=10)
TY_rigid, (s, R, t) = rig.register()
# Affine CPD
aff = AffineRegistration(X=X, Y=Y, max_iterations=50, use_kdtree=True, k=10)
TY_affine, (B, t) = aff.register()
# Deformable CPD (low-rank + k-d tree)
defm = DeformableRegistration(X=X, Y=Y, alpha=2.0, beta=2.0, low_rank=True, num_eig=80,
use_kdtree=True, k=10, radius_mode=False, w=0.05,
max_iterations=50)
TY_def, params = defm.register()
# Constrained Deformable CPD
ids = np.arange(10)
con = ConstrainedDeformableRegistration(X=X, Y=Y, alpha=2.0, beta=2.0, low_rank=True, num_eig=80,
use_kdtree=True, k=10, e_alpha=1e-4,
source_id=ids, target_id=ids,
max_iterations=50)
TY_con, params_con = con.register()
# Atlas / Statistical Shape Model CPD
M, D, K = 200, 3, 12
mean_shape = rng.normal(size=(M, D)).reshape(-1)
U = rng.normal(size=(M*D, K))
L = np.abs(rng.normal(size=(K,))) + 1e-1
atl = AtlasRegistration(X=X, Y=mean_shape.reshape(M, D), mean_shape=mean_shape,
U=U, eigenvalues=L, lambda_reg=0.1,
normalize=True, use_kdtree=True, k=10, radius_mode=False,
optimize_similarity=True, with_scale=True, w=0.02,
max_iterations=50)
TY_atl, params_atl = atl.register()
```
## Key options
- `use_kdtree`, `k`: enable sparse E-step for speed on large data
- `low_rank`, `num_eig` (deformable): low-rank kernel for fast M-step
- `radius_mode`: optional radius gating in sparse E-step (off by default)
- `w`: outlier weight (0 ≤ w < 1) in GMM
- `normalize` (atlas): improves stability across scales
## Acknowledgements
- This work builds on the excellent original CPD implementation by Siavash Khallaghi (`pycpd`, MIT-licensed) and the CPD method by Myronenko and Song.
- Repository for `pycpd`: https://github.com/siavashk/pycpd
## Citation
If you use this package in academic work, please cite CPD:
- Myronenko, A. and Song, X., "Point Set Registration: Coherent Point Drift," in IEEE Transactions on Pattern Analysis and Machine Intelligence, 2010.
## License
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/agporto/biocpd",
"name": "biocpd",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "point cloud registration CPD",
"author": "Arthur Porto",
"author_email": "agporto@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/27/ba/94b6c79e963ec6d8ce414050f7374e1edc2bfbbce7497c3ea42b53ace6ea/biocpd-0.1.1.tar.gz",
"platform": null,
"description": "# biocpd\n\nCoherent Point Drift (CPD) registration in pure NumPy/SciPy with fast variants:\n- Rigid and Affine CPD\n- Deformable CPD with low-rank (randomized SVD) and k-d tree accelerated E-step\n- Constrained Deformable CPD with correspondence priors\n- Atlas/SSM-based CPD (`AtlasRegistration`) optimized in coefficient space\n\n## Why biocpd?\n- Fast: sparse k-NN E-step, low-rank kernels, and efficient linear solvers\n- Flexible: rigid, affine, unconstrained and constrained deformable, and SSM/atlas-based\n- Simple: pure NumPy/SciPy implementation; easy to read and extend\n\n## Install\n\n```bash\npip install -r requirements.txt\n# optional (recommended for building)\npip install build wheel\n```\n\n## Build wheel\n\n```bash\n# From repository root\npython -m build\n# or legacy\npython setup.py sdist bdist_wheel\n```\n\n## Quickstart\n\n```python\nimport numpy as np\nfrom biocpd import RigidRegistration, AffineRegistration, DeformableRegistration, ConstrainedDeformableRegistration, AtlasRegistration\n\nrng = np.random.default_rng(0)\nX = rng.normal(size=(200, 3)) # target\nY = X + 0.05 * rng.normal(size=(200,3)) # source (noisy)\n\n# Rigid CPD\nrig = RigidRegistration(X=X, Y=Y, max_iterations=50, use_kdtree=True, k=10)\nTY_rigid, (s, R, t) = rig.register()\n\n# Affine CPD\naff = AffineRegistration(X=X, Y=Y, max_iterations=50, use_kdtree=True, k=10)\nTY_affine, (B, t) = aff.register()\n\n# Deformable CPD (low-rank + k-d tree)\ndefm = DeformableRegistration(X=X, Y=Y, alpha=2.0, beta=2.0, low_rank=True, num_eig=80,\n use_kdtree=True, k=10, radius_mode=False, w=0.05,\n max_iterations=50)\nTY_def, params = defm.register()\n\n# Constrained Deformable CPD\nids = np.arange(10)\ncon = ConstrainedDeformableRegistration(X=X, Y=Y, alpha=2.0, beta=2.0, low_rank=True, num_eig=80,\n use_kdtree=True, k=10, e_alpha=1e-4,\n source_id=ids, target_id=ids,\n max_iterations=50)\nTY_con, params_con = con.register()\n\n# Atlas / Statistical Shape Model CPD\nM, D, K = 200, 3, 12\nmean_shape = rng.normal(size=(M, D)).reshape(-1)\nU = rng.normal(size=(M*D, K))\nL = np.abs(rng.normal(size=(K,))) + 1e-1\natl = AtlasRegistration(X=X, Y=mean_shape.reshape(M, D), mean_shape=mean_shape,\n U=U, eigenvalues=L, lambda_reg=0.1,\n normalize=True, use_kdtree=True, k=10, radius_mode=False,\n optimize_similarity=True, with_scale=True, w=0.02,\n max_iterations=50)\nTY_atl, params_atl = atl.register()\n```\n\n## Key options\n- `use_kdtree`, `k`: enable sparse E-step for speed on large data\n- `low_rank`, `num_eig` (deformable): low-rank kernel for fast M-step\n- `radius_mode`: optional radius gating in sparse E-step (off by default)\n- `w`: outlier weight (0 \u2264 w < 1) in GMM\n- `normalize` (atlas): improves stability across scales\n\n## Acknowledgements\n- This work builds on the excellent original CPD implementation by Siavash Khallaghi (`pycpd`, MIT-licensed) and the CPD method by Myronenko and Song.\n- Repository for `pycpd`: https://github.com/siavashk/pycpd\n\n## Citation\nIf you use this package in academic work, please cite CPD:\n\n- Myronenko, A. and Song, X., \"Point Set Registration: Coherent Point Drift,\" in IEEE Transactions on Pattern Analysis and Machine Intelligence, 2010.\n\n## License\nMIT \n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Coherent Point Drift variants (rigid, affine, deformable, PCA/SSM) in NumPy/SciPy",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/agporto/biocpd"
},
"split_keywords": [
"point",
"cloud",
"registration",
"cpd"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "48d2f8a2f8cbbb203a6d557782b6fa65368266f1c096bde58d5bac09c06cbe17",
"md5": "14168c45eed1dc7304dad460d96a8cc1",
"sha256": "a0bbc1d5c346e7aa6e0391c8bde76f9f4fce28fd68b777a0fee58368b5ca3e71"
},
"downloads": -1,
"filename": "biocpd-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "14168c45eed1dc7304dad460d96a8cc1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19099,
"upload_time": "2025-08-23T03:45:06",
"upload_time_iso_8601": "2025-08-23T03:45:06.303473Z",
"url": "https://files.pythonhosted.org/packages/48/d2/f8a2f8cbbb203a6d557782b6fa65368266f1c096bde58d5bac09c06cbe17/biocpd-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "27ba94b6c79e963ec6d8ce414050f7374e1edc2bfbbce7497c3ea42b53ace6ea",
"md5": "0b2f97b9fbd9d1e27156915472604c8e",
"sha256": "3921fa356fcaa0879ea5e1661c9f912cbc50fca373fced52a4c301e312426db4"
},
"downloads": -1,
"filename": "biocpd-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "0b2f97b9fbd9d1e27156915472604c8e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16469,
"upload_time": "2025-08-23T03:45:08",
"upload_time_iso_8601": "2025-08-23T03:45:08.338181Z",
"url": "https://files.pythonhosted.org/packages/27/ba/94b6c79e963ec6d8ce414050f7374e1edc2bfbbce7497c3ea42b53ace6ea/biocpd-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-23 03:45:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "agporto",
"github_project": "biocpd",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
"~=",
"1.26.4"
]
]
},
{
"name": "scipy",
"specs": [
[
"~=",
"1.11.4"
]
]
},
{
"name": "scikit-learn",
"specs": [
[
"~=",
"1.4.2"
]
]
},
{
"name": "matplotlib",
"specs": [
[
"~=",
"3.8.4"
]
]
},
{
"name": "setuptools",
"specs": [
[
"~=",
"75.8.0"
]
]
}
],
"lcname": "biocpd"
}