segmentation#
Segmentation#
- class scportrait.pipeline.segmentation.Segmentation(config, directory, nuc_seg_name, cyto_seg_name, _tmp_image_path, project_location, debug, overwrite, project, filehandler, **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. Maps can be numpy 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 theShardedSegmentation
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
Example
def process(self): # two maps are initialized self.maps = {"map0": None, "map1": None} # its checked if the segmentation directory already contains these maps and they are then loaded. The index of the first map which has not been found is returned. It indicates the step where computation needs to resume current_step = self.load_maps_from_disk() if current_step <= 0: # do stuff and generate map0 self.save_map("map0") if current_step <= 1: # do stuff and generate map1 self.save_map("map1")
- save_map(map_name)#
Saves newly computed map.
- Args
map_name (str): name of the map to be saved, as defined in
self.maps
.
Example
# declare all intermediate maps self.maps = {"myMap": None} # load intermediate maps if possible and get current processing step current_step = self.load_maps_from_disk() if current_step <= 0: # do some computations self.maps["myMap"] = myNumpyArray # save map self.save_map("myMap")
- process(input_image)#
Process the input image with the segmentation method.