Class FileUtility


  • public class FileUtility
    extends java.lang.Object
    Constants and static methods which relate to file input, output or processing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int AFNI
      AFNI file type. extension: .head, .brik
      static int ANALYZE
      Analyze format (Mayo). extension: .img, .hdr
      static int ANALYZE_MULTIFILE
      Multiple files of type analyze.
      static int AVI
      AVI file type.
      static int BFLOAT
      Extension: .hdr for header, .bfloat for data
      static int BIORAD
      Used by the Bio-Rad Pic format. extension: .pic && fileID(54L)==12345
      static int BMP
      extension: .bmp.
      static int BMP_MULTIFILE
      Bmp multifile
      static int BRUKER
      Bruker file format.
      static int CHESHIRE
      Cheshire file type (a kind of Analyze). extension: .imc Can also have .img extension
      static int CHESHIRE_OVERLAY
      Cheshire overlay file type.
      static int COR
      Used by FreeSurfer software. extension: -.info or -.info~ for header file -.nnn for slice data file where nnn is the slice number
      static int CUR
      extension: .cur.
      static int CZI
      Zeiss ZISRAW (CZI) file format extension .czi
      static int DIB
      extension: .dib.
      static int DICOM
      Digital Imaging and COmmunications in Medicine file type.
      static int DM3
      Gatan's Digital Micrograph version 3 file format. extension: .dm3
      static int ERROR
      Ill defined file type.
      private static java.lang.String[] fileTypeStr  
      static int FITS
      FITS file type. extension: .fits
      static int GE_GENESIS
      GE Genesis 5X and LX. extension: .sig
      static int GE_GENESIS_MULTIFILE
      Multiple files of type GE_GENESIS
      static int GE_SIGNA4X
      GE Signa 4.x.
      static int GE_SIGNA4X_MULTIFILE
      Multiple files of type GE_SIGNA4X
      static int GIF
      extension: .gif.
      static int ICO
      extension: .ico.
      static int ICS
      Image Cytometry Standard. extension: .ics, .ids
      static int INTERFILE
      Interfile file format used in Nuclear Medicine. extension: .hdr
      static int INTERFILE_MULTIFILE
      Multiple files of type INTERFILE
      static int JIMI
      Java Image Manangement Interface file type.
      static int JP2  
      static int JPEG
      extension: .jpeg, .jpg.
      static int JSON
      extension .json
      static int LIFF
      Do not confuse with Leica image file format .lif
      static int LSM
      Used by the Zeiss LSM 510 Dataserver. extension: .lsm
      static int LSM_MULTIFILE
      Used by the Zeiss LSM 510 Dataserver.
      static int MAGNETOM_VISION
      Siemens MAGNETOM VISION. extension: .ima
      static int MAGNETOM_VISION_MULTIFILE
      Multiple files of type MAGNETOM_VISION
      static int MAP
      Benes Trus special file type. extension: .map
      static int MATLAB
      extension .mat
      static int MEDIVISION
      extension: .bin.
      static int METAIMAGE
      Metaimage files are either separate .mhd header and .raw image data files or combined .mha header and image data file
      static int MGH
      MGH/MGZ volume format.
      static int MICRO_CAT
      Micro CT format for small animal imaging. extension: .log, .ct
      static int MINC
      MINC file type.
      static int MINC_HDF
      MINC 2.0 (HDF5)
      static int MINC_MULTIFILE
      Multiple files of type MINC.
      static int MIPAV
      Not presently implemented.
      static int MRC
      extension: .mrc.
      static int NIFTI
      NIFTI format. extension: .img, .hdr, .nii
      static int NIFTI_MULTIFILE
      NIFTI multi-file format.
      static int NRRD
      Nearly raw raster data.
      static int NRRD_MULTIFILE
      Nearly raw raster data.
      static int OSM
      Washington University OSM dataset structure. extension: .wu
      static int PARREC
      extension: "par","parv2","rec","frec".
      static int PARREC_MULTIFILE
      extension: "par","parv2","rec","frec".
      static int PCX
      extension: .pcx.
      static int PGM
      Portable Gray Map extension .pgm
      static int PIC
      extension: .pic.
      static int PICT
      extension: .pict.
      static int PNG
      extension: .png.
      static int PPM
      Portable Pixmap Utilities .ppm
      static int PSD
      extension: .psd.
      static int QT
      Quicktime file type. extension: .mov, .qt
      static int RAW
      RAW image data, no header. extension: .raw
      static int RAW_MULTIFILE
      RAW MULTIFLE image data, no header.
      static int SIEMENSTEXT
      Extension: .hdr for header, .img for data
      static int SPAR
      SPAR file format for use with PARREC images
      static int SPM
      SPM file format.
      static int STK
      MetaMorph Stack (STK) file type. extension: .stk
      static int SURFACE_XML
      MIPAV Surface XML file format. extension: .xml
      static int SURFACEREF_XML
      MIPAV Surface XML file format. extension: .xml
      static int SVS
      Aperio TIFF based .svs
      static int TGA
      extension: .tga.
      static int TIFF
      TIFF file; tagged header. extension: .tif, .tiff
      static int TIFF_MULTIFILE
      Multiple files of TIFF images.
      static int TMG
      Optical coherence tomography. extension: .tmg
      static int TRACKVIS
      Extension: .trk, TrackVis track data
      static int UNDEFINED
      Undefined file type.
      static int VISTA
      Vista file extension .v
      static int VOI_FILE
      VOI file, used to read VOIs. extension: .voi
      static int XBM
      extension: .xbm.
      static int XML
      MIPAV XML file format. mipav xml image format. extension: .xml
      static int XML_MULTIFILE
      MIPAV XML file format.
      static int XPM
      extension: .xpm.
      static int ZVI
      Zeiss ZVI has extension .zvi
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtility()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String[] getCORFileList​(java.lang.String fileDir, java.lang.String fileName, boolean quiet)
      Only for FreeSurfer COR volume files Looks in the image directory and returns all images with the same root up to the hyphen, sorted in lexicographical order.
      static java.lang.String getCORSuffixFrom​(java.lang.String fn)
      Only used for COR volume files with hyphen in name Breaks the filename into basename and suffix, then returns the suffix.
      static java.lang.String getExtension​(java.lang.String absolutePath)
      Returns the extension of the file name (including the dot), if file name does not have extension, then return empty string.
      static java.lang.String getFileDirectory​(java.lang.String fileName)
      Returns the path information from the file name with the path information.
      static int getFileIndex​(java.lang.String fName)
      Trims off the file extension and file name, but leaves the file index.
      static java.lang.String[] getFileList​(java.lang.String fileDir, java.lang.String fileName, boolean quiet)
      Looks in the image directory and returns all images with the same suffix as fileName, sorted in lexicographical order.
      static java.lang.String getFileName​(java.lang.String absolutePath)
      Returns the file name without path information from file name with the path information.
      static java.util.List<java.lang.String> getFileNameList​(FileInfoBase[] fileInfoList)
      Gets the file name list from which this ModelImage is opened.
      static java.util.List<java.lang.String> getFileNameList​(ModelImage image)
      Gets the file name list from which this ModelImage is opened.
      static int getFileType​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Sets the FileBase.
      static int getFileType​(java.lang.String fileName, java.lang.String fileDir, boolean doWrite, boolean quiet, boolean[] zerofunused)
      Sets the FileBase.
      static int getFileTypeFromStr​(java.lang.String s)
      Returns the file type associated with a string.
      static java.lang.String getFileTypeStr​(int m)
      Return the string associated with a file type.
      static int isAnalyzeOrSPM​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type Analyze.
      static int isDicom​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type Dicom.
      static int isDicom_ver2​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      tests if unknown file is of type 2.0 dicom
      static int isGESigna4X​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type GE Signa 4X type.
      static int isGESigna5X​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type GE Signa 5X type.
      static int isInterfile​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type Interfile.
      static int isMagnetomVision​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type Siemens Magnetom Vision.
      static int isMinc​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type Minc.
      static int isMincHDF​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Determines whether the file on disk is of type MINC 2.0
      static int isNIFTI​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type Nifti.
      static int isSPM​(java.lang.String fileName, java.lang.String fileDir, boolean quiet)
      Tests if the unknown file is of type SPM.
      static java.lang.String stripExtension​(java.lang.String fileName)
      Helper method to strip the image name of the extension, so when we save we don't have double extensions (like genormcor.img.tif).
      static java.lang.String trimCOR​(java.lang.String fName)
      Trims the numbers or file extension from COR file names.
      static java.lang.String trimNumbersAndSpecial​(java.lang.String fName)
      Trims the numbers and special character from the file name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • AFNI

        public static final int AFNI
        AFNI file type. extension: .head, .brik
        See Also:
        Constant Field Values
      • ANALYZE

        public static final int ANALYZE
        Analyze format (Mayo). extension: .img, .hdr
        See Also:
        Constant Field Values
      • ANALYZE_MULTIFILE

        public static final int ANALYZE_MULTIFILE
        Multiple files of type analyze.
        See Also:
        Constant Field Values
      • AVI

        public static final int AVI
        AVI file type. Windows Media. extension: .avi
        See Also:
        Constant Field Values
      • BIORAD

        public static final int BIORAD
        Used by the Bio-Rad Pic format. extension: .pic && fileID(54L)==12345
        See Also:
        Constant Field Values
      • BRUKER

        public static final int BRUKER
        Bruker file format. Reads a BRUKER file by first reading in the d3proc header file, second the reco header file, third the acqp file int the same directory or up one or two two parent directories, and finally the 2dseq binary file.
        See Also:
        Constant Field Values
      • CHESHIRE

        public static final int CHESHIRE
        Cheshire file type (a kind of Analyze). extension: .imc Can also have .img extension
        See Also:
        Constant Field Values
      • CHESHIRE_OVERLAY

        public static final int CHESHIRE_OVERLAY
        Cheshire overlay file type. Contains VOIs. extension: .oly
        See Also:
        Constant Field Values
      • COR

        public static final int COR
        Used by FreeSurfer software. extension: -.info or -.info~ for header file -.nnn for slice data file where nnn is the slice number
        See Also:
        Constant Field Values
      • DICOM

        public static final int DICOM
        Digital Imaging and COmmunications in Medicine file type. Fully implemented versions 2 & 3. extension: .dcm
        See Also:
        Constant Field Values
      • DM3

        public static final int DM3
        Gatan's Digital Micrograph version 3 file format. extension: .dm3
        See Also:
        Constant Field Values
      • GE_GENESIS

        public static final int GE_GENESIS
        GE Genesis 5X and LX. extension: .sig
        See Also:
        Constant Field Values
      • GE_GENESIS_MULTIFILE

        public static final int GE_GENESIS_MULTIFILE
        Multiple files of type GE_GENESIS
        See Also:
        Constant Field Values
      • GE_SIGNA4X_MULTIFILE

        public static final int GE_SIGNA4X_MULTIFILE
        Multiple files of type GE_SIGNA4X
        See Also:
        Constant Field Values
      • ICS

        public static final int ICS
        Image Cytometry Standard. extension: .ics, .ids
        See Also:
        Constant Field Values
      • INTERFILE

        public static final int INTERFILE
        Interfile file format used in Nuclear Medicine. extension: .hdr
        See Also:
        Constant Field Values
      • INTERFILE_MULTIFILE

        public static final int INTERFILE_MULTIFILE
        Multiple files of type INTERFILE
        See Also:
        Constant Field Values
      • JIMI

        public static final int JIMI
        Java Image Manangement Interface file type.
        See Also:
        Constant Field Values
      • LSM

        public static final int LSM
        Used by the Zeiss LSM 510 Dataserver. extension: .lsm
        See Also:
        Constant Field Values
      • LSM_MULTIFILE

        public static final int LSM_MULTIFILE
        Used by the Zeiss LSM 510 Dataserver.
        See Also:
        Constant Field Values
      • MAGNETOM_VISION

        public static final int MAGNETOM_VISION
        Siemens MAGNETOM VISION. extension: .ima
        See Also:
        Constant Field Values
      • MAGNETOM_VISION_MULTIFILE

        public static final int MAGNETOM_VISION_MULTIFILE
        Multiple files of type MAGNETOM_VISION
        See Also:
        Constant Field Values
      • MAP

        public static final int MAP
        Benes Trus special file type. extension: .map
        See Also:
        Constant Field Values
      • MICRO_CAT

        public static final int MICRO_CAT
        Micro CT format for small animal imaging. extension: .log, .ct
        See Also:
        Constant Field Values
      • MINC

        public static final int MINC
        MINC file type. MINC is a medical imaging oriented extension of the NetCDF file format. NetCDF stands for 'Network Common Data Form'. extension: .mnc
        See Also:
        Constant Field Values
      • MINC_MULTIFILE

        public static final int MINC_MULTIFILE
        Multiple files of type MINC.
        See Also:
        Constant Field Values
      • NIFTI

        public static final int NIFTI
        NIFTI format. extension: .img, .hdr, .nii
        See Also:
        Constant Field Values
      • NIFTI_MULTIFILE

        public static final int NIFTI_MULTIFILE
        NIFTI multi-file format.
        See Also:
        Constant Field Values
      • NRRD_MULTIFILE

        public static final int NRRD_MULTIFILE
        Nearly raw raster data.
        See Also:
        Constant Field Values
      • OSM

        public static final int OSM
        Washington University OSM dataset structure. extension: .wu
        See Also:
        Constant Field Values
      • QT

        public static final int QT
        Quicktime file type. extension: .mov, .qt
        See Also:
        Constant Field Values
      • RAW

        public static final int RAW
        RAW image data, no header. extension: .raw
        See Also:
        Constant Field Values
      • RAW_MULTIFILE

        public static final int RAW_MULTIFILE
        RAW MULTIFLE image data, no header.
        See Also:
        Constant Field Values
      • SPM

        public static final int SPM
        SPM file format. SPM99 and SPM2 are slight variants of analyze with the same .img, .hdr file extensions. The user could also change the extension .img to .spm to indicate SPM. The header extension would remain .hdr
        See Also:
        Constant Field Values
      • STK

        public static final int STK
        MetaMorph Stack (STK) file type. extension: .stk
        See Also:
        Constant Field Values
      • SURFACE_XML

        public static final int SURFACE_XML
        MIPAV Surface XML file format. extension: .xml
        See Also:
        Constant Field Values
      • TIFF

        public static final int TIFF
        TIFF file; tagged header. extension: .tif, .tiff
        See Also:
        Constant Field Values
      • TIFF_MULTIFILE

        public static final int TIFF_MULTIFILE
        Multiple files of TIFF images.
        See Also:
        Constant Field Values
      • TMG

        public static final int TMG
        Optical coherence tomography. extension: .tmg
        See Also:
        Constant Field Values
      • VOI_FILE

        public static final int VOI_FILE
        VOI file, used to read VOIs. extension: .voi
        See Also:
        Constant Field Values
      • XML

        public static final int XML
        MIPAV XML file format. mipav xml image format. extension: .xml
        See Also:
        Constant Field Values
      • XML_MULTIFILE

        public static final int XML_MULTIFILE
        MIPAV XML file format.
        See Also:
        Constant Field Values
      • PARREC

        public static final int PARREC
        extension: "par","parv2","rec","frec".
        See Also:
        Constant Field Values
      • PARREC_MULTIFILE

        public static final int PARREC_MULTIFILE
        extension: "par","parv2","rec","frec".
        See Also:
        Constant Field Values
      • SPAR

        public static final int SPAR
        SPAR file format for use with PARREC images
        See Also:
        Constant Field Values
      • SURFACEREF_XML

        public static final int SURFACEREF_XML
        MIPAV Surface XML file format. extension: .xml
        See Also:
        Constant Field Values
      • LIFF

        public static final int LIFF
        Do not confuse with Leica image file format .lif
        See Also:
        Constant Field Values
      • BFLOAT

        public static final int BFLOAT
        Extension: .hdr for header, .bfloat for data
        See Also:
        Constant Field Values
      • SIEMENSTEXT

        public static final int SIEMENSTEXT
        Extension: .hdr for header, .img for data
        See Also:
        Constant Field Values
      • METAIMAGE

        public static final int METAIMAGE
        Metaimage files are either separate .mhd header and .raw image data files or combined .mha header and image data file
        See Also:
        Constant Field Values
      • TRACKVIS

        public static final int TRACKVIS
        Extension: .trk, TrackVis track data
        See Also:
        Constant Field Values
      • CZI

        public static final int CZI
        Zeiss ZISRAW (CZI) file format extension .czi
        See Also:
        Constant Field Values
      • fileTypeStr

        private static final java.lang.String[] fileTypeStr
    • Constructor Detail

      • FileUtility

        public FileUtility()
    • Method Detail

      • getFileTypeFromStr

        public static int getFileTypeFromStr​(java.lang.String s)
        Returns the file type associated with a string.
        Parameters:
        s - String to test
        Returns:
        axis orientation
      • getFileTypeStr

        public static java.lang.String getFileTypeStr​(int m)
        Return the string associated with a file type.
        Parameters:
        m - int representing the file type (see the above static definitions)
        Returns:
        String representing the string associated with the file type.
      • getCORFileList

        public static final java.lang.String[] getCORFileList​(java.lang.String fileDir,
                                                              java.lang.String fileName,
                                                              boolean quiet)
                                                       throws java.lang.OutOfMemoryError
        Only for FreeSurfer COR volume files Looks in the image directory and returns all images with the same root up to the hyphen, sorted in lexicographical order. Will set the number of images (nImages) for the calling program.
        Parameters:
        fileDir - Directory to look for images.
        fileName - File name of the image.
        quiet - Whether to avoid displaying errors using the GUI.
        Returns:
        An array of the image names to be read in or saved as.
        Throws:
        java.lang.OutOfMemoryError - If there is a problem allocating required memory.
      • getCORSuffixFrom

        public static final java.lang.String getCORSuffixFrom​(java.lang.String fn)
        Only used for COR volume files with hyphen in name Breaks the filename into basename and suffix, then returns the suffix.
        Parameters:
        fn - The filename.
        Returns:
        The suffix or file-extension. For example, -info. Note that suffix includes the separator '-'
      • getExtension

        public static final java.lang.String getExtension​(java.lang.String absolutePath)
        Returns the extension of the file name (including the dot), if file name does not have extension, then return empty string.
        Parameters:
        absolutePath - the file name.
        Returns:
        The file's extension.
      • getFileDirectory

        public static final java.lang.String getFileDirectory​(java.lang.String fileName)
        Returns the path information from the file name with the path information.
        Parameters:
        fileName - the file name wiht the path information.
        Returns:
        The path information.
      • getFileIndex

        public static final int getFileIndex​(java.lang.String fName)
        Trims off the file extension and file name, but leaves the file index. An index might be 0001, or 140, for example.
        Parameters:
        fName - String file name to get index
        Returns:
        String (index string)
      • getFileList

        public static final java.lang.String[] getFileList​(java.lang.String fileDir,
                                                           java.lang.String fileName,
                                                           boolean quiet)
                                                    throws java.lang.OutOfMemoryError
        Looks in the image directory and returns all images with the same suffix as fileName, sorted in lexicographical order.
        Parameters:
        fileDir - Directory to look for images.
        fileName - File name of the image.
        quiet - Whether to avoid displaying errors using the GUI.
        Returns:
        An array of the image names to be read in or saved as.
        Throws:
        java.lang.OutOfMemoryError - If there is a problem allocating required memory.
      • getFileName

        public static final java.lang.String getFileName​(java.lang.String absolutePath)
        Returns the file name without path information from file name with the path information.
        Parameters:
        absolutePath - the file name with the path information.
        Returns:
        The file name without path information.
      • getFileType

        public static final int getFileType​(java.lang.String fileName,
                                            java.lang.String fileDir,
                                            boolean quiet)
        Sets the FileBase.(filetype) based on the file extension of the given filename. Also sets file "suffix", if required.
        Parameters:
        fileName - Filename of the image to read in. Must include the file extension.
        fileDir - Directory where fileName exists.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        Filetype from FileBase.
        See Also:
        FileBase
      • getFileType

        public static final int getFileType​(java.lang.String fileName,
                                            java.lang.String fileDir,
                                            boolean doWrite,
                                            boolean quiet,
                                            boolean[] zerofunused)
        Sets the FileBase.(filetype) based on the file extension of the given filename. Also sets file "suffix", if required.
        Parameters:
        fileName - Filename of the image to read in. Must include the file extension.
        fileDir - Directory where fileName exists.
        doWrite - If true about to write a file
        quiet - Whether to avoid any user interaction (ie, from error popups).
        zerofunused - If true, zero funused fields in an analyze write
        Returns:
        Filetype from FileBase.
        See Also:
        FileBase
      • isAnalyzeOrSPM

        public static final int isAnalyzeOrSPM​(java.lang.String fileName,
                                               java.lang.String fileDir,
                                               boolean quiet)
                                        throws java.io.IOException
        Tests if the unknown file is of type Analyze.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.ANALYZE if the file is a ANALYZE type, FileUtility.SPM if the file is a SPM type, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isDicom

        public static final int isDicom​(java.lang.String fileName,
                                        java.lang.String fileDir,
                                        boolean quiet)
                                 throws java.io.IOException
        Tests if the unknown file is of type Dicom.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.DICOM if the file is a DICOM file, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isDicom_ver2

        public static final int isDicom_ver2​(java.lang.String fileName,
                                             java.lang.String fileDir,
                                             boolean quiet)
                                      throws java.io.IOException
        tests if unknown file is of type 2.0 dicom
        Parameters:
        fileName -
        fileDir -
        quiet -
        Returns:
        Throws:
        java.io.IOException
      • isGESigna4X

        public static final int isGESigna4X​(java.lang.String fileName,
                                            java.lang.String fileDir,
                                            boolean quiet)
                                     throws java.io.IOException
        Tests if the unknown file is of type GE Signa 4X type.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.GE_SIGNA4X if the file is a GE MR Signa 4.x file, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isGESigna5X

        public static final int isGESigna5X​(java.lang.String fileName,
                                            java.lang.String fileDir,
                                            boolean quiet)
                                     throws java.io.IOException
        Tests if the unknown file is of type GE Signa 5X type.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.GE_GENESIS if the file is a GE MR Signa 5.x file, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isInterfile

        public static final int isInterfile​(java.lang.String fileName,
                                            java.lang.String fileDir,
                                            boolean quiet)
                                     throws java.io.IOException
        Tests if the unknown file is of type Interfile.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.Interfile if the file is a Interfile type, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isMagnetomVision

        public static final int isMagnetomVision​(java.lang.String fileName,
                                                 java.lang.String fileDir,
                                                 boolean quiet)
                                          throws java.io.IOException
        Tests if the unknown file is of type Siemens Magnetom Vision.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.MAGNETOM_VISION if the file is a Siemens Magnetom Vision type, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isMinc

        public static final int isMinc​(java.lang.String fileName,
                                       java.lang.String fileDir,
                                       boolean quiet)
                                throws java.io.IOException
        Tests if the unknown file is of type Minc.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.MINC if the file is a MINC type, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isMincHDF

        public static final int isMincHDF​(java.lang.String fileName,
                                          java.lang.String fileDir,
                                          boolean quiet)
        Determines whether the file on disk is of type MINC 2.0
        Parameters:
        fileName - name of the file
        fileDir - directory
        quiet -
        Returns:
        whether the file is HDF5 type
      • isNIFTI

        public static final int isNIFTI​(java.lang.String fileName,
                                        java.lang.String fileDir,
                                        boolean quiet)
                                 throws java.io.IOException
        Tests if the unknown file is of type Nifti.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.NIFTI if the file is a NIFTI type, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • isSPM

        public static final int isSPM​(java.lang.String fileName,
                                      java.lang.String fileDir,
                                      boolean quiet)
                               throws java.io.IOException
        Tests if the unknown file is of type SPM.
        Parameters:
        fileName - Name of the image file to read.
        fileDir - Directory of the image file to read.
        quiet - Whether to avoid any user interaction (ie, from error popups).
        Returns:
        FileUtility.SPM if the file is a SPM type, and FileUtility.UNDEFINED otherwise
        Throws:
        java.io.IOException - If there is a problem determining the type of the given file.
      • stripExtension

        public static final java.lang.String stripExtension​(java.lang.String fileName)
        Helper method to strip the image name of the extension, so when we save we don't have double extensions (like genormcor.img.tif).
        Parameters:
        fileName - Original name.
        Returns:
        Name without extension, or original name if there was no extension.
      • trimCOR

        public static final java.lang.String trimCOR​(java.lang.String fName)
        Trims the numbers or file extension from COR file names. Any numbers or .info or .info~ will be removed from after a hyphen in the given fname.
        Parameters:
        fName - File name where the last characters are alpha-numerics indicating the image number or .info or .info~
        Returns:
        File name without numbers on the end.
      • trimNumbersAndSpecial

        public static final java.lang.String trimNumbersAndSpecial​(java.lang.String fName)
        Trims the numbers and special character from the file name. Numerics and some special characters [ - _ . are removed from the end of the file.
        Parameters:
        fName - File name where the last characters are alpha-numerics indicating the image number.
        Returns:
        File name without numbers on the end.
      • getFileNameList

        public static final java.util.List<java.lang.String> getFileNameList​(ModelImage image)
        Gets the file name list from which this ModelImage is opened.
        Parameters:
        image - the ModelImage object.
        Returns:
        the actual file name list.
      • getFileNameList

        public static final java.util.List<java.lang.String> getFileNameList​(FileInfoBase[] fileInfoList)
        Gets the file name list from which this ModelImage is opened.
        Parameters:
        image - the ModelImage object.
        Returns:
        the actual file name list.