@@ -63,6 +63,7 @@ def __init__(
6363 save_fragments = False ,
6464 use_anisotropy = True ,
6565 valid_labels = None ,
66+ verbose = True
6667 ):
6768 """
6869 Instantiates a SkeletonMetric object that evaluates the topological
@@ -75,7 +76,7 @@ def __init__(
7576 documentation. These SWC files are assumed to be stored in voxel
7677 coordinates.
7778 label_mask : ImageReader
78- Predicted segmentation mask .
79+ Predicted segmentation.
7980 output_dir : str
8081 Path to directory wehere results are written.
8182 anisotropy : Tuple[float], optional
@@ -95,10 +96,12 @@ def __init__(
9596 save_fragments : bool, optional
9697 Indication of whether to save fragments that project onto each
9798 ground truth skeleton. Default is False.
98- valid_labels : set [int], optional
99+ valid_labels : Set [int], optional
99100 Segment IDs that can be assigned to nodes. This argument accounts
100101 for segments that were been removed due to some type of filtering.
101102 Default is None.
103+ verbose : bool, optional
104+ Indication of whether to printout updates. Default is True.
102105 """
103106 # Instance attributes
104107 self .anisotropy = anisotropy
@@ -107,6 +110,7 @@ def __init__(
107110 self .save_merges = save_merges
108111 self .save_fragments = save_fragments
109112 self .use_anisotropy = use_anisotropy
113+ self .verbose = verbose
110114
111115 # Label handler
112116 self .label_handler = gutil .LabelHandler (
@@ -151,8 +155,10 @@ def load_groundtruth(self, swc_pointer, label_mask):
151155 label_mask : ImageReader
152156 Predicted segmentation mask.
153157 """
158+ if self .verbose :
159+ print ("\n (1) Load Ground Truth" )
160+
154161 # Build graphs
155- print ("\n (1) Load Ground Truth" )
156162 graph_loader = gutil .GraphLoader (
157163 anisotropy = self .anisotropy ,
158164 is_groundtruth = True ,
@@ -176,7 +182,9 @@ def load_fragments(self, swc_pointer):
176182 swc_pointer : Any
177183 Pointer to predicted SWC files if provided.
178184 """
179- print ("\n (2) Load Fragments" )
185+ if self .verbose :
186+ print ("\n (2) Load Fragments" )
187+
180188 if swc_pointer :
181189 graph_loader = gutil .GraphLoader (
182190 anisotropy = self .anisotropy ,
@@ -271,7 +279,8 @@ def run(self):
271279 """
272280 Computes skeleton-based metrics.
273281 """
274- print ("\n (3) Evaluation" )
282+ if self .verbose :
283+ print ("\n (3) Evaluation" )
275284
276285 # Compute metrics
277286 self .detect_splits ()
@@ -308,7 +317,9 @@ def detect_splits(self):
308317 Perform split detection across all graphs, update graph structures,
309318 and compute several skeleton metrics.
310319 """
311- pbar = tqdm (total = len (self .graphs ), desc = "Split Detection" )
320+ if self .verbose :
321+ pbar = tqdm (total = len (self .graphs ), desc = "Split Detection" )
322+
312323 with ProcessPoolExecutor (max_workers = 4 ) as executor :
313324 # Assign processes
314325 pending = dict ()
@@ -335,7 +346,9 @@ def detect_splits(self):
335346 self .metrics .loc [key , "% Split Edges" ] = round (p_split , 2 )
336347 self .metrics .at [key , "% Omit Edges" ] = round (p_omit , 2 )
337348 self .metrics .loc [key , "GT Run Length" ] = round (gt_rl , 2 )
338- pbar .update (1 )
349+
350+ if self .verbose :
351+ pbar .update (1 )
339352
340353 # -- Merge Detection --
341354 def detect_merges (self ):
0 commit comments