segmentation#

Segmentation#

class scportrait.pipeline.segmentation.segmentation.Segmentation(config, directory, nuc_seg_name, cyto_seg_name, _tmp_image_path, project_location, debug, overwrite, project, filehandler, from_project: bool = False, **kwargs)#

Bases: ProcessingStep

Segmentation helper class used for creating segmentation workflows.

maps#

Segmentation workflows based on the Segmentation class can use maps for saving and loading checkpoints and perform operations. Maps can be array like structures, e.g. memory-mapped temp arrays.

Type:

dict(str)

DEFAULT_FILTER_ADDTIONAL_FILE#
Type:

str, default filtered_classes.csv

PRINT_MAPS_ON_DEBUG#
Type:

bool, default False

identifier#

Only set if called by ShardedSegmentation. Unique index of the shard.

Type:

int, default None

window#

Only set if called by ShardedSegmentation. Defines the window which is assigned to the shard. The window will be applied to the input. The first element refers to the first dimension of the image and so on. For example use [(0,1000),(0,2000)] To crop the image to 1000 px height and 2000 px width from the top left corner.

Type:

list(tuple), default None

input_path#

Only set if called by ShardedSegmentation. Location of the input hdf5 file. During sharded segmentation the ShardedSegmentation derived helper class will save the input image in form of a hdf5 file. This makes the input image available for parallel reading by the segmentation processes.

Type:

str, default None

process(input_image)#

Process the input image with the segmentation method.

ShardedSegmentation#

class scportrait.pipeline.segmentation.segmentation.ShardedSegmentation(*args, **kwargs)#

Bases: Segmentation

To perform a sharded segmentation where the input image is split into individual tiles (with overlap) that are processed idnividually before the results are joined back together.

process(input_image)#

Process the input image with the sharded segmentation method.

Important

This function is called automatically when a Segmentation Class is executed.

Parameters:

input_image (np.array) – Input image to be processed. The input image should be a numpy array of shape (C, H, W) where C is the number of channels, H is the height of the image and W is the width of the image.

complete_segmentation(input_image, force_run=False)#

Complete an already started sharded segmentation of the provided input image.

Parameters:
  • input_image (np.array) – Input image to be processed. The input image should be a numpy array of shape (C, H, W) where C is the number of channels, H is the height of the image and W is the width of the image.

  • force_run (bool) – If set to True the segmentation will be run even if a completed segmentation is already found in the sdata object. Default is False.