Package loci.formats.in
Class ND2Reader
java.lang.Object
loci.formats.FormatHandler
loci.formats.FormatReader
loci.formats.SubResolutionFormatReader
loci.formats.in.ND2Reader
- All Implemented Interfaces:
Closeable,AutoCloseable,ICompressedTileReader,IFormatHandler,IFormatReader,IMetadataConfigurable,IPyramidHandler
ND2Reader is the file format reader for Nikon ND2 files.
The JAI ImageIO library is required to use this reader; it is available from
http://jai-imageio.dev.java.net. Note that JAI ImageIO is bundled with a
version of the JJ2000 library, so it is important that either:
(1) the JJ2000 jar file is *not* in the classpath; or
(2) the JAI jar file precedes JJ2000 in the classpath.
Thanks to Tom Caswell for additions to the ND2 metadata parsing logic.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ND2Handlerprivate static final intprivate CodecCodec to use when decompressing pixel data.private int[]private int(package private) String(package private) Booleanprivate booleanWhether or not the pixel data is compressed using JPEG 2000.private booleanWhether or not the pixel data is losslessly compressed.private intprivate Doublestatic final longstatic final longprivate intprivate Doubleprivate Stringprivate long[][]Array of image offsets.private longprivate longprivate intprivate ArrayList<ome.units.quantity.Length> private ArrayList<ome.units.quantity.Length> private ArrayList<ome.units.quantity.Length> private Doubleprivate booleanprivate booleanprivate doubleprivate doubleprivate Doublestatic final booleanstatic final Stringstatic final StringDeprecated.private Booleanprivate longprivate longprivate longFields 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, LOGGER, 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.private voidcopyPixels(int x, int y, int w, int h, int bpp, int scanlinePad, byte[] pix, byte[] buf, boolean split) private CodeccreateCodec(boolean isJPEG) short[][]Gets the 16-bit color lookup table associated with the most recently opened image.byte[][]Gets the 8-bit color lookup table associated with the most recently opened image.Returns the list of available metadata options.long[][]private intprotected voidInitializes the given file (parsing header information, etc.).booleanisThisType(loci.common.RandomAccessInputStream stream) Checks if the given stream is a valid stream for this file format.Function for iterating through ND2 metaAttributesFunction for iterating through ND2 metaAttributesbyte[]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 voidprivate voidpopulateMetadataStore(ND2Handler handler) static StringRemove control and invalid characters from the given string.private voidsetDimensions(int numT, int numZ, int numSeries) voidsetOffsets(String file, long[][] newOffsets) Change the underlying file path and pixel data offsets, keeping all other metadata the same.booleanMethods 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, fileGroupOption, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getBinning, getBitsPerPixel, getCompression, getContrastMethod, getCorrection, getCurrentFile, getDatasetStructureDescription, getDetectorType, getDimensionOrder, getDimensionOrder, getDomains, 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, getOptimalTileHeight, getOptimalTileWidth, getPixelType, getPixelType, getPossibleDomains, getPulse, getRequiredDirectories, getRGBChannelCount, getRotationTransform, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getThumbSizeX, getThumbSizeY, getTileColumns, getTileRows, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, isThisType, isThisType, isThumbnailSeries, isUsedFile, makeFilterMetadata, openBytes, openBytes, openBytes, openPlane, openThumbBytes, readPlane, readPlane, readPlane, reopenFile, 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
-
ND2_MAGIC_BYTES_1
public static final long ND2_MAGIC_BYTES_1- See Also:
-
ND2_MAGIC_BYTES_2
public static final long ND2_MAGIC_BYTES_2- See Also:
-
BUFFER_SIZE
private static final int BUFFER_SIZE- See Also:
-
USE_CHUNKMAP_LEGACY_KEY
Deprecated.Legacy chunkmap option key will be removed in Bio-Formats 8.0.0.- See Also:
-
USE_CHUNKMAP_KEY
- See Also:
-
USE_CHUNKMAP_DEFAULT
public static final boolean USE_CHUNKMAP_DEFAULT- See Also:
-
offsets
private long[][] offsetsArray of image offsets. -
isJPEG
private boolean isJPEGWhether or not the pixel data is compressed using JPEG 2000. -
codec
Codec to use when decompressing pixel data. -
isLossless
private boolean isLosslessWhether or not the pixel data is losslessly compressed. -
tsT
-
positionCount
private int positionCount -
fieldIndex
private int fieldIndex -
xOffset
private long xOffset -
yOffset
private long yOffset -
zOffset
private long zOffset -
pfsOffset
private long pfsOffset -
pfsStateOffset
private long pfsStateOffset -
posX
-
posY
-
posZ
-
exposureTime
-
channelColors
-
split
private boolean split -
lastChannel
private int lastChannel -
colors
private int[] colors -
useZ
-
nXFields
private int nXFields -
backupHandler
-
trueSizeX
private double trueSizeX -
trueSizeY
private double trueSizeY -
trueSizeZ
-
textChannelNames
-
textEmissionWavelengths
-
textData
private boolean textData -
refractiveIndex
-
imageMetadataLVProcessed
Boolean imageMetadataLVProcessed -
imageMetadataLVOrder
String imageMetadataLVOrder -
lensNA
-
objectiveMag
-
objectiveModel
-
-
Constructor Details
-
ND2Reader
public ND2Reader()Constructs a new ND2 reader.
-
-
Method Details
-
useChunkMap
public boolean useChunkMap() -
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 classFormatReader- 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
-
get8BitLookupTable
public byte[][] get8BitLookupTable()Description copied from interface:IFormatReaderGets the 8-bit color lookup table associated with the most recently opened image. If no image planes have been opened, or ifIFormatReader.isIndexed()returns false, then this may return null. Also, ifIFormatReader.getPixelType()returns anything other thanFormatTools.INT8orFormatTools.UINT8, this method will return null.- Specified by:
get8BitLookupTablein interfaceIFormatReader- Overrides:
get8BitLookupTablein classFormatReader
-
get16BitLookupTable
public short[][] get16BitLookupTable()Description copied from interface:IFormatReaderGets the 16-bit color lookup table associated with the most recently opened image. If no image planes have been opened, or ifIFormatReader.isIndexed()returns false, then this may return null. Also, ifIFormatReader.getPixelType()returns anything other thanFormatTools.INT16orFormatTools.UINT16, this method will return null.- Specified by:
get16BitLookupTablein interfaceIFormatReader- Overrides:
get16BitLookupTablein 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- Specified by:
openBytesin classFormatReader- 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 classSubResolutionFormatReader- Throws:
IOException
-
getAvailableOptions
Description copied from class:FormatReaderReturns the list of available metadata options.- Overrides:
getAvailableOptionsin classFormatReader
-
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 classSubResolutionFormatReader- Throws:
FormatException- if a parsing error occurs processing the file.IOException- if an I/O error occurs processing the file
-
iterateIn
Function for iterating through ND2 metaAttributes- Parameters:
in- stream of bytes from filestop- position where to stop- Returns:
- text info values, if found
-
iterateIn
private ArrayList<String> iterateIn(loci.common.RandomAccessInputStream in, Long stop, boolean minimal) Function for iterating through ND2 metaAttributes- Parameters:
in- stream of bytes from filestop- position where to stopminimal- true if values should be read with no additional metadata parsing- Returns:
- text info values, if found
-
populateMetadataStore
- Throws:
FormatException
-
createCodec
-
copyPixels
private void copyPixels(int x, int y, int w, int h, int bpp, int scanlinePad, byte[] pix, byte[] buf, boolean split) throws IOException - Throws:
IOException
-
sanitizeControl
Remove control and invalid characters from the given string. -
getScanlinePad
private int getScanlinePad() -
parseText
-
setDimensions
private void setDimensions(int numT, int numZ, int numSeries) -
getOffsets
public long[][] getOffsets()- Returns:
- offsets to pixel data
-
setOffsets
Change the underlying file path and pixel data offsets, keeping all other metadata the same.- Throws:
IOException
-