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

histomicstk.segmentation.nuclear.detect_tile_nuclei(tile_info, args, src_mu_lab=None, src_sigma_lab=None, invert_image=False, default_img_inversion=False, return_fdata=False)[source]

Detect nuclei within a tile image and generate annotations.

Args:

tile_info (dict): Information about the tile image. args: Arguments from the cli. src_mu_lab: Source mean in LAB color space. src_sigma_lab: Source standard deviation in LAB color space. invert_image (bool): Invert the image. default_img_inversion (bool): Apply default image inversion. return_fdata (bool): Return computed features.

Returns:

nuclei_annot_list (list): List of nuclei annotations. fdata: Computed nuclei features.

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

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 parameter 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

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

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. Referred 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