fepegar / torchio

@@ -26,6 +26,8 @@
Loading
26 26
            of size :math:`w \times h \times d`.
27 27
            If a single number :math:`n` is provided,
28 28
            :math:`w = h = d = n`.
29 +
            This argument is mandatory (it is a keyword argument for backward
30 +
            compatibility).
29 31
        patch_overlap: Tuple of even integers :math:`(w_o, h_o, d_o)`
30 32
            specifying the overlap between patches for dense inference. If a
31 33
            single number :math:`n` is provided, :math:`w_o = h_o = d_o = n`.
@@ -70,6 +72,8 @@
Loading
70 72
        super().__init__(patch_size)
71 73
        self.patch_overlap = np.array(to_tuple(patch_overlap, length=3))
72 74
        self.padding_mode = padding_mode
75 +
        if subject is not None and not isinstance(subject, Subject):
76 +
            raise ValueError('The subject argument must be None or Subject')
73 77
        self.subject = self._pad(subject)
74 78
        self.locations = self._compute_locations(self.subject)
75 79

@@ -1,7 +1,7 @@
Loading
1 1
#!/usr/bin/env python
2 2
3 3
from copy import copy
4 -
from torchio.data import GridSampler
4 +
import torchio as tio
5 5
from ...utils import TorchioTestCase
6 6
7 7
@@ -11,7 +11,11 @@
Loading
11 11
    def test_locations(self):
12 12
        patch_size = 5, 20, 20
13 13
        patch_overlap = 2, 4, 6
14 -
        sampler = GridSampler(self.sample_subject, patch_size, patch_overlap)
14 +
        sampler = tio.GridSampler(
15 +
            subject=self.sample_subject,
16 +
            patch_size=patch_size,
17 +
            patch_overlap=patch_overlap,
18 +
        )
15 19
        fixture = [
16 20
            [0, 0, 0, 5, 20, 20],
17 21
            [0, 0, 10, 5, 20, 30],
@@ -25,18 +29,18 @@
Loading
25 29
26 30
    def test_large_patch(self):
27 31
        with self.assertRaises(ValueError):
28 -
            GridSampler(self.sample_subject, (5, 21, 5), (0, 2, 0))
32 +
            tio.GridSampler(self.sample_subject, (5, 21, 5), (0, 2, 0))
29 33
30 34
    def test_large_overlap(self):
31 35
        with self.assertRaises(ValueError):
32 -
            GridSampler(self.sample_subject, (5, 20, 5), (2, 4, 6))
36 +
            tio.GridSampler(self.sample_subject, (5, 20, 5), (2, 4, 6))
33 37
34 38
    def test_odd_overlap(self):
35 39
        with self.assertRaises(ValueError):
36 -
            GridSampler(self.sample_subject, (5, 20, 5), (2, 4, 3))
40 +
            tio.GridSampler(self.sample_subject, (5, 20, 5), (2, 4, 3))
37 41
38 42
    def test_single_location(self):
39 -
        sampler = GridSampler(self.sample_subject, (10, 20, 30), 0)
43 +
        sampler = tio.GridSampler(self.sample_subject, (10, 20, 30), 0)
40 44
        fixture = [[0, 0, 0, 10, 20, 30]]
41 45
        self.assertEqual(sampler.locations.tolist(), fixture)
42 46
@@ -44,7 +48,7 @@
Loading
44 48
        patch_size = 5, 20, 20
45 49
        patch_overlap = 2, 4, 6
46 50
        initial_shape = copy(self.sample_subject.shape)
47 -
        GridSampler(
51 +
        tio.GridSampler(
48 52
            self.sample_subject,
49 53
            patch_size,
50 54
            patch_overlap,
@@ -52,3 +56,8 @@
Loading
52 56
        )
53 57
        final_shape = self.sample_subject.shape
54 58
        self.assertEqual(initial_shape, final_shape)
59 +
60 +
    def test_bad_subject(self):
61 +
        with self.assertRaises(ValueError):
62 +
            patch_size = 88
63 +
            tio.GridSampler(patch_size)
Files Coverage
tests 99.76%
torchio 86.47%
print_system.py 0.00%
Project Totals (132 files) 90.48%
1880.3
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
1880.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
1881.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
1880.1
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
1881.1
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
1881.3
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
1
ignore:
2
  - "setup.py"
3
  - "torchio/external/due.py"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading