com.xinapse.multisliceimage.Analyze
Class ANZImage

java.lang.Object
  extended by com.xinapse.multisliceimage.MultiSliceImage
      extended by com.xinapse.multisliceimage.Analyze.ANZImage
All Implemented Interfaces:
LoadableImage, java.lang.Cloneable
Direct Known Subclasses:
Analyze75Image, NIFTIImage

public abstract class ANZImage
extends MultiSliceImage

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.
 
Fields inherited from class com.xinapse.multisliceimage.MultiSliceImage
AUDIT_TRAIL_ACTION_TEXT, BIRTH_DATE_NAME, COLOUR_MAPPING_NAME, DATE_FORMAT, DEFAULT_IMAGE_CLASS, ECHO_TIME_NAME, FLIP_ANGLE_NAME, IMAGE_ORIENTATION_PATIENT_NAME, IMAGE_POSITION_PATIENT_NAME, INTENSITY_RESCALE_INTERCEPT_NAME, INTENSITY_RESCALE_SLOPE_NAME, INTENSITY_RESCALE_UNITS_NAME, INVERSION_TIME_NAME, MAXDIM, MODALITY_NAME, mode, PATIENT_ID_NAME, PATIENT_NAME_NAME, PATIENT_POSITION_NAME, pixArray, PIXEL_SPACING_NAME, PIXEL_X_SIZE_NAME, PIXEL_Y_SIZE_NAME, PIXEL_Z_SIZE_NAME, PULSE_SEQUENCE_NAME, randomAccessFile, REPETITION_TIME_NAME, SCAN_DATE_FORMAT, SCAN_DATE_NAME, SCANNING_SEQUENCE_NAME, SEQUENCE_VARIANT_NAME, SLICE_THICKNESS_NAME, TIME_BETWEEN_FRAMES_NAME
 
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 com.xinapse.multisliceimage.MultiSliceImage
autoResample, checkMinMax, crop, deleteImage, exists, export, export, export, getClasses, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getModality, getMostLikePlane, getNPixels, getPix, getPix, getPix, getPix, getPix, getPreferredImageClass, getROIs, getSimpleName, getSlice, getSlice, getSuggestedFileName, isImage, isModified, main, pad, putPix, putPix, putPix, putPix, putSlice, reorient, reorientRadiological, reSample, reSample, savePreferredImageClass, set3DBlockParameters, setFlipAngle, setIntensityRescale, setMinMax, setModality, setModified, setOrientationPositionRadiological, setPatientDoB, setPatientID, setPatientName, setPatientPosition, setPulseSequence, setRescaleUnits, setScanDate, setScanningSequence, setScanTE, setScanTE, setScanTI, setScanTR, setSequenceVariant, setSliceThickness, setSuggestedFileName, toBufferedImage
 
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

EXTENSION

public static final java.lang.String EXTENSION
The file extension for Analyze image files in lower case form.

See Also:
Constant Field Values

UPPERCASE_EXTENSION

public static final java.lang.String UPPERCASE_EXTENSION
The file extension for Analyze image files in upper case form.


COMPRESSED_EXTENSION

public static final java.lang.String COMPRESSED_EXTENSION
The file extension for Analyze image files in lower case form.

See Also:
Constant Field Values

COMPRESSED_UPPERCASE_EXTENSION

public static final java.lang.String COMPRESSED_UPPERCASE_EXTENSION
The file extension for Analyze image files in upper case form.

Method Detail

getByteOrder

public java.nio.ByteOrder getByteOrder()
Description copied from class: MultiSliceImage
Returns the byte order for this image.

Specified by:
getByteOrder in class MultiSliceImage
Returns:
the byte oder for this image, or null if the byte order is not defined yet (in-memory images only).

imageExists

public static boolean imageExists(java.lang.String filename)
Tests whether an ANZImage with the given name already exists on disk. File extensions are handled in a smart and case-insensitive way.

Parameters:
filename - the name of the image file to test for existence.
Returns:
true if a pair of ANZImage .img and .hdr with the specified name exist on disk; false otherwise.

write

public void write(java.lang.String filename)
           throws java.io.IOException,
                  MultiSliceImageException
Writes this ANZImage to disk.

Specified by:
write in class MultiSliceImage
Parameters:
filename - the root of the Analyze filename. Will be appended with ".img" and ".hdr" to create the appropriate full filenames.
Throws:
MultiSliceImageException - if the image cannot be written.
java.io.IOException - if an I/O error occurs.

write

public MultiSliceImage write(java.lang.String filename,
                             java.lang.Class cl)
                      throws java.io.IOException,
                             MultiSliceImageException
Description copied from class: MultiSliceImage
Writes this image to a disk-file given by the filename, in one of the MultiSliceImage sub-class image formats.

Specified by:
write in class MultiSliceImage
Parameters:
filename - 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).
Returns:
the MultiSliceImage that is written.
Throws:
java.io.IOException - if an I/O error occurs.
MultiSliceImageException - if the image cannot be written.

getInstance

public abstract MultiSliceImage getInstance(java.lang.String filename,
                                            java.lang.Class cl,
                                            int nSlices)
                                     throws java.io.IOException,
                                            MultiSliceImageException
Description copied from class: MultiSliceImage
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. If the number of slices requested for the new image is is less than the original, only the first slices will be copied to the new image. If the number of slices requested for the new image is more than the original, the additional slices will be filled with zero pixel values, and the slice-specific information will be empty.

Specified by:
getInstance in class MultiSliceImage
Parameters:
filename - 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.
Returns:
the new MultiSliceImage that is created.
Throws:
java.io.IOException - if an I/O error occurs.
MultiSliceImageException - if the image cannot be written.

close

public void close()
           throws java.io.IOException,
                  MultiSliceImageException
Closes an ANZImage and frees up resources. For in-memory ANZImages, this merely explicity frees resources so that the garbage collector can work more efficiently. However, for disk-based images it is essential to apply the close() method. Image data is written to disk during the put methods, but header information is only written to disk by the close() method. If the close() method is not applied to a disk-based ANZImage, then any changes to the header will be lost. Any further operations to a closed ANZImage are not possible, and may cause an exception to be thrown.

Throws:
MultiSliceImageException - if the file cannot be written or closed.
java.io.IOException - if an I/O error occurs.

finalize

protected void finalize()
                 throws java.lang.Throwable
Called by the garbage collector on this ANZImage when garbage collection determines that there are no more references to the image.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - - the Exception raised by this method.

isOpen

public boolean isOpen()
Description copied from interface: LoadableImage
Tests whether this image is still open.

Returns:
true if the image is still open for reading and (if opened read/write) writing; false otherwise.

isCompressed

public boolean isCompressed()
Tests whether this ANZImage is compressed when on disk. Returns true if compressed; false otherwise.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDataType

public ANZPixFormat getDataType()
Returns the data type (ANZPixFormat) of this image.

Returns:
an ANZPixFormat representing a particular pixel data type.

setDBName

public void setDBName(java.lang.String name)
               throws ANZException
Sets the data base name for this ANZImage.

Parameters:
name - a String representing the name data base name.
Throws:
ANZException - if the data base name cannot be set for this image.

setDescription

public void setDescription(java.lang.String descripstr)
                    throws ANZException
Sets the description for this ANZImage.

Parameters:
descripstr - a String representing the name description.
Throws:
ANZException - if the description cannot be set for the image header.

setMinMax

public void setMinMax(int min,
                      int max)
               throws MultiSliceImageException
Sets the glMin and glMax fields for this ANZImage.

Specified by:
setMinMax in class MultiSliceImage
Parameters:
min - the minimum pixel value in the image.
max - the maximum pixel value in the image.
Throws:
MultiSliceImageException - if the values supplied are unsuitable, or the values cannot be set.

getHeader

public ANZHeader getHeader()
Returns the ANZHeader image header for this image. Warning! If this header is manipulated, then accessing the image pixel data may cause errors.

Returns:
the Analyze image header for this image.

getNCols

public int getNCols()
             throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the number of image columns in this image.

Returns:
the number of image columns.
Throws:
MultiSliceImageException

getNRows

public int getNRows()
             throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the number of image rows in this image.

Returns:
the number of image rows.
Throws:
MultiSliceImageException

getNSlices

public int getNSlices()
               throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the number of physical slice locations in this image. If the image dimensionality is greater than or equal to three, then this method returns the number of samples in the third dimension. If the dimensionality is two, it returns 1. If the dimensionality is less than two, it throws an InvalidImageException.

Returns:
the number of physical slice locations.
Throws:
MultiSliceImageException

getNFrames

public int getNFrames()
               throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the number of frames in a multi-frame image. If the image dimensionality is greater than or equal to four, then this method returns the number of samples in the fourth dimension. If the dimensionality is less than 4, it returns 1.

Returns:
the number of image (movie) frames.
Throws:
MultiSliceImageException

getTotalNSlices

public int getTotalNSlices()
                    throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the total number of slices in this image. If the image is 2-dimensional, this method returns 1; if it is 3-dimensional, it returns the number of slices; if it is 4- or more dimensional, it sums up the total number of planar slices in each dimension and returns the total. For example a 4-dimensional image with 4 slices and 10 frames, the total number of slices is 40.

Returns:
the number of planar image slices.
Throws:
MultiSliceImageException

getNDim

public int getNDim()
Description copied from interface: LoadableImage
Returns the dimensionality of this image.

Returns:
the image dimensionality.

getDims

public int[] getDims()
              throws MultiSliceImageException
Description copied from class: MultiSliceImage
Returns the dimensions of this image.

Specified by:
getDims in class MultiSliceImage
Returns:
the image dimensions in a int array, where element 0 is the most slowly varying index, 1 the next most slowly-varying, etc.
Throws:
MultiSliceImageException - if the dimensions are bad.

getPixelDataType

public PixelDataType getPixelDataType()
Description copied from interface: LoadableImage
Returns a PixelDataType representing the data type of this image.

Returns:
the PixelDataType representing the data type of this image.

getFileDataOffset

public int getFileDataOffset()
Description copied from class: MultiSliceImage
Returns the byte offset into the disk-based file format where pixel data begins.

Specified by:
getFileDataOffset in class MultiSliceImage
Returns:
the byte offset to the start of pixel data for images that are written to disk.

getPixelXSize

public float getPixelXSize()
                    throws ParameterNotSetException
Description copied from interface: LoadableImage
Returns the pixel size in the x (horizontal) direction for this image.

Returns:
the pixel size in the x (horizontal) direction in mm.
Throws:
ParameterNotSetException - if the pixel size can't be found.

setPixelXSize

public void setPixelXSize(float width)
                   throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the pixel size in the x (horizontal) direction for this image.

Specified by:
setPixelXSize in class MultiSliceImage
Parameters:
width - the width of a pixel.
Throws:
MultiSliceImageException - if the pixel width cannot be set.

getPixelYSize

public float getPixelYSize()
                    throws ParameterNotSetException
Description copied from interface: LoadableImage
Returns the pixel size in the y (vertical) direction for this image.

Returns:
the pixel size in the y (vertical) direction in mm.
Throws:
ParameterNotSetException - if the pixel size can't be found.

setPixelYSize

public void setPixelYSize(float height)
                   throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the pixel size in the y (vertical) direction for this image.

Specified by:
setPixelYSize in class MultiSliceImage
Parameters:
height - the height of a pixel.
Throws:
MultiSliceImageException - if the pixel height cannot be set.

getPixelZSize

public float getPixelZSize()
                    throws ParameterNotSetException
Description copied from interface: LoadableImage
Returns the separation between the centres of image planes for this image.

Returns:
the pixel size in the z (slice) direction in mm.
Throws:
ParameterNotSetException - if the pixel size can't be found.

setPixelZSize

public void setPixelZSize(float thickness)
                   throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the pixel size in the z (slice) direction for this image.

Specified by:
setPixelZSize in class MultiSliceImage
Parameters:
thickness - the thickness of a pixel.
Throws:
MultiSliceImageException - if the pixel thickness cannot be set.

getTimeBetweenFrames

public float getTimeBetweenFrames()
                           throws ParameterNotSetException
Description copied from interface: LoadableImage
Returns the time between frames in a 4- or higher dimensional image.

Returns:
the time between frames in seconds.
Throws:
ParameterNotSetException - if the time between frames is not set, or if this image doesn't have a dimensionality of at least 4.

setTimeBetweenFrames

public void setTimeBetweenFrames(float deltaT)
                          throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the time between frames in a 4- or higher dimensional image.

Specified by:
setTimeBetweenFrames in class MultiSliceImage
Parameters:
deltaT - the time between frames (in seconds).
Throws:
MultiSliceImageException - if the time between frames can't be set, or if this image doesn't have a dimensionality of at least 4.

getImageOrientationPatient

public float[][] getImageOrientationPatient()
Description copied from interface: LoadableImage
Returns the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient coordinates.

Returns:
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. If the distance between image adjacent slices is not the same for all slices, but the slices are parallel, then this method will return a 2x3 float[][] giving the direction cosines of the row and column directions respectively. Returns null if the direction cosines cannot be retrieved from this image.

setImageOrientationPatient

public void setImageOrientationPatient(float[][] orientation)
                                throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient (LPS) coordinates.

Specified by:
setImageOrientationPatient in class MultiSliceImage
Parameters:
orientation - 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.
Throws:
MultiSliceImageException - if the direction cosines cannot be set for this image, or if cosines does not have the correct dimensions.

getImageOrientationPatient

public float[][] getImageOrientationPatient(int slice)
Description copied from interface: LoadableImage
Returns the direction cosines of the row, column and (possiblly) slice directions (for increasing row, column and slice) of the image, in patient coordinates.

Parameters:
slice - the slice for which to return the image orientation.
Returns:
a 3x3 or 2x3 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 (if present) cosines[2][0..2] is the slice direction. Returns null if the direction cosines cannot be retrieved from this image.

setImageOrientationPatient

public void setImageOrientationPatient(float[][] orientation,
                                       int slice)
                                throws MultiSliceImageException
This action is not supported by the Analyze/NIFTI-1 file format, so this method always throws a MultiSliceImageException. All slices of an Analyze image are parallel, so setting the orientation of an individual slice is not possible.

Specified by:
setImageOrientationPatient in class MultiSliceImage
Parameters:
orientation - the direction cosines for the column, row and slice directions.
slice - the slice number.
Throws:
MultiSliceImageException - always.

getImagePositionPatient

public float[] getImagePositionPatient()
Description copied from interface: LoadableImage
Returns the coordinates of the center of the first pixel of the image, in mm, in patient coordinates. This method will only return if the image pixels form a regular array of pixels with parallel image planes; otherwise a ParameterNotSetException is thrown.

Returns:
a float array of length 3, corresponding to the Left,Posterior,Superior (LPS) coordinates of the first pixel in the image data matrix. Returns null if the position cannot be retrieved from this image.

getImagePositionPatient

public float[] getImagePositionPatient(int slice)
                                throws java.lang.IndexOutOfBoundsException
Description copied from interface: LoadableImage
Returns the coordinates of the center of the first pixel of the specified slice of this image, in mm, in patient coordinates.

Returns:
a float array of length 3, corresponding to the Left,Posterior,Superior (LPS) coordinates of the first pixel in the specified slice of this image. Returns null if the position cannot be retrieved from this image.
Throws:
java.lang.IndexOutOfBoundsException - if the slice number is bad for this image.

setImagePositionPatient

public void setImagePositionPatient(float[] position)
                             throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the coordinates of the center of the first pixel of the image, in mm, in patient (LPS) coordinates.

Specified by:
setImagePositionPatient in class MultiSliceImage
Parameters:
position - a float array of length 3, corresponding to the Left,Posterior,Superior (LPS) coordinates of the first pixel in the image data matrix.
Throws:
MultiSliceImageException - if the position cannot be set for this image, or if position does not have the correct dimensions.

setImagePositionPatient

public void setImagePositionPatient(float[] position,
                                    int slice)
                             throws MultiSliceImageException
This action is not supported by the Analyze/NIFTI-1 file format, so this method always throws a MultiSliceImageException. All slices are parallel and the position of individual slices may not be set.

Specified by:
setImagePositionPatient in class MultiSliceImage
Parameters:
position - the position of the first pixel in the volume.
slice - the slice number in the volume.
Throws:
MultiSliceImageException - always.

setImageOrientationPositionPatient

public void setImageOrientationPositionPatient(javax.vecmath.Vector3f[] cosines,
                                               javax.vecmath.Point3f position)
                                        throws MultiSliceImageException
Description copied from class: MultiSliceImage
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.

N.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.

Specified by:
setImageOrientationPositionPatient in class MultiSliceImage
Parameters:
cosines - 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.
Throws:
MultiSliceImageException - if the direction cosines cannot be set for this image, or if the cosines array does not have the correct dimensions.

setPixelSpacing

public void setPixelSpacing(float[] spacing)
                     throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the distance (in mm) between pixel centres in the row, column and slice directions of the image. The distances should always be positive values.

Specified by:
setPixelSpacing in class MultiSliceImage
Parameters:
spacing - 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.
Throws:
MultiSliceImageException - if the pixel spacing cannot be set for this image, or if spacing does not have the correct dimensions.

getIntensityRescale

public float[] getIntensityRescale(int slice)
Description copied from interface: LoadableImage
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.

Parameters:
slice - a slice number for which to retrieve the rescaling values.
Returns:
an array will be of length 2 where the first element is m and the second is b, for the specified slice.

setIntensityRescale

public void setIntensityRescale(float[] rescale,
                                int slice)
                         throws MultiSliceImageException
This action is not supported by the Analyze/NIFTI-1 file format, so this method always throws a MultiSliceImageException.

Specified by:
setIntensityRescale in class MultiSliceImage
Parameters:
rescale - 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.
Throws:
MultiSliceImageException - always.

getRescaleUnits

public java.lang.String getRescaleUnits()
Description copied from interface: LoadableImage
Specifies the output units of Intensity Rescale Slope and Intensity Rescale Intercept, retrieved by getIntensityRescale().

Returns:
a String describing the physical meaning of the pixel intensity units. Returns the String "arbitrary units" if the physical meaning is unknown, or arbitrary.

getDescription

public java.lang.String getDescription()
Description copied from interface: LoadableImage
Returns a String description of this image.

Returns:
a String describing this image.

getDescription

public java.lang.String getDescription(int slice)
Description copied from interface: LoadableImage
Returns a description of a slice of this image.

Parameters:
slice - the slice number. o
Returns:
a String describing this image slice.

getTitle

public java.lang.String getTitle()
Description copied from interface: LoadableImage
Returns the title of this image.

Returns:
the title of this image.

setTitle

public void setTitle(java.lang.String title)
              throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the title of this image. If new title String is longer than is allowed by the image format, then it is truncated before being applied.
N.B. For disk-based images, the changes in the title will not be reflected on disk unless the close() method is called.

Specified by:
setTitle in class MultiSliceImage
Parameters:
title - the new title to be assigned to this image.
Throws:
MultiSliceImageException - if the title cannot be set.

getHTMLDescription

public java.lang.String getHTMLDescription()
Description copied from interface: LoadableImage
Returns a String description of this image in HTML format.

Returns:
a String describing this image.

getHTMLDescription

public java.lang.String getHTMLDescription(int slice)
Description copied from interface: LoadableImage
Returns a String description of a slice of this image in HTML format.

Parameters:
slice - the slice number.
Returns:
a String describing this image slice.

getNativeColourMapping

public ColourMapping getNativeColourMapping()
Returns a ColourMapping if this Analyze image has an associated colour mapping. Colour mappings are kept in a file with an extension ".lkup" and with the same name root as the Analyze image.

Returns:
a ColourMapping if this image has an associated colour mapping. Returns null if it does not.

setNativeColourMapping

public void setNativeColourMapping(ColourMapping colourMapping)
                            throws MultiSliceImageException
Description copied from class: MultiSliceImage
Sets the ColourMapping for this image. No exception occurs if the image format does not support a colour mapping.
N.B. For disk-based images, the changes in the ColourMapping will not be reflected on disk unless the close() method is called.

Specified by:
setNativeColourMapping in class MultiSliceImage
Parameters:
colourMapping - the new ColourMapping to be assigned to this image.
Throws:
MultiSliceImageException - if the ColourMapping cannot be set for this image.

getMin

public java.lang.Double getMin()
                        throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the minimum pixel intensity in the image.

Returns:
the maximum pixel intensity as a Double, or null if the intensity min hasn't been calculated for this image.
Throws:
MultiSliceImageException

getMax

public java.lang.Double getMax()
                        throws MultiSliceImageException
Description copied from interface: LoadableImage
Returns the maximum pixel intensity in the image.

Returns:
the maximum pixel intensity as a Double, or null if the intensity max hasn't been calculated for this image.
Throws:
MultiSliceImageException

clone

public java.lang.Object clone()
Creates an in-memory clone of an Analyze image.

Overrides:
clone in class MultiSliceImage
Returns:
a copy of the ANZImage Object.


Copyright 2006-2008 Xinapse Systems Limited. All Rights Reserved.