|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xinapse.multisliceimage.MultiSliceImage
com.xinapse.multisliceimage.Analyze.ANZImage
public abstract class ANZImage
This is an abstract class that is the superclass of a multi-dimensional image in the Analyze 7.5 format or the new NIFTI-1 format.
Image data for images loaded from disk remains on disk, and is accessed as required; image data loaded from streams or created afresh resides in memory. Image data loaded from compressed (gzipped) disk-files also resides in memory.
Both big-endian and little-endian byte ordering are implemented and supported. When reading existing images, the byte order is auto detected from the header file. When existing images are copied or modified, the original byte order is retained. For images newly-created from scratch by this package, the byte ordering is the native byte order.
N.B. The Analyze format requires that for BINARY images, individual slices must begin on a byte boundary. In this implementation, that restriction is removed. If you wish to maintain compatibility with Analyze and other programs that maintain this restriction, please ensure that a multi-slice/multi-frame images have slices with a number of pixels that is a multiple of 8 (bits).
| Field Summary | |
|---|---|
static java.lang.String |
COMPRESSED_EXTENSION
The file extension for Analyze image files in lower case form. |
static java.lang.String |
COMPRESSED_UPPERCASE_EXTENSION
The file extension for Analyze image files in upper case form. |
static java.lang.String |
EXTENSION
The file extension for Analyze image files in lower case form. |
static java.lang.String |
UPPERCASE_EXTENSION
The file extension for Analyze image files in upper case form. |
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Creates an in-memory clone of an Analyze image. |
void |
close()
Closes an ANZImage and frees up resources. |
protected void |
finalize()
Called by the garbage collector on this ANZImage when garbage collection determines that there are no more references to the image. |
java.nio.ByteOrder |
getByteOrder()
Returns the byte order for this image. |
ANZPixFormat |
getDataType()
Returns the data type (ANZPixFormat) of this image. |
java.lang.String |
getDescription()
Returns a String description of this image. |
java.lang.String |
getDescription(int slice)
Returns a description of a slice of this image. |
int[] |
getDims()
Returns the dimensions of this image. |
int |
getFileDataOffset()
Returns the byte offset into the disk-based file format where pixel data begins. |
ANZHeader |
getHeader()
Returns the ANZHeader image header for this image. |
java.lang.String |
getHTMLDescription()
Returns a String description of this image in HTML format. |
java.lang.String |
getHTMLDescription(int slice)
Returns a String description of a slice of this image in HTML format. |
float[][] |
getImageOrientationPatient()
Returns the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient coordinates. |
float[][] |
getImageOrientationPatient(int slice)
Returns the direction cosines of the row, column and (possiblly) slice directions (for increasing row, column and slice) of the image, in patient coordinates. |
float[] |
getImagePositionPatient()
Returns the coordinates of the center of the first pixel of the image, in mm, in patient coordinates. |
float[] |
getImagePositionPatient(int slice)
Returns the coordinates of the center of the first pixel of the specified slice of this image, in mm, in patient coordinates. |
abstract MultiSliceImage |
getInstance(java.lang.String filename,
java.lang.Class cl,
int nSlices)
Writes this image to a disk-file given by the filename, with the MultiSliceImage class given by the class, possibly changing the number of slices in the image. |
float[] |
getIntensityRescale(int slice)
Returns the values m and b in the relationship between pixel intensity (I) values and the output units specified in getRescaleUnits() in the expression: Output units = m*I + b for a particular slice. |
java.lang.Double |
getMax()
Returns the maximum pixel intensity in the image. |
java.lang.Double |
getMin()
Returns the minimum pixel intensity in the image. |
ColourMapping |
getNativeColourMapping()
Returns a ColourMapping if this Analyze image has an associated colour mapping. |
int |
getNCols()
Returns the number of image columns in this image. |
int |
getNDim()
Returns the dimensionality of this image. |
int |
getNFrames()
Returns the number of frames in a multi-frame image. |
int |
getNRows()
Returns the number of image rows in this image. |
int |
getNSlices()
Returns the number of physical slice locations in this image. |
PixelDataType |
getPixelDataType()
Returns a PixelDataType representing the data type of this image. |
float |
getPixelXSize()
Returns the pixel size in the x (horizontal) direction for this image. |
float |
getPixelYSize()
Returns the pixel size in the y (vertical) direction for this image. |
float |
getPixelZSize()
Returns the separation between the centres of image planes for this image. |
java.lang.String |
getRescaleUnits()
Specifies the output units of Intensity Rescale Slope and Intensity Rescale Intercept, retrieved by getIntensityRescale(). |
float |
getTimeBetweenFrames()
Returns the time between frames in a 4- or higher dimensional image. |
java.lang.String |
getTitle()
Returns the title of this image. |
int |
getTotalNSlices()
Returns the total number of slices in this image. |
static boolean |
imageExists(java.lang.String filename)
Tests whether an ANZImage with the given name already exists on disk. |
boolean |
isCompressed()
Tests whether this ANZImage is compressed when on disk. |
boolean |
isOpen()
Tests whether this image is still open. |
void |
setDBName(java.lang.String name)
Sets the data base name for this ANZImage. |
void |
setDescription(java.lang.String descripstr)
Sets the description for this ANZImage. |
void |
setImageOrientationPatient(float[][] orientation)
Sets the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient (LPS) coordinates. |
void |
setImageOrientationPatient(float[][] orientation,
int slice)
This action is not supported by the Analyze/NIFTI-1 file format, so this method always throws a MultiSliceImageException. |
void |
setImageOrientationPositionPatient(javax.vecmath.Vector3f[] cosines,
javax.vecmath.Point3f position)
Sets both the direction cosines of the row, column and slice directions of the image, and the coordinates of the center of the first pixel of the image, in patient (LPS) coordinates. |
void |
setImagePositionPatient(float[] position)
Sets the coordinates of the center of the first pixel of the image, in mm, in patient (LPS) coordinates. |
void |
setImagePositionPatient(float[] position,
int slice)
This action is not supported by the Analyze/NIFTI-1 file format, so this method always throws a MultiSliceImageException. |
void |
setIntensityRescale(float[] rescale,
int slice)
This action is not supported by the Analyze/NIFTI-1 file format, so this method always throws a MultiSliceImageException. |
void |
setMinMax(int min,
int max)
Sets the glMin and glMax fields for this ANZImage. |
void |
setNativeColourMapping(ColourMapping colourMapping)
Sets the ColourMapping for this image. |
void |
setPixelSpacing(float[] spacing)
Sets the distance (in mm) between pixel centres in the row, column and slice directions of the image. |
void |
setPixelXSize(float width)
Sets the pixel size in the x (horizontal) direction for this image. |
void |
setPixelYSize(float height)
Sets the pixel size in the y (vertical) direction for this image. |
void |
setPixelZSize(float thickness)
Sets the pixel size in the z (slice) direction for this image. |
void |
setTimeBetweenFrames(float deltaT)
Sets the time between frames in a 4- or higher dimensional image. |
void |
setTitle(java.lang.String title)
Sets the title of this image. |
java.lang.String |
toString()
|
void |
write(java.lang.String filename)
Writes this ANZImage to disk. |
MultiSliceImage |
write(java.lang.String filename,
java.lang.Class cl)
Writes this image to a disk-file given by the filename, in one of the MultiSliceImage sub-class image formats. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.xinapse.loadableimage.LoadableImage |
|---|
appendAuditInfo, getFlipAngle, getIntensityRescale, getPatientDoB, getPatientID, getPatientName, getPatientPosition, getPulseSequence, getScanDate, getScanningSequence, getScanTE, getScanTE, getScanTI, getScanTR, getSequenceVariant, getSliceThickness |
| Field Detail |
|---|
public static final java.lang.String EXTENSION
public static final java.lang.String UPPERCASE_EXTENSION
public static final java.lang.String COMPRESSED_EXTENSION
public static final java.lang.String COMPRESSED_UPPERCASE_EXTENSION
| Method Detail |
|---|
public java.nio.ByteOrder getByteOrder()
MultiSliceImage
getByteOrder in class MultiSliceImagepublic static boolean imageExists(java.lang.String filename)
filename - the name of the image file to test for existence.
public void write(java.lang.String filename)
throws java.io.IOException,
MultiSliceImageException
write in class MultiSliceImagefilename - the root of the Analyze filename. Will be appended with
".img" and ".hdr" to create the appropriate full filenames.
MultiSliceImageException - if the image cannot be written.
java.io.IOException - if an I/O error occurs.
public MultiSliceImage write(java.lang.String filename,
java.lang.Class cl)
throws java.io.IOException,
MultiSliceImageException
MultiSliceImage
write in class MultiSliceImagefilename - the file name. If filename is null, then an in-memory MultiSliceImage
will be returned.cl - the class of image to be written (e.g. com.xinapse.multisliceimage.UNC.UNCImage).
java.io.IOException - if an I/O error occurs.
MultiSliceImageException - if the image cannot be written.
public abstract MultiSliceImage getInstance(java.lang.String filename,
java.lang.Class cl,
int nSlices)
throws java.io.IOException,
MultiSliceImageException
MultiSliceImage
getInstance in class MultiSliceImagefilename - the file name. If filename is null, then an in-memory MultiSliceImage
will be returned.cl - the class of image to be written (e.g.
com.xinapse.multisliceimage.UNC.UNCImage.class).nSlices - the number of slices in the image that is to be written.
java.io.IOException - if an I/O error occurs.
MultiSliceImageException - if the image cannot be written.
public void close()
throws java.io.IOException,
MultiSliceImageException
MultiSliceImageException - if the file cannot be written or closed.
java.io.IOException - if an I/O error occurs.
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - - the Exception raised by this method.public boolean isOpen()
LoadableImage
public boolean isCompressed()
public java.lang.String toString()
toString in class java.lang.Objectpublic ANZPixFormat getDataType()
public void setDBName(java.lang.String name)
throws ANZException
name - a String representing the name data base name.
ANZException - if the data base name cannot be set for this image.
public void setDescription(java.lang.String descripstr)
throws ANZException
descripstr - a String representing the name description.
ANZException - if the description cannot be set for the image header.
public void setMinMax(int min,
int max)
throws MultiSliceImageException
setMinMax in class MultiSliceImagemin - the minimum pixel value in the image.max - the maximum pixel value in the image.
MultiSliceImageException - if the values supplied are unsuitable, or the values
cannot be set.public ANZHeader getHeader()
public int getNCols()
throws MultiSliceImageException
LoadableImage
MultiSliceImageException
public int getNRows()
throws MultiSliceImageException
LoadableImage
MultiSliceImageException
public int getNSlices()
throws MultiSliceImageException
LoadableImage
MultiSliceImageException
public int getNFrames()
throws MultiSliceImageException
LoadableImage
MultiSliceImageException
public int getTotalNSlices()
throws MultiSliceImageException
LoadableImage
MultiSliceImageExceptionpublic int getNDim()
LoadableImage
public int[] getDims()
throws MultiSliceImageException
MultiSliceImage
getDims in class MultiSliceImageMultiSliceImageException - if the dimensions are bad.public PixelDataType getPixelDataType()
LoadableImage
public int getFileDataOffset()
MultiSliceImage
getFileDataOffset in class MultiSliceImage
public float getPixelXSize()
throws ParameterNotSetException
LoadableImage
ParameterNotSetException - if the pixel size can't be found.
public void setPixelXSize(float width)
throws MultiSliceImageException
MultiSliceImage
setPixelXSize in class MultiSliceImagewidth - the width of a pixel.
MultiSliceImageException - if the pixel width cannot be set.
public float getPixelYSize()
throws ParameterNotSetException
LoadableImage
ParameterNotSetException - if the pixel size can't be found.
public void setPixelYSize(float height)
throws MultiSliceImageException
MultiSliceImage
setPixelYSize in class MultiSliceImageheight - the height of a pixel.
MultiSliceImageException - if the pixel height cannot be set.
public float getPixelZSize()
throws ParameterNotSetException
LoadableImage
ParameterNotSetException - if the pixel size can't be found.
public void setPixelZSize(float thickness)
throws MultiSliceImageException
MultiSliceImage
setPixelZSize in class MultiSliceImagethickness - the thickness of a pixel.
MultiSliceImageException - if the pixel thickness cannot be set.
public float getTimeBetweenFrames()
throws ParameterNotSetException
LoadableImage
ParameterNotSetException - if the time between frames is not set, or if this
image doesn't have a dimensionality of at least 4.
public void setTimeBetweenFrames(float deltaT)
throws MultiSliceImageException
MultiSliceImage
setTimeBetweenFrames in class MultiSliceImagedeltaT - the time between frames (in seconds).
MultiSliceImageException - if the time between frames can't be set, or if this
image doesn't have a dimensionality of at least 4.public float[][] getImageOrientationPatient()
LoadableImage
public void setImageOrientationPatient(float[][] orientation)
throws MultiSliceImageException
MultiSliceImage
setImageOrientationPatient in class MultiSliceImageorientation - a 3x3 float[][], corresponding to the direction cosines of the image
row, column and slice directions in Left,Posterior,Superior (LPS) coordinates.
cosines[0][0..2] is the row direction; cosines[1][0..2] is the column direction; and
cosines[2][0..2] is the slice direction.
MultiSliceImageException - if the direction cosines cannot be set for this image, or if
cosines does not have the correct dimensions.public float[][] getImageOrientationPatient(int slice)
LoadableImage
slice - the slice for which to return the image orientation.
public void setImageOrientationPatient(float[][] orientation,
int slice)
throws MultiSliceImageException
setImageOrientationPatient in class MultiSliceImageorientation - the direction cosines for the column, row and slice directions.slice - the slice number.
MultiSliceImageException - always.public float[] getImagePositionPatient()
LoadableImage
public float[] getImagePositionPatient(int slice)
throws java.lang.IndexOutOfBoundsException
LoadableImage
java.lang.IndexOutOfBoundsException - if the slice number is bad for this image.
public void setImagePositionPatient(float[] position)
throws MultiSliceImageException
MultiSliceImage
setImagePositionPatient in class MultiSliceImageposition - a float array of length 3, corresponding to the Left,Posterior,Superior
(LPS) coordinates of the first pixel in the image data matrix.
MultiSliceImageException - if the position cannot be set for this image, or if
position does not have the correct dimensions.
public void setImagePositionPatient(float[] position,
int slice)
throws MultiSliceImageException
setImagePositionPatient in class MultiSliceImageposition - the position of the first pixel in the volume.slice - the slice number in the volume.
MultiSliceImageException - always.
public void setImageOrientationPositionPatient(javax.vecmath.Vector3f[] cosines,
javax.vecmath.Point3f position)
throws MultiSliceImageException
MultiSliceImageN.B. the actual position and orientation set by this method may not be those specified. For example, for NIFTI-1 images, the actual orientation and position may depend on the user Preferences for whether to put pixel values in an order that is compatible with SPM. After using this method, you should use the getImageOrientationPatient() and getImagePositionPatient() methods to obtain the real orientation and positions set.
setImageOrientationPositionPatient in class MultiSliceImagecosines - a Vector3f[] of length 3, corresponding to the direction
cosines of the image row, column and slice directions in Left,Posterior,Superior (LPS)
coordinates.
cosines[0] is the row direction; cosines[1] is the column direction; and
cosines[2] is the slice direction.position - the Left,Posterior,Superior (LPS) coordinates of the first pixel
in the image data matrix.
MultiSliceImageException - if the direction cosines cannot be set for this image, or if
the cosines array does not have the correct dimensions.
public void setPixelSpacing(float[] spacing)
throws MultiSliceImageException
MultiSliceImage
setPixelSpacing in class MultiSliceImagespacing - a float[] of length 3, corresponding to the distance between pixel centres
in the row, column and slice directions respectively. If this is a single-slice image,
then spacing may (otionally) have length 2 to indicate the in-plane distance between
pixel centres.
MultiSliceImageException - if the pixel spacing cannot be set for this image, or if
spacing does not have the correct dimensions.public float[] getIntensityRescale(int slice)
LoadableImage
slice - a slice number for which to retrieve the rescaling values.
public void setIntensityRescale(float[] rescale,
int slice)
throws MultiSliceImageException
setIntensityRescale in class MultiSliceImagerescale - a float[] of length 2 where the first element is m
and the second is b.slice - a slice number for which to set the rescaling values.
MultiSliceImageException - always.public java.lang.String getRescaleUnits()
LoadableImage
public java.lang.String getDescription()
LoadableImage
public java.lang.String getDescription(int slice)
LoadableImage
slice - the slice number.
o
public java.lang.String getTitle()
LoadableImage
public void setTitle(java.lang.String title)
throws MultiSliceImageException
MultiSliceImage
setTitle in class MultiSliceImagetitle - the new title to be assigned to this image.
MultiSliceImageException - if the title cannot be set.public java.lang.String getHTMLDescription()
LoadableImage
public java.lang.String getHTMLDescription(int slice)
LoadableImage
slice - the slice number.
public ColourMapping getNativeColourMapping()
public void setNativeColourMapping(ColourMapping colourMapping)
throws MultiSliceImageException
MultiSliceImage
setNativeColourMapping in class MultiSliceImagecolourMapping - the new ColourMapping to be assigned to this image.
MultiSliceImageException - if the ColourMapping cannot be set for this image.
public java.lang.Double getMin()
throws MultiSliceImageException
LoadableImage
MultiSliceImageException
public java.lang.Double getMax()
throws MultiSliceImageException
LoadableImage
MultiSliceImageExceptionpublic java.lang.Object clone()
clone in class MultiSliceImage
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||