wsipipe.preprocess.patching package

patch_finder module

Patch Finders describe how patches are created for a slide.

They work on a labelled image, that is a numpy array with integers giving the annotation category for each pixel.

The input labelled image can be at any level of the pyramid for which a numpy array for that size can fit into memory.

A patch finder will create a dataframe with columns x, y, label where x and y represents the top left corner of the patch and label is the label applied to the patch.

class GridPatchFinder(labels_level, patch_level, patch_size, stride, border=0, jitter=0, remove_background=True, pool_mode='max')[source]

Bases: PatchFinder

Parameters:
  • labels_level (int) –

  • patch_level (int) –

  • patch_size (int) –

  • stride (int) –

  • border (int) –

  • jitter (int) –

  • remove_background (bool) –

  • pool_mode (str) –

labels_level()[source]
class PatchFinder[source]

Bases: object

Generic patch finder class

Parameters:
  • labels_image (np.array) – The whole slide image represented as a 2d numpy array, the classification is given by an integer. For example an image such as those output by AnnotationSet.render

  • slide_shape (Size) – The size of the WSI at the level at which the labels are rendered. This may be different to the labels image shape, as the labels image may not include blank parts of the slide in the bottom right.

abstract property labels_level
class RandomPatchFinder(labels_level, patch_level, patch_size, border=0, npatches=1000, pool_mode='mode')[source]

Bases: PatchFinder

Parameters:
  • labels_level (int) –

  • patch_level (int) –

  • patch_size (int) –

  • border (int) –

  • npatches (int) –

  • pool_mode (str) –

labels_level()[source]

patchset module

patchset_utils module