Package gov.nih.mipav.model.file
Class FileFits
java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileFits
Some of this code is derived from FITS.java in ImageJ.
In A User's Guide for the Flexible Image Transport System (FITS) Version 4.0, Section 4.1 Indexes and Physical
Coordinates, the text says, "Historically, astronomers have generally assumed that the index point in a FITS file
represents the center of a pixel. This interpretation is endorsed by GC. It differs from the common practice in
computer graphics of treating the center of a pixel as a half-integral point." For CRPIXn in FITS: The center of the
first pixel is 1 and the center of the last pixel is NAXISn. In MIPAV the center of the first pixel is 0.5 and the
center of the last pixel is NAXISn - 0.5. So subtract 0.5 to go from FITS to MIPAV. " ...recommend that FITS writers
order pixels starting in the lower left hand corner of the image, with the first axis increasing to the right, as in
the rectangular coordinate x-axis, and the second increasing upward (the y-axis)." MIPAV uses the upper left hand
corner as the origin and has the y axis going downward. Therefore, the image is flipped after reading and flipped
before writing.
ImageJ disclaimer:
ImageJ is being developed at the National Institutes of Health by an employee of the Federal Government in the course of his official duties. Pursuant to Title 17, Section 105 of the United States Code, this software is not subject to copyright protection and is in the public domain. ImageJ is an experimental system. NIH assumes no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intDOCUMENT ME!private booleanDOCUMENT ME!private FileDOCUMENT ME!private StringDOCUMENT ME!private FileInfoFitsDOCUMENT ME!private FileInfoFitsprivate StringDOCUMENT ME!private AlgorithmFlipprivate booleanDOCUMENT ME!private ModelImageDOCUMENT ME!(package private) int[]DOCUMENT ME!private booleanprivate ModelLUTDOCUMENT ME!(package private) intDOCUMENT ME!private intDOCUMENT ME!(package private) intDOCUMENT ME!Fields 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 TypeMethodDescriptionvoidfinalize()Prepares this class for cleanup.returns LUT if defined.private voidreadBuffer(int slice, float[] buffer, float scaleFact, float scaleOffset) Reads a slice of data at a time and stores the results in the buffer.private voidreadDBuffer(int slice, double[] buffer, double scaleFact, double scaleOffset) Reads a slice of data at a time and stores the results in the buffer.readImage(boolean one) reads the FITS file header and data.voidwriteImage(ModelImage image, FileWriteOptions options) Writes a FITS format type image.Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, 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
-
imgExtents
int[] imgExtentsDOCUMENT ME! -
nDimensions
int nDimensionsDOCUMENT ME! -
sourceType
int sourceTypeDOCUMENT ME! -
BLANK
private int BLANKDOCUMENT ME! -
endianess
private boolean endianessDOCUMENT ME! -
file
DOCUMENT ME! -
fileDir
DOCUMENT ME! -
fileInfo
DOCUMENT ME! -
fileInfoCopy
-
fileName
DOCUMENT ME! -
haveBlank
private boolean haveBlankDOCUMENT ME! -
image
DOCUMENT ME! -
LUT
DOCUMENT ME! -
numberSlices
private int numberSlicesDOCUMENT ME! -
isColorPlanar2D
private boolean isColorPlanar2D -
flipAlgo
-
-
Constructor Details
-
FileFits
FITS reader/writer constructor.- Parameters:
fileName- file namefileDir- file directory- Throws:
IOException- if there is an error making the file
-
-
Method Details
-
finalize
public void finalize()Prepares this class for cleanup. Calls thefinalizemethod for existing elements, closes any open files and sets other elements tonull. -
getModelLUT
returns LUT if defined.- Returns:
- the LUT if defined else it is null
-
readImage
reads the FITS file header and data.- Parameters:
one- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
IOException- if there is an error reading the file
-
writeImage
Writes a FITS format type image.- Parameters:
image- Image model of data to write.options- options such as starting and ending slices and times- Throws:
IOException- if there is an error writing the file
-
readBuffer
private void readBuffer(int slice, float[] buffer, float scaleFact, float scaleOffset) throws IOException Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice- offset into the file stored in the dataOffset arraybuffer- buffer where the info is storedscaleFact- if 1 data is unscaledscaleOffset- if 0 don't add offset- Throws:
IOException- if there is an error reading the file
-
readDBuffer
private void readDBuffer(int slice, double[] buffer, double scaleFact, double scaleOffset) throws IOException Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice- offset into the file stored in the dataOffset arraybuffer- buffer where the info is storedscaleFact- if 1 data is unscaledscaleOffset- if 0 don't add offset- Throws:
IOException- if there is an error reading the file
-