Network flow based tracker with guided error correction
Project description
tracktour
tracktour
is a simple object tracker based on a network flow linear model. tracktour
takes a dataframe of detected objects and solves a linear program
(currently using Gurobi, but we will soon add an open source solver interface) to produce tracking results.
tracktour
is rapidly changing and its API will change without deprecation warnings.
About tracktour
tracktour
is a purely discrete-optimization-based tracker. It takes the coordinates of detected objects as input, and associates
these objects over time to create complete trajectories, including divisions. Tracktour's only parameter is k
- the number of
neighbours to consider for possible assignment in the next frame. Using this parameter and very simple distance based cost,
a candidate graph is created, and passed to Gurobi for solving. Once solved, the detected objects and edges that make up the tracks are
returned to the user for inspection.
Installation
tracktour
is available as a pip-installable Python package. Running pip install tracktour
in a virtual environment will install all
required dependencies, but you will need a separate Gurobi Optimizer installation (instructions here).
tracktour
is tested with all Python versions >=3.8.
Note - If you wish to visualize data with napari
(e.g. as per the Cell Tracking Challenge example), you will need to separately install it.
Support
Please feel free to open issues with feature requests, bug reports, questions on usage, etc.
Usage
The Tracker
object is the interface for producing tracking solutions. Below is a toy example with explicitly defined detections.
# define the coordinates of ten detections across three frames.
coords = [
(0, 50.0, 50.0),
(0, 40, 50),
(0, 30, 57),
(1, 50, 52),
(1, 38, 51),
(1, 29, 60),
(2, 52, 53),
(2, 37, 53),
(2, 28, 64),
]
coords = pd.DataFrame(coords, columns=["t", "y", "x"])
# initialize Tracker object
tracker = Tracker(
im_shape=(100, 100), # size of the image detections come from. Affects cost of detections appearing/disappearing
k_neighbours=2 # number of neighbours to consider for assignment in the next frame (default=10)
)
# solve
tracked = tracker.solve(coords)
The Tracked
object contains a copy of the detections, potentially reindexed, and a dataframe of edges that make up the solution.
Columns u
and v
in tracked_edges
are direct indices into tracked_detections
.
print(tracked.tracked_detections)
print(tracked.tracked_edges)
You may want to convert the solution into a networkx graph for easier manipulation.
solution_graph = tracked.as_nx_digraph()
See the toy example for a complete script, and the CTC example for visualization in napari
.
Extracting Detections
If you're starting from an image segmentation, you can use the get_im_centers
or extract_im_centers
functions.
If your segmentation is already loaded into a numpy array, use extract_im_centers
. The returned detections
DataFrame is ready for use with the Tracker
.
detections, min_t, max_t, corners = extract_im_centers(segmentation)
If your segmentation is in Cell Tracking Challenge format and lives in single tiffs per frame in a directory, use get_im_centers
. This will also return
the segmentation as a numpy array.
seg, detections, min_t, max_t, corners = get_im_centers('path/to/01_RES/')
Note: If using the ctc
utilities, detections will be extracted for you.
Cell Tracking Challenge
If you're working with Cell Tracking Challenge formatted datasets, see the example notebook for producing and visualizing tracks.
You can also use the CLI at the command-line to extract detections, run tracktour, and save output in CTC format.
# run tracktour with k-neighbours=8
$ tracktour ctc /path/to/seg/ /path/to/save/ -k 8
Note: Tracktour was recently submitted to the Cell Tracking Challenge. To use the submission version specifically, install tracktour==0.0.4
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tracktour-0.0.5rc1.tar.gz
.
File metadata
- Download URL: tracktour-0.0.5rc1.tar.gz
- Upload date:
- Size: 13.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc18073f0a5dba2bc47a9b4b3565b79cc720fece28b9e26263ec8ea5a9687c00 |
|
MD5 | e70b449a3b15d5ca9490bc9026db20db |
|
BLAKE2b-256 | 0695b2b49e43662568ea7aa8d49196b8ff1ab3076b9cc8207643a0d0d83ecce0 |
File details
Details for the file tracktour-0.0.5rc1-py3-none-any.whl
.
File metadata
- Download URL: tracktour-0.0.5rc1-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fda2b7d8a7ef120ecf0fe44379ae7401bf54386eb9abe293fa7feda410664e53 |
|
MD5 | e8adb7e69d4c44782a69da1906cb0ba7 |
|
BLAKE2b-256 | 63692b78e7391c0abb28e84192d7ed4814096d0f0beeb7b88f1a9a72c24c08ef |