average_precision#

cellpose_omni.metrics.average_precision(masks_true, masks_pred, threshold=[0.5, 0.75, 0.9])[source]#

average precision estimation: AP = TP / (TP + FP + FN)

This function is based heavily on the fast stardist matching functions (https://github.com/mpicbg-csbd/stardist/blob/master/stardist/matching.py)

Parameters
  • masks_true (list of ND-arrays (int) or ND-array (int)) -- where 0=NO masks; 1,2... are mask labels

  • masks_pred (list of ND-arrays (int) or ND-array (int)) -- ND-array (int) where 0=NO masks; 1,2... are mask labels

Returns

  • ap (array [len(masks_true) x len(threshold)]) -- average precision at thresholds

  • tp (array [len(masks_true) x len(threshold)]) -- number of true positives at thresholds

  • fp (array [len(masks_true) x len(threshold)]) -- number of false positives at thresholds

  • fn (array [len(masks_true) x len(threshold)]) -- number of false negatives at thresholds