histomicstk.segmentation.nuclear

This package contains implementations of state-of-th-art methods for segmenting nuclei from histopathology images.

histomicstk.segmentation.nuclear.detect_nuclei_kofahi(im_nuclei_stain, im_nuclei_fgnd_mask, min_radius, max_radius, min_nucleus_area, local_max_search_radius)[source]

Performs a nuclear segmentation using kofahi’s method.

This method uses scale-adaptive multi-scale Laplacian-of-Gaussian filtering for blob enhancement and a local maximum clustering for segmentation. The original implementation described by Al-Kofahi et al. uses Laplacian of Gaussian but this function replaces it with Difference of Gaussian to improve speed.

Parameters
  • im_nuclei_stain (array_like) – A hematoxylin intensity image obtained from ColorDeconvolution.

  • im_nuclei_fgnd_mask (array_like) – A binary mask of the nuclear foreground typically obtained by applying a threshold on the hematoxylin/nuclei stain image

  • min_radius (float) – Minimum nuclear radius (used to set min sigma of the multiscale LoG filter)

  • max_radius (float) – Maximum nuclear radius (used to set max sigma of the multiscale LoG filter)

  • min_nucleus_area (int) – Minimum area that each nucleus should have

  • local_max_search_radius (float) – Local max search radius used for detection seed points in nuclei

Returns

im_nuclei_seg_mask – A 2D array mask of the nuclei segmentation.

Return type

array_like

References

1

Y. Al-Kofahi et al “Improved Automatic Detection and Segmentation of Cell Nuclei in Histopathology Images” in IEEE Transactions on Biomedical Engineering, Volume: 57, Issue: 4, doi: 10.1109/TBME.2009.2035102, April 2010.

histomicstk.segmentation.nuclear.gaussian_voting(I, rmax=35, rmin=10, sSigma=5, Tau=5, bw=15, Psi=0.3)[source]

Performs nuclear detection using Gaussian kernel voting.

Uses a gaussian kernel to localize the centroids of cell nuclei. Takes as input a hematoxylin-deconvolved image and uses the gradient signal to cast directed votes towards the center of cell nuclei. These votes are blurred by a gaussian kernel, and are spatially clustered using the mean-shift algorithm. Convolutions are performed separably to reduce compute time.

Parameters
  • I (array_like) – A hematoxylin intensity image obtained from ColorDeconvolution.

  • rmax (double) – Upper-limit on voting area extent. Default value = 35.

  • rmin (double) – Lower-limit on voting area extent. Default value = 10.

  • sSigma (double) – Standard deviation of smoothing kernel used in gradient calculation. Default value = 5.

  • Tau (double) – Lower limit on gradient magnitude for casting a vote. Default value = 5.

  • bw (double) – Bandwidth parameter for mean-shift clustering. Default value = 15.

  • Psi (double) – Lower limit threshold on votes. Expressed as a fraction of the maximum vote, ranges from [0, 1). Default value = 0.3.

Returns

  • Centroids (array_like) – An N x 2 array defining the (x,y) coordinates of cell centroids.

  • Votes (array_like) – An intensity image containing the blurred votes obtained by voting.

Notes

Return values are returned as a namedtuple

References

2

X. Qi, F. Xing, D.J. Foran, L. Yang, “Robust Segmentation of Overlapping Cells in Histopathology Specimens Using Parallel Seed Detection and Repulsive Level Set,” in IEEE Transactions on Biomedical Engineering, vol.59,no.23,pp.754-65, 2011.

histomicstk.segmentation.nuclear.gvf_tracking(I, Mask, K=1000, Diffusions=10, Mu=5, Lambda=5, Iterations=10, dT=0.05)[source]

Performs gradient-field tracking to segment smoothed images of cell nuclei.

Takes as input a smoothed intensity or Laplacian-of-Gaussian filtered image and a foreground mask, and groups pixels by tracking them to mutual gradient sinks. Typically requires merging of sinks (seeds) as a post processing steps.

Parameters
  • I (array_like) – Smoothed intensity or log-filtered response where nuclei regions have larger intensity values than background.

  • Mask (array_like) – Binary mask where foreground objects have value 1, and background objects have value 0. Used to restrict influence of background vectors on diffusion process and to reduce tracking computations.

  • K (float) – Number of steps to check for tracking cycle. Default value = 1000.

  • Mu (float) – Weight parmeter from Navier-Stokes diffusion - weights divergence and Laplacian terms. Default value = 5.

  • Lambda (float) – Weight parameter from Navier-Stokes diffusion - used to weight divergence. Default value = 5.

  • Iterations (float) – Number of time-steps to use in Navier-Stokes diffusion. Default value = 10.

  • dT (float) – Timestep to be used in Navier-Stokes diffusion. Default value = 0.05.

Returns

  • Segmentation (array_like) – Label image where positive values correspond to foreground pixels that share mutual sinks.

  • Sinks (array_like) – N x 2 array containing the (x,y) locations of the tracking sinks. Each row is an (x,y) pair - in that order.

References

3

G. Li et al “3D cell nuclei segmentation based on gradient flow tracking” in BMC Cell Biology,vol.40,no.8, 2007.

histomicstk.segmentation.nuclear.max_clustering(im_response, im_fgnd_mask, r=10)[source]

Local max clustering pixel aggregation for nuclear segmentation. Takes as input a constrained log or other filtered nuclear image, a binary nuclear mask, and a clustering radius. For each pixel in the nuclear mask, the local max is identified. A hierarchy of local maxima is defined, and the root nodes used to define the label image.

Parameters
  • im_response (array_like) – A filtered-smoothed image where the maxima correspond to nuclear center. Typically obtained by constrained-LoG filtering on a hematoxylin intensity image obtained from ColorDeconvolution.

  • im_fgnd_mask (array_like) – A binary mask of type boolean where nuclei pixels have value ‘True’, and non-nuclear pixels have value ‘False’.

  • r (float) – A scalar defining the clustering radius. Default value = 10.

Returns

  • im_label (array_like) – im_label image where positive values correspond to foreground pixels that share mutual sinks.

  • seeds (array_like) – An N x 2 array defining the (x,y) coordinates of nuclei seeds.

  • max_response (array_like) – An N x 1 array containing the maximum response value corresponding to ‘seeds’.

References

4

XW. Wu et al “The local maximum clustering method and its application in microarray gene expression data analysis,” EURASIP J. Appl. Signal Processing, volume 2004, no.1, pp.53-63, 2004.

5

Y. Al-Kofahi et al “Improved Automatic Detection and Segmentation of Cell Nuclei in Histopathology Images” in IEEE Transactions on Biomedical Engineering,vol.57,no.4,pp.847-52, 2010.

histomicstk.segmentation.nuclear.min_model(I, Delta=0.3, MaxLength=255, Compaction=3, MinArea=100, MinWidth=5, MinDepth=2, MinConcavity=inf)[source]

Performs a nuclear segmentation using a gradient contour tracing and geometry splitting algorithm. Implemented from the reference below.

Parameters
  • I (array_like) – An intensity image used for analyzing local minima/maxima and gradients. Dimensions M x N.

  • Delta (float) – Fractional difference threshold between minima/maxima pairs to be included in seed point detection. Fractional difference ([0, 1]) in total image range e.g. Delta = 0.3 with a uint8 input would translate to 0.3 * 255. Default value = 0.3.

  • MaxLength (int) – Maximum allowable contour length. Default value = 255.

  • Compaction (int) – Factor used in compacting objects to remove thin spurs. Refered to as ‘d’ in the paper. Default value = 3.

  • MinArea (int) – Minimum area of objects to analyze. Default value = 100.

  • MinWidth (int) – Minimum max-width of objects to analyze. Default value = 5.

  • MinDepth (float) – Minimum depth of concavities to consider during geometric splitting. Default value = 2.

  • MinConcavity (float) – Minimum concavity score to consider when performing for geometric splitting. Default value = np.inf.

Notes

Objects are assumed to be dark (as nuclei in hematoxylin channel from color deconvolution). Smoothing improves accuracy and computation time by eliminating spurious seed points. Specifying a value for ‘Delta’ prevents shallow transitions from being included, also reducing computation time and increasing specificity.

Returns

  • X (array_like) – A 1D array of horizontal coordinates of contour seed pixels for tracing.

  • Y (array_like) – A 1D array of the vertical coordinates of seed pixels for tracing.

  • Min (array_like) – A 1D array of the corresponding minimum values for contour tracing of seed point X, Y.

  • Max (array_like) – A 1D array of the corresponding maximum values for contour tracing of seed point X, Y.

References

6

S. Weinert et al “Detection and Segmentation of Cell Nuclei in Virtual Microscopy Images: A Minimum-Model Approach” in Nature Scientific Reports,vol.2,no.503, doi:10.1038/srep00503, 2012.