def malis_f1_score(gt_lbl, pred_lbl): if (np.max(gt_lbl) == 0): gt_lbl += 1 ret = rand_index(gt_lbl, pred_lbl)[1] ret = float(ret) return ret
def malis_rand_index(gt_lbl, pred_lbl): ret = rand_index(gt_lbl, pred_lbl)[0] ret = float(ret) return ret
#hdf5_raw_file = 'zebrafish_friedrich/raw.hdf5' #hdf5_gt_file = 'zebrafish_friedrich/labels_2.hdf5' # hdf5_raw = h5py.File(hdf5_raw_file, 'r') h5seg = h5py.File(hdf5_gt_file, 'r') # hdf5_aff = h5py.File(hdf5_aff_file, 'r') seg = np.asarray(h5seg['main']).astype(np.int32) aff = m.seg_to_affgraph(seg, nhood) cc, ccSizes = m.connected_components_affgraph(aff, nhood) aff2 = m.seg_to_affgraph(cc, nhood) cc2, ccSizes2 = m.connected_components_affgraph(aff2, nhood) print "Comparing 'seg' and 'cc':" frac_disagree = np.mean(seg.ravel() != cc.ravel()) ri, fscore, prec, rec = m.rand_index(seg, cc) V_rand, V_rand_split, V_rand_merge = m.compute_V_rand_N2(seg, cc) print "Connected components disagree at %f%% locations" % (frac_disagree * 100) print "\tRand index: %f, fscore: %f, prec: %f, rec: %f" % (ri, fscore, prec, rec) print "\tV_rand: %f, V_rand_split: %f, V_rand_merge: %f" % ( V_rand, V_rand_split, V_rand_merge) print "Comparing 'cc' and 'cc2':" frac_disagree = np.mean(cc.ravel() != cc2.ravel()) ri, fscore, prec, rec = m.rand_index(cc, cc2) V_rand, V_rand_split, V_rand_merge = m.compute_V_rand_N2(cc, cc2) print "Connected components disagree at %f%% locations" % (frac_disagree * 100) print "\tRand index: %f, fscore: %f, prec: %f, rec: %f" % (ri, fscore, prec, rec) print "\tV_rand: %f, V_rand_split: %f, V_rand_merge: %f" % (
def malis_f1_score (gt_lbl, pred_lbl): ret = rand_index (gt_lbl, pred_lbl) [1] ret = float (ret) return ret
#hdf5_raw_file = 'zebrafish_friedrich/raw.hdf5' #hdf5_gt_file = 'zebrafish_friedrich/labels_2.hdf5' # hdf5_raw = h5py.File(hdf5_raw_file, 'r') h5seg = h5py.File(hdf5_gt_file, 'r') # hdf5_aff = h5py.File(hdf5_aff_file, 'r') seg = np.asarray(h5seg['main']).astype(np.int32) aff = m.seg_to_affgraph(seg,nhood) cc,ccSizes = m.connected_components_affgraph(aff,nhood) aff2 = m.seg_to_affgraph(cc,nhood) cc2,ccSizes2 = m.connected_components_affgraph(aff2,nhood) print "Comparing 'seg' and 'cc':" frac_disagree = np.mean(seg.ravel()!=cc.ravel()) ri,fscore,prec,rec = m.rand_index(seg,cc) V_rand,V_rand_split,V_rand_merge = m.compute_V_rand_N2(seg,cc) print "Connected components disagree at %f%% locations" % (frac_disagree*100) print "\tRand index: %f, fscore: %f, prec: %f, rec: %f" % (ri,fscore,prec,rec) print "\tV_rand: %f, V_rand_split: %f, V_rand_merge: %f" % (V_rand,V_rand_split,V_rand_merge) print "Comparing 'cc' and 'cc2':" frac_disagree = np.mean(cc.ravel()!=cc2.ravel()) ri,fscore,prec,rec = m.rand_index(cc,cc2) V_rand,V_rand_split,V_rand_merge = m.compute_V_rand_N2(cc,cc2) print "Connected components disagree at %f%% locations" % (frac_disagree*100) print "\tRand index: %f, fscore: %f, prec: %f, rec: %f" % (ri,fscore,prec,rec) print "\tV_rand: %f, V_rand_split: %f, V_rand_merge: %f" % (V_rand,V_rand_split,V_rand_merge)