com.xinapse.multisliceimage
Class MultiSliceImage

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

public abstract class MultiSliceImage
extends java.lang.Object
implements LoadableImage, java.lang.Cloneable

An abstract representation of a multi-dimensional image. This class cannot be instantiated, and sub-classes must implement the abstract methods defined here, and those defined in LoadableImage.


Field Summary
static java.lang.String AUDIT_TRAIL_ACTION_TEXT
          A String used when composing audit trail information.
static java.lang.String BIRTH_DATE_NAME
          The information field name that is written into image headers to indicate the patient's birth date.
static java.lang.String COLOUR_MAPPING_NAME
          The information field name that is written into image headers to indicate the colour mapping.
static java.lang.Class DEFAULT_IMAGE_CLASS
          The default image class to work with, if the user has no Preference.
static java.lang.String DW_B_MATRIX_NAME
          The information field name that is written into image headers to indicate the excitation diffusion-weighting B-matrix.
static java.lang.String DW_B_VALUE_NAME
          The information field name that is written into image headers to indicate the excitation diffusion-weighting b-value.
static java.lang.String DW_GRADIENT_VECTOR_NAME
          The information field name that is written into image headers to indicate the excitation diffusion-weighting gradient vector.
static java.lang.String ECHO_TIME_NAME
          The information field name that is written into image headers to indicate the scan echo time.
static java.lang.String FLIP_ANGLE_NAME
          The information field name that is written into image headers to indicate the excitation pulse flip angle.
static java.lang.String FRAME_OF_REFERENCE_UID_NAME
          The information field name that is written into image headers to indicate the frame of reference UID for the image position/orientation.
static java.lang.String IMAGE_ORIENTATION_PATIENT_NAME
          The information field name that is written into image headers to indicate the orientation (direction cosines) of the matrix of image pixels, in patient coordinates.
static java.lang.String IMAGE_POSITION_PATIENT_NAME
          The information field name that is written into image headers to indicate the location of the first pixel of the image, in patient coordinates.
static java.lang.String INTENSITY_RESCALE_INTERCEPT_NAME
          The information field name that is written into image headers to indicate the intensity rescale intercept.
static java.lang.String INTENSITY_RESCALE_SLOPE_NAME
          The information field name that is written into image headers to indicate the intensity rescale slope.
static java.lang.String INTENSITY_RESCALE_UNITS_NAME
          The information field name that is written into image headers to indicate the intensity rescale units.
static java.lang.String INVERSION_TIME_NAME
          The information field name that is written into image headers to indicate the scan inversion time.
static int MAXDIM
          The maximum dimensionality of an image.
static java.lang.String MODALITY_NAME
          The information field name that is written into image headers to indicate the imaging modality.
protected  java.lang.String mode
          The "mode" with which the image was opened, if a disk-file: either "r" or "rw".
static java.lang.String PATIENT_ID_NAME
          The information field name that is written into image headers to indicate the patient ID.
static java.lang.String PATIENT_NAME_NAME
          The information field name that is written into image headers to indicate the patient name.
static java.lang.String PATIENT_POSITION_NAME
          The information field name that is written into image headers to indicate the way in which the patient is positioned in the scanner.
protected  PixArray pixArray
          If non-null, pixel data held in this PixArray object.
static java.lang.String PIXEL_SPACING_NAME
          The information field name that is written into image headers to indicate the physical distance in the patient between the center of each pixel.
static java.lang.String PIXEL_X_SIZE_NAME
          The information field name that is written into image headers to indicate the width of an image pixel in mm.
static java.lang.String PIXEL_Y_SIZE_NAME
          The information field name that is written into image headers to indicate the height of an image pixel in mm.
static java.lang.String PIXEL_Z_SIZE_NAME
          The information field name that is written into image headers to indicate the thickness of an image pixel in mm.
static java.lang.String PULSE_SEQUENCE_NAME
          The information field name that is written into image headers to indicate the pulse sequence name.
protected  java.io.RandomAccessFile randomAccessFile
          If non-null, pixel data kept on disk and accessed via this RandomAccessFile.
static java.lang.String REPETITION_TIME_NAME
          The information field name that is written into image headers to indicate the scan repetition time.
static java.lang.String SCAN_DATE_NAME
          The information field name that is written into image headers to indicate the scan date.
static java.lang.String SCANNING_SEQUENCE_NAME
          The information field name that is written into image headers to indicate the DICOM scanning sequence.
static java.lang.String SEQUENCE_VARIANT_NAME
          The information field name that is written into image headers to indicate the DICOM scanning sequence variant.
static java.lang.String SLICE_THICKNESS_NAME
          The information field name that is written into image headers to indicate the thickness of an image slice.
static java.lang.String TIME_BETWEEN_FRAMES_NAME
          The information field name that is written into image headers to indicate the time between frames of a multi-frame image.
 
Constructor Summary
protected MultiSliceImage()
          Default constructor for MultiSliceImage for use by sub-classes.
 
Method Summary
 MultiSliceImage autoResample(int maxNVoxels, SubSampleType subSampleType, boolean allowSliceResample, boolean verbose)
          Automatically resamples this image so that the resulting resampled image has no more than the given maximum number of voxels.
static void checkMinMax(int min, int max, PixelDataType dataType)
          Checks the integrity of the minimum and maximum pixel values taking into account the data type of the image.
 MultiSliceImage clone()
          Returns a copy of this MultiSliceImage.
 MultiSliceImage crop(int[][] cropDims, MonitorWorker worker, boolean verbose)
          Crops an existing MultiSliceImage.
static boolean deleteImage(java.lang.String filename, java.lang.Class c)
          Attempts to delete an image of the given Class with the given name.
static boolean exists(java.lang.String filename)
          Tests whether a MultiSliceImage with the given name already exists on disk.
 java.io.InputStream export(java.lang.String suffix, ColourMapping cm, double displayMin, double displayMax, ComplexMode complexMode, int slicesPerRow)
          Returns an InputStream from which a external format image (such as JPEG, GIF etc.) can be read, producing the external format image from this MultiSliceImage, by drawing all of the slices in a raster of slices.
 void export(java.lang.String suffix, javax.imageio.stream.ImageOutputStream outputStream, ColourMapping cm, double displayMin, double displayMax, ComplexMode complexMode, int slicesPerRow)
          Writes an image to an ImageOutputStream in an external format (such as JPEG, GIF etc.), creating the disk image from this MultiSliceImage, by drawing all of the slices in a raster of slices.
 void export(java.lang.String suffix, java.lang.String filename, ColourMapping cm, double displayMin, double displayMax, ComplexMode complexMode, int slicesPerRow)
          Writes an image to a disk file in an external format (such as JPEG, GIF etc.), creating the disk image from this MultiSliceImage, by drawing all of the slices in a raster of slices.
protected abstract  java.nio.ByteOrder getByteOrder()
          Returns the byte order for this image.
static java.lang.Class[] getClasses()
          Returns an array of classes that are known to be sub-classes of MultiSliceImage.
static java.text.DateFormat getDateFormat()
           
abstract  int[] getDims()
          Returns the dimensions of this image.
protected abstract  int getFileDataOffset()
          Returns the byte offset into the disk-based file format where pixel data begins.
 com.xinapse.dicom.Uid getFrameOfReferenceUID()
          Returns the frame of reference UID that uniquely identifies the frame of reference for an image.
abstract  MultiSliceImage getInstance(java.lang.Class c, int nSlices)
          Creates a new in-memory MultiSliceImage with the MultiSliceImage class given by the argument, possibly changing the number of slices in the image.
static MultiSliceImage getInstance(java.awt.Component component, MultiSliceImage templateImage)
          Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created.
static MultiSliceImage getInstance(java.awt.Component component, MultiSliceImage templateImage, java.lang.Class outputImageClass)
          Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created.
static MultiSliceImage getInstance(java.awt.Component component, MultiSliceImage templateImage, int nSlices)
          Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created.
 MultiSliceImage getInstance(int nSlices)
          Creates a new in-memory MultiSliceImage, based on this MultiSliceImage, but possibly changing the number of slices in the image.
static MultiSliceImage getInstance(MultiSliceImage templateImage, java.lang.Class outputImageClass, int nSlices)
          Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created.
static MultiSliceImage getInstance(MultiSliceImage templateImage, int nSlices)
          Returns an in-memory instance of an image class using the supplied MultiSliceImage as a template for the image to be created.
static MultiSliceImage getInstance(java.lang.String filename)
          Returns an instance of an image class gotten from a file.
static MultiSliceImage getInstance(java.lang.String filename, java.lang.String mode)
          Returns an instance of an image class gotten from a file, opened according to the mode.
abstract  Modality getModality()
          Returns the modality with which this image was acquired.
 MostLikePlane getMostLikePlane()
          Returns the imaging plane that this image is "most like".
static int getNPixels(int nDim, int[] dims)
          Returns the total number of picture elements for a MultiSliceImage with the given dimensions.
 java.lang.Object getPix()
          Returns all pixel values from this image.
 java.lang.Object getPix(boolean radiological)
          Returns all pixel values from this image.
 java.lang.Object getPix(int[] pixIdx)
          Returns a single pixel value from the image.
 java.lang.Object getPix(int[] lowIdx, int[] highIdx)
          Returns pixel values from this image.
 java.lang.Object getPix(java.lang.Object array, int[] lowIdx, int[] highIdx)
          Get pixel values from this image into a specified array.
static java.lang.Class getPreferredImageClass()
          Returns the MultiSliceImage class set in the user's Preferences.
static PreviewIcon getPreview(java.io.File f)
          Gets a PreviewIcon for a LoadableImage contained within the supplied File.
 java.util.List<ROI> getROIs()
          Returns a List of ROIs that are stored with the image.
static java.text.DateFormat getScanDateFormat()
          Returns the java.text.DateFormat with which a scan date should be formatted.
abstract  java.lang.String getSimpleName()
          Returns the simple name for this type of image - the String that should be seen by the users to identify this type of image.
 java.lang.Object getSlice(int slice)
          Returns all the pixels for a two-dimensional slice of this image, as a 1-dimensional array of primitive values.
 java.lang.Object getSlice(java.lang.Object array, int slice)
          Returns all the pixels for a two-dimensional slice of this image, as a 1-dimensional array of primitive values.
protected  int getSliceDim(int slice)
           
 java.lang.String getSuggestedFileName()
          Returns the suggested file name for in-memory images that are to be saved to disk.
static boolean isImage(java.io.File f)
          Tests whether the supplied File refers to a MultSliceImage file.
 boolean isModified()
          Tests whether this this MultiSliceImage has been modified since instantiation.
static void main(java.lang.String[] args)
          Run the self-test on the MultiSliceImage class.
 MultiSliceImage pad(int[] padDims, MonitorWorker worker, boolean verbose)
          Pads an existing MultiSliceImage with zero-intensity pixels around the edge of the image.
protected static double[] parseMultiValuedString(java.lang.String s, int nValues)
          Convenience method to parse Strings of the form "value1\value2\value3\…\valueN", where value1 to valueN are numerical values.
 void putPix(java.lang.Object array)
          Put pixel values from a specified array to this image.
 void putPix(java.lang.Object array, boolean radiological)
          Put pixel values from a specified array to this image.
 java.lang.Object putPix(java.lang.Object pix, int[] pixIdx)
          Puts a single pixel value to the image.
 void putPix(java.lang.Object array, int[] lowIdx, int[] highIdx)
          Put pixel values from a specified array to this image.
 void putSlice(java.lang.Object array, int slice)
          Puts the pixel values to one slice of an n-dimensional image, where n > 1.
 MultiSliceImage reorient(MostLikePlane newOrientation, MostLikePlane currentOrientation, java.lang.Boolean slicesAreReversed, MonitorWorker worker, boolean verbose)
          Reorients an existing MultiSliceImage.
static void reorientRadiological(LoadableImage image, java.lang.Object pix)
          Reorients a set of pixels for an image so that they will be presented in standard radiological orientation.
 MultiSliceImage reSample(float[] newPixelSizes, InterpolationType interpolationType, SubSampleType subSampleType, MonitorWorker worker, boolean verbose)
          Resamples an existing MultiSliceImage to have different pixel sizes.
 MultiSliceImage reSample(int[] newDims, InterpolationType interpolationType, SubSampleType subSampleType, MonitorWorker worker, boolean verbose)
          Resamples an existing MultiSliceImage to have different numbers of pixels.
static void savePreferredImageClass(java.lang.Class imageClass)
          Saves the supplied class to the user's Preferences.
 void set3DBlockParameters()
          For an image which contains multiple slices with all slices parallel and regularly-spaced, this method will modify the image position (patient coords), image orientation (patient coords) and pixel spacing (pixel sizes) according to the block.
abstract  void setDWBMatrix(float[] bMatrix, int slice)
          Sets the diffusion-weighting B-matrix for one slice of this image.
abstract  void setDWbValue(float bValue, int slice)
          Sets the diffusion-weighting b-value for one slice of this image.
abstract  void setDWGradientVector(javax.vecmath.Vector3f gradVec, int slice)
          Sets the diffusion-weighting gradient vector for one slice of this image.
abstract  void setFlipAngle(float flipAngle)
          Sets the excitation pulse flip angle for this image.
abstract  void setImageOrientationPatient(javax.vecmath.Vector3f[] dirCos, int slice)
          Sets the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient (LPS) coordinates.
abstract  void setImageOrientationPositionPatient(javax.vecmath.Vector3f[] dirCos, javax.vecmath.Point3f position, boolean force)
          Sets the direction cosines of the row, column and slice directions of the image, the coordinates of the center of the first pixel of the image, in patient (LPS) coordinates.
abstract  void setImagePositionPatient(javax.vecmath.Point3f position, int slice)
          Sets the coordinates of the center of the first pixel of the image, in mm, in patient (LPS) coordinates, for one slice of this image.
abstract  void setIntensityRescale(float[] rescale)
          Sets the values m and b in the relationship between pixel intensity (I) values and the output units specified in setRescaleUnits() in the expression:
Output units = m*I + b.
abstract  void setIntensityRescale(float[] rescale, int slice)
          Sets the values m and b in the relationship between pixel intensity (I) values and the output units specified in setRescaleUnits() in the expression:
Output units = m*I + b, for a particular slice.
 void setMinMax(int[] minmax)
          Sets the min and max pixel values for this image.
abstract  void setMinMax(int min, int max)
          Sets the min and max pixel values for this image.
abstract  void setModality(Modality modality)
          Sets the modality with which this image was acquired.
 void setModified()
          Sets the "modified" flag for this MultiSliceImage to indicate that it has been modified since instantiation.
abstract  void setNativeColourMapping(ColourMapping colourMapping)
          Sets the ColourMapping for this image.
static void setOrientationPositionRadiological(javax.vecmath.Vector3f[] orientation, javax.vecmath.Point3f position, int nCols, int nRows, float pixelXSize, float pixelYSize)
          Reorientates the image orientation vectors, and repositions an image position so that the positions and orientations refer to blocks of image pixels that have been gotten in an anatomical orientation.
abstract  void setPatientDoB(java.util.Date newDoB)
          Sets the patient's date of birth for this image.
abstract  void setPatientID(java.lang.String newID)
          Sets the patient ID for this image.
abstract  void setPatientName(java.lang.String newName)
          Attempts to set the patient name for this image.
abstract  void setPatientPosition(PatientPosition position)
          Sets the position in which the patient is lying in the scanning equipment for this MultiSliceImage.
abstract  void setPixelSpacing(float[] spacing)
          Sets the distance (in mm) between pixel centres in the row, column and slice directions of the image.
abstract  void setPixelXSize(float width)
          Sets the pixel size in the x (horizontal) direction for this image.
abstract  void setPixelYSize(float height)
          Sets the pixel size in the y (vertical) direction for this image.
abstract  void setPixelZSize(float thickness)
          Sets the pixel size in the z (slice) direction for this image.
abstract  void setPulseSequence(java.lang.String seqName)
          Sets the pulse sequence name for this image.
abstract  void setRescaleUnits(java.lang.String unitsString)
          Sets the output units of Intensity Rescale Slope and Intensity Rescale Intercept, retrieved by getIntensityRescale().
abstract  void setScanDate(java.util.Date newDate)
          Sets the scan date/time for this image.
abstract  void setScanningSequence(PulseSequenceType seqType)
          Sets the DICOM scanning sequence for this image.
abstract  void setScanTE(float TE)
          Sets the scan echo time for this image, for single-echo-time images.
abstract  void setScanTE(float TE, int slice)
          Sets the scan echo time for one slice of this image.
abstract  void setScanTI(float TI)
          Sets the scan inversion time for this image.
abstract  void setScanTR(float TR)
          Sets the scan repetition time for this image.
abstract  void setSequenceVariant(PulseSequenceVariant seqVariant)
          Sets the DICOM scanning sequence variant for this image.
abstract  void setSliceThickness(float thickness)
          Sets the slice thickness (in mm).
 void setSuggestedFileName(java.lang.String name)
          Sets a suggested file name for in-memory images that might be saved to disk later.
abstract  void setTimeBetweenFrames(float deltaT)
          Sets the time between frames in a 4- or higher dimensional image.
abstract  void setTitle(java.lang.String newTitle)
          Sets the title of this image.
 java.awt.image.BufferedImage toBufferedImage(ColourMapping cm, double displayMin, double displayMax, ComplexMode complexMode, int slicesPerRow)
          Create a BufferedImage from this MultiSliceImage, by drawing all of the slices in a raster of slices.
abstract  java.lang.String write(java.lang.String filename)
          Writes this image to a disk-file given by the name.
abstract  MultiSliceImage write(java.lang.String filename, java.lang.Class c)
          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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.xinapse.loadableimage.LoadableImage
appendAuditInfo, close, getDescription, getDescription, getDWBMatrix, getDWbValue, getDWGradientVector, getFlipAngle, getHTMLDescription, getHTMLDescription, getImageOrientationPatient, getImageOrientationPatient, getImagePositionPatient, getImagePositionPatient, getIntensityRescale, getIntensityRescale, getMax, getMin, getNativeColourMapping, getNCols, getNDim, getNFrames, getNRows, getNSlices, getPatientDoB, getPatientID, getPatientName, getPatientPosition, getPixelDataType, getPixelXSize, getPixelYSize, getPixelZSize, getPulseSequence, getRescaleUnits, getScanDate, getScanningSequence, getScanTE, getScanTE, getScanTI, getScanTR, getSequenceVariant, getSliceThickness, getTimeBetweenFrames, getTitle, getTotalNSlices, isOpen
 

Field Detail

PATIENT_NAME_NAME

public static final java.lang.String PATIENT_NAME_NAME
The information field name that is written into image headers to indicate the patient name.

See Also:
Constant Field Values

PATIENT_ID_NAME

public static final java.lang.String PATIENT_ID_NAME
The information field name that is written into image headers to indicate the patient ID.

See Also:
Constant Field Values

BIRTH_DATE_NAME

public static final java.lang.String BIRTH_DATE_NAME
The information field name that is written into image headers to indicate the patient's birth date.

See Also:
Constant Field Values

SCAN_DATE_NAME

public static final java.lang.String SCAN_DATE_NAME
The information field name that is written into image headers to indicate the scan date.

See Also:
Constant Field Values

MODALITY_NAME

public static final java.lang.String MODALITY_NAME
The information field name that is written into image headers to indicate the imaging modality.

See Also:
Constant Field Values

PULSE_SEQUENCE_NAME

public static final java.lang.String PULSE_SEQUENCE_NAME
The information field name that is written into image headers to indicate the pulse sequence name.

See Also:
Constant Field Values

SCANNING_SEQUENCE_NAME

public static final java.lang.String SCANNING_SEQUENCE_NAME
The information field name that is written into image headers to indicate the DICOM scanning sequence.

See Also:
Constant Field Values

SEQUENCE_VARIANT_NAME

public static final java.lang.String SEQUENCE_VARIANT_NAME
The information field name that is written into image headers to indicate the DICOM scanning sequence variant.

See Also:
Constant Field Values

REPETITION_TIME_NAME

public static final java.lang.String REPETITION_TIME_NAME
The information field name that is written into image headers to indicate the scan repetition time.

See Also:
Constant Field Values

INVERSION_TIME_NAME

public static final java.lang.String INVERSION_TIME_NAME
The information field name that is written into image headers to indicate the scan inversion time.

See Also:
Constant Field Values

ECHO_TIME_NAME

public static final java.lang.String ECHO_TIME_NAME
The information field name that is written into image headers to indicate the scan echo time.

See Also:
Constant Field Values

FLIP_ANGLE_NAME

public static final java.lang.String FLIP_ANGLE_NAME
The information field name that is written into image headers to indicate the excitation pulse flip angle.

See Also:
Constant Field Values

DW_B_VALUE_NAME

public static final java.lang.String DW_B_VALUE_NAME
The information field name that is written into image headers to indicate the excitation diffusion-weighting b-value.

See Also:
Constant Field Values

DW_GRADIENT_VECTOR_NAME

public static final java.lang.String DW_GRADIENT_VECTOR_NAME
The information field name that is written into image headers to indicate the excitation diffusion-weighting gradient vector.

See Also:
Constant Field Values

DW_B_MATRIX_NAME

public static final java.lang.String DW_B_MATRIX_NAME
The information field name that is written into image headers to indicate the excitation diffusion-weighting B-matrix.

See Also:
Constant Field Values

COLOUR_MAPPING_NAME

public static final java.lang.String COLOUR_MAPPING_NAME
The information field name that is written into image headers to indicate the colour mapping.

See Also:
Constant Field Values

PIXEL_X_SIZE_NAME

public static final java.lang.String PIXEL_X_SIZE_NAME
The information field name that is written into image headers to indicate the width of an image pixel in mm.

See Also:
Constant Field Values

PIXEL_Y_SIZE_NAME

public static final java.lang.String PIXEL_Y_SIZE_NAME
The information field name that is written into image headers to indicate the height of an image pixel in mm.

See Also:
Constant Field Values

PIXEL_Z_SIZE_NAME

public static final java.lang.String PIXEL_Z_SIZE_NAME
The information field name that is written into image headers to indicate the thickness of an image pixel in mm.

See Also:
Constant Field Values

TIME_BETWEEN_FRAMES_NAME

public static final java.lang.String TIME_BETWEEN_FRAMES_NAME
The information field name that is written into image headers to indicate the time between frames of a multi-frame image.

See Also:
Constant Field Values

FRAME_OF_REFERENCE_UID_NAME

public static final java.lang.String FRAME_OF_REFERENCE_UID_NAME
The information field name that is written into image headers to indicate the frame of reference UID for the image position/orientation.

See Also:
Constant Field Values

IMAGE_POSITION_PATIENT_NAME

public static final java.lang.String IMAGE_POSITION_PATIENT_NAME
The information field name that is written into image headers to indicate the location of the first pixel of the image, in patient coordinates.

See Also:
Constant Field Values

IMAGE_ORIENTATION_PATIENT_NAME

public static final java.lang.String IMAGE_ORIENTATION_PATIENT_NAME
The information field name that is written into image headers to indicate the orientation (direction cosines) of the matrix of image pixels, in patient coordinates.

See Also:
Constant Field Values

PIXEL_SPACING_NAME

public static final java.lang.String PIXEL_SPACING_NAME
The information field name that is written into image headers to indicate the physical distance in the patient between the center of each pixel.

See Also:
Constant Field Values

PATIENT_POSITION_NAME

public static final java.lang.String PATIENT_POSITION_NAME
The information field name that is written into image headers to indicate the way in which the patient is positioned in the scanner.

See Also:
Constant Field Values

SLICE_THICKNESS_NAME

public static final java.lang.String SLICE_THICKNESS_NAME
The information field name that is written into image headers to indicate the thickness of an image slice.

See Also:
Constant Field Values

INTENSITY_RESCALE_SLOPE_NAME

public static final java.lang.String INTENSITY_RESCALE_SLOPE_NAME
The information field name that is written into image headers to indicate the intensity rescale slope.

See Also:
Constant Field Values

INTENSITY_RESCALE_INTERCEPT_NAME

public static final java.lang.String INTENSITY_RESCALE_INTERCEPT_NAME
The information field name that is written into image headers to indicate the intensity rescale intercept.

See Also:
Constant Field Values

INTENSITY_RESCALE_UNITS_NAME

public static final java.lang.String INTENSITY_RESCALE_UNITS_NAME
The information field name that is written into image headers to indicate the intensity rescale units.

See Also:
Constant Field Values

AUDIT_TRAIL_ACTION_TEXT

public static final java.lang.String AUDIT_TRAIL_ACTION_TEXT
A String used when composing audit trail information.

See Also:
Constant Field Values

MAXDIM

public static final int MAXDIM
The maximum dimensionality of an image.

See Also:
Constant Field Values

pixArray

protected PixArray pixArray
If non-null, pixel data held in this PixArray object.


randomAccessFile

protected java.io.RandomAccessFile randomAccessFile
If non-null, pixel data kept on disk and accessed via this RandomAccessFile. However, it isn't compulory to have access to the pixel data: if all the user wants is the image header info, both could be null.


mode

protected java.lang.String mode
The "mode" with which the image was opened, if a disk-file: either "r" or "rw".


DEFAULT_IMAGE_CLASS

public static final java.lang.Class DEFAULT_IMAGE_CLASS
The default image class to work with, if the user has no Preference.

Constructor Detail

MultiSliceImage

protected MultiSliceImage()
Default constructor for MultiSliceImage for use by sub-classes. MultiSliceImage Objects cannot be directly instantiated.

Method Detail

isModified

public boolean isModified()
Tests whether this this MultiSliceImage has been modified since instantiation.


setModified

public void setModified()
Sets the "modified" flag for this MultiSliceImage to indicate that it has been modified since instantiation.


getPreferredImageClass

public static java.lang.Class getPreferredImageClass()
Returns the MultiSliceImage class set in the user's Preferences.

Returns:
the MultiSliceImage class that has been set in the user's Preferences as the one that the user most often works with.

savePreferredImageClass

public static void savePreferredImageClass(java.lang.Class imageClass)
Saves the supplied class to the user's Preferences.

Parameters:
imageClass - the Class that the user most often works with, and which will be set as the default to use when this Class loads.

getSliceDim

protected int getSliceDim(int slice)
                   throws java.lang.IndexOutOfBoundsException
Throws:
java.lang.IndexOutOfBoundsException

setSuggestedFileName

public void setSuggestedFileName(java.lang.String name)
Sets a suggested file name for in-memory images that might be saved to disk later.

Parameters:
name - the suggested file name.

getSuggestedFileName

public java.lang.String getSuggestedFileName()
Description copied from interface: LoadableImage
Returns the suggested file name for in-memory images that are to be saved to disk.

Specified by:
getSuggestedFileName in interface LoadableImage
Returns:
the suggested file name, or null if not set.

getDims

public abstract int[] getDims()
                       throws java.lang.IllegalStateException
Returns the dimensions of this image.

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:
java.lang.IllegalStateException - if the dimensions are bad.

getByteOrder

protected abstract java.nio.ByteOrder getByteOrder()
Returns the byte order for this image.

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

getFileDataOffset

protected abstract int getFileDataOffset()
Returns the byte offset into the disk-based file format where pixel data begins.

Returns:
the byte offset to the start of pixel data for images that are written to disk.

setPixelXSize

public abstract void setPixelXSize(float width)
                            throws java.lang.IllegalArgumentException,
                                   java.io.IOException
Sets the pixel size in the x (horizontal) direction for this image.

Parameters:
width - the width of a pixel.
Throws:
java.lang.IllegalArgumentException - if the pixel width is not positive.
java.io.IOException - if and I/O error occurs.

setPixelYSize

public abstract void setPixelYSize(float height)
                            throws java.lang.IllegalArgumentException,
                                   java.io.IOException
Sets the pixel size in the y (vertical) direction for this image.

Parameters:
height - the height of a pixel.
Throws:
java.lang.IllegalArgumentException - if height is not positive.
java.io.IOException - if an I/O error occurs.
java.lang.IndexOutOfBoundsException - if the image doesn't have a dimensionality of at least 2.

setPixelZSize

public abstract void setPixelZSize(float thickness)
                            throws java.lang.IllegalArgumentException,
                                   java.io.IOException
Sets the pixel size in the z (slice) direction for this image.

Parameters:
thickness - the thickness of a pixel.
Throws:
java.lang.IllegalArgumentException - if thickness is not positive.
java.io.IOException - if an I/O error occurs.
java.lang.IndexOutOfBoundsException - if the image doesn't have a dimensionality of at least 3.

setTimeBetweenFrames

public abstract void setTimeBetweenFrames(float deltaT)
                                   throws java.lang.IllegalArgumentException,
                                          java.io.IOException
Sets the time between frames in a 4- or higher dimensional image.

Parameters:
deltaT - the time between frames (in seconds).
Throws:
java.lang.IllegalArgumentException - if deltaT is negative.
java.io.IOException - if an I/O error occurs.
java.lang.IndexOutOfBoundsException - if the image doesn't have a dimensionality of at least 4.

setTitle

public abstract void setTitle(java.lang.String newTitle)
                       throws java.io.IOException
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.

Parameters:
newTitle - the new title to be assigned to this image.
Throws:
java.io.IOException - if the title cannot be set.

setPatientName

public abstract void setPatientName(java.lang.String newName)
                             throws java.io.IOException
Attempts to set the patient name for this image. If new patient name String is longer than is allowed by the image format, then it is truncated before being applied. No exception occurs if the image format does not support patient name recording.
N.B. For disk-based images, the changes in the patient name will not be reflected on disk unless the close() method is called.

Parameters:
newName - the new patient name to be assigned to this image.
Throws:
java.io.IOException - if the patient name cannot be set.

setPatientID

public abstract void setPatientID(java.lang.String newID)
                           throws java.io.IOException
Sets the patient ID for this image. If the new patient ID String is longer than is allowed by the image format, then it is truncated before being applied. No exception occurs if the image format does not support patient ID recording.
N.B. For disk-based images, the changes in the patient ID will not be reflected on disk unless the close() method is called.

Parameters:
newID - the new patient ID to be assigned to this image.
Throws:
java.io.IOException - if the patient ID cannot be set.

setPatientDoB

public abstract void setPatientDoB(java.util.Date newDoB)
                            throws java.io.IOException
Sets the patient's date of birth for this image. No exception occurs if the image format does not support patient date of birth recording.
N.B. For disk-based images, the changes in the patient's birth date will not be reflected on disk unless the close() method is called.

Parameters:
newDoB - the new patient date of birth to be assigned to this image.
Throws:
java.io.IOException - if the patient date of birth cannot be set.

setScanDate

public abstract void setScanDate(java.util.Date newDate)
                          throws java.io.IOException
Sets the scan date/time for this image.
N.B. For disk-based images, the changes in the scan date will not be reflected on disk unless the close() method is called.

Parameters:
newDate - the new scan date/time to be assigned to this image.
Throws:
java.io.IOException - if the scan date cannot be set.

setPulseSequence

public abstract void setPulseSequence(java.lang.String seqName)
                               throws java.io.IOException
Sets the pulse sequence name for this image.
N.B. For disk-based images, the changes in the scanning sequence will not be reflected on disk unless the close() method is called.

Parameters:
seqName - the new name of the pulse sequence to be assigned to this image.
Throws:
java.io.IOException - if the pulse sequence name cannot be set.

setScanningSequence

public abstract void setScanningSequence(PulseSequenceType seqType)
                                  throws java.io.IOException
Sets the DICOM scanning sequence for this image.
N.B. For disk-based images, the changes in the scanning sequence will not be reflected on disk unless the close() method is called.

Parameters:
seqType - the new scanning sequence to be assigned to this image.
Throws:
java.io.IOException - if the scanning sequence cannot be set.

setSequenceVariant

public abstract void setSequenceVariant(PulseSequenceVariant seqVariant)
                                 throws java.io.IOException
Sets the DICOM scanning sequence variant for this image.
N.B. For disk-based images, the changes in the scanning sequence variant will not be reflected on disk unless the close() method is called.

Parameters:
seqVariant - the new scanning sequence variant to be assigned to this image.
Throws:
java.io.IOException - if the scanning sequence variant cannot be set.

setModality

public abstract void setModality(Modality modality)
                          throws java.io.IOException
Sets the modality with which this image was acquired. No exception occurs if the image format does not support modality recording.
N.B. For disk-based images, the changes in the modality will not be reflected on disk unless the close() method is called.

Parameters:
modality - the new imaging modality to be assigned to this image.
Throws:
java.io.IOException - if modality cannot be set.

getModality

public abstract Modality getModality()
Returns the modality with which this image was acquired.

Specified by:
getModality in interface LoadableImage
Returns:
the modality with which this image was collected. Returns Modality.UNKNOWN if the modality cannot be found of is not one of the recognised modalities.

setScanTR

public abstract void setScanTR(float TR)
                        throws java.io.IOException
Sets the scan repetition time for this image. No exception occurs if the image format does not support scan TR recording.
N.B. For disk-based images, the changes in the scan TR will not be reflected on disk unless the close() method is called.

Parameters:
TR - the new scan TR to be assigned to this image.
Throws:
java.io.IOException - if the scan TR cannot be set.

setScanTI

public abstract void setScanTI(float TI)
                        throws java.io.IOException
Sets the scan inversion time for this image. No exception occurs if the image format does not support scan TI recording.
N.B. For disk-based images, the changes in the scan TI will not be reflected on disk unless the close() method is called.

Parameters:
TI - the new scan TI to be assigned to this image.
Throws:
java.io.IOException - if the scan TI cannot be set.

setScanTE

public abstract void setScanTE(float TE)
                        throws java.io.IOException
Sets the scan echo time for this image, for single-echo-time images. No exception occurs if the image format does not support scan TE recording.
N.B. For disk-based images, the changes in the scan TE will not be reflected on disk unless the close() method is called.

Parameters:
TE - the new scan TE to be assigned to this image.
Throws:
java.io.IOException - if the scan TE cannot be set.

setScanTE

public abstract void setScanTE(float TE,
                               int slice)
                        throws java.io.IOException
Sets the scan echo time for one slice of this image. No exception occurs if the image format does not support a scan TE recording.
N.B. For disk-based images, the changes in the scan TE will not be reflected on disk unless the close() method is called.

Parameters:
TE - the new scan TE to be assigned to this image.
slice - the slice number for which to set the echo time.
Throws:
java.io.IOException - if the scan TE cannot be set.

setFlipAngle

public abstract void setFlipAngle(float flipAngle)
                           throws java.io.IOException
Sets the excitation pulse flip angle for this image. No exception occurs if the image format does not support flip angle recording.
N.B. For disk-based images, the changes in the scan flip angle will not be reflected on disk unless the close() method is called.

Parameters:
flipAngle - the new scan flip angle to be assigned to this image.
Throws:
java.io.IOException - if the scan flip angle cannot be set.

setDWbValue

public abstract void setDWbValue(float bValue,
                                 int slice)
                          throws java.io.IOException
Sets the diffusion-weighting b-value for one slice of this image. No exception occurs if the image format does not support recording the b-value.
N.B. For disk-based images, the changes in the b-value will not be reflected on disk unless the close() method is called.

Parameters:
bValue - the new b-value to be assigned to this image.
slice - the slice number for which to set the b-value.
Throws:
java.io.IOException - if the scan b-value cannot be set.

setDWGradientVector

public abstract void setDWGradientVector(javax.vecmath.Vector3f gradVec,
                                         int slice)
                                  throws java.io.IOException
Sets the diffusion-weighting gradient vector for one slice of this image. No exception occurs if the image format does not support recording the gradient vector.
N.B. For disk-based images, the changes in the gradient vector will not be reflected on disk unless the close() method is called.

Parameters:
gradVec - the new gradient vector to be assigned to this image.
slice - the slice number for which to set the gradient vector.
Throws:
java.io.IOException - if the scan gradient vector cannot be set.

setDWBMatrix

public abstract void setDWBMatrix(float[] bMatrix,
                                  int slice)
                           throws java.io.IOException
Sets the diffusion-weighting B-matrix for one slice of this image. No exception occurs if the image format does not support recording the B-matrix.
N.B. For disk-based images, the changes in the B-matrix will not be reflected on disk unless the close() method is called.

Parameters:
bMatrix - the new B-matrix to be assigned to this image.
slice - the slice number for which to set the B-matrix.
Throws:
java.io.IOException - if the scan B-matrix cannot be set.

setPatientPosition

public abstract void setPatientPosition(PatientPosition position)
                                 throws java.io.IOException
Sets the position in which the patient is lying in the scanning equipment for this MultiSliceImage.

Parameters:
position - the position in which the patient is lying in the scanning equipment. e.g. PatientPosition.HFS (head-first supine).
Throws:
java.io.IOException - if the patient position cannot be set for this image.

setPixelSpacing

public abstract void setPixelSpacing(float[] spacing)
                              throws java.io.IOException,
                                     java.lang.IndexOutOfBoundsException
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.

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:
java.io.IOException - if the pixel spacing cannot be set for this image.
java.lang.IndexOutOfBoundsException - if spacing does not have the correct dimensions.

setSliceThickness

public abstract void setSliceThickness(float thickness)
                                throws java.io.IOException
Sets the slice thickness (in mm). This method is necessary because the slice thickness may not be the same as the inter-slice pixel spacing, if there is a gap between slices.

Parameters:
thickness - the slice thickness in mm.
Throws:
java.io.IOException - if the slice thickness cannot be set for this image, or if the slice thickness is negative.

setImagePositionPatient

public abstract void setImagePositionPatient(javax.vecmath.Point3f position,
                                             int slice)
                                      throws MultiSliceImageException
Sets the coordinates of the center of the first pixel of the image, in mm, in patient (LPS) coordinates, for one slice of this image.

Parameters:
position - the Left,Posterior,Superior (LPS) coordinates of the first pixel of this specified slice in the image data matrix.
slice - the slice for which to set the position.
Throws:
MultiSliceImageException - if the position cannot be set for this image, if position does not have the correct dimensions, or if the slice number is out of range.

setImageOrientationPositionPatient

public abstract void setImageOrientationPositionPatient(javax.vecmath.Vector3f[] dirCos,
                                                        javax.vecmath.Point3f position,
                                                        boolean force)
                                                 throws java.io.IOException,
                                                        java.lang.IndexOutOfBoundsException
Sets the direction cosines of the row, column and slice directions of the image, 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.

If the orientation or position cannot be set for this image, this method does not report an error.

Parameters:
dirCos - the direction cosines of the image row, column and (optionally) slice directions respectively in Left,Posterior,Superior (LPS) coordinates. If dirCos is null, this method will attempt to clear any orientation information, if that is supported by the image format.
position - the Left,Posterior,Superior (LPS) coordinates of the centre of the first pixel in the image data matrix. If position is null, this method will attempt to clear any positional information, if that is supported by the image format.
force - if true, this method will force the orientation and position to be set as requested, regardless of the user Preferences. This can be useful if you read the orientation from an existing image, and you want to set the orientation exactly the same in a new image.
Throws:
java.lang.IndexOutOfBoundsException - if the dirCos array does not have the correct length.
java.io.IOException - if an I/O error occurs.

getMostLikePlane

public MostLikePlane getMostLikePlane()
Description copied from interface: LoadableImage
Returns the imaging plane that this image is "most like".

Specified by:
getMostLikePlane in interface LoadableImage
Returns:
the plane that is "most" like the imaging plane for this image. Returns MostLikePlane.UNKNOWN if the imaging plane cannot be determined, or if the image does not contain a set of parallel slices.

setImageOrientationPatient

public abstract void setImageOrientationPatient(javax.vecmath.Vector3f[] dirCos,
                                                int slice)
                                         throws java.lang.IndexOutOfBoundsException
Sets the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient (LPS) coordinates.

If the orientation cannot be set for this image, this method does nothing.

Parameters:
dirCos - the direction cosines of the image row, column and (optionally) slice directions respectively in Left,Posterior,Superior (LPS) coordinates.
slice - the slice for which to set the orientation.
Throws:
java.lang.IndexOutOfBoundsException - if the cosines array does not have the correct dimensions.

getFrameOfReferenceUID

public com.xinapse.dicom.Uid getFrameOfReferenceUID()
Description copied from interface: LoadableImage
Returns the frame of reference UID that uniquely identifies the frame of reference for an image.

Specified by:
getFrameOfReferenceUID in interface LoadableImage
Returns:
the frame of reference UID, or null if this image does not have frame of reference UID.

setIntensityRescale

public abstract void setIntensityRescale(float[] rescale)
                                  throws MultiSliceImageException,
                                         java.io.IOException
Sets the values m and b in the relationship between pixel intensity (I) values and the output units specified in setRescaleUnits() in the expression:
Output units = m*I + b.

Parameters:
rescale - a float[] of length 2 where the first element is m and the second is b.
Throws:
MultiSliceImageException - if a single rescaling cannot be set for this image.
java.io.IOException - if an I/O error occurs.

setIntensityRescale

public abstract void setIntensityRescale(float[] rescale,
                                         int slice)
                                  throws MultiSliceImageException,
                                         java.io.IOException
Sets the values m and b in the relationship between pixel intensity (I) values and the output units specified in setRescaleUnits() in the expression:
Output units = m*I + b, for a particular slice.

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 - if a rescaling cannot be set for the specified slice of this image.
java.io.IOException - if an I/O error occurs.

setRescaleUnits

public abstract void setRescaleUnits(java.lang.String unitsString)
                              throws java.io.IOException
Sets the output units of Intensity Rescale Slope and Intensity Rescale Intercept, retrieved by getIntensityRescale().

Parameters:
unitsString - a String describing the physical meaning of the pixel intensity units. If the unitsString is null, future calls to getRescaleUnits() will return the String "arbitrary units".
Throws:
java.io.IOException - if the rescaling units cannot be set for this image.

write

public abstract java.lang.String write(java.lang.String filename)
                                throws java.io.IOException,
                                       MultiSliceImageException
Writes this image to a disk-file given by the name.

Parameters:
filename - the file name.
Returns:
the actual file name with which the image was written, including any extension added by the particular image format.
Throws:
MultiSliceImageException - if the image cannot be written.
java.io.IOException - if an I/O error occurs.

write

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

Parameters:
filename - the file name. If filename is null, then an in-memory MultiSliceImage will be returned.
c - the class of image to be written (e.g. com.xinapse.multisliceimage.UNC.UNCImage).
Returns:
the MultiSliceImage that is written.
Throws:
MultiSliceImageException - if the image cannot be written.
java.io.IOException - if an I/O error occurs.

isImage

public static boolean isImage(java.io.File f)
                       throws java.io.FileNotFoundException
Tests whether the supplied File refers to a MultSliceImage file.

Parameters:
f - the java.io.File to be tested.
Returns:
true if the supplied File refers an image file; false otherwise.
Throws:
java.io.FileNotFoundException - if the file does not exist.

getInstance

public abstract MultiSliceImage getInstance(java.lang.Class c,
                                            int nSlices)
                                     throws java.io.IOException,
                                            MultiSliceImageException
Creates a new in-memory MultiSliceImage with the MultiSliceImage class given by the argument, 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.

Parameters:
c - 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:
MultiSliceImageException - if the image cannot be written.
java.io.IOException - if an I/O error occurs.

getInstance

public MultiSliceImage getInstance(int nSlices)
                            throws java.io.IOException,
                                   MultiSliceImageException
Creates a new in-memory MultiSliceImage, based on this MultiSliceImage, but 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.

Parameters:
nSlices - the number of slices in the new image.
Returns:
the new MultiSliceImage that is created.
Throws:
MultiSliceImageException - if the image cannot be created.
java.io.IOException - if an I/O error occurs.

getSimpleName

public abstract java.lang.String getSimpleName()
Returns the simple name for this type of image - the String that should be seen by the users to identify this type of image.

Returns:
a simple name for the image type.

getClasses

public static java.lang.Class[] getClasses()
Returns an array of classes that are known to be sub-classes of MultiSliceImage.

Returns:
an array of Class Objects of all known sub-classes of MultiSliceImage.

exists

public static boolean exists(java.lang.String filename)
Tests whether a MultiSliceImage with the given name already exists on disk. Analyze/NIFTI file extensions are handled in a smart fashion.

Parameters:
filename - the name of the image file to test for existence.
Returns:
true if a disk file with the specified file name exists on disk; false otherwise.

getPreview

public static PreviewIcon getPreview(java.io.File f)
Gets a PreviewIcon for a LoadableImage contained within the supplied File.

Parameters:
f - the image file for which to get a preview.
Returns:
a PreviewIcon if the disk file contains an image; null otherwise.

getDateFormat

public static java.text.DateFormat getDateFormat()

getScanDateFormat

public static java.text.DateFormat getScanDateFormat()
Returns the java.text.DateFormat with which a scan date should be formatted.

Returns:
the java.text.DateFormat with which a scan date should be formatted.

getInstance

public static MultiSliceImage getInstance(java.lang.String filename)
                                   throws MultiSliceImageException,
                                          java.io.IOException
Returns an instance of an image class gotten from a file. This method will auto-detect the sub-class of MultiSliceImage that is to be instantiated. The file will be opened read-only.

Parameters:
filename - the name of the file from which the image data will be read.
Returns:
the new MultiSliceImage that is gotten from file.
Throws:
MultiSliceImageException - if the file does not supply data that gives a valid MultiSliceImage.
java.io.IOException - if the image seems valid, but the file supplies imcomplete data.

getInstance

public static MultiSliceImage getInstance(java.lang.String filename,
                                          java.lang.String mode)
                                   throws java.io.FileNotFoundException
Returns an instance of an image class gotten from a file, opened according to the mode. The mode argument must either be equal to "r" or "rw", indicating that the file is to be opened for input only or for both input and output, respectively. This method will auto-detect the sub-class of MultiSliceImage that is to be instantiated.

Parameters:
filename - the name of the file from which the image data will be read.
mode - the access mode.
Returns:
the MultiSliceImage that is gotten from file.
Throws:
java.io.FileNotFoundException - if an image with the supplied name cannot be opened.

getInstance

public static MultiSliceImage getInstance(java.awt.Component component,
                                          MultiSliceImage templateImage)
                                   throws java.io.IOException,
                                          InvalidImageException,
                                          MultiSliceImageException
Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created. The user is asked to select a file into which the new image instance will be created. The new image will be of the same class as the template image, and will be disk-based.

Parameters:
component - used as the parent component for the ImageFileChooser created to select the new image name. May be null.
templateImage - the MultiSliceImage instance to be used as a template for creating the new image.
Returns:
a MultiSliceImage object of the required class, identical in properties and pixel values to supplied template image.
Throws:
MultiSliceImageException - if the new image cannot be created.
java.io.IOException - if an I/O error occurs.
InvalidImageException

getInstance

public static MultiSliceImage getInstance(java.awt.Component component,
                                          MultiSliceImage templateImage,
                                          int nSlices)
                                   throws java.io.IOException,
                                          MultiSliceImageException
Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created. The number of slices in the newly-created image may be altered from the original. The user is asked to select a file into which the new image instance will be created. The new image will be of the same class as the template image, and will be disk-based. 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.

Parameters:
component - used as the parent component for the ImageFileChooser created to select the new image name. May be null.
templateImage - the MultiSliceImage instance to be used as a template for creating the new image.
nSlices - the number of slices in the new image.
Returns:
a MultiSliceImage object of the required class, identical in properties and pixel values to supplied template 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.
Throws:
MultiSliceImageException - if the new image cannot be created.
java.io.IOException - if an I/O error occurs.

getInstance

public static MultiSliceImage getInstance(java.awt.Component component,
                                          MultiSliceImage templateImage,
                                          java.lang.Class outputImageClass)
                                   throws java.io.IOException,
                                          InvalidImageException,
                                          MultiSliceImageException
Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created. The class of the output image to be created is given by the third argument, and must be one of the MultiSliceImage sub-classes. The user is asked to select a file into which the new image instance will be created, and the new image will be disk-based.

Parameters:
component - used as the parent component for the ImageFileChooser created to select the new image name. May be null.
templateImage - the MultiSliceImage instance to be used as a template for creating the new image.
outputImageClass - the class of the output image, which must be one of the MultiSliceImage sub-classes.
Returns:
a MultiSliceImage object of the required class, as close to the supplied template image as is possible within the constraints imposed by the types of image.
Throws:
MultiSliceImageException - if the new image cannot be created.
java.io.IOException - if an I/O error occurs.
InvalidImageException

getInstance

public static MultiSliceImage getInstance(MultiSliceImage templateImage,
                                          java.lang.Class outputImageClass,
                                          int nSlices)
                                   throws java.io.IOException,
                                          MultiSliceImageException
Returns an instance of an image class using the supplied MultiSliceImage as a template for the image to be created. The class of the output image to be created is given by the second argument, and must be one of the MultiSliceImage sub-classes. The number of slices in the newly-created image may be altered from the original. An in-memory image is created with the name given by the supplied File. If the number of slices requested for the new image 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.

Parameters:
templateImage - the MultiSliceImage instance to be used as a template for creating the new image.
outputImageClass - the class of the output image, which must be one of the MultiSliceImage sub-classes.
nSlices - the number of slices in the new image.
Returns:
a MultiSliceImage object of the required class, as close to the supplied template image as is possible within the constraints imposed by the types of 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.
Throws:
MultiSliceImageException - if the new image cannot be created.
java.io.IOException - if an I/O error occurs.

getInstance

public static MultiSliceImage getInstance(MultiSliceImage templateImage,
                                          int nSlices)
                                   throws java.io.IOException,
                                          MultiSliceImageException
Returns an in-memory instance of an image class using the supplied MultiSliceImage as a template for the image to be created. The new image will be the same class as the template image. The number of slices in the new image may be altered from the original. 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 .

Parameters:
templateImage - the MultiSliceImage instance to be used as a template for creating the new image.
nSlices - the number of slices in the new image.
Returns:
a memory-based MultiSliceImage, as close to the supplied template image as is possible within the constraints imposed by (possibly) changing the number of slices. 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.
Throws:
MultiSliceImageException - if the new image cannot be created.
java.io.IOException - if an I/O error occurs.

deleteImage

public static boolean deleteImage(java.lang.String filename,
                                  java.lang.Class c)
Attempts to delete an image of the given Class with the given name.

Parameters:
filename - the name of the image file that is to be deleted.
Returns:
true if the image file is successfully deleted, or if the image file did not exist in the first place.

getPix

public java.lang.Object getPix()
                        throws InvalidImageException
Returns all pixel values from this image. The pixel values are returned in the order in which they are stored internally.

Specified by:
getPix in interface LoadableImage
Returns:
a one-dimensional array of pixel values of the correct type for this image, cast to an Object.
Throws:
InvalidImageException - if the pixel values cannot be gotten.

getPix

public java.lang.Object getPix(boolean radiological)
                        throws InvalidImageException
Returns all pixel values from this image.

Specified by:
getPix in interface LoadableImage
Parameters:
radiological - true if a standard radiological orientation of the array of pixels is required. Standard radiological orientation is:
  • For axial images, increasing left coordinate with column number, and increasing posterior coordinate with row number.
  • For coronal images, increasing left coordinate with column number, and increasing inferior coordinate with row number.
  • For sagittal images, increasing posterior coordinate with column number, and increasing inferior coordinate with row number.
If false, the pixels are returned without any consideration of the orientation.
Returns:
a one-dimensional array of pixel values of the correct type for this image, cast to an Object.
Throws:
InvalidImageException - if the pixel values cannot be gotten.

getPix

public java.lang.Object getPix(int[] lowIdx,
                               int[] highIdx)
                        throws InvalidImageException
Returns pixel values from this image. The lowIdx and highIdx arrays should have at least a number of elements at least equal to the dimensionality of the image, and the elements specifing the pixel number range for each dimension. For example, if an image has 3 dimensions, and dimensions of {5, 256, 256}, then pixels for the middle three slices will be returned by setting lowIdx to {1, 0, 0} and highIdx to {4, 255, 255}.

Parameters:
lowIdx - an array of int specifying the low index of pixel values to get.
highIdx - an array of int specifying the high index of pixel values to get.
Returns:
a one-dimensional array of pixel values of the correct type for this image, cast to an Object.
Throws:
InvalidImageException - if the indices supplied extend beyond the image, or the pixel values cannot be gotten for other reasons.

getPix

public java.lang.Object getPix(java.lang.Object array,
                               int[] lowIdx,
                               int[] highIdx)
                        throws InvalidImageException
Get pixel values from this image into a specified array. array is a 1-dimensional array of the correct type of element for this image into which pixel values will be copied; it must be cast to an Object and must have enough elements to contain all the pixel values requested. The lowIdx and highIdx int arrays should have at least a number of elements at least equal to the dimensionality of the image, and the elements specifing the pixel number range for each dimension. For example, if an image has 3 dimensions, and dimensions of {5, 256, 256}, then pixels for the middle three slices will be returned by setting lowIdx to {1, 0, 0} and highIdx to {4, 255, 255}.

Parameters:
array - a 1-dimensional array of length at least enough to contain all the pixel values, and of the correct java primitive data type.
lowIdx - an array of int specifying the low index of pixel values to get.
highIdx - an array of int specifying the high index of pixel values to get.
Returns:
a one-dimensional array of pixel values of the correct type for this image, cast to an Object.
Throws:
InvalidImageException - if the indices supplied extend beyond the image, if the supplied array is of the wrong primitive data type, or if the pixel values cannot be gotten for other reasons.

putPix

public void putPix(java.lang.Object array)
            throws InvalidImageException
Put pixel values from a specified array to this image. array is an array of the correct type of element for this image from which pixel values will be copied; it must be cast to an Object and must have the correct number of elements. The pixel values are set in the order in which they are stored internally.

Parameters:
array - a 1-dimensional array of pixel values of the correct java primitive data type to put to the image.
Throws:
InvalidImageException - if the pixel values are of the wrong primitive data type, or cannot be put for other reasons.

putPix

public void putPix(java.lang.Object array,
                   boolean radiological)
            throws InvalidImageException
Put pixel values from a specified array to this image. array is an array of the correct type of element for this image from which pixel values will be copied; it must be cast to an Object and must have the correct number of elements.

Parameters:
array - a 1-dimensional array of pixel values of the correct java primitive data type to put to the image.
radiological - true if the pixels have a standard radiological orientation Standard radiological orientation is:
  • For axial images, increasing left coordinate with column number, and increasing posterior coordinate with row number.
  • For coronal images, increasing left coordinate with column number, and increasing inferior coordinate with row number.
  • For sagittal images, increasing posterior coordinate with column number, and increasing inferior coordinate with row number.
If false, the pixels are put without any consideration of the orientation.
Throws:
InvalidImageException - if the pixel values are of the wrong primitive data type, or cannot be put for other reasons.

putPix

public void putPix(java.lang.Object array,
                   int[] lowIdx,
                   int[] highIdx)
            throws InvalidImageException
Put pixel values from a specified array to this image. array is an array of the correct type of element for this image from which pixel values will be copied; it must be cast to an Object and must have the right number of elements to copy to the pixel values requested. The lowIdx and highIdx int arrays should have at least nDim elements, and the elements specify the pixel number range for each dimension. For example, if an image has nDim = 3, and dims[] = {5, 256, 256}, then pixels for the middle slices 4 will be returned by setting lowIdx to {1, 0, 0} and highIdx to {4, 255, 255}.

Parameters:
array - a 1-dimensional array of pixel values of the correct java primitive data type to put to the image.
lowIdx - an array of int specifying the low index of pixel values to put.
highIdx - an array of int specifying the high index of pixel values to put.
Throws:
InvalidImageException - if the indices supplied extend beyond the image, the pixel values are of the wrong primitive data type or cannot be put for other reasons.

getPix

public java.lang.Object getPix(int[] pixIdx)
                        throws InvalidImageException
Returns a single pixel value from the image.

Parameters:
pixIdx - an int[] of length at least equal to nDim for this image where each element corresponds to an index to the pixel in each dimension. The first element of pixIdx refers to the slowest-varying dimension, and the last relevant element refers to the fastest-varuing dimension. For example, for a 3-D image, pixIdx[0] refers to the slice dimension, and pixIdx[2] refers to the column dimension.
Returns:
the pixel value as a java Object cast from the appropriate class. For example, for a short int image, the pixel will be a Short cast to Object.
Throws:
InvalidImageException - if the indices are inappropriate for this image, or if the pixel data is not available.

putPix

public java.lang.Object putPix(java.lang.Object pix,
                               int[] pixIdx)
                        throws InvalidImageException
Puts a single pixel value to the image.

Parameters:
pix - the pixel value to put, as a suitable Object.
pixIdx - an int[] of length at least equal to nDim for this image where each element corresponds to an index to the pixel in each dimension. The first element of pixIdx refers to the slowest-varying dimension, and the last relevant element refers to the fastest-varuing dimension. For example, for a 3-D image, pixIdx[0] refers to the slice dimension, and pixIdx[2] refers to the column dimension.
Returns:
the same pixel as supplied. Pixel must be of the correct type cast to an Object. For example, for a short int image, the pixel will be a Short cast to Object.
Throws:
InvalidImageException - if the indices are inappropriate for this image, if the supplied pixel is of the wrong Class, or if the pixel value cannot be written to the image.

reorientRadiological

public static void reorientRadiological(LoadableImage image,
                                        java.lang.Object pix)
Reorients a set of pixels for an image so that they will be presented in standard radiological orientation. This is: If the orientation of the image slice cannot be found, then nothing is done.

Parameters:
image - the LoadableImage for which the pixels are to be reoriented.
pix - the array of pixels to reorient. The reorientation is done in-place.

setOrientationPositionRadiological

public static void setOrientationPositionRadiological(javax.vecmath.Vector3f[] orientation,
                                                      javax.vecmath.Point3f position,
                                                      int nCols,
                                                      int nRows,
                                                      float pixelXSize,
                                                      float pixelYSize)
Reorientates the image orientation vectors, and repositions an image position so that the positions and orientations refer to blocks of image pixels that have been gotten in an anatomical orientation.

This method works out the way in which an image slice with the supplied orientation and position will be presented radiologically, and sets the orientation and position "in place" correctly for the image slice as presented radiologically.

Parameters:
orientation - the current orientation of the image slice.
position - the current position of the image slice.
nCols - the number of columns in the image.
nRows - the number of rows in the image.
pixelXSize - the pixel size along a row.
pixelYSize - the pixel size down a column.

getNPixels

public static int getNPixels(int nDim,
                             int[] dims)
                      throws MultiSliceImageException
Returns the total number of picture elements for a MultiSliceImage with the given dimensions.

Parameters:
nDim - the dimensionality of the image.
dims - the size of the image in each dimension.
Returns:
the total number of pixels for an image with the given dimensions.
Throws:
MultiSliceImageException

getSlice

public java.lang.Object getSlice(int slice)
                          throws InvalidImageException
Returns all the pixels for a two-dimensional slice of this image, as a 1-dimensional array of primitive values. The pixels values are ordered so that the first pixel in the returned array should be displayed at the top left corner of the 2-D image array, when viewed in standard radiological orientation.

Specified by:
getSlice in interface LoadableImage
Parameters:
slice - the slice number. Slices numbered from zero up to the total number of slices in this image (-1), regardless of the dimensionality of the image.
Returns:
an array of the correct primitive data type for this image.
Throws:
InvalidImageException - if the slice number is invalid for this image.

getSlice

public java.lang.Object getSlice(java.lang.Object array,
                                 int slice)
                          throws InvalidImageException
Returns all the pixels for a two-dimensional slice of this image, as a 1-dimensional array of primitive values. The pixels values are ordered so that the first pixel in the returned array should be displayed at the top left corner of the 2-D image array, when viewed in standard radiological orientation.

If the supplied array is null, a new array will be created and returned.

Parameters:
slice - the slice number. Slices numbered from zero up to the total number of slices in this image (-1), regardless of the dimensionality of the image.
array - an array of suitable length and of a suitable primitive data type for this image.
Returns:
an array of the correct primitive data type for this image.
Throws:
InvalidImageException - if the slice number is invalid for this image,

putSlice

public void putSlice(java.lang.Object array,
                     int slice)
              throws InvalidImageException
Puts the pixel values to one slice of an n-dimensional image, where n > 1.

N.B.Whenever the radiological orientation of the image can be determined, this method sets pixel values such that when the slice is viewed on-screen, the first pixel in the array belongs at the top left of the screen, and the last pixel in the array belongs at the bottom right of the screen. This is regardless of the sub-class of image (for example., the flipping of Analyze images is taken care of by this method).

Parameters:
array - a 1-dimensional array of the correct primitive java data type for this image, with dimensions [nRows * nCols] containing the pixel values to put.
slice - the slice number. Must be 0 for a 2-dimensional image or from 0 to dims[0]-1 for a 3-dimensional image.
Throws:
InvalidImageException - if the image does not have the right dimensionality, if the slice number is inappropriate for this image, if the array is not of the correct primitive data type for this image, or if there is a problem accessing the pixel values.

setNativeColourMapping

public abstract void setNativeColourMapping(ColourMapping colourMapping)
                                     throws java.io.IOException
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.

Parameters:
colourMapping - the new ColourMapping to be assigned to this image.
Throws:
java.io.IOException - if the ColourMapping cannot be set for this image.

setMinMax

public void setMinMax(int[] minmax)
               throws MultiSliceImageException
Sets the min and max pixel values for this image. It is up to the caller to ensure that the values supplied are correct at the time they are written to the image. Any subsequent changes to the image pixel values may cause either the values returned by getMin() and getMax() to be incorrect, or cause these methods to throw a MultiSliceImageException.

Parameters:
minmax - an int array of length at least 2, where the first element is the minimum pixel value in the image, and second element is the maximum pixel value in the image.
Throws:
MultiSliceImageException - if the array supplied is unsuitable, or the values cannot be set.

setMinMax

public abstract void setMinMax(int min,
                               int max)
                        throws MultiSliceImageException
Sets the min and max pixel values for this image. It is up to the caller to ensure that the values supplied are correct at the time they are written to the image. Any subsequent changes to the image pixel values may cause either the values returned by getMin() and getMax() to be incorrect, or cause these methods to throw a MultiSliceImageException.

Parameters:
min - the minimum pixel value in the image.
max - the maximum pixel value in the image.
Throws:
MultiSliceImageException - if the array supplied is unsuitable, or the values cannot be set.

checkMinMax

public static void checkMinMax(int min,
                               int max,
                               PixelDataType dataType)
                        throws MultiSliceImageException
Checks the integrity of the minimum and maximum pixel values taking into account the data type of the image.

Parameters:
min - the putative minimum pixel value.
max - the putative maximum pixel value.
dataType - the PixelDataType for the image.
Throws:
MultiSliceImageException - if the min/max values are unsuitable for this image.

set3DBlockParameters

public void set3DBlockParameters()
                          throws java.io.IOException,
                                 InvalidImageException
For an image which contains multiple slices with all slices parallel and regularly-spaced, this method will modify the image position (patient coords), image orientation (patient coords) and pixel spacing (pixel sizes) according to the block.

Images that do not consist of a single block of parallel, equally-spaced slices are unaffeted by this method.

Throws:
MultiSliceImageException - if the image information cannot be modified.
java.io.IOException
InvalidImageException

getROIs

public java.util.List<ROI> getROIs()
Description copied from interface: LoadableImage
Returns a List of ROIs that are stored with the image.

Specified by:
getROIs in interface LoadableImage
Returns:
null if there are no ROIs stored with the image.

crop

public MultiSliceImage crop(int[][] cropDims,
                            MonitorWorker worker,
                            boolean verbose)
                     throws InvalidImageException,
                            CancelledException
Crops an existing MultiSliceImage. The cropDims array specifies the range of pixel indices in each dimension of the image from which to select a block of pixels.

Parameters:
cropDims - the high and low indices (referenced from zero) of samples in each of the dimensions of the image. cropDims must have the same number of elements as there are dimensions in this image, and each element must be an array of length 2. The first element of each array specifies the low pixel index for that dimension, and the second element of the array specifies the high pixel index to select for the cropped image. The column dimension is the last array element; the row dimension is the next-to-last; the slice dimension is the second-from-last etc.
worker - if non-null, a ProgressMonitor will be created, showing the progress of the cropping.
verbose - if true, progress messages will be written to System.out.
Returns:
a new in-memory MultiSliceImage of the same class as this MultiSliceImage, but cropped to the specified range of pixels.
Throws:
InvalidImageException - if any of the indices is less than zero, or greater than the number of samples, or if the size of the cropDims array is incorrect for this image.
CancelledException - if cropping is cancelled via the ProgressMonitor that may pop up.

pad

public MultiSliceImage pad(int[] padDims,
                           MonitorWorker worker,
                           boolean verbose)
                    throws InvalidImageException,
                           CancelledException
Pads an existing MultiSliceImage with zero-intensity pixels around the edge of the image. The padDims array specifies the number of samples in each dimension of the padded image. The zero-intensity pixels are distributed as evenly as possible to either side of the current field of view (within the constrains imposed by odd/even numbers of pixel samples).

Parameters:
padDims - the number of samples in each dimension of the image for the padded image. padDims must have the same number of elements as there are dimensions in this image. The column dimension is the last array element; the row dimension is the next-to-last; the slice dimension is the second-from-last etc. If any value is less than the number of samples in the current image, then the number of samples in that dimension is unchanged in the new image.
worker - if non-null, a ProgressMonitor will be created, showing the progress of the padding.
verbose - if true, progress messages will be written to System.out.
Returns:
a new in-memory MultiSliceImage of the same class as this MultiSliceImage, but padded to the specified number of of pixel samples.
Throws:
InvalidImageException - if the size of the padDims array is incorrect for this image.
CancelledException - if padding is cancelled via the ProgressMonitor that may pop up.

reorient

public MultiSliceImage reorient(MostLikePlane newOrientation,
                                MostLikePlane currentOrientation,
                                java.lang.Boolean slicesAreReversed,
                                MonitorWorker worker,
                                boolean verbose)
                         throws InvalidImageException,
                                CancelledException
Reorients an existing MultiSliceImage. The newOrientation sets the orientation of the reoriented image. If non-null, currentOrientation specifies the orientation of this image. If currentOrientation is null, this method will try to determine the orientation of this image.

Parameters:
newOrientation - the MostLikePlane of the required new orientation.
currentOrientation - the MostLikePlane of the current orientation, or null to force an attempt to determine the orientation automatically.
slicesAreReversed - if non-null, specifies whether the slices are in reverse order compared to standard radiological order (which is:
  • axial: increasing superior coordinate with slice number
  • coronal: increasing posterior coordinate with slice number
  • sagittal: increasing left coordinate with slice number
If null, the slice order is determined from the image header.
worker - if non-null, a ProgressMonitor will be created, showing the progress of the reorientation.
verbose - if true, progress messages will be written to System.out.
Returns:
a new in-memory MultiSliceImage of the same class as this MultiSliceImage, but reoriented to the specified new orientation.
Throws:
InvalidImageException - if currentOrientation is null, and the orientation of this image cannot be determined.
CancelledException - if reorienting is cancelled via the ProgressMonitor that may pop up.

autoResample

public MultiSliceImage autoResample(int maxNVoxels,
                                    SubSampleType subSampleType,
                                    boolean allowSliceResample,
                                    boolean verbose)
                             throws InvalidImageException,
                                    CancelledException
Automatically resamples this image so that the resulting resampled image has no more than the given maximum number of voxels.

The numbers of samples will be calculated to give a more isotropic resolution. The algorithm will reduce the number of samples (if necessary) in any or all dimensions so that the resulting image has no more than the specified number of voxels, but the number of samples in any direction will never be increased to try to achieve isotropic resolution.

The number of voxels may be less than the maximum because the resulting image will always have the same field of view as this image, and the number of samples in each dimension must (of course) be a whole number.

Resampling of the fourth dimension of 4-D images does not take place, only of the three spatial dimensions. Images with dimensionality greater than 4 may not ne resampled with this method.

Parameters:
maxNVoxels - maximum number of voxels allowed in the resampled image.
subSampleType - the type of sub-sampling to be used if the pixel size is increased in any dimension.
allowSliceResample - if true, resampling of pixels in the slice direction is allowed; if false, resampling in the slice direction is disallowed.
verbose - if true, progress messages will be written to System.out.
Returns:
a resampled image with no more than the specified maximum number of voxels, or the original image if it already has fewer voxels than the specified maximum.
Throws:
InvalidImageException - if the image dimensionality is greater than 4. or equal to zero, or if the length of the newDims array is incorrect for this image.
CancelledException - if resampling is cancelled via the ProgressMonitor that may pop up.

reSample

public MultiSliceImage reSample(int[] newDims,
                                InterpolationType interpolationType,
                                SubSampleType subSampleType,
                                MonitorWorker worker,
                                boolean verbose)
                         throws InvalidImageException,
                                CancelledException
Resamples an existing MultiSliceImage to have different numbers of pixels. The newDims array specifies the new number of pixels in each dimension of the image.

Parameters:
newDims - the number of samples in each of the dimensions of the image. newDims must have the same number of elements as there are dimensions in this image. The integer in each element of the array specifies the number of samples in each dimension for the resampled image. The column dimension is the last array element; the row dimension is the next-to-last; the slice dimension is the second-from-last, and the time dimension is the third-from-last. Any dimensions that are below the time dimension are ignored, and no resampling will occur in these dimensions.
interpolationType - the type of interpolation to used if the number of samples increases in any dimension.
subSampleType - the type of sub-sampling to be used if the pixel size is increased in any dimension.
worker - if non-null, a ProgressMonitor will be created, showing the progress of the resampling.
verbose - if true, progress messages will be written to System.out.
Returns:
a new in-memory MultiSliceImage of the same class as this MultiSliceImage, but resampled to the specified number of samples.
Throws:
InvalidImageException - if any of the new number of samples is less than or equal to zero, or if the length of the newDims array is incorrect for this image.
CancelledException - if resampling is cancelled via the ProgressMonitor that may pop up.

reSample

public MultiSliceImage reSample(float[] newPixelSizes,
                                InterpolationType interpolationType,
                                SubSampleType subSampleType,
                                MonitorWorker worker,
                                boolean verbose)
                         throws InvalidImageException,
                                CancelledException
Resamples an existing MultiSliceImage to have different pixel sizes. The newPixelSizes array specifies the physical size of pixels in each dimension of the image that has a physical "size". If, for any dimension of this image, the pixel size cannot be found, or if the pixel size is invalid, that dimension is not resampled. reSample does not know how to resample in any dimension greater than 4; in any image with dimensions higher than 4, higher dimensions are are not resampled, since reSample cannot find the pixel size in these dimensions. Any new pixel sizes you set for these higher dimensions will be ignored.

Parameters:
newPixelSizes - the physical pixel size in each of the dimensions of the image. newPixelSizes must have the same number of elements as there are dimensions in this image. The floating point number in each element of the array specifies the pixel size in each dimension for the resampled image. The column dimension is the last array element; the row dimension is the next-to-last; the slice dimension is the second-from-last, and the time dimension is the third-from-last. Any other dimensions are ignored.
interpolationType - the type of interpolation to be used if the pixel size is reduced in any dimension.
subSampleType - the type of sub-sampling to be used if the pixel size is increased in any dimension.
worker - if non-null, a ProgressMonitor will be created, showing the progress of the resampling.
verbose - if true, progress messages will be written to System.out.
Returns:
a new in-memory MultiSliceImage of the same class as this MultiSliceImage, but resampled to the specified pixel sizes.
Throws:
InvalidImageException - if any of the new pixel sizes is not positive, or if the length of the newPixelSizes array is insufficient for this image.
CancelledException - if resampling is cancelled via the ProgressMonitor that may pop up.

export

public void export(java.lang.String suffix,
                   java.lang.String filename,
                   ColourMapping cm,
                   double displayMin,
                   double displayMax,
                   ComplexMode complexMode,
                   int slicesPerRow)
            throws java.io.IOException,
                   InvalidImageException
Writes an image to a disk file in an external format (such as JPEG, GIF etc.), creating the disk image from this MultiSliceImage, by drawing all of the slices in a raster of slices. The first slice will be at the top left of the image, and the image is filled across the row of slices before moving down to the next row. The width of the disk image will be either be the number of columns in the MultiSliceImage multiplied by the number of slicesPerRow, or 1024, whichever is the smaller.

Parameters:
suffix - the suffix describing the type of image to be created. Currently, must be one of:
  • "gif"
  • "jpeg" or "jpg"
  • "bmp"
  • "png"
The case of the suffix is ignored.
filename - the name of the disk file to which the image will be written.
cm - the ColourMapping to use when converting the pixel values to colours in the image. The cm is ignored for PixelDataTypes that have the R.G.B components specified.
displayMin - the image pixel value that maps to the first entry in the ColourMapping. All pixel values below displayMin will also be mapped to the first entry.
displayMax - the image pixel value that maps to the last entry in the ColourMapping. All pixel values above displayMax will also be mapped to the last entry.
complexMode - the display mode for complex images. May be null for non-complex images.
slicesPerRow - the number of image slices to put into one row of the image raster.
Throws:
java.io.IOException - an error occurs writing to the file, or if an image of the type requested cannot be created.
InvalidImageException - if this MultiSliceImage has bad dimensionality for this operation.

export

public java.io.InputStream export(java.lang.String suffix,
                                  ColourMapping cm,
                                  double displayMin,
                                  double displayMax,
                                  ComplexMode complexMode,
                                  int slicesPerRow)
                           throws java.io.IOException,
                                  InvalidImageException
Returns an InputStream from which a external format image (such as JPEG, GIF etc.) can be read, producing the external format image from this MultiSliceImage, by drawing all of the slices in a raster of slices. The first slice will be at the top left of the image, and the image is filled across the row of slices before moving down to the next row. The width of the image will be either be the number of columns in the MultiSliceImage multiplied by the number of slicesPerRow, or 1024, whichever is the smaller.

Parameters:
suffix - the suffix describing the type of image to be created. Currently, must be one of:
  • "gif"
  • "jpeg" or "jpg"
  • "bmp"
  • "png"
The case of the suffix is ignored.
cm - the ColourMapping to use when converting the pixel values to colours in the image. The cm is ignored for PixelDataTypes that have the R.G.B components specified.
displayMin - the image pixel value that maps to the first entry in the ColourMapping. All pixel values below displayMin will also be mapped to the first entry.
displayMax - the image pixel value that maps to the last entry in the ColourMapping. All pixel values above displayMax will also be mapped to the last entry.
complexMode - the display mode for complex images. May be null for non-complex images.
slicesPerRow - the number of image slices to put into one row of the image raster.
Returns:
an InputStream from which the resulting external format image can be read.
Throws:
java.io.IOException - an error occurs writing the image, or if an image of the type requested cannot be created.
InvalidImageException - if this MultiSliceImage has bad dimensionality for this operation.

export

public void export(java.lang.String suffix,
                   javax.imageio.stream.ImageOutputStream outputStream,
                   ColourMapping cm,
                   double displayMin,
                   double displayMax,
                   ComplexMode complexMode,
                   int slicesPerRow)
            throws java.io.IOException,
                   InvalidImageException
Writes an image to an ImageOutputStream in an external format (such as JPEG, GIF etc.), creating the disk image from this MultiSliceImage, by drawing all of the slices in a raster of slices. The first slice will be at the top left of the image, and the image is filled across the row of slices before moving down to the next row. The width of the image will be either be the number of columns in the MultiSliceImage multiplied by the number of slicesPerRow, or 1024, whichever is the smaller.

Parameters:
suffix - the suffix describing the type of image to be created. Currently, must be one of:
  • "gif"
  • "jpeg" or "jpg"
  • "bmp"
  • "png"
The case of the suffix is ignored.
outputStream - the OutputStream to which the image will be written.
cm - the ColourMapping to use when converting the pixel values to colours in the image. The cm is ignored for PixelDataTypes that have the R.G.B components specified.
displayMin - the image pixel value that maps to the first entry in the ColourMapping. All pixel values below displayMin will also be mapped to the first entry.
displayMax - the image pixel value that maps to the last entry in the ColourMapping. All pixel values above displayMax will also be mapped to the last entry.
complexMode - the display mode for complex images. May be null for non-complex images.
slicesPerRow - the number of image slices to put into one row of the image raster.
Throws:
java.io.IOException - an error occurs writing to the ImageOutputStream, or if an image of the type requested cannot be created.
InvalidImageException - if this MultiSliceImage has bad dimensionality for this operation.

toBufferedImage

public java.awt.image.BufferedImage toBufferedImage(ColourMapping cm,
                                                    double displayMin,
                                                    double displayMax,
                                                    ComplexMode complexMode,
                                                    int slicesPerRow)
                                             throws java.lang.IllegalArgumentException,
                                                    InvalidImageException
Create a BufferedImage from this MultiSliceImage, by drawing all of the slices in a raster of slices. The first slice will be at the top left of the BufferedImage, and the BufferedImage is filled across the row of slices before moving down to the next row. The width of the BufferedImage will be either the number of columns in the MultiSliceImage multiplied by the number of slicesPerRow, or 1048, whichever is the smaller.

Parameters:
cm - the ColourMapping to use when converting the pixel values to colours in the BufferedImage. The cm is ignored for PixelDataTypes that have the R.G.B components specified.
displayMin - the image pixel value that maps to the first entry in the ColourMapping. All pixel values below displayMin will also be mapped to the first entry.
displayMax - the image pixel value that maps to the last entry in the ColourMapping. All pixel values above displayMax will also be mapped to the last entry.
complexMode - the display mode for complex images. May be null for non-complex images.
slicesPerRow - the number of image slices to put into one row of the BufferedImage raster.
Returns:
a BufferedImage showing all the slices of this MultiSliceImage.
Throws:
java.lang.IllegalArgumentException - if this image cannot be converted to a BufferedImage.
InvalidImageException - if this MultiSliceImage has bad dimensionality for this operation.

clone

public MultiSliceImage clone()
Returns a copy of this MultiSliceImage. The copy will always be an in-memory image, regardless of whether the original is in-memory or on disk.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this MultiSliceImage instance.

parseMultiValuedString

protected static double[] parseMultiValuedString(java.lang.String s,
                                                 int nValues)
                                          throws MultiSliceImageException
Convenience method to parse Strings of the form "value1\value2\value3\…\valueN", where value1 to valueN are numerical values.

Parameters:
s - the java.lang.String to be parsed.
nValues - the number of values expected in s.
Returns:
the multiple values in s as a double[].
Throws:
MultiSliceImageException - if nValues numerical values cannot be parsed from String s.

main

public static void main(java.lang.String[] args)
Run the self-test on the MultiSliceImage class.

Parameters:
args - ignored.


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