How to use the batchgenerators.transforms.MirrorTransform function in batchgenerators

To help you get started, we’ve selected a few batchgenerators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jenspetersen / probabilistic-unet / probunet / experiment / probabilistic_unet_segmentation.py View on Github external
generator_val=data.LinearBatchGenerator,
        transforms_train={
            0: {
                "type": SpatialTransform,
                "kwargs": {
                    "patch_size": patch_size,
                    "patch_center_dist_from_border": patch_size[0] // 2,
                    "do_elastic_deform": False,
                    "p_el_per_sample": 0.2,
                    "p_rot_per_sample": 0.3,
                    "p_scale_per_sample": 0.3
                },
                "active": True
            },
            1: {
                "type": MirrorTransform,
                "kwargs": {"axes": (0, 1, 2)},
                "active": True
            },
            2: {
                "type": SegLabelSelectionBinarizeTransform,
                "kwargs": {"label": [1, 2, 3]},
                "active": False
            }
        },
        transforms_val={
            0: {
                "type": CenterCropTransform,
                "kwargs": {"crop_size": patch_size},
                "active": False
            },
            1: {
github MIC-DKFZ / basic_unet_example / datasets / three_dim / data_augmentation.py View on Github external
def get_transforms(mode="train", target_size=128):
    transform_list = []

    if mode == "train":
        transform_list = [CenterCropTransform(crop_size=target_size),
                          ResizeTransform(target_size=target_size, order=1),
                          MirrorTransform(axes=(2,)),
                          SpatialTransform(patch_size=(target_size, target_size, target_size), random_crop=False,
                                           patch_center_dist_from_border=target_size // 2,
                                           do_elastic_deform=True, alpha=(0., 1000.), sigma=(40., 60.),
                                           do_rotation=True,
                                           angle_x=(-0.1, 0.1), angle_y=(0, 1e-8), angle_z=(0, 1e-8),
                                           scale=(0.9, 1.4),
                                           border_mode_data="nearest", border_mode_seg="nearest"),
                          ]

    elif mode == "val":
        transform_list = [CenterCropTransform(crop_size=target_size),
                          ResizeTransform(target_size=target_size, order=1),
                          ]

    elif mode == "test":
        transform_list = [CenterCropTransform(crop_size=target_size),
github MIC-DKFZ / basic_unet_example / datasets / two_dim / data_augmentation.py View on Github external
def get_transforms(mode="train", target_size=128):
    tranform_list = []

    if mode == "train":
        tranform_list = [# CenterCropTransform(crop_size=target_size),
                         ResizeTransform(target_size=(target_size,target_size), order=1),
                         MirrorTransform(axes=(1,)),
                         SpatialTransform(patch_size=(target_size, target_size), random_crop=False,
                                          patch_center_dist_from_border=target_size // 2,
                                          do_elastic_deform=True, alpha=(0., 900.), sigma=(20., 30.),
                                          do_rotation=True, p_rot_per_sample=0.8,
                                          angle_x=(-15. / 360 * 2. * np.pi, 15. / 360 * 2. * np.pi), angle_y=(0, 1e-8), angle_z=(0, 1e-8),
                                          scale=(0.85, 1.25), p_scale_per_sample=0.8,
                                          border_mode_data="nearest", border_mode_seg="nearest"),
                         ]


    elif mode == "val":
        tranform_list = [# CenterCropTransform(crop_size=target_size),
                         ResizeTransform(target_size=target_size, order=1),
                         ]

    elif mode == "test":
github frankkramer-lab / MIScnn / miscnn / processing / data_augmentation.py View on Github external
def run(self, img_data, seg_data):
        # Define label for segmentation for segmentation augmentation
        if self.seg_augmentation : seg_label = "seg"
        else : seg_label = "class"
        # Create a parser for the batchgenerators module
        data_generator = DataParser(img_data, seg_data, seg_label)
        # Initialize empty transform list
        transforms = []
        # Add mirror augmentation
        if self.mirror:
            aug_mirror = MirrorTransform(axes=self.config_mirror_axes)
            transforms.append(aug_mirror)
        # Add contrast augmentation
        if self.contrast:
            aug_contrast = ContrastAugmentationTransform(
                                        self.config_contrast_range,
                                        preserve_range=True,
                                        per_channel=True,
                                        p_per_sample=self.config_p_per_sample)
            transforms.append(aug_contrast)
        # Add brightness augmentation
        if self.brightness:
            aug_brightness = BrightnessMultiplicativeTransform(
                                        self.config_brightness_range,
                                        per_channel=True,
                                        p_per_sample=self.config_p_per_sample)
            transforms.append(aug_brightness)
github frankkramer-lab / MIScnn / miscnn / preprocessing / data_augmentation.py View on Github external
def run(self, img_data, seg_data):
        # Create a parser for the batchgenerators module
        data_generator = DataParser(img_data, seg_data)
        # Initialize empty transform list
        transforms = []
        # Add mirror augmentation
        if self.mirror:
            aug_mirror = MirrorTransform(axes=self.config_mirror_axes)
            transforms.append(aug_mirror)
        # Add contrast augmentation
        if self.contrast:
            aug_contrast = ContrastAugmentationTransform(
                                        self.config_contrast_range,
                                        preserve_range=True,
                                        per_channel=True,
                                        p_per_sample=self.config_p_per_sample)
            transforms.append(aug_contrast)
        # Add brightness augmentation
        if self.brightness:
            aug_brightness = BrightnessMultiplicativeTransform(
                                        self.config_brightness_range,
                                        per_channel=True,
                                        p_per_sample=self.config_p_per_sample)
            transforms.append(aug_brightness)