Utils

norm_range

norm_range(mode)[source]

Closure function for range normalization

Parameters

mode (str) – ‘-1,1’ normalizes data to range [-1, 1], while ‘0,1’ normalizes data to range [0, 1]

Returns

normalization function

Return type

callable

norm_zero_mean_unit_std

norm_zero_mean_unit_std(data)[source]

Return normalized data with mean 0, standard deviation 1

Parameters

data (np.nadarray) –

Returns

normalized data

Return type

np.ndarray

is_valid_image_file

is_valid_image_file(fname, img_extensions, gt_extensions)[source]

Helper Function to check wheter file is image file and has at least one label file

Parameters
  • fname (str) – filename of image path

  • img_extensions (list) – list of valid image file extensions

  • gt_extensions (list) – list of valid gt file extensions

Returns

is valid data sample

Return type

bool

default_load_fn_2d

default_load_fn_2d(img_file, *label_files, img_shape, n_channels=1)[source]

loading single 2d sample with arbitrary number of samples

Parameters
  • img_file (string) – path to image file

  • label_files (list of strings) – paths to label files

  • img_shape (iterable) – shape of image

  • n_channels (int) – number of image channels

Returns

  • numpy.ndarray – image

  • Any – labels

LoadSample

class LoadSample(sample_ext: dict, sample_fn: collections.abc.Callable, dtype=None, normalize=(), norm_fn=<function norm_range.<locals>.norm_fn>, **kwargs)[source]

Bases: object

Provides a callable to load a single sample from multiple files in a folder