def test_ri_random_data(self): print("Blob") from elf.evaluation import rand_index shape = (256, 256) x = np.random.randint(0, 100, size=shape) y = np.random.randint(0, 100, size=shape) ari, ri = rand_index(x, y, ignore_gt=[0]) ari_exp = adapted_rand(x, gy) self.assertAlmostEqual(ari, ari_exp)
def test_ri(self): from cluster_tools.utils.validation_utils import rand_index f = z5py.File(self.path) ds_gt = f[self.gt_key] ds_gt.n_threads = 4 gt = ds_gt[self.bb] ds_seg = f[self.seg_key] ds_seg.n_threads = 4 seg = ds_seg[self.bb] ari, ri = rand_index(seg, gt, ignore_gt=[0]) ari_exp = adapted_rand(seg, gt) self.assertAlmostEqual(ari, ari_exp)
def test_cremi_score(self): from cluster_tools.utils.validation_utils import cremi_score f = z5py.File(self.path) ds_gt = f[self.gt_key] ds_gt.n_threads = 4 gt = ds_gt[self.bb] ds_seg = f[self.seg_key] ds_seg.n_threads = 4 seg = ds_seg[self.bb] vis, vim, ari, cs = cremi_score(seg, gt, ignore_gt=[0]) ari_exp = adapted_rand(seg, gt) vis_exp, vim_exp = voi(seg, gt) cs_exp = np.sqrt(ari_exp * (vis_exp + vim_exp)) self.assertAlmostEqual(ari, ari_exp) self.assertAlmostEqual(vis, vis_exp) self.assertAlmostEqual(vim, vim_exp) self.assertAlmostEqual(cs, cs_exp)
def get_scores(seg, gt): rand = adapted_rand(seg, gt) vis, vim = voi(seg, gt) return {'rand': rand, 'vi-split': vis, 'vi-merge': vim}