elektronn3.data.transforms.random_blurring module

class elektronn3.data.transforms.random_blurring.FunctionCallsCounter[source]

Bases: object

counter = 0
exception elektronn3.data.transforms.random_blurring.IncorrectLimits[source]

Bases: Exception

exception elektronn3.data.transforms.random_blurring.IncorrectThreshold[source]

Bases: Exception

exception elektronn3.data.transforms.random_blurring.IncorrectType[source]

Bases: Exception

exception elektronn3.data.transforms.random_blurring.IncorrectValue[source]

Bases: Exception

class elektronn3.data.transforms.random_blurring.ScalarScheduler(value, max_value=None, growth_type=None, interval=None, steps_per_report=None)[source]

Bases: object

A scheduler for a scalar value within an iterative process according to either linear or exponential growth. The user specifies the initial value, the maximum one, growth type and the number of steps within which the scalar value has to be gradually scaled. At each iteration the user has to explicitly call step() to update and modify the scalar value If the user doesn’t specify the maximum value or the interval, the scalar value works as a constant.

exp_update()[source]

Performs an update of the scheduled value according to the exponential growth

Return type

None

idle_update()[source]

No-op function (keeps the scheduled value constant)

Return type

None

lin_update()[source]

Performs an update of the scheduled value according to the linear growth

Return type

None

step()[source]

Performs an update of the scheduled value according to the growth type parameter chosen by the user :returns: :rtype: the current scalar value

elektronn3.data.transforms.random_blurring.apply_random_blurring(inp_sample, probability, threshold, lower_lim_region_size, upper_lim_region_size, verbose=False, save_path=None, num_steps_save=None)[source]

Takes an input sample and applies random blurring. At the beginning the function generates a random number within the range [0,1) and compares it with the probability value passed by the user. If the random number exceeds the probability value the function terminates and returns the controls to the caller. Otherwise, the function generates random regions within a raw data sample volume until the total accumulated region volume exceeds that value specified by means of the threshold parameter. The threshold denotes the percentage of input sample volume that has to be filled in by regions. Regions have different spatial shape which is randomly generated within the ranges specified by the user. Moreover, the volume within a region is blurred by a Gaussian filter.

Parameters
  • - input sample with the format (C (inp_sample) –

  • D

  • H

  • W)

  • - probability of applying the random blurring algorithm (probability) –

  • - controls the level of random blurring with respect to (threshold) – the input sample volume

  • - min values of region size along each axis (lower_lim_region_size) –

  • - max values of region size along each axis (upper_lim_region_size) –

  • - mode that controls text information on the screen (verbose) –

  • - path to the files that will contain modified (blurred) (save_path) – input sample in the “h5” format

  • - number of steps between writing modified (blurred) (num_steps_save) – raw data input sample in the “h5” format

Return type

None

elektronn3.data.transforms.random_blurring.check_random_data_blurring_config(patch_shape, probability, threshold, lower_lim_region_size, upper_lim_region_size, verbose=False, save_path=None, num_steps_save=None)[source]

Checks random data blurring parameters and ensures that all parameters won’t cause problems during apply_random_blurring function calls. The function raises exceptions if a conflict is detected. Use this function before a training procedure to be sure the config fulfills the requirements posed by the apply_random_blurring function

Parameters
  • - shape of input samples (patch_shape) –

  • - probability of applying the random blurring algorithm (probability) –

  • - controls the level of data random blurring with respect to (threshold) – input sample volume

  • - min values of regions size along each axis (lower_lim_region_size) –

  • - max values of regions size along each axis (upper_lim_region_size) –

  • - mode that controls text information on the screen (verbose) –

  • - path to the files that will contain a modified (blurred) (save_path) – raw data input sample in the “h5” format

  • - number of steps between writing a modified (blurred) (num_steps_save) – raw data input sample in the “h5” format

Return type

None