11import argparse
22import os
3+ from glob import glob
34
45import pandas as pd
56from common import get_paths , get_file_names , ALL_NAMES
@@ -14,17 +15,37 @@ def run_az_evaluation(args):
1415 results = []
1516 for dataset in args .datasets :
1617 print (dataset , ":" )
17- file_names = get_file_names (dataset , split_folder , split_names = ["test" ])
18+ if args .in_path :
19+ file_paths = glob (os .path .join (args .in_path , dataset , "*.h5" ))
20+ file_names = [os .path .basename (path ) for path in file_paths ]
21+ else :
22+ file_names = get_file_names (dataset , split_folder , split_names = ["test" ])
1823 seg_paths , gt_paths = get_paths (dataset , file_names )
1924 result = az_evaluation (
20- seg_paths , gt_paths , seg_key = seg_key , gt_key = "/labels/az_merged " ,
25+ seg_paths , gt_paths , seg_key = seg_key , gt_key = "/labels/az_merged_v6 " ,
2126 criterion = args .criterion , dataset = [dataset ] * len (seg_paths ), threshold = args .threshold ,
2227 )
2328 results .append (result )
2429
2530 results = pd .concat (results )
2631 output_path = f"/user/muth9/u12095/synapse-net/scripts/cooper/revision/evaluation_results/v{ args .version } .xlsx"
27- results .to_excel (output_path , index = False )
32+
33+ if os .path .exists (output_path ):
34+ # Read existing data
35+ existing = pd .read_excel (output_path )
36+
37+ # Ensure consistent column naming and types
38+ if "tomo_name" in results .columns and "tomo_name" in existing .columns :
39+ # Drop existing entries with matching "tomo_name"
40+ existing = existing [~ existing ["tomo_name" ].isin (results ["tomo_name" ])]
41+
42+ # Combine: old (filtered) + new
43+ combined = pd .concat ([existing , results ], ignore_index = True )
44+ else :
45+ combined = results
46+
47+ # Save back to Excel
48+ combined .to_excel (output_path , index = False )
2849
2950
3051def visualize_az_evaluation (args ):
@@ -44,7 +65,7 @@ def visualize_az_evaluation(args):
4465 with open_file (seg_path , "r" ) as f :
4566 seg = f [seg_key ][:].squeeze ()
4667 with open_file (gt_path , "r" ) as f :
47- gt = f ["/labels/az_merged " ][:]
68+ gt = f ["/labels/az_merged_v6 " ][:]
4869
4970 seg = seg > args .threshold
5071
@@ -66,6 +87,7 @@ def main():
6687 parser .add_argument ("--datasets" , nargs = "+" , default = ALL_NAMES )
6788 # Set the threshold to None if the AZ prediction already a segmentation.
6889 parser .add_argument ("--threshold" , type = float , default = 0.5 )
90+ parser .add_argument ("--in_path" , "-i" , default = None )
6991 args = parser .parse_args ()
7092
7193 if args .visualize :
0 commit comments