lazyslide.seg.artifact

Contents

lazyslide.seg.artifact#

artifact(wsi, tile_key, model='grandqc', variant='7x', mode='gaussian', sigma_scale=None, low_memory=False, threshold=0.8, buffer_px=2, batch_size=4, num_workers=0, device=None, amp=None, autocast_dtype=None, key_added='artifacts', pbar=None, *args)#

Artifact segmentation for the whole slide image.

Run GrandQC [Weng et al., 2024] artifact segmentation model on the whole slide image. The model is trained on 512x512 tiles with mpp=1.5, 2, or 1.

It can detect the following artifacts:

  • Fold

  • Darkspot & Foreign Object

  • Pen Marking

  • Edge & Air Bubble

  • Out of Focus

Parameters:
wsiWSIData

The WSIData object to work on.

tile_keystr

The key of the tile table.

model{“grandqc”}, default: “grandqc”

The model to use for artifact segmentation.

variantstr, default: “7x”

The model variants, grandqc has variants 5x, 7x and 10x.

mode{“constant”, “gaussian”}, default: “gaussian”

The probability distribution to apply for the prediction map. If “constant”, uses uniform weights, “gaussian” applies a Gaussian weighting.

sigma_scalefloat

The scale of the Gaussian sigma for the importance map if mode is “gaussian”. If None, the scale is calculated based on the overlap of the tiles.

low_memorybool, default: False

Whether to use a low-memory mode for processing large slides.

thresholdfloat, default: 0.8

The probability threshold to consider a pixel as an artifact.

buffer_pxint, default: 2

The buffer in pixels to apply when merging polygons.

batch_sizeint, default: 4

The batch size for segmentation.

num_workersint, default: 0

The number of workers for data loading.

devicestr, default: None

The device for the model.

key_addedstr, default: “artifacts”

The key for the added artifact shapes.

pbarbool, default: True

Whether to show a progress bar during segmentation.