Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"networkx",
"numpy",
"pandas",
"s3fs==2025.6.0",
"s3fs",
"scikit-image",
"tensorstore",
"tifffile",
Expand Down
6 changes: 4 additions & 2 deletions src/segmentation_skeleton_metrics/skeleton_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ def __call__(self, gt_graphs, results):
for name, graph in gt_graphs.items():
# Compute result
if results["# Splits"][name] > 0:
rate = graph.labeled_run_length / results["# Splits"][name]
rl = util.compute_segmented_run_length(graph, results)
rate = rl / results["# Splits"][name]
else:
rate = np.nan
new_results[name] = round(rate, 2)
Expand Down Expand Up @@ -766,7 +767,8 @@ def __call__(self, gt_graphs, results):
for name, graph in gt_graphs.items():
# Compute result
if results["# Merges"][name] > 0:
rate = graph.labeled_run_length / results["# Merges"][name]
rl = util.compute_segmented_run_length(graph, results)
rate = rl / results["# Merges"][name]
else:
rate = np.nan
new_results[name] = round(rate, 2)
Expand Down
21 changes: 21 additions & 0 deletions src/segmentation_skeleton_metrics/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,27 @@ def compute_weighted_avg(df, column_name):
return (values * weights).sum() / weights.sum()


def compute_segmented_run_length(graph, results):
"""
Computes the run length of a graph that was segmented.

Parameters
----------
graph : LabeledGraph
Graph to be evaluated.
results : pandas.DataFrame
Data frame containing skeleton metrics

Returns
-------
float
Run length of a graph that was segmented.
"""
omit_run_length = graph.run_length * results["% Omit"] / 100
split_run_length = graph.run_length * results["% Split"] / 100
return graph.run_length - omit_run_length - split_run_length


def get_segment_id(filename):
"""
Gets the segment ID correspionding to the given filename, assuming that
Expand Down
Loading