Package loci.formats

Class MetadataTools

java.lang.Object
loci.formats.MetadataTools

public final class MetadataTools extends Object
A utility class for working with metadata objects, including MetadataStore, MetadataRetrieve, and OME-XML strings. Most of the methods require the optional loci.formats.ome package, and optional ome-xml.jar library, to be present at runtime.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static boolean
     
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    createLSID(String type, int... indices)
    Constructs an LSID, given the object type and indices.
    static IMetadata
    Creates an OME-XML metadata object using reflection, to avoid direct dependencies on the optional loci.formats.ome package.
    static ome.xml.model.enums.AcquisitionMode
    Retrieves an AcquisitionMode enumeration value for the given String.
    static ome.xml.model.enums.ArcType
    Retrieves an ArcType enumeration value for the given String.
    static ome.xml.model.enums.Binning
    Retrieves an Binning enumeration value for the given String.
    static ome.xml.model.enums.Compression
    Retrieves an Compression enumeration value for the given String.
    static ome.xml.model.enums.ContrastMethod
    Retrieves an ContrastMethod enumeration value for the given String.
    static ome.xml.model.enums.Correction
    Retrieves an Correction enumeration value for the given String.
    static ome.xml.model.enums.DetectorType
    Retrieves an DetectorType enumeration value for the given String.
    static ome.xml.model.enums.DimensionOrder
    Retrieves an DimensionOrder enumeration value for the given String.
    static ome.xml.model.enums.ExperimentType
    Retrieves an ExperimentType enumeration value for the given String.
    static ome.xml.model.enums.FilamentType
    Retrieves an FilamentType enumeration value for the given String.
    static ome.xml.model.enums.FillRule
    Retrieves an FillRule enumeration value for the given String.
    static ome.xml.model.enums.FilterType
    Retrieves an FilterType enumeration value for the given String.
    static ome.xml.model.enums.FontFamily
    Retrieves an FontFamily enumeration value for the given String.
    static ome.xml.model.enums.FontStyle
    Retrieves an FontStyle enumeration value for the given String.
    static ome.xml.model.enums.IlluminationType
    Retrieves an IlluminationType enumeration value for the given String.
    static ome.xml.model.enums.Immersion
    Retrieves an Immersion enumeration value for the given String.
    static ome.xml.model.enums.LaserMedium
    Retrieves an LaserMedium enumeration value for the given String.
    static ome.xml.model.enums.LaserType
    Retrieves an LaserType enumeration value for the given String.
    static ome.xml.model.enums.Marker
    Retrieves an Marker enumeration value for the given String.
    static ome.xml.model.enums.Medium
    Retrieves an Medium enumeration value for the given String.
    static ome.xml.model.enums.MicrobeamManipulationType
    Retrieves an MicrobeamManipulationType enumeration value for the given String.
    static ome.xml.model.enums.MicroscopeType
    Retrieves an MicroscopeType enumeration value for the given String.
    static ome.xml.model.enums.NamingConvention
    Retrieves an NamingConvention enumeration value for the given String.
    static ome.xml.model.enums.PixelType
    Retrieves an PixelType enumeration value for the given String.
    static ome.xml.model.enums.Pulse
    Retrieves an Pulse enumeration value for the given String.
    static String[]
    Gets a sorted list of keys from the given hashtable.
    static String
    Adjusts the given dimension order as needed so that it contains exactly one of each of the following characters: 'X', 'Y', 'Z', 'C', 'T'.
    static void
    merge(Map<String,Object> src, Map<String,Object> dest, String prefix)
    Merges the given lists of metadata, prepending the specified prefix for the destination keys.
    static void
    populateMetadata(MetadataStore store, int series, String imageName, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel)
    Populates the given MetadataStore, for the specified series, using the provided values.
    static void
    populateMetadata(MetadataStore store, int series, String imageName, CoreMetadata coreMeta)
    Populates the given MetadataStore, for the specified series, using the values from the provided CoreMetadata.
    static void
    populateMetadata(MetadataStore store, String file, int series, String imageName, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel)
    Populates the given MetadataStore, for the specified series, using the provided values.
    static void
    Populates the Pixels element of the given metadata store, using core metadata from the given reader.
    static void
    populatePixels(MetadataStore store, IFormatReader r, boolean doPlane)
    Populates the Pixels element of the given metadata store, using core metadata from the given reader.
    static void
    populatePixels(MetadataStore store, IFormatReader r, boolean doPlane, boolean doImageName)
    Populates the Pixels element of the given metadata store, using core metadata from the given reader.
    static void
    populatePixelsOnly(MetadataStore store, int series, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel)
     
    static void
     
    static void
    setDefaultCreationDate(MetadataStore store, String id, int series)
    Sets a default creation date.
    static void
    setDefaultDateEnabled(boolean enabled)
    Disables the setting of a default creation date.
    static void
    Checks whether the given metadata object has the minimum metadata populated to successfully describe an Image.
    static void
    Checks whether the given metadata object has the minimum metadata populated to successfully describe the nth Image.

    Methods inherited from class java.lang.Object

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

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • defaultDateEnabled

      private static boolean defaultDateEnabled
  • Constructor Details

    • MetadataTools

      private MetadataTools()
  • Method Details

    • populatePixels

      public static void populatePixels(MetadataStore store, IFormatReader r)
      Populates the Pixels element of the given metadata store, using core metadata from the given reader. Delegate to populatePixels(MetadataStore, IFormatReader, boolean, boolean) with doPlane set to false and doImageName set to true.
      Parameters:
      store - The metadata store whose Pixels should be populated
      r - The format reader whose core metadata should be used
    • populatePixels

      public static void populatePixels(MetadataStore store, IFormatReader r, boolean doPlane)
      Populates the Pixels element of the given metadata store, using core metadata from the given reader. If the doPlane flag is set, then the Plane elements will be populated as well. Delegates to populatePixels(MetadataStore, IFormatReader, boolean, boolean) with doImageName set to true.
      Parameters:
      store - The metadata store whose Pixels should be populated
      r - The format reader whose core metadata should be used
      doPlane - Specifies whether Plane elements should be populated
    • populatePixels

      public static void populatePixels(MetadataStore store, IFormatReader r, boolean doPlane, boolean doImageName)
      Populates the Pixels element of the given metadata store, using core metadata from the given reader. If the doPlane flag is set, then the Plane elements will be populated as well. If the doImageName flag is set, then the image name will be populated as well.
      Parameters:
      store - The metadata store whose Pixels should be populated
      r - The format reader whose core metadata should be used
      doPlane - Specifies whether Plane elements should be populated
      doImageName - Specifies whether the Image name should be populated
    • populateMetadata

      public static void populateMetadata(MetadataStore store, int series, String imageName, CoreMetadata coreMeta)
      Populates the given MetadataStore, for the specified series, using the values from the provided CoreMetadata.

      After calling this method, the metadata store will be sufficiently populated for use with an IFormatWriter (assuming it is also a MetadataRetrieve).

    • populateMetadata

      public static void populateMetadata(MetadataStore store, int series, String imageName, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel)
      Populates the given MetadataStore, for the specified series, using the provided values.

      After calling this method, the metadata store will be sufficiently populated for use with an IFormatWriter (assuming it is also a MetadataRetrieve).

    • populateMetadata

      public static void populateMetadata(MetadataStore store, String file, int series, String imageName, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel)
      Populates the given MetadataStore, for the specified series, using the provided values.

      After calling this method, the metadata store will be sufficiently populated for use with an IFormatWriter (assuming it is also a MetadataRetrieve).

    • populatePixelsOnly

      public static void populatePixelsOnly(MetadataStore store, IFormatReader r)
    • populatePixelsOnly

      public static void populatePixelsOnly(MetadataStore store, int series, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel)
    • createLSID

      public static String createLSID(String type, int... indices)
      Constructs an LSID, given the object type and indices. For example, if the arguments are "Detector", 1, and 0, the LSID will be "Detector:1:0".
    • verifyMinimumPopulated

      public static void verifyMinimumPopulated(MetadataRetrieve src) throws FormatException
      Checks whether the given metadata object has the minimum metadata populated to successfully describe an Image.
      Throws:
      FormatException - if there is a missing metadata field, or the metadata object is uninitialized
    • verifyMinimumPopulated

      public static void verifyMinimumPopulated(MetadataRetrieve src, int n) throws FormatException
      Checks whether the given metadata object has the minimum metadata populated to successfully describe the nth Image.
      Throws:
      FormatException - if there is a missing metadata field, or the metadata object is uninitialized
    • setDefaultDateEnabled

      public static void setDefaultDateEnabled(boolean enabled)
      Disables the setting of a default creation date. By default, missing creation dates will be replaced with the corresponding file's last modification date, or the current time if the modification date is not available. Calling this method with the 'enabled' parameter set to 'false' causes missing creation dates to be left as null.
      Parameters:
      enabled - See above.
      See Also:
    • setDefaultCreationDate

      public static void setDefaultCreationDate(MetadataStore store, String id, int series)
      Sets a default creation date. If the named file exists, then the creation date is set to the file's last modification date. Otherwise, it is set to the current date.
      See Also:
    • makeSaneDimensionOrder

      public static String makeSaneDimensionOrder(String dimensionOrder)
      Adjusts the given dimension order as needed so that it contains exactly one of each of the following characters: 'X', 'Y', 'Z', 'C', 'T'.
    • keys

      public static String[] keys(Hashtable<String,Object> meta)
      Gets a sorted list of keys from the given hashtable.
    • merge

      public static void merge(Map<String,Object> src, Map<String,Object> dest, String prefix)
      Merges the given lists of metadata, prepending the specified prefix for the destination keys.
    • createOMEXMLMetadata

      public static IMetadata createOMEXMLMetadata()
      Creates an OME-XML metadata object using reflection, to avoid direct dependencies on the optional loci.formats.ome package.
      Returns:
      A new instance of AbstractOMEXMLMetadata, or null if one cannot be created.
    • getAcquisitionMode

      public static ome.xml.model.enums.AcquisitionMode getAcquisitionMode(String value) throws FormatException
      Retrieves an AcquisitionMode enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getArcType

      public static ome.xml.model.enums.ArcType getArcType(String value) throws FormatException
      Retrieves an ArcType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getBinning

      public static ome.xml.model.enums.Binning getBinning(String value) throws FormatException
      Retrieves an Binning enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getCompression

      public static ome.xml.model.enums.Compression getCompression(String value) throws FormatException
      Retrieves an Compression enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getContrastMethod

      public static ome.xml.model.enums.ContrastMethod getContrastMethod(String value) throws FormatException
      Retrieves an ContrastMethod enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getCorrection

      public static ome.xml.model.enums.Correction getCorrection(String value) throws FormatException
      Retrieves an Correction enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getDetectorType

      public static ome.xml.model.enums.DetectorType getDetectorType(String value) throws FormatException
      Retrieves an DetectorType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getDimensionOrder

      public static ome.xml.model.enums.DimensionOrder getDimensionOrder(String value) throws FormatException
      Retrieves an DimensionOrder enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getExperimentType

      public static ome.xml.model.enums.ExperimentType getExperimentType(String value) throws FormatException
      Retrieves an ExperimentType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getFilamentType

      public static ome.xml.model.enums.FilamentType getFilamentType(String value) throws FormatException
      Retrieves an FilamentType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getFillRule

      public static ome.xml.model.enums.FillRule getFillRule(String value) throws FormatException
      Retrieves an FillRule enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getFilterType

      public static ome.xml.model.enums.FilterType getFilterType(String value) throws FormatException
      Retrieves an FilterType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getFontFamily

      public static ome.xml.model.enums.FontFamily getFontFamily(String value) throws FormatException
      Retrieves an FontFamily enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getFontStyle

      public static ome.xml.model.enums.FontStyle getFontStyle(String value) throws FormatException
      Retrieves an FontStyle enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getIlluminationType

      public static ome.xml.model.enums.IlluminationType getIlluminationType(String value) throws FormatException
      Retrieves an IlluminationType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getImmersion

      public static ome.xml.model.enums.Immersion getImmersion(String value) throws FormatException
      Retrieves an Immersion enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getLaserMedium

      public static ome.xml.model.enums.LaserMedium getLaserMedium(String value) throws FormatException
      Retrieves an LaserMedium enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getLaserType

      public static ome.xml.model.enums.LaserType getLaserType(String value) throws FormatException
      Retrieves an LaserType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getMarker

      public static ome.xml.model.enums.Marker getMarker(String value) throws FormatException
      Retrieves an Marker enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getMedium

      public static ome.xml.model.enums.Medium getMedium(String value) throws FormatException
      Retrieves an Medium enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getMicrobeamManipulationType

      public static ome.xml.model.enums.MicrobeamManipulationType getMicrobeamManipulationType(String value) throws FormatException
      Retrieves an MicrobeamManipulationType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getMicroscopeType

      public static ome.xml.model.enums.MicroscopeType getMicroscopeType(String value) throws FormatException
      Retrieves an MicroscopeType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getNamingConvention

      public static ome.xml.model.enums.NamingConvention getNamingConvention(String value) throws FormatException
      Retrieves an NamingConvention enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getPixelType

      public static ome.xml.model.enums.PixelType getPixelType(String value) throws FormatException
      Retrieves an PixelType enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException
    • getPulse

      public static ome.xml.model.enums.Pulse getPulse(String value) throws FormatException
      Retrieves an Pulse enumeration value for the given String.
      Throws:
      ome.xml.model.enums.EnumerationException - if an appropriate enumeration value is not found.
      FormatException