com.xinapse.multisliceimage.Analyze
Class NIFTIImage

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

public class NIFTIImage
extends ANZImage
implements InfoStorer

This class is a representation of a multi-dimensional image in the NIFTI-1 format (see The Neuroimaging Informatics Technology Initiative), an extension of the original Analyze 7.5 format (see The Biomedical Imaging Resource). A NIFTIImage Object can be created either from two data sources (one for the header, the other for the image data), one data source (a combined header/image source), or it can be created afresh.

Both big-endian and little-endian byte ordering are implemented and supported. When reading existing images, the byte order is auto detected. When existing images are copied or modified, the original byte order is retained. For images newly-created from scratch by this package, the byte ordering the native byte order.

N.B. The Analyze format requires that for BINARY images, individual slices must begin on a byte boundary. In this implementation, that restriction is removed. If you wish to maintain compatibility with Analyze and other programs that maintain this restriction, please ensure that a multi-slice/multi-frame images have slices with a number of pixels that is a multiple of 8 (bits).

N.B. When the pixel values are returned by methods such as getPix() and getSlice(), these are the intensities of the data primities values stored on disk or help in memory. They are not scaled according to the intensity rescaling factors that are part of the NIFTI-1 standard. To get the pixel values intended by the setter of the intensity rescaling factors, you will need to perform any intensity rescaling yourself.


Field Summary
static java.lang.String COMPRESSED_EXTENSION
          The file extension for compressed NIFTI image files.
static java.lang.String COMPRESSED_PROPERTY_KEY
          The property value key for setting whether NIFTI images should be stored compressed, or uncompressed.
static boolean DEFAULT_COMPRESSED
          Whether to store NIFTI images compressed by default.
static boolean DEFAULT_NIFTI_ONE_FILE
          Whether to store NIFTI images in one file (.nii) by default.
static java.lang.String EXTENSION
          The file extension for NIFTI image files.
static java.lang.String ONE_FILE_PROPERTY_KEY
          The property value key for setting whether NIFTI images should be stored in one file, or two.
static java.lang.String UPPERCASE_COMPRESSED_EXTENSION
          The file extension for compressed NIFTI image files in upper case form.
static java.lang.String UPPERCASE_EXTENSION
          The file extension for NIFTI image files in upper case form.
 
Fields inherited from class com.xinapse.multisliceimage.Analyze.ANZImage
COMPRESSED_UPPERCASE_EXTENSION
 
Fields inherited from class com.xinapse.multisliceimage.MultiSliceImage
AUDIT_TRAIL_ACTION_TEXT, BIRTH_DATE_NAME, COLOUR_MAPPING_NAME, DEFAULT_IMAGE_CLASS, DW_B_MATRIX_NAME, DW_B_VALUE_NAME, DW_GRADIENT_VECTOR_NAME, ECHO_TIME_NAME, FLIP_ANGLE_NAME, FRAME_OF_REFERENCE_UID_NAME, IMAGE_ORIENTATION_PATIENT_NAME, IMAGE_POSITION_PATIENT_NAME, INTENSITY_RESCALE_INTERCEPT_NAME, INTENSITY_RESCALE_SLOPE_NAME, INTENSITY_RESCALE_UNITS_NAME, INVERSION_TIME_NAME, MAXDIM, MODALITY_NAME, mode, PATIENT_ID_NAME, PATIENT_NAME_NAME, PATIENT_POSITION_NAME, pixArray, PIXEL_SPACING_NAME, PIXEL_X_SIZE_NAME, PIXEL_Y_SIZE_NAME, PIXEL_Z_SIZE_NAME, PULSE_SEQUENCE_NAME, randomAccessFile, REPETITION_TIME_NAME, SCAN_DATE_NAME, SCANNING_SEQUENCE_NAME, SEQUENCE_VARIANT_NAME, SLICE_THICKNESS_NAME, TIME_BETWEEN_FRAMES_NAME
 
Constructor Summary
NIFTIImage(ANZPixFormat dataType, java.lang.Short... dims)
          Creates a new in-memory NIFTIImage.
NIFTIImage(java.io.File f, NIFTIHeader header)
          Creates a new disk-based NIFTIImage, using an existing header as a template for the new image.
NIFTIImage(NIFTIHeader hdr)
          Creates a new in-memory NIFTIImage, using information from an existing NIFTIHeader.
NIFTIImage(short nCols, short nRows, short nSlices, short nFrames, ANZPixFormat dataType)
          Creates a new in-memory NINFIImage.
NIFTIImage(java.lang.String filename, ANZPixFormat dataType, java.lang.Short... dims)
          Creates a new disk-based NIFTIImage.
NIFTIImage(java.lang.String filename, NIFTIHeader header)
          Creates a new disk-based NIFTIImage, using an existing header as a template for the new image.
NIFTIImage(java.lang.String filename, short nCols, short nRows, short nSlices, short nFrames, ANZPixFormat dataType)
          Creates a new disk-based NIFTIImage.
NIFTIImage(java.lang.String filename, java.lang.String mode)
          Opens an existing NIFTIImage, with pixel data remaining on disk until requested.
 
Method Summary
 void addExtendedData(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData)
          Adds a block of ExtendedData to this NIFTIImage.
 void appendAuditInfo(java.lang.String name, java.lang.String value)
          Appends audit trail information to this image.
 void appendInfoList(InfoList infoList)
          Appends an InfoList to the existing general file info of this image.
 void appendInfoList(InfoList infoList, int dim, int n)
          Appends an InfoList to that for a particular dimension of this image.
 void close()
          Closes a NIFTIImage and frees up resources.
static java.lang.String getCommonName()
          Returns the common name for this type of image.
 float[] getDWBMatrix(int slice)
          Returns the diffusion-weighting b-matrix for one slice of this image.
 float getDWbValue(int slice)
          Returns the diffusion-weighting b-value for one slice of this image.
 javax.vecmath.Vector3f getDWGradientVector(int slice)
          Returns the diffusion-weighting gradient-vector for one slice of this image.
 java.util.List<com.xinapse.multisliceimage.Analyze.ExtendedData> getExtendedData()
          Returns a java.util.List of ExtendedData for this NIFTIImage.
 float getFlipAngle()
          Returns the excitation pulse flip angle for this image.
 java.lang.String getHTMLDescription(int slice)
          Returns a String description of a slice of this image in HTML format.
 javax.vecmath.Vector3f[] getImageOrientationPatient(int slice)
          Returns the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient coordinates.
 javax.vecmath.Point3f getImagePositionPatient(int slice)
          Returns the coordinates of the center of the first pixel of the specified slice of this image, in mm, in patient coordinates.
 java.lang.String getInfo(java.lang.String name)
          Returns a string representing the value of this information item in the general image information.
 java.lang.String getInfo(java.lang.String name, int dim, int n)
          Returns a java.lang.String representing the value of this information item in a particular dimension of this image.
 InfoList getInfoList()
          Returns an InfoList object which is the general info for this image.
 InfoList getInfoList(int dim, int n)
          Returns an InfoList object applying to a particular dimension/element for this image.
 MultiSliceImage getInstance(java.lang.Class cl, 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.
 float[] getIntensityRescale()
          Returns the values m and b in the relationship between pixel intensity (I) values and the output units specified in getRescaleUnits() in the expression:
Output units = m*I + b.
 NIFTIIntent getIntent()
          Returns the NIFTIIntent in this NIFTIImage.
 Modality getModality()
          Returns the modality with which this image was acquired.
 java.util.Date getPatientDoB()
          Returns the patient's date of birth for this image.
 java.lang.String getPatientID()
          Returns the patient ID for this image.
 java.lang.String getPatientName()
          Returns the patient name for this image.
 PatientPosition getPatientPosition()
          Returns the position in which the patient is lying in the scanning equipment.
static boolean getPreferredCompressed()
          Returns the user's preference about whether NIFTI images should be stored compressed.
static boolean getPreferredNIFTIOneFile()
          Returns the user's preference about whether NIFTI images should be stored in two separate files (.hdr and .hdr) or one (.nii).
static PreviewIcon getPreviewIcon(java.io.File f)
          Returns the PreviewIcon for an NIFTIImage, or null if the supplied File does not represent a NIFTI image.
 java.lang.String getPulseSequence()
          Returns the pulse sequence name for this image.
 NIFTIXForm getQForm()
          Returns the qForm in this NIFTIImage.
 java.lang.String getRescaleUnits()
          Returns the intent name, or "arbitrary units", if the intent name is not set.
 java.util.Date getScanDate()
          Returns the scan date for this image.
 PulseSequenceType getScanningSequence()
          Returns the scanning sequence for this image.
 float getScanTE()
          Returns the scan echo time for this image if it has a single echo-time.
 float getScanTE(int slice)
          Returns the scan echo time for one slice of this image.
 float getScanTI()
          Returns the scan inversion time for this image.
 float getScanTR()
          Returns the scan repetition time for this image.
 PulseSequenceVariant getSequenceVariant()
          Returns the scanning sequence variant for this image.
 NIFTIXForm getSForm()
          Returns the sForm in this NIFTIImage.
 AffineTransform3D getSFormAffineTransform()
          Returns the general (sForm) AffineTransform3D that will transform the pixel indices (colIdx, rowIdx, sliceIdx) to a position in space in a patient-centric coordinate system.
 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.String getSliceInfo(java.lang.String name, int slice)
          Returns a java.lang.String representing the value of this information item in a particular slice of this image.
 InfoList getSliceInfoList(int slice)
          Returns an InfoList object applying to a particular slice of this image.
 float getSliceThickness()
          Returns the slice thickness (in mm).
static boolean imageExists(java.lang.String filename)
          Tests whether a NIFTIImage with the given name already exists on disk.
static void main(java.lang.String[] args)
          Run the self-test for the NIFTIImage class.
 void putInfo(java.lang.String name, float value)
          Adds an item to the general file info.
 void putInfo(java.lang.String name, float value, int dim, int n)
          Adds an item to the dimension-specific information.
 void putInfo(java.lang.String name, int value)
          Adds an item to the general file info.
 void putInfo(java.lang.String name, int value, int dim, int n)
          Adds an item to the dimension-specific information.
 void putInfo(java.lang.String name, java.lang.String value)
          Adds an item to the general file info.
 void putInfo(java.lang.String name, java.lang.String value, int dim, int n)
          Adds an item to the dimension-specific information.
 void putSliceInfo(InfoList infoList, int slice)
          Adds all the items in an InfoList to the slice-specific information.
 void putSliceInfo(java.lang.String name, java.lang.String value, int slice)
          Adds an item to the slice-specific information.
 void removeExtendedData(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData)
          Removes a block of ExtendedData from this NIFTIImage.
 void removeInfo(java.lang.String name)
          Removes an item from the general file information.
 void removeInfo(java.lang.String name, int dim, int n)
          Removes an item from the dimension-specific information.
static void savePreferredCompressed(boolean compressed)
          Sets the user's preference about whether NIFTI images should be stored compressed.
static void savePreferredNIFTIOneFile(boolean oneFile)
          Sets the user's preference about whether NIFTI images should be stored in two separate files (.hdr and .hdr) or one (.nii).
 void setDWBMatrix(float[] bMatrix, int slice)
          Sets the diffusion-weighting B-matrix for one slice of this image.
 void setDWbValue(float bValue, int slice)
          Sets the diffusion-weighting b-value for one slice of this image.
 void setDWGradientVector(javax.vecmath.Vector3f gradVec, int slice)
          Sets the diffusion-weighting gradient vector for one slice of this image.
 void setFlipAngle(float flipAngle)
          Sets the excitation pulse flip angle for this image.
 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.
 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.
 void setInfoList(InfoList infoList)
          Sets a new InfoList to the general file info of this image.
 void setInfoList(InfoList infoList, int dim, int n)
          Sets a new InfoList a specific dimension of this image.
 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.
 void setIntent(NIFTIIntent intent)
          Sets the NIFTIIntent in this NIFTIImage.
 void setModality(Modality modality)
          Sets the modality with which this image was acquired.
 void setPatientDoB(java.util.Date patientDoB)
          Sets the patient's date of birth for this image.
 void setPatientID(java.lang.String patientID)
          Sets the patient ID for this image.
 void setPatientName(java.lang.String patientName)
          Attempts to set the patient name for this image.
 void setPatientPosition(PatientPosition position)
          Sets the position in which the patient is lying in the scanning equipment for this MultiSliceImage.
 void setPulseSequence(java.lang.String seqName)
          Sets the pulse sequence name for this image.
 void setQForm(NIFTIXForm qForm)
          Sets the qForm code in this NIFTIImage.
 void setRescaleUnits(java.lang.String unitsString)
          Sets the intent name.
 void setScanDate(java.util.Date scanDate)
          Sets the scan date/time for this image.
 void setScanningSequence(PulseSequenceType seq)
          Sets the DICOM scanning sequence for this image.
 void setScanTE(float TE)
          Sets the scan echo time for this image, for single-echo-time images.
 void setScanTE(float TE, int slice)
          Sets the scan echo time for one slice of this image.
 void setScanTI(float TI)
          Sets the scan inversion time for this image.
 void setScanTR(float TR)
          Sets the scan repetition time for this image.
 void setSequenceVariant(PulseSequenceVariant seqVar)
          Sets the DICOM scanning sequence variant for this image.
 void setSForm(NIFTIXForm sForm)
          Sets the sForm code in this NIFTIImage.
 void setSliceInfoList(InfoList infoList, int slice)
          Sets a new InfoList a specific slice of this image.
 void setSliceThickness(float thickness)
          Sets the slice thickness (in mm).
 java.lang.String write(java.lang.String root)
          Writes this NIFTIImage to disk.
 
Methods inherited from class com.xinapse.multisliceimage.Analyze.ANZImage
clone, getByteOrder, getDataType, getDescription, getDescription, getDims, getFileDataOffset, getHeader, getHTMLDescription, getImageOrientationPatient, getImagePositionPatient, getIntensityRescale, getMax, getMin, getNativeColourMapping, getNCols, getNDim, getNFrames, getNRows, getNSlices, getPixelDataType, getPixelXSize, getPixelYSize, getPixelZSize, getTimeBetweenFrames, getTitle, getTotalNSlices, isCompressed, isOpen, setDBName, setDescription, setImageOrientationPositionPatient, setIntensityRescale, setMinMax, setNativeColourMapping, setPixelSpacing, setPixelXSize, setPixelYSize, setPixelZSize, setTimeBetweenFrames, setTitle, toString, write
 
Methods inherited from class com.xinapse.multisliceimage.MultiSliceImage
autoResample, checkMinMax, crop, deleteImage, exists, export, export, export, getClasses, getDateFormat, getFrameOfReferenceUID, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getMostLikePlane, getNPixels, getPix, getPix, getPix, getPix, getPix, getPreferredImageClass, getPreview, getROIs, getScanDateFormat, getSlice, getSlice, getSliceDim, getSuggestedFileName, isImage, isModified, pad, parseMultiValuedString, putPix, putPix, putPix, putPix, putSlice, reorient, reorientRadiological, reSample, reSample, savePreferredImageClass, set3DBlockParameters, setMinMax, setModified, setOrientationPositionRadiological, setSuggestedFileName, toBufferedImage
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE_FILE_PROPERTY_KEY

public static final java.lang.String ONE_FILE_PROPERTY_KEY
The property value key for setting whether NIFTI images should be stored in one file, or two.

See Also:
Constant Field Values

COMPRESSED_PROPERTY_KEY

public static final java.lang.String COMPRESSED_PROPERTY_KEY
The property value key for setting whether NIFTI images should be stored compressed, or uncompressed.

See Also:
Constant Field Values

DEFAULT_NIFTI_ONE_FILE

public static final boolean DEFAULT_NIFTI_ONE_FILE
Whether to store NIFTI images in one file (.nii) by default.

See Also:
Constant Field Values

DEFAULT_COMPRESSED

public static final boolean DEFAULT_COMPRESSED
Whether to store NIFTI images compressed by default.

See Also:
Constant Field Values

EXTENSION

public static final java.lang.String EXTENSION
The file extension for NIFTI image files.

See Also:
Constant Field Values

UPPERCASE_EXTENSION

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


COMPRESSED_EXTENSION

public static final java.lang.String COMPRESSED_EXTENSION
The file extension for compressed NIFTI image files.

See Also:
Constant Field Values

UPPERCASE_COMPRESSED_EXTENSION

public static final java.lang.String UPPERCASE_COMPRESSED_EXTENSION
The file extension for compressed NIFTI image files in upper case form.

Constructor Detail

NIFTIImage

public NIFTIImage(short nCols,
                  short nRows,
                  short nSlices,
                  short nFrames,
                  ANZPixFormat dataType)
           throws ANZException,
                  java.io.IOException
Creates a new in-memory NINFIImage. This image exists in memory, and will only be written with an explicit write() method call.

Parameters:
nCols - the number of columns in the image x-direction.
nRows - the number of rows in the image y-direction.
nSlices - the number of slice in the image.
nFrames - the number of frames (time points) in the image.
dataType - the ANZPixFormat for the image.
Throws:
ANZException - if the image cannot be created.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(ANZPixFormat dataType,
                  java.lang.Short... dims)
           throws ANZException,
                  java.io.IOException
Creates a new in-memory NIFTIImage. This image exists in memory, and will only be written with an explicit write() method call.

Parameters:
dims - the number of samples in each of the image dimensions. The number of arguments supplied determines the dimensionality of the image.
dataType - an ANZPixFormat.
Throws:
ANZException - if the header cannot be created.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(NIFTIHeader hdr)
           throws ANZException,
                  java.io.IOException
Creates a new in-memory NIFTIImage, using information from an existing NIFTIHeader. This image exists in memory, and will only be written with an explicit write() method call. The supplied NIFTIHeader object is cloned and can therefore be re-used.

Parameters:
hdr - the NIFTIHeader that will be used for dimensional information etc.
Throws:
ANZException - if the image cannot be created.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(java.lang.String filename,
                  short nCols,
                  short nRows,
                  short nSlices,
                  short nFrames,
                  ANZPixFormat dataType)
           throws java.io.IOException,
                  ANZException
Creates a new disk-based NIFTIImage. After manipulation, a call to the close() method is necessary for any changes to be reflected on disk.

Parameters:
filename - the root of the Analyze file name (i.e. without the ".img" or ".hdr" extension). If the filename does have an extension, this this will be handled.
nCols - the number of columns in the image x-direction.
nRows - the number of rows in the image y-direction.
nSlices - the number of slice in the image.
nFrames - the number of frames (time points) in the image.
dataType - the ANZPixFormat for the image.
Throws:
ANZException - if the NIFTIImage cannot be instantiated.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(java.lang.String filename,
                  ANZPixFormat dataType,
                  java.lang.Short... dims)
           throws java.io.IOException,
                  ANZException
Creates a new disk-based NIFTIImage. After manipulation, a call to the close() method is necessary for any changes to be reflected on disk.

Parameters:
filename - the root of the NIFTI file name (i.e. without any ".img" ".hdr", ".nii", ".img.gz", ".hdr.gz" or ".nii.gz" extension). If the filename does have an extension, this this will be handled gracefully.
dims - the number of samples in each of the image dimensions. The number of arguments supplied determines the dimensionality of the image.
dataType - an ANZPixFormat.
Throws:
ANZException - if the header cannot be created.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(java.io.File f,
                  NIFTIHeader header)
           throws java.io.IOException,
                  ANZException
Creates a new disk-based NIFTIImage, using an existing header as a template for the new image. After manipulation, a call to the close() method is necessary for any changes to the header to be reflected on disk.

Parameters:
f - the File object that will form the root of the Analyze file name (i.e. without the ".hdr" extension). If f's name does have an extension, this this will be handled.
header - the NIFTIHeader to use as the template.
Throws:
ANZException - if the new image cannot be created on disk.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(java.lang.String filename,
                  NIFTIHeader header)
           throws java.io.IOException,
                  ANZException
Creates a new disk-based NIFTIImage, using an existing header as a template for the new image. After manipulation, a call to the close() method is necessary for any changes to the image to be reflected on disk.

Parameters:
filename - the image file name (possibly without any ".hdr" or ".nii" extension). If the filename has no extension, then the decision about whether to save the image in a NIFTI one-file format (.nii) and whether it will be compressed (.hdr.gz/.img.gz/.nii.gz) will be made according to the user preferences. If the filename does have an extension, this this will override the user preferences, and will be handled as follows:
  • If the extension is a standard Analyze (.hdr/.img) extension, then the image will be saved in a two-file format.
  • If the extension is .nii, then then the image will be saved in a one-file format.
  • If the extension is ..hdr.gz, .img.gz or .nii.gz then then the image will be saved in a compressed two-file or one-file format.
header - the ANZHeader to use as the template.
Throws:
ANZException - if the new image cannot be created on disk.
java.io.IOException - if an I/O error occurs.

NIFTIImage

public NIFTIImage(java.lang.String filename,
                  java.lang.String mode)
           throws MultiSliceImageException,
                  java.io.IOException,
                  java.io.FileNotFoundException
Opens an existing NIFTIImage, with pixel data remaining on disk until requested.

Parameters:
filename - the name of the image file.
mode - the open mode. Can be either "r" (read-only) or "rw" (read-write).
Throws:
MultiSliceImageException - if the image cannot be opened or loaded, or if mode is invalid.
java.io.FileNotFoundException - if the image file doesn't exist.
java.io.IOException - if an I/O error occurs.
Method Detail

getPreferredNIFTIOneFile

public static boolean getPreferredNIFTIOneFile()
Returns the user's preference about whether NIFTI images should be stored in two separate files (.hdr and .hdr) or one (.nii).

If the system property "nifti.onefile" exists, and the property value is either "true" or "false", then the user's preference is overridden by the property value.

Returns:
true if the user prefers to store NIFTI-compliant images in one .nii file; false otherwise.

savePreferredNIFTIOneFile

public static void savePreferredNIFTIOneFile(boolean oneFile)
Sets the user's preference about whether NIFTI images should be stored in two separate files (.hdr and .hdr) or one (.nii).

Parameters:
oneFile - true if the user prefers to store NIFTI-compliant images in one .nii file; false otherwise.

getPreferredCompressed

public static boolean getPreferredCompressed()
Returns the user's preference about whether NIFTI images should be stored compressed.

If the system property "nifti.compressed" exists, and the property value is either "true" or "false", then the user's preference is overridden by the property value.

Returns:
true if the user prefers to store NIFTI-compliant images compressed; false otherwise.

savePreferredCompressed

public static void savePreferredCompressed(boolean compressed)
Sets the user's preference about whether NIFTI images should be stored compressed.

Parameters:
compressed - true if the user prefers to store NIFTI-compliant images compressed.

getInstance

public MultiSliceImage getInstance(java.lang.Class cl,
                                   int nSlices)
                            throws java.io.IOException,
                                   MultiSliceImageException
Description copied from class: MultiSliceImage
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.

Specified by:
getInstance in class ANZImage
Parameters:
cl - the class of image to be written (e.g. com.xinapse.multisliceimage.UNC.UNCImage.class).
nSlices - the number of slices in the image that is to be written.
Returns:
the new MultiSliceImage that is created.
Throws:
java.io.IOException - if an I/O error occurs.
MultiSliceImageException - if the image cannot be written.

imageExists

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

Parameters:
filename - the name of the image file to test for existence.
Returns:
true if either:
  • a pair of NIFTIImages .img and .hdr with the specified name exist on disk;
  • a single NIFTIImage with extension .nii exists on disk.
false otherwise.

getPreviewIcon

public static PreviewIcon getPreviewIcon(java.io.File f)
Returns the PreviewIcon for an NIFTIImage, or null if the supplied File does not represent a NIFTI image.

Parameters:
f - the File to be tested.
Returns:
PreviewInfo if the File produces an NIFTIImage; null otherwise.

write

public java.lang.String write(java.lang.String root)
                       throws java.io.IOException,
                              MultiSliceImageException
Writes this NIFTIImage to disk. This method will either: The choice depends on the magic number set in the image header (i.e., a magic number the "n+1" for a .nii file, and "ni1" for separate .hdr and .img files).

Overrides:
write in class ANZImage
Parameters:
root - the root of the NIFTI filename. Will be appended with ".hdr", ".img", ".nii", ".hdr.gz", ".img.gz" or ".nii.gz" as appropriate to create the full filename(s).
Returns:
the actual file name used to write the image, including any added extension.
Throws:
MultiSliceImageException - if the image cannot be written.
java.io.IOException - if an I/O error occurs.

close

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

Specified by:
close in interface LoadableImage
Overrides:
close in class ANZImage
Throws:
MultiSliceImageException - if the file cannot be written or closed.
java.io.IOException - if an I/O error occurs.

getImagePositionPatient

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

Specified by:
getImagePositionPatient in interface LoadableImage
Overrides:
getImagePositionPatient in class ANZImage
Returns:
the Left,Posterior,Superior (LPS) coordinates of the first pixel in the specified slice of this image. Returns null if the position cannot be retrieved from this image.
Throws:
java.lang.IndexOutOfBoundsException - if the slice number is bad for this image.

setImagePositionPatient

public void setImagePositionPatient(javax.vecmath.Point3f position,
                                    int slice)
Description copied from class: MultiSliceImage
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.

Specified by:
setImagePositionPatient in class MultiSliceImage
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.

getImageOrientationPatient

public javax.vecmath.Vector3f[] getImageOrientationPatient(int slice)
                                                    throws java.lang.IndexOutOfBoundsException
Description copied from interface: LoadableImage
Returns the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient coordinates.

Specified by:
getImageOrientationPatient in interface LoadableImage
Overrides:
getImageOrientationPatient in class ANZImage
Parameters:
slice - the slice for which to return the image orientation.
Returns:
a Point3f[], corresponding to the direction cosines of the image row, column and slice directions in Left,Posterior,Superior (LPS) coordinates. Returns null if the direction cosines cannot be retrieved from this image.
Throws:
java.lang.IndexOutOfBoundsException - if the image does not have the right dimensionality or the slice number is inappropriate for this image.

setImageOrientationPatient

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

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

Specified by:
setImageOrientationPatient in class MultiSliceImage
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.

getIntensityRescale

public float[] getIntensityRescale()
Description copied from interface: LoadableImage
Returns the values m and b in the relationship between pixel intensity (I) values and the output units specified in getRescaleUnits() in the expression:
Output units = m*I + b.

Specified by:
getIntensityRescale in interface LoadableImage
Returns:
an array will be of length 2 where the first element is m and the second is b.

setIntensityRescale

public void setIntensityRescale(float[] rescale)
                         throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setIntensityRescale in class MultiSliceImage
Parameters:
rescale - a float[] of length 2 where the first element is m and the second is b.
Throws:
java.io.IOException - if an I/O error occurs.

getRescaleUnits

public java.lang.String getRescaleUnits()
Returns the intent name, or "arbitrary units", if the intent name is not set.

Specified by:
getRescaleUnits in interface LoadableImage
Overrides:
getRescaleUnits in class ANZImage
Returns:
a String describing the physical meaning of the pixel intensity units. Returns the String "arbitrary units" if the physical meaning is unknown, or arbitrary.

setRescaleUnits

public void setRescaleUnits(java.lang.String unitsString)
                     throws java.io.IOException
Sets the intent name.

Specified by:
setRescaleUnits in class MultiSliceImage
Parameters:
unitsString - the new intent name.
Throws:
java.io.IOException - if the rescaling units cannot be set for this image.

getSimpleName

public java.lang.String getSimpleName()
Description copied from class: MultiSliceImage
Returns the simple name for this type of image - the String that should be seen by the users to identify this type of image.

Specified by:
getSimpleName in class MultiSliceImage
Returns:
a simple name for the image type.

getCommonName

public static java.lang.String getCommonName()
Returns the common name for this type of image.

Returns:
the String "NIFTI-1".

getQForm

public NIFTIXForm getQForm()
Returns the qForm in this NIFTIImage.

Returns:
the qForm set in this NIFTIImage.

setQForm

public void setQForm(NIFTIXForm qForm)
              throws ANZException
Sets the qForm code in this NIFTIImage.

Parameters:
qForm - the qForm to set in this NIFTIImage.
Throws:
ANZException - if the qForm cannot be set.

getSForm

public NIFTIXForm getSForm()
Returns the sForm in this NIFTIImage.

Returns:
the sForm in this NIFTIImage.

setSForm

public void setSForm(NIFTIXForm sForm)
              throws ANZException
Sets the sForm code in this NIFTIImage.

Parameters:
sForm - the sForm to set in this NIFTIImage.
Throws:
ANZException - if the sForm cannot be set.

getSFormAffineTransform

public AffineTransform3D getSFormAffineTransform()
                                          throws ParameterNotSetException
Returns the general (sForm) AffineTransform3D that will transform the pixel indices (colIdx, rowIdx, sliceIdx) to a position in space in a patient-centric coordinate system.
N.B. Note: the patient-centric coordinate system is different from that defined in the NIFTI-1 standard. Jim's coordinate system is a right-handed system, with: This is the standard radiological coordinate system, and is different from NIFTI's.

Returns:
the AffineTransform3D that will transform the pixel indices (colIdx, rowIdx, sliceIdx) to a position in space in the patient-centric coordinate system. The pixel indices can be transformed to the (L,P,S) coordinate by applying:
     // Create a point for the pixel indices.
     Point3f ijk = new Point3f(i, j, k);
     Point3f lps = new Point3f();
     // The lps coordinate of the point is returned.
     Point3f lps = header.getAffineTransform().transform(ijk, lps);
     
Throws:
ParameterNotSetException - if the AffineTransform cannot be retrieved.

getIntent

public NIFTIIntent getIntent()
Returns the NIFTIIntent in this NIFTIImage.

Returns:
the NIFTIIntent set in this NIFTIImage.

setIntent

public void setIntent(NIFTIIntent intent)
               throws ANZException
Sets the NIFTIIntent in this NIFTIImage.

Parameters:
intent - the NIFTIIntent to set in this NIFTIImage.
Throws:
ANZException - if the intent cannot be set.

getPatientPosition

public PatientPosition getPatientPosition()
Description copied from interface: LoadableImage
Returns the position in which the patient is lying in the scanning equipment. For example, PatientPosition.HFS (head-first supine).

Specified by:
getPatientPosition in interface LoadableImage
Returns:
the position in which the patient is lying in the scanning equipment.

setPatientPosition

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

Specified by:
setPatientPosition in class 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.

setScanDate

public void setScanDate(java.util.Date scanDate)
                 throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setScanDate in class MultiSliceImage
Parameters:
scanDate - the new scan date/time to be assigned to this image.
Throws:
java.io.IOException - if the scan date cannot be set.

setPulseSequence

public void setPulseSequence(java.lang.String seqName)
                      throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setPulseSequence in class MultiSliceImage
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 void setScanningSequence(PulseSequenceType seq)
                         throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setScanningSequence in class MultiSliceImage
Parameters:
seq - the new scanning sequence to be assigned to this image.
Throws:
java.io.IOException - if the scanning sequence cannot be set.

setSequenceVariant

public void setSequenceVariant(PulseSequenceVariant seqVar)
                        throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setSequenceVariant in class MultiSliceImage
Parameters:
seqVar - the new scanning sequence variant to be assigned to this image.
Throws:
java.io.IOException - if the scanning sequence variant cannot be set.

getSliceThickness

public float getSliceThickness()
                        throws ParameterNotSetException
Description copied from interface: LoadableImage
Returns 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.

Specified by:
getSliceThickness in interface LoadableImage
Returns:
the slice thickness in mm.
Throws:
ParameterNotSetException - if the slice thickness is not set, or its value is corrupt.

setSliceThickness

public void setSliceThickness(float thickness)
                       throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setSliceThickness in class MultiSliceImage
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.

getModality

public Modality getModality()
Description copied from class: MultiSliceImage
Returns the modality with which this image was acquired.

Specified by:
getModality in interface LoadableImage
Specified by:
getModality in class MultiSliceImage
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.

setModality

public void setModality(Modality modality)
                 throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setModality in class MultiSliceImage
Parameters:
modality - the new imaging modality to be assigned to this image.
Throws:
java.io.IOException - if modality cannot be set.

getScanTR

public float getScanTR()
                throws ParameterNotSetException
Returns the scan repetition time for this image.

Specified by:
getScanTR in interface LoadableImage
Returns:
the scan TR for this image.
Throws:
ParameterNotSetException - if the TR hasn't been set.

setScanTR

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

Specified by:
setScanTR in class MultiSliceImage
Parameters:
TR - the new scan TR to be assigned to this image.
Throws:
java.io.IOException - if the scan TR cannot be set.

getScanTI

public float getScanTI()
                throws ParameterNotSetException
Returns the scan inversion time for this image.

Specified by:
getScanTI in interface LoadableImage
Returns:
the scan TI for this image.
Throws:
ParameterNotSetException - if the TI hasn't been set.

setScanTI

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

Specified by:
setScanTI in class MultiSliceImage
Parameters:
TI - the new scan TI to be assigned to this image.
Throws:
java.io.IOException - if the scan TI cannot be set.

getScanTE

public float getScanTE()
                throws ParameterNotSetException
Returns the scan echo time for this image if it has a single echo-time.

Specified by:
getScanTE in interface LoadableImage
Returns:
the scan TE for this image.
Throws:
ParameterNotSetException - if the TE hasn't been set.

setScanTE

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

Specified by:
setScanTE in class MultiSliceImage
Parameters:
TE - the new scan TE to be assigned to this image.
Throws:
java.io.IOException - if an I/O error occurs.

getScanTE

public float getScanTE(int slice)
                throws ParameterNotSetException,
                       java.lang.IndexOutOfBoundsException
Returns the scan echo time for one slice of this image.

Specified by:
getScanTE in interface LoadableImage
Parameters:
slice - the slice number for which to return the echo time.
Returns:
the scan TE for the specified slice of this image.
Throws:
ParameterNotSetException - if the TE hasn't been set.
java.lang.IndexOutOfBoundsException - if the slice number is bad for this image.

setScanTE

public void setScanTE(float TE,
                      int slice)
               throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setScanTE in class MultiSliceImage
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.

getFlipAngle

public float getFlipAngle()
                   throws ParameterNotSetException
Returns the excitation pulse flip angle for this image.

Specified by:
getFlipAngle in interface LoadableImage
Returns:
the excitation pulse flip angle for this image.
Throws:
ParameterNotSetException - if the flip angle hasn't been set.

setFlipAngle

public void setFlipAngle(float flipAngle)
                  throws java.io.IOException
Sets the excitation pulse flip angle for this image.
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.

Specified by:
setFlipAngle in class MultiSliceImage
Parameters:
flipAngle - the new scan flip angle to be assigned to this image.
Throws:
java.io.IOException - if an I/O error occurs.

getDWbValue

public float getDWbValue(int slice)
                  throws ParameterNotSetException,
                         java.lang.IndexOutOfBoundsException
Description copied from interface: LoadableImage
Returns the diffusion-weighting b-value for one slice of this image.

Specified by:
getDWbValue in interface LoadableImage
Parameters:
slice - the slice number for which to return the b-value.
Returns:
the diffusion-weighting b-value for the specified slice of this image.
Throws:
ParameterNotSetException - if the b-value is not set.
java.lang.IndexOutOfBoundsException - if the slice number is bad for this image.

setDWbValue

public void setDWbValue(float bValue,
                        int slice)
                 throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setDWbValue in class MultiSliceImage
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.

getDWGradientVector

public javax.vecmath.Vector3f getDWGradientVector(int slice)
                                           throws ParameterNotSetException,
                                                  java.lang.IndexOutOfBoundsException
Description copied from interface: LoadableImage
Returns the diffusion-weighting gradient-vector for one slice of this image.

Specified by:
getDWGradientVector in interface LoadableImage
Parameters:
slice - the slice number for which to return the gradient-vector.
Returns:
the diffusion-weighting gradient-vector for the specified slice of this image.
Throws:
ParameterNotSetException - if the gradient-vector is not set.
java.lang.IndexOutOfBoundsException - if the slice number is bad for this image.

setDWGradientVector

public void setDWGradientVector(javax.vecmath.Vector3f gradVec,
                                int slice)
                         throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setDWGradientVector in class MultiSliceImage
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.

getDWBMatrix

public float[] getDWBMatrix(int slice)
                     throws ParameterNotSetException,
                            java.lang.IndexOutOfBoundsException
Description copied from interface: LoadableImage
Returns the diffusion-weighting b-matrix for one slice of this image.

Specified by:
getDWBMatrix in interface LoadableImage
Parameters:
slice - the slice number for which to get the b-matrix.
Returns:
the diffusion-weighting b-matrix for this image if it is a magnetic resonance image. The 6 unique matrix elements are returned as a float[] with elements in the order bXX, bXY, bXZ, bYY, bYZ, bZZ
Throws:
ParameterNotSetException - if the b-matrix cannot be found, or if the modality used to collect the image doesn't have a b-matrix defined.
java.lang.IndexOutOfBoundsException

setDWBMatrix

public void setDWBMatrix(float[] bMatrix,
                         int slice)
                  throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setDWBMatrix in class MultiSliceImage
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.

getPatientName

public java.lang.String getPatientName()
Returns the patient name for this image.

Specified by:
getPatientName in interface LoadableImage
Returns:
the patient name for this image, or null if the patient name can't be found.

setPatientName

public void setPatientName(java.lang.String patientName)
                    throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setPatientName in class MultiSliceImage
Parameters:
patientName - the new patient name to be assigned to this image.
Throws:
java.io.IOException - if the patient name cannot be set.

getPatientID

public java.lang.String getPatientID()
Returns the patient ID for this image.

Specified by:
getPatientID in interface LoadableImage
Returns:
the patientID for this image, or null if the patientID can't be found.

setPatientID

public void setPatientID(java.lang.String patientID)
                  throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setPatientID in class MultiSliceImage
Parameters:
patientID - the new patient ID to be assigned to this image.
Throws:
java.io.IOException - if the patient ID cannot be set.

getPatientDoB

public java.util.Date getPatientDoB()
Returns the patient's date of birth for this image.

Specified by:
getPatientDoB in interface LoadableImage
Returns:
the patien't date of birth, or null if the patient's date of birth can't be found.

setPatientDoB

public void setPatientDoB(java.util.Date patientDoB)
                   throws java.io.IOException
Description copied from class: MultiSliceImage
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.

Specified by:
setPatientDoB in class MultiSliceImage
Parameters:
patientDoB - 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.

getScanDate

public java.util.Date getScanDate()
Returns the scan date for this image.

Specified by:
getScanDate in interface LoadableImage
Returns:
the date/time at which this scan was performed, or null if the scan date can't be found.

getPulseSequence

public java.lang.String getPulseSequence()
                                  throws ParameterNotSetException
Returns the pulse sequence name for this image.

Specified by:
getPulseSequence in interface LoadableImage
Returns:
the pulse sequence name with which this scan was performed.
Throws:
ParameterNotSetException - if the pulse sequence name hasn't been set.

getScanningSequence

public PulseSequenceType getScanningSequence()
                                      throws ParameterNotSetException
Returns the scanning sequence for this image.

Specified by:
getScanningSequence in interface LoadableImage
Returns:
the scanning sequence with which this scan was performed.
Throws:
ParameterNotSetException - if the scanning sequence hasn't been set.

getSequenceVariant

public PulseSequenceVariant getSequenceVariant()
                                        throws ParameterNotSetException
Returns the scanning sequence variant for this image.

Specified by:
getSequenceVariant in interface LoadableImage
Returns:
the scanning sequence variant with which this scan was performed.
Throws:
ParameterNotSetException - if the scanning sequence variant hasn't been set.

appendAuditInfo

public void appendAuditInfo(java.lang.String name,
                            java.lang.String value)
                     throws java.io.IOException
Appends audit trail information to this image.

Specified by:
appendAuditInfo in interface LoadableImage
Parameters:
name - a String describing the name of the action that was performed on this image.
value - a String describing the value of the action that was performed on this image.
Throws:
java.io.IOException - if an I/O error occurs.

putInfo

public void putInfo(java.lang.String name,
                    int value)
             throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the general file info.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putInfo in interface InfoStorer
Parameters:
name - the name of the information field to put.
value - an integer value to be associated with this name in the general file information.
Throws:
java.io.IOException - if the information cannot be added.

putInfo

public void putInfo(java.lang.String name,
                    float value)
             throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the general file info. If an info item with the same name exists, then then value will be overwritten.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putInfo in interface InfoStorer
Parameters:
name - the name of the information to put.
value - a floating point value to be associated with this name in the general file information.
Throws:
java.io.IOException - if the information cannot be addded.

putInfo

public void putInfo(java.lang.String name,
                    java.lang.String value)
             throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the general file info. If an info item with the same name exists, then then value will be overwritten.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putInfo in interface InfoStorer
Parameters:
name - the name of the information to put.
value - a java.lang.String to be associated with this name in the general file information.
Throws:
java.io.IOException - if the information cannot be addded.

putInfo

public void putInfo(java.lang.String name,
                    int value,
                    int dim,
                    int n)
             throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the dimension-specific information. If an info item with the same name exists, then then value will be overwritten.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putInfo in interface InfoStorer
Parameters:
name - the name of the information item to put.
value - an integer value to be associated with this name in the general file information.
dim - the dimension of this image to put the information item. For example in a 3-dimensional image you would put to dimension 0 for slice-specific info.
n - the element to put to. For example in a 3-dimensional image you would put to slice n to info that applied only to slice n.
Throws:
java.io.IOException - if the information cannot be addded.

putInfo

public void putInfo(java.lang.String name,
                    float value,
                    int dim,
                    int n)
             throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the dimension-specific information. If an info item with the same name exists, then then value will be overwritten.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putInfo in interface InfoStorer
Parameters:
name - the name of the information item to put.
value - an floating-point value to be associated with this name in the dimension-specific information.
dim - the dimension of this image to put the information. For example in a 3-dimensional image you would put to dimension 0 for slice-specific info.
n - the element to put to. For example in a 3-dimensional image you would put to slice n to info that applied only to slice n.
Throws:
java.io.IOException - if the information cannot be addded.

putInfo

public void putInfo(java.lang.String name,
                    java.lang.String value,
                    int dim,
                    int n)
             throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the dimension-specific information. If an info item with the same name exists, then then value will be overwritten.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putInfo in interface InfoStorer
Parameters:
name - the name of the information item to put.
value - a String value to be associated with this name in the dimension-specific information.
dim - the dimension of this image to put the information. For example in a 3-dimensional image you would put to dimension 0 for slice-specific info.
n - the element to put to. For example in a 3-dimensional image you would put to slice n to info that applied only to slice n.
Throws:
java.io.IOException - if the information cannot be addded.

putSliceInfo

public void putSliceInfo(InfoList infoList,
                         int slice)
                  throws java.io.IOException
Description copied from interface: InfoStorer
Adds all the items in an InfoList to the slice-specific information. If an info item with the same name exists, then then value will be overwritten.

The slice number is referenced from 0 to (total number of slice - 1) regardless of the number of samples in the "slice" dimension of the image.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putSliceInfo in interface InfoStorer
Parameters:
infoList - the list of InfoItems to put.
slice - the slice number.
Throws:
java.io.IOException - if the information cannot be added.

putSliceInfo

public void putSliceInfo(java.lang.String name,
                         java.lang.String value,
                         int slice)
                  throws java.io.IOException
Description copied from interface: InfoStorer
Adds an item to the slice-specific information. If an info item with the same name exists, then then value will be overwritten.

The slice number is referenced from 0 to (total number of slice - 1) regardless of the number of samples in the "slice" dimension of the image.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
putSliceInfo in interface InfoStorer
Parameters:
name - the name of the information item to put.
value - a String to be associated with this name in the slice-specific info.
slice - the slice number.
Throws:
java.io.IOException - if the information cannot be added.

getInfo

public java.lang.String getInfo(java.lang.String name)
                         throws InfoNotFoundException
Description copied from interface: InfoStorer
Returns a string representing the value of this information item in the general image information.

For example, if there is a item with a name "pixel_x_size" and a value "0.91162" in the general info, and name "pixel_x_size" is supplied, then this method will return "0.91162".

Specified by:
getInfo in interface InfoStorer
Parameters:
name - the name of this information field.
Returns:
a java.lang.String representation of the value of this information field.
Throws:
InfoNotFoundException - if the name is not found in the general info.

getInfo

public java.lang.String getInfo(java.lang.String name,
                                int dim,
                                int n)
                         throws InfoNotFoundException
Description copied from interface: InfoStorer
Returns a java.lang.String representing the value of this information item in a particular dimension of this image. For example, if there is a item "pixel_x_size=0.91162" in the file info for this dimension, and a name "pixel_x_size" is supplied, then this method will return "0.91162".

Specified by:
getInfo in interface InfoStorer
Parameters:
name - the name of this information item.
dim - the dimension of this image to look for the information. For example in a 3-dimensional image you would look in dimension 0 for slice-specific info.
n - the element to look in. For example in a 3-dimensional image you would look in slice n to info that applied only to slice n.
Returns:
a java.lang.String representation of the value of this information.
Throws:
InfoNotFoundException - if the name is not found in this dimension/element info.

getSliceInfo

public java.lang.String getSliceInfo(java.lang.String name,
                                     int slice)
                              throws InfoNotFoundException
Description copied from interface: InfoStorer
Returns a java.lang.String representing the value of this information item in a particular slice of this image.

The slice number is referenced from 0 to (total number of slice - 1) regardless of the number of samples in the "slice" dimension of the image.

Specified by:
getSliceInfo in interface InfoStorer
Parameters:
name - the name of this information item.
slice - the slice number.
Returns:
a java.lang.String representation of the value of this information.
Throws:
InfoNotFoundException - if the name is not found for the specified slice.

removeInfo

public void removeInfo(java.lang.String name)
Description copied from interface: InfoStorer
Removes an item from the general file information. If an info item with the given name is not present in the general info, then this method does nothing.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
removeInfo in interface InfoStorer
Parameters:
name - the name of the information item to be removed.

removeInfo

public void removeInfo(java.lang.String name,
                       int dim,
                       int n)
Description copied from interface: InfoStorer
Removes an item from the dimension-specific information. If an info item with the given name is not present in the dimension-specific, then this method does nothing.
N.B. For disk-based images, the changes in the info will not be reflected on disk unless the close() method is called.

Specified by:
removeInfo in interface InfoStorer
Parameters:
name - the name of the information item to put.
dim - the dimension of this image to from which to remove the information. For example in a 3-dimensional image you would put to dimension 0 for slice-specific info.
n - the element to from which to remove the info item. For example in a 3-dimensional image you would put to slice n to info that applied only to slice n.

getInfoList

public InfoList getInfoList()
Description copied from interface: InfoStorer
Returns an InfoList object which is the general info for this image.

Specified by:
getInfoList in interface InfoStorer
Returns:
an InfoList which is the general file info for this InfoStorer.

setInfoList

public void setInfoList(InfoList infoList)
                 throws java.io.IOException
Description copied from interface: InfoStorer
Sets a new InfoList to the general file info of this image.

Specified by:
setInfoList in interface InfoStorer
Parameters:
infoList - the InfoList object to set to the general file info for this image.
Throws:
java.io.IOException - if the InfoList cannot be set.

getInfoList

public InfoList getInfoList(int dim,
                            int n)
Description copied from interface: InfoStorer
Returns an InfoList object applying to a particular dimension/element for this image.

Specified by:
getInfoList in interface InfoStorer
Parameters:
dim - the dimension for which to get the information list.
n - the element for which to get the information list.
Returns:
an InfoList object from a particular dimension of this InfoStorer.

getSliceInfoList

public InfoList getSliceInfoList(int slice)
Description copied from interface: InfoStorer
Returns an InfoList object applying to a particular slice of this image.

Specified by:
getSliceInfoList in interface InfoStorer
Parameters:
slice - the slice number.
Returns:
an InfoList object from a particular slice of this InfoStorer.

setInfoList

public void setInfoList(InfoList infoList,
                        int dim,
                        int n)
                 throws java.io.IOException
Description copied from interface: InfoStorer
Sets a new InfoList a specific dimension of this image.

Specified by:
setInfoList in interface InfoStorer
Parameters:
infoList - the InfoList to associate with this image/dimension.
dim - the dimension to which to set the information list.
n - the element to which to set the information list.
Throws:
java.io.IOException - if the InfoList cannot be set.

setSliceInfoList

public void setSliceInfoList(InfoList infoList,
                             int slice)
                      throws java.io.IOException
Description copied from interface: InfoStorer
Sets a new InfoList a specific slice of this image.

Specified by:
setSliceInfoList in interface InfoStorer
Parameters:
infoList - the InfoList to associate with this image/slice.
slice - the slice for which to set the information list.
Throws:
java.io.IOException - if the InfoList cannot be set.

appendInfoList

public void appendInfoList(InfoList infoList)
                    throws java.io.IOException
Description copied from interface: InfoStorer
Appends an InfoList to the existing general file info of this image.

Specified by:
appendInfoList in interface InfoStorer
Parameters:
infoList - the InfoList object to append to the general file info for this image.
Throws:
java.io.IOException - if the InfoList cannot be appended.

appendInfoList

public void appendInfoList(InfoList infoList,
                           int dim,
                           int n)
                    throws MultiSliceImageException
Appends an InfoList to that for a particular dimension of this image.

Specified by:
appendInfoList in interface InfoStorer
Parameters:
infoList - ths list to append.
dim - the diemension for which the InfoList will be appended.
n - the element of that dimension for which the InfoList will be appended.
Throws:
MultiSliceImageException - if the InfoList cannot be appended.

addExtendedData

public void addExtendedData(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData)
                     throws ANZException
Adds a block of ExtendedData to this NIFTIImage.

Parameters:
extendedData - the ExtendedData to add.
Throws:
ANZException - if the ExtendedData cannot be added.

getExtendedData

public java.util.List<com.xinapse.multisliceimage.Analyze.ExtendedData> getExtendedData()
Returns a java.util.List of ExtendedData for this NIFTIImage.

Returns:
a java.util.List of ExtendedData, or null if there is no ExtendedData.

removeExtendedData

public void removeExtendedData(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData)
                        throws ANZException
Removes a block of ExtendedData from this NIFTIImage. This method does nothing if the supplied ExtendedData is not present.

Parameters:
extendedData - the ExtendedData to remove.
Throws:
ANZException - if the extended data cannot be removed.

getHTMLDescription

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

Specified by:
getHTMLDescription in interface LoadableImage
Overrides:
getHTMLDescription in class ANZImage
Parameters:
slice - the slice number.
Returns:
a String describing this image slice.

main

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

Parameters:
args - a list of images to try to open.


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