Class IJProperties

java.lang.Object
qupath.imagej.tools.IJProperties

public class IJProperties extends Object
Store QuPath-related information within the properties of ImageJ objects.

Note that these use ImagePlus.setProp(String, String) rather than the tempting ImagePlus.setProperty(String, Object), as this seems necessary to be able to access the properties later from a macro.

  • Field Details

    • IMAGE_TYPE

      public static final String IMAGE_TYPE
      Key for an ImagePlus property to store a string representing a QuPath ImageData.ImageType.
      See Also:
    • IMAGE_BACKGROUND

      public static final String IMAGE_BACKGROUND
      Key for an ImagePlus property storing either "light" or "dark depending upon whether an image is known to be brightfield of fluorescence respectively.
      See Also:
    • BACKGROUND_DARK

      public static final String BACKGROUND_DARK
      Property value for IMAGE_BACKGROUND when an image is known to have a dark background.
      See Also:
    • BACKGROUND_LIGHT

      public static final String BACKGROUND_LIGHT
      Property value for IMAGE_BACKGROUND when an image is known to have a light background.
      See Also:
    • IMAGE_REGION_ROOT

      public static final String IMAGE_REGION_ROOT
      Key for a ImagePlus properties to store the bounding box of a QuPath ImageRegion. Each value (x, y, width, height) is stored as a separate entry.
      See Also:
    • IMAGE_REQUEST

      public static final String IMAGE_REQUEST
      Key for an ImagePlus property to store a json representation of a RegionRequest used to request the image.
      See Also:
    • OBJECT_CLASSIFICATION

      public static final String OBJECT_CLASSIFICATION
      Set property for PathObject.getClassification() ()}
      See Also:
    • OBJECT_NAME

      public static final String OBJECT_NAME
      Set property for PathObject.getName()
      See Also:
    • OBJECT_ID

      public static final String OBJECT_ID
      Set property for PathObject.getID() ()}
      See Also:
    • OBJECT_MEASUREMENT_ROOT

      public static final String OBJECT_MEASUREMENT_ROOT
      Base for property names that store measurements to be added to PathObject.getMeasurements(). The measurement name should be in the format OBJECT_MEASUREMENT_ROOT + name where name must not contain any spaces or newlines.
      See Also:
  • Constructor Details

    • IJProperties

      public IJProperties()
  • Method Details

    • setImageRegion

      public static String setImageRegion(ImagePlus imp, qupath.lib.regions.ImageRegion region)
      Set the IMAGE_REGION property as a string representation of the region's bounding box.

      This also stores additional properties under "qupath.image.region.x", "qupath.image.region.y", "qupath.image.region.width" and "qupath.image.region.height" to encode the values separately, in addition to "qupath.image.region.downsample" if available.

      Parameters:
      imp -
      region -
      Returns:
      the value that was set for the property, or null if the region was null
    • getImageRegion

      public static qupath.lib.regions.ImageRegion getImageRegion(ImagePlus imp)
    • setRegionRequest

      public static String setRegionRequest(ImagePlus imp, qupath.lib.regions.RegionRequest request)
      Store a json representation of a RegionRequest as a property in an image.
      Parameters:
      imp - the image
      request - the request that corresponds to the image
      Returns:
      the json representation that is stored
      See Also:
    • getRegionRequest

      public static qupath.lib.regions.RegionRequest getRegionRequest(ImagePlus imp)
      Get a RegionRequest by reading the json representation stored as a property in the image.
      Parameters:
      imp - the image
      Returns:
      the RegionRequest, or null if none is found
      See Also:
    • setImageType

      public static String setImageType(ImagePlus imp, qupath.lib.images.ImageData.ImageType imageType)
      Set the IMAGE_TYPE property based on the name of QuPath's image type, if available.
      Parameters:
      imp -
      imageType -
      Returns:
      the value that was set for the property, or null if it was not set
    • setImageBackground

      public static String setImageBackground(ImagePlus imp, qupath.lib.images.ImageData.ImageType imageType)
      Set the IMAGE_BACKGROUND property as "dark" for fluorescence images or "light" for brightield images; otherwise, do nothing.
      Parameters:
      imp -
      imageType -
      Returns:
      the value that was set for the property, or null if it was not set
    • getImageBackground

      public static String getImageBackground(ImagePlus imp)
      Get the image background property value
      Parameters:
      imp -
      Returns:
      one of "dark", "light" or null.
    • setClassification

      public static String setClassification(Roi roi, qupath.lib.objects.PathObject pathObject)
      Set a property storing a QuPath object classification within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      pathObject - the object whose classification should be stored
      See Also:
    • setClassification

      public static String setClassification(Roi roi, String classification)
      Set a property storing a QuPath object classification within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      classification - the classification string value
      See Also:
    • getClassification

      public static String getClassification(Roi roi)
      Get a QuPath classification, as stored in a roi's properties.
      Parameters:
      roi - the roi
      Returns:
      the classification if available, or null otherwise
      See Also:
    • setObjectName

      public static String setObjectName(Roi roi, qupath.lib.objects.PathObject pathObject)
      Set a property storing a QuPath object name within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      pathObject - the object whose name should be stored
      See Also:
    • setObjectName

      public static String setObjectName(Roi roi, String name)
      Set a property storing a QuPath object name within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      name - the name value
      See Also:
    • getObjectName

      public static String getObjectName(Roi roi)
      Get a QuPath object name, as stored in a roi's properties.
      Parameters:
      roi - the roi
      Returns:
      the name if available, or null otherwise
      See Also:
    • setObjectId

      public static String setObjectId(Roi roi, qupath.lib.objects.PathObject pathObject)
      Set a property storing a QuPath object ID within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      pathObject - the object whose ID should be stored
      See Also:
    • setObjectId

      public static String setObjectId(Roi roi, UUID id)
      Set a property storing a QuPath object ID within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      id - the id value
      See Also:
    • getObjectId

      public static UUID getObjectId(Roi roi)
      Get a QuPath object ID from the Roi properties.
      Parameters:
      roi - the roi
      Returns:
      a UUID if found in the Roi's properties, or null otherwise
      See Also:
    • putMeasurement

      public static void putMeasurement(Roi roi, String name, double value)
      Set a property storing a QuPath object measurement within a specified Roi.
      Parameters:
      roi - the roi with the property to set
      name - the name of the measurement
      value - the measurement value
      See Also:
    • getMeasurement

      public static Double getMeasurement(Roi roi, String name)
      Get a measurement stored as a property. The property name will begin with OBJECT_MEASUREMENT_ROOT but the name supplied here need only be the measurement name appended to this.
      Parameters:
      roi - the roi that may contain the measurement as a property
      name - the measurement name
      Returns:
      the measurement if it is found, or null otherwise
      See Also:
    • getAllMeasurements

      public static Map<String,Number> getAllMeasurements(Roi roi)
      Get all QuPath object measurements found in the properties of a Roi. These are properties with names that start with OBJECT_MEASUREMENT_ROOT and contain a numeric value that can be parsed.
      Parameters:
      roi - the Roi to query
      Returns:
      a map of all measurements that could be found, or an empty map if none are found
      See Also: