Modular, ROI-based centroid tracking for behavioural assays. anytrack turns a
recorded multi-arena video (plus a per-frame timing CSV) into per-fly trajectories
and kinematics, with a fast streaming pipeline, batch processing, quality-control
reports, and optional odor-port detection.
Status: active development (
0.x). The classical tracking pipeline is feature-complete and validated; pose estimation (SLEAP) is planned for 0.3.0. The0.xline means the API/CLI may still change between minor versions.
Given an AVI (or MP4/MOV) of several circular arenas filmed from above and a CSV of
per-frame timestamps, anytrack:
- detects each arena (ROI) as a Hough circle,
- models a per-arena background,
- detects the fly each frame (background subtraction → arena-disk mask → threshold → contour → centroid),
- links detections into a trajectory with a Kalman-gated tracker,
- computes kinematics from the real per-frame time intervals, and
- writes tracks to Parquet/CSV — optionally with a QC report and odor-port distance.
It decodes each video once and streams cropped frames to parallel workers, and it can process a whole directory of videos concurrently.
Requires Python ≥ 3.10 and FFmpeg on your PATH (used for decoding).
# from a clone of the repo, with uv (https://docs.astral.sh/uv/)
uv venv
uv pip install -e .Optional extras: anytrack[pose] (SLEAP label/export bridge), anytrack[sam]
(Segment-Anything odor-port backend), anytrack[docs] (build the docs site).
# one video (timing CSV defaults to <video>.csv)
anytrack run --video /data/expt/localsearch_2026-05-28.avi
# a whole directory, 3 videos at a time, with a QC report
anytrack run --video /data/expt/ --concurrency 3 --qc
# preflight only: validate inputs + print the plan, decode nothing
anytrack run --video /data/expt/ --dry-runanytrack is a subcommand dispatcher — anytrack <cmd> routes to anytrack-<cmd>
(e.g. anytrack run → anytrack-run). Run anytrack with no arguments to list
commands, or anytrack <cmd> --help for options. The GUI is anytrack gui.
Key commands: run, validate, qc, bg, roi, crop-export, bench,
label, train, gui, debug, arena-debug.
- Video: one file per recording; several arenas per frame is expected.
- Timing CSV (
<video>.csvby default): aframecolumn plus eitherdt_s(seconds since the previous frame) ortimestamp_s(absolute seconds).
Full documentation — installation, the pipeline explained, CLI and configuration reference, output formats, and the GUIs — is published at:
https://fmi-basel.github.io/gfelsenb-anytrack/
Build it locally with uv pip install -e '.[docs]' && mkdocs serve.
- Tests:
uv run python -m pytest(usepython -m pytest, notpytest). - Branches: work happens on
dev;mainis the released branch. See the development guide.
MIT © 2026 Dennis Goldschmidt, Friedrich Miescher Institute for Biomedical Research (FMI).