def test_label_to_boundary_with_ignore(self): size = 20 label = _diagonal_label_volume(size, init=-1) transform = LabelToBoundary(offsets=(2, 4), ignore_index=-1) result = transform(label) assert result.shape == (2, ) + label.shape assert np.array_equal(np.unique(result), [-1, 0, 1])
def test_average_precision_real_data(self): l_file = 'resources/sample_patch.h5' with h5py.File(l_file, 'r') as f: label = f['big_label'][...] ltb = LabelToBoundary((2, 4, 6, 8)) pred = ltb(label) ap = AveragePrecision(min_instance_size=20000) assert ap(pred, label) > 0.2
def test_label_to_boundary(self): size = 20 label = _diagonal_label_volume(size) # this transform will produce 2 channels transform = LabelToBoundary(offsets=(2, 4)) result = transform(label) assert result.shape == (2, ) + label.shape assert np.array_equal(np.unique(result), [0, 1])
def test_label_to_boundary_no_aggregate(self): size = 20 label = _diagonal_label_volume(size) # this transform will produce 6 channels transform = LabelToBoundary(offsets=(2, 4), aggregate_affinities=False) result = transform(label) assert result.shape == (6,) + label.shape assert np.array_equal(np.unique(result), [0, 1])
def test_average_precision_real_data(self): l_file = 'resources/sample_patch.h5' with h5py.File(l_file, 'r') as f: label = f['big_label'][...] ltb = LabelToBoundary((1, 2, 4, 6), aggregate_affinities=True) pred = ltb(label) # don't compare instances smaller than 25K voxels ap = AveragePrecision(min_instance_size=25000) assert ap(pred, label) > 0.5