Color thresholding semantic segmentation

Created on Tue Oct 22 02:37:52 2019.

@author: mtageld

class histomicstk.saliency.cellularity_detection_thresholding.CDT_single_tissue_piece(cdt, tissue_mask, monitorPrefix='')[source]

Bases: object

Detect various regions in a single tissue piece (internal).

assign_components_by_thresholding()[source]

Get components by thresholding in HSI and LAB spaces.

color_normalize_unspecified_components()[source]

Color normalize “true” tissue components.

find_potentially_cellular_regions()[source]

Find regions that are potentially cellular.

find_top_cellular_regions()[source]

Keep largest and most cellular regions.

initialize_labeled_mask()[source]

Initialize labeled components mask.

restrict_mask_to_single_tissue_piece()[source]

Only keep relevant part of slide mask.

run()[source]

Get cellularity and optionally visualize on DSA.

set_tissue_rgb()[source]

Load RGB from server for single tissue piece.

visualize_results()[source]

Visualize results in DSA.

class histomicstk.saliency.cellularity_detection_thresholding.Cellularity_detector_thresholding(gc, slide_id, GTcodes, **kwargs)[source]

Bases: histomicstk.utils.general_utils.Base_HTK_Class

Detect cellular regions in a slide using thresholding.

This uses a thresholding and stain unmixing based pipeline to detect highly-cellular regions in a slide. The run() method of the CDT_single_tissue_piece() class has the key steps of the pipeline. In summary, here are the steps involved…

1. Detect tissue from background using the RGB slide thumbnail. Each “tissue piece” is analysed independently from here onwards. The tissue_detection modeule is used for this step. A high sensitivity, low specificity setting is used here.

2. Fetch the RGB image of tissue at target magnification. A low magnification (default is 3.0) is used and is sufficient.

3. The image is converted to HSI and LAB spaces. Thresholding is performed to detect various non-salient components that often throw-off the color normalization and deconvolution algorithms. Thresholding includes both minimum and maximum values. The user can set whichever thresholds of components they would like. The development of this workflow was focused on breast cancer so the thresholded components by default are whote space (or adipose tissue), dark blue/green blotches (sharpie, inking at margin, etc), and blood. Whitespace is obtained by thresholding the saturation and intensity, while other components are obtained by thresholding LAB.

4. Now that we know where “actual” tissue is, we do a MASKED color normalization to a prespecified standard. The masking ensures the normalization routine is not thrown off by non- tissue components.

5. Perform masked stain unmixing/deconvolution to obtain the hematoxylin stain channel.

6. Smooth and threshold the hematoxylin channel. Then perform connected component analysis to find contiguous potentially-cellular regions.

7. Keep the n largest potentially-cellular regions. Then from those large regions, keep the m brightest regions (using hematoxylin channel brightness) as the final salient/cellular regions.

fix_GTcodes()[source]

Fix self.GTcodes (important!).

run()[source]

Run full pipeline to detect cellular regions.

set_color_normalization_target(ref_image_path, color_normalization_method='macenko_pca')[source]

Set color normalization values to use from target image.

Arguments ref_image_path, str > path to target (reference) image color_normalization_method, str > color normalization method to use. Currently, only > reinhard and macenko_pca are accepted.

set_slide_info_and_get_tissue_mask()[source]

Set self.slide_info dict and self.labeled tissue mask.