elektronn2.data.non_geometric_augmentation module

exception elektronn2.data.non_geometric_augmentation.InvalidNonGeomAugmentParameters[source]

Bases: exceptions.Exception

elektronn2.data.non_geometric_augmentation.add_blobs(data, num_blob_range, blob_size_range, data_overwrite, blob_operator, blob_operator_args=())[source]
elektronn2.data.non_geometric_augmentation.blur_augment(data, level=1, data_overwrite=False)[source]

The function performs Gaussian smoothing on the original data.

By default the raw data will be copied in order to avoid overwriting the original data. However, the user can disable that and allow the function to make changes to the passed data. The function doesn’t require to change the corresponding labels of the raw data.

Parameters:
  • data (np.ndarray) – Current field of view. Has to have the following format: [num_channels, z, x, y]
  • level (int) – Strength of the gaussian smoothing.
  • data_overwrite (bool) – Determines whether the input data may be modified. If data_overwrite is true the original data passed to the function will be overwritten.
Returns:

data – The array has the following format: [num_channels, z, x, y]

Return type:

np.ndarray

elektronn2.data.non_geometric_augmentation.blur_blob(blob, diffuseness=None)[source]
elektronn2.data.non_geometric_augmentation.blurry_blobs(data, diffuseness, num_blob_range=(5, 15), blob_size_range=(10, 32), data_overwrite=False)[source]

Generates random blobs across the given (raw) input data.

A blob is a cube of the size that will be randomly drawn from the blob_size_range. The area within the blob will be affected by Gausssian smoothing. Depending on the diffuseness level the blob can stay almost transparent (in case of low diffuseness value) or be filled with the mean color value of the blob region (in case of high diffuseness value)

By default the raw data will be copied in order to avoid overwriting the original data. However, the user can disable that and allow the function to make changes to the passed data. The function doesn’t require to change the corresponding labels of the raw data

If the size of a blob exceeds the length of any dimension of the give volume the blob size will be assigned to the length of the corresponding dimension.

Parameters:
  • data (np.ndarray) – Current field of view. It has to have the following format: [num_channels, z, x, y]
  • diffuseness (int) – The standard deviation of the applied Gaussian kernel.
  • num_blob_range ((int, int)) – Range of possible numbers of blobs generated
  • blob_size_range ((int, int)) – Range of possible blob sizes
  • data_overwrite (bool) – Determines whether the input data may be modified. If data_overwrite is true the original data passed to the function will be overwritten.
Returns:

data – Augmented data of the following format: [num_channels, z, x, y]

Return type:

np.ndarray

elektronn2.data.non_geometric_augmentation.make_blob(data, blob_operator, blob_operator_args, depth, width, height, blob_size)[source]

Generates a random blob within the given field of view.

The user can control the level of diffuseness or it can be generated automatically drawing from a distribution.

Parameters:
  • data (np.ndarray) – Represents the current field of view. It has to have the following format: [num_channels, z, x, y]
  • blob_operator (Function to apply on the blob, i.e.) – blur_blob, random_noise_blob or uniform_blob
  • blob_operator_args (tuple) – Arguments that are passed to the blob operator
  • depth (int) – The depth of the field of view
  • width (int) – The width of the field of view
  • height (int) – The height of the field of view
  • blob_size (int) – A particular size of a blob
elektronn2.data.non_geometric_augmentation.noise_augment(data, level=0.15, data_overwrite=False)[source]

Adds random noise to the original raw data passed to the function.

By default the raw data will be copied in order to avoid of overwriting of the original data. However, the user can disable that and allow the function to make changes on the passed data. The function doesn’t require to change the corresponding labels of the raw data

If the noise level is too high (more than 1.0) or too low (less than 0.0) the function throws the corresponding error

Parameters:
  • data (np.ndarray) – Current field of view. Has to have the following format: [num_channels, z, x, y]
  • level (float) – Strength of the noise. The maximum value is 1.0.
  • data_overwrite – Determines whether the input data may be modified. If data_overwrite is true the original data passed to the function will be overwritten.
data: np.ndarray
The array has the following format: [num_channels, z, x, y]
elektronn2.data.non_geometric_augmentation.noisy_random_erasing(data, noise_range=(0, 255), num_blob_range=(5, 15), blob_size_range=(10, 32), data_overwrite=False)[source]

Like blurry_blobs, but the blob area is filled with random noise.

elektronn2.data.non_geometric_augmentation.random_noise_blob(blob, noise_range=(0, 255))[source]
elektronn2.data.non_geometric_augmentation.uniform_blob(blob, value)[source]
elektronn2.data.non_geometric_augmentation.uniform_random_erasing(data, value, num_blob_range=(5, 15), blob_size_range=(10, 32), data_overwrite=False)[source]

Like blurry blobs, but the blob area is filled with a uniform value.