napari_cellseg3d.utils#

Utilities functions, classes, and variables.

Functions

align_array_sizes(array_shape, target_shape)

Aligns the sizes of two arrays by adding zeros to the smaller one.

channels_fraction_above_threshold(volume[, ...])

Computes the fraction of pixels above a certain value in a 4D volume for each channel.

correct_rotation(image)

Rotates the axes 0 and 2 in [DHW] section of image array.

denormalize_y(image)

De-normalizes the values of an image array to be between [0;255] rather than [0;1].

dice_coeff(y_true, y_pred[, smooth])

Compute Dice-Sorensen coefficient between two numpy arrays.

fill_list_in_between(lst, n, fill_value)

Fills a list with n * elem between each member of list.

fraction_above_threshold(volume[, threshold])

Computes the fraction of pixels above a certain value in a volume.

get_all_matching_files(path[, pattern])

Returns a list of all files in a directory matching the pattern.

get_date_time()

Get date and time in the following format : year_month_day_hour_minute_second.

get_padding_dim(image_shape[, anisotropy_factor])

Finds the nearest and superior power of two for each image dimension to zero-pad it for CNN processing.

get_time()

Get time in the following format : hour:minute:second.

get_time_filepath()

Get time in the following format : hour_minute_second.

load_images(dir_or_path[, filetype, as_folder])

Loads the images in directory, with different behaviour depending on filetype and as_folder.

mkdir_from_str(path[, exist_ok, parents])

Creates a directory from a string path.

normalize_max(image)

Normalizes an image using the max and min value.

normalize_x(image)

Normalizes the values of an image array to be between [-1;1] rather than [0;255].

normalize_y(image)

Normalizes the values of an image array to be between [0;1] rather than [0;255].

parse_default_path(possible_paths[, ...])

Returns a default path based on a vector of paths, some of which might be empty.

quantile_normalization(image[, ...])

Normalizes an image using the quantiles.

remap_image(image[, new_max, new_min, ...])

Normalizes a numpy array or Tensor using the max and min value.

resize(image, zoom_factors)

Resizes an image using the zoom_factors.

save_folder(results_path, folder_name, ...)

Saves a list of images in a folder.

save_layer(results_path, image_name, image)

Saves an image layer at the specified path.

seek_best_dice_coeff_channel(y_pred, y_true)

Compute Dice-Sorensen coefficient between unsupervised model output and ground truth labels; returns the channel with the highest dice coefficient.

show_result(viewer, layer, image, name[, ...])

Adds layers to a viewer to show result to user.

sphericity_axis(semi_major, semi_minor)

Computes the sphericity from volume semi major (a) and semi minor (b) axes.

sphericity_volume_area(volume, surface_area)

Computes the sphericity from volume and area.

time_difference(time_start, time_finish[, ...])

Computes the time difference between two datetime objects.

Classes

Singleton

Singleton class that can only be instantiated once at a time, with said unique instance always being accessed on call.