API Reference#

The API of DeLTA etc.

Assets#

Asset downloads (model files, training sets, and demonstration movies).

We provide our trained models, training sets, and evaluation movies in this google drive folder. We refer to these data files as “assets”.

You can of course download them manually, but shouldn’t have to, because DeLTA knows where to find them and downloads them automatically when needed, with the pooch library, which makes everything completely transparent.

Cache location#

Upon downloading the assets, DeLTA caches them in the default OS cache location (see the pooch documentation for details). If you want to download them to a different location, you can specify this path in the DELTA_ASSETS_CACHE environment variable.

For example, to set this variable permanently within your conda environment, you can run the following command in a terminal, inside your conda environment:

(delta_env)$ conda env config vars set DELTA_ASSETS_CACHE="D:/data/delta_cache"

download_training_set(presets, model)

Return the path of the training set for the currently loaded configuration.

download_demo_movie(presets)

Return the path of the demo movie for the currently loaded configuration.

download_model(presets, model)

Return the path of the downloaded model, after downloading it if needed.

Configuration#

Define, read and write DeLTA’s configuration.

Config(presets, models, model_file_rois, ...)

Configuration class containing DeLTA parameters.

Data#

Data manipulations and input/output operations.

data_augmentation(images_input, aug_par[, ...])

Create an augmented sample based on data augmentation parameters.

histogram_voodoo(image, rng[, ...])

Perform a deformation on the image histogram to simulate illumination changes.

illumination_voodoo(image, rng[, ...])

Simulate a variation in illumination along the length of the chamber.

SegmentationDataset(dataset, target_size, ...)

Dataset used to train the segmentation model.

load_training_dataset_seg(dataset_path, ...)

Create new segmentation datasets.

random_crop(img, seg, wei, target_size, rng)

Randomly crop a tuple of (image, segmentation mask, weight map).

save_result_seg(save_path, npyfile, *[, ...])

Save an array of segmentation output images to disk.

predict_generator_seg(files_path, *[, ...])

Get a generator for predicting segmentation on new image files once the segmentation U-Net has been trained.

seg_weights(mask[, classweights, w0, sigma])

Compute the weight map as described in the original U-Net paper to force the model to learn borders.

make_weights(training_dataset_path, ...)

Create and populate the directory training_dataset_path/wei with the image weights for training.

kernel(n)

Get kernel for morphological operations.

estimate_seg2D_classweights(mask_path[, ...])

Estimate the weights to assign each class in the weight maps.

seg_weights_2D(mask[, classweights])

Compute custom weightmaps designed for bacterial images where borders are difficult to distinguish.

estimate_classweights(gene[, num_samples])

Estimate the class weights to use with the weighted categorical cross-entropy based on the train_generator_track output.

train_generator_track(batch_size, img_path, ...)

Create a generato to train the tracking U-Net.

path_from_prototype(prototype, fileorder[, ...])

Generate full filename for specific frame based on file path, prototype, fileorder, and filenamesindexing.

predict_compile_from_seg_track(img_path, ...)

Compile an inputs array for tracking prediction with the tracking U-Net, directly from U-Net segmentation masks saved to disk.

tracking_weights(track, segall[, halo_distance])

Compute weights for tracking training sets.

save_result_track(save_path, npyfile[, ...])

Save tracking output masks to disk.

Lineage#

Cell- and lineage-related objects and functions.

CellFeatures(new_pole, old_pole[, length, ...])

Container for cell features of a given cell at a given frame.

Cell(motherid, first_frame, _daughterids, ...)

Container for a cell across the movie.

Lineage([cells])

Represents the cell lineages contained in a ROI.

Model#

Model and loss/metrics functions definitions.

This module contains the declaration of the U-Nets in Keras / Tensorflow as well as the loss function we used to train them. See our publications for descriptions of the models and losses.

For the seminal paper describing the structure of the U-Net model:

Ronneberger, Olaf, Philipp Fischer, and Thomas Brox. “U-net: Convolutional networks for biomedical image segmentation.” International Conference on Medical image computing and computer-assisted intervention. 2015

pixelwise_weighted_binary_crossentropy_seg(...)

Pixel-wise weighted binary cross-entropy loss.

pixelwise_weighted_binary_crossentropy_track(...)

Pixel-wise weighted binary cross-entropy loss.

unstack_acc(seg_weights, logits)

Compute binary accuracy from a stacked tensor with mask and weight map.

unet([input_size, final_activation, ...])

Create a U-Net.

unet_seg([pretrained_weights, input_size, ...])

Cell segmentation U-Net definition function.

unet_track([pretrained_weights, input_size, ...])

Tracking U-Net definition function.

unet_rois([input_size, levels, filters])

Segmentation U-Net for ROIs.

Pipeline#

Main processing pipeline.

Pipeline(xpreader, config[, resfolder])

Main Pipeline class to process all positions.

Position(position_nb, config)

Position-processing object.

ROI(img_stack, fluo_stack, roi_nb, ...)

ROI processor object.

Utilities#

Utility functions and class definitions that are used in pipeline.py.

CroppingBox(xtl, ytl, xbr, ybr)

Class describing a box to cut out.

XPReader(path[, channelnames])

Class to read experiment files from single files or from file sequences in folders.

cells_in_frame(labels, *[, return_contours])

Get numbers of cells present in frame, sorted along Y axis.

eucl(p1, p2)

Euclidean point to point distance.

track_poles(features, prev_old, prev_new)

Track poles of a cell to the previous old and new poles.

division_poles(features1, features2, ...)

Identify which poles belong to the mother and which to the daughter.

tracking_scores(labels, logits, boxes)

Get overlap scores between input/target cells and tracking outputs.

attributions(scores)

Get attribution matrix from tracking scores.

random_colors(cellids[, seed])

Generate list of random hsv colors.

write_video(images, filename[, crf, verbose])

Write images stack to video file with h264 compression.

roi_features(labels, poles, fluo_frames)

Extract single-cell morphological and fluorescence features.

image_edges(contour, shape)

Identify if cell touches image borders.

cell_width_length(cell_poles, distance_map)

Measure width and length of single cell.

cell_area(contour)

Area of a single cell.

cell_perimeter(contour)

Get single cell perimeter.

cell_fluo(fluo_frames, mask)

Extract mean fluorescence level from mask.

list_files(directory, suffixes)

Return a sorted list of filenames in directory that have one of the specified extensions.

tensorboard_callback()

Return a callback for TensorBoard logging.