Ejemplo n.º 1
0
 def test_default_intensity(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     t = RandKSpaceSpikeNoise(1.0,
                              intensity_range=None,
                              channel_wise=channel_wise)
     out = t(deepcopy(im))
     self.assertEqual(out.shape, im.shape)
 def test_intensity(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 14.1]
     t = RandKSpaceSpikeNoise(1.0, intensity_range, channel_wise)
     _ = t(deepcopy(im))
     self.assertGreaterEqual(t.sampled_k_intensity[0], 14)
     self.assertLessEqual(t.sampled_k_intensity[0], 14.1)
 def test_0_prob(self, im_shape, as_tensor_output, as_tensor_input,
                 channel_wise):
     im = self.get_data(im_shape, as_tensor_input)
     intensity_range = [14, 15]
     t = RandKSpaceSpikeNoise(0.0, intensity_range, channel_wise,
                              as_tensor_output)
     out = t(im)
     np.testing.assert_allclose(im, out)
Ejemplo n.º 4
0
 def test_1_prob(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 14]
     t = RandKSpaceSpikeNoise(1.0, intensity_range, channel_wise)
     out = t(im)
     base_t = KSpaceSpikeNoise(t.sampled_locs, [14])
     out = out - base_t(im)
     assert_allclose(out, im * 0, type_test="tensor")
 def test_0_prob(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 15]
     t = RandKSpaceSpikeNoise(0.0, intensity_range, channel_wise)
     out = t(im)
     self.assertEqual(type(im), type(out))
     if isinstance(out, torch.Tensor):
         self.assertEqual(out.device, im.device)
         im, out = im.cpu(), out.cpu()
     np.testing.assert_allclose(im, out)
 def test_1_prob(self, im_shape, as_tensor_output, as_tensor_input,
                 channel_wise):
     im = self.get_data(im_shape, as_tensor_input)
     intensity_range = [14, 14]
     t = RandKSpaceSpikeNoise(1.0, intensity_range, channel_wise,
                              as_tensor_output)
     out = t(im)
     base_t = KSpaceSpikeNoise(t.sampled_locs, [14], as_tensor_output)
     out = out - base_t(im)
     np.testing.assert_allclose(out, im * 0)
 def test_1_prob(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 14]
     t = RandKSpaceSpikeNoise(1.0, intensity_range, channel_wise)
     out = t(im)
     base_t = KSpaceSpikeNoise(t.sampled_locs, [14])
     out = out - base_t(im)
     self.assertEqual(type(im), type(out))
     if isinstance(out, torch.Tensor):
         self.assertEqual(out.device, im.device)
         im, out = im.cpu(), out.cpu()
     np.testing.assert_allclose(out, im * 0)
Ejemplo n.º 8
0
 def test_same_result(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 15]
     t = RandKSpaceSpikeNoise(0.0, intensity_range, channel_wise)
     t.set_random_state(42)
     out1 = t(deepcopy(im))
     t.set_random_state(42)
     out2 = t(deepcopy(im))
     assert_allclose(out1, out2, type_test="tensor")
 def test_same_result(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 15]
     t = RandKSpaceSpikeNoise(0.0, intensity_range, channel_wise)
     t.set_random_state(42)
     out1 = t(deepcopy(im))
     t.set_random_state(42)
     out2 = t(deepcopy(im))
     self.assertEqual(type(im), type(out1))
     if isinstance(out1, torch.Tensor):
         self.assertEqual(out1.device, im.device)
         out1, out2 = out1.cpu(), out2.cpu()
     np.testing.assert_allclose(out1, out2)
 def test_same_result(self, im_shape, as_tensor_output, as_tensor_input,
                      channel_wise):
     im = self.get_data(im_shape, as_tensor_input)
     intensity_range = [14, 15]
     t = RandKSpaceSpikeNoise(0.0, intensity_range, channel_wise,
                              as_tensor_output)
     t.set_random_state(42)
     out1 = t(deepcopy(im))
     t.set_random_state(42)
     out2 = t(deepcopy(im))
     np.testing.assert_allclose(out1, out2)
     self.assertIsInstance(out1,
                           torch.Tensor if as_tensor_output else np.ndarray)
Ejemplo n.º 11
0
 def test_0_prob(self, im_shape, im_type, channel_wise):
     im = self.get_data(im_shape, im_type)
     intensity_range = [14, 15]
     t = RandKSpaceSpikeNoise(0.0, intensity_range, channel_wise)
     out = t(im)
     assert_allclose(out, im, type_test="tensor")