Class FileCOR
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileCOR
-
public class FileCOR extends FileBase
FreeSurfer COR files are used to store 3 dimensional unsigned byte data. Suppose the file base name is table. There is a header file named table-.info/and or table-.info~ which has the header information in ascii. A separate unsigned byte file exists for each slice of the 3D image - table-001, table-002, and so on until the last slice. The default is to have xDim = yDim = zDim = 256 and xResolution = yResolution = zResolution = 0.001 meter. Note that all distances in a COR file represent meters.The header fields are as follows: imnr0 the first slice number imnr1 the last slice number ptype the data type; 2 for unsigned byte x the x dimension y the y dimension fov the field of view thick the z resolution psiz = a common value for both the x and y resolutions locatn location strtx the minimum x value in meters endx the maximum x value in meters strty the minimum y value in meters endy the maximum y value in meters strtz the minimum z value in meters endz the maximum z value in meters tr T_r te T_e ti T_i xform transform file ras_good_file = 1 if the orientation fields are set, 0 otherwise x_ras x axis orientation y_ras y axis orientation z_ras z axis orientation c_ras volume center coordinates If orientation information is missing, the file is assumed to be coronal with z axis = R to L, y axis = S to I, and z axis = P to A. readInfoImage reads in the header information from the set of FreeSurfer COR volume images and then readImage is called once for each slice that must be read from a COR image file set.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilefileDOCUMENT ME!private java.lang.StringfileDirDOCUMENT ME!private FileInfoCORfileInfoDOCUMENT ME!private java.lang.StringfileNameDOCUMENT ME!private booleanfoundEOFDOCUMENT ME!private ModelImageimageDOCUMENT ME!private int[]imageExtentsDOCUMENT ME!private intimageOrientationDOCUMENT ME!private float[]imgBufferDOCUMENT ME!private float[]imgResolsDOCUMENT ME!private ModelLUTLUTDOCUMENT ME!private int[]orientDOCUMENT ME!-
Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE
-
-
Constructor Summary
Constructors Constructor Description FileCOR(java.lang.String fileName, java.lang.String fileDir)COR reader/writer constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinalize()Prepares this class for cleanup.FileInfoBasegetFileInfo()Accessor that returns the file info.float[]getImageBuffer()Accessor that returns the image buffer.ModelLUTgetModelLUT()Rreturns LUT if defined.private java.lang.String[]parse(java.lang.String inString)DOCUMENT ME!voidreadImage(int length)This method reads one slice from the file into byteBuffer and then transfers into the float array imgBuffer.voidreadInfoImage()DOCUMENT ME!private java.lang.StringreadLine()Reads lines of the file until a nonnull String results or the end of the file is reached.voidsetFileName(java.lang.String fName)Accessor to set the file name (used for reading COR multiFile).voidwriteImage(ModelImage image, FileWriteOptions options)Writes a COR format type image.-
Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, floatToBytes, getBufferDouble, getBufferFloat, getBufferInt, getBufferLong, getBufferShort, getBufferUShort, getDataType, getDouble, getFloat, getInt, getLong, getProgressChangeListeners, getRaFile, getSignedShort, getString, getUInt, getUnsignedByte, getUnsignedShort, intToBytes, isBigEndian, isProgressBarVisible, linkProgress, longToBytes, readDouble, readFloat, readInt, readLong, readShort, readString, readUnsignedShort, removeProgressChangeListener, setBigEndian, setBufferFloat, setBufferInt, setBufferLong, setBufferShort, setBufferString, setDataType, setEndianess, shortToBytes, writeBytes, writeDouble, writeFloat, writeInt, writeLong, writeShort
-
-
-
-
Field Detail
-
file
private java.io.File file
DOCUMENT ME!
-
fileDir
private java.lang.String fileDir
DOCUMENT ME!
-
fileInfo
private FileInfoCOR fileInfo
DOCUMENT ME!
-
fileName
private java.lang.String fileName
DOCUMENT ME!
-
foundEOF
private boolean foundEOF
DOCUMENT ME!
-
image
private ModelImage image
DOCUMENT ME!
-
imageExtents
private int[] imageExtents
DOCUMENT ME!
-
imageOrientation
private int imageOrientation
DOCUMENT ME!
-
imgBuffer
private float[] imgBuffer
DOCUMENT ME!
-
imgResols
private float[] imgResols
DOCUMENT ME!
-
LUT
private ModelLUT LUT
DOCUMENT ME!
-
orient
private int[] orient
DOCUMENT ME!
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for cleanup. Calls thefinalizemethod for existing elements, closes any open files and sets other elements tonull.
-
getFileInfo
public FileInfoBase getFileInfo()
Accessor that returns the file info.- Returns:
- FileInfoBase containing the file info
-
getImageBuffer
public float[] getImageBuffer()
Accessor that returns the image buffer.- Returns:
- buffer of image.
-
getModelLUT
public ModelLUT getModelLUT()
Rreturns LUT if defined.- Returns:
- the LUT if defined else it is null
-
readImage
public void readImage(int length) throws java.io.IOExceptionThis method reads one slice from the file into byteBuffer and then transfers into the float array imgBuffer.- Parameters:
length- length = imageExtents[0] * imageExtents[1]- Throws:
java.io.IOException- if there is an error reading the file
-
readInfoImage
public void readInfoImage() throws java.io.IOExceptionDOCUMENT ME!- Throws:
java.io.IOException- DOCUMENT ME!
-
setFileName
public void setFileName(java.lang.String fName)
Accessor to set the file name (used for reading COR multiFile).- Parameters:
fName- file name of image to read.
-
writeImage
public void writeImage(ModelImage image, FileWriteOptions options) throws java.io.IOException
Writes a COR format type image.- Parameters:
image- Image model of data to write.options- options such as starting and ending slices and times- Throws:
java.io.IOException- if there is an error writing the file
-
parse
private java.lang.String[] parse(java.lang.String inString)
DOCUMENT ME!- Parameters:
inString- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
readLine
private java.lang.String readLine() throws java.io.IOExceptionReads lines of the file until a nonnull String results or the end of the file is reached.- Returns:
- the line read in
- Throws:
java.io.IOException- if there is an error reading the file
-
-