Package qupath.lib.objects
Class CellTools
java.lang.Object
qupath.lib.objects.CellTools
Helper class for working with PathObjects that represent cells.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic PathCellObjectconstrainCellByNucleusDistance(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.static PathCellObjectconstrainCellByScaledNucleus(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.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.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.static GeometryestimateCellBoundary(Geometry geomNucleus, double distance, double nucleusScale) Estimate a cell boundary usingGeometryobjects.
- 
Constructor Details- 
CellToolspublic CellTools()
 
- 
- 
Method Details- 
constrainCellByScaledNucleuspublic 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
 
- 
constrainCellOverlapsAdjust 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.
 
- 
detectionsToCellspublic 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.
 
- 
estimateCellBoundarypublic static Geometry estimateCellBoundary(Geometry geomNucleus, double distance, double nucleusScale) Estimate a cell boundary usingGeometryobjects. This avoids the need to createROIorPathObjectfirst.- Parameters:
- geomNucleus-- Geometryrepresenting 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 Geometryproviding a cell boundary estimate
 
- 
constrainCellByNucleusDistancepublic 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
 
 
-