retina
Class OIDHeader

java.lang.Object
  |
  +--retina.OIDHeader

public class OIDHeader
extends java.lang.Object

Defines the header for KES/DAT files for OID devices. (c) 2003 Michael Abramoff. All rights reserved.


Field Summary
protected  byte[] byteHeader
           
(package private) static java.lang.String DATA_EXTENSION
           
protected  java.lang.String date
           
protected  java.lang.String directory
           
protected  java.lang.String extraInfo
           
protected  java.lang.String fileName
           
protected  java.lang.String firstname
           
(package private) static java.lang.String HEADER_EXTENSION
           
protected  java.lang.String headerInfo
           
static int headerSize
           
protected static int HEIGHT
           
protected  java.lang.String name
           
protected static int NRSLICES
           
static int RAW_OFFSET
           
protected  boolean rightEye
           
protected  java.lang.String stimulus
           
protected  int stimulusEndFrame
           
protected  int stimulusStartFrame
           
protected  java.lang.String subject
           
protected  java.lang.String time
           
protected static int WIDTH
           
 
Constructor Summary
OIDHeader()
           
OIDHeader(byte[] byteHeader, java.lang.String headerInfo)
          Instantiates an OIDHeader from known header bytes (in .kes file) and String from .dat file.
OIDHeader(java.io.File file)
          Instantiates an OIDHeader from a .dat File.
OIDHeader(int width, int height, int stackSize, java.lang.String headerInfo)
          Instantiates an OIDHeader from image file parameters and properly formatted String headerInfo.
OIDHeader(java.lang.String directory, java.lang.String fileName)
          Instantiates an OIDHeader from both .kes and .dat files.
 
Method Summary
static java.lang.String getDataFileName(java.lang.String name)
          From a file name, either header or data file, get the data file name (ending in _Data.kes).
 java.lang.String getDate()
           
static ij.io.FileInfo getFileInfo(OIDHeader header, java.lang.String directory, java.lang.String file)
           
 int getFrameLength()
          Get the length of each frame.
 byte[] getHeader()
           
 java.lang.String getHeaderAsString()
          Obtains the header text as a String.
static java.lang.String getHeaderAsString(java.io.File file)
          Reads the header text as a String from file.
static java.lang.String getHeaderAsString(java.lang.String directory, java.lang.String name)
          Obtains the header text as a String from a OID file.
static java.lang.String getHeaderFileName(java.lang.String name)
          From a file name, either header or data file, get the header file name (ending in .dat).
protected  int getHeaderInfoInt(java.lang.String precursor)
          Read an int coming directly after the String precursor.
protected  java.lang.String getHeaderInfoString(java.lang.String precursor)
          Read a String coming directly after the String precursor.
 int getHeight()
           
 java.lang.String getInfo()
           
 java.io.FileInputStream getInputStream()
          Get an input stream from the .kes file.
 void getProperties()
           
 int getSequenceNumber()
          Get the sequence number of the .dat (and .kes file corresponding to fileName.) Assumes the filename is built as follows:
 int getStackSize()
           
 java.lang.String getStimulus()
           
protected  void getStimulusData()
          Parse the subject's name and date from the headerInfo String.
 int getStimulusEndFrame()
           
 int getStimulusStartFrame()
           
 java.lang.String getSubject()
           
 int getWidth()
           
static boolean isOIDDATFile(java.lang.String name)
          Check whether the name can be an OID .dat file, the file with the textual header info.
static boolean isOIDFile(java.lang.String name)
          Check whether the name can be an OID file.
 boolean isRightEye()
           
 void putHeaderAsString(java.io.File file)
          Writes the header text as a String to the appropriate file
 void setExtraInfo(java.lang.String extraInfo)
           
 void setHeader(byte[] byteHeader)
           
 void setHeight(int height)
           
 void setProcessing(java.lang.String string)
          Prepend a modification String to the headerinfo so we know it is the result of processing.
 void setProperties(int width, int height, int stackSize, java.lang.String headerInfo)
           
 void setStackSize(int stackSize)
           
 void setStimulus(java.lang.String stimulus)
           
 void setStimulusEndFrame(int stimulusEndFrame)
           
 void setStimulusStartFrame(int stimulusStartFrame)
           
 void setWidth(int width)
           
 java.io.FileOutputStream write(java.lang.String directory, java.lang.String name)
          Write the header to the header part of .kes file and as a .dat file.
 void writeHeader(java.lang.String directory, java.lang.String name)
          Write only the .dat header.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER_EXTENSION

static final java.lang.String HEADER_EXTENSION

DATA_EXTENSION

static final java.lang.String DATA_EXTENSION

headerSize

public static final int headerSize

RAW_OFFSET

public static final int RAW_OFFSET

WIDTH

protected static final int WIDTH

HEIGHT

protected static final int HEIGHT

NRSLICES

protected static final int NRSLICES

byteHeader

protected byte[] byteHeader

directory

protected java.lang.String directory

fileName

protected java.lang.String fileName

headerInfo

protected java.lang.String headerInfo

extraInfo

protected java.lang.String extraInfo

stimulus

protected java.lang.String stimulus

subject

protected java.lang.String subject

firstname

protected java.lang.String firstname

name

protected java.lang.String name

date

protected java.lang.String date

time

protected java.lang.String time

stimulusStartFrame

protected int stimulusStartFrame

stimulusEndFrame

protected int stimulusEndFrame

rightEye

protected boolean rightEye
Constructor Detail

OIDHeader

public OIDHeader()

OIDHeader

public OIDHeader(byte[] byteHeader,
                 java.lang.String headerInfo)
Instantiates an OIDHeader from known header bytes (in .kes file) and String from .dat file.
Parameters:
header - a byte[] with the header info from the .kes file.
headerInfo - a String with the contents of the .dat file.

OIDHeader

public OIDHeader(java.lang.String directory,
                 java.lang.String fileName)
Instantiates an OIDHeader from both .kes and .dat files.
Parameters:
directory -  
name -  

OIDHeader

public OIDHeader(java.io.File file)
Instantiates an OIDHeader from a .dat File.
Parameters:
file - a File of the .dat file.

OIDHeader

public OIDHeader(int width,
                 int height,
                 int stackSize,
                 java.lang.String headerInfo)
Instantiates an OIDHeader from image file parameters and properly formatted String headerInfo.
Parameters:
width -  
height -  
stackSize - all parameters of the image data.
headerInfo - a String with the properly extra header info.
Method Detail

getHeaderFileName

public static java.lang.String getHeaderFileName(java.lang.String name)
From a file name, either header or data file, get the header file name (ending in .dat).
Parameters:
name - a String ending in either _Data.kes or .dat
Returns:
a file name of type .dat.

getDataFileName

public static java.lang.String getDataFileName(java.lang.String name)
From a file name, either header or data file, get the data file name (ending in _Data.kes).
Parameters:
name - a String ending in either _Data.kes or .dat
Returns:
a file name of type _Data.kes

getFileInfo

public static ij.io.FileInfo getFileInfo(OIDHeader header,
                                         java.lang.String directory,
                                         java.lang.String file)

write

public java.io.FileOutputStream write(java.lang.String directory,
                                      java.lang.String name)
Write the header to the header part of .kes file and as a .dat file. Will close the .dat file, keep open the .kes file.
Returns:
a FileOutputStream for the .kes file.

writeHeader

public void writeHeader(java.lang.String directory,
                        java.lang.String name)
Write only the .dat header.

getInputStream

public java.io.FileInputStream getInputStream()
                                       throws java.io.IOException
Get an input stream from the .kes file.
Returns:
a FileInputStream.

getSequenceNumber

public int getSequenceNumber()
Get the sequence number of the .dat (and .kes file corresponding to fileName.) Assumes the filename is built as follows:
 __n_.dat OR n_.dat
 
with n the sequence number + 1.
Returns:
n-1

getFrameLength

public int getFrameLength()
Get the length of each frame.
Returns:
the length of eachf rame in bytes.

isOIDFile

public static boolean isOIDFile(java.lang.String name)
Check whether the name can be an OID file.
Parameters:
name - a String
Returns:
true if it is a OID file, false otherwise.

isOIDDATFile

public static boolean isOIDDATFile(java.lang.String name)
Check whether the name can be an OID .dat file, the file with the textual header info.
Parameters:
name - a String
Returns:
true if it is a OID .dat file, false otherwise.

getHeaderAsString

public static java.lang.String getHeaderAsString(java.lang.String directory,
                                                 java.lang.String name)
                                          throws java.io.IOException
Obtains the header text as a String from a OID file.
Parameters:
directory - the directory where the ehader file is in.
name - the name of an associated file; i.e. a filename ending in either "_Data.kes" or ".dat" indicating the root name of the header file.
Returns:
the text of the header as a String.

getHeaderAsString

public static java.lang.String getHeaderAsString(java.io.File file)
                                          throws java.io.IOException
Reads the header text as a String from file.
Parameters:
file - the header file.
Returns:
the text of the header as a String.

putHeaderAsString

public void putHeaderAsString(java.io.File file)
                       throws java.io.IOException
Writes the header text as a String to the appropriate file
Parameters:
file - the header file.

getHeaderAsString

public java.lang.String getHeaderAsString()
Obtains the header text as a String.
Returns:
the text of the header as a String.

getWidth

public int getWidth()

getHeight

public int getHeight()

getStackSize

public int getStackSize()

isRightEye

public boolean isRightEye()

getStimulusData

protected void getStimulusData()
Parse the subject's name and date from the headerInfo String.

getHeaderInfoInt

protected int getHeaderInfoInt(java.lang.String precursor)
Read an int coming directly after the String precursor.
Parameters:
precursor - the String immediately preceding the required int.
Returns:
the value of the required int.

getHeaderInfoString

protected java.lang.String getHeaderInfoString(java.lang.String precursor)
Read a String coming directly after the String precursor.
Parameters:
precursor - the String immediately preceding the required String.
Returns:
the value of the required String.

setProcessing

public void setProcessing(java.lang.String string)
Prepend a modification String to the headerinfo so we know it is the result of processing.
Parameters:
string - the modification String.

setExtraInfo

public void setExtraInfo(java.lang.String extraInfo)

setStimulus

public void setStimulus(java.lang.String stimulus)

getStimulus

public java.lang.String getStimulus()

getSubject

public java.lang.String getSubject()

getDate

public java.lang.String getDate()

getStimulusStartFrame

public int getStimulusStartFrame()

getStimulusEndFrame

public int getStimulusEndFrame()

setStimulusStartFrame

public void setStimulusStartFrame(int stimulusStartFrame)

setStimulusEndFrame

public void setStimulusEndFrame(int stimulusEndFrame)

setProperties

public void setProperties(int width,
                          int height,
                          int stackSize,
                          java.lang.String headerInfo)

getProperties

public void getProperties()

setWidth

public void setWidth(int width)

setHeight

public void setHeight(int height)

setStackSize

public void setStackSize(int stackSize)

getInfo

public java.lang.String getInfo()

getHeader

public byte[] getHeader()

setHeader

public void setHeader(byte[] byteHeader)