tracksdata.functional
Functional utilities for graph operations.
Functions:
-
to_napari_format
–Convert the subgraph of solution nodes to a napari-ready format.
to_napari_format
to_napari_format(graph: BaseGraph, shape: tuple[int, ...], solution_key: str = DEFAULT_ATTR_KEYS.SOLUTION, output_track_id_key: str = DEFAULT_ATTR_KEYS.TRACK_ID) -> tuple[GraphArrayView, pl.DataFrame, dict[int, int]]
Convert the subgraph of solution nodes to a napari-ready format.
This includes: - a labels layer with the solution nodes - a tracks layer with the solution tracks - a graph with the parent-child relationships for the solution tracks
IMPORTANT: This function will reset the track ids if they already exist.
Parameters:
-
graph
BaseGraph
) –The graph to convert.
-
shape
tuple[int, ...]
) –The shape of the labels layer.
-
solution_key
str
, default:SOLUTION
) –The key of the solution attribute.
-
output_track_id_key
str
, default:TRACK_ID
) –The key of the output track id attribute.
Returns:
-
tuple[GraphArrayView, DataFrame, dict[int, int]]
–- array_view: The array view of the solution graph.
- tracks_data: The tracks data as a polars DataFrame.
- dict_graph: A dictionary of parent -> child relationships.