Package qupath.lib.analysis.heatmaps
Class DensityMaps
java.lang.Object
qupath.lib.analysis.heatmaps.DensityMaps
Class for constructing and using density maps.
A density map is an ImageServer
with the channel type ImageServerMetadata.ChannelType.DENSITY
.
The pixel values relate to the density of objects of some kind, based upon applying one or more predicates.
Currently, only 2D density maps are supported.
There are several supported density map types, defined with DensityMaps.DensityMapType
.
- Author:
- Pete Bankhead
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for anImageServer
representing a density map or forDensityMaps.DensityMapParameters
.static class
Class for storing parameters to build aImageServer
representing a density map.static enum
Density map types. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuilder
(DensityMaps.DensityMapBuilder builder) Create a newDensityMaps.DensityMapBuilder
initialized with the same properties as an existing builder.builder
(PathObjectPredicates.PathObjectPredicate mainObjectFilter) Create a newDensityMaps.DensityMapBuilder
to generate a customized density map.static void
findHotspots
(PathObjectHierarchy hierarchy, ImageServer<BufferedImage> densityServer, int channel, int nHotspots, double radius, double minCount, PathClass hotspotClass, boolean deleteExisting, boolean peaksOnly) Find hotspots in a density map.loadDensityMap
(Path path) Load aDensityMaps.DensityMapBuilder
from the specified path.static boolean
threshold
(PathObjectHierarchy hierarchy, ImageServer<BufferedImage> densityServer, int channel, double threshold, PixelClassifierTools.CreateObjectOptions... options) Threshold a single channel of a density map to generate new annotations.static boolean
threshold
(PathObjectHierarchy hierarchy, ImageServer<BufferedImage> densityServer, Map<Integer, ? extends Number> thresholds, String pathClassName, PixelClassifierTools.CreateObjectOptions... options) Threshold one or more channels of a density map to generate new annotations.
-
Field Details
-
CHANNEL_ALL_OBJECTS
Channel name for the channel with all object counts (not always present).- See Also:
-
PROJECT_LOCATION
Default location to use when storing density maps in a project.- See Also:
-
-
Constructor Details
-
DensityMaps
public DensityMaps()
-
-
Method Details
-
builder
public static DensityMaps.DensityMapBuilder builder(PathObjectPredicates.PathObjectPredicate mainObjectFilter) Create a newDensityMaps.DensityMapBuilder
to generate a customized density map.- Parameters:
mainObjectFilter
- predicate to identify which objects will be included in the density map- Returns:
- the builder
-
builder
Create a newDensityMaps.DensityMapBuilder
initialized with the same properties as an existing builder.- Parameters:
builder
- the existing builder- Returns:
- the new builder
-
loadDensityMap
Load aDensityMaps.DensityMapBuilder
from the specified path.- Parameters:
path
-- Returns:
- Throws:
IOException
-
threshold
public static boolean threshold(PathObjectHierarchy hierarchy, ImageServer<BufferedImage> densityServer, int channel, double threshold, PixelClassifierTools.CreateObjectOptions... options) throws IOException Threshold a single channel of a density map to generate new annotations.- Parameters:
hierarchy
- hierarchy to which objects should be addeddensityServer
- density mapchannel
- channel to threshold; this is also used to determine the class name for the created annotationsthreshold
- threshold valueoptions
- additional objects when creating the annotations- Returns:
- true if changes were made, false otherwise
- Throws:
IOException
-
threshold
public static boolean threshold(PathObjectHierarchy hierarchy, ImageServer<BufferedImage> densityServer, Map<Integer, ? extends Number> thresholds, String pathClassName, PixelClassifierTools.CreateObjectOptions... options) throws IOExceptionThreshold one or more channels of a density map to generate new annotations.- Parameters:
hierarchy
- hierarchy to which objects should be addeddensityServer
- density mapthresholds
- map between channel numbers and thresholdspathClassName
- name of the classification to apply to the generated annotationsoptions
- additional options to customize how annotations are created- Returns:
- true if changes were made, false otherwise
- Throws:
IOException
-
findHotspots
public static void findHotspots(PathObjectHierarchy hierarchy, ImageServer<BufferedImage> densityServer, int channel, int nHotspots, double radius, double minCount, PathClass hotspotClass, boolean deleteExisting, boolean peaksOnly) throws IOException Find hotspots in a density map.- Parameters:
hierarchy
- hierarchy used to obtain selected objects and add hotspotsdensityServer
- the density map to querychannel
- channel in which to find hotspots (usually 0)nHotspots
- maximum number of hotspots to find per selected annotationradius
- hotspot radius, in calibrated unitsminCount
- minimum value required in the 'count' channel (the last channel)hotspotClass
- the classification to apply to hotspotsdeleteExisting
- optionally delete existing annotations identified as hotspotspeaksOnly
- optionally restrict hotspots to only include intensity peaks- Throws:
IOException
-