Cost-function Optimized Maximal Overlap Drift EsTimation
COMET is a fast, GPU-accelerated software package for drift correction in single-molecule localization microscopy (SMLM) datasets. It achieves high spatial and temporal resolution by maximizing spatiotemporal overlap across frames using a cost-function optimization approach.
Visit our web platform at smlm.tools, upload your dataset, and get results directly without any installation required.
- Format: CSV (ThunderSTORM-compatible)
- Required headers:
"frame","x [nm]","y [nm]", and optionally"z [nm]" - Column headers must match exactly (quotes included)
- Extra columns are allowed
-
Upload your file on smlm.tools
-
Choose:
- Segmentation method (e.g. segment by number of localizations per time window)
- Segmentation parameter (e.g. 500 locs per time window)
- The maximum drift expected in nm
-
Click Run
- ✅ Check "Keep file for later" to re-analyze with different settings
- ✅ Check "Spline Interpolation" to get a smooth result per frame
- ✅ Check "Dynamic downsampling" if you experience memory errors on very large datasets
- ⏳ Busy? If queue times are high, use the Python/Colab version locally.
Requirements
- Python 3.8+
- CUDA-capable GPU (for full acceleration) compatible with Numba CUDA
- (All other dependencies—NumPy, SciPy, Matplotlib, Pandas, h5py, Numba, tqdm, scikit-learn, lmfit—are installed automatically.)
git clone https://github.com/gpufit/Comet
cd Comet
cd Python_interface
pip install -e .This creates an “editable” install so that any changes to the code reflect immediately.
To test the installation, run:
comet_self_test --plot Once installed, you have a comet command available in your environment:
comet \
--input your_data.csv \
--output corrected.csv \
--format csv \
--segmentation_mode 2 \
--segmentation_var 60To see all options:
comet --help-
--input(string, required): Path to your input file (.csvor.h5). -
--output(string, required): Where to save the corrected output. -
--format(csv|h5, required): Output file format. -
--segmentation_mode(0|1|2, default=2):0: Fixed number of time windows (--segmentation_var= number of segments)1: Fixed number of localizations per window (--segmentation_var= locs per segment)2: Fixed number of frames per window (--segmentation_var= frames per segment)
-
--segmentation_var(int, required): Value associated with your chosen mode. -
--initial_sigma_nm(float, default=600): Initial Gaussian sigma (nm) for overlap optimization. -
--target_sigma_nm(float, default=1): Target sigma (nm) at which the algorithm stops refining. -
--max_drift_nm(float, default=None): Maximum expected drift (nm); defaults to3 × initial_sigma_nm. -
--boxcar_width(int, default=1): Width of the moving-average filter applied between iterations. -
--interpolation(cubic|catmull-rom, default=cubic): Interpolation method for per-frame drift curves.
You can omit any optional parameters to use their default values.
If you prefer to call COMET directly in Python:
from comet.core.drift_optimizer import comet_run_kd
from comet.core.io_utils import load_thunderstorm_csv, save_dataset_as_thunderstorm_csv
# Load your CSV
dataset = load_thunderstorm_csv("your_data.csv")
# Run drift correction
drift, corrected = comet_run_kd(
dataset,
segmentation_mode=2,
segmentation_var=60,
initial_sigma_nm=100,
target_sigma_nm=1,
max_drift_nm=300,
boxcar_width=1,
interpolation_method="cubic",
return_corrected_locs=True
)
# Save as CSV
save_dataset_as_thunderstorm_csv(corrected, "corrected.csv")Click the badge above to launch the interactive version in your browser with no setup required.
This repository also ships developer documentation built with MkDocs and the Material theme.
It includes usage guides, background, and an auto-generated API reference.
After installing COMET with pip install -e ., install the documentation extras:
pip install mkdocs mkdocs-material mkdocstrings[python] pymdown-extensionsThen from within the Python_interface folder build and serve the docs:
mkdocs serveOpen your browser at http://127.0.0.1:8000
COMET segments data before estimating drift. Choose from:
| Mode | Description | Parameter |
|---|---|---|
| 0 | Fixed number of time windows | Number of segments |
| 1 | Fixed number of localizations/window | Localizations per segment |
| 2 | Fixed number of frames/window (default) | Frames per segment |
Some features are experimental and may change in future releases:
GPU acceleration for Mac (MPS) and AMD GPUs (ROCm) is under development. Using pytorch a first running version of COMET on these platforms is possible, but performance may vary. Using the same (cuda capable) GPU initial tests showed that the numba cuda implementation is currently at least 2x faster than the pytorch implementation. Anyhow, to enable usage of COMET on MPS and ROCm platforms we included a pytorch based implementation. First successful tests were done on Apple Silicon (M2). Feedback from users with AMD GPUs is welcome!
To install PyTorch with MPS support on macOS, use the following command:
pip install torch torchvision torchaudiothen simply call COMET as usual with the 'mode' ... TODO
If you use COMET in your research, please cite our upcoming publication (link TBD).
For questions or contributions, feel free to open an issue or reach out on GitHub.
