public class TextReader extends FormatReader
Modifier and Type | Field and Description |
---|---|
private String[] |
channels
List of channel labels.
|
private float[][] |
data
Because we have no way of indexing into the text file efficiently
in general, we cheat and store the entire file's data in a giant array.
|
private static String |
LABEL_X |
private static String |
LABEL_Y |
private static boolean |
LITTLE_ENDIAN |
private int |
row
Current row number.
|
private int |
rowLength
Number of tokens per row.
|
private int |
sizeX
Image width.
|
private int |
sizeY
Image height.
|
private static long |
TIME_OFFSET
How often to report progress during initialization, in milliseconds.
|
private int |
xIndex
Column index for X coordinate.
|
private int |
yIndex
Column index for Y coordinate.
|
core, coreIndex, datasetDescription, domains, filterMetadata, flattenedResolutions, group, hasCompanionFiles, in, indexedAsRGB, metadata, metadataOptions, metadataStore, normalizeData, resolution, saveOriginalMetadata, series, suffixNecessary, suffixSufficient, THUMBNAIL_DIMENSION
COMPRESSION_SUFFIXES, currentId, format, LOGGER, suffixes
CAN_GROUP, CANNOT_GROUP, MUST_GROUP
Constructor and Description |
---|
TextReader()
Constructs a new text reader.
|
Modifier and Type | Method and Description |
---|---|
private void |
assignValues(double[] rowData)
Assigns values from the given row into the data array.
|
private long |
checkTime(long time,
int no,
long pos,
long len) |
void |
close(boolean fileOnly)
Closes the currently open file.
|
String |
getChannelLabel(int c)
Gets the label for the given channel.
|
Class<?> |
getNativeDataType()
Returns the native data type of image planes for this reader, as returned
by
IFormatReader.openPlane(int, int, int, int, int) or IFormatWriter.savePlane(int, java.lang.Object) . |
private String[] |
getNextLine(List<String> lines) |
private boolean |
getRowData(String[] tokens,
double[] rowData)
Parses numerical row data from the given tokens.
|
private int |
getX(double[] rowData) |
private int |
getY(double[] rowData) |
protected void |
initFile(String id)
Initializes the given file (parsing header information, etc.).
|
boolean |
isThisType(RandomAccessInputStream stream)
Checks if the given stream is a valid stream for this file format.
|
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.
|
Object |
openPlane(int no,
int x,
int y,
int w,
int h)
Obtains the specified image plane (or sub-image thereof) in the reader's
native data structure.
|
private int |
parseFileHeader(List<String> lines)
Parses the file looking for the file header.
|
private void |
parseHeaderRow(String[] tokens)
Populates rowLength, xIndex, yIndex, and channels.
|
private void |
parseTableData(List<String> lines,
int linesToSkip)
Reads the tabular data into the data array.
|
private void |
populateCoreMetadata(int sizeX,
int sizeY,
int sizeZ,
int sizeC,
int sizeT)
Populates the
CoreMetadata values. |
private List<String> |
readFile(String id) |
addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMetaList, addMeta, addMetaList, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMetaList, close, coreIndexToSeries, fileGroupOption, flattenHashtables, get16BitLookupTable, get8BitLookupTable, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getBinning, getBitsPerPixel, getCompression, getContrastMethod, getCoreIndex, getCoreMetadataList, getCorrection, getCurrentFile, getDatasetStructureDescription, getDetectorType, getDimensionOrder, getDimensionOrder, getDomains, getEffectiveSizeC, getExperimentType, getFilamentType, getFillRule, getFilterType, getFontFamily, getFontStyle, getGlobalMeta, getGlobalMetadata, getIlluminationType, getImageCount, getImmersion, getIndex, getIndex, getLaserMedium, getLaserType, getLineCap, getMarker, getMedium, getMetadataOptions, getMetadataStore, getMetadataStoreRoot, getMetadataValue, getMicrobeamManipulationType, getMicroscopeType, getModuloC, getModuloT, getModuloZ, getNamingConvention, getOptimalTileHeight, getOptimalTileWidth, getPixelType, getPixelType, getPossibleDomains, getPulse, getRequiredDirectories, getResolution, getResolutionCount, getRGBChannelCount, getRotationTransform, getSeries, getSeriesCount, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getSupportedMetadataLevels, getThumbSizeX, getThumbSizeY, 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, openThumbBytes, readPlane, readPlane, reopenFile, seriesToCoreIndex, setCoreIndex, setFlattenedResolutions, setGroupFiles, setId, setMetadataFiltered, setMetadataOptions, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setResolution, setSeries
checkSuffix, checkSuffix, getFormat, getSuffixes
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormat, getSuffixes
private static final boolean LITTLE_ENDIAN
private static final String LABEL_X
private static final String LABEL_Y
private static final long TIME_OFFSET
private float[][] data
private int row
private int rowLength
private int xIndex
private int yIndex
private String[] channels
private int sizeX
private int sizeY
public String getChannelLabel(int c)
public boolean isThisType(RandomAccessInputStream stream) throws IOException
IFormatReader
isThisType
in interface IFormatReader
isThisType
in class FormatReader
IOException
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException
IFormatReader
openBytes
in interface IFormatReader
openBytes
in class FormatReader
no
- the image index within the file.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.IOException
- if there was a problem reading the file.public Object openPlane(int no, int x, int y, int w, int h) throws FormatException, IOException
IFormatReader
BufferedImage
. The openPlane method exists to
maintain generality and efficiency while avoiding pollution of the API
with AWT-specific logic.openPlane
in interface IFormatReader
openPlane
in class FormatReader
FormatException
IOException
FormatReader
,
BufferedImageReader
public void close(boolean fileOnly) throws IOException
IFormatReader
Closeable.close()
.close
in interface IFormatReader
close
in class FormatReader
IOException
public Class<?> getNativeDataType()
IFormatHandler
IFormatReader.openPlane(int, int, int, int, int)
or IFormatWriter.savePlane(int, java.lang.Object)
.
For most readers this type will be a byte array; however, some readers
call external APIs that work with other types such as
BufferedImage
.getNativeDataType
in interface IFormatHandler
getNativeDataType
in class FormatHandler
protected void initFile(String id) throws FormatException, IOException
FormatReader
initFile
in class FormatReader
FormatException
- if a parsing error occurs processing the file.IOException
- if an I/O error occurs processing the fileprivate List<String> readFile(String id) throws IOException
IOException
private int parseFileHeader(List<String> lines) throws FormatException
FormatException
private void parseTableData(List<String> lines, int linesToSkip)
private void populateCoreMetadata(int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)
CoreMetadata
values.private boolean getRowData(String[] tokens, double[] rowData)
tokens
- list of token strings to parserowData
- array to fill in with the data; length must match tokensprivate void parseHeaderRow(String[] tokens)
private void assignValues(double[] rowData)
private long checkTime(long time, int no, long pos, long len)
private int getX(double[] rowData)
private int getY(double[] rowData)
Copyright © 2016 Open Microscopy Environment