fepegar / torchio

@@ -17,8 +17,13 @@
Loading
17 17
18 18
    def apply_transform(self, subject):
19 19
        for image in self.get_images(subject):
20 -
            assert image.data.ndim == 4 and image.data.shape[0] == 1
21 -
            data = image.data.squeeze()
20 +
            if image.num_channels > 1:
21 +
                message = (
22 +
                    'The number of input channels must be 1,'
23 +
                    f' but it is {image.num_channels}'
24 +
                )
25 +
                raise RuntimeError(message)
26 +
            data = image.data[0]
22 27
            num_classes = -1 if self.num_classes is None else self.num_classes
23 28
            one_hot = F.one_hot(data.long(), num_classes=num_classes)
24 29
            image.set_data(one_hot.permute(3, 0, 1, 2).type(data.type()))

@@ -274,6 +274,11 @@
Loading
274 274
        point_fin = nib.affines.apply_affine(self.affine, fin)
275 275
        return np.array((point_ini, point_fin))
276 276
277 +
    @property
278 +
    def num_channels(self) -> int:
279 +
        """Get the number of channels in the associated 4D tensor."""
280 +
        return len(self.data)
281 +
277 282
    def axis_name_to_index(self, axis: str) -> int:
278 283
        """Convert an axis name to an axis index.
279 284
Files Coverage
tests 99.76%
torchio 86.57%
print_system.py 0.00%
Project Totals (132 files) 90.55%
1875.3
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
1875.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
1875.1
TRAVIS_PYTHON_VERSION=3.8
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