Passed
Push — main ( e43adb...aa4098 )
by Fernando
01:29
created

tests.transforms.preprocessing.test_transpose   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TestTranspose.test_transpose() 0 7 1
A TestTranspose.test_orientation_reversed() 0 5 1
1
import SimpleITK as sitk
2
3
import torchio as tio
4
5
from ...utils import TorchioTestCase
6
7
8
class TestTranspose(TorchioTestCase):
9
    def test_transpose(self):
10
        transform = tio.Transpose()
11
        image = tio.ScalarImage(self.get_image_path('image'))
12
        transformed = transform(image)
13
        sitk_image = sitk.GetImageFromArray(image.numpy()[0])
14
        from_sitk = tio.ScalarImage.from_sitk(sitk_image)
15
        self.assert_tensor_equal(transformed.data, from_sitk.data)
16
17
    def test_orientation_reversed(self):
18
        transform = tio.Transpose()
19
        image = tio.ScalarImage(self.get_image_path('image'))
20
        transformed = transform(image)
21
        self.assertEqual(transformed.orientation_str, image.orientation_str[::-1])
22