@@ -59,10 +59,10 @@ def __init__(
5959 self ,
6060 gt_pointer ,
6161 label_mask ,
62+ output_dir ,
6263 anisotropy = (1.0 , 1.0 , 1.0 ),
6364 connections_path = None ,
6465 fragments_pointer = None ,
65- output_dir = None ,
6666 preexisting_merges = None ,
6767 save_merges = False ,
6868 valid_labels = None ,
@@ -79,6 +79,8 @@ def __init__(
7979 coordinates.
8080 label_mask : ImageReader
8181 Predicted segmentation mask.
82+ output_dir : str
83+ Path to directory wehere results are written.
8284 anisotropy : Tuple[float], optional
8385 Image to physical coordinate scaling factors applied to SWC files
8486 stored at "fragments_pointer". The default is (1.0, 1.0, 1.0).
@@ -90,8 +92,6 @@ def __init__(
9092 "swc_util.Reader" for documentation. Notes: (1) "anisotropy" is
9193 applied to these SWC files and (2) these SWC files are required
9294 for counting merges. The default is None.
93- output_dir : str, optional
94- Path to directory wehere results are written. The default is None.
9595 preexisting_merges : List[int], optional
9696 List of segment IDs that are known to contain a merge mistake. The
9797 default is None.
@@ -346,29 +346,28 @@ def init_zip_writer(self):
346346
347347 """
348348 # Initialize output directory
349- output_dir = os .path .join (self .output_dir , "projections" )
350- util .mkdir (output_dir )
349+ projections_dir = os .path .join (self .output_dir , "projections" )
350+ util .mkdir (projections_dir )
351351
352352 # Save intial graphs
353353 self .zip_writer = dict ()
354354 for key in self .graphs .keys ():
355- self .zip_writer [key ] = ZipFile (f"{ output_dir } /{ key } .zip" , "w" )
355+ zip_path = f"{ projections_dir } /{ key } .zip"
356+ self .zip_writer [key ] = ZipFile (zip_path , "w" )
356357 self .graphs [key ].to_zipped_swc (self .zip_writer [key ])
357358
358359 # -- Main Routine --
359- def run (self , path = None ):
360+ def run (self ):
360361 """
361362 Computes skeleton-based metrics.
362363
363364 Parameters
364365 ----------
365- path : str, optional
366- Path where the results will be saved. The default is None.
366+ None
367367
368368 Returns
369369 -------
370- tuple
371- ...
370+ None
372371
373372 """
374373 print ("\n (3) Evaluation" )
@@ -381,21 +380,23 @@ def run(self, path=None):
381380 self .detect_merges ()
382381 self .quantify_merges ()
383382
384- # Report results
383+ # Compute metrics
385384 full_results , avg_results = self .compile_results ()
386- print (f"\n Average Results..." )
387- for key in avg_results .keys ():
388- print (f" { key } : { round (avg_results [key ], 4 )} " )
389385
390- print (f"\n Total Results..." )
391- print ("# splits:" , self .count_total_splits ())
392- print ("# merges:" , self .count_total_merges ())
386+ # Report full results
387+ prefix = "corrected-" if self .connections_path else ""
388+ path = f"{ self .output_dir } /{ prefix } results.xls"
389+ util .save_results (path , full_results )
393390
394- # Save results (if applicable)
395- if path :
396- util .save_results (path , full_results )
391+ # Report results overview
392+ path = os .path .join (self .output_dir , f"{ prefix } results-overview.txt" )
393+ util .update_txt (path , "Average Results..." )
394+ for key in avg_results .keys ():
395+ util .update_txt (path , f" { key } : { round (avg_results [key ], 4 )} " )
397396
398- return full_results , avg_results
397+ util .update_txt (path , "\n Total Results..." )
398+ util .update_txt (path , f" # splits: { self .count_total_splits ()} " )
399+ util .update_txt (path , f" # merges: { self .count_total_merges ()} " )
399400
400401 # -- Split Detection --
401402 def detect_splits (self ):
@@ -695,7 +696,7 @@ def save_merged_labels(self):
695696 """
696697 # Save detected merges
697698 prefix = "corrected_" if self .connections_path else ""
698- filename = f"merged_{ prefix } _segment_ids .txt"
699+ filename = f"merged_{ prefix } segment_ids .txt"
699700 with open (os .path .join (self .output_dir , filename ), "w" ) as f :
700701 f .write (f" Label - Physical Coordinate\n " )
701702 for _ , label , xyz in self .merged_labels :
0 commit comments