def test_DATAAUGMENTATION_parameter_classification(self): data_aug = Data_Augmentation() data_aug.config_p_per_sample = 1 data_aug.seg_augmentation = False img_aug, seg_aug = data_aug.run(self.img3D, self.seg3D) self.assertFalse(np.array_equal(img_aug, self.img3D)) self.assertTrue(np.array_equal(seg_aug, self.seg3D))
def test_DATAAUGMENTATION_parameter_gaussiannoise(self): data_aug = Data_Augmentation(cycles=1, scaling=False, rotations=False, elastic_deform=False, mirror=False, brightness=False, contrast=False, gamma=False, gaussian_noise=True) data_aug.config_p_per_sample = 1 img_aug, seg_aug = data_aug.run(self.img3D, self.seg3D) self.assertFalse(np.array_equal(img_aug, self.img3D)) self.assertTrue(np.array_equal(seg_aug, self.seg3D))
def test_DATAAUGMENTATION_parameter_percentage(self): data_aug = Data_Augmentation(cycles=100, scaling=True, rotations=False, elastic_deform=False, mirror=False, brightness=False, contrast=False, gamma=False, gaussian_noise=False) data_aug.config_p_per_sample = 0.3 img_aug, seg_aug = data_aug.run(self.img3D, self.seg3D) counter_equal = 0 for i in range(0, 100): is_equal = np.array_equal(img_aug[i], self.img3D[0]) if is_equal: counter_equal += 1 ratio = counter_equal / 100 self.assertTrue(ratio >= 0.5 and ratio <= 0.9)
def test_DATAAUGMENTATION_BASE_run2D(self): data_aug = Data_Augmentation() data_aug.config_p_per_sample = 1 img_aug, seg_aug = data_aug.run(self.img2D, self.seg2D) self.assertEqual(img_aug.shape, self.img2D.shape) self.assertFalse(np.array_equal(img_aug, self.img2D)) self.assertEqual(seg_aug.shape, self.seg2D.shape) self.assertFalse(np.array_equal(seg_aug, self.seg2D)) data_aug = Data_Augmentation(cycles=1, scaling=False, rotations=False, elastic_deform=False, mirror=False, brightness=False, contrast=False, gamma=False, gaussian_noise=False) img_aug, seg_aug = data_aug.run(self.img2D, self.seg2D) self.assertTrue(np.array_equal(img_aug, self.img2D))