Source code for torchio.transforms.preprocessing.label.contour

import SimpleITK as sitk

from .label_transform import LabelTransform

[docs]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 apply_transform(self, subject): for image in self.get_images(subject): assert == 4 and[0] == 1 sitk_image = image.as_sitk() contour = sitk.BinaryContour(sitk_image) tensor, _ = self.sitk_to_nib(contour) image.set_data(tensor) return subject