@@ -47,7 +47,6 @@ class SkeletonMetric:
4747 (6) Edge accuracy
4848 (7) Expected Run Length (ERL)
4949 (8) Normalized ERL
50-
5150 """
5251
5352 def __init__ (
@@ -79,30 +78,25 @@ def __init__(
7978 Path to directory wehere results are written.
8079 anisotropy : Tuple[float], optional
8180 Image to physical coordinate scaling factors applied to SWC files
82- stored at "fragments_pointer". The default is (1.0, 1.0, 1.0).
81+ stored at "fragments_pointer". Default is (1.0, 1.0, 1.0).
8382 connections_path : str, optional
8483 Path to a txt file containing pairs of segment IDs that represents
85- fragments that were merged. The default is None.
84+ fragments that were merged. Default is None.
8685 fragments_pointer : Any, optional
8786 Pointer to SWC files corresponding to "label_mask", see
8887 "swc_util.Reader" for documentation. Notes: (1) "anisotropy" is
8988 applied to these SWC files and (2) these SWC files are required
90- for counting merges. The default is None.
89+ for counting merges. Default is None.
9190 save_merges: bool, optional
92- Indication of whether to save fragments with a merge mistake. The
93- default is None.
91+ Indication of whether to save fragments with a merge mistake.
92+ Default is None.
9493 save_fragments : bool, optional
9594 Indication of whether to save fragments that project onto each
96- ground truth skeleton. The default is False.
95+ ground truth skeleton. Default is False.
9796 valid_labels : set[int], optional
9897 Segment IDs that can be assigned to nodes. This argument accounts
9998 for segments that were been removed due to some type of filtering.
100- The default is None.
101-
102- Returns
103- -------
104- None
105-
99+ Default is None.
106100 """
107101 # Instance attributes
108102 self .anisotropy = anisotropy
@@ -152,11 +146,6 @@ def load_groundtruth(self, swc_pointer, label_mask):
152146 Pointer to ground truth SWC files.
153147 label_mask : ImageReader
154148 Predicted segmentation mask.
155-
156- Returns
157- -------
158- None
159-
160149 """
161150 # Build graphs
162151 print ("\n (1) Load Ground Truth" )
@@ -179,11 +168,6 @@ def load_fragments(self, swc_pointer):
179168 ----------
180169 swc_pointer : Any
181170 Pointer to predicted SWC files if provided.
182-
183- Returns
184- -------
185- None
186-
187171 """
188172 print ("\n (2) Load Fragments" )
189173 if swc_pointer :
@@ -202,15 +186,6 @@ def set_fragment_ids(self):
202186 """
203187 Sets the "fragment_ids" attribute by extracting unique segment IDs
204188 from the "fragment_graphs" keys.
205-
206- Parameters
207- ----------
208- None
209-
210- Returns
211- -------
212- None
213-
214189 """
215190 self .fragment_ids = set ()
216191 for key in self .fragment_graphs :
@@ -220,15 +195,10 @@ def get_all_node_labels(self):
220195 """
221196 Gets the set of unique node labels from all graphs in "self.graphs".
222197
223- Parameters
224- ----------
225- None
226-
227198 Returns
228199 -------
229200 Set[int]
230201 Set of unique node labels from all graphs.
231-
232202 """
233203 all_labels = set ()
234204 inverse_bool = self .label_handler .use_mapping ()
@@ -246,16 +216,15 @@ def get_node_labels(self, key, inverse_bool=False):
246216 ----------
247217 key : str
248218 Unique identifier of graph from which to retrieve the node labels.
249- inverse_bool : bool
219+ inverse_bool : bool, optional
250220 Indication of whether to return the labels (from "labels_mask") or
251221 a remapping of these labels in the case when "connections_path" is
252- provided. The default is False.
222+ provided. Default is False.
253223
254224 Returns
255225 -------
256226 Set[int]
257227 Labels corresponding to nodes in the graph identified by "key".
258-
259228 """
260229 if inverse_bool :
261230 output = set ()
@@ -269,15 +238,6 @@ def init_writers(self):
269238 """
270239 Initializes "self.merge_writer" attribute by setting up a directory for
271240 output files and creating ZIP files for each graph in "self.graphs".
272-
273- Parameters
274- ----------
275- None
276-
277- Returns
278- -------
279- None
280-
281241 """
282242 # Fragments writer
283243 if self .save_fragments :
@@ -303,15 +263,6 @@ def init_writers(self):
303263 def run (self ):
304264 """
305265 Computes skeleton-based metrics.
306-
307- Parameters
308- ----------
309- None
310-
311- Returns
312- -------
313- None
314-
315266 """
316267 print ("\n (3) Evaluation" )
317268
@@ -349,15 +300,6 @@ def detect_splits(self):
349300 """
350301 Detects split and omit edges in the labeled ground truth graphs, then
351302 removes omit nodes.
352-
353- Parameters
354- ----------
355- None
356-
357- Returns
358- -------
359- None
360-
361303 """
362304 pbar = tqdm (total = len (self .graphs ), desc = "Split Detection" )
363305 with ProcessPoolExecutor (max_workers = 4 ) as executor :
@@ -391,15 +333,6 @@ def detect_merges(self):
391333 """
392334 Detects merges in the predicted segmentation, then deletes node and
393335 edges in "self.graphs" that correspond to a merge.
394-
395- Parameters
396- ----------
397- None
398-
399- Returns
400- -------
401- None
402-
403336 """
404337 # Initilizations
405338 self .n_merged_edges = {key : 0 for key in self .graphs }
@@ -437,11 +370,6 @@ def count_merges(self, key, kdtree):
437370 Unique identifier of graph to detect merges.
438371 kdtree : scipy.spatial.KDTree
439372 A KD-tree built from voxels in graph corresponding to "key".
440-
441- Returns
442- -------
443- None
444-
445373 """
446374 # Iterate over fragments that intersect with GT skeleton
447375 for label in self .get_node_labels (key ):
@@ -466,12 +394,7 @@ def is_fragment_merge(self, key, label, kdtree):
466394 Label contained in "labels" attribute in the graph corresponding
467395 to "key".
468396 kdtree : scipy.spatial.KDTree
469- A KD-tree built from voxels in graph corresponding to "key".
470-
471- Returns
472- -------
473- None
474-
397+ KD-tree built from voxels in graph corresponding to "key".
475398 """
476399 for fragment_graph in self .find_graph_from_label (label ):
477400 if fragment_graph .run_length < 10 ** 6 :
@@ -596,16 +519,11 @@ def find_label_intersections(self):
596519 Detects merges between ground truth graphs, namely distinct graphs that
597520 contain nodes with the same label.
598521
599- Parameters
600- ----------
601- None
602-
603522 Returns
604523 -------
605524 Set[tuple]
606525 Set of tuples containing a tuple of graph ids and common label
607526 between the graphs.
608-
609527 """
610528 label_intersections = set ()
611529 visited = set ()
@@ -628,15 +546,10 @@ def process_merge(self, key, label, xyz, update_merged_labels=True):
628546
629547 Parameters
630548 ----------
631- str
549+ key : str
632550 Key associated with the graph to be searched.
633- int
551+ label : int
634552 Label in prediction that is assocatied with a merge.
635-
636- Returns
637- -------
638- None
639-
640553 """
641554 if label in self .graphs [key ].get_labels ():
642555 # Compute metrics
@@ -652,15 +565,6 @@ def process_merge(self, key, label, xyz, update_merged_labels=True):
652565 def quantify_merges (self ):
653566 """
654567 Computes the percentage of merged edges for each graph.
655-
656- Parameters
657- ----------
658- None
659-
660- Returns
661- -------
662- None
663-
664568 """
665569 for key in self .graphs :
666570 n_edges = max (self .graphs [key ].graph ["n_edges" ], 1 )
@@ -671,15 +575,6 @@ def quantify_merges(self):
671575 def compute_edge_accuracy (self ):
672576 """
673577 Computes the edge accuracy of each self.graph.
674-
675- Parameters
676- ----------
677- None
678-
679- Returns
680- -------
681- None
682-
683578 """
684579 for key in self .graphs :
685580 p_omit = self .metrics .loc [key , "% Omit" ]
@@ -690,15 +585,6 @@ def compute_edge_accuracy(self):
690585 def compute_erl (self ):
691586 """
692587 Computes the expected run length (ERL) of each graph.
693-
694- Parameters
695- ----------
696- None
697-
698- Returns
699- -------
700- None
701-
702588 """
703589 total_run_length = 0
704590 for key in self .graphs :
@@ -726,18 +612,17 @@ def branch_search(self, graph, kdtree, root, radius=100):
726612 ----------
727613 graph : networkx.Graph
728614 Graph to be searched.
729- kdtree : ...
615+ kdtree : scipy.spatial.KDTree
730616 KDTree containing voxel coordinates from a ground truth tracing.
731617 root : int
732618 Root of search.
733619 radius : float, optional
734- Distance to search from root. The default is 100.
620+ Distance to search from root. Default is 100.
735621
736622 Returns
737623 -------
738624 int
739625 Root node or closest branching node within distance "radius".
740-
741626 """
742627 queue = list ([(root , 0 )])
743628 visited = set ({root })
@@ -766,25 +651,24 @@ def find_graph_from_label(self, label):
766651 graphs .append (self .fragment_graphs [key ])
767652 return graphs
768653
769- def physical_dist (self , voxel_1 , voxel_2 ):
654+ def physical_dist (self , voxel1 , voxel2 ):
770655 """
771656 Computes the physical distance between the given voxel coordinates.
772657
773658 Parameters
774659 ----------
775- voxel_1 : Tuple[int]
660+ voxel1 : Tuple[int]
776661 Voxel coordinate.
777- voxel_2 : Tuple[int]
662+ voxel2 : Tuple[int]
778663 Voxel coordinate.
779664
780665 Returns
781666 -------
782667 float
783668 Physical distance between the given voxel coordinates.
784-
785669 """
786- xyz_1 = img_util .to_physical (voxel_1 , self .anisotropy )
787- xyz_2 = img_util .to_physical (voxel_2 , self .anisotropy )
670+ xyz_1 = img_util .to_physical (voxel1 , self .anisotropy )
671+ xyz_2 = img_util .to_physical (voxel2 , self .anisotropy )
788672 return distance .euclidean (xyz_1 , xyz_2 )
789673
790674 def to_local_voxels (self , key , i , offset ):
0 commit comments