Skip to content

Commit ad03103

Browse files
committed
add dataset info
1 parent d966ea3 commit ad03103

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

run_sbatch_revision.sbatch

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@
99

1010
source ~/.bashrc
1111
conda activate synapse-net
12-
python /user/muth9/u12095/synapse-net/scripts/cooper/revision/updated_data_analysis/run_data_analysis.py \
13-
-i /mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/20241102_TOMO_DATA_Imig2014/final_Imig2014_seg_autoComp/SNAP25/ \
14-
-o /mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/20241102_TOMO_DATA_Imig2014/afterRevision_analysis/boundaryT0_9_constantins_presynapticFiltering/full_dataset --store \
15-
-s ./analysis_results/full_dataset
12+
python scripts/cooper/revision/surface_dice.py -i /mnt/ceph-hdd/cold/nim00007/AZ_prediction_new/endbulb_of_held/ -gt /mnt/ceph-hdd/cold/nim00007/new_AZ_train_data/endbulb_of_held/ -v 7

scripts/cooper/revision/surface_dice.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def collect_results(input_folder, gt_folder, version, check=False):
7070
results = []
7171
seg_key = f"predictions/az/seg_v{version}"
7272
gt_key = "/labels/az_merged"
73+
input_folder_name = os.path.basename(os.path.normpath(input_folder))
7374

7475
for fname in tqdm(os.listdir(input_folder), desc="Processing segmentations"):
7576
if not fname.endswith(".h5"):
@@ -84,18 +85,36 @@ def collect_results(input_folder, gt_folder, version, check=False):
8485

8586
result = process_file(pred_path, gt_path, seg_key, gt_key, check)
8687
if result:
88+
result["input_folder"] = input_folder_name
8789
results.append(result)
8890

8991
return results
9092

9193

9294
def save_results(results, output_file):
93-
"""Save results as an Excel file."""
94-
df = pd.DataFrame(results)
95-
df.to_excel(output_file, index=False)
95+
"""Append results to an Excel file, updating rows with matching tomo_name and input_folder."""
96+
new_df = pd.DataFrame(results)
97+
98+
if os.path.exists(output_file):
99+
existing_df = pd.read_excel(output_file)
100+
101+
# Drop rows where tomo_name and input_folder match any in new_df
102+
combined_df = existing_df[
103+
~existing_df.set_index(["tomo_name", "input_folder"]).index.isin(
104+
new_df.set_index(["tomo_name", "input_folder"]).index
105+
)
106+
]
107+
108+
# Append new data and reset index
109+
final_df = pd.concat([combined_df, new_df], ignore_index=True)
110+
else:
111+
final_df = new_df
112+
113+
final_df.to_excel(output_file, index=False)
96114
print(f"Results saved to {output_file}")
97115

98116

117+
99118
def main():
100119
parser = argparse.ArgumentParser(description="Compute surface dice for AZ segmentations.")
101120
parser.add_argument("--input_folder", "-i", required=True, help="Folder with predicted segmentations (.h5)")

0 commit comments

Comments
 (0)