Skip to content

Commit 6e81809

Browse files
anna-grimanna-grim
andauthored
refactor: removed adjust metrics option (#132)
Co-authored-by: anna-grim <[email protected]>
1 parent fa4fffd commit 6e81809

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed

src/segmentation_skeleton_metrics/skeleton_metric.py

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def __init__(
6666
anisotropy=(1.0, 1.0, 1.0),
6767
connections_path=None,
6868
fragments_pointer=None,
69-
preexisting_merges=None,
7069
save_merges=False,
7170
save_fragments=False,
7271
use_anisotropy=True,
@@ -97,9 +96,6 @@ def __init__(
9796
"swc_util.Reader" for documentation. Notes: (1) "anisotropy" is
9897
applied to these SWC files and (2) these SWC files are required
9998
for counting merges. The default is None.
100-
preexisting_merges : List[int], optional
101-
List of segment IDs that are known to contain a merge mistake. The
102-
default is None.
10399
save_merges: bool, optional
104100
Indication of whether to save fragments with a merge mistake. The
105101
default is None.
@@ -120,7 +116,6 @@ def __init__(
120116
self.anisotropy = anisotropy
121117
self.connections_path = connections_path
122118
self.output_dir = output_dir
123-
self.preexisting_merges = preexisting_merges
124119
self.save_merges = save_merges
125120
self.save_fragments = save_fragments
126121
self.use_anisotropy = use_anisotropy
@@ -506,11 +501,6 @@ def detect_merges(self):
506501
pbar.update(1)
507502
self.process_merge_sites()
508503

509-
# Adjust metrics (if applicable)
510-
if self.preexisting_merges:
511-
for key in self.graphs:
512-
self.adjust_metrics(key)
513-
514504
# Detect merges by finding ground truth graphs with common node labels
515505
for (key_1, key_2), label in self.find_label_intersections():
516506
self.process_merge(key_1, label, -1)
@@ -686,46 +676,7 @@ def process_merge_sites(self):
686676

687677
# Save results
688678
path = os.path.join(self.output_dir, "merge_sites.csv")
689-
self.merge_sites.to_csv(path, index=True)
690-
691-
def adjust_metrics(self, key):
692-
"""
693-
Adjusts the metrics of the graph associated with the given key by
694-
removing nodes corresponding to known merges and their corresponding
695-
subgraphs. Updates the total number of edges and run lengths in the
696-
graph.
697-
698-
Parameters
699-
----------
700-
key : str
701-
Unique identifier of the graph to adjust attributes that are are
702-
used to compute various metrics.
703-
704-
Returns
705-
-------
706-
None
707-
708-
"""
709-
visited = set()
710-
for label in self.preexisting_merges:
711-
try:
712-
label = self.label_handler.mapping[label]
713-
if label in self.graphs[key].get_labels():
714-
if label not in visited and label != 0:
715-
# Get component with label
716-
nodes = self.graphs[key].nodes_with_label(label)
717-
root = util.sample_once(list(nodes))
718-
719-
# Adjust metrics
720-
rl = self.graphs[key].run_length_from(root)
721-
self.graphs[key].run_length -= np.sum(rl)
722-
self.graphs[key].graph["n_edges"] -= len(nodes) - 1
723-
724-
# Update graph
725-
self.graphs[key].remove_nodes_from(nodes)
726-
visited.add(label)
727-
except:
728-
pass
679+
self.merge_sites.to_csv(path, index=True)
729680

730681
def find_label_intersections(self):
731682
"""

0 commit comments

Comments
 (0)