| Total Complexity | 3 | 
| Total Lines | 25 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import SimpleITK as sitk  | 
            ||
| 2 | |||
| 3 | from .label_transform import LabelTransform  | 
            ||
| 4 | |||
| 5 | |||
| 6 | class Contour(LabelTransform):  | 
            ||
| 7 | r"""Keep only the borders of each connected component in a binary image.  | 
            ||
| 8 | |||
| 9 | Args:  | 
            ||
| 10 | **kwargs: See :class:`~torchio.transforms.Transform` for additional  | 
            ||
| 11 | keyword arguments.  | 
            ||
| 12 | """  | 
            ||
| 13 | def __init__(self, **kwargs):  | 
            ||
| 14 | super().__init__(**kwargs)  | 
            ||
| 15 | self.args_names = []  | 
            ||
| 16 | |||
| 17 | def apply_transform(self, subject):  | 
            ||
| 18 | for image in self.get_images(subject):  | 
            ||
| 19 | assert image.data.ndim == 4 and image.data.shape[0] == 1  | 
            ||
| 20 | sitk_image = image.as_sitk()  | 
            ||
| 21 | contour = sitk.BinaryContour(sitk_image)  | 
            ||
| 22 | tensor, _ = self.sitk_to_nib(contour)  | 
            ||
| 23 | image.set_data(tensor)  | 
            ||
| 24 | return subject  | 
            ||
| 25 |