public class DicomReader extends SubResolutionFormatReader
Modifier and Type | Field and Description |
---|---|
private int |
centerPixelValue |
private java.util.List<java.lang.String> |
channelNames |
private java.util.List<java.lang.String> |
companionFiles |
private java.lang.Number |
concatenationNumber |
private java.lang.String |
date |
static java.lang.String |
DICOM_MAGIC_STRING |
private static java.lang.String[] |
DICOM_SUFFIXES |
private boolean |
edf |
private java.util.Map<java.lang.Integer,java.util.List<java.lang.String>> |
fileList |
static int |
HEADER_LENGTH |
private int |
imagesPerFile |
private java.lang.String |
imageType |
private java.lang.String |
instanceUID |
private boolean |
inverted |
private boolean |
isDeflate |
private boolean |
isJP2K |
private boolean |
isJPEG |
private boolean |
isRLE |
private byte[][] |
lut |
private int |
maxPixelRange |
private java.lang.String |
originalDate |
private java.lang.String |
originalInstance |
private int |
originalSeries |
private java.lang.String |
originalSpecimen |
private java.lang.String |
originalTime |
private int |
originalX |
private int |
originalY |
private java.lang.String |
pixelSizeX |
private java.lang.String |
pixelSizeY |
private java.lang.Double |
pixelSizeZ |
private java.util.List<java.lang.Double> |
positionX |
private java.util.List<java.lang.Double> |
positionY |
private java.util.List<java.lang.Double> |
positionZ |
private short[][] |
shortLut |
private java.util.List<DicomTag> |
tags |
private java.util.Map<java.lang.Integer,java.util.List<DicomTile>> |
tilePositions |
private java.lang.String |
time |
private java.util.Map<java.lang.Integer,java.util.List<java.lang.Double>> |
zOffsets |
core
coreIndex, datasetDescription, domains, filterMetadata, flattenedResolutions, group, hasCompanionFiles, in, indexedAsRGB, metadata, metadataStore, normalizeData, resolution, saveOriginalMetadata, series, suffixNecessary, suffixSufficient, THUMBNAIL_DIMENSION
COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes
CAN_GROUP, CANNOT_GROUP, MUST_GROUP
Constructor and Description |
---|
DicomReader()
Constructs a new DICOM reader.
|
Modifier and Type | Method and Description |
---|---|
private void |
addFileToList(java.lang.String file,
boolean checkSeries)
Determine if the given file belongs in the same dataset as this file.
|
private void |
addInfo(DicomTag info) |
private void |
addOriginalMetadata(java.lang.String key,
DicomTag info)
Store the given tag's value (if present) in the original metadata
hashtable using the provided key.
|
private void |
attachCompanionFiles()
DICOM datasets produced by:
http://www.ct-imaging.de/index.php/en/ct-systeme-e/mikro-ct-e.html
contain a bunch of extra metadata and log files.
|
private void |
calculatePixelsOffsets(long baseOffset)
Calculate offsets to all pixel data (tiles or planes) in the file,
starting from the given offset.
|
void |
close(boolean fileOnly)
Closes the currently open file.
|
private DicomFileInfo |
createFileInfo(java.lang.String file)
Construct a DicomFileInfo for the given file.
|
int |
fileGroupOption(java.lang.String id)
Returns an indication of whether the files in a multi-file dataset can
be handled individually.
|
short[][] |
get16BitLookupTable()
Gets the 16-bit color lookup table associated with
the most recently opened image.
|
byte[][] |
get8BitLookupTable()
Gets the 8-bit color lookup table associated with
the most recently opened image.
|
java.util.List<java.lang.String> |
getChannelNames() |
int |
getConcatenationIndex() |
java.lang.String |
getImageType() |
int |
getOptimalTileHeight()
Returns the optimal sub-image height for use with openBytes.
|
int |
getOptimalTileWidth()
Returns the optimal sub-image width for use with openBytes.
|
ome.units.quantity.Length |
getPixelSizeX() |
ome.units.quantity.Length |
getPixelSizeY() |
ome.units.quantity.Length |
getPixelSizeZ() |
java.util.List<java.lang.Double> |
getPositionX() |
java.util.List<java.lang.Double> |
getPositionY() |
java.util.List<java.lang.Double> |
getPositionZ() |
int |
getRequiredDirectories(java.lang.String[] files)
Returns the number of parent directories that are important when
processing the given list of files.
|
java.lang.String[] |
getSeriesUsedFiles(boolean noPixels)
Returns an array of filenames needed to open the current series.
|
java.util.List<DicomTag> |
getTags()
Provide the complete hierarchy of DICOM tags.
|
private void |
getTile(DicomTile tile,
byte[] buf,
int x,
int y,
int w,
int h)
Decompress pixel data associated with the given DicomTile.
|
java.util.List<DicomTile> |
getTiles() |
ome.xml.model.primitives.Timestamp |
getTimestamp() |
private long |
getTimestampMicroseconds(java.lang.String v)
Convert the timestamp from a TM value to microseconds.
|
java.util.List<java.lang.Double> |
getZOffsets() |
private void |
handleReferencedFile(DicomTag tag,
java.lang.String currentType) |
protected void |
initFile(java.lang.String id)
Initializes the given file (parsing header information, etc.).
|
boolean |
isExtendedDepthOfField() |
boolean |
isThisType(loci.common.RandomAccessInputStream stream)
Checks if the given stream is a valid stream for this file format.
|
boolean |
isThisType(java.lang.String name,
boolean open)
Checks if a file matches the type of this format reader.
|
private void |
makeFileList()
Build a list of files that belong with the current file.
|
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 int |
parseIntValue(java.lang.Number v,
int defaultValue) |
private void |
parsePixelSpacing(java.lang.String value) |
private void |
scanDirectory(loci.common.Location dir,
boolean checkSeries)
Scan the given directory for files that belong to this dataset.
|
private void |
updateCoreMetadata(CoreMetadata ms) |
coreIndexToSeries, flattenHashtables, getCoreIndex, getCoreMetadataList, getCurrentCore, getResolution, getResolutionCount, getSeries, getSeriesCount, seriesToCoreIndex, setCoreIndex, setResolution, setSeries
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, getDomains, getEffectiveSizeC, getExperimentType, getFilamentType, 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, getRGBChannelCount, getRotationTransform, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getThumbSizeX, getThumbSizeY, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, isThisType, isThumbnailSeries, isUsedFile, makeFilterMetadata, openBytes, openBytes, openBytes, openPlane, openThumbBytes, readPlane, readPlane, readPlane, reopenFile, setFlattenedResolutions, setGroupFiles, setId, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, updateMetadataLists
checkSuffix, checkSuffix, getFormat, getMetadataOptions, getNativeDataType, getSuffixes, getSupportedMetadataLevels, setMetadataOptions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormat, getNativeDataType, getSuffixes
getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions
public static final java.lang.String DICOM_MAGIC_STRING
public static final int HEADER_LENGTH
private static final java.lang.String[] DICOM_SUFFIXES
private byte[][] lut
private short[][] shortLut
private int maxPixelRange
private int centerPixelValue
private boolean inverted
private java.lang.String date
private java.lang.String time
private java.lang.String imageType
private java.lang.String pixelSizeX
private java.lang.String pixelSizeY
private java.lang.Double pixelSizeZ
private java.util.List<java.lang.Double> positionX
private java.util.List<java.lang.Double> positionY
private java.util.List<java.lang.Double> positionZ
private java.util.List<java.lang.String> channelNames
private boolean isJPEG
private boolean isRLE
private boolean isJP2K
private boolean isDeflate
private java.util.Map<java.lang.Integer,java.util.List<java.lang.String>> fileList
private int imagesPerFile
private java.lang.String instanceUID
private java.lang.String originalDate
private java.lang.String originalTime
private java.lang.String originalInstance
private int originalSeries
private int originalX
private int originalY
private java.lang.String originalSpecimen
private java.util.List<java.lang.String> companionFiles
private java.util.Map<java.lang.Integer,java.util.List<DicomTile>> tilePositions
private java.util.Map<java.lang.Integer,java.util.List<java.lang.Double>> zOffsets
private java.lang.Number concatenationNumber
private boolean edf
private java.util.List<DicomTag> tags
public boolean isThisType(java.lang.String name, boolean open)
FormatReader
FormatReader.isThisType(RandomAccessInputStream)
.isThisType
in interface IFormatReader
isThisType
in class FormatReader
open
- If true, and the file extension is insufficient to determine
the file type, the (existing) file is opened for further analysis.public boolean isThisType(loci.common.RandomAccessInputStream stream) throws java.io.IOException
IFormatReader
isThisType
in interface IFormatReader
isThisType
in class FormatReader
stream
- A RandomAccessInputStream representing the file to check.
The first byte in the stream is assumed to be the first byte
in the file.java.io.IOException
public int getRequiredDirectories(java.lang.String[] files) throws FormatException, java.io.IOException
IFormatReader
getRequiredDirectories
in interface IFormatReader
getRequiredDirectories
in class FormatReader
FormatException
java.io.IOException
public byte[][] get8BitLookupTable()
IFormatReader
IFormatReader.isIndexed()
returns
false, then this may return null. Also, if IFormatReader.getPixelType()
returns
anything other than FormatTools.INT8
or FormatTools.UINT8
,
this method will return null.get8BitLookupTable
in interface IFormatReader
get8BitLookupTable
in class FormatReader
public short[][] get16BitLookupTable()
IFormatReader
IFormatReader.isIndexed()
returns
false, then this may return null. Also, if IFormatReader.getPixelType()
returns
anything other than FormatTools.INT16
or FormatTools.UINT16
, this method will return null.get16BitLookupTable
in interface IFormatReader
get16BitLookupTable
in class FormatReader
public java.lang.String[] getSeriesUsedFiles(boolean noPixels)
IFormatReader
IFormatHandler.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.getSeriesUsedFiles
in interface IFormatReader
getSeriesUsedFiles
in class FormatReader
public int fileGroupOption(java.lang.String id) throws FormatException, java.io.IOException
IFormatReader
fileGroupOption
in interface IFormatReader
fileGroupOption
in class FormatReader
id
- a file in the multi-file datasetFormatTools.MUST_GROUP
indicates that the
files cannot be handled separately; the reader will always detect and
read all files in the dataset. FormatTools.CAN_GROUP
indicates
that the files may be handled separately, but file grouping must then
be disabled via IFormatReader.setGroupFiles(boolean)
.
FormatTools.CANNOT_GROUP
indicates that the files must be handled
separately; the reader will not attempt to read all files in the dataset
(this is rare).FormatException
java.io.IOException
FormatTools.MUST_GROUP
,
FormatTools.CAN_GROUP
,
FormatTools.CANNOT_GROUP
public int getOptimalTileWidth()
IFormatReader
getOptimalTileWidth
in interface IFormatReader
getOptimalTileWidth
in class FormatReader
public int getOptimalTileHeight()
IFormatReader
getOptimalTileHeight
in interface IFormatReader
getOptimalTileHeight
in class FormatReader
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, java.io.IOException
IFormatReader
openBytes
in interface IFormatReader
openBytes
in class FormatReader
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-imagebuf
for convenience.FormatException
- if there was a problem parsing the metadata of the
file.java.io.IOException
- if there was a problem reading the file.IFormatReader.openBytes(int, byte[], int, int, int, int)
public void close(boolean fileOnly) throws java.io.IOException
IFormatReader
Closeable.close()
.close
in interface IFormatReader
close
in class SubResolutionFormatReader
java.io.IOException
protected void initFile(java.lang.String id) throws FormatException, java.io.IOException
SubResolutionFormatReader
initFile
in class SubResolutionFormatReader
FormatException
- if a parsing error occurs processing the file.java.io.IOException
- if an I/O error occurs processing the fileprivate void addInfo(DicomTag info) throws java.io.IOException
java.io.IOException
private void addOriginalMetadata(java.lang.String key, DicomTag info)
private void makeFileList() throws FormatException, java.io.IOException
FormatException
java.io.IOException
private void scanDirectory(loci.common.Location dir, boolean checkSeries) throws FormatException, java.io.IOException
FormatException
java.io.IOException
private void addFileToList(java.lang.String file, boolean checkSeries) throws FormatException, java.io.IOException
FormatException
java.io.IOException
private int parseIntValue(java.lang.Number v, int defaultValue)
private long getTimestampMicroseconds(java.lang.String v)
private void attachCompanionFiles() throws java.io.IOException
java.io.IOException
private void getTile(DicomTile tile, byte[] buf, int x, int y, int w, int h) throws FormatException, java.io.IOException
FormatException
java.io.IOException
private void parsePixelSpacing(java.lang.String value)
private void handleReferencedFile(DicomTag tag, java.lang.String currentType)
private void calculatePixelsOffsets(long baseOffset) throws FormatException, java.io.IOException
FormatException
java.io.IOException
private DicomFileInfo createFileInfo(java.lang.String file) throws FormatException, java.io.IOException
FormatException
java.io.IOException
private void updateCoreMetadata(CoreMetadata ms)
public java.lang.String getImageType()
public java.util.List<DicomTile> getTiles()
public java.util.List<java.lang.Double> getZOffsets()
public int getConcatenationIndex()
public ome.units.quantity.Length getPixelSizeX()
public ome.units.quantity.Length getPixelSizeY()
public ome.units.quantity.Length getPixelSizeZ()
public java.util.List<java.lang.Double> getPositionX()
public java.util.List<java.lang.Double> getPositionY()
public java.util.List<java.lang.Double> getPositionZ()
public java.util.List<java.lang.String> getChannelNames()
public boolean isExtendedDepthOfField()
public ome.xml.model.primitives.Timestamp getTimestamp()
public java.util.List<DicomTag> getTags()
Copyright © 2022 Open Microscopy Environment