Class CellTools

java.lang.Object
qupath.lib.objects.CellTools

public class CellTools extends Object
Helper class for working with PathObjects that represent cells.
  • Constructor Details

    • CellTools

      public CellTools()
  • Method Details

    • constrainCellByScaledNucleus

      public static PathCellObject constrainCellByScaledNucleus(PathCellObject cell, double nucleusScaleFactor, boolean keepMeasurements)
      Constrain a cell boundary to fall within a maximum region, determined by scaling the nucleus ROI by a fixed scale factor about its centroid. This can be used to create more biologically plausible cell boundaries in cases where the initial boundary estimates may be too large.
      Parameters:
      cell - original cell object
      nucleusScaleFactor - scale factor by which the nucleus should be expanded to defined maximum cell size
      keepMeasurements - if true, retain the measurements of the original cell if creating a new cell; if false, discard existing measurements
      Returns:
      the updated cell object, or the original cell object either if its boundary falls within the specified limit or it lacks both boundary and nucleus ROIs
    • constrainCellOverlaps

      public static List<PathObject> constrainCellOverlaps(Collection<? extends PathObject> cells)
      Adjust cell boundary ROIs to be non-overlapping, by assigning overlaps to the cell with the closest nucleus. Results are returned as a new list of cells.
      Parameters:
      cells - input cells
      Returns:
      a new list of cells, potentially containing some of the original cells and other adjusted cells
      Implementation Note
      It is not guaranteed that the cells that are output will be in the same order as the input collection. This behavior may change in the future.
    • detectionsToCells

      public static List<PathObject> detectionsToCells(Collection<? extends PathObject> detections, double distance, double nucleusScale)
      Create cell objects by expanding the (nucleus) ROIs from existing detections to approximate the full cell boundary.
      Parameters:
      detections - the detection objects from which to create the cells; these define the nuclei
      distance - the maximum distance (in pixels) to expand each nucleus
      nucleusScale - the maximum size of the cell relative to the nucleus (ignored if ≤ 1).
      Returns:
      cell objects derived from the supplied detections. This may have fewer entries if not all detections could be used successfully.
      Implementation Note
      It is not guaranteed that the cells that are output will be in the same order as the input collection. This behavior may change in the future.
    • estimateCellBoundary

      public static Geometry estimateCellBoundary(Geometry geomNucleus, double distance, double nucleusScale)
      Estimate a cell boundary using Geometry objects. This avoids the need to create ROI or PathObject first.
      Parameters:
      geomNucleus - Geometry representing the cell nucleus
      distance - distance to expand the nucleus, in pixels
      nucleusScale - optional maximum expansion distance defined in terms of scaling the nucleus ROI about its centroid; ignored if ≤ 1
      Returns:
      a Geometry providing a cell boundary estimate
    • constrainCellByNucleusDistance

      public static PathCellObject constrainCellByNucleusDistance(PathCellObject cell, double distance, boolean keepMeasurements)
      Constrain a cell boundary to fall within a maximum region, determined by buffering the convex hull of the nucleus ROI by a fixed distance. This can be used to create more biologically plausible cell boundaries in cases where the initial boundary estimates may be too large.
      Parameters:
      cell - original cell object
      distance - distance (in pixels) by which the nucleus should be expanded to defined maximum cell size
      keepMeasurements - if true, retain the measurements of the original cell if creating a new cell; if false, discard existing measurements
      Returns:
      the updated cell object, or the original cell object either if its boundary falls within the specified limit or it lacks both boundary and nucleus ROIs