Class NIFTIImage
- All Implemented Interfaces:
ReadableImage
,WritableImage
,InfoStorer
,AutoCloseable
,Cloneable
- Direct Known Subclasses:
NIFTI2Image
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, 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 MultiSliceImage.getPix()
and
MultiSliceImage.getSlice(int)
, the intensities are scaled according to the intensity rescaling
factors that are part of the NIFTI-1 standard.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.xinapse.image.ReadableImage
ReadableImage.Position
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The file extension for compressed NIFTI image files.static final String
The property value key for setting whether NIFTI images should be stored compressed, or uncompressed.static final boolean
Whether to store NIFTI images compressed by default.static final boolean
Whether to store NIFTI images in one file (.nii) by default.static final String
The file extension for NIFTI image files.static final String
The property value key for setting whether NIFTI images should be stored in one file, or two.static final String
The file extension for compressed NIFTI image files in upper case form.static final String
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, BODY_PART_NAME, COLOUR_MAPPING_NAME, DW_B_MATRIX_NAME, DW_B_VALUE_NAME, DW_GRADIENT_VECTOR_NAME, ECHO_TIME_NAME, ECHO_TRAIN_LENGTH_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, LATERALITY_NAME, MODALITY_NAME, mode, PATIENT_ID_NAME, PATIENT_NAME_NAME, PATIENT_POSITION_NAME, PATIENT_SEX_NAME, pixArray, PIXEL_SPACING_NAME, PIXEL_X_SIZE_NAME, PIXEL_Y_SIZE_NAME, PIXEL_Z_SIZE_NAME, PULSE_SEQUENCE_NAME, randomAccessFile, REPETITION_TIME_NAME, SAT_PULSE_FREQ_OFFSET_PPM_NAME, SCAN_DATE_NAME, SCANNING_SEQUENCE_NAME, SEQUENCE_VARIANT_NAME, SERIES_DESCRIPTION_NAME, SERIES_INSTANCE_UID_NAME, SERIES_NUMBER_NAME, SLICE_THICKNESS_NAME, STORAGE_CLASS_UID_NAME, STUDY_ID_NAME, STUDY_INSTANCE_UID_NAME, TIME_BETWEEN_FRAMES_NAME, TRIGGER_DELAY_NAME
-
Constructor Summary
ConstructorDescriptionCreates an uninitialised instance of a NIFTIImage.NIFTIImage
(short nCols, short nRows, short nSlices, short nFrames, ANZPixFormat dataType) Creates a new in-memory NIFTIImage.NIFTIImage
(ANZPixFormat dataType, Short... dims) Creates a new in-memory NIFTIImage.NIFTIImage
(NIFTIHeader hdr) Creates a new in-memory NIFTIImage, using information from an existing NIFTIHeader.NIFTIImage
(File f, NIFTIHeader header) Creates a new disk-based NIFTIImage, using an existing header as a template for the new image.NIFTIImage
(String fileName, short nCols, short nRows, short nSlices, short nFrames, ANZPixFormat dataType) Creates a new disk-based NIFTIImage.NIFTIImage
(String fileName, ANZPixFormat dataType, Short... dims) Creates a new disk-based NIFTIImage.NIFTIImage
(String fileName, NIFTIHeader header) Creates a new disk-based NIFTIImage (either NIFTI-1 or NIFTI-2), using an existing header (NIFTIHeader or NIFTI2Header) as a template for the new image.NIFTIImage
(String fileName, String mode) Opens an existing NIFTIImage, with pixel data remaining on disk until requested. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtendedData
(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData) Adds a block ofExtendedData
to thisNIFTIImage
.void
anonymise
(String patientName, String patientID, Date birthDate, boolean patSex, String patAddr, String patInsurancePlanID, String accessionNumber, boolean patOther, String physicianName, String physicianAddr, String institutionName, String institutionAddr, String deptName, String stationName, String telNumber, boolean removePrivateElements) Anonymise this WritableImage.void
appendAuditInfo
(String name, String value) Appends audit trail information to this image.void
appendInfoList
(InfoList infoList) Appends anInfoList
to the existing general file info of this image.void
appendInfoList
(InfoList infoList, int dim, int n) Appends anInfoList
to that for a particular dimension of this image.void
close()
Closes a NIFTIImage and frees up resources.com.xinapse.dicom.BodyPart
By default, body part recording is not supported, so this method always returnsnull
.static String
Returns the common name for this type of image.Returns the echo train length for this image.List<com.xinapse.multisliceimage.Analyze.ExtendedData>
Returns the excitation pulse flip angle for this image.float[]
getFrameDWBMatrix
(int frame) Returns the diffusion-weighting b-matrix for one frame of this image.getFrameDWbValue
(int frame) Returns the diffusion-weighting b-value for one frame of this 4-D image.org.jogamp.vecmath.Vector3f
getFrameDWGradientVector
(int frame) Returns the diffusion-weighting gradient-vector for one frame of this image 4-D image.getFrameInfo
(String name, int frame) Returns aString
representing the value of this information item in a particular frame of this image.getFrameInfoList
(int frame) Returns anInfoList
object applying to a particular frame of this image.getFrameTriggerDelayMS
(int frame) Returns the trigger delay, in milliseconds, for one frame of this image.getHTMLDescription
(int slice) Returns a String description of a slice of this image in HTML format.org.jogamp.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.org.jogamp.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.Returns the human readable name for this type of image.Returns a string representing the value of this information item in the general image information.Returns aString
representing the value of this information item in a particular dimension of this image.Returns anInfoList
object which is the general info for this image.getInfoList
(int dim, int n) Returns anInfoList
object applying to a particular dimension/element for this image.float[]
Returns the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified ingetRescaleUnits()
in the expression:
Output units = m*I + b
.Returns theNIFTIIntent
in thisNIFTIImage
.com.xinapse.dicom.Laterality
By default, laterality recording is not supported, so this method returnsLaterality.BOTH
.Returns the patient date of birth for this image.Returns the patient ID for this image.Returns the patient name for this image.Returns the position in which the patient is lying in the scanning equipment.com.xinapse.dicom.Sex
Returns the patient sex for this image.static boolean
Returns the user's preference about whether NIFTI images should be stored compressed.static boolean
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
(File f, boolean withImageIcon) Returns thePreviewIcon
for an NIFTIImage, ornull
if the suppliedFile
does not represent a NIFTI image.Returns the name of the pulse sequence with which this image was collected.getQForm()
Returns the qForm in thisNIFTIImage
.com.xinapse.dicom.RescaleUnits
Returns RescaleUnits.US.Returns the saturation pulse frequency offset for this image if it has a single saturation pulse frequency offset.getSaturationFreqOffsetPPM
(int index) Returns the scan saturation frequency offset for one dimension index of this image in parts-per-million.Returns the scan date for this image.Returns the DICOM Scanning Sequence with which this image was collected.Returns the scan echo time for this image if it has a single echo-time.getScanTE
(int index) Returns the scan echo time for one dimension index of this image.Returns the scan inversion time for this image.Returns the scan repetition time for this image.Returns the DICOM Scanning Sequence Variant with which this image was collected.Returns a short description of the series (scan), such as is provided by the DICOM series description.Returns the series number for this ReadableImage.getSForm()
Returns the sForm in thisNIFTIImage
.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.float[]
getSliceDWBMatrix
(int slice) Returns the diffusion-weighting b-matrix for one slice of this image.getSliceDWbValue
(int slice) Returns the diffusion-weighting b-value for one slice of this image.org.jogamp.vecmath.Vector3f
getSliceDWGradientVector
(int slice) Returns the diffusion-weighting gradient-vector for one slice of this image.getSliceInfo
(String name, int slice) Returns aString
representing the value of this information item in a particular slice of this image.getSliceInfoList
(int slice) Returns anInfoList
object applying to a particular slice of this image.Returns the slice thickness (in mm).getSliceTriggerDelayMS
(int slice) Returns the trigger delay, in milliseconds, for one slice of this image.Returns the study ID for this ReadableImage.static boolean
imageExists
(String fileName) Tests whether aNIFTIImage
with the given name already exists on disk.static void
Run the self-test for the NIFTIImage class.void
putFrameInfo
(InfoList infoList, int frame) Adds all the items in an InfoList to the frame-specific information.void
putFrameInfo
(String name, String value, int frame) Adds an item to the frame-specific information.void
Adds an item to the general file info.void
Adds an item to the dimension-specific information.void
Adds an item to the general file info.void
Adds an item to the dimension-specific information.void
Adds an item to the general file info.void
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
(String name, String value, int slice) Adds an item to the slice-specific information.void
removeExtendedData
(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData) Removes a block ofExtendedData
from thisNIFTIImage
.void
removeInfo
(String name) Removes an item from the general file information.void
removeInfo
(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
setBodyPart
(com.xinapse.dicom.BodyPart bodyPart) By default, body part recording is not supported, so this method does nothing.void
Sets the echo train length for this image.void
setFlipAngle
(Float flipAngle) Sets the excitation pulse flip angle for this image.void
setFrameDWBMatrix
(float[] bMatrix, int frame) Sets the diffusion-weighting B-matrix for one "frame" of this 4-D image.void
setFrameDWbValue
(float bValue, int frame) Sets the diffusion-weighting b-value for one "frame" of this 4-D image.void
setFrameDWGradientVector
(org.jogamp.vecmath.Vector3f gradVec, int frame) Sets the diffusion-weighting gradient vector for one "frame" of this 4-D image.void
setFrameInfoList
(InfoList infoList, int frame) Sets a newInfoList
a specific frame of this image.void
setFrameTriggerDelayMS
(float delay, int frame) Sets the trigger delay (in milliseconds) for one "frame" of this 4-D image.void
setImageOrientationPatient
(org.jogamp.vecmath.Vector3f[] orientation, 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
(org.jogamp.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 newInfoList
to the general file info of this image.void
setInfoList
(InfoList infoList, int dim, int n) Sets a newInfoList
a specific dimension of this image.void
setIntensityRescale
(float rescaleSlope, float rescaleIntercept) Sets the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified inWritableImage.setRescaleUnits(com.xinapse.dicom.RescaleUnits)
in the expression:
Output units = m*I + b
.void
setIntent
(NIFTIIntent intent) Sets theNIFTIIntent
in thisNIFTIImage
.void
setLaterality
(com.xinapse.dicom.Laterality laterality) By default, laterality recording is not supported, so this method does nothing.void
setPatientDoB
(Date patientDoB) Sets the patient's date of birth for this image.void
setPatientID
(String patientID) Sets the patient ID for this image.void
setPatientName
(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 thisWritableImage
.void
setPatientSex
(com.xinapse.dicom.Sex sex) Sets the patient sex for this image.void
setPulseSequence
(String seqName) Sets the pulse sequence name for this image.void
setQForm
(NIFTIXForm qForm) Sets the qForm code in thisNIFTIImage
.void
setRescaleUnits
(com.xinapse.dicom.RescaleUnits units) Sets the rescale units.void
setSaturationFreqOffsetPPM
(Float freqOffset) Sets the saturation pulse frequency offset for this image, for images with a single saturation pulse frequency offset.void
setSaturationFreqOffsetPPM
(Float freqOffset, int index) Sets the saturation frequency offset for one dimension index of this image.void
setScanDate
(Date scanDate) Sets the scan date/time for this image.void
Sets the DICOM scanning sequence for this image.void
Sets the scan echo time for this image, for single-echo-time images.void
Sets the scan echo time for one dimension index of this image.void
Sets the scan inversion time for this image.void
Sets the scan repetition time for this image.void
Sets the DICOM scanning sequence variant for this image.void
setSeriesDescription
(String description) Sets a short description of the series (scan).void
setSeriesNumber
(Integer seriesNumber) Sets the series number for this image.void
setSForm
(NIFTIXForm sForm) Sets the sForm code in thisNIFTIImage
.void
setSliceDWBMatrix
(float[] bMatrix, int slice) Sets the diffusion-weighting B-matrix for one slice of this image.void
setSliceDWbValue
(float bValue, int slice) Sets the diffusion-weighting b-value for one slice of this image.void
setSliceDWGradientVector
(org.jogamp.vecmath.Vector3f gradVec, int slice) Sets the diffusion-weighting gradient vector for one slice of this image.void
setSliceInfoList
(InfoList infoList, int slice) Sets a newInfoList
a specific slice of this image.void
setSliceThickness
(Float thickness) Sets the slice thickness (in mm).void
setSliceTriggerDelayMS
(float delay, int slice) Sets the trigger delay (in milliseconds) for one slice of this image.void
setStudyID
(String studyID) Sets the study ID for this image.static String
stripExtension
(String fileName) Strips any ".img", ".img.gz", ".hdr", ".hdr.gz", ".nii", or ".nii.gz" extension (in upper or lowe case) from a file name.boolean
Returnstrue
because NIFTI-1 images support intensity rescaling.Writes this NIFTIImage to disk.Methods inherited from class com.xinapse.multisliceimage.Analyze.ANZImage
disposeImageData, getByteOrder, getCopy, getDataType, getDescription, getDescription, getDims, getFileDataOffset, getHeader, getHTMLDescription, getImageOrientationPatient, getImagePositionPatient, getMax, getMin, getNativeColourMapping, getNativeHeader, getNCols, getNDim, getNFrames, getNRows, getNSlices, getPixelXSize, getPixelYSize, getPixelZSize, getStoredPixelDataType, getTimeBetweenFrames, getTitle, getTotalNSlices, isCompressed, isOpen, setDBName, setDescription, setImageOrientationPositionPatient, setMinMax, setNativeColourMapping, setPixelSpacing, setPixelXSize, setPixelYSize, setPixelZSize, setTimeBetweenFrames, setTitle, toString
Methods inherited from class com.xinapse.multisliceimage.MultiSliceImage
clone, getDateFormat, getFrameDim, getFrameOfReferenceUID, getModality, getMostLikePlane, getPix, getPix, getPix, getPix, getPix, getPresentationPixelDataType, getROIs, getScanDateFormat, getSlice, getSlice, getSliceDim, getStoredPix, getSuggestedFileName, isModified, parseMultiValuedString, putPix, putPix, putPix, putPix, putSlice, setFrameOfReferenceUID, setIntensityRescale, setMinMax, setModality, setModified, setSeriesInstanceUID, setStudyInstanceUID, setSuggestedFileName
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.xinapse.image.ReadableImage
getAffineTransform, getAffineTransform, getNSliceLocations
Methods inherited from interface com.xinapse.image.WritableImage
appendToTitle
-
Field Details
-
ONE_FILE_PROPERTY_KEY
The property value key for setting whether NIFTI images should be stored in one file, or two.- See Also:
-
COMPRESSED_PROPERTY_KEY
The property value key for setting whether NIFTI images should be stored compressed, or uncompressed.- See Also:
-
DEFAULT_NIFTI_ONE_FILE
public static final boolean DEFAULT_NIFTI_ONE_FILEWhether to store NIFTI images in one file (.nii) by default.- See Also:
-
DEFAULT_COMPRESSED
public static final boolean DEFAULT_COMPRESSEDWhether to store NIFTI images compressed by default.- See Also:
-
EXTENSION
The file extension for NIFTI image files.- See Also:
-
UPPERCASE_EXTENSION
The file extension for NIFTI image files in upper case form. -
COMPRESSED_EXTENSION
The file extension for compressed NIFTI image files.- See Also:
-
UPPERCASE_COMPRESSED_EXTENSION
The file extension for compressed NIFTI image files in upper case form.
-
-
Constructor Details
-
NIFTIImage
public NIFTIImage()Creates an uninitialised instance of a NIFTIImage. Needed so that newInstance() method can be called on the class. -
NIFTIImage
public NIFTIImage(short nCols, short nRows, short nSlices, short nFrames, ANZPixFormat dataType) throws ANZException, IOException Creates a new in-memory NIFTIImage. 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
- theANZPixFormat
for the image.- Throws:
ANZException
- if the image cannot be created.IOException
- if an I/O error occurs.
-
NIFTIImage
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.IOException
- if an I/O error occurs.
-
NIFTIImage
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.IOException
- if an I/O error occurs.
-
NIFTIImage
public NIFTIImage(String fileName, short nCols, short nRows, short nSlices, short nFrames, ANZPixFormat dataType) throws 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, then 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
- theANZPixFormat
for the image.- Throws:
ANZException
- if the NIFTIImage cannot be instantiated.IOException
- if an I/O error occurs.
-
NIFTIImage
public NIFTIImage(String fileName, ANZPixFormat dataType, Short... dims) throws 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, then 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.IOException
- if an I/O error occurs.
-
NIFTIImage
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, then this will be handled.header
- the NIFTIHeader to use as the template.- Throws:
ANZException
- if the new image cannot be created on disk.IOException
- if an I/O error occurs.
-
NIFTIImage
Creates a new disk-based NIFTIImage (either NIFTI-1 or NIFTI-2), using an existing header (NIFTIHeader or NIFTI2Header) as a template for the new image. After manipulation, a call to close() 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, then 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 NIFTIHeader or NIFTI2Header to use as the template.- Throws:
ANZException
- if the new image cannot be created on disk.IOException
- if an I/O error occurs.
-
NIFTIImage
public NIFTIImage(String fileName, String mode) throws InvalidImageException, IOException, 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:
InvalidImageException
- if the image cannot be opened or loaded, or if mode is invalid.FileNotFoundException
- if the image file doesn't exist.IOException
- if an I/O error occurs.
-
-
Method Details
-
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.
-
imageExists
Tests whether aNIFTIImage
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
Returns thePreviewIcon
for an NIFTIImage, ornull
if the suppliedFile
does not represent a NIFTI image.- Parameters:
f
- theFile
to be tested.withImageIcon
- whether a image preview is to be generated. Generating an image preview will take longer than not generating one.- Returns:
PreviewIcon
if the File produces anNIFTIImage
;null
otherwise.
-
write
Writes this NIFTIImage to disk. This method will either:- write that header to a .hdr file, and the image data to a .img file, or
- write the image data to the same file as the header information in a .nii file.
- Specified by:
write
in interfaceWritableImage
- Overrides:
write
in classANZImage
- 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 file name(s).- Returns:
- the actual file name used to write the image, including any added extension.
- Throws:
InvalidImageException
- if the image cannot be written.IOException
- if an I/O error occurs.
-
close
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 interfaceAutoCloseable
- Specified by:
close
in interfaceReadableImage
- Overrides:
close
in classANZImage
- Throws:
IOException
- if an I/O error occurs.
-
getImagePositionPatient
public org.jogamp.vecmath.Point3f getImagePositionPatient(int slice) throws IndexOutOfBoundsException Description copied from interface:ReadableImage
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 interfaceReadableImage
- Overrides:
getImagePositionPatient
in classANZImage
- Parameters:
slice
- the slice number (indexed from 0) for which to return the pixel coordinates.- 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:
IndexOutOfBoundsException
- if the slice number is bad for this image.
-
setImagePositionPatient
public void setImagePositionPatient(org.jogamp.vecmath.Point3f position, int slice) Description copied from interface:WritableImage
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 interfaceWritableImage
- 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 org.jogamp.vecmath.Vector3f[] getImageOrientationPatient(int slice) throws IndexOutOfBoundsException Description copied from interface:ReadableImage
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 interfaceReadableImage
- Overrides:
getImageOrientationPatient
in classANZImage
- Parameters:
slice
- the slice for which to return the image orientation.- Returns:
- a
Vector3f
[], corresponding to the direction cosines of the image row, column and slice directions in Left,Posterior,Superior (LPS) coordinates. Returnsnull
if the direction cosines cannot be retrieved from this image. - Throws:
IndexOutOfBoundsException
- if the image does not have the right dimensionality or the slice number is inappropriate for this image.
-
setImageOrientationPatient
public void setImageOrientationPatient(org.jogamp.vecmath.Vector3f[] orientation, int slice) throws 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 interfaceWritableImage
- Specified by:
setImageOrientationPatient
in classMultiSliceImage
- Parameters:
orientation
- 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:
IndexOutOfBoundsException
- if thecosines
array does not have the correct dimensions.
-
supportsIntensityRescaling
public boolean supportsIntensityRescaling()Returnstrue
because NIFTI-1 images support intensity rescaling.- Specified by:
supportsIntensityRescaling
in interfaceWritableImage
- Returns:
true
.
-
getIntensityRescale
public float[] getIntensityRescale()Description copied from interface:ReadableImage
Returns the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified ingetRescaleUnits()
in the expression:
Output units = m*I + b
.- Specified by:
getIntensityRescale
in interfaceReadableImage
- Returns:
- an array will be of length 2 where the first element is
m
and the second isb
.
-
setIntensityRescale
Description copied from interface:WritableImage
Sets the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified inWritableImage.setRescaleUnits(com.xinapse.dicom.RescaleUnits)
in the expression:
Output units = m*I + b
.- Specified by:
setIntensityRescale
in interfaceWritableImage
- Parameters:
rescaleSlope
- the value ofm
in the expression above.rescaleIntercept
- the value ofb
in the expression above.- Throws:
IOException
- if an I/O error occurs.
-
getRescaleUnits
public com.xinapse.dicom.RescaleUnits getRescaleUnits()Returns RescaleUnits.US.- Specified by:
getRescaleUnits
in interfaceReadableImage
- Overrides:
getRescaleUnits
in classANZImage
- Returns:
- com.xinapse.dicom.RescaleUnits.US.
-
setRescaleUnits
Description copied from interface:WritableImage
Sets the rescale units.- Specified by:
setRescaleUnits
in interfaceWritableImage
- Parameters:
units
- the rescale units.- Throws:
IOException
- if the rescale units cannot be set.
-
getCommonName
Returns the common name for this type of image.- Returns:
- the
String
"NIFTI-1".
-
getImageTypeName
Returns the human readable name for this type of image.- Specified by:
getImageTypeName
in interfaceWritableImage
- Returns:
- a
String
like "NIFTI-1" or "NIFTI-2".
-
getQForm
Returns the qForm in thisNIFTIImage
.- Returns:
- the
qForm
set in thisNIFTIImage
.
-
setQForm
Sets the qForm code in thisNIFTIImage
.- Parameters:
qForm
- theqForm
to set in thisNIFTIImage
.- Throws:
ANZException
- if the qForm cannot be set.
-
getSForm
Returns the sForm in thisNIFTIImage
.- Returns:
- the
sForm
in thisNIFTIImage
.
-
setSForm
Sets the sForm code in thisNIFTIImage
.- Parameters:
sForm
- thesForm
to set in thisNIFTIImage
.- Throws:
ANZException
- if the sForm cannot be set.
-
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.
N.B. Note: the patient-centric coordinate system is different from that defined in the NIFTI-1 standard. Jim's coordinate system is a left-handed system, with:- The first coordinate increasing to the patient left (L).
- The second coordinate increasing to the patient posterior (P).
- The third coordinate increasing to the patient superior (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
Returns theNIFTIIntent
in thisNIFTIImage
.- Returns:
- the
NIFTIIntent
set in thisNIFTIImage
.
-
setIntent
Sets theNIFTIIntent
in thisNIFTIImage
.- Parameters:
intent
- theNIFTIIntent
to set in thisNIFTIImage
.- Throws:
ANZException
- if the intent cannot be set.
-
getPatientPosition
Description copied from interface:ReadableImage
Returns the position in which the patient is lying in the scanning equipment. For example,PatientPosition.HFS
(head-first supine).- Specified by:
getPatientPosition
in interfaceReadableImage
- Returns:
- the position in which the patient is lying in the scanning equipment, or
null
if the patient position cannot be determined.
-
setPatientPosition
Description copied from interface:WritableImage
Sets the position in which the patient is lying in the scanning equipment for thisWritableImage
.- Specified by:
setPatientPosition
in interfaceWritableImage
- Parameters:
position
- the position in which the patient is lying in the scanning equipment. e.g.PatientPosition.HFS
(head-first supine).- Throws:
IOException
- if the patient position cannot be set for this image.
-
setScanDate
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
scanDate
- the new scan date/time to be assigned to this image.- Throws:
IOException
- if the scan date cannot be set.
-
setPulseSequence
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
seqName
- the new name of the pulse sequence to be assigned to this image.- Throws:
IOException
- if the pulse sequence name cannot be set.
-
setScanningSequence
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
seq
- the new scanning sequence to be assigned to this image.- Throws:
IOException
- if the scanning sequence cannot be set.
-
setSequenceVariant
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
seqVar
- the new scanning sequence variant to be assigned to this image.- Throws:
IOException
- if the scanning sequence variant cannot be set.
-
setSeriesNumber
Description copied from interface:WritableImage
Sets the series number for this image.
N.B. For disk-based images, the changes in the series number will not be reflected on disk unless the close() method is called.- Specified by:
setSeriesNumber
in interfaceWritableImage
- Parameters:
seriesNumber
- the new series number to be assigned to this image.- Throws:
IOException
- if the series number cannot be set.
-
setSeriesDescription
Description copied from interface:WritableImage
Sets a short description of the series (scan).
N.B. For disk-based images, the changes in the series description will not be reflected on disk unless the close() method is called.- Specified by:
setSeriesDescription
in interfaceWritableImage
- Parameters:
description
- the new short description of the series, or null if none is available.- Throws:
IOException
- if the description cannot be set.
-
getSliceThickness
Description copied from interface:ReadableImage
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 interfaceReadableImage
- Returns:
- the slice thickness in mm, or null if the slice thickness is not set, or its value is corrupt.
-
setSliceThickness
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
thickness
- the slice thickness in mm, or null to remove the slice thickness information.- Throws:
IOException
- if the slice thickness cannot be set for this image.
-
getBodyPart
public com.xinapse.dicom.BodyPart getBodyPart()Description copied from class:MultiSliceImage
By default, body part recording is not supported, so this method always returnsnull
.- Specified by:
getBodyPart
in interfaceReadableImage
- Overrides:
getBodyPart
in classMultiSliceImage
- Returns:
null
.
-
setBodyPart
Description copied from class:MultiSliceImage
By default, body part recording is not supported, so this method does nothing.- Specified by:
setBodyPart
in interfaceWritableImage
- Overrides:
setBodyPart
in classMultiSliceImage
- Parameters:
bodyPart
- body the imaged body part.- Throws:
IOException
- if body part cannot be set.
-
getLaterality
public com.xinapse.dicom.Laterality getLaterality()Description copied from class:MultiSliceImage
By default, laterality recording is not supported, so this method returnsLaterality.BOTH
.- Specified by:
getLaterality
in interfaceReadableImage
- Overrides:
getLaterality
in classMultiSliceImage
- Returns:
Laterality.BOTH
.
-
setLaterality
Description copied from class:MultiSliceImage
By default, laterality recording is not supported, so this method does nothing.- Specified by:
setLaterality
in interfaceWritableImage
- Overrides:
setLaterality
in classMultiSliceImage
- Parameters:
laterality
- the image laterality.- Throws:
IOException
- if laterality cannot be set.
-
getScanTR
Returns the scan repetition time for this image.- Specified by:
getScanTR
in interfaceReadableImage
- Returns:
- the scan TR for this image.
-
setScanTR
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 interfaceWritableImage
- Parameters:
TR
- the new scan TR to be assigned to this image.- Throws:
IOException
- if the scan TR cannot be set.
-
getScanTI
Returns the scan inversion time for this image.- Specified by:
getScanTI
in interfaceReadableImage
- Returns:
- the scan TI for this image.
-
setScanTI
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 interfaceWritableImage
- Parameters:
TI
- the new scan TI to be assigned to this image.- Throws:
IOException
- if the scan TI cannot be set.
-
getScanTE
Returns the scan echo time for this image if it has a single echo-time.- Specified by:
getScanTE
in interfaceReadableImage
- Returns:
- the scan TE for this image.
-
setScanTE
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 interfaceWritableImage
- Parameters:
TE
- the new scan TE to be assigned to this image.- Throws:
IOException
- if an I/O error occurs.
-
getScanTE
Description copied from interface:ReadableImage
Returns the scan echo time for one dimension index of this image. For 3-D images, the dimension index is the slice dimension. For 4-D (or higher dimensionality) images, the dimension index is the frame dimension.- Specified by:
getScanTE
in interfaceReadableImage
- Parameters:
index
- the index for which to return the echo time.- Returns:
- the scan TE for the specified index of this image, or null if not set for this image.
- Throws:
IndexOutOfBoundsException
- if the index is bad for this image.
-
setScanTE
Description copied from interface:WritableImage
Sets the scan echo time for one dimension index of this image. For 3-D images, the dimension index is the slice dimension. For 4-D (or higher dimensionality) images, the dimension index is the frame dimension. 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 interfaceWritableImage
- Parameters:
TE
- the new scan TE to be assigned to this image.index
- the slice number for which to set the echo time.- Throws:
IOException
- if the scan TE cannot be set because of an I/O error.
-
getSaturationFreqOffsetPPM
Returns the saturation pulse frequency offset for this image if it has a single saturation pulse frequency offset.- Specified by:
getSaturationFreqOffsetPPM
in interfaceReadableImage
- Returns:
- the saturation pulse frequency offset for this image, in PPM.
-
setSaturationFreqOffsetPPM
Sets the saturation pulse frequency offset for this image, for images with a single saturation pulse frequency offset.
N.B. For disk-based images, the changes in the saturation pulse frequency offset will not be reflected on disk unless the close() method is called.- Specified by:
setSaturationFreqOffsetPPM
in interfaceWritableImage
- Parameters:
freqOffset
- the new saturation pulse frequency offset to be assigned to this image.- Throws:
IOException
- if an I/O error occurs.
-
getSaturationFreqOffsetPPM
Description copied from interface:ReadableImage
Returns the scan saturation frequency offset for one dimension index of this image in parts-per-million. For 3-D images, the dimension index is the slice dimension. For 4-D (or higher dimensionality) images, the dimension index is the frame dimension.- Specified by:
getSaturationFreqOffsetPPM
in interfaceReadableImage
- Parameters:
index
- the index for which to return the saturation frequency offset.- Returns:
- the scan TE for the specified index of this image, or null if not set for this image.
- Throws:
IndexOutOfBoundsException
- if the index is bad for this image.
-
setSaturationFreqOffsetPPM
Description copied from interface:WritableImage
Sets the saturation frequency offset for one dimension index of this image. For 3-D images, the dimension index is the slice dimension. For 4-D (or higher dimensionality) images, the dimension index is the frame dimension. No exception occurs if the image format does not support saturation frequency offset recording.
N.B. For disk-based images, the changes in the saturation frequency offset will not be reflected on disk unless the close() method is called.- Specified by:
setSaturationFreqOffsetPPM
in interfaceWritableImage
- Parameters:
freqOffset
- the new saturation frequency offset to be assigned to this image.index
- the slice number for which to set the saturation frequency offset.- Throws:
IOException
- if the saturation frequency offset cannot be set because of an I/O error.
-
getEchoTrainLength
Returns the echo train length for this image.- Specified by:
getEchoTrainLength
in interfaceReadableImage
- Returns:
- the echo train length for this image.
-
setEchoTrainLength
Sets the echo train length for this image. N.B. For disk-based images, the changes in the echo train length will not be reflected on disk unless the close() method is called.- Specified by:
setEchoTrainLength
in interfaceWritableImage
- Parameters:
etl
- the new echo train length to be assigned to this image; null if the echo train length is to be unassigned.- Throws:
IOException
- if the echo train length cannot be set because of an I/O error.
-
getFlipAngle
Returns the excitation pulse flip angle for this image.- Specified by:
getFlipAngle
in interfaceReadableImage
- Returns:
- the excitation pulse flip angle for this image.
-
setFlipAngle
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 interfaceWritableImage
- Parameters:
flipAngle
- the new scan flip angle to be assigned to this image.- Throws:
IOException
- if an I/O error occurs.
-
getSliceDWbValue
Description copied from interface:ReadableImage
Returns the diffusion-weighting b-value for one slice of this image.- Specified by:
getSliceDWbValue
in interfaceReadableImage
- 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, or
null
if the b-value cannot be found, or if the modality used to collect the image doesn't have a b-value defined - Throws:
IndexOutOfBoundsException
- if the slice number is bad for this image.
-
getFrameDWbValue
Description copied from interface:ReadableImage
Returns the diffusion-weighting b-value for one frame of this 4-D image.- Specified by:
getFrameDWbValue
in interfaceReadableImage
- Parameters:
frame
- the frame number for which to return the b-value.- Returns:
- the diffusion-weighting b-value for the specified frame of this image, or
null
if the b-value cannot be found, or if the modality used to collect the image doesn't have a b-value defined - Throws:
IndexOutOfBoundsException
- if the frame number is bad for this image, or it isn't a 4-D image.
-
setSliceDWbValue
Description copied from interface:WritableImage
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:
setSliceDWbValue
in interfaceWritableImage
- Parameters:
bValue
- the new b-value to be assigned to this image.slice
- the slice number for which to set the b-value.- Throws:
IOException
- if the scan b-value cannot be set.
-
setFrameDWbValue
Description copied from interface:WritableImage
Sets the diffusion-weighting b-value for one "frame" of this 4-D 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:
setFrameDWbValue
in interfaceWritableImage
- Parameters:
bValue
- the new b-value to be assigned to this image.frame
- the frame number for which to set the b-value.- Throws:
IOException
- if the scan b-value cannot be set.
-
getSliceDWGradientVector
public org.jogamp.vecmath.Vector3f getSliceDWGradientVector(int slice) throws IndexOutOfBoundsException Description copied from interface:ReadableImage
Returns the diffusion-weighting gradient-vector for one slice of this image.- Specified by:
getSliceDWGradientVector
in interfaceReadableImage
- 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, or
null
if the gradient vector cannot be found, or if the modality used to collect the image doesn't have a gradient vector defined. - Throws:
IndexOutOfBoundsException
- if the slice number is bad for this image.
-
getFrameDWGradientVector
public org.jogamp.vecmath.Vector3f getFrameDWGradientVector(int frame) throws IndexOutOfBoundsException Description copied from interface:ReadableImage
Returns the diffusion-weighting gradient-vector for one frame of this image 4-D image.- Specified by:
getFrameDWGradientVector
in interfaceReadableImage
- Parameters:
frame
- the frame number for which to return the gradient-vector.- Returns:
- the diffusion-weighting gradient-vector for the specified frame of this image, or
null
if the gradient vector cannot be found, or if the modality used to collect the image doesn't have a gradient vector defined. - Throws:
IndexOutOfBoundsException
- if the frame number is bad for this image, or it isn't a 4-D image.
-
setSliceDWGradientVector
public void setSliceDWGradientVector(org.jogamp.vecmath.Vector3f gradVec, int slice) throws IOException Description copied from interface:WritableImage
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:
setSliceDWGradientVector
in interfaceWritableImage
- Parameters:
gradVec
- the new gradient vector to be assigned to this image.slice
- the slice number for which to set the gradient vector.- Throws:
IOException
- if the scan gradient vector cannot be set.
-
setFrameDWGradientVector
public void setFrameDWGradientVector(org.jogamp.vecmath.Vector3f gradVec, int frame) throws IOException Description copied from interface:WritableImage
Sets the diffusion-weighting gradient vector for one "frame" of this 4-D 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:
setFrameDWGradientVector
in interfaceWritableImage
- Parameters:
gradVec
- the new gradient vector to be assigned to this image.frame
- the frame number for which to set the gradient vector.- Throws:
IOException
- if the scan gradient vector cannot be set.
-
getSliceDWBMatrix
Description copied from interface:ReadableImage
Returns the diffusion-weighting b-matrix for one slice of this image.- Specified by:
getSliceDWBMatrix
in interfaceReadableImage
- 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, or
null
if the B-matrix cannot be found, or if the modality used to collect the image doesn't have a B-matrix defined. The 6 unique matrix elements are returned as a float[] with elements in the order bXX, bXY, bXZ, bYY, bYZ, bZZ. - Throws:
IndexOutOfBoundsException
- if the slice number is bad for this image.
-
getFrameDWBMatrix
Description copied from interface:ReadableImage
Returns the diffusion-weighting b-matrix for one frame of this image.- Specified by:
getFrameDWBMatrix
in interfaceReadableImage
- Parameters:
frame
- the frame number for which to get the b-matrix.- Returns:
- the diffusion-weighting b-matrix for this image if it is a
magnetic resonance image, or
null
if the B-matrix cannot be found, or if the modality used to collect the image doesn't have a B-matrix defined. The 6 unique matrix elements are returned as a float[] with elements in the order bXX, bXY, bXZ, bYY, bYZ, bZZ. - Throws:
IndexOutOfBoundsException
- if the frame number is bad for this image, or it isn't a 4-D image.
-
setSliceDWBMatrix
Description copied from interface:WritableImage
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:
setSliceDWBMatrix
in interfaceWritableImage
- Parameters:
bMatrix
- the new B-matrix to be assigned to this image.slice
- the slice number for which to set the B-matrix.- Throws:
IOException
- if the scan B-matrix cannot be set.
-
setFrameDWBMatrix
Description copied from interface:WritableImage
Sets the diffusion-weighting B-matrix for one "frame" of this 4-D 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:
setFrameDWBMatrix
in interfaceWritableImage
- Parameters:
bMatrix
- the new B-matrix to be assigned to this image.frame
- the frame number for which to set the B-matrix.- Throws:
IOException
- if the scan B-matrix cannot be set.
-
getSliceTriggerDelayMS
Description copied from interface:ReadableImage
Returns the trigger delay, in milliseconds, for one slice of this image.- Specified by:
getSliceTriggerDelayMS
in interfaceReadableImage
- Parameters:
slice
- the slice number for which to get the trigger delay.- Returns:
- the trigger delay (in milliseconds) for this image, or
null
if the trigger delay cannot be found. - Throws:
IndexOutOfBoundsException
- if the slice number is bad for this image, or it isn't a 4-D image.
-
getFrameTriggerDelayMS
Description copied from interface:ReadableImage
Returns the trigger delay, in milliseconds, for one frame of this image.- Specified by:
getFrameTriggerDelayMS
in interfaceReadableImage
- Parameters:
frame
- the frame number for which to get the trigger delay.- Returns:
- the trigger delay (in milliseconds) for this image, or
null
if the trigger delay cannot be found. - Throws:
IndexOutOfBoundsException
- if the frame number is bad for this image, or it isn't a 4-D image.
-
setSliceTriggerDelayMS
Description copied from interface:WritableImage
Sets the trigger delay (in milliseconds) for one slice of this image. No exception occurs if the image format does not support recording the trigger delay.
N.B. For disk-based images, the changes in the trigger delay will not be reflected on disk unless the close() method is called.- Specified by:
setSliceTriggerDelayMS
in interfaceWritableImage
- Parameters:
delay
- the new trigger delay (in milliseconds) to be assigned to this image slice.slice
- the slice number for which to set the trigger delay.- Throws:
IOException
- if the trigger delay cannot be set.
-
setFrameTriggerDelayMS
Description copied from interface:WritableImage
Sets the trigger delay (in milliseconds) for one "frame" of this 4-D image. No exception occurs if the image format does not support recording the trigger delay.
N.B. For disk-based images, the changes in the trigger delay will not be reflected on disk unless the close() method is called.- Specified by:
setFrameTriggerDelayMS
in interfaceWritableImage
- Parameters:
delay
- the new trigger delay to be assigned to this image.frame
- the frame number for which to set the trigger delay.- Throws:
IOException
- if the trigger delay cannot be set.
-
getPatientName
Returns the patient name for this image.- Specified by:
getPatientName
in interfaceReadableImage
- Returns:
- the patient name for this image, or
null
if the patient name can't be found.
-
setPatientName
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
patientName
- the new patient name to be assigned to this image.- Throws:
IOException
- if the patient name cannot be set.
-
getPatientID
Returns the patient ID for this image.- Specified by:
getPatientID
in interfaceReadableImage
- Returns:
- the patientID for this image, or
null
if the patientID can't be found.
-
setPatientID
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
patientID
- the new patient ID to be assigned to this image.- Throws:
IOException
- if the patient ID cannot be set.
-
getPatientDoB
Description copied from interface:ReadableImage
Returns the patient date of birth for this image.- Specified by:
getPatientDoB
in interfaceReadableImage
- Returns:
- the patient's date of birth for this image, or
null
if the patient's dob can't be found.
-
setPatientDoB
Description copied from interface:WritableImage
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 interfaceWritableImage
- Parameters:
patientDoB
- the new patient date of birth to be assigned to this image.- Throws:
IOException
- if the patient date of birth cannot be set.
-
getPatientSex
public com.xinapse.dicom.Sex getPatientSex()Description copied from interface:ReadableImage
Returns the patient sex for this image.- Specified by:
getPatientSex
in interfaceReadableImage
- Returns:
- the patient's sex image, or
Sex.OTHER
if the patient's sex can't be found.
-
setPatientSex
Description copied from interface:WritableImage
Sets the patient sex for this image.- Specified by:
setPatientSex
in interfaceWritableImage
- Parameters:
sex
- the patient sex to be assigned to this image.- Throws:
IOException
- if the patient sex cannot be set.
-
getStudyID
Description copied from interface:ReadableImage
Returns the study ID for this ReadableImage.- Specified by:
getStudyID
in interfaceReadableImage
- Returns:
- the study ID. Returns
null
if the study ID can't be found.
-
setStudyID
Description copied from interface:WritableImage
Sets the study ID for this image.
N.B. For disk-based images, the changes in the study ID will not be reflected on disk unless the close() method is called.- Specified by:
setStudyID
in interfaceWritableImage
- Parameters:
studyID
- the new study ID to be assigned to this image.- Throws:
IOException
- if the study ID cannot be set.
-
getScanDate
Returns the scan date for this image.- Specified by:
getScanDate
in interfaceReadableImage
- Returns:
- the date/time at which this scan was performed, or
null
if the scan date can't be found.
-
getPulseSequence
Description copied from interface:ReadableImage
Returns the name of the pulse sequence with which this image was collected.- Specified by:
getPulseSequence
in interfaceReadableImage
- Returns:
- the name of the pulse sequence used to collect this image.
-
getScanningSequence
Description copied from interface:ReadableImage
Returns the DICOM Scanning Sequence with which this image was collected.- Specified by:
getScanningSequence
in interfaceReadableImage
- Returns:
- the DICOM Scanning Sequence used to collect this image, or
null
if the scanning sequence isn't available.
-
getSequenceVariant
Description copied from interface:ReadableImage
Returns the DICOM Scanning Sequence Variant with which this image was collected.- Specified by:
getSequenceVariant
in interfaceReadableImage
- Returns:
- the DICOM Scanning Sequence Variant used to collect this image, or
null
if the sequence variant isn't available.
-
getSeriesNumber
Description copied from interface:ReadableImage
Returns the series number for this ReadableImage.- Specified by:
getSeriesNumber
in interfaceReadableImage
- Returns:
- the series number. Returns
null
if the series number can't be found.
-
getSeriesDescription
Description copied from interface:ReadableImage
Returns a short description of the series (scan), such as is provided by the DICOM series description.- Specified by:
getSeriesDescription
in interfaceReadableImage
- Returns:
- a short description of the series, or null if none is available.
-
anonymise
public void anonymise(String patientName, String patientID, Date birthDate, boolean patSex, String patAddr, String patInsurancePlanID, String accessionNumber, boolean patOther, String physicianName, String physicianAddr, String institutionName, String institutionAddr, String deptName, String stationName, String telNumber, boolean removePrivateElements) throws IOException Description copied from interface:WritableImage
Anonymise this WritableImage.- Specified by:
anonymise
in interfaceWritableImage
- Overrides:
anonymise
in classANZImage
- Parameters:
patientName
- if non-null, the patient name to substitute.patientID
- if non-null, the patient ID to substitute.birthDate
- if non-null, the birth date to substitute.patSex
- if true, set the sex to "OTHER".patAddr
- if non-null, the address to substitute.patInsurancePlanID
- if non-null, the insurance plan ID to substitute.accessionNumber
- if non-null, the accession number to substitute.patOther
- if true, other patient-related items will be anonymised.physicianName
- if non-null, the physician name to substitute.physicianAddr
- if non-null, the physician's address to substitute.institutionName
- if non-null, the institution name to substitute.institutionAddr
- if non-null, the institution address to substitute.deptName
- if non-null, the department name to substitute.stationName
- if non-null, the station name to substitute.telNumber
- if non-null, the telephone number to substitute for all telephone numbers.removePrivateElements
- if true, all private DICOM elements will be removed.- Throws:
IOException
- if an I/O error occurs during anonymisation.
-
appendAuditInfo
Appends audit trail information to this image.- Specified by:
appendAuditInfo
in interfaceWritableImage
- 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:
IOException
- if an I/O error occurs.
-
putInfo
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 theReadableImage.close()
method is called.- Specified by:
putInfo
in interfaceInfoStorer
- 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:
IOException
- if the information cannot be added because of an I/O error.
-
putInfo
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 theReadableImage.close()
method is called.- Specified by:
putInfo
in interfaceInfoStorer
- 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:
IOException
- if the information cannot be addded because of an I/O error.
-
putInfo
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 theReadableImage.close()
method is called.- Specified by:
putInfo
in interfaceInfoStorer
- Parameters:
name
- the name of the information to put.value
- aString
to be associated with this name in the general file information.- Throws:
IOException
- if the information cannot be addded because of an I/O error.
-
putInfo
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 theReadableImage.close()
method is called.- Specified by:
putInfo
in interfaceInfoStorer
- 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 slicen
to info that applied only to slicen
.- Throws:
IOException
- if the information cannot be addded because of an I/O error.
-
putInfo
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 interfaceInfoStorer
- 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 slicen
to info that applied only to slicen
.- Throws:
IOException
- if the information cannot be addded because of an I/O error.
-
putInfo
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 interfaceInfoStorer
- 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 slicen
to info that applied only to slicen
.- Throws:
IOException
- if the information cannot be addded because of an I/O error.
-
putSliceInfo
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 (number of slices - 1).
N.B. For disk-based images, the changes in the info will not be reflected on disk unless theReadableImage.close()
method is called.- Specified by:
putSliceInfo
in interfaceInfoStorer
- Parameters:
infoList
- the list of InfoItems to put.slice
- the slice number.- Throws:
IOException
- if the information cannot be added because of an I/O error.
-
putFrameInfo
Description copied from interface:InfoStorer
Adds all the items in an InfoList to the frame-specific information. If an info item with the same name exists, then the value will be overwritten.The frame number is referenced from 0 to (number of frames - 1).
N.B. For disk-based images, the changes in the info will not be reflected on disk unless theReadableImage.close()
method is called.- Specified by:
putFrameInfo
in interfaceInfoStorer
- Parameters:
infoList
- the list of InfoItems to put.frame
- the frame number.- Throws:
IOException
- if the information cannot be added because of an I/O error.
-
putSliceInfo
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 (number of slices - 1).
N.B. For disk-based images, the changes in the info will not be reflected on disk unless theReadableImage.close()
method is called.- Specified by:
putSliceInfo
in interfaceInfoStorer
- 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:
IOException
- if the information cannot be added because of an I/O error.
-
putFrameInfo
Description copied from interface:InfoStorer
Adds an item to the frame-specific information. If an info item with the same name exists, then then value will be overwritten.The frame number is referenced from 0 to (number of frames).
N.B. For disk-based images, the changes in the info will not be reflected on disk unless theReadableImage.close()
method is called.- Specified by:
putFrameInfo
in interfaceInfoStorer
- Parameters:
name
- the name of the information item to put.value
- a String to be associated with this name in the frame-specific info.frame
- the frame number.- Throws:
IOException
- if the information cannot be added because of an I/O error.
-
getInfo
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 interfaceInfoStorer
- Parameters:
name
- the name of this information field.- Returns:
- a
String
representation of the value of this information field. - Throws:
InfoNotFoundException
- if the name is not found in the general info.
-
getInfo
Description copied from interface:InfoStorer
Returns aString
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 interfaceInfoStorer
- 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 slicen
to info that applied only to slicen
.- Returns:
- a
String
representation of the value of this information. - Throws:
InfoNotFoundException
- if the name is not found in this dimension/element info.
-
getSliceInfo
Description copied from interface:InfoStorer
Returns aString
representing the value of this information item in a particular slice of this image.The slice number is referenced from 0 to (number of slices - 1).
- Specified by:
getSliceInfo
in interfaceInfoStorer
- Parameters:
name
- the name of this information item.slice
- the slice number.- Returns:
- a
String
representation of the value of this information. - Throws:
InfoNotFoundException
- if the name is not found for the specified slice.
-
getFrameInfo
Description copied from interface:InfoStorer
Returns aString
representing the value of this information item in a particular frame of this image.The frame number is referenced from 0 to (number of frames - 1).
- Specified by:
getFrameInfo
in interfaceInfoStorer
- Parameters:
name
- the name of this information item.frame
- the frame number.- Returns:
- a
String
representation of the value of this information. - Throws:
InfoNotFoundException
- if the name is not found for the specified frame.
-
removeInfo
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 theReadableImage.close()
method is called.- Specified by:
removeInfo
in interfaceInfoStorer
- Parameters:
name
- the name of the information item to be removed.
-
removeInfo
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 theReadableImage.close()
method is called.- Specified by:
removeInfo
in interfaceInfoStorer
- 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 slicen
to info that applied only to slicen
.
-
getInfoList
Description copied from interface:InfoStorer
Returns anInfoList
object which is the general info for this image.- Specified by:
getInfoList
in interfaceInfoStorer
- Returns:
- an
InfoList
which is the general file info for thisInfoStorer
.
-
setInfoList
Description copied from interface:InfoStorer
Sets a newInfoList
to the general file info of this image.- Specified by:
setInfoList
in interfaceInfoStorer
- Parameters:
infoList
- theInfoList
object to set to the general file info for this image.- Throws:
IOException
- if theInfoList
cannot be set.
-
getInfoList
Description copied from interface:InfoStorer
Returns anInfoList
object applying to a particular dimension/element for this image.- Specified by:
getInfoList
in interfaceInfoStorer
- 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 thisInfoStorer
.
-
getSliceInfoList
Description copied from interface:InfoStorer
Returns anInfoList
object applying to a particular slice of this image.The slice number is referenced from 0 to (number of slices - 1).
- Specified by:
getSliceInfoList
in interfaceInfoStorer
- Parameters:
slice
- the slice number.- Returns:
- an
InfoList
object from a particular slice of thisInfoStorer
.
-
getFrameInfoList
Description copied from interface:InfoStorer
Returns anInfoList
object applying to a particular frame of this image.The frame number is referenced from 0 to (number of frames - 1).
- Specified by:
getFrameInfoList
in interfaceInfoStorer
- Parameters:
frame
- the frame number.- Returns:
- an
InfoList
object from a particular frame of thisInfoStorer
.
-
setInfoList
Description copied from interface:InfoStorer
Sets a newInfoList
a specific dimension of this image.- Specified by:
setInfoList
in interfaceInfoStorer
- Parameters:
infoList
- theInfoList
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:
IOException
- if theInfoList
cannot be set.
-
setSliceInfoList
Description copied from interface:InfoStorer
Sets a newInfoList
a specific slice of this image.- Specified by:
setSliceInfoList
in interfaceInfoStorer
- Parameters:
infoList
- theInfoList
to associate with this image/slice.slice
- the slice for which to set the information list.- Throws:
IOException
- if theInfoList
cannot be set.
-
setFrameInfoList
Description copied from interface:InfoStorer
Sets a newInfoList
a specific frame of this image.- Specified by:
setFrameInfoList
in interfaceInfoStorer
- Parameters:
infoList
- theInfoList
to associate with this image/frame.frame
- the frame for which to set the information list.- Throws:
IOException
- if theInfoList
cannot be set.
-
appendInfoList
Description copied from interface:InfoStorer
Appends anInfoList
to the existing general file info of this image.- Specified by:
appendInfoList
in interfaceInfoStorer
- Parameters:
infoList
- theInfoList
object to append to the general file info for this image.- Throws:
IOException
- if theInfoList
cannot be appended because of an I/O error.
-
appendInfoList
Appends anInfoList
to that for a particular dimension of this image.- Specified by:
appendInfoList
in interfaceInfoStorer
- Parameters:
infoList
- ths list to append.dim
- the diemension for which theInfoList
will be appended.n
- the element of that dimension for which theInfoList
will be appended.- Throws:
InvalidImageException
- if theInfoList
cannot be appended.
-
addExtendedData
public void addExtendedData(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData) throws ANZException Adds a block ofExtendedData
to thisNIFTIImage
.- Parameters:
extendedData
- theExtendedData
to add.- Throws:
ANZException
- if theExtendedData
cannot be added.
-
getExtendedData
- Returns:
- a
List
ofExtendedData
, ornull
if there is noExtendedData
.
-
removeExtendedData
public void removeExtendedData(com.xinapse.multisliceimage.Analyze.ExtendedData extendedData) throws ANZException Removes a block ofExtendedData
from thisNIFTIImage
. This method does nothing if the suppliedExtendedData
is not present.- Parameters:
extendedData
- theExtendedData
to remove.- Throws:
ANZException
- if the extended data cannot be removed.
-
stripExtension
Strips any ".img", ".img.gz", ".hdr", ".hdr.gz", ".nii", or ".nii.gz" extension (in upper or lowe case) from a file name.- Parameters:
fileName
- the file name that may or may not have an extension.- Returns:
- the stripped file name.
-
getHTMLDescription
Description copied from interface:ReadableImage
Returns a String description of a slice of this image in HTML format.- Specified by:
getHTMLDescription
in interfaceReadableImage
- Overrides:
getHTMLDescription
in classANZImage
- Parameters:
slice
- the slice number.- Returns:
- a String describing this image slice.
-
main
Run the self-test for the NIFTIImage class.- Parameters:
args
- a list of images to try to open.
-