Package loci.formats.in
Class MetamorphReader
- All Implemented Interfaces:
Closeable,AutoCloseable,ICompressedTileReader,IFormatHandler,IFormatReader,IMetadataConfigurable,IPyramidHandler
Reader is the file format reader for Metamorph STK files.
- Author:
- Eric Kjellman egkjellman at wisc.edu, Melissa Linkert melissa at glencoesoftware.com, Curtis Rueden ctrueden at wisc.edu, Sebastien Huart Sebastien dot Huart at curie.fr
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate booleanprivate booleanprivate long[]The TIFF's emWavelengthprivate Doubleprivate boolean[]private Doubleprivate booleanprivate booleanprivate booleanprivate booleanprivate StringThe TIFF's creation dateprivate StringThe TIFF's nameprivate long[]private booleanprivate static final org.slf4j.LoggerLogger for this class.static final Stringprivate static final intprivate intprivate static final Stringstatic final String[]private Stringprivate static final Stringprivate static final Stringprivate intstatic final Stringprivate Doubleprivate Doubleprivate String[]private ome.units.quantity.Length[]private ome.units.quantity.Length[]private doublestatic final String[]private MetamorphReader[][]private String[][]List of STK files in the dataset.private doubleprivate static final intprivate static final intprivate static final intprivate static final intprivate booleanprivate double[]static final Patternprivate double[]private doubleprivate doubleFields inherited from class loci.formats.in.BaseTiffReader
DATE_FORMATSFields inherited from class loci.formats.in.MinimalTiffReader
canSeparateSeries, equalStrips, ifds, lastPlane, mergeSubIFDs, noSubresolutions, seriesToIFD, subResolutionIFDs, thumbnailIFDs, tiffParser, use64BitFields inherited from class loci.formats.SubResolutionFormatReader
coreFields inherited from class loci.formats.FormatReader
coreIndex, datasetDescription, domains, fillColor, filterMetadata, flattenedResolutions, group, hasCompanionFiles, in, indexedAsRGB, metadata, metadataStore, normalizeData, resolution, saveOriginalMetadata, series, suffixNecessary, suffixSufficient, THUMBNAIL_DIMENSIONFields inherited from class loci.formats.FormatHandler
COMPRESSION_SUFFIXES, currentId, format, metadataOptions, suffixesFields inherited from interface loci.formats.IFormatReader
CAN_GROUP, CANNOT_GROUP, MUST_GROUP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(boolean fileOnly) Closes the currently open file.static StringdecodeDate(int julian) Converts a Julian date value into a human-readable string.static StringdecodeTime(int millis) Converts a time value in milliseconds into a human-readable string.intReturns an indication of whether the files in a multi-file dataset can be handled individually.private StringgetComment(int i, int no) String[]Returns the list of domains represented by the current file.private StringgetFirstComment(int i) Returns the TIFF comment from the first IFD of the first STK file in the given series.private StringgetKey(int id) private StringgetNDVersionSuffix(loci.common.Location ndfile) Parses the given ND file to determined the version and return the expected file suffixprivate StringgetRealSTKFile(loci.common.Location l) Check that the given STK file exists.String[]getSeriesUsedFiles(boolean noPixels) Returns an array of filenames needed to open the current series.protected ome.units.quantity.Length[]protected ome.units.quantity.Length[]getWellCoords(String label) protected voidInitializes the given file (parsing header information, etc.).protected voidParses standard metadata.static StringintFormat(int myint, int digits) Formats an integer value with leading 0s if needed.static StringintFormatMax(int myint, int maxint) Formats an integer with leading 0 using maximum sequence number.booleanisSingleFile(String id) Returns true if the named file is expected to be the only file in the dataset.booleanisThisType(String name, boolean open) Checks if a file matches the type of this format reader.booleanisThisType(loci.common.RandomAccessInputStream stream) Checks if the given stream is a valid stream for this file format.private StringLocates the first valid file in the STK arrays.private StringmakeImageName(int i) Create an appropriate name for the given series.byte[]openBytes(int no, byte[] buf, int x, int y, int w, int h) Obtains a sub-image of the specified image plane into a pre-allocated byte array.private voidparseUIC1Tags(long uic1offset, int uic1count) UIC1 entry parser(package private) voidparseUIC2Tags(long uic2offset) Populates metadata fields with some contained in MetaMorph UIC2 Tag.private voidparseUIC4Tags(long uic4offset) UIC4 metadata parser UIC4 Table contains per-plane blocks of metadata stage X/Y positions, camera chip offsets, stage labels...(package private) voidprivate static StringreadCString(loci.common.RandomAccessInputStream s, int n) Read a null-terminated string.private voidprivate TiffRationalreadRational(loci.common.RandomAccessInputStream s) private TiffRationalreadRational(loci.common.RandomAccessInputStream s, long offset) private voidreadRationals(String[] labels) (package private) voidprivate voidprivate voidsetCanLookForND(boolean v) Methods inherited from class loci.formats.in.BaseTiffReader
getExifTagName, getImageCreationDate, initMetadata, initMetadataStore, put, put, put, put, put, put, put, put, put, put, putDouble, putInt, putStringMethods inherited from class loci.formats.in.MinimalTiffReader
copyTile, get16BitLookupTable, get8BitLookupTable, getCompressedByteCount, getIFDs, getOptimalTileHeight, getOptimalTileWidth, getThumbnailIFDs, getThumbSizeX, getThumbSizeY, getTileIndex, initTiffParser, openThumbBytes, reopenFile, setResolutionLevelMethods inherited from class loci.formats.SubResolutionFormatReader
coreIndexToSeries, flattenHashtables, getCoreIndex, getCoreMetadataList, getCurrentCore, getResolution, getResolutionCount, getSeries, getSeriesCount, seriesToCoreIndex, setCoreIndex, setResolution, setSeriesMethods inherited from class loci.formats.FormatReader
addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMetaList, addMeta, addMetaList, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMetaList, close, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getAvailableOptions, getBinning, getBitsPerPixel, getCompression, getContrastMethod, getCorrection, getCurrentFile, getDatasetStructureDescription, getDetectorType, getDimensionOrder, getDimensionOrder, getEffectiveSizeC, getExperimentType, getFilamentType, getFillColor, getFillRule, getFilterType, getFontFamily, getFontStyle, getGlobalMeta, getGlobalMetadata, getIlluminationType, getImageCount, getImmersion, getIndex, getIndex, getLaserMedium, getLaserType, getMarker, getMedium, getMetadataStore, getMetadataStoreRoot, getMetadataValue, getMicrobeamManipulationType, getMicroscopeType, getModuloC, getModuloT, getModuloZ, getNamingConvention, getPixelType, getPixelType, getPossibleDomains, getPulse, getRequiredDirectories, getRGBChannelCount, getRotationTransform, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getTileColumns, getTileRows, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isThisType, isThisType, isThumbnailSeries, isUsedFile, makeFilterMetadata, openBytes, openBytes, openBytes, openPlane, readPlane, readPlane, readPlane, setFillColor, setFlattenedResolutions, setGroupFiles, setId, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, updateMetadataListsMethods inherited from class loci.formats.FormatHandler
checkSuffix, checkSuffix, getFormat, getMetadataOptions, getNativeDataType, getSuffixes, getSupportedMetadataLevels, setMetadataOptionsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface loci.formats.ICompressedTileReader
getTileCodec, getTileCodecOptions, openCompressedBytes, openCompressedBytesMethods inherited from interface loci.formats.IFormatHandler
getFormat, getNativeDataType, getSuffixesMethods inherited from interface loci.formats.IMetadataConfigurable
getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERLogger for this class. -
SHORT_DATE_FORMAT
- See Also:
-
LONG_DATE_FORMAT
- See Also:
-
ND_SUFFIX
-
STK_SUFFIX
-
WELL_COORDS
-
METAMORPH_ID
private static final int METAMORPH_ID- See Also:
-
UIC1TAG
private static final int UIC1TAG- See Also:
-
UIC2TAG
private static final int UIC2TAG- See Also:
-
UIC3TAG
private static final int UIC3TAG- See Also:
-
UIC4TAG
private static final int UIC4TAG- See Also:
-
NDINFOFILE_VER1
- See Also:
-
NDINFOFILE_VER2
- See Also:
-
ND_ENCODING
- See Also:
-
imageName
The TIFF's name -
imageCreationDate
The TIFF's creation date -
emWavelength
private long[] emWavelengthThe TIFF's emWavelength -
isHCS
private boolean isHCS -
stageLabels
-
wave
private double[] wave -
binning
-
zoom
private double zoom -
stepSize
private double stepSize -
exposureTime
-
waveNames
-
stageNames
-
internalStamps
private long[] internalStamps -
zDistances
private double[] zDistances -
stageX
private ome.units.quantity.Length[] stageX -
stageY
private ome.units.quantity.Length[] stageY -
zStart
private double zStart -
sizeX
-
sizeY
-
tempZ
private double tempZ -
validZ
private boolean validZ -
gain
-
mmPlanes
private int mmPlanes -
stkReaders
-
stks
List of STK files in the dataset. -
ndFilename
-
canLookForND
private boolean canLookForND -
firstSeriesChannels
private boolean[] firstSeriesChannels -
bizarreMultichannelAcquisition
private boolean bizarreMultichannelAcquisition -
openFiles
private int openFiles -
hasStagePositions
private boolean hasStagePositions -
hasChipOffsets
private boolean hasChipOffsets -
hasAbsoluteZ
private boolean hasAbsoluteZ -
hasAbsoluteZValid
private boolean hasAbsoluteZValid
-
-
Constructor Details
-
MetamorphReader
public MetamorphReader()Constructs a new Metamorph reader.
-
-
Method Details
-
getDomains
Description copied from interface:IFormatReaderReturns the list of domains represented by the current file.- Specified by:
getDomainsin interfaceIFormatReader- Overrides:
getDomainsin classFormatReader
-
isThisType
Description copied from class:FormatReaderChecks if a file matches the type of this format reader. Checks filename suffixes against those known for this format. If the suffix check is inconclusive and the open parameter is true, the file is opened and tested withFormatReader.isThisType(RandomAccessInputStream).- Specified by:
isThisTypein interfaceIFormatReader- Overrides:
isThisTypein classFormatReader- Parameters:
open- If true, and the file extension is insufficient to determine the file type, the (existing) file is opened for further analysis.
-
isThisType
Description copied from interface:IFormatReaderChecks if the given stream is a valid stream for this file format. The number of bytes read is format-dependent.- Specified by:
isThisTypein interfaceIFormatReader- Overrides:
isThisTypein classMinimalTiffReader- Parameters:
stream- A RandomAccessInputStream representing the file to check. The first byte in the stream is assumed to be the first byte in the file.- Returns:
- true if the file represented by the stream can be read by this reader; false otherwise.
- Throws:
IOException
-
isSingleFile
Description copied from interface:IFormatReaderReturns true if the named file is expected to be the only file in the dataset. For single-file formats, always returns true.- Specified by:
isSingleFilein interfaceIFormatReader- Overrides:
isSingleFilein classFormatReader- Throws:
FormatExceptionIOException
-
fileGroupOption
Description copied from interface:IFormatReaderReturns an indication of whether the files in a multi-file dataset can be handled individually. This method is only useful for formats and datasets which contain multiple files.- Specified by:
fileGroupOptionin interfaceIFormatReader- Overrides:
fileGroupOptionin classFormatReader- Parameters:
id- a file in the multi-file dataset- Returns:
- an int indicating that we cannot, must, or might group the files.
A return value of
FormatTools.MUST_GROUPindicates that the files cannot be handled separately; the reader will always detect and read all files in the dataset.FormatTools.CAN_GROUPindicates that the files may be handled separately, but file grouping must then be disabled viaIFormatReader.setGroupFiles(boolean).FormatTools.CANNOT_GROUPindicates that the files must be handled separately; the reader will not attempt to read all files in the dataset (this is rare). - Throws:
FormatExceptionIOException- See Also:
-
getSeriesUsedFiles
Description copied from interface:IFormatReaderReturns an array of filenames needed to open the current series. If the 'noPixels' flag is set, then only files that do not contain pixel data will be returned. The first element in the array is expected to be the path passed toIFormatHandler.setId(String), if appropriate based upon 'noPixels'. The remaining elements are expected to be in a consistent order; if a directory listing is necessary to build the list then it should be sorted first.- Specified by:
getSeriesUsedFilesin interfaceIFormatReader- Overrides:
getSeriesUsedFilesin classFormatReader
-
openBytes
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException Description copied from interface:IFormatReaderObtains a sub-image of the specified image plane into a pre-allocated byte array.- Specified by:
openBytesin interfaceIFormatReader- Overrides:
openBytesin classMinimalTiffReader- Parameters:
no- the plane index within the current series.buf- a pre-allocated buffer.x- X coordinate of the upper-left corner of the sub-imagey- Y coordinate of the upper-left corner of the sub-imagew- width of the sub-imageh- height of the sub-image- Returns:
- the pre-allocated buffer
buffor convenience. - Throws:
FormatException- if there was a problem parsing the metadata of the file.IOException- if there was a problem reading the file.- See Also:
-
close
Description copied from interface:IFormatReaderCloses the currently open file. If the flag is set, this is all that happens; if unset, it is equivalent to callingCloseable.close().- Specified by:
closein interfaceIFormatReader- Overrides:
closein classMinimalTiffReader- Throws:
IOException
-
initFile
Description copied from class:SubResolutionFormatReaderInitializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.- Overrides:
initFilein classBaseTiffReader- Throws:
FormatException- if a parsing error occurs processing the file.IOException- if an I/O error occurs processing the file
-
initStandardMetadata
Description copied from class:BaseTiffReaderParses standard metadata. NOTE: Absolutely no calls to the metadata store should be made in this method or methods that override this method. Data will be overwritten if you do so.- Overrides:
initStandardMetadatain classBaseTiffReader- Throws:
FormatExceptionIOException
-
getRealSTKFile
Check that the given STK file exists. If it does, then return the absolute path. If it does not, then apply various formatting rules until an existing file is found.- Returns:
- the absolute path of an STK file, or null if no STK file is found.
-
getFirstComment
Returns the TIFF comment from the first IFD of the first STK file in the given series.- Throws:
IOException
-
getComment
- Throws:
IOException
-
makeImageName
Create an appropriate name for the given series. -
parseUIC2Tags
Populates metadata fields with some contained in MetaMorph UIC2 Tag. (for each plane: 6 integers: zdistance numerator, zdistance denominator, creation date, creation time, modif date, modif time)- Parameters:
uic2offset- offset to UIC2 (33629) tag entries not a regular tiff tag (6*N entries, N being the tagCount)- Throws:
IOException
-
parseUIC4Tags
UIC4 metadata parser UIC4 Table contains per-plane blocks of metadata stage X/Y positions, camera chip offsets, stage labels...- Parameters:
uic4offset- offset of UIC4 table (not tiff-compliant)- Throws:
IOException
-
getStageX
protected ome.units.quantity.Length[] getStageX() -
getStageY
protected ome.units.quantity.Length[] getStageY() -
readStagePositions
- Throws:
IOException
-
readRationals
- Throws:
IOException
-
readStageLabels
- Throws:
IOException
-
readAbsoluteZValid
- Throws:
IOException
-
parseUIC1Tags
UIC1 entry parser- Parameters:
uic1offset- offset as found in the tiff tag 33628 (UIC1Tag)uic1count- number of entries in UIC1 table (not tiff-compliant)- Throws:
IOException
-
decodeDate
Converts a Julian date value into a human-readable string. -
decodeTime
Converts a time value in milliseconds into a human-readable string. Note that the date and time are handled separately, so this method is only concerned with the time of day. The time of day in milliseconds is stored as a 32-bit int in Metamorph files, but is expected to be a positive integer less than the number of milliseconds in one day.- Parameters:
millis- milliseconds elapsed in the relevant day- See Also:
-
intFormat
Formats an integer value with leading 0s if needed. -
intFormatMax
Formats an integer with leading 0 using maximum sequence number.- Parameters:
myint- integer to formatmaxint- max of "myint"- Returns:
- String
-
locateFirstValidFile
Locates the first valid file in the STK arrays.- Returns:
- Path to the first valid file.
-
readRational
- Throws:
IOException
-
readRational
private TiffRational readRational(loci.common.RandomAccessInputStream s, long offset) throws IOException - Throws:
IOException
-
setCanLookForND
private void setCanLookForND(boolean v) -
readPlaneData
- Throws:
IOException
-
getKey
-
getWellCoords
-
readCString
Read a null-terminated string. Read at most n characters if the null character is not found.- Throws:
IOException
-
getNDVersionSuffix
Parses the given ND file to determined the version and return the expected file suffix- Parameters:
ndfile- The ND file which should be parsed- Returns:
- The file suffix to be used for associated files based on the ND version
- Throws:
IOException
-