Class MeasurementMapper

java.lang.Object
qupath.lib.gui.tools.MeasurementMapper

public class MeasurementMapper extends Object
Helpers class that can be used to map an object's measurement to a color (packed RGB int).

By passing a collection of objects, the minimum and maximum of all the measurements are found and these used to determine the lookup table scaling; alternative minimum and maximum values can also be set to override these extrema.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MeasurementMapper(qupath.lib.color.ColorMaps.ColorMap mapper, String measurement, Collection<? extends qupath.lib.objects.PathObject> pathObjects)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    getColorForObject(qupath.lib.objects.PathObject pathObject)
    Get the display color for a specified object, according to the settings of this mapper.
    qupath.lib.color.ColorMaps.ColorMap
    Get the color mapper, which is effectively a lookup table.
    double
    Get the maximum measurement value from the objects passed to the constructor of this mapper.
    double
    Get the minimum measurement value from the objects passed to the constructor of this mapper.
    double
    Get the measurement value that maps to the last color in the color mapper.
    double
    Get the measurement value that maps to the first color in the color mapper.
    boolean
    Returns true if objects with values outside the specified min/max range have the min/max colors returned, false if null should be returned instead.
    protected double
    getUsefulValue(qupath.lib.objects.PathObject pathObject, double nanValue)
     
    boolean
    Query if the mapper is valid.
    void
    setColorMapper(qupath.lib.color.ColorMaps.ColorMap mapper)
    Set a new color mapper.
    void
    setDisplayMaxValue(double maxValue)
    Set the measurement value that maps to the last color in the color mapper.
    void
    setDisplayMinValue(double minValue)
    Set the measurement value that maps to the first color in the color mapper.
    void
    setExcludeOutsideRange(boolean excludeOutsideRange)
    Specify whether out-of-range values should be excluded.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MeasurementMapper

      public MeasurementMapper(qupath.lib.color.ColorMaps.ColorMap mapper, String measurement, Collection<? extends qupath.lib.objects.PathObject> pathObjects)
      Constructor.
      Parameters:
      mapper - color mapper (lookup table)
      measurement - the measurement to colorize
      pathObjects - an initial collection of objects used to determine display ranges (i.e. find the min/max values of the specified measurement)
  • Method Details

    • setColorMapper

      public void setColorMapper(qupath.lib.color.ColorMaps.ColorMap mapper)
      Set a new color mapper.
      Parameters:
      mapper -
    • getExcludeOutsideRange

      public boolean getExcludeOutsideRange()
      Returns true if objects with values outside the specified min/max range have the min/max colors returned, false if null should be returned instead.
      Returns:
    • setExcludeOutsideRange

      public void setExcludeOutsideRange(boolean excludeOutsideRange)
      Specify whether out-of-range values should be excluded.
      Parameters:
      excludeOutsideRange -
    • isValid

      public boolean isValid()
      Query if the mapper is valid. This returns true if the mapper has been initialized with objects to determine an appropriate display range.
      Returns:
    • getColorForObject

      public Integer getColorForObject(qupath.lib.objects.PathObject pathObject)
      Get the display color for a specified object, according to the settings of this mapper.
      Parameters:
      pathObject -
      Returns:
    • getUsefulValue

      protected double getUsefulValue(qupath.lib.objects.PathObject pathObject, double nanValue)
    • getColorMapper

      public qupath.lib.color.ColorMaps.ColorMap getColorMapper()
      Get the color mapper, which is effectively a lookup table.
      Returns:
    • getDataMinValue

      public double getDataMinValue()
      Get the minimum measurement value from the objects passed to the constructor of this mapper.
      Returns:
    • getDataMaxValue

      public double getDataMaxValue()
      Get the maximum measurement value from the objects passed to the constructor of this mapper.
      Returns:
    • setDisplayMinValue

      public void setDisplayMinValue(double minValue)
      Set the measurement value that maps to the first color in the color mapper.
      Parameters:
      minValue -
    • setDisplayMaxValue

      public void setDisplayMaxValue(double maxValue)
      Set the measurement value that maps to the last color in the color mapper.
      Parameters:
      maxValue -
    • getDisplayMinValue

      public double getDisplayMinValue()
      Get the measurement value that maps to the first color in the color mapper.
      Returns:
    • getDisplayMaxValue

      public double getDisplayMaxValue()
      Get the measurement value that maps to the last color in the color mapper.
      Returns: