motile_plugin.data_views.views.tree_view.tree_widget_utils

Functions

extract_sorted_tracks(→ pandas.DataFrame | None)

Extract the information of individual tracks required for constructing the pyqtgraph plot. Follows the same logic as the relabel_segmentation

find_root(→ int)

Function to find the root associated with a track by tracing its lineage

sort_track_ids(→ list[dict])

Sort track IDs such to maintain left-first order in the tree formed by parent-child relationships.

extract_lineage_tree(→ list[str])

Extract the entire lineage tree including horizontal relations for a given node

Module Contents

motile_plugin.data_views.views.tree_view.tree_widget_utils.extract_sorted_tracks(tracks: motile_plugin.data_model.Tracks, colormap: napari.utils.CyclicLabelColormap, prev_df: pandas.DataFrame | None = None) pandas.DataFrame | None

Extract the information of individual tracks required for constructing the pyqtgraph plot. Follows the same logic as the relabel_segmentation function from the Motile toolbox.

Args:
tracks (motile_plugin.core.Tracks): A tracks object containing a graph

to be converted into a dataframe.

colormap (napari.utils.CyclicLabelColormap): The colormap to use to

extract the color of each node from the track ID

prev_df (pd.DataFrame, Optional). Dataframe that holds the previous track_df, including the order of the tracks.

Returns:

pd.DataFrame | None: data frame with all the information needed to construct the pyqtgraph plot. Columns are: ‘t’, ‘node_id’, ‘track_id’, ‘color’, ‘x’, ‘y’, (‘z’), ‘index’, ‘parent_id’, ‘parent_track_id’, ‘state’, ‘symbol’, and ‘x_axis_pos’

motile_plugin.data_views.views.tree_view.tree_widget_utils.find_root(track_id: int, parent_map: dict) int

Function to find the root associated with a track by tracing its lineage

motile_plugin.data_views.views.tree_view.tree_widget_utils.sort_track_ids(track_list: list[dict], prev_df: pandas.DataFrame | None = None) list[dict]

Sort track IDs such to maintain left-first order in the tree formed by parent-child relationships. Used to determine the x-axis order of the tree plot.

Args:

track_list (list): List of dictionaries with ‘track_id’ and ‘parent_track_id’. prev_df (pd.DataFrame, Optional). Dataframe that holds the previous track_df, including the order of the tracks.

Returns:

list: Ordered list of track IDs for the x-axis.

motile_plugin.data_views.views.tree_view.tree_widget_utils.extract_lineage_tree(graph: networkx.DiGraph, node_id: str) list[str]

Extract the entire lineage tree including horizontal relations for a given node