Interface WritableImage
- All Superinterfaces:
AutoCloseable
,ReadableImage
- All Known Implementing Classes:
Analyze75Image
,ANZImage
,MultiSliceImage
,NIFTI2Image
,NIFTIImage
,UNCImage
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.xinapse.image.ReadableImage
ReadableImage.Position
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.default void
appendToTitle
(String toAppend) Append some text to the title of this WritableImage, if the image format can handle titles.getCopy()
Returns a copy of thisWritableImage
.Returns the normal human readable name for this type of image.void
Put pixel values from a specified array to this image.void
Puts a single pixel value to the image.void
Put pixel values from a specified array to this image.void
Puts the pixel values to one slice of an n-dimensional image, where n > 1.void
setBodyPart
(com.xinapse.dicom.BodyPart bodyPart) Sets the body part imaged.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 gVector, int frame) Sets the diffusion-weighting gradient vector for one "frame" of this 4-D image.void
setFrameOfReferenceUID
(com.xinapse.dicom.Uid uid) Sets the frame of reference UID that uniquely identifies the frame of reference for an 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
setImageOrientationPositionPatient
(org.jogamp.vecmath.Vector3f[] orientation, org.jogamp.vecmath.Point3f position, boolean force) Sets the direction cosines of the row, column and slice directions of the image, the coordinates of the center of the first pixel of the image, in patient (LPS) coordinates.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
setIntensityRescale
(float[] rescaleSlopeIntercept) Sets the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified insetRescaleUnits(com.xinapse.dicom.RescaleUnits)
in the expression:
Output units = m*I + b
.void
setIntensityRescale
(float rescaleSlope, float rescaleIntercept) Sets the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified insetRescaleUnits(com.xinapse.dicom.RescaleUnits)
in the expression:
Output units = m*I + b
.void
setLaterality
(com.xinapse.dicom.Laterality laterality) Sets the anatomical laterality of the image.void
setMinMax
(int min, int max) Sets the min and max pixel values for this WritableImage.void
setModality
(Modality modality) Sets the modality with which this image was acquired.void
setNativeColourMapping
(ColourMapping colourMapping) Sets theColourMapping
for this image.void
setPatientDoB
(Date dob) Sets the patient's date of birth for this image.void
setPatientID
(String id) Sets the patient ID for this image.void
setPatientName
(String name) 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
setPixelSpacing
(Float[] pixelSpacing) Sets the distance (in mm) between pixel centres in the row, column and slice directions of the image, and the time between movie frames (for 4-D images) in seconds.void
setPulseSequence
(String seqName) Sets the pulse sequence name for this image.void
setRescaleUnits
(com.xinapse.dicom.RescaleUnits units) Sets the rescale units.void
setSaturationFreqOffsetPPM
(Float freqOffset) Sets the saturation frequency offset in PPM for this image.void
setSaturationFreqOffsetPPM
(Float freqOffset, int slice) 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
setScanningSequence
(PulseSequenceType sequenceType) Sets the DICOM scanning sequence for this image.void
Sets the scan echo time for this image.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
setSequenceVariant
(PulseSequenceVariant seqVariant) Sets the DICOM scanning sequence variant for this image.void
setSeriesDescription
(String description) Sets a short description of the series (scan).void
setSeriesInstanceUID
(com.xinapse.dicom.Uid uid) Sets the series instance UID for this image.void
setSeriesNumber
(Integer seriesNumber) Sets the series number for this image.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 gVector, int slice) Sets the diffusion-weighting gradient vector for one 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.void
setStudyInstanceUID
(com.xinapse.dicom.Uid uid) Sets the study instance UID for this image.void
setSuggestedFileName
(String name) Sets a suggested file name for this WritableImage that might be used when saving to disk later.void
Sets the title for this WritableImage, if the image format can handle titles.boolean
Tests whether thisWritableImage
format supports intensity rescaling.Writes this WritableImage to a file (or possibly a pair of header/image files).Methods inherited from interface com.xinapse.image.ReadableImage
close, disposeImageData, getAffineTransform, getAffineTransform, getBodyPart, getDescription, getDescription, getDims, getEchoTrainLength, getFlipAngle, getFrameDWBMatrix, getFrameDWbValue, getFrameDWGradientVector, getFrameOfReferenceUID, getFrameTriggerDelayMS, getHTMLDescription, getHTMLDescription, getImageOrientationPatient, getImageOrientationPatient, getImagePositionPatient, getImagePositionPatient, getIntensityRescale, getLaterality, getMax, getMin, getModality, getMostLikePlane, getNativeColourMapping, getNativeHeader, getNCols, getNDim, getNFrames, getNRows, getNSliceLocations, getNSlices, getPatientDoB, getPatientID, getPatientName, getPatientPosition, getPatientSex, getPix, getPix, getPix, getPix, getPix, getPixelXSize, getPixelYSize, getPixelZSize, getPresentationPixelDataType, getPulseSequence, getRescaleUnits, getROIs, getSaturationFreqOffsetPPM, getSaturationFreqOffsetPPM, getScanDate, getScanningSequence, getScanTE, getScanTE, getScanTI, getScanTR, getSequenceVariant, getSeriesDescription, getSeriesNumber, getSlice, getSlice, getSliceDWBMatrix, getSliceDWbValue, getSliceDWGradientVector, getSliceThickness, getSliceTriggerDelayMS, getStoredPix, getStoredPixelDataType, getStudyID, getSuggestedFileName, getTimeBetweenFrames, getTitle, getTotalNSlices, isOpen
-
Method Details
-
getImageTypeName
String getImageTypeName()Returns the normal human readable name for this type of image.- Returns:
- a
String
with a one-word description of this type of image.
-
appendAuditInfo
Appends audit trail information to this image.- 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.
-
setNativeColourMapping
Sets theColourMapping
for this image. No exception occurs if the image format does not support a colour mapping.
N.B. For disk-based images, the changes in the ColourMapping may not be reflected on disk unless the close() method is called.- Parameters:
colourMapping
- the new ColourMapping to be assigned to this image.- Throws:
IOException
- if the ColourMapping cannot be set for this image.
-
setTitle
Sets the title for this WritableImage, if the image format can handle titles.- Parameters:
title
- the new title.- Throws:
IOException
- if an error occurs writing the title.
-
appendToTitle
Append some text to the title of this WritableImage, if the image format can handle titles.- Parameters:
toAppend
- the text to append to the title.- Throws:
IOException
- if an error occurs writing the title.
-
setModality
Sets the modality with which this image was acquired. No exception occurs if the image format does not support modality recording.
N.B. For disk-based images, the changes in the modality will not be reflected on disk unless the close() method is called.- Parameters:
modality
- the new imaging modality to be assigned to this image.- Throws:
IOException
- if modality cannot be set.
-
setBodyPart
Sets the body part imaged. No exception occurs if the image format does not support body part recording.
N.B. For disk-based images, the changes in the body part will not be reflected on disk unless the close() method is called.- Parameters:
bodyPart
- the new imaged body part.- Throws:
IOException
- if body part cannot be set.
-
setLaterality
Sets the anatomical laterality of the image. No exception occurs if the image format does not support laterality recording.
N.B. For disk-based images, the changes in the laterality will not be reflected on disk unless the close() method is called.- Parameters:
laterality
- the new image laterality.- Throws:
IOException
- if laterality cannot be set.
-
setPulseSequence
Sets the pulse sequence name for this image.
N.B. For disk-based images, the changes in the scanning sequence will not be reflected on disk unless the close() method is called.- Parameters:
seqName
- the new name of the pulse sequence to be assigned to this image.- Throws:
IOException
- if the pulse sequence name cannot be set.
-
setScanningSequence
Sets the DICOM scanning sequence for this image.
N.B. For disk-based images, the changes in the scanning sequence will not be reflected on disk unless the close() method is called.- Parameters:
sequenceType
- the new scanning sequence to be assigned to this image.- Throws:
IOException
- if the scanning sequence cannot be set.
-
setSequenceVariant
Sets the DICOM scanning sequence variant for this image.
N.B. For disk-based images, the changes in the scanning sequence variant will not be reflected on disk unless the close() method is called.- Parameters:
seqVariant
- the new scanning sequence variant to be assigned to this image.- Throws:
IOException
- if the scanning sequence variant cannot be set.
-
setFlipAngle
Sets the excitation pulse flip angle for this image. No exception occurs if the image format does not support flip angle recording.
N.B. For disk-based images, the changes in the scan flip angle will not be reflected on disk unless the close() method is called.- Parameters:
flipAngle
- the new scan flip angle to be assigned to this image. If null, the flip angle should be unset.- Throws:
IOException
- if the scan flip angle cannot be set.
-
setScanTR
Sets the scan repetition time for this image. No exception occurs if the image format does not support scan TR recording.
N.B. For disk-based images, the changes in the scan TR will not be reflected on disk unless the close() method is called.- Parameters:
tr
- the new scan TR to be assigned to this image. If null, the TR should be unset.- Throws:
IOException
- if the scan TR cannot be set.
-
setScanTI
Sets the scan inversion time for this image. No exception occurs if the image format does not support scan TI recording.
N.B. For disk-based images, the changes in the scan TI will not be reflected on disk unless the close() method is called.- Parameters:
ti
- the new scan TI to be assigned to this image. If null, the TI should be unset.- Throws:
IOException
- if the scan TI cannot be set.
-
setScanTE
Sets the scan echo time for this image. No exception occurs if the image format does not support scan TE recording.
N.B. For disk-based images, the changes in the scan TE will not be reflected on disk unless the close() method is called.- Parameters:
te
- the new scan TE to be assigned to this image. If null, the TE should be unset.- Throws:
IOException
- if the scan TE cannot be set.
-
setScanTE
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.- Parameters:
te
- the new scan TE to be assigned to this image.slice
- the slice number for which to set the echo time.- Throws:
IndexOutOfBoundsException
- if the index is bad for this image.IOException
- if the scan TE cannot be set because of an I/O error.
-
setSaturationFreqOffsetPPM
Sets the saturation frequency offset in PPM for this image. 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.- Parameters:
freqOffset
- the new saturation frequency offset to be assigned to this image. If null, the saturation frequency offset should be unset.- Throws:
IOException
- if the saturation frequency offset cannot be set.
-
setSaturationFreqOffsetPPM
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.- Parameters:
freqOffset
- the new saturation frequency offset to be assigned to this image.slice
- the slice number for which to set the saturation frequency offset.- Throws:
IndexOutOfBoundsException
- if the index is bad for this image.IOException
- if the saturation frequency offset cannot be set because of an I/O error.
-
setEchoTrainLength
Sets the echo train length for this image. No exception occurs if the image format does not support a echo train length recording.
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.- Parameters:
etl
- the new scan echo train length to be assigned to this image. If null, the echo train length is unassigned.- Throws:
IOException
- if the echo train length cannot be set because of an I/O error.
-
setSliceDWbValue
Sets the diffusion-weighting b-value for one slice of this image. No exception occurs if the image format does not support recording the b-value.
N.B. For disk-based images, the changes in the b-value will not be reflected on disk unless the close() method is called.- Parameters:
bValue
- the new b-value to be assigned to this image.slice
- the slice number for which to set the b-value.- Throws:
IOException
- if the scan b-value cannot be set.IndexOutOfBoundsException
-
setFrameDWbValue
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.- 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.IndexOutOfBoundsException
- if this is not a 4-D image.
-
setSliceDWGradientVector
void setSliceDWGradientVector(org.jogamp.vecmath.Vector3f gVector, int slice) throws IOException, IndexOutOfBoundsException Sets the diffusion-weighting gradient vector for one slice of this image. No exception occurs if the image format does not support recording the gradient vector.
N.B. For disk-based images, the changes in the gradient vector will not be reflected on disk unless the close() method is called.- Parameters:
gVector
- 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.IndexOutOfBoundsException
-
setFrameDWGradientVector
void setFrameDWGradientVector(org.jogamp.vecmath.Vector3f gVector, int frame) throws IOException, IndexOutOfBoundsException 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.- Parameters:
gVector
- 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.IndexOutOfBoundsException
- if this is not a 4-D image.
-
setSliceDWBMatrix
Sets the diffusion-weighting B-matrix for one slice of this image. No exception occurs if the image format does not support recording the B-matrix.
N.B. For disk-based images, the changes in the B-matrix will not be reflected on disk unless the close() method is called.- Parameters:
bMatrix
- the new B-matrix to be assigned to this image.slice
- the slice number for which to set the B-matrix.- Throws:
IOException
- if the scan B-matrix cannot be set.IndexOutOfBoundsException
-
setFrameDWBMatrix
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.- 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.IndexOutOfBoundsException
- if this is not a 4-D image.
-
setSliceTriggerDelayMS
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.- 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.IndexOutOfBoundsException
-
setFrameTriggerDelayMS
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.- 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.IndexOutOfBoundsException
- if this is not a 4-D image.
-
setPatientName
Attempts to set the patient name for this image. If new patient name String is longer than is allowed by the image format, then it is truncated before being applied. No exception occurs if the image format does not support patient name recording.
N.B. For disk-based images, the changes in the patient name will not be reflected on disk unless the close() method is called.- Parameters:
name
- the new patient name to be assigned to this image.- Throws:
IOException
- if the patient name cannot be set.
-
setPatientID
Sets the patient ID for this image. If the new patient ID String is longer than is allowed by the image format, then it is truncated before being applied. No exception occurs if the image format does not support patient ID recording.
N.B. For disk-based images, the changes in the patient ID will not be reflected on disk unless the close() method is called.- Parameters:
id
- the new patient ID to be assigned to this image.- Throws:
IOException
- if the patient ID cannot be set.
-
setPatientDoB
Sets the patient's date of birth for this image. No exception occurs if the image format does not support patient date of birth recording.
N.B. For disk-based images, the changes in the patient's birth date will not be reflected on disk unless the close() method is called.- Parameters:
dob
- the new patient date of birth to be assigned to this image.- Throws:
IOException
- if the patient date of birth cannot be set.
-
setPatientSex
Sets the patient sex for this image.- Parameters:
sex
- the patient sex to be assigned to this image.- Throws:
IOException
- if the patient sex cannot be set.
-
setScanDate
Sets the scan date/time for this image.
N.B. For disk-based images, the changes in the scan date will not be reflected on disk unless the close() method is called.- Parameters:
scanDate
- the new scan date/time to be assigned to this image.- Throws:
IOException
- if the scan date cannot be set.
-
setPatientPosition
Sets the position in which the patient is lying in the scanning equipment for thisWritableImage
.- 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.
-
setStudyID
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.- Parameters:
studyID
- the new study ID to be assigned to this image.- Throws:
IOException
- if the study ID cannot be set.
-
setStudyInstanceUID
Sets the study instance UID for this image.
N.B. For disk-based images, the changes in the study instance UID will not be reflected on disk unless the close() method is called.- Parameters:
uid
- the new study instance UID to be assigned to this image.- Throws:
IOException
- if the study instance UID cannot be set.
-
setSeriesNumber
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.- Parameters:
seriesNumber
- the new series number to be assigned to this image.- Throws:
IOException
- if the series number cannot be set.
-
setSeriesInstanceUID
Sets the series instance UID for this image.
N.B. For disk-based images, the changes in the series instance UID will not be reflected on disk unless the close() method is called.- Parameters:
uid
- the new series instance UID to be assigned to this image.- Throws:
IOException
- if the series instance UID cannot be set.
-
setSeriesDescription
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.- Parameters:
description
- the new short description of the series, or null if none is available.- Throws:
IOException
- if the description cannot be set.
-
supportsIntensityRescaling
boolean supportsIntensityRescaling()Tests whether thisWritableImage
format supports intensity rescaling.- Returns:
true
if thisWritableImage
format supports intensity rescaling;false
otherwise.
-
setIntensityRescale
void setIntensityRescale(float rescaleSlope, float rescaleIntercept) throws InvalidImageException, IOException Sets the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified insetRescaleUnits(com.xinapse.dicom.RescaleUnits)
in the expression:
Output units = m*I + b
.- Parameters:
rescaleSlope
- the value ofm
in the expression above.rescaleIntercept
- the value ofb
in the expression above.- Throws:
InvalidImageException
- if rescaling cannot be set for this image.IOException
- if an I/O error occurs.
-
setIntensityRescale
Sets the valuesm
andb
in the relationship between pixel intensity (I) values and the output units specified insetRescaleUnits(com.xinapse.dicom.RescaleUnits)
in the expression:
Output units = m*I + b
.- Parameters:
rescaleSlopeIntercept
- an array of length 2, containing the values ofm
andb
in the expression above, in that order.- Throws:
InvalidImageException
- if rescaling cannot be set for this image.IOException
- if an I/O error occurs.
-
setRescaleUnits
Sets the rescale units.- Parameters:
units
- the rescale units.- Throws:
IOException
- if the rescale units cannot be set.
-
setFrameOfReferenceUID
void setFrameOfReferenceUID(com.xinapse.dicom.Uid uid) Sets the frame of reference UID that uniquely identifies the frame of reference for an image.- Parameters:
uid
- the frame of reference UID. If uid is null, the frame of reference Uid is removed from the image header.
-
putSlice
Puts the pixel values to one slice of an n-dimensional image, where n > 1.N.B.Whenever the radiological orientation of the image can be determined, this method sets pixel values such that when the slice is viewed on-screen, the first pixel in the array belongs at the top left of the screen, and the last pixel in the array belongs at the bottom right of the screen. This must be regardless of the sub-class of image.
- Parameters:
slicePix
- a 1-dimensional array of the correct primitive java data type for this image, with dimensions [nRows * nCols] containing the pixel values to put.slice
- the slice number. Must be 0 for a 2-dimensional image or from 0 to dims[0]-1 for a 3-dimensional image.- Throws:
IOException
- if an error occurs during the writing of the pixel data.InvalidImageException
- if the image does not have the right dimensionality, if the slice number is inappropriate for this image, if the array is not of the correct primitive data type for this image, or if there is a problem accessing the pixel values.
-
putPix
Put pixel values from a specified array to this image. array is an array of the correct type of element for this image from which pixel values will be copied; it must be cast to anObject
and must have the correct number of elements.- Parameters:
pixels
- a 1-dimensional array of pixel values of the correct java primitive data type to put to the image.radiological
-true
if the pixels have a standard radiological orientation Standard radiological orientation is:- For axial images, increasing left coordinate with column number, and increasing posterior coordinate with row number.
- For coronal images, increasing left coordinate with column number, and increasing inferior coordinate with row number.
- For sagittal images, increasing posterior coordinate with column number, and increasing inferior coordinate with row number.
false
, the pixels are put without any consideration of the orientation.- Throws:
InvalidImageException
- if an I/O error occurs while accessing the pixel values.IOException
- if an error occurs during the writing of the pixel data.
-
putPix
Puts a single pixel value to the image.- Parameters:
pix
- the pixel value to put, as a suitable Object.pixIdx
- an int[] of length at least equal tonDim
for this image where each element corresponds to an index to the pixel in each dimension. The first element ofpixIdx
refers to the slowest-varying dimension, and the last relevant element refers to the fastest-varying dimension. For example, for a 3-D image,pixIdx[0]
refers to the slice dimension, andpixIdx[2]
refers to the column dimension.- Throws:
IOException
- if an I/O error occurs while accessing the pixel values.InvalidImageException
- if the indices are inappropriate for this image, if the supplied pixel is of the wrong Class, or if the pixel value cannot be written to the image.
-
putPix
Put pixel values from a specified array to this image. array is an array of the correct type of element for this image from which pixel values will be copied; it must be cast to anObject
and must have the right number of elements to copy to the pixel values requested. ThelowIdx
andhighIdx
int arrays should have at least nDim elements, and the elements specify the pixel number range for each dimension. For example, if an image hasnDim
= 3, anddims
[] = {5, 256, 256}, then pixels for the middle slices 4 will be returned by setting lowIdx to {1, 0, 0} and highIdx to {4, 255, 255}.- Parameters:
pixels
- a 1-dimensional array of pixel values of the correct java primitive data type to put to the image.lowIdx
- an array ofint
specifying the low index of pixel values to put.highIdx
- an array ofint
specifying the high index of pixel values to put.- Throws:
IOException
- if an I/O error occurs while writing the pixel values.InvalidImageException
- if the indices supplied extend beyond the image, the pixel values are of the wrong primitive data type or cannot be put for other reasons.
-
setPixelSpacing
Sets the distance (in mm) between pixel centres in the row, column and slice directions of the image, and the time between movie frames (for 4-D images) in seconds. The distances and time should always be positive values.- Parameters:
pixelSpacing
- a Float[] of length up to 4, corresponding to the distance between pixel centres in the row, column, slice and time directions, respectively. Spacing values will only be set for image dimensions where the spacing array is long enough and the array element is non-null. The first element of the array indicates the horizontal pixel size; the second is the vertical pixel size; the third is the pixel depth; fourth is the time between frames.- Throws:
IOException
- if the pixel spacing cannot be set for this image.IndexOutOfBoundsException
- ifspacing
does not have the correct dimensions.
-
setSliceThickness
Sets the slice thickness (in mm). This method is necessary because the slice thickness may not be the same as the inter-slice pixel spacing, if there is a gap between slices.- Parameters:
thickness
- the slice thickness in mm, or null to remove the slice thickness information.- Throws:
IOException
- if the slice thickness cannot be set for this image.
-
setImageOrientationPositionPatient
void setImageOrientationPositionPatient(org.jogamp.vecmath.Vector3f[] orientation, org.jogamp.vecmath.Point3f position, boolean force) throws IOException Sets the direction cosines of the row, column and slice directions of the image, the coordinates of the center of the first pixel of the image, in patient (LPS) coordinates.N.B. the actual position and orientation set by this method may not be those specified. For example, for NIFTI-1 images, the actual orientation and position may depend on the user
Preferences
for whether to put pixel values in an order that is compatible with SPM. After using this method, you should use theReadableImage.getImageOrientationPatient()
andReadableImage.getImagePositionPatient()
methods to obtain the real orientation and positions set.If the orientation or position cannot be set for this image, this method does not report an error.
- Parameters:
orientation
- the direction cosines of the image row, column and (optionally) slice directions respectively in Left,Posterior,Superior (LPS) coordinates. If orientation isnull
, this method will attempt to clear any orientation information, if that is supported by the image format.position
- the Left,Posterior,Superior (LPS) coordinates of the centre of the first pixel in the image data matrix. If position isnull
, this method will attempt to clear any positional information, if that is supported by the image format.force
- iftrue
, this method will force the orientation and position to be set as requested, regardless of the userPreferences
. This can be useful if you read the orientation from an existing image, and you want to set the orientation exactly the same in a new image.- Throws:
IndexOutOfBoundsException
- if theorientation
array does not have the correct length.IOException
- if an I/O error occurs.
-
setImageOrientationPatient
void setImageOrientationPatient(org.jogamp.vecmath.Vector3f[] orientation, int slice) throws IOException Sets the direction cosines of the row, column and slice directions (for increasing row, column and slice) of the image, in patient (LPS) coordinates.If the orientation cannot be set for this image, this method does nothing.
- Parameters:
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.IOException
- if an I/O error occurs.
-
setImagePositionPatient
Sets the coordinates of the center of the first pixel of the image, in mm, in patient (LPS) coordinates, for one slice of this image.- Parameters:
position
- the Left,Posterior,Superior (LPS) coordinates of the first pixel of this specified slice in the image data matrix.slice
- the slice for which to set the position.- Throws:
IOException
- if the position cannot be set for this image, ifposition
does not have the correct dimensions, or if the slice number is out of range.
-
setMinMax
Sets the min and max pixel values for this WritableImage. It is up to the caller to ensure that the values supplied are correct at the time they are written to the image. Any subsequent changes to the image pixel values may cause either the values returned by getMin() and getMax() to be incorrect, or cause these methods to throw a InvalidImageException.- Parameters:
min
- the minimum pixel value in the image.max
- the maximum pixel value in the image.- Throws:
InvalidImageException
- if the values supplied are unsuitable, or the values cannot be set.
-
setSuggestedFileName
Sets a suggested file name for this WritableImage that might be used when saving to disk later.- Parameters:
name
- the suggested file name.
-
write
Writes this WritableImage to a file (or possibly a pair of header/image files).- Parameters:
filename
- with which the image is to be written.- Returns:
- the actual file name to which the image was written.
- Throws:
InvalidImageException
- if the image cannot be written.IOException
- if an I/O error occurs.
-
getCopy
Returns a copy of thisWritableImage
.- Specified by:
getCopy
in interfaceReadableImage
- Returns:
- a copy of this
ReadableImage
. - Throws:
IOException
- if the an I/O error occurs whilst copying.
-
anonymise
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 Anonymise this WritableImage.- 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.
-