Skip to main content

PyCorre

Fast, GPU-accelerated rigid and piecewise-rigid motion correction for calcium-imaging recordings. PyCorre implements the NoRMCorre algorithm, which is the same phase-correlation + upsampled-DFT method used by CaImAn, but rewritten in PyTorch. The whole stack is corrected in batched operations that run on CPU or GPU from a single, dependency-light codebase.

Installation

pip install pycorre

The only runtime dependencies are torch, numpy, and tqdm. GPU support is whatever your PyTorch build provides (install the appropriate CUDA wheel of torch for your machine).

Quickstart

import numpy as np
from pycorre import RigidMotionCorrection, PWRigidMotionCorrection

# A recording of shape (n_frames, height, width); numpy array or torch tensor.
frames = ...

# Rigid correction on the GPU.
model = RigidMotionCorrection(device="cuda")  # or "cpu" / "auto"
corrected = model.fit_transform(frames)

# Piecewise-rigid (non-rigid) correction.
model = PWRigidMotionCorrection(device="cuda", strides=(96, 96), overlaps=(32, 32))
corrected = model.fit_transform(frames)

The API follows scikit-learn's fit / transform / fit_transform pattern. fit estimates the template (unless you pass one) and finds the per-frame shifts; transform applies them. Inputs may be numpy arrays or torch tensors; numpy in and numpy out.

Performance

The table below shows the rigid correction throughput on a real recording with resolution 360x640 for 1800 frames.

method device fps vs PyCorre (GPU)
PyCorre (torch) GPU ~2,285 1.0x
jnormcorre (NoRMCorre in JAX) GPU ~762 3.0x slower
PyCorre (torch) CPU ~468 4.9x slower
jnormcorre CPU ~162 14x slower
CaImAn reference CPU ~103 22x slower

On this sample, PyCorre is ~22x faster than CaImAn and ~3x faster than jnormcorre. On CPU alone, with no GPU at all, PyCorre still leads, running ~4.5x faster than the CaImAn reference and ~2.9x faster than jnormcorre.

The scaling curve can be seen here:

Author

PyCorre is written and maintained by Ryan 'RyanIRL' Peters (@ryanirl).

Citation

If you use PyCorre in your research, please cite it:

@software{peters_pycorre,
  author = {Peters, Ryan},
  title  = {{PyCorre}: GPU-accelerated rigid and piecewise-rigid motion correction for calcium imaging},
  url    = {https://github.com/ryanirl/pycorre},
  year   = {2026}
}

PyCorre implements the NoRMCorre algorithm; if you use it, please also cite the original method:

Pnevmatikakis, E. A., & Giovannucci, A. (2017). NoRMCorre: An online algorithm for piecewise rigid motion correction of calcium imaging data. Journal of Neuroscience Methods, 291, 83-94. https://doi.org/10.1016/j.jneumeth.2017.07.031

License

pycorre is released under the MIT License (see LICENSE).

Metadata

Release files for pycorre 0.1.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 pycorre 0.1.1
File Size Uploaded
pycorre-0.1.1.tar.gz 11.8 kB Details

Built distribution (wheel)

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

Total release size: 25.1 kB

Release files / pycorre-0.1.1.tar.gz

Download URL pycorre-0.1.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
187719d4329c3fedecff2f94a00b3adc574233d2314e079e71fefb7e1df269cb
BLAKE2b-256 checksum
How to use checksums
c6f0055a6743f6b025d0c174f7eedecb9d5d9af91f1a74e260f9b238f7d7633a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / pycorre-0.1.1-py3-none-any.whl

Download URL pycorre-0.1.1-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65085e9fe8425dbed820bb98db4b677b6d9b9c4e9451bc610dcf4decd8ca30e4
BLAKE2b-256 checksum
How to use checksums
b449c09287a44b690fd74fde08db70e30e966f72d637e12575596aff70e7e76b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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