lazyslide_models.tile_prediction.cv_features.ColorDeconvolution#
- class ColorDeconvolution(stain='hed')#
Bases:
_CVFeaturescolor_deconvolution Paper [Ruifrok and Johnston, 2001] Mean amount of each stain in a tile (hematoxylin, eosin, DAB), by color deconvolution
Measure the stains in a tile by color deconvolution.
Each pixel’s optical density is unmixed into the amounts of three stains, given their RGB absorption vectors, and each amount is averaged over the tile. On an IHC slide,
dabmeasures the chromogen.The amounts are in the units of
skimage.color.separate_stains, so the default equalsskimage.color.rgb2hedaveraged over the tile: a pixel holding amountssof stains with RGB vectorsVtransmits10 ** (-6 * s @ V)of the light. Negative amounts are clipped to zero in each pixel.An absent stain does not read zero, since real pixels are never exact mixtures of the stain vectors: an H&E slide reads a
dabof about 0.02 to 0.05, so compare tiles with each other or with a negative control. White background adds zero, so a tile with less tissue has a lower mean; for statistics over the tissue alone, useColorDeconvolutionMap. The presets are published stain vectors. Stain colors vary with the staining batch and the scanner, so pass measured vectors when the numbers matter.>>> zs.tl.tile_prediction(wsi, "color_deconvolution") >>> tiles = wsi["tiles"] >>> tiles[tiles["dab"] > tiles["dab"].quantile(0.9)]
- Parameters:
- stainstr or dict, default: “hed”
The stains to unmix.
"hed"giveshematoxylin,eosinanddab;"hdx"giveshematoxylin,daband aresidual, for IHC without eosin. A dict of exactly three{name: vector}entries unmixes custom stains: each vector is the stain’s optical density in red, green and blue, like a row ofskimage.color.rgb_from_hed. The names become the columns.
- columns = ('hematoxylin', 'eosin', 'dab')#
Subclasses whose
_funcreturns a dict set this explicitly; for the rest it is derived below from the class name, which is the same rule_process_batchuses to key its result.