# skip the ground truth if "1st_manual" not in result: # print metrics print "-- {} --".format(os.path.basename(result)) print "dice coefficient : {}".format(utils.dice_coefficient(gt_vessels,pred_vessels, masks)) print "f1 score : {}, accuracy : {}, specificity : {}, sensitivity : {}".format(*utils.misc_measures(gt_vessels,pred_vessels, masks)) # compute false positive rate, true positive graph method=os.path.basename(result) methods.append(method) if method=='CRFs' or method=='2nd_manual': cm=confusion_matrix(gt_vessels_in_mask, pred_vessels_in_mask) fpr=1-1.*cm[0,0]/(cm[0,1]+cm[0,0]) tpr=1.*cm[1,1]/(cm[1,0]+cm[1,1]) prec=1.*cm[1,1]/(cm[0,1]+cm[1,1]) recall=tpr else: fpr, tpr, _ = roc_curve(gt_vessels_in_mask, pred_vessels_in_mask) prec, recall, _ = precision_recall_curve(gt_vessels_in_mask, pred_vessels_in_mask) fprs.append(fpr) tprs.append(tpr) precs.append(prec) recalls.append(recall) # save plots of ROC and PR curves curve_dir=curves_out.format(os.path.basename(dataset)) if not os.path.isdir(curve_dir): os.makedirs(curve_dir) utils.plot_AUC_ROC(fprs, tprs, methods, curve_dir) utils.plot_AUC_PR(precs, recalls, methods, curve_dir)
# compute false positive rate, true positive graph method = os.path.basename(result) methods.append(method) if method == 'CRFs' or method == '2nd_manual': cm = confusion_matrix(gt_vessels_in_mask, pred_vessels_in_mask) fpr = 1 - 1. * cm[0, 0] / (cm[0, 1] + cm[0, 0]) tpr = 1. * cm[1, 1] / (cm[1, 0] + cm[1, 1]) prec = 1. * cm[1, 1] / (cm[0, 1] + cm[1, 1]) recall = tpr if method == '2nd_manual': human_op_pts_roc, human_op_pts_pr = utils.operating_pts_human_experts( gt_vessels, pred_vessels, masks) else: fpr, tpr, _ = roc_curve(gt_vessels_in_mask, pred_vessels_in_mask) prec, recall, _ = precision_recall_curve( gt_vessels_in_mask, pred_vessels_in_mask) fprs.append(fpr) tprs.append(tpr) precs.append(prec) recalls.append(recall) # save plots of ROC and PR curves curve_dir = curves_out.format(os.path.basename(dataset)) if not os.path.isdir(curve_dir): os.makedirs(curve_dir) utils.plot_AUC_ROC(fprs, tprs, methods, curve_dir, human_op_pts_roc) utils.plot_AUC_PR(precs, recalls, methods, curve_dir, human_op_pts_pr)
if method == 'CRFs' or method == '2nd_manual': cm = confusion_matrix(gt_vessels_in_mask, pred_vessels_in_mask) fpr = 1 - 1. * cm[0, 0] / (cm[0, 1] + cm[0, 0]) tpr = 1. * cm[1, 1] / (cm[1, 0] + cm[1, 1]) prec = 1. * cm[1, 1] / (cm[0, 1] + cm[1, 1]) recall = tpr else: fpr, tpr, _ = roc_curve(gt_vessels_in_mask, pred_vessels_in_mask) prec, recall, _ = precision_recall_curve( gt_vessels_in_mask, pred_vessels_in_mask) fprs.append(fpr) tprs.append(tpr) precs.append(prec) recalls.append(recall) # save plots of ROC and PR curves curve_dir = curves_out.format(os.path.basename(dataset)) if not os.path.isdir(curve_dir): os.makedirs(curve_dir) if os.path.basename(dataset) == 'STARE': num = stare_num elif os.path.basename(dataset) == 'DRIVE': num = drive_num utils.plot_AUC_ROC(fprs, tprs, methods, curve_dir, os.path.basename(dataset), model_name, num) utils.plot_AUC_PR(precs, recalls, methods, curve_dir, os.path.basename(dataset), model_name, num)