Class FileInterfile


  • public class FileInterfile
    extends FileBase
    Author:
    William Gandler
    See Also:
    FileIO
    • Field Detail

      • UNSIGNED_INTEGER

        private static final int UNSIGNED_INTEGER
        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!
      • fileLength

        private long fileLength
        DOCUMENT ME!
      • fileName

        private java.lang.String fileName
        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!
      • 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 name
        fileDir - 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 the finalize method for existing elements, closes any open files and sets other elements to null.
        Overrides:
        finalize in class FileBase
      • 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 array
        buffer - 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 array
        buffer - 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 array
        buffer - 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