napari_track_edit.data_views.views.tree_view.tree_widget_utils
Functions
|
Group nodes into tracklets by BFS, cutting at division nodes. |
|
Extract the information of individual tracks required for constructing the tree |
|
Function to find the root associated with a track by tracing its lineage |
|
Order a list of root nodes by the previous order, insert missing orders immediately |
|
Extract the lineage tree plot order of the tracklet_ids on the graph, ensuring that |
|
Extract the entire lineage tree including horizontal relations for a given node |
|
Extract the regionprops feature display names currently activated on Tracks. |
Module Contents
- napari_track_edit.data_views.views.tree_view.tree_widget_utils.get_tracklets(parent_to_children: dict[int, list[int]], child_to_parent: dict[int, int], node_ids: list[int], dividing_node_set: set[int], node_to_track_id: dict[int, int]) list[set[int]]
Group nodes into tracklets by BFS, cutting at division nodes.
A tracklet is a maximal linear segment of the track graph — it does not cross a division point. The returned sets contain node IDs; callers are responsible for sorting by time if needed.
- Parameters:
parent_to_children – maps each parent node_id to its list of child node_ids.
child_to_parent – maps each child node_id to its single parent node_id.
node_ids – all node IDs to partition.
dividing_node_set – set of node IDs that have ≥2 children (division nodes).
node_to_track_id – maps each node_id to its pre-computed tracklet ID.
- Returns:
List of sets, one set of node IDs per tracklet.
- napari_track_edit.data_views.views.tree_view.tree_widget_utils.extract_sorted_tracks(tracks: funtracks.data_model.Tracks, colormap: napari_track_edit.data_views.colormap.TrackColormap, prev_axis_order: list[int] | None = None) pandas.DataFrame | None
Extract the information of individual tracks required for constructing the tree plot. Follows the same logic as the relabel_segmentation function from the Motile toolbox.
- Parameters:
tracks (funtracks.data_model.Tracks) – A tracks object containing a graph to be converted into a dataframe.
colormap (TrackColormap) – Colors tree-view nodes per node via colormap.get_colors(node_ids), so the tree follows whichever feature the colormap is coloring by, like every other view.
prev_axis_order (list[int], Optional)
- Returns:
data frame with all the information needed to construct the tree plot. Columns are: ‘t’, ‘node_id’, ‘track_id’, ‘color’, ‘x’, ‘y’, (‘z’), ‘index’, ‘parent_id’, ‘parent_track_id’, ‘state’, ‘symbol’, and ‘x_axis_pos’
- Return type:
pd.DataFrame | None
- napari_track_edit.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
- napari_track_edit.data_views.views.tree_view.tree_widget_utils.order_roots_by_prev(prev_axis_order: list[int], roots: list[int]) list[int]
Order a list of root nodes by the previous order, insert missing orders immediately to the right of the closest smaller numerical element.
- Parameters:
prev_axis_order (list[int]) – the previous order of root nodes.
roots (list[int]) – the to be sorted list of root nodes.
- Returns:
sorted list of root nodes.
- Return type:
list[int]
- napari_track_edit.data_views.views.tree_view.tree_widget_utils.get_sorted_track_ids(node_ids: list[int], node_to_track_id: dict, child_to_parent: dict[int, int], parent_to_children: dict[int, list[int]], prev_axis_order: list[int] | None = None) list[Any]
Extract the lineage tree plot order of the tracklet_ids on the graph, ensuring that each tracklet_id is placed in between its daughter tracklet_ids and adjacent to its parent track id.
- Parameters:
node_ids – list of all node IDs.
node_to_track_id (dict) – precomputed mapping from node_id to track_id.
child_to_parent – precomputed mapping from child node_id to parent node_id.
parent_to_children – precomputed mapping from parent node_id to child node_ids.
prev_axis_order (list[int], Optional)
- Returns:
list[Any] of ordered tracklet_ids.
- napari_track_edit.data_views.views.tree_view.tree_widget_utils.extract_lineage_tree(graph: tracksdata.GraphView, node_id: str) list[str]
Extract the entire lineage tree including horizontal relations for a given node
- napari_track_edit.data_views.views.tree_view.tree_widget_utils.get_features_from_tracks(tracks: funtracks.data_model.Tracks | None = None, features_to_ignore: list[str] | None = None) list[str]
Extract the regionprops feature display names currently activated on Tracks.
- Parameters:
tracks (Tracks | None) – the Tracks instance to extract features from
- Returns:
list of the feature names to plot, or an empty list if tracks is None
- Return type:
features_to_plot (list[str])