Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lacan committed Dec 5, 2023
2 parents a0ac5f1 + e203d2d commit c463cf2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions QC/run-cellpose-qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ def compareLabels( model_name, image_folder ):
image_folder = Path(image_folder)
# Grab all tif images
raw_images = [x for x in Path(image_folder).glob("*.tif") if not ( "masks" in x.name or "flows" in x.name )]
gt_images = [x for x in Path(image_folder).glob("*.tif") if ( "masks" in x.name and not "cp_masks" in x.name )]
pred_images = [x for x in Path(image_folder).glob("*.tif") if ( "cp_masks" in x.name )]

# Define save folder from the parent of the predicted_labels_folder
results_path = image_folder / "QC-Results"
Expand All @@ -325,11 +323,19 @@ def compareLabels( model_name, image_folder ):
writer.writerow(["model","image","Prediction v. GT Intersection over Union", "false positive", "true positive", "false negative", "precision", "recall", "accuracy", "f1 score", "n_true", "n_pred", "mean_true_score", "mean_matched_score", "panoptic_quality"])

# define the images
for raw, gt, pred in zip(raw_images, gt_images, pred_images):
print( 'Running QC on: ' + raw.name )
test_input = io.imread(raw)
test_prediction = io.imread(pred)
test_ground_truth_image = io.imread(gt)
for raw in raw_images:
mask_name = f"{raw.stem}_masks{raw.suffix}"
gt_image = raw.parent / mask_name
cp_mask_name = f"{raw.stem}_cp_masks{raw.suffix}"
pred_image = raw.parent / cp_mask_name
if not gt_image.is_file():
raise FileNotFoundError
if not pred_image.is_file():
raise FileNotFoundError

#test_input = io.imread(raw)
test_prediction = io.imread(pred_image)
test_ground_truth_image = io.imread(gt_image)

# Calculate the matching (with IoU threshold `thresh`) and all metrics

Expand All @@ -353,4 +359,3 @@ def compareLabels( model_name, image_folder ):

# Finally running the check on the given inputs
compareLabels(model_name, data_folder)

0 comments on commit c463cf2

Please sign in to comment.