-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
4 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
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,24 @@ | ||
import SimpleITK as sitk | ||
|
||
from .label_transform import LabelTransform | ||
|
||
|
||
class Contour(LabelTransform): | ||
r"""Keep only the borders of each connected component in a binary image. | ||
Args: | ||
**kwargs: See :class:`~torchio.transforms.Transform` for additional | ||
keyword arguments. | ||
""" | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.args_names = [] | ||
|
||
def apply_transform(self, subject): | ||
for image in self.get_images(subject): | ||
assert image.data.ndim == 4 and image.data.shape[0] == 1 | ||
sitk_image = image.as_sitk() | ||
contour = sitk.BinaryContour(sitk_image) | ||
tensor, _ = self.sitk_to_nib(contour) | ||
image.set_data(tensor) | ||
return subject |
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