traccuracy.utils

Module Contents

Functions

get_equivalent_skip_edge(→ list[collections.abc.Hashable])

Get path matched_src ->...-> matched_dst equivalent to skip_src -> skip_dst.

get_corrected_division_graphs_with_delta(...)

Returns copies of graphs with divisions corrected.

export_graphs_to_geff(→ None)

Export annotated tracking graphs as geffs along with a summary of traccuracy results

save_results_json(→ None)

Save a list of results to a traccuracy export json

traccuracy.utils.get_equivalent_skip_edge(skip_other_matched: traccuracy.matchers._matched.Matched, skip_src: collections.abc.Hashable, skip_dst: collections.abc.Hashable, matched_src: collections.abc.Hashable, matched_dst: collections.abc.Hashable) list[collections.abc.Hashable][source]

Get path matched_src ->...-> matched_dst equivalent to skip_src -> skip_dst.

A skip edge skip_src -> skip_dst is equivalent to a path connecting matched_src and matched_dst if:

  • skip_src is a valid match for matched_src,

  • skip_dst is a valid match for matched_dst,

  • matched_src is an ancestor of matched_dst (regardless of intervening nodes) AND

  • all nodes on the path matched_src ->...-> matched_dst have no valid matches in

    skip_other_matched.

Parameters:
  • skip_other_matched (traccuracy.matchers._base.Matched) – Matched object mapping skip nodes to other nodes

  • skip_src (Hashable) – ID of source node of skip edge

  • skip_dst (Hashable) – ID of destination node of skip edge

  • matched_src (Hashable) – matched node of skip_src

  • matched_dst (Hashable) – matched node of skip_dst

Returns:

path from matched_src to matched_dst, or empty list if no such path.

Return type:

list[Hashable]

traccuracy.utils.get_corrected_division_graphs_with_delta(matched: traccuracy.matchers._matched.Matched, frame_buffer: int = 0, relax_skip_edges: bool = False) tuple[traccuracy._tracking_graph.TrackingGraph, traccuracy._tracking_graph.TrackingGraph][source]

Returns copies of graphs with divisions corrected.

All divisions corrected by a frame_buffer value less than or equal to the given frame buffer are marked as TP_DIV.

Parameters:
  • matched (traccuracy.matchers._base.Matched) – Matched object for set of GT and Pred data. Must be annotated with division events.

  • frame_buffer (int) – Maximum frame buffer to use for division correction

  • relax_skip_edges (bool) – If True, will allow divisions that incorporate skip edges from parent to daughter

Returns:

Tuple of corrected

GT and Pred graphs

Return type:

tuple[traccuracy.TrackingGraph, traccuracy.TrackingGraph]

traccuracy.utils.export_graphs_to_geff(out_zarr: str, matched: traccuracy.matchers._matched.Matched, results: list[traccuracy.metrics._results.Results] | list[dict[str, Any]], target_frame_buffer: int = 0) None[source]

Export annotated tracking graphs as geffs along with a summary of traccuracy results

Output file structure: out_zarr.zarr/ ├── gt.geff ├── pred.geff └── traccuracy-results.json

Parameters:
  • out_zarr (str) – Path to output zarr

  • matched (traccuracy.matchers._base.Matched) – Matched object containing annotated TrackingGraphs

  • results (list[traccuracy.metrics._results.Results] | list[dict[str, Any]) – List of Results output by Metric.compute OR results objects as dictionary as returned by run_metrics

  • target_frame_buffer (int, optional) – If divisions are annotated, target_frame_buffer can be used to run get_corrected_divisions_with_delta in order to provide division annotations for a specific frame buffer. Defaults to 0.

Raises:
  • ValueError – matched argument must be an instance of Matched

  • ValueError – results argument must be a list of Results or dictionary objects

  • ValueError – Zarr already exists at out_zarr

  • ValueError – Requested target frame buffer {target_frame_buffer} exceeds computed ” “frame buffer {max_frame_buffer}

traccuracy.utils.save_results_json(results: list[traccuracy.metrics._results.Results] | list[dict[str, Any]], out_path: str) None[source]

Save a list of results to a traccuracy export json

Parameters:
  • results (list[traccuracy.metrics._results.Results] | list[dict[str, Any]) – List of either results dictionaries or results objects

  • out_path (str) – Path to save json file

Raises:
  • ValueError – out_path already exists

  • ValueError – results argument must be a list of Results objects or dictionaries

  • ValueError – results argument must be a list