biapy.data.generators.single_data_3D_generator

3D single image data generator for BiaPy.

This module provides the Single3DImageDataGenerator class, which generates batches of 3D images with on-the-fly augmentation for deep learning workflows.

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

Bases: SingleBaseDataGenerator

Custom 3D data generator to transform single image data.

Parameters:

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

apply_transform(image)[source]

Apply transformations to the input image, including optional z-flip.

Parameters:

image (4D Numpy array) – Input image to transform. E.g. (z, y, x, channels).

Returns:

image – Transformed image. E.g. (z, y, x, channels).

Return type:

4D Numpy array

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

Save transformed samples in order to check the generator.

Parameters:
  • img (4D Numpy array) – Image to use as sample. E.g. (z, y, x, channels).

  • orig_images (dict) – Dict where the original image is saved in “o_x”.

  • i (int) – Number of the sample within the transformed ones.

  • pos (int) – Number of the sample within the dataset.

  • out_dir (str) – Directory to save the images.

  • draw_grid (bool) – Whether to draw a grid or not.