bacteria_density.graph module
- bacteria_density.graph.find_root(leaves, hint)[source]
Among all leaf nodes, finds the one closest to the provided hint point. It will define the root of the graph traversal to find the longest path.
- Parameters:
leaves (-) – A list of leaf nodes, where each node is a tuple (z, y, x).
hint (-) – A 2D point (y, x) to guide the root selection.
- Returns:
The leaf node closest to the hint point.
- Return type:
(tuple)
- bacteria_density.graph.get_leaves(bbox, graph)[source]
Identifies leaf nodes in the graph, which are nodes with only one connection.
- bacteria_density.graph.skeleton_to_undirected_graph(skel)[source]
Converts a 3D skeleton into an undirected graph representation. First pass: create edges for direct (6-face) neighbors only. Second pass: add diagonal edges (edge and corner) only when the two voxels are not already connected via a path of direct neighbors.
- Parameters:
skel (-) – A binary 3D numpy array representing the skeleton.
- Returns:
- A dictionary where keys are voxel coordinates (z, y, x) and
values are sets of neighboring voxel coordinates.
- Return type:
(dict)