Skip to content

Commit bed292a

Browse files
anna-grimanna-grim
andauthored
Feat report summary (#160)
* doc: skeleton metrics and swc_loading * feat: fix label misalignments * doc: skeletongraph and dataloading * refactor: improved doc --------- Co-authored-by: anna-grim <[email protected]>
1 parent 27fb2bf commit bed292a

File tree

11 files changed

+227
-81
lines changed

11 files changed

+227
-81
lines changed

demo/merged_segment_ids.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

demo/results-overview.txt

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,82 @@ Average Results...
1313
Total Results...
1414
# Splits: 27
1515
# Merges: 0
16+
Average Results...
17+
# Splits: 7.2780
18+
# Merges: nan
19+
% Split Edges: 1.1997
20+
% Omit Edges: 0.9740
21+
% Merged Edges: 0.0000
22+
ERL: 187.0877
23+
Normalized ERL: 0.4006
24+
Edge Accuracy: 97.8253
25+
Split Rate: 116.9354
26+
Merge Rate: nan
27+
28+
Total Results...
29+
# Splits: 27.0
30+
# Merges: 0.0
31+
32+
Average Results...
33+
# Splits: 7.2780
34+
# Merges: nan
35+
% Split Edges: 1.1997
36+
% Omit Edges: 0.9740
37+
% Merged Edges: 0.0000
38+
ERL: 187.0877
39+
Normalized ERL: 0.4006
40+
Edge Accuracy: 97.8253
41+
Split Rate: 116.9354
42+
Merge Rate: nan
43+
44+
Total Results...
45+
# Splits: 27.0
46+
# Merges: 0.0
47+
48+
Average Results...
49+
# Splits: 7.2780
50+
# Merges: nan
51+
% Split Edges: 1.1997
52+
% Omit Edges: 0.9740
53+
% Merged Edges: 0.0000
54+
ERL: 187.0877
55+
Normalized ERL: 0.4006
56+
Edge Accuracy: 97.8253
57+
Split Rate: 116.9354
58+
Merge Rate: nan
59+
60+
Total Results...
61+
# Splits: 27.0
62+
# Merges: 0.0
63+
64+
Average Results...
65+
# Splits: 7.2780
66+
# Merges: nan
67+
% Split Edges: 1.1997
68+
% Omit Edges: 0.9740
69+
% Merged Edges: 0.0000
70+
ERL: 187.0877
71+
Normalized ERL: 0.4006
72+
Edge Accuracy: 97.8253
73+
Split Rate: 116.9354
74+
Merge Rate: nan
75+
76+
Total Results...
77+
# Splits: 27.0
78+
# Merges: 0.0
79+
80+
Average Results...
81+
# Splits: 7.2780
82+
# Merges: nan
83+
% Split Edges: 1.1997
84+
% Omit Edges: 0.9740
85+
% Merged Edges: 0.0000
86+
ERL: 187.0877
87+
Normalized ERL: 0.4006
88+
Edge Accuracy: 97.8253
89+
Split Rate: 116.9354
90+
Merge Rate: nan
91+
92+
Total Results...
93+
# Splits: 27.0
94+
# Merges: 0.0

demo/results.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
,SWC Run Length,# Splits,# Merges,% Split Edges,% Omit Edges,% Merged Edges,ERL,Normalized ERL,Edge Accuracy,Split Rate,Merge Rate
22
SNT_Data-002,84.0837616185713,0.0,,0.0,0.0,0.0,84.08,1.0,100.0,,
33
SNT_Data-035,163.37074041968341,0.0,,0.0,0.0,0.0,163.37,1.0,100.0,,
4-
SNT_Data-037,214.98055903143316,1.0,,0.9803921568627451,0.9803921568627451,0.0,40.27,0.1873,98.04,62.82,
5-
SNT_Data-038,254.78664303157612,1.0,,0.8264462809917356,5.785123966942149,0.0,146.36,0.5744,93.39,224.52,
4+
SNT_Data-037,214.98055903143316,1.0,,0.9803921568627451,0.0,0.0,184.57,0.8585,99.02,211.98,
5+
SNT_Data-038,254.78664303157612,1.0,,0.8264462809917356,0.0,0.0,144.38,0.5667,99.17,251.79,
66
SNT_Data-041,230.16780853555437,3.0,,2.830188679245283,0.0,0.0,45.66,0.1984,97.17,51.2,
77
SNT_Data-043,105.95635789438495,1.0,,1.9230769230769231,1.9230769230769231,0.0,30.3,0.286,96.15,51.19,
88
SNT_Data-051,106.56843799568803,0.0,,0.0,0.0,0.0,106.57,1.0,100.0,,
99
SNT_Data-052,633.5729425811579,5.0,,1.3651877133105803,2.3890784982935154,0.0,293.17,0.4627,96.25,103.53,
10-
SNT_Data-053,1547.4466172913558,14.0,,1.3123359580052494,0.7874015748031497,0.0,217.71,0.1407,97.9,92.8,
10+
SNT_Data-053,1547.4466172913558,14.0,,1.3123359580052494,0.5249343832020997,0.0,212.3,0.1372,98.16,103.02,
1111
SNT_Data-062,227.24329460444093,2.0,,0.9009009009009009,4.504504504504505,0.0,116.9,0.5144,94.59,105.19,
1212
SNT_Data-074,80.17991450259146,0.0,,0.0,0.0,0.0,80.18,1.0,100.0,,

demo/results.xls

-5.5 KB
Binary file not shown.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dynamic = ["version"]
1616

1717
dependencies = [
1818
"boto3",
19-
'cloud-volume[crackle,seg-codecs]',
2019
"google-cloud-storage",
2120
"networkx",
2221
"numpy",

src/segmentation_skeleton_metrics/data_handling/graph_loading.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def load_groundtruth(self, swc_pointer, label_mask):
9393

9494
def load_fragments(self, swc_pointer, gt_graphs):
9595
"""
96-
Load fragment graphs (predicted skeletons).
96+
Loads fragment graphs (predicted skeletons).
9797
9898
Parameters
9999
----------
@@ -129,7 +129,7 @@ def load_fragments(self, swc_pointer, gt_graphs):
129129
# --- Helpers ---
130130
def get_all_node_labels(self, graphs):
131131
"""
132-
Get the set of unique node labels across all given graphs.
132+
Gets the set of unique node labels across all given graphs.
133133
134134
Parameters
135135
----------
@@ -138,7 +138,7 @@ def get_all_node_labels(self, graphs):
138138
139139
Returns
140140
-------
141-
labels : Set[int]
141+
node_labels : Set[int]
142142
Unique node labels across all graphs.
143143
"""
144144
node_labels = set()
@@ -149,7 +149,7 @@ def get_all_node_labels(self, graphs):
149149

150150
class GraphLoader:
151151
"""
152-
A class that builds a graphs from SWC files.
152+
A class that builds graphs from SWC files.
153153
"""
154154

155155
def __init__(
@@ -176,8 +176,8 @@ def __init__(
176176
label_mask : ImageReader, optional
177177
Predicted segmentation mask.
178178
selected_ids : Set[int], optional
179-
Only SWC files with a name contained in this set are read.
180-
Default is None.
179+
Only SWC files with a name contained in this set are read. Default
180+
is None.
181181
use_anisotropy : bool, optional
182182
Indication of whether coordinates in SWC files should be converted
183183
from physical to image coordinates using the given anisotropy.
@@ -210,7 +210,7 @@ def run(self, swc_pointer):
210210
211211
Returns
212212
-------
213-
dict
213+
graphs : Dict[str, SkeletonGraph]
214214
Dictionary where the keys are unique identifiers (i.e. filenames
215215
of SWC files) and values are the corresponding SkeletonGraph.
216216
"""
@@ -233,7 +233,7 @@ def _build_graphs_from_swcs(self, swc_pointer):
233233
234234
Returns
235235
-------
236-
dict
236+
graphs : Dict[str, SkeletonGraph]
237237
Dictionary where the keys are unique identifiers (i.e. SWC
238238
filenames) and values are the corresponding SkeletonGraphs.
239239
"""
@@ -243,11 +243,11 @@ def _build_graphs_from_swcs(self, swc_pointer):
243243
pbar = tqdm(total=len(swc_dicts), desc="Build Graphs")
244244

245245
# Main
246-
graph_dict = dict()
246+
graphs = dict()
247247
if len(swc_dicts) > 10 ** 4:
248248
while len(swc_dicts) > 0:
249249
swc_dict = swc_dicts.pop()
250-
graph_dict.update(self.to_graph(swc_dict))
250+
graphs.update(self.to_graph(swc_dict))
251251
if self.verbose:
252252
pbar.update(1)
253253
else:
@@ -260,10 +260,10 @@ def _build_graphs_from_swcs(self, swc_pointer):
260260

261261
# Store results
262262
for process in as_completed(processes):
263-
graph_dict.update(process.result())
263+
graphs.update(process.result())
264264
if self.verbose:
265265
pbar.update(1)
266-
return graph_dict
266+
return graphs
267267

268268
def to_graph(self, swc_dict):
269269
"""
@@ -278,7 +278,7 @@ def to_graph(self, swc_dict):
278278
279279
Returns
280280
-------
281-
SkeletonGraph
281+
Dict[str, SkeletonGraph]
282282
Graph built from an SWC file.
283283
"""
284284
# Initialize graph
@@ -307,7 +307,7 @@ def _init_graph(self, swc_dict):
307307
308308
Returns
309309
-------
310-
SkeletonGraph
310+
graph : SkeletonGraph
311311
An initialized LabeledGraph or FragmentGraph instance with voxel
312312
data, filename, and node count set.
313313
"""
@@ -399,7 +399,7 @@ def get_patch_labels(self, graph, nodes):
399399
400400
Returns
401401
-------
402-
dict
402+
node_to_label : Dict[int, int]
403403
Dictionary that maps node IDs to their respective labels.
404404
"""
405405
bbox = graph.get_bbox(nodes)
@@ -578,7 +578,7 @@ def build_labels_graph(self, connections_path):
578578
579579
Returns
580580
-------
581-
LabeledGraph
581+
labels_graph : networkx.Graph
582582
Graph with nodes that represent labels and edges are based on the
583583
connections read from the "connections_path".
584584
"""
@@ -627,14 +627,14 @@ def get_class(self, label):
627627
628628
Returns
629629
-------
630-
List[int] or Set[int]
630+
List[int]
631631
Labels corresponding to the class.
632632
"""
633633
return self.inverse_mapping[label] if self.use_mapping() else [label]
634634

635635
def use_mapping(self):
636636
"""
637-
Check whether mappings have been initialized.
637+
Checks whether mappings have been initialized.
638638
639639
Returns
640640
-------

src/segmentation_skeleton_metrics/data_handling/skeleton_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def get_bbox(self, nodes):
398398
399399
Returns
400400
-------
401-
dict
401+
Dict[str, Tuple[int]
402402
Dictionary containing the bounding box coordinates:
403403
- "min": minimum voxel coordinates along each axis.
404404
- "max": maximum voxel coordinates along each axis.
@@ -435,7 +435,7 @@ def get_radius(self):
435435

436436
class FragmentGraph(SkeletonGraph):
437437
"""
438-
Subclass of SkeletonGraph for skeletons derived from the segmentation.
438+
Subclass of SkeletonGraph for skeletons obtained from a segmentation.
439439
"""
440440

441441
def __init__(

0 commit comments

Comments
 (0)