Class DensityMaps

java.lang.Object
qupath.lib.analysis.heatmaps.DensityMaps

public class DensityMaps extends Object
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
  • Field Details

  • Constructor Details

    • DensityMaps

      public DensityMaps()
  • Method Details

    • builder

      Create a new DensityMaps.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 new DensityMaps.DensityMapBuilder initialized with the same properties as an existing builder.
      Parameters:
      builder - the existing builder
      Returns:
      the new builder
    • loadDensityMap

      public static DensityMaps.DensityMapBuilder loadDensityMap(Path path) throws IOException
      Load a DensityMaps.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 added
      densityServer - density map
      channel - channel to threshold; this is also used to determine the class name for the created annotations
      threshold - threshold value
      options - 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 IOException
      Threshold one or more channels of a density map to generate new annotations.
      Parameters:
      hierarchy - hierarchy to which objects should be added
      densityServer - density map
      thresholds - map between channel numbers and thresholds
      pathClassName - name of the classification to apply to the generated annotations
      options - 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 hotspots
      densityServer - the density map to query
      channel - channel in which to find hotspots (usually 0)
      nHotspots - maximum number of hotspots to find per selected annotation
      radius - hotspot radius, in calibrated units
      minCount - minimum value required in the 'count' channel (the last channel)
      hotspotClass - the classification to apply to hotspots
      deleteExisting - optionally delete existing annotations identified as hotspots
      peaksOnly - optionally restrict hotspots to only include intensity peaks
      Throws:
      IOException