3D pair generator

class biapy.data.generators.pair_data_3D_generator.Pair3DImageDataGenerator(zflip=False, **kwars)[source]

Bases: PairBaseDataGenerator

Custom 3D data generator based on imgaug and our own augmentors.py transformations. This generator will yield an image and its corresponding mask.

Based on microDL and Shervine’s blog.

Parameters:

zflip (bool, optional) – To activate flips in z dimension.

ensure_shape(img, mask)[source]
apply_transform(image, mask, e_im=None, e_mask=None)[source]

Transform the input image and its mask at the same time with one of the selected choices based on a probability.

Parameters:
  • image (3D/4D Numpy array) – Image to transform. E.g. (y, x, channels) in 2D and (z, y, x, channels) in 3D.

  • mask (3D/4D Numpy array) – Mask to transform. E.g. (y, x, channels) in 2D and (z, y, x, channels) in 3D.

  • e_img (3D/4D Numpy array) – Extra image to help transforming image. E.g. (y, x, channels) in 2D or (z, y, x, channels) in 3D.

  • e_mask (3D/4D Numpy array) – Extra mask to help transforming mask. E.g. (y, x, channels) in 2D or (z, y, x, channels) in 3D.

Returns:

  • image (3D/4D Numpy array) – Transformed image. E.g. (y, x, channels) in 2D or (y, x, z, channels) in 3D.

  • mask (3D/4D Numpy array) – Transformed image mask. E.g. (y, x, channels) in 2D or (y, x, z, channels) in 3D.

save_aug_samples(img, mask, orig_images, i, pos, out_dir, point_dict)[source]