Skip to main content

Network flow based tracker with guided error correction

Project description

tracktour

License PyPI Python Version CI

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.

Usage

The Tracker object is the interface for producing tracking solutions. Below is a toy example with explicitly defined detections.

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()

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/')

CLI Tool - Cell Tracking Challenge

If you're working with Cell Tracking Challenge formatted datasets, you can use the CLI to extract detections, run tracktour, and save output in CTC format.

$ tracktour ctc /path/to/seg/ /path/to/save/ -k 8

Support

Please feel free to open issues with feature requests, bug reports, questions on usage, etc.

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

tracktour-0.0.4.post3.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

tracktour-0.0.4.post3-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file tracktour-0.0.4.post3.tar.gz.

File metadata

  • Download URL: tracktour-0.0.4.post3.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for tracktour-0.0.4.post3.tar.gz
Algorithm Hash digest
SHA256 edd98e19b7a3d631275234a16b8658262a6c71438aed73a083182edfa11b0a0d
MD5 695c8da24ad293506f71c1af82116c06
BLAKE2b-256 a544dee4440b3579bed216a9d7b5be3f301cb3f514de886dc0363324ee7aa04f

See more details on using hashes here.

Provenance

File details

Details for the file tracktour-0.0.4.post3-py3-none-any.whl.

File metadata

File hashes

Hashes for tracktour-0.0.4.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b578b8d8a19ffb9cc817967a06e4328df6b905e6d8bad2bb684a916c45ea5d
MD5 f6649003ec6d6e101973cd83b93b4752
BLAKE2b-256 f90428122db9289ac980639fd960f57bc4ad6705a01b12d5846735911bc9848d

See more details on using hashes here.

Provenance

Supported by

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