Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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))