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

TestTranspose.test_transpose()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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