44@author: Anna Grim
5566
7+
8+ Implementation of class that computes skeleton-based metrics by comparing a
9+ predicted neuron segmentation to a set of ground truth graphs.
10+
711"""
812
913from concurrent .futures import (
@@ -33,12 +37,14 @@ class SkeletonMetric:
3337 the ground truth skeletons to the predicted segmentation mask. The
3438 accuracy is then quantified by detecting splits and merges, then computing
3539 the following metrics:
36- (1) Number of splits
37- (2) Number of merges
38- (3) Percentage of omit edges
39- (4) Percentage of merged edges
40- (5) Edge accuracy
41- (6) Expected Run Length (ERL)
40+ (1) # Splits
41+ (2) # Merges
42+ (3) Omit Edge Ratio
43+ (4) Split Edge Ratio
44+ (5) Merged Edge Ratio
45+ (6) Edge accuracy
46+ (7) Expected Run Length (ERL)
47+ (8) Normalized ERL
4248
4349 """
4450
@@ -51,59 +57,56 @@ def __init__(
5157 fragments_pointer = None ,
5258 output_dir = None ,
5359 preexisting_merges = None ,
54- save_projections = False ,
60+ save_merges = False ,
5561 valid_labels = None ,
5662 ):
5763 """
58- Constructs skeleton metric object that evaluates the quality of a
59- predicted segmentation.
64+ Instantiates a SkeletonMetric object that evaluates the topological
65+ accuracy of a predicted segmentation.
6066
6167 Parameters
6268 ----------
6369 gt_pointer : Any
64- Pointer to ground truth swcs , see "swc_util.Reader" for further
65- documentation. Note these SWC files are assumed to be stored in
66- image coordinates.
70+ Pointer to ground truth SWC files , see "swc_util.Reader" for
71+ documentation. These SWC files are assumed to be stored in voxel
72+ coordinates.
6773 pred_labels : ArrayLike
6874 Predicted segmentation mask.
6975 anisotropy : Tuple[float], optional
7076 Image to physical coordinate scaling factors applied to SWC files
7177 stored at "fragments_pointer". The default is (1.0, 1.0, 1.0).
7278 connections_path : str, optional
73- Path to a txt file containing pairs of segment ids of segments
74- that were merged into a single segment . The default is None.
79+ Path to a txt file containing pairs of segment IDs that represents
80+ fragments that were merged. The default is None.
7581 fragments_pointer : Any, optional
7682 Pointer to SWC files corresponding to "pred_labels", see
77- "swc_util.Reader" for further documentation. Note that these SWC
78- file may be stored in physical coordiantes, but the anisotropy
79- scaling factors must be provided . The default is None.
83+ "swc_util.Reader" for documentation. Notes: (1) "anisotropy" is
84+ applied to these SWC files and (2) these SWC files are required
85+ for counting merges . The default is None.
8086 output_dir : str, optional
81- Path to directory that mistake sites are written to. The default
82- is None.
83- preexisting_merges : list[int], optional
84- List of segment IDs that are known to be create a false merge. The
87+ Path to directory wehere results are written. The default is None.
88+ preexisting_merges : List[int], optional
89+ List of segment IDs that are known to contain a merge mistake. The
8590 default is None.
86- save_projections: bool, optional
87- Indication of whether to save fragments that 'project' onto the
88- ground truth neurons (i.e. there exists a node in a graph from
89- "self.graphs" that is labeled with a given fragment id. The
91+ save_merges: bool, optional
92+ Indication of whether to save fragments with a merge mistake. The
9093 default is None.
9194 valid_labels : set[int], optional
92- Segment ids (i.e. labels) that are present in the segmentation.
93- The purpose of this argument is to account for segments that were
94- removed due to thresholding by path length. The default is None.
95+ Segment IDs that can be assigned to nodes. This argument accounts
96+ for segments that were removed during thresholding based on path
97+ length. The default is None.
9598
9699 Returns
97100 -------
98- None.
101+ None
99102
100103 """
101104 # Instance attributes
102105 self .anisotropy = anisotropy
103106 self .connections_path = connections_path
104107 self .output_dir = output_dir
105108 self .preexisting_merges = preexisting_merges
106- self .save_projections = save_projections
109+ self .save_merges = save_merges
107110
108111 # Label handler
109112 self .label_handler = gutil .LabelHandler (
@@ -116,7 +119,7 @@ def __init__(
116119 self .load_fragments (fragments_pointer )
117120
118121 # Initialize writer
119- if self .save_projections :
122+ if self .save_merges :
120123 self .init_zip_writer ()
121124
122125 # --- Load Data ---
@@ -499,7 +502,7 @@ def is_fragment_merge(self, key, label, kdtree):
499502 self .merged_labels .add ((key , equiv_label , tuple (xyz )))
500503
501504 # Save merged fragment (if applicable)
502- if self .save_projections :
505+ if self .save_merges :
503506 fragment_graph .to_zipped_swc (self .zip_writer [key ])
504507 break
505508
0 commit comments