Skip to main content

Biological Multiple Object Tracking in Python

Project description

ByoTrack

Lint and Test
Documentation Status

pipeline

ByoTrack is a Python library for tracking biological objects in microscopy videos (2D and 3D).

Its goal is to provide a fast, modular, and research-friendly tracking framework that integrates seamlessly with the Python scientific ecosystem and established bioimage analysis platforms such as Fiji, Icy and Napari.

ByoTrack defines a modular tracking API that can be easily extended to design and evaluate new methods. It also includes implementations of several state-of-the-art detection and tracking approaches following this API.

Some components are implemented natively in Python (e.g. WaveletDetector, KalmanLinker, KOFT, RTSSmoother, EMC2Stitcher), while others wrap existing tools (e.g. StarDistDetector, IcyEMHTLinker, TrackMateLinker), integrating with external software.

In addition, ByoTrack provides utilities for data loading and preprocessing, as well as evaluation and visualization of tracking results.

[!NOTE] ByoTrack has been primarily developed for scenarios involving up to a few thousand targets in 2D or 3D microscopy data. Some components assume that individual frames fit in memory, which may limit scalability to very large 3D volumes. If you encounter limitations with your use case, feel free to open an issue or contribute a pull request.

🏆 ByoTrack (PAST-FR) won the Cell Linking Benchmark of the Cell Tracking Challenge with its SKT/KOFT implementation (see our paper for details).


Installation

pip

pip install byotrack

Some components require additional dependencies that are not installed with the library by default. For these components, you need to install their specific dependencies. Here is the complete list:

For visualization, with byotrack.visualize module you need to install Matplotlib.

From source

git clone git@github.com:raphaelreme/byotrack.git  # OR https://github.com/raphaelreme/byotrack.git
cd byotrack
pip install .

Getting started

import byotrack

# Load some specific implementations
from byotrack.implementation.detector.wavelet import WaveletDetector
from byotrack.implementation.linker.icy_emht import IcyEMHTLinker
from byotrack.implementation.refiner.cleaner import Cleaner
from byotrack.implementation.refiner.stitching import EMC2Stitcher

# Read a video from a path, normalize and aggregate channels
video = byotrack.Video(video_path)
transform_config = VideoTransformConfig(aggregate=True, normalize=True, q_min=0.01, q_max=0.999)
video.set_transform(transform_config)

# Create a multi step tracker
## First the detector
## Smaller scale <=> search for smaller spots
## The noise threshold is linear with k. If you increase it, you will retrieve less spots.
detector = WaveletDetector(scale=1, k=3.0, min_area=5)

## Second the linker
## Hyperparameters are automatically chosen by Icy
linker = IcyEMHTLinker(icy_path)

## Finally refiners
## If needed you can add Cleaning and Stitching operations
refiners = []
if True:
    refiners.append(Cleaner(5, 3.5))  # Split tracks on position jumps and drop small ones
    refiners.append(EMC2Stitcher())  # Merge tracks if they track the same particle

tracker = byotrack.MultiStepTracker(detector, linker, refiners)

# Run the tracker
tracks = tracker.run(video)

# Save tracks
byotrack.Track.save(tracks, output_path)

Please refer to the official documentation (https://byotrack.readthedocs.io/en/latest/).


Tracking Pipeline

ByoTrack implements a modular multi-step tracking pipeline:

Video → Detection → Detection Refinement → Linking → Track Refinement

Detection

Detect objects in each frame.

Implemented detectors:

  • Wavelet detector [2]
    Similar to the Icy implementation but rewritten in PyTorch

  • StarDist [3]
    Wrapper for inference (training is performed using the official StarDist library)

Detection Refinement

Filter, refine, split and merge detections.

Implemented detection refiners:

  • Detection filtering
    Filter detections based on intensity and size criteria.

  • Watershed
    Convert semantic (binary) segmentation into instance segmentation with Watershed
    Can also be applied to instance segmentation to refine the instances found

Linking

Associate detections across frames.

Implemented linkers:

  • Nearest-neighbor linking

    • Euclidean
    • Optical flow
    • Kalman filtering (SKT) [9]
    • KOFT (Kalman + Optical Flow Tracker) [9]
    • optional adaptive gating [12]
  • EMHT [4]
    Wrapper around the Icy implementation

  • TrackMate / u-track [7]
    Wrapper around Fiji's TrackMate implementation [6,8]

Track Refinement

Post-processing operations applied to tracks:

  • Cleaning
    Remove outliers tracks based on length and motion criteria

  • Gap Closing / Stitching
    Tracklet Stitching via EMC2 algorithm [5]

  • Interpolation
    Replace miss-detection by an interpolated position
    Extrapolate tracks on the full temporal sequence

  • Smoothing
    RTS optimal Kalman smoother


Data, Evaluation & Utilities

Data input

ByoTrack supports:

  • Most standard video formats via OpenCV
  • TIFF stacks
  • Folder of images (sorted by name)
  • Dedicated Python loading of the video (np.array) and detections (converted as a Detections object)

Note that microscope private formats are not supported but can be converted into TIFF manually using bftools

Optical flow

Optical flow can be used for:

  • Linking detections
  • Gap closing / Stitching
  • Interpolation

Currently provide wrappers around implementations from:

  • OpenCV (TVL1, Farneback) (Only 2D)
  • Scikit-Image (ILK, TVL1) (2D + 3D)

Datasets

Built-in loaders for common benchmarks:

  • Cell Tracking Challenge (CTC) [10]
  • SINETRA [11]

Metrics

Evaluation utilities for:

  • Segmentation
  • Detection
  • Tracking

Currently implemented:

  • Cell Tracking Challenge metrics

More metrics will be added in future releases.


Cell Tracking Challenge

Our submission (PAST-FR) to the Cell Linking Benchmark of the Cell Tracking Challenge is available in the examples/ctc folder.


Contributing

Contributions are very welcome! Feel free to open an issue or submit a pull request.

Typical contributions could include:

  • New detections or linking algorithms
  • Dataset loaders
  • Evaluation metrics
  • New data format
  • Track analysis methods

See the contribution guidelines.


Cite us

If you use ByoTrack in your research, please cite:

@article{hanson2024automatic,
  title={Automatic monitoring of neural activity with single-cell resolution in behaving Hydra},
  author={Hanson, Alison and Reme, Raphael and Telerman, Noah and Yamamoto, Wataru and Olivo-Marin, Jean-Christophe and Lagache, Thibault and Yuste, Rafael},
  journal={Scientific Reports},
  volume={14},
  number={1},
  pages={5083},
  year={2024},
  publisher={Nature Publishing Group UK London}
}

References

  • [1] F. De Chaumont, S. Dallongeville, N. Chenouard, et al., "Icy: an open bioimage informatics platform for extended reproducible research", Nature methods, 2012.
  • [2] J.-C. Olivo-Marin, "Extraction of spots in biological images using multiscale products", Pattern Recognition, 2002.
  • [3] U. Schmidt, M. Weigert, C. Broaddus, and G. Myers, "Cell detection with star-convex polygons", MICCAI, 2018.
  • [4] N. Chenouard, I. Bloch, and J.-C. Olivo-Marin, "Multiple hypothesis tracking for cluttered biological image sequences", IEEE TPAMI, 2013.
  • [5] T. Lagache, A. Hanson, J. Perez-Ortega, et al., "Tracking calcium dynamics from individual neurons in behaving animals", PLoS Computational Biology, 2021.
  • [6] J. Schindelin, I. Arganda-Carreras, E. Frise, et al., "Fiji: an open-source platform for biological-image analysis", Nature Methods, 2012.
  • [7] K. Jaqaman, D. Loerke, M. Mettlen, et al., "Robust single-particle tracking in live-cell time-lapse sequences.", Nature Methods, 2008.
  • [8] J.-Y. Tinevez, N. Perry, J. Schindelin, et al., "TrackMate: An open and extensible platform for single-particle tracking.", Methods, 2017.
  • [9] R. Reme, A. Newson, E. Angelini, J.-C. Olivo-Marin and T. Lagache, "Particle tracking in biological images with optical-flow enhanced kalman filtering", IEEE ISBI, 2024.
  • [10] M. Maška, V. Ulman, D. Svoboda, P. Matula, et al., "A benchmark for comparison of cell tracking algorithms", in Bioinformatics, 2014.
  • [11] R. Reme, A. Newson, E. Angelini, J.-C. Olivo-Marin and T. Lagache, "SINETRA: a Versatile Framework for Evaluating Single Neuron Tracking in Behaving Animals", IEEE ISBI, 2025.
  • [12] A. Genovesio, Z. Belhassine, and J.-C. Olivo-Marin, "Adaptive gating in Gaussian Bayesian multi-target tracking", IEEE ICIP, 2004.

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

byotrack-1.4.2.tar.gz (112.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

byotrack-1.4.2-py3-none-any.whl (151.1 kB view details)

Uploaded Python 3

File details

Details for the file byotrack-1.4.2.tar.gz.

File metadata

  • Download URL: byotrack-1.4.2.tar.gz
  • Upload date:
  • Size: 112.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for byotrack-1.4.2.tar.gz
Algorithm Hash digest
SHA256 bc44541e61ebc57122bd471b6b368ffa46f3a748c4c30ee562c4c0eb9268637d
MD5 4cf816d2486f191864db99f95f63e71d
BLAKE2b-256 ee826167d0569ad39872901bfb1ec8001a8e3c7bab0a7ef582f77c73a15f2932

See more details on using hashes here.

File details

Details for the file byotrack-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: byotrack-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 151.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for byotrack-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d6306265a5a4b1cf4fab52177b1b9cb7b48990761fd249562caf34d9eac5859
MD5 c88a67781661140128e8906ba6676b39
BLAKE2b-256 e7cfb521ba8a2bcd6b7cbd51b13d1115b5e94534208b10392e132910765ff2f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page