-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid using SimpleITK in some transforms (#334)
* Use PyTorch to crop * Use Crop transform to create patches * Remove typing hint * Use NumPy to pad * Use scipy to blur * Fix kwarg name and default values
- Loading branch information
Showing
14 changed files
with
134 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import torch | ||
import SimpleITK as sitk | ||
from torchio.utils import sitk_to_nib | ||
from torchio.transforms import Pad | ||
from ...utils import TorchioTestCase | ||
|
||
|
||
class TestPad(TorchioTestCase): | ||
"""Tests for `Pad`.""" | ||
def test_pad(self): | ||
image = self.sample.t1 | ||
padding = 1, 2, 3, 4, 5, 6 | ||
sitk_image = image.as_sitk() | ||
low, high = padding[::2], padding[1::2] | ||
sitk_padded = sitk.ConstantPad(sitk_image, low, high, 0) | ||
tio_padded = Pad(padding, padding_mode=0)(image) | ||
sitk_tensor, sitk_affine = sitk_to_nib(sitk_padded) | ||
tio_tensor, tio_affine = sitk_to_nib(tio_padded.as_sitk()) | ||
self.assertTensorEqual(sitk_tensor, tio_tensor) | ||
self.assertTensorEqual(sitk_affine, tio_affine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.