Package qupath.lib.objects
Class CellTools
java.lang.Object
qupath.lib.objects.CellTools
Helper class for working with PathObjects that represent cells.
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.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.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 Geometry
estimateCellBoundary
(Geometry geomNucleus, double distance, double nucleusScale) Estimate a cell boundary usingGeometry
objects.
-
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 objectnucleusScaleFactor
- scale factor by which the nucleus should be expanded to defined maximum cell sizekeepMeasurements
- 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
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
-
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 nucleidistance
- the maximum distance (in pixels) to expand each nucleusnucleusScale
- 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.
-
estimateCellBoundary
public static Geometry estimateCellBoundary(Geometry geomNucleus, double distance, double nucleusScale) Estimate a cell boundary usingGeometry
objects. This avoids the need to createROI
orPathObject
first.- Parameters:
geomNucleus
-Geometry
representing the cell nucleusdistance
- distance to expand the nucleus, in pixelsnucleusScale
- 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 objectdistance
- distance (in pixels) by which the nucleus should be expanded to defined maximum cell sizekeepMeasurements
- 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
-