Skip to content

Commit 1d1b275

Browse files
committed
Merge branch 'main' into add-to-video
2 parents 5de4167 + 2876825 commit 1d1b275

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

docs/source/transforms/preprocessing.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ Intensity
4646
:show-inheritance:
4747

4848

49+
:class:`To`
50+
~~~~~~~~~~~
51+
52+
.. autoclass:: To
53+
:show-inheritance:
54+
55+
4956
.. currentmodule:: torchio.transforms.preprocessing.intensity
5057

5158

@@ -56,13 +63,6 @@ Intensity
5663
:show-inheritance:
5764

5865

59-
:class:`To`
60-
~~~~~~~~~~~
61-
62-
.. autoclass:: To
63-
:show-inheritance:
64-
65-
6666
Spatial
6767
-------
6868

src/torchio/transforms/preprocessing/intensity/to.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
class To(IntensityTransform):
1313
"""Convert the image tensor data type and/or device.
1414
15+
This transform is a thin wrapper around :func:`torch.Tensor.to`.
16+
1517
Args:
1618
target: First argument to :func:`torch.Tensor.to`.
1719
to_kwargs: Additional keyword arguments to pass to :func:`torch.Tensor.to`.
@@ -25,7 +27,6 @@ class To(IntensityTransform):
2527
>>> ct_rescaled = rescale(ct_clamped)
2628
>>> to_uint8 = tio.To(torch.uint8)
2729
>>> ct_uint8 = to_uint8(ct_rescaled)
28-
2930
"""
3031

3132
def __init__(
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
def test_todo():
2-
assert False
1+
import torch
2+
3+
import torchio as tio
4+
5+
from ...utils import TorchioTestCase
6+
7+
8+
class TestTo(TorchioTestCase):
9+
"""Tests for :class:`tio.To` class."""
10+
11+
def test_to(self):
12+
transform = tio.To(torch.int)
13+
tensor = 10 * torch.rand(2, 3, 4, 5)
14+
image = tio.ScalarImage(tensor=tensor)
15+
transformed = transform(image)
16+
assert image.data.dtype == torch.float32
17+
assert transformed.data.dtype == torch.int

0 commit comments

Comments
 (0)