Class FileMetaImage


  • public class FileMetaImage
    extends FileBase
    • Field Detail

      • fileDir

        private java.lang.String fileDir
        DOCUMENT ME!
      • fileName

        private java.lang.String fileName
        DOCUMENT ME!
      • headerSize

        private long headerSize
      • currentLocation

        private long currentLocation
      • file

        private java.io.File file
        DOCUMENT ME!
      • origin

        private float[] origin
        DOCUMENT ME!
      • resolutions

        private float[] resolutions
      • numValues

        private int numValues
      • fieldSeparator

        private java.lang.String fieldSeparator
        DOCUMENT ME!
      • category

        private java.lang.String category
      • baseName

        private java.lang.String baseName
      • values

        private java.lang.String[] values
      • nDims

        private int nDims
      • defaultFileDataName

        private java.lang.String defaultFileDataName
      • defaultFileData

        private java.io.File defaultFileData
      • defaultFileDataExists

        private boolean defaultFileDataExists
      • asciiFormat

        private boolean asciiFormat
      • compressedData

        private boolean compressedData
      • extents

        private int[] extents
      • compressedDataSize

        private int compressedDataSize
      • sepFound

        private boolean sepFound
      • zlibDecompresser

        private java.util.zip.Inflater zlibDecompresser
      • oneFile

        private boolean oneFile
        If true, header and data both stored in .mha file. If false, header stored in filename.mhd and data stored in filename.raw.
      • fileHeader

        private java.io.File fileHeader
    • Constructor Detail

      • FileMetaImage

        public FileMetaImage​(java.lang.String fName,
                             java.lang.String fDir)
        Constructs new file object.
        Parameters:
        fName - File name.
        fDir - File directory.
    • Method Detail

      • readImage

        public ModelImage readImage​(boolean one)
                             throws java.io.IOException
        reads the MetaImatge file header and data.
        Parameters:
        one - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
        Throws:
        java.io.IOException - if there is an error reading the file
      • updateorigins

        private void updateorigins​(FileInfoBase[] fileInfo)
        Updates the start locations. Each image has a fileinfo where the start locations are stored. Note that the start location for the Z (3rd) dimension change with the change is the slice. The origin is in the upper left corner and we are using the right hand rule. + x -> left to right; + y -> top to bottom and + z -> into screen.
        Parameters:
        fileInfo - DOCUMENT ME!
      • readLine

        private void readLine()
                       throws java.io.IOException
        readLine() - reads a line of the file header separate into category, subcategory, and values.
        Throws:
        java.io.IOException - if there is an error reading the file
      • writeImage

        public void writeImage​(ModelImage image,
                               FileWriteOptions options)
                        throws java.io.IOException
        Writes an MetaImage format type image.
        Parameters:
        image - Image model of data to write.
        Throws:
        java.io.IOException - if there is an error writing the file
        See Also:
        FileInfoMeta, FileRaw
      • writeHeader

        public boolean writeHeader​(ModelImage image,
                                   int nImagesSaved,
                                   int nTimeSaved,
                                   java.lang.String fileName,
                                   java.lang.String fileDir,
                                   boolean oneFile,
                                   int headerIndex,
                                   long[] finalHeaderPosition)
                            throws java.io.IOException
        Writes a MetaImage header to a separate file.
        Parameters:
        image - Image model of data to write.
        fileName - File name.
        fileDir - File directory.
        Returns:
        Flag to confirm a successful read.
        Throws:
        java.io.IOException - if there is an error
        See Also:
        FileInfoMetaImage
      • writeHeader3DTo2D

        private void writeHeader3DTo2D​(ModelImage image,
                                       java.lang.String fileName,
                                       java.lang.String fileDir,
                                       FileWriteOptions options,
                                       boolean oneFile,
                                       long[] finalHeaderPosition)
                                throws java.io.IOException
        This method is used when saving a 3D image in an array of 2D files. The file name has numbers appended to correctly order the images.
        Parameters:
        image - the image dataset to be saved
        fileName - the file name
        fileDir - the file directory
        options - file options indicate how to save the image
        Throws:
        java.io.IOException - DOCUMENT ME!
      • writeHeader4DTo3D

        private void writeHeader4DTo3D​(ModelImage image,
                                       java.lang.String fileName,
                                       java.lang.String fileDir,
                                       FileWriteOptions options,
                                       boolean oneFile,
                                       long[] finalHeaderPosition)
                                throws java.io.IOException
        This method is used when saving a 4D image in an array of 3D files. The file name has numbers appended to correctly order the images.
        Parameters:
        image - the image dataset to be saved
        fileName - the file name
        fileDir - the file directory
        options - file options indicate how to save the image
        Throws:
        java.io.IOException - DOCUMENT ME!