Finding cellular regions with superpixel analysis¶
Created on Mon Sep 23 21:17:43 2019.
@author: mtageld
- class histomicstk.saliency.cellularity_detection_superpixels.CD_single_tissue_piece(cd, tissue_mask, monitorPrefix='')[source]¶
Bases:
object
Detect cellular regions in a single tissue piece (internal).
- class histomicstk.saliency.cellularity_detection_superpixels.Cellularity_detector_superpixels(gc, slide_id, **kwargs)[source]¶
Bases:
Base_HTK_Class
Detect cellular regions in a slides by classifying superpixels.
This uses Simple Linear Iterative Clustering (SLIC) to get superpixels at a low slide magnification to detect cellular regions. The first step of this pipeline detects tissue regions (i.e. individual tissue pieces) using the get_tissue_mask method of the histomicstk.saliency module. Then, each tissue piece is processed separately for accuracy and disk space efficiency. It is important to keep in mind that this does NOT rely on a tile iterator, but loads the entire tissue region (but NOT the whole slide) in memory and passes it on to skimage.segmentation.slic method.
Once superpixels are segmented, the image is deconvolved and features are extracted from the hematoxylin channel. Features include intensity and possibly also texture features. Then, a mixed component Gaussian mixture model is fit to the features, and median intensity is used to rank superpixel clusters by ‘cellularity’ (since we are working with the hematoxylin channel).
Additional functionality includes contour extraction to get the final segmentation boundaries of cellular regions and to visualize them in DSA using one’s preferred colormap.
- run()[source]¶
Run cellularity detection and optionally visualize result.
This runs the cellularity detection +/- visualization pipeline and returns a list of CD_single_tissue_piece objects. Each object has the following attributes
- tissue_masknp array
mask of where tissue is at target magnification
- yminint
min y coordinate at base (scan) magnification
- xminint
min x coordinate at base (scan) magnification
- ymaxint
max y coordinate at base (scan) magnification
- xmaxint
max x coordinate at base (scan) magnification
- spixel_masknp array
np array where each unique value represents one superpixel
- fdatapandas DataFrame
features extracted for each superpixel. Index corresponds to values in the spixel_mask. This includes a ‘cluster’ column indicatign which cluster this superpixel belongs to.
- cluster_propsdict
properties of each superpixel cluster, including its assigned cellularity score.