Package gov.nih.mipav.model.file
Class FileSpar
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileSpar
-
public class FileSpar extends FileBase
Reads a spar/sdat file. MIPAV only uses the spar information since the sdat is spectroscopy data.- Author:
- senseneyj
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringfileDirFile directory of the image.private FileInfoSPARfileInfoReference fileinfoprivate java.lang.StringfileNameFile name of the image.static java.lang.String[]hdrEXTENSIONSThe extensions of ANALYZE file.private ModelImageimageThe image read in from the file.private ModelImageimageAprivate FileInfoBaseimageAInfoimageA file infostatic java.lang.String[]imgEXTENSIONSprivate FileInfoSPARoutInfofile info-
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 FileSpar(ModelImage imageA, FileInfoBase imageAInfo, java.lang.String fileName, java.lang.String fileDir)FileSpar(java.lang.String fileName, java.lang.String fileDir)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String[]getCompleteFileNameList(java.lang.String absolutePath)Returns the complete list of file names according to given file name.FileInfoSPARgetFileInfo()static java.lang.StringgetHeaderFile(java.lang.String[] fileNames)======= Returns the header file.static booleanisHeaderFile(java.lang.String absolutePath)Return true if the file specified by absolutePath is header file of ANALYZE.static booleanisImageFile(java.lang.String absolutePath)Return true if the file specified by absolutePath is image file of ANALYZE.private static doubleparseDouble(java.lang.String nextLine)private static intparseInt(java.lang.String nextLine)booleanreadHeader(java.lang.String imageFileName, java.lang.String fileDir)Reads the spar header and stores the information in fileInfo.ModelImagereadImage(boolean one)Constructs a SPAR image mask based on the parameters defined in FileInfoSPARprivate intsetLowerExtents(int index)private intsetUpperExtents(int index)private ModelImageupdateTransformMatrix(ModelImage image)-
Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, finalize, 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
-
hdrEXTENSIONS
public static final java.lang.String[] hdrEXTENSIONS
The extensions of ANALYZE file.
-
imgEXTENSIONS
public static final java.lang.String[] imgEXTENSIONS
-
fileDir
private java.lang.String fileDir
File directory of the image.
-
fileName
private java.lang.String fileName
File name of the image.
-
image
private ModelImage image
The image read in from the file.
-
outInfo
private FileInfoSPAR outInfo
file info
-
imageAInfo
private FileInfoBase imageAInfo
imageA file info
-
imageA
private ModelImage imageA
-
fileInfo
private FileInfoSPAR fileInfo
Reference fileinfo
-
-
Constructor Detail
-
FileSpar
public FileSpar(java.lang.String fileName, java.lang.String fileDir)
-
FileSpar
public FileSpar(ModelImage imageA, FileInfoBase imageAInfo, java.lang.String fileName, java.lang.String fileDir)
-
-
Method Detail
-
parseDouble
private static double parseDouble(java.lang.String nextLine)
-
parseInt
private static int parseInt(java.lang.String nextLine)
-
readHeader
public boolean readHeader(java.lang.String imageFileName, java.lang.String fileDir) throws java.io.IOExceptionReads the spar header and stores the information in fileInfo.- Parameters:
imageFileName- File name of image (is also the spar file).fileDir- Directory.- Returns:
- Flag to confirm a successful read.
- Throws:
java.io.IOException- if there is an error reading the header- See Also:
FileInfoAnalyze
-
setLowerExtents
private int setLowerExtents(int index)
-
setUpperExtents
private int setUpperExtents(int index)
-
readImage
public ModelImage readImage(boolean one) throws java.io.IOException, java.lang.OutOfMemoryError
Constructs a SPAR image mask based on the parameters defined in FileInfoSPAR- Parameters:
one- flag indicating one image of a 3D dataset should be read in.- Returns:
- The image.
- Throws:
java.io.IOException- if there is an error reading the filejava.lang.OutOfMemoryError- See Also:
FileRaw
-
getFileInfo
public FileInfoSPAR getFileInfo()
-
updateTransformMatrix
private ModelImage updateTransformMatrix(ModelImage image)
-
getCompleteFileNameList
public static java.lang.String[] getCompleteFileNameList(java.lang.String absolutePath)
Returns the complete list of file names according to given file name.- Parameters:
absolutePath- one file name of PARREC.- Returns:
- the complete list of file names.
-
getHeaderFile
public static java.lang.String getHeaderFile(java.lang.String[] fileNames)
======= Returns the header file.- Parameters:
fileNames- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
isHeaderFile
public static boolean isHeaderFile(java.lang.String absolutePath)
Return true if the file specified by absolutePath is header file of ANALYZE.- Parameters:
absolutePath- the file name including path information.- Returns:
- true if the specified file is header file.
-
isImageFile
public static boolean isImageFile(java.lang.String absolutePath)
Return true if the file specified by absolutePath is image file of ANALYZE.- Parameters:
absolutePath- the file name including path information.- Returns:
- true if the specified file is image file.
-
-