Numpy + Cython Implementation of the Coherent Point Drift Algorithm
Project description
Cython-CPD
Numpy + Cython Implementation of the Coherent Point Drift Algorithm.
Update to the PyCPD module to include Cython to try and improve performance
Introduction / Background
Please see here (https://github.com/siavashk/pycpd) for Pure Numpy implementation
Please see here (https://tinyurl.com/tph4u7e) for original manuscript describing CPD
Please see here (https://sites.google.com/site/myronenko/research/cpd) for original code (Matlab) that you can request
Please see here for Matlab code stored on github by secondary source (https://github.com/markeroon/matlab-computer-vision-routines/tree/master/third_party/CoherentPointDrift)
Please see here (https://github.com/gadomski/cpd) for a C++ implementation
This implementation aims to speed up the PyCPD implementation of CPD. First we added cython functions to compute the expectation step of the EM algorithm. This cut E-step times to be ~1/3. E-step is the major bottle neck for rigid and affine registration. Therefore, this function reduces registration of those methods to be ~1/3.
For deformable (non-rigid) registration, the major bottle neck is solving the system of equations for the transformation paramters, which took ~9 seconds (5k point clouds). The first approach we took to speed things up is to implement the low-rank method described in the original CPD paper. This low-rank method significantly reduced computation time and now the entire M-step using default parametrs took <1 second and the E-step is the bottleneck (same as rigid and affine).
The next steps will be to:
- Add the FGT (Fast Gauss Transform). This has the potential to further increase the performance of all methods because it reduces computation for the E-step, which is consistent for all three methods.
- Write more Cython functions to speed up other process/computations.
Installation
You should be able to install this by cloning, navigating to this root directory, and installing with pip:
git clone https://github.com/gattia/cycpd
cd cycpd
pip install .
Cython
If the above didnt work... previous versions of cycpd
had issues with Cython - if you have cython related issues, the following may be helpful:
Must have Cython installed to build package
pip install cython
or
conda install -c anaconda cython
For any operating system you will have to have a C compiler. If you do not have a C compiler you will get errors when building cycpd. You can often follow these errors to install the appropriate packages.
Details about installing C-compiler and other steps necessary for installing Cython can be found here: http://docs.cython.org/en/latest/src/quickstart/install.html. Briefly.
Linux
C compiler (gcc) is often present. If it is not, you can install it using:
sudo apt-get install build-essential
OSX
You will like need to install gcc (if you havent already). This can be done by installing Apple's xcode command line tools:
xcode-select --install
Windows
You will need Visual Studio Community 2019 (free) & Build Tools for Visual Studio 2019. These can be downloaded from: https://visualstudio.microsoft.com/downloads/ You may need newer versions of Visual Studio and it's tools, but thats the one that was required as of writing.
With cython installed:
Examples
To run the examples, you will also need matplotlib
which is not required for the base package. This can be installed using:
pip install matplotlib
There are three exmples currently implemented. They all show registration of two 3D bones with 5k points each. The Affine applies a transformation to a bone and then use CPD to return it back to its original shape. The rigid and deformable (non-rigid) warps the bone of one person onto a version of that same bone warped to best fit another person. The deformable example will end at 100 epochs (default), at which time it will not have converged fully.
These examples can be run by navigating to the examples folder (after installing) and running:
python knee_rigid_3D.py
python knee_affine_3D.py
python knee_deformable_3D.py
Rigid
Affine
Non-Rigid (Deformable)
Tests
Regular Tests
Testing includes rigid, affine, and deformable examples. The rigid, affine, and 2D deformable all test to ensure the algorithm recovers a predefined transformation. The 3D deformable tests to ensure that the resulting registrtaion has errors (between a mesh and the closest point on the other mesh) below a pre-defined tolerance.
These tests are continually run by Github Actions for all new merges/builds. All of these tests can be run by navigating to the cpd directory and running:
pytest
Inidividual tests can be run by running
python -m pytests path_to_test
path_to_test
need be replaced by the path to the approriate test. If in the testing directory, it can be just affine_test.py
or similar. If not in testing directory, will need to specify full (absolute or relative) path.
Timing of Analyses
If the test files are run directly, e.g.,:
python affine_test.py
the same tests that are run by pytest will be conducted. Running these files directly will also time the analyses and print the time to do the analysis. Running this way will also run the diagnostics that are built in to the functions and will print those out.
Contributing
If you want to contribute, please read over the documentaiton in CONTRIBUTING.md
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file cycpd-0.28.tar.gz
.
File metadata
- Download URL: cycpd-0.28.tar.gz
- Upload date:
- Size: 8.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa42fc1bee5dcbb46238718f02b47abbc62a481b2d06edcad9144b5eb52aaff9 |
|
MD5 | 8be8b44fa9face25c76d85198c21ecc1 |
|
BLAKE2b-256 | dab47b8332ceaba05671f78ff0326d35e675c4bba6fd5d682cd0db96599479b3 |
File details
Details for the file cycpd-0.28-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: cycpd-0.28-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 104.1 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 719c0b6ba92e7e65f49400dd499fee7997d4da1dcb823401dd4d983a0fd42f81 |
|
MD5 | 49fe08fa393221f77f43775a01fd6f9e |
|
BLAKE2b-256 | 1bb98e027cfb6d56cefcdf388ff88ca7a398b64b8ccfad839de1a28ec0d4ea04 |
File details
Details for the file cycpd-0.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 680.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25032913614d53ab4f14e9d9c5184358fa65f3ccc357f8147f277ce2706879ff |
|
MD5 | f01d31c0e75b5f00bacd606f579f5662 |
|
BLAKE2b-256 | b63128fb1e3371b71f73644b9d979486c3d7ce9aacb1813384b23734e316d732 |
File details
Details for the file cycpd-0.28-cp312-cp312-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 122.2 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec621a73b159c6de64e7c994fb68788ef2bcc3dd2ed7111f2657eb21f3f98510 |
|
MD5 | 811630542d5216c79f6d5b6d2257f837 |
|
BLAKE2b-256 | b642ea3a109c8ff9df49f4d1e88ccbf467628871aa821cdc80fd5b5a54d197da |
File details
Details for the file cycpd-0.28-cp312-cp312-macosx_10_9_universal2.whl
.
File metadata
- Download URL: cycpd-0.28-cp312-cp312-macosx_10_9_universal2.whl
- Upload date:
- Size: 219.3 kB
- Tags: CPython 3.12, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c710599c76385ad1d211a463b81ca06986013daa595335d498359c5516b0aa |
|
MD5 | 8ada27eb0e122620362314bf51d3d670 |
|
BLAKE2b-256 | c1baab45ed3543ee52a2fd7b58f0c741e32364b6fb6b130d56cd4d5c5fdcfe0b |
File details
Details for the file cycpd-0.28-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: cycpd-0.28-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 104.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd0fcc7c1edebee75b21bc63696eee8cb1ecb3f88e6c85e37a3ba1be7d68ed96 |
|
MD5 | fbc8e4da709d80a837c1b2163ae42ca4 |
|
BLAKE2b-256 | d2ccb21f6eecc6fa1cba434d2abf7dcb898fb78d259e579d49e528cb5a9f2eef |
File details
Details for the file cycpd-0.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 689.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6942ebc0b818904b4e240d687bb99a69f6aa33ed5a8d3508d21e392ee94432d1 |
|
MD5 | 4ec7897499a758e55ee3ed38173a55d9 |
|
BLAKE2b-256 | 8f0a63d269ff2598abdf033420578c88faf5f5310e9ca866d7e9f5236de14f4e |
File details
Details for the file cycpd-0.28-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 116.5 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c180ab639140b7cc6aec61aed526b210c87fbe27e3651f1dc79ab60af0f34f7 |
|
MD5 | aa6b7ecfca2c10c8cafb398f1387d85b |
|
BLAKE2b-256 | 4c7abe635c308af44c0ba75811b051dec872310f9b1e5bd23b657c6869d48b40 |
File details
Details for the file cycpd-0.28-cp311-cp311-macosx_10_9_universal2.whl
.
File metadata
- Download URL: cycpd-0.28-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 214.2 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 848393dca00c8f05f4c5d6fe1096f77187dc9c4f5a2ec1a29a1ce05205e09e22 |
|
MD5 | aa34dcbe134b5b702d3edad3b9850252 |
|
BLAKE2b-256 | d855b00a3aa56247262991c04de268bebc9287fa60fac4c19f930fb2f31764ef |
File details
Details for the file cycpd-0.28-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: cycpd-0.28-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 104.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 737103cce2c11f21cfc9d6135a8424f355e611f2827b3ecf7921794444c743ac |
|
MD5 | 4d60e0abcd75249248afe01e6b52027f |
|
BLAKE2b-256 | 9524427fe9854763a64d9c90d59002a1f581549f99d0c297f3d3ad17bda96747 |
File details
Details for the file cycpd-0.28-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 645.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c23bcc5e2f0260095271a7dcf1cc6e4d50f3af419b5684e2ec2b216fa65d45d |
|
MD5 | 15f5be420270992ac9f4e341c60e9554 |
|
BLAKE2b-256 | f808f22efe5cabad172673809e62c3e17b9ab0d3f0c997e0c32aa60eec2a6c9b |
File details
Details for the file cycpd-0.28-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 116.3 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c1c6387aafcb81a0ea2eca705a8b7d3ff265dd81308bccf585ca6119112b77e |
|
MD5 | 4e4d59e548a570f7fda3cfb1cc5b1cd7 |
|
BLAKE2b-256 | 6b622bb3a396ccfb1f68333ab579cb25c6b6d98af40f059d758652e0632dd49e |
File details
Details for the file cycpd-0.28-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: cycpd-0.28-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 214.1 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 444894c28791b799f4a07bf51a81f987b8f9c15db4247a2dfa4180a2553adf08 |
|
MD5 | bf30713af4030a05edc2a8679242db43 |
|
BLAKE2b-256 | 973cb25a5a2d78a5fad86b953428f744988a4dcf46b416b16604f33671a2ab0c |
File details
Details for the file cycpd-0.28-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: cycpd-0.28-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 104.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f0d02cadf6bf085bfa5386e7199674c3bcc1b4475713c1519ba11e440f36cf9 |
|
MD5 | 5eccd674292acced30ee89f9a11a2065 |
|
BLAKE2b-256 | 451a544546ad22b24d2306f1b9acb849ebb42db6abb6f7bb997c1edbf1c2dd2b |
File details
Details for the file cycpd-0.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 647.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dde2935926d086388a54d3f0ce4beb83668f6b665c73be65cab19720da16058d |
|
MD5 | 8f94a83d86e13bcd23bbe50691faf259 |
|
BLAKE2b-256 | fe74af751343aa72d3726cf23f382e5d2be4c4820f1811eb3f83de869f9e53ca |
File details
Details for the file cycpd-0.28-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 116.9 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36ffc0031a893a847ab30c365135628211fe9df8dbff74d13844424482ba7afd |
|
MD5 | 27fc14cf585714462c459a5f69f37085 |
|
BLAKE2b-256 | abc5af52abe79ea2217bdaa8dde40660f08aee3800fdd45c309dc1b711210862 |
File details
Details for the file cycpd-0.28-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: cycpd-0.28-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 215.2 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b063fab3a3f2a139751e757d2243f0298d7ec8cd8c78489d50c63f072d36975e |
|
MD5 | 2fbc48e9454ce2c15d66582adff9ac7c |
|
BLAKE2b-256 | d499c06fdc94ce4b04c2e6775d769c8ad187222b5791cd1cecf614c074b9690a |
File details
Details for the file cycpd-0.28-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: cycpd-0.28-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 104.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ef9371c06349c94802f53aef4479552665fa68c068cd0c723ae7fdb4368ce9 |
|
MD5 | 096d30eedd9c052dc21c8804a696f872 |
|
BLAKE2b-256 | 7318ad902c8f8da7c2f165ba3ee5efa24b157a794aa371c11998eb9f8a01b6ec |
File details
Details for the file cycpd-0.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 665.0 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f84a3c4648cdb729626549d409da50a28c1b1b7f3e489f24d560a2f5aae57874 |
|
MD5 | 20b99ed8b75814957153d3fd11475da9 |
|
BLAKE2b-256 | 7c65571bf689942c61d8c6182468a659a7adfbedc7a2b340ee1d318daf998097 |
File details
Details for the file cycpd-0.28-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 116.4 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cf17ddddd5daf4d8bda05751b25570e7decca0435ad99eb60dcd084ed9194ec |
|
MD5 | a35f0ce9737ed310748324c68f9a0b8d |
|
BLAKE2b-256 | 607b54baa35ffc1859c31b1612e442e00aade5d62b457a826d5302a69fd8554b |
File details
Details for the file cycpd-0.28-cp38-cp38-macosx_10_9_universal2.whl
.
File metadata
- Download URL: cycpd-0.28-cp38-cp38-macosx_10_9_universal2.whl
- Upload date:
- Size: 214.0 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63c89090272982c5a42c22296686ea6ece0558561b3e1c6dc08d96ac44aeb73f |
|
MD5 | b226bd1127b5c4335fe8f7f5de64862b |
|
BLAKE2b-256 | 84a68f32ef085941508f6e5e9791c5617e8c2943d5a059edc3a3831eb2a322c8 |
File details
Details for the file cycpd-0.28-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: cycpd-0.28-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 103.4 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09381c0fcfcde108f54cd843426e1658e13130e7dc5e97c2b9c65043a7246a2e |
|
MD5 | 1792a9d46863fd3ef4270f1f0c8d43ea |
|
BLAKE2b-256 | 692d46a28919a5d84e8f8b5fca850d2ee5f0693bd5ca759fb757692a9cda4df5 |
File details
Details for the file cycpd-0.28-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 586.0 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb0dff07c14ce7963b0569e8f89ceb7e68517d9d59a91be26b9aad343a2ebe5d |
|
MD5 | 002c6119a0b2482240bf8717c364c24f |
|
BLAKE2b-256 | 9c2a9e44405455c65a22dc186c1a150623063180701e2f311923d10f42535de3 |
File details
Details for the file cycpd-0.28-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: cycpd-0.28-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 114.4 kB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e007fb6b6dc2d41e9c3568cae05279f6aa5820c0819cae622424647778d62f4 |
|
MD5 | 1d2d79b449f20191b746b339634fab39 |
|
BLAKE2b-256 | ec52f5b9dbf9302c5818b372fd47b12caf59ecd853754362d1d75ae71d9346d6 |