Class ROIHandler

java.lang.Object
loci.plugins.util.ROIHandler

public class ROIHandler extends Object
Utility class for managing regions of interest within ImageJ. Capable of constructing ROIs within ImageJ's ROI manager matching those specified in an OME metadata store, and vice versa.
Author:
Melissa Linkert melissa at glencoesoftware.com
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    openROIs(IMetadata retrieve, ij.ImagePlus[] images)
    Look for ROIs in the given OMEXMLMetadata; if any are present, apply them to the given images and display them in the ROI manager.
    static void
    openROIs(IMetadata retrieve, ij.ImagePlus[] images, boolean isOMERO)
    Opens the rois and converts them into ImageJ Rois.
    static void
    openROIs(IMetadata retrieve, ij.ImagePlus[] images, boolean isOMERO, String roisMode)
    Opens the rois and converts them into ImageJ Rois.
    private static int[][]
    Parse (x, y) coordinates from a String returned by MetadataRetrieve.getPolygonpoints(...) or MetadataRetrieve.getPolylinepoints(...)
    static ij.gui.Roi[]
    Returns rois if any from the overlay.
    static ij.gui.Roi[]
    Returns the rois if any stored in the ROI manager.
    static void
    Save ROIs in the ROI manager to the given MetadataStore.
    private static void
    storeLine(ij.gui.Line roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
    Stores the Line ROI into the specified metadata store.
    private static void
    storeOval(ij.gui.OvalRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
    Stores the Oval ROI into the specified metadata store.
    private static void
    storePoint(ij.gui.PointRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
    Stores the Point ROI into the specified metadata store.
    private static void
    storePolygon(ij.gui.PolygonRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
    Stores the Polygon ROI into the specified metadata store.
    private static void
    storeRectangle(ij.gui.Roi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
    Stores the Rectangle ROI into the specified metadata store.
    private static void
    storeText(ij.gui.TextRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
    Stores the text ROI into the metadata stored.
    private static ome.xml.model.primitives.Color
    Converts the Java Color into an OME-XML Color.
    private static ome.xml.model.primitives.NonNegativeInteger
    unwrap(int r)
    Wraps the specified integer into a Non negative integer.

    Methods inherited from class java.lang.Object

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

    • ROIHandler

      public ROIHandler()
  • Method Details

    • openROIs

      public static void openROIs(IMetadata retrieve, ij.ImagePlus[] images)
      Look for ROIs in the given OMEXMLMetadata; if any are present, apply them to the given images and display them in the ROI manager.
    • openROIs

      public static void openROIs(IMetadata retrieve, ij.ImagePlus[] images, boolean isOMERO)
      Opens the rois and converts them into ImageJ Rois.
      Parameters:
      retrieve - The OMEXML store.
      images - The imageJ object.
      isOMERO - true if data stored in OMERO, false otherwise.
    • openROIs

      public static void openROIs(IMetadata retrieve, ij.ImagePlus[] images, boolean isOMERO, String roisMode)
      Opens the rois and converts them into ImageJ Rois.
      Parameters:
      retrieve - The OMEXML store.
      images - The imageJ object.
      isOMERO - true if data stored in OMERO, false otherwise.
      roisMode - Determines whether to import Rois to overlay or RoiManager
    • readFromRoiManager

      public static ij.gui.Roi[] readFromRoiManager()
      Returns the rois if any stored in the ROI manager.
      Returns:
      See above.
    • readFromOverlays

      public static ij.gui.Roi[] readFromOverlays()
      Returns rois if any from the overlay.
      Returns:
      See above
    • saveROIs

      public static void saveROIs(MetadataStore store)
      Save ROIs in the ROI manager to the given MetadataStore.
      Parameters:
      store - Where to store the rois.
    • unwrap

      private static ome.xml.model.primitives.NonNegativeInteger unwrap(int r)
      Wraps the specified integer into a Non negative integer.
      Parameters:
      r - The value to wrap.
      Returns:
      See above.
    • storeText

      private static void storeText(ij.gui.TextRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
      Stores the text ROI into the metadata stored.
      Parameters:
      roi - The roi to convert.
      store - The store to handle.
      roiNum - The roi number
      shape - The index of the shape.
      c - The selected channel.
      z - The selected slice.
      t - The selected timepoint.
    • storePoint

      private static void storePoint(ij.gui.PointRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
      Stores the Point ROI into the specified metadata store.
      Parameters:
      roi - The roi to convert.
      store - The store to handle.
      roiNum - The roi number
      shape - The index of the shape.
      c - The selected channel.
      z - The selected slice.
      t - The selected timepoint.
    • storeLine

      private static void storeLine(ij.gui.Line roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
      Stores the Line ROI into the specified metadata store.
      Parameters:
      roi - The roi to convert.
      store - The store to handle.
      roiNum - The roi number
      shape - The index of the shape.
      c - The selected channel.
      z - The selected slice.
      t - The selected timepoint.
    • storeRectangle

      private static void storeRectangle(ij.gui.Roi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
      Stores the Rectangle ROI into the specified metadata store.
      Parameters:
      roi - The roi to convert.
      store - The store to handle.
      roiNum - The roi number
      shape - The index of the shape.
      c - The selected channel.
      z - The selected slice.
      t - The selected timepoint.
    • storePolygon

      private static void storePolygon(ij.gui.PolygonRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
      Stores the Polygon ROI into the specified metadata store.
      Parameters:
      roi - The roi to convert.
      store - The store to handle.
      roiNum - The roi number
      shape - The index of the shape.
      c - The selected channel.
      z - The selected slice.
      t - The selected timepoint.
    • storeOval

      private static void storeOval(ij.gui.OvalRoi roi, MetadataStore store, int roiNum, int shape, int c, int z, int t)
      Stores the Oval ROI into the specified metadata store.
      Parameters:
      roi - The roi to convert.
      store - The store to handle.
      roiNum - The roi number
      shape - The index of the shape.
      c - The selected channel.
      z - The selected slice.
      t - The selected timepoint.
    • parsePoints

      private static int[][] parsePoints(String points)
      Parse (x, y) coordinates from a String returned by MetadataRetrieve.getPolygonpoints(...) or MetadataRetrieve.getPolylinepoints(...)
    • toOMExmlColor

      private static ome.xml.model.primitives.Color toOMExmlColor(Color color)
      Converts the Java Color into an OME-XML Color.
      Parameters:
      color - The color to convert
      Returns:
      See above