Package loci.formats
Class MetadataTools
java.lang.Object
loci.formats.MetadataTools
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
FieldsModifier and TypeFieldDescriptionprivate static booleanprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateLSID(String type, int... indices) Constructs an LSID, given the object type and indices.static IMetadataCreates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage.static ome.xml.model.enums.AcquisitionModegetAcquisitionMode(String value) Retrieves anAcquisitionModeenumeration value for the given String.static ome.xml.model.enums.ArcTypegetArcType(String value) Retrieves anArcTypeenumeration value for the given String.static ome.xml.model.enums.BinninggetBinning(String value) Retrieves anBinningenumeration value for the given String.static ome.xml.model.enums.CompressiongetCompression(String value) Retrieves anCompressionenumeration value for the given String.static ome.xml.model.enums.ContrastMethodgetContrastMethod(String value) Retrieves anContrastMethodenumeration value for the given String.static ome.xml.model.enums.CorrectiongetCorrection(String value) Retrieves anCorrectionenumeration value for the given String.static ome.xml.model.enums.DetectorTypegetDetectorType(String value) Retrieves anDetectorTypeenumeration value for the given String.static ome.xml.model.enums.DimensionOrdergetDimensionOrder(String value) Retrieves anDimensionOrderenumeration value for the given String.static ome.xml.model.enums.ExperimentTypegetExperimentType(String value) Retrieves anExperimentTypeenumeration value for the given String.static ome.xml.model.enums.FilamentTypegetFilamentType(String value) Retrieves anFilamentTypeenumeration value for the given String.static ome.xml.model.enums.FillRulegetFillRule(String value) Retrieves anFillRuleenumeration value for the given String.static ome.xml.model.enums.FilterTypegetFilterType(String value) Retrieves anFilterTypeenumeration value for the given String.static ome.xml.model.enums.FontFamilygetFontFamily(String value) Retrieves anFontFamilyenumeration value for the given String.static ome.xml.model.enums.FontStylegetFontStyle(String value) Retrieves anFontStyleenumeration value for the given String.static ome.xml.model.enums.IlluminationTypegetIlluminationType(String value) Retrieves anIlluminationTypeenumeration value for the given String.static ome.xml.model.enums.ImmersiongetImmersion(String value) Retrieves anImmersionenumeration value for the given String.static ome.xml.model.enums.LaserMediumgetLaserMedium(String value) Retrieves anLaserMediumenumeration value for the given String.static ome.xml.model.enums.LaserTypegetLaserType(String value) Retrieves anLaserTypeenumeration value for the given String.static ome.xml.model.enums.MarkerRetrieves anMarkerenumeration value for the given String.static ome.xml.model.enums.MediumRetrieves anMediumenumeration value for the given String.static ome.xml.model.enums.MicrobeamManipulationTypeRetrieves anMicrobeamManipulationTypeenumeration value for the given String.static ome.xml.model.enums.MicroscopeTypegetMicroscopeType(String value) Retrieves anMicroscopeTypeenumeration value for the given String.static ome.xml.model.enums.NamingConventiongetNamingConvention(String value) Retrieves anNamingConventionenumeration value for the given String.static ome.xml.model.enums.PixelTypegetPixelType(String value) Retrieves anPixelTypeenumeration value for the given String.static ome.xml.model.enums.PulseRetrieves anPulseenumeration value for the given String.static String[]Gets a sorted list of keys from the given hashtable.static StringmakeSaneDimensionOrder(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'.static voidMerges the given lists of metadata, prepending the specified prefix for the destination keys.static voidpopulateMetadata(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 givenMetadataStore, for the specified series, using the provided values.static voidpopulateMetadata(MetadataStore store, int series, String imageName, CoreMetadata coreMeta) Populates the givenMetadataStore, for the specified series, using the values from the providedCoreMetadata.static voidpopulateMetadata(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 givenMetadataStore, for the specified series, using the provided values.static voidpopulatePixels(MetadataStore store, IFormatReader r) Populates the Pixels element of the given metadata store, using core metadata from the given reader.static voidpopulatePixels(MetadataStore store, IFormatReader r, boolean doPlane) Populates the Pixels element of the given metadata store, using core metadata from the given reader.static voidpopulatePixels(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 voidpopulatePixelsOnly(MetadataStore store, int series, boolean littleEndian, String dimensionOrder, String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int samplesPerPixel) static voidpopulatePixelsOnly(MetadataStore store, IFormatReader r) static voidsetDefaultCreationDate(MetadataStore store, String id, int series) Sets a default creation date.static voidsetDefaultDateEnabled(boolean enabled) Disables the setting of a default creation date.static voidChecks whether the given metadata object has the minimum metadata populated to successfully describe an Image.static voidverifyMinimumPopulated(MetadataRetrieve src, int n) Checks whether the given metadata object has the minimum metadata populated to successfully describe the nth Image.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
defaultDateEnabled
private static boolean defaultDateEnabled
-
-
Constructor Details
-
MetadataTools
private MetadataTools()
-
-
Method Details
-
populatePixels
Populates the Pixels element of the given metadata store, using core metadata from the given reader. Delegate topopulatePixels(MetadataStore, IFormatReader, boolean, boolean)withdoPlaneset tofalseanddoImageNameset totrue.- Parameters:
store- The metadata store whose Pixels should be populatedr- The format reader whose core metadata should be used
-
populatePixels
Populates the Pixels element of the given metadata store, using core metadata from the given reader. If thedoPlaneflag is set, then the Plane elements will be populated as well. Delegates topopulatePixels(MetadataStore, IFormatReader, boolean, boolean)withdoImageNameset totrue.- Parameters:
store- The metadata store whose Pixels should be populatedr- The format reader whose core metadata should be useddoPlane- 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 thedoPlaneflag is set, then the Plane elements will be populated as well. If thedoImageNameflag is set, then the image name will be populated as well.- Parameters:
store- The metadata store whose Pixels should be populatedr- The format reader whose core metadata should be useddoPlane- Specifies whether Plane elements should be populateddoImageName- Specifies whether the Image name should be populated
-
populateMetadata
public static void populateMetadata(MetadataStore store, int series, String imageName, CoreMetadata coreMeta) Populates the givenMetadataStore, for the specified series, using the values from the providedCoreMetadata.After calling this method, the metadata store will be sufficiently populated for use with an
IFormatWriter(assuming it is also aMetadataRetrieve). -
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 givenMetadataStore, 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 aMetadataRetrieve). -
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 givenMetadataStore, 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 aMetadataRetrieve). -
populatePixelsOnly
-
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
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
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
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
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
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
Gets a sorted list of keys from the given hashtable. -
merge
Merges the given lists of metadata, prepending the specified prefix for the destination keys. -
createOMEXMLMetadata
Creates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage.- 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 anAcquisitionModeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getArcType
Retrieves anArcTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getBinning
Retrieves anBinningenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getCompression
Retrieves anCompressionenumeration 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 anContrastMethodenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getCorrection
Retrieves anCorrectionenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getDetectorType
Retrieves anDetectorTypeenumeration 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 anDimensionOrderenumeration 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 anExperimentTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getFilamentType
Retrieves anFilamentTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getFillRule
Retrieves anFillRuleenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getFilterType
Retrieves anFilterTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getFontFamily
Retrieves anFontFamilyenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getFontStyle
Retrieves anFontStyleenumeration 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 anIlluminationTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getImmersion
Retrieves anImmersionenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getLaserMedium
Retrieves anLaserMediumenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getLaserType
Retrieves anLaserTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getMarker
Retrieves anMarkerenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getMedium
Retrieves anMediumenumeration 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 anMicrobeamManipulationTypeenumeration 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 anMicroscopeTypeenumeration 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 anNamingConventionenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getPixelType
Retrieves anPixelTypeenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-
getPulse
Retrieves anPulseenumeration value for the given String.- Throws:
ome.xml.model.enums.EnumerationException- if an appropriate enumeration value is not found.FormatException
-