Package gov.nih.mipav.model.file
Class FileMetaImage
java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileMetaImage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Stringprivate Stringprivate booleanprivate intprivate longprivate Fileprivate booleanprivate Stringprivate int[]private StringDOCUMENT ME!private FileDOCUMENT ME!private StringDOCUMENT ME!private Fileprivate FileInfoMetaImageDOCUMENT ME!private StringDOCUMENT ME!private longprivate ModelImageDOCUMENT ME!private TransMatrixprivate intprivate intprivate booleanIf true, header and data both stored in .mha file.private float[]DOCUMENT ME!private float[]private booleanprivate String[]private InflaterFields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreadImage(boolean one) reads the MetaImatge file header and data.private voidreadLine()readLine() - reads a line of the file header separate into category, subcategory, and values.private voidupdateorigins(FileInfoBase[] fileInfo) Updates the start locations.booleanwriteHeader(ModelImage image, int nImagesSaved, int nTimeSaved, String fileName, String fileDir, boolean oneFile, int headerIndex, long[] finalHeaderPosition) Writes a MetaImage header to a separate file.private voidwriteHeader3DTo2D(ModelImage image, String fileName, String fileDir, FileWriteOptions options, boolean oneFile, long[] finalHeaderPosition) This method is used when saving a 3D image in an array of 2D files.private voidwriteHeader4DTo3D(ModelImage image, String fileName, String fileDir, FileWriteOptions options, boolean oneFile, long[] finalHeaderPosition) This method is used when saving a 4D image in an array of 3D files.voidwriteImage(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 Details
-
fileDir
DOCUMENT ME! -
fileInfo
DOCUMENT ME! -
fileName
DOCUMENT ME! -
headerSize
private long headerSize -
currentLocation
private long currentLocation -
file
DOCUMENT ME! -
image
DOCUMENT ME! -
origin
private float[] originDOCUMENT ME! -
resolutions
private float[] resolutions -
numValues
private int numValues -
fieldSeparator
DOCUMENT ME! -
category
-
baseName
-
values
-
nDims
private int nDims -
defaultFileDataName
-
defaultFileData
-
defaultFileDataExists
private boolean defaultFileDataExists -
asciiFormat
private boolean asciiFormat -
compressedData
private boolean compressedData -
extents
private int[] extents -
matrix
-
compressedDataSize
private int compressedDataSize -
sepFound
private boolean sepFound -
zlibDecompresser
-
oneFile
private boolean oneFileIf true, header and data both stored in .mha file. If false, header stored in filename.mhd and data stored in filename.raw. -
fileHeader
-
-
Constructor Details
-
FileMetaImage
Constructs new file object.- Parameters:
fName- File name.fDir- File directory.
-
-
Method Details
-
readImage
reads the MetaImatge file header and data.- Parameters:
one- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
IOException- if there is an error reading the file
-
updateorigins
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
readLine() - reads a line of the file header separate into category, subcategory, and values.- Throws:
IOException- if there is an error reading the file
-
writeImage
Writes an MetaImage format type image.- Parameters:
image- Image model of data to write.- Throws:
IOException- if there is an error writing the file- See Also:
-
writeHeader
public boolean writeHeader(ModelImage image, int nImagesSaved, int nTimeSaved, String fileName, String fileDir, boolean oneFile, int headerIndex, long[] finalHeaderPosition) throws 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:
IOException- if there is an error- See Also:
-
writeHeader3DTo2D
private void writeHeader3DTo2D(ModelImage image, String fileName, String fileDir, FileWriteOptions options, boolean oneFile, long[] finalHeaderPosition) throws 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:
IOException- DOCUMENT ME!
-
writeHeader4DTo3D
private void writeHeader4DTo3D(ModelImage image, String fileName, String fileDir, FileWriteOptions options, boolean oneFile, long[] finalHeaderPosition) throws 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:
IOException- DOCUMENT ME!
-