Skip to content

Commit 186df5b

Browse files
Merge branch 'more-inner-ear-analysis' of https://github.com/computational-cell-analytics/synaptic-reconstruction into more-inner-ear-analysis
2 parents 186c92d + 305a80b commit 186df5b

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

scripts/inner_ear/processing/run_analyis.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _load_segmentation(seg_path, tomo_shape):
5252
return seg
5353

5454

55-
def compute_distances(segmentation_paths, save_folder, resolution, force, tomo_shape):
55+
def compute_distances(segmentation_paths, save_folder, resolution, force, tomo_shape, use_corrected_vesicles=True):
5656
os.makedirs(save_folder, exist_ok=True)
5757

5858
vesicles = None
@@ -61,9 +61,10 @@ def _require_vesicles():
6161
vesicle_path = segmentation_paths["vesicles"]
6262

6363
if vesicles is None:
64-
vesicle_pool_path = os.path.join(os.path.split(save_folder)[0], "vesicle_pools.tif")
65-
if os.path.exists(vesicle_pool_path):
66-
vesicle_path = vesicle_pool_path
64+
if use_corrected_vesicles:
65+
vesicle_pool_path = os.path.join(os.path.split(save_folder)[0], "vesicle_pools.tif")
66+
if os.path.exists(vesicle_pool_path):
67+
vesicle_path = vesicle_pool_path
6768
return _load_segmentation(vesicle_path, tomo_shape)
6869

6970
else:
@@ -394,14 +395,22 @@ def analyze_folder(folder, version, n_ribbons, force, use_corrected_vesicles):
394395
with open_file(data_path, "r") as f:
395396
tomo_shape = f["data"].shape
396397

397-
out_distance_folder = os.path.join(output_folder, "distances")
398+
if use_corrected_vesicles:
399+
out_distance_folder = os.path.join(output_folder, "distances")
400+
else:
401+
out_distance_folder = os.path.join(output_folder, "distances_uncorrected")
398402
distance_paths, skip = compute_distances(
399403
segmentation_paths, out_distance_folder, resolution, force=force, tomo_shape=tomo_shape,
404+
use_corrected_vesicles=use_corrected_vesicles
400405
)
401406
if skip:
402407
return
403408

404409
if force or not os.path.exists(result_path):
410+
411+
if not use_corrected_vesicles:
412+
pool_correction_path = None
413+
405414
analyze_distances(
406415
segmentation_paths, distance_paths, resolution, result_path, tomo_shape,
407416
pool_correction_path=pool_correction_path

scripts/inner_ear/training/postprocessing_and_evaluation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
from train_structure_segmentation import get_train_val_test_split
1515

16-
ROOT = "/home/pape/Work/data/synaptic_reconstruction/moser"
17-
# ROOT = "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/moser"
16+
# ROOT = "/home/pape/Work/data/synaptic_reconstruction/moser"
17+
ROOT = "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/moser"
1818
MODEL_PATH = "/mnt/lustre-emmy-hdd/projects/nim00007/models/synaptic-reconstruction/vesicle-DA-inner_ear-v2"
1919
OUTPUT_ROOT = "./predictions"
2020

@@ -187,8 +187,8 @@ def segment_train_domain():
187187
name = "train_domain"
188188
run_vesicle_segmentation(paths, MODEL_PATH, name, is_nested=True)
189189
postprocess_structures(paths, name, is_nested=True)
190-
visualize(paths, name, is_nested=True)
191-
results = evaluate(paths, name, is_nested=True, save_path="./results/train_domain_postprocessed.csv")
190+
# visualize(paths, name, is_nested=True)
191+
results = evaluate(paths, name, is_nested=True, save_path="./results/train_domain_postprocessed_v2.csv")
192192
print(results)
193193
print("Ribbon segmentation:", results["ribbon"].mean(), "+-", results["ribbon"].std())
194194
print("PD segmentation:", results["PD"].mean(), "+-", results["PD"].std())

scripts/inner_ear/training/structure_prediction_and_evaluation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def predict_and_evaluate_train_domain():
143143
print("Run evaluation on", len(paths), "tomos")
144144

145145
name = "train_domain"
146-
model_path = "./checkpoints/inner_ear_structure_model"
146+
model_path = "./checkpoints/inner_ear_structure_model_v2"
147147

148148
run_prediction(paths, model_path, name, is_nested=True)
149-
evaluate(paths, name, is_nested=True, save_path="./results/train_domain.csv")
149+
evaluate(paths, name, is_nested=True, save_path="./results/train_domain_v2.csv")
150150
visualize(paths, name, is_nested=True)
151151

152152

@@ -187,9 +187,9 @@ def predict_and_evaluate_rat():
187187

188188

189189
def main():
190-
# predict_and_evaluate_train_domain()
190+
predict_and_evaluate_train_domain()
191191
# predict_and_evaluate_vesicle_pools()
192-
predict_and_evaluate_rat()
192+
# predict_and_evaluate_rat()
193193

194194

195195
if __name__ == "__main__":

0 commit comments

Comments
 (0)