Package gov.nih.mipav.model.file
Class FileMetaImage
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileMetaImage
-
public class FileMetaImage extends FileBase
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
asciiFormat
private java.lang.String
baseName
private java.lang.String
category
private boolean
compressedData
private int
compressedDataSize
private long
currentLocation
private java.io.File
defaultFileData
private boolean
defaultFileDataExists
private java.lang.String
defaultFileDataName
private int[]
extents
private java.lang.String
fieldSeparator
DOCUMENT ME!private java.io.File
file
DOCUMENT ME!private java.lang.String
fileDir
DOCUMENT ME!private java.io.File
fileHeader
private FileInfoMetaImage
fileInfo
DOCUMENT ME!private java.lang.String
fileName
DOCUMENT ME!private long
headerSize
private ModelImage
image
DOCUMENT ME!private TransMatrix
matrix
private int
nDims
private int
numValues
private boolean
oneFile
If true, header and data both stored in .mha file.private float[]
origin
DOCUMENT ME!private float[]
resolutions
private boolean
sepFound
private java.lang.String[]
values
private java.util.zip.Inflater
zlibDecompresser
-
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 FileMetaImage(java.lang.String fName, java.lang.String fDir)
Constructs new file object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelImage
readImage(boolean one)
reads the MetaImatge file header and data.private void
readLine()
readLine() - reads a line of the file header separate into category, subcategory, and values.private void
updateorigins(FileInfoBase[] fileInfo)
Updates the start locations.boolean
writeHeader(ModelImage image, int nImagesSaved, int nTimeSaved, java.lang.String fileName, java.lang.String fileDir, boolean oneFile, int headerIndex, long[] finalHeaderPosition)
Writes a MetaImage header to a separate file.private void
writeHeader3DTo2D(ModelImage image, java.lang.String fileName, java.lang.String fileDir, FileWriteOptions options, boolean oneFile, long[] finalHeaderPosition)
This method is used when saving a 3D image in an array of 2D files.private void
writeHeader4DTo3D(ModelImage image, java.lang.String fileName, java.lang.String fileDir, FileWriteOptions options, boolean oneFile, long[] finalHeaderPosition)
This method is used when saving a 4D image in an array of 3D files.void
writeImage(ModelImage image, FileWriteOptions options)
Writes an MetaImage format type 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
-
fileDir
private java.lang.String fileDir
DOCUMENT ME!
-
fileInfo
private FileInfoMetaImage fileInfo
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!
-
image
private ModelImage image
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
-
matrix
private TransMatrix matrix
-
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
-
-
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 savedfileName
- the file namefileDir
- the file directoryoptions
- 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 savedfileName
- the file namefileDir
- the file directoryoptions
- file options indicate how to save the image- Throws:
java.io.IOException
- DOCUMENT ME!
-
-