Skip to content

Commit a646ca5

Browse files
committed
Added/Updated docstrings
1 parent 504351f commit a646ca5

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

flamingo_tools/segmentation/postprocessing.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,17 @@ def downscaled_centroids(
319319
return new_array
320320

321321

322-
def graph_connected_components(coords, min_edge_distance, min_component_length):
322+
def graph_connected_components(coords: dict, min_edge_distance: float, min_component_length: int):
323+
"""Create a list of IDs for each connected component of a graph.
324+
325+
Args:
326+
coords: Dictionary containing label IDs as keys and their position as value.
327+
min_edge_distance: Minimal edge distance between graph nodes to create an edge between nodes.
328+
min_component_length: Minimal length of nodes of connected component. Filtered out if lower.
329+
330+
Returns:
331+
List of dictionary keys of connected components.
332+
"""
323333
graph = nx.Graph()
324334
for num, pos in coords.items():
325335
graph.add_node(num, pos=pos)
@@ -423,7 +433,7 @@ def label_components_sgn(
423433
min_edge_distance: float = 30,
424434
iterations_erode: Optional[int] = None,
425435
) -> List[int]:
426-
"""Label components using graph connected components.
436+
"""Label SGN components using graph connected components.
427437
428438
Args:
429439
table: Dataframe of segmentation table.
@@ -496,6 +506,16 @@ def components_ihc(
496506
min_component_length: int = 50,
497507
min_edge_distance: float = 30,
498508
):
509+
"""Create connected components for IHC segmentation.
510+
511+
Args:
512+
table: Dataframe of segmentation table.
513+
min_component_length: Minimal length for filtering out connected components.
514+
min_edge_distance: Minimal distance in micrometer between points to create edges for connected components.
515+
516+
Returns:
517+
Subgraph components as lists of label_ids of dataframe.
518+
"""
499519
centroids = list(zip(table["anchor_x"], table["anchor_y"], table["anchor_z"]))
500520
labels = [int(i) for i in list(table["label_id"])]
501521
coords = {}
@@ -517,10 +537,8 @@ def label_components_ihc(
517537
Args:
518538
table: Dataframe of segmentation table.
519539
min_size: Minimal number of pixels for filtering small instances.
520-
threshold_erode: Threshold of column value after erosion step with spatial statistics.
521540
min_component_length: Minimal length for filtering out connected components.
522541
min_edge_distance: Minimal distance in micrometer between points to create edges for connected components.
523-
iterations_erode: Number of iterations for erosion, normally determined automatically.
524542
525543
Returns:
526544
List of component label for each point in dataframe. 0 - background, then in descending order of size
@@ -555,15 +573,13 @@ def postprocess_ihc_seg(
555573
min_component_length: int = 50,
556574
min_edge_distance: float = 30,
557575
) -> pd.DataFrame:
558-
"""Postprocessing SGN segmentation of cochlea.
576+
"""Postprocessing IHC segmentation of cochlea.
559577
560578
Args:
561579
table: Dataframe of segmentation table.
562580
min_size: Minimal number of pixels for filtering small instances.
563-
threshold_erode: Threshold of column value after erosion step with spatial statistics.
564581
min_component_length: Minimal length for filtering out connected components.
565582
min_edge_distance: Minimal distance in micrometer between points to create edges for connected components.
566-
iterations_erode: Number of iterations for erosion, normally determined automatically.
567583
568584
Returns:
569585
Dataframe with component labels.

0 commit comments

Comments
 (0)