def test_output_shape(self, class_args, img_shape): key = "img" bias_field = RandBiasFieldd(keys=[key], **class_args) img = np.random.rand(*img_shape) output = bias_field({key: img}) np.testing.assert_equal(output[key].shape, img_shape) np.testing.assert_equal(output[key].dtype, bias_field.rand_bias_field.dtype)
def test_one_range_input(self, class_args, expected): key = "img" bias_field = RandBiasFieldd(keys=[key], **class_args) img = np.ones([1, 2, 2]) output = bias_field({key: img}) np.testing.assert_allclose(output[key], expected.astype( bias_field.rand_bias_field.dtype), rtol=1e-3)
def test_zero_prob(self): key = "img" bias_field = RandBiasFieldd(keys=[key], prob=0.0) img = np.random.rand(3, 32, 32) output = bias_field({key: img}) np.testing.assert_equal(output[key], img)
def test_zero_range(self, class_args, img_shape): key = "img" bias_field = RandBiasFieldd(keys=[key], **class_args) img = np.ones(img_shape) output = bias_field({key: img}) np.testing.assert_allclose(output[key], np.ones(img_shape))