Package qupath.lib.analysis
Class DelaunayTools
java.lang.Object
qupath.lib.analysis.DelaunayTools
Tools for creating and querying Delaunay triangulations and Voronoi diagrams.
- Author:
- Pete Bankhead
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class to create aDelaunayTools.Subdivision
based on Delaunay triangulation.static class
Helper class for extracting information from a Delaunay triangulation computed from PathObjects. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BiPredicate
<PathObject, PathObject> boundaryDistancePredicate
(double maxDistance, boolean preferNucleus) BiPredicate that returns true for objects with ROI boundaries within a specified distance.static BiPredicate
<PathObject, PathObject> centroidDistancePredicate
(double maxDistance, boolean preferNucleus) BiPredicate that returns true for objects with ROI centroids within a specified distance.static Collection
<PathObject> classifyObjectsByCluster
(Collection<Collection<? extends PathObject>> clusters) Assign object classifications based upon pre-computed clusters.static Collection
<PathObject> classifyObjectsByCluster
(Collection<Collection<? extends PathObject>> clusters, Function<Integer, PathClass> pathClassFun) Assign object classifications based upon pre-computed clusters.static List
<PathObject> createAnnotationsFromSubdivision
(DelaunayTools.Subdivision subdivision, ROI bounds) Create annotations surrounding objects within a specified subdivision based on Voronoi faces.static DelaunayTools.Subdivision
createFromCentroids
(Collection<PathObject> pathObjects, boolean preferNucleusROI) Create aDelaunayTools.Subdivision
using the centroid coordinates of ROIs.static DelaunayTools.Subdivision
createFromGeometryCoordinates
(Collection<PathObject> pathObjects, boolean preferNucleusROI, double densifyFactor) Create aDelaunayTools.Subdivision
using the boundary coordinates of ROIs.static Collection
<PathObject> nameObjectsByCluster
(Collection<Collection<? extends PathObject>> clusters) Assign object names based upon pre-computed clusters.static Collection
<PathObject> nameObjectsByCluster
(Collection<Collection<? extends PathObject>> clusters, Function<Integer, PathClass> pathClassFun) Assign object classifications based upon pre-computed clusters.static DelaunayTools.Builder
newBuilder
(Collection<PathObject> pathObjects) Create a newDelaunayTools.Builder
to compute a triangulation using the specified objects.static BiPredicate
<PathObject, PathObject> BiPredicate that returns true for objects that share the same classification.
-
Constructor Details
-
DelaunayTools
public DelaunayTools()
-
-
Method Details
-
newBuilder
Create a newDelaunayTools.Builder
to compute a triangulation using the specified objects.- Parameters:
pathObjects
-- Returns:
-
createFromCentroids
public static DelaunayTools.Subdivision createFromCentroids(Collection<PathObject> pathObjects, boolean preferNucleusROI) Create aDelaunayTools.Subdivision
using the centroid coordinates of ROIs.Note: centroids must be distinct. If multiple objects have identical centroids, one or more objects may be lost from the resulting
DelaunayTools.Subdivision
.- Parameters:
pathObjects
- collection of objects from which to construct theDelaunayTools.Subdivision
preferNucleusROI
- if true, prefer the nucleus ROI when extracting the centroid from a cell- Returns:
- a new
DelaunayTools.Subdivision
computed from the centroids of the provided objects - See Also:
-
createFromGeometryCoordinates
public static DelaunayTools.Subdivision createFromGeometryCoordinates(Collection<PathObject> pathObjects, boolean preferNucleusROI, double densifyFactor) Create aDelaunayTools.Subdivision
using the boundary coordinates of ROIs. This is primarily useful for computing Voronoi faces centered on ROIs rather than single points, i.e. to identify pixels closest to specific objects.Notes:
- This is typically much slower than
createFromCentroids(Collection, boolean)
- For interpretable results, ROIs should be non-overlapping.
- Parameters:
pathObjects
- collection of objects from which to construct theDelaunayTools.Subdivision
preferNucleusROI
- if true, prefer the nucleus ROI when extracting geometries from a celldensifyFactor
- amount to 'density' each ROI; this is needed to interpolate coordinates (suggested value = 4.0)- Returns:
- a new
DelaunayTools.Subdivision
computed from the provided objects - See Also:
- This is typically much slower than
-
sameClassificationPredicate
BiPredicate that returns true for objects that share the same classification.- Returns:
-
centroidDistancePredicate
public static BiPredicate<PathObject,PathObject> centroidDistancePredicate(double maxDistance, boolean preferNucleus) BiPredicate that returns true for objects with ROI centroids within a specified distance.- Parameters:
maxDistance
- maximum separation between ROI centroidspreferNucleus
- if true, prefer nucleus centroids for cell objects- Returns:
- true for object pairs with close centroids
-
boundaryDistancePredicate
public static BiPredicate<PathObject,PathObject> boundaryDistancePredicate(double maxDistance, boolean preferNucleus) BiPredicate that returns true for objects with ROI boundaries within a specified distance.- Parameters:
maxDistance
- maximum separation between ROI boundariespreferNucleus
- if true, prefer nucleus ROIs for cell objects- Returns:
- true for object pairs with close boundaries
-
createAnnotationsFromSubdivision
public static List<PathObject> createAnnotationsFromSubdivision(DelaunayTools.Subdivision subdivision, ROI bounds) Create annotations surrounding objects within a specified subdivision based on Voronoi faces. This can be used to create annotations based upon existing detections.- Parameters:
subdivision
- subdivision representing object relationshipsbounds
- if provided, clip the annotations to fit within the ROI- Returns:
- a list of annotations, one for each classification represented by objects within the subdivision within the bounds
-
classifyObjectsByCluster
public static Collection<PathObject> classifyObjectsByCluster(Collection<Collection<? extends PathObject>> clusters, Function<Integer, PathClass> pathClassFun) Assign object classifications based upon pre-computed clusters.- Parameters:
clusters
- a collection ofPathObject
collections, each of which corresponds to a cluster of related objects.pathClassFun
- function used to create aPathClass
from a cluster number (determined by where it falls within the collection).- Returns:
- a collection of objects that have had their classifications set by this method
-
classifyObjectsByCluster
public static Collection<PathObject> classifyObjectsByCluster(Collection<Collection<? extends PathObject>> clusters) Assign object classifications based upon pre-computed clusters.- Parameters:
clusters
- a collection ofPathObject
collections, each of which corresponds to a cluster of related objects.- Returns:
- a collection of objects that have had their classifications set by this method
-
nameObjectsByCluster
public static Collection<PathObject> nameObjectsByCluster(Collection<Collection<? extends PathObject>> clusters, Function<Integer, PathClass> pathClassFun) Assign object classifications based upon pre-computed clusters.- Parameters:
clusters
- a collection ofPathObject
collections, each of which corresponds to a cluster of related objects.pathClassFun
- function used to create aPathClass
from a cluster number (determined by where it falls within the collection). However rather than set this as the object classification, it will be used to set the name and color of the object (so as to avoid overriding an existing classification).- Returns:
- a collection of objects that have had their classifications set by this method
-
nameObjectsByCluster
public static Collection<PathObject> nameObjectsByCluster(Collection<Collection<? extends PathObject>> clusters) Assign object names based upon pre-computed clusters.- Parameters:
clusters
- a collection ofPathObject
collections, each of which corresponds to a cluster of related objects.- Returns:
- a collection of objects that have had their classifications set by this method
-