COMET
Cost-function Optimized Maximal Overlap Drift EsTimation
Fast, GPU-accelerated drift correction for single-molecule localization microscopy (SMLM) datasets. COMET achieves high spatial and temporal resolution by maximizing spatiotemporal overlap across frames using a cost-function optimization approach.
- Documentation: https://comet.smlm.tools/
- Source and issues: https://github.com/gpufit/Comet
- Preprint: https://doi.org/10.64898/2026.03.27.714864
- No-install web tool: https://www.smlm.tools
This page covers the Python package. The repository README also documents the CUDA/C++ library, the IDL interface, and the web tool.
Install
pip install comet-smlm
For the PyTorch backend, which is useful on machines without an NVIDIA GPU (including Apple Silicon):
pip install "comet-smlm[torch]"
Then check the install:
comet_self_test
This simulates a dataset with a known drift, recovers it, and reports which backends it found. It needs no GPU and takes a few seconds.
A GPU is optional
COMET runs on three backends and picks the fastest available automatically:
| Backend | Needs | Notes |
|---|---|---|
cuda |
NVIDIA GPU + CUDA driver | Fastest; the numba-cuda kernels |
torch |
pip install "comet-smlm[torch]" |
Uses CUDA or Apple MPS, or falls back to CPU |
cpu |
nothing | numba-compiled; no GPU needed |
import comet
print(comet.describe_backends()) # what this machine supports
print(comet.best_backend()) # what COMET will use
Python 3.6 / 3.7
These are not supported, but not blocked either. The intent is that pip does not refuse the install outright, so you can try COMET on an older interpreter if that is what you have.
pip install comet-smlm resolves to the frozen 1.0.x line there, whose
dependency floors are low enough for those interpreters. Upgrade pip first
(python -m pip install --upgrade pip) — versions before pip 9 ignore the
metadata that makes this work.
Expect to do some work: getting numba and llvmlite built or wheel-matched on
3.6/3.7 is fiddly and platform-dependent. This path is untested in CI beyond a
best-effort job, so treat it as "try it and see" rather than a supported
configuration. Use Python 3.9+ if you have the choice.
Quickstart
from comet import comet_run_kd, load_thunderstorm_csv, save_dataset_as_thunderstorm_csv
# (N, 4) array of [x_nm, y_nm, z_nm, frame]
dataset = load_thunderstorm_csv("your_data.csv")
drift, corrected = comet_run_kd(
dataset,
segmentation_mode=2, # fixed number of frames per time window
segmentation_var=60, # 60 frames per window
max_drift_nm=300, # maximum expected drift
target_sigma_nm=10, # stop refining at this length scale
return_corrected_locs=True,
)
save_dataset_as_thunderstorm_csv(corrected, "corrected.csv")
drift is an (F, 4) array of [dx_nm, dy_nm, dz_nm, frame], one row per
frame.
Note:
comet_run_kdmodifies the array you pass in — it subtracts the estimated drift fromdatasetin place. Passdataset.copy()to keep the original.
Input format
CSV input is ThunderSTORM-compatible. Required headers are "frame",
"x [nm]", "y [nm]", and optionally "z [nm]"; extra columns are allowed.
Molecule-set HDF5 files are read with load_normal_molecule_set.
Command line
comet \
--input your_data.csv \
--output corrected.csv \
--format csv \
--segmentation_mode 2 \
--segmentation_var 60
comet --help lists every option. The backend defaults to the fastest one
available; override it with --mode {cuda,torch,cpu}.
Segmentation modes
COMET segments data temporally before estimating drift.
| Mode | Description | --segmentation_var means |
|---|---|---|
| 0 | Fixed number of time windows | Number of windows |
| 1 | Fixed number of localizations per window | Localizations per window |
| 2 | Fixed number of frames per window (default) | Frames per window |
| -1 | Pre-segmented: the frame column already holds a window id per localization | (ignored) |
Choose a parameter that gives you enough windows to resolve the drift, but enough localizations per window to constrain it.
Automatic fiducial detection
comet_fiducials is a standalone package shipped alongside COMET that locates
fiducial beads from one 2D histogram binned at the maximum expected drift, and
scores candidates by the number of localization pairs they contribute across
time. It imports only NumPy and SciPy — nothing from comet — and COMET never
calls it; use it when you want to remove beads before correction, or to keep
only the beads as a drift reference.
from comet_fiducials import find_fiducials, fiducial_mask
centers_nm, report = find_fiducials(locs, max_drift_nm=250,
field_bounds_nm=camera_fov_nm)
radii = [c["radius_p99_nm"] for c in report["accepted"]]
clean = locs[~fiducial_mask(locs, centers_nm, radii)]
locs is the usual (N, >=4) array of [x_nm, y_nm, z_nm, frame, ...], and
field_bounds_nm is (x_min, x_max, y_min, y_max) of the camera. It is
required, because from localizations alone an empty corner and a stray
coordinate look the same; field_bounds_from_data(locs, max_drift_nm) returns
a guess when there is no metadata. The report carries per-bead diagnostics:
the pair burden, the measured cloud radius (which fiducial_mask accepts per
bead), the frame span, and how many bins of pure chance would be expected to
reach that occupancy. Two beads closer together than max_drift_nm are
reported as one — that is the resolution limit. See
docs/fiducials.md.
Running the tests
The test suite ships with the package, so a GPU user can validate the CUDA backend on their own hardware:
pip install "comet-smlm[test]"
pytest --pyargs comet.tests comet_fiducials.tests
Tests needing a GPU are marked and skip automatically.
Citing COMET
If you use COMET in your research, please cite the preprint. Machine-readable metadata is in CITATION.cff.
License
MIT. See LICENSE.txt.
Metadata
Release files for comet-smlm 1.2.0
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 |
|---|---|---|---|---|
| comet_smlm-1.2.0.tar.gz | 112.0 kB | With provenance | Details for comet_smlm-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| comet_smlm-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for comet_smlm-1.2.0-py3-none-any.whl |
Total release size: 236.6 kB
Release files / comet_smlm-1.2.0.tar.gz
| Download URL | comet_smlm-1.2.0.tar.gz |
|---|---|
| Size | 112.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8133defeb5c727f4b5c436009b1520713ce33ee3adec908a87ae57632ffa2062
|
|
BLAKE2b-256 checksum How to use checksums |
143dff845e8e82391c74b92a57a235ab5b77241ddd96cc51696004a4f8fda72b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / comet_smlm-1.2.0-py3-none-any.whl
| Download URL | comet_smlm-1.2.0-py3-none-any.whl |
|---|---|
| Size | 124.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
400ac8c2ec9acdf463ba401c13ab5202530760a15549c6945b41d94426d540c6
|
|
BLAKE2b-256 checksum How to use checksums |
3abf218118ca502c649f2c044426233d40e183180f1bb36f545d2c8b6d569868
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logSecurity for comet-smlm 1.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for comet_smlm-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logA 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.