Package gov.nih.mipav.model.file
Class FileInterfile
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileInterfile
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ASCII
DOCUMENT ME!private static int
BIT
DOCUMENT ME!private int
bufferSize
DOCUMENT ME!private int
bytesPerPixel
DOCUMENT ME!private long
dataByteOffset
DOCUMENT ME!private java.io.File
dataFile
DOCUMENT ME!private java.lang.String
dataFileName
DOCUMENT ME!private int
dataStartingBlock
DOCUMENT ME!private boolean
endianess
DOCUMENT ME!private java.io.File
file
DOCUMENT ME!private java.lang.String
fileDir
DOCUMENT ME!private FileInfoInterfile
fileInfo
DOCUMENT ME!private FileInfoInterfile
fileInfoCopy
private long
fileLength
DOCUMENT ME!private java.lang.String
fileName
DOCUMENT ME!private FileRawChunk
fileRW
DOCUMENT ME!private boolean
foundEOF
DOCUMENT ME!private boolean
haveBytesPerPixel
DOCUMENT ME!private boolean
haveDataByteOffset
DOCUMENT ME!private boolean
haveDataStartingBlock
DOCUMENT ME!private boolean
haveDecayCorrected
DOCUMENT ME!private boolean
haveDetectorHeadNumber
DOCUMENT ME!private boolean
haveEndianess
DOCUMENT ME!private boolean
haveEnergyWindowsNumber
DOCUMENT ME!private boolean
haveFileName
DOCUMENT ME!private boolean
haveFloodCorrected
DOCUMENT ME!private boolean
haveImagesPerEWindow
DOCUMENT ME!private boolean
haveNumberFormat
DOCUMENT ME!private boolean
haveOrientation
DOCUMENT ME!private boolean
haveReconstructed
DOCUMENT ME!private boolean
haveReferenceFrameNumber
DOCUMENT ME!private boolean
haveResolsT
DOCUMENT ME!private boolean
haveResolsX
DOCUMENT ME!private boolean
haveResolsY
DOCUMENT ME!private boolean
haveResolsZ
DOCUMENT ME!private boolean
haveSliceThickness
DOCUMENT ME!private boolean
haveStaticStudy
private boolean
haveTDim
private boolean
haveTomographic
DOCUMENT ME!private boolean
haveTotalImageNumber
DOCUMENT ME!private boolean
haveXDim
DOCUMENT ME!private boolean
haveYDim
DOCUMENT ME!private boolean
haveZDim
DOCUMENT ME!private java.lang.String
headerFileName
private ModelImage
image
DOCUMENT ME!private int
imageOrientation
DOCUMENT ME!private float[]
imgBuffer
DOCUMENT ME!private double[]
imgDBuffer
DOCUMENT ME!private int[]
imgExtents
DOCUMENT ME!private long[]
imgLBuffer
DOCUMENT ME!private float[]
imgResols
DOCUMENT ME!private java.lang.String
isotopeNumber
DOCUMENT ME!private static int
LONG_FLOAT
DOCUMENT ME!private ModelLUT
LUT
DOCUMENT ME!private int
numberFormat
DOCUMENT ME!private int
numberSlices
DOCUMENT ME!private int
orientation
DOCUMENT ME!private java.lang.String
originalFileName
DOCUMENT ME!private int
resXUnit
DOCUMENT ME!private int
resYUnit
DOCUMENT ME!private int
resZUnit
DOCUMENT ME!private float
scalingFactor1
DOCUMENT ME!private float
scalingFactor2
DOCUMENT ME!private float
scalingFactor3
DOCUMENT ME!private float
scalingFactor4
DOCUMENT ME!private static int
SHORT_FLOAT
DOCUMENT ME!private static int
SIGNED_INTEGER
DOCUMENT ME!private int
tDim
DOCUMENT ME!private java.lang.String
timeFrame
DOCUMENT ME!private int
totalImageNumber
DOCUMENT ME!private int
type
DOCUMENT ME!private static int
UNSIGNED_INTEGER
DOCUMENT ME!private java.lang.String
windowNumber
DOCUMENT ME!private int
xDim
DOCUMENT ME!private float
xResol
DOCUMENT ME!private int
yDim
DOCUMENT ME!private float
yResol
DOCUMENT ME!private int
zDim
DOCUMENT ME!private float
zResol
DOCUMENT 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 FileInterfile(java.lang.String originalFileName, java.lang.String fileDir)
Interfile reader/writer constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finalize()
Prepares this class for cleanup.FileInfoInterfile
getFileInfo()
Returns the file info.float[]
getImageBuffer()
Returns the image buffer.ModelLUT
getModelLUT()
Returns LUT if defined.static java.lang.String
isInterfile(java.lang.String fName, java.lang.String fDir)
Method to test to determine if the image format is Cheshire, so appropriate read method may be called.private void
readBBuffer(int slice, float[] buffer)
DOCUMENT ME!private void
readBuffer(int slice, float[] buffer)
Reads a slice of data at a time and stores the results in the buffer.private void
readDBuffer(int slice, double[] buffer)
Reads a slice of data at a time and stores the results in the buffer.ModelImage
readImage(boolean one, boolean readData)
Reads the image.private void
readLBuffer(int slice, long[] buffer)
Reads a slice of data at a time and stores the results in the buffer.private java.lang.String
readLine()
Reads lines of the file and strips comments indicated by the ; symbol until a nonnull String results or the end of the file is reached.private static java.lang.String
removeChars(java.lang.String inString)
Removes white space and exclamation marks.private static java.lang.String
returnKey(java.lang.String inString)
Returns the key found in the string.private java.lang.String
returnValue(java.lang.String inString)
Returns the value found in the string.void
setFileName(java.lang.String fName)
Sets the file name (used when reading TIFF multiFile).void
writeImage(ModelImage image, FileWriteOptions options)
Writes an Interfile 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
-
SIGNED_INTEGER
private static final int SIGNED_INTEGER
DOCUMENT ME!- See Also:
- Constant Field Values
-
UNSIGNED_INTEGER
private static final int UNSIGNED_INTEGER
DOCUMENT ME!- See Also:
- Constant Field Values
-
LONG_FLOAT
private static final int LONG_FLOAT
DOCUMENT ME!- See Also:
- Constant Field Values
-
SHORT_FLOAT
private static final int SHORT_FLOAT
DOCUMENT ME!- See Also:
- Constant Field Values
-
BIT
private static final int BIT
DOCUMENT ME!- See Also:
- Constant Field Values
-
ASCII
private static final int ASCII
DOCUMENT ME!- See Also:
- Constant Field Values
-
bufferSize
private int bufferSize
DOCUMENT ME!
-
bytesPerPixel
private int bytesPerPixel
DOCUMENT ME!
-
dataByteOffset
private long dataByteOffset
DOCUMENT ME!
-
dataFile
private java.io.File dataFile
DOCUMENT ME!
-
dataFileName
private java.lang.String dataFileName
DOCUMENT ME!
-
headerFileName
private java.lang.String headerFileName
-
dataStartingBlock
private int dataStartingBlock
DOCUMENT ME!
-
endianess
private boolean endianess
DOCUMENT ME!
-
file
private java.io.File file
DOCUMENT ME!
-
fileDir
private java.lang.String fileDir
DOCUMENT ME!
-
fileInfo
private FileInfoInterfile fileInfo
DOCUMENT ME!
-
fileInfoCopy
private FileInfoInterfile fileInfoCopy
-
fileLength
private long fileLength
DOCUMENT ME!
-
fileName
private java.lang.String fileName
DOCUMENT ME!
-
fileRW
private FileRawChunk fileRW
DOCUMENT ME!
-
foundEOF
private boolean foundEOF
DOCUMENT ME!
-
haveBytesPerPixel
private boolean haveBytesPerPixel
DOCUMENT ME!
-
haveDataByteOffset
private boolean haveDataByteOffset
DOCUMENT ME!
-
haveDataStartingBlock
private boolean haveDataStartingBlock
DOCUMENT ME!
-
haveDecayCorrected
private boolean haveDecayCorrected
DOCUMENT ME!
-
haveDetectorHeadNumber
private boolean haveDetectorHeadNumber
DOCUMENT ME!
-
haveEndianess
private boolean haveEndianess
DOCUMENT ME!
-
haveEnergyWindowsNumber
private boolean haveEnergyWindowsNumber
DOCUMENT ME!
-
haveFileName
private boolean haveFileName
DOCUMENT ME!
-
haveFloodCorrected
private boolean haveFloodCorrected
DOCUMENT ME!
-
haveImagesPerEWindow
private boolean haveImagesPerEWindow
DOCUMENT ME!
-
haveNumberFormat
private boolean haveNumberFormat
DOCUMENT ME!
-
haveOrientation
private boolean haveOrientation
DOCUMENT ME!
-
haveReconstructed
private boolean haveReconstructed
DOCUMENT ME!
-
haveReferenceFrameNumber
private boolean haveReferenceFrameNumber
DOCUMENT ME!
-
haveResolsT
private boolean haveResolsT
DOCUMENT ME!
-
haveResolsX
private boolean haveResolsX
DOCUMENT ME!
-
haveResolsY
private boolean haveResolsY
DOCUMENT ME!
-
haveResolsZ
private boolean haveResolsZ
DOCUMENT ME!
-
haveSliceThickness
private boolean haveSliceThickness
DOCUMENT ME!
-
haveTDim
private boolean haveTDim
-
haveTomographic
private boolean haveTomographic
DOCUMENT ME!
-
haveTotalImageNumber
private boolean haveTotalImageNumber
DOCUMENT ME!
-
haveXDim
private boolean haveXDim
DOCUMENT ME!
-
haveYDim
private boolean haveYDim
DOCUMENT ME!
-
haveZDim
private boolean haveZDim
DOCUMENT ME!
-
image
private ModelImage image
DOCUMENT ME!
-
imageOrientation
private int imageOrientation
DOCUMENT ME!
-
imgBuffer
private float[] imgBuffer
DOCUMENT ME!
-
imgDBuffer
private double[] imgDBuffer
DOCUMENT ME!
-
imgExtents
private int[] imgExtents
DOCUMENT ME!
-
imgLBuffer
private long[] imgLBuffer
DOCUMENT ME!
-
imgResols
private float[] imgResols
DOCUMENT ME!
-
isotopeNumber
private java.lang.String isotopeNumber
DOCUMENT ME!
-
LUT
private ModelLUT LUT
DOCUMENT ME!
-
numberFormat
private int numberFormat
DOCUMENT ME!
-
numberSlices
private int numberSlices
DOCUMENT ME!
-
orientation
private int orientation
DOCUMENT ME!
-
originalFileName
private java.lang.String originalFileName
DOCUMENT ME!
-
resXUnit
private int resXUnit
DOCUMENT ME!
-
resYUnit
private int resYUnit
DOCUMENT ME!
-
resZUnit
private int resZUnit
DOCUMENT ME!
-
scalingFactor1
private float scalingFactor1
DOCUMENT ME!
-
scalingFactor2
private float scalingFactor2
DOCUMENT ME!
-
scalingFactor3
private float scalingFactor3
DOCUMENT ME!
-
scalingFactor4
private float scalingFactor4
DOCUMENT ME!
-
tDim
private int tDim
DOCUMENT ME!
-
timeFrame
private java.lang.String timeFrame
DOCUMENT ME!
-
totalImageNumber
private int totalImageNumber
DOCUMENT ME!
-
type
private int type
DOCUMENT ME!
-
windowNumber
private java.lang.String windowNumber
DOCUMENT ME!
-
xDim
private int xDim
DOCUMENT ME!
-
xResol
private float xResol
DOCUMENT ME!
-
yResol
private float yResol
DOCUMENT ME!
-
zResol
private float zResol
DOCUMENT ME!
-
yDim
private int yDim
DOCUMENT ME!
-
zDim
private int zDim
DOCUMENT ME!
-
haveStaticStudy
private boolean haveStaticStudy
-
-
Constructor Detail
-
FileInterfile
public FileInterfile(java.lang.String originalFileName, java.lang.String fileDir) throws java.io.IOException
Interfile reader/writer constructor.- Parameters:
originalFileName
- file namefileDir
- file directory- Throws:
java.io.IOException
- if there is an error making the file
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for cleanup. Calls thefinalize
method for existing elements, closes any open files and sets other elements tonull
.
-
isInterfile
public static java.lang.String isInterfile(java.lang.String fName, java.lang.String fDir)
Method to test to determine if the image format is Cheshire, so appropriate read method may be called.- Parameters:
fName
- File name of image.fDir
- Directory.- Returns:
true
if Cheshire file,false
otherwise.
-
getFileInfo
public FileInfoInterfile getFileInfo()
Returns the file info.- Returns:
- FileInfoBase containing the file info
-
getImageBuffer
public float[] getImageBuffer()
Returns the image buffer.- Returns:
- buffer of image.
-
getModelLUT
public ModelLUT getModelLUT()
Returns LUT if defined.- Returns:
- the LUT if defined else it is null
-
readImage
public ModelImage readImage(boolean one, boolean readData) throws java.io.IOException
Reads the image.- Parameters:
one
- Flag for only reading one image of dataset.readData
-- Returns:
- returns the image
- Throws:
java.io.IOException
- if there is an error reading the file
-
setFileName
public void setFileName(java.lang.String fName)
Sets the file name (used when reading TIFF multiFile).- Parameters:
fName
- file name of image to read.
-
writeImage
public void writeImage(ModelImage image, FileWriteOptions options) throws java.io.IOException
Writes an Interfile 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
-
removeChars
private static java.lang.String removeChars(java.lang.String inString)
Removes white space and exclamation marks.- Parameters:
inString
- String to remove characters from.- Returns:
- new String with removed white space.
-
returnKey
private static java.lang.String returnKey(java.lang.String inString)
Returns the key found in the string.- Parameters:
inString
- String to search for key in.- Returns:
- Key, or
null
if not found
-
readBBuffer
private void readBBuffer(int slice, float[] buffer) throws java.io.IOException
DOCUMENT ME!- Parameters:
slice
- DOCUMENT ME!buffer
- DOCUMENT ME!- Throws:
java.io.IOException
- DOCUMENT ME!
-
readBuffer
private void readBuffer(int slice, float[] buffer) throws java.io.IOException
Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice
- offset into the file stored in the dataOffset arraybuffer
- buffer where the info is stored- Throws:
java.io.IOException
- if there is an error reading the file
-
readDBuffer
private void readDBuffer(int slice, double[] buffer) throws java.io.IOException
Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice
- offset into the file stored in the dataOffset arraybuffer
- buffer where the info is stored- Throws:
java.io.IOException
- if there is an error reading the file
-
readLBuffer
private void readLBuffer(int slice, long[] buffer) throws java.io.IOException
Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice
- offset into the file stored in the dataOffset arraybuffer
- buffer where the info is stored- Throws:
java.io.IOException
- if there is an error reading the file
-
readLine
private java.lang.String readLine() throws java.io.IOException
Reads lines of the file and strips comments indicated by the ; symbol 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
-
returnValue
private java.lang.String returnValue(java.lang.String inString)
Returns the value found in the string.- Parameters:
inString
- String to search for value in.- Returns:
- Value, or
null
if not found
-
-