Package gov.nih.mipav.model.file
Class FilePARREC
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FilePARREC
-
public class FilePARREC extends FileBase
The class reads and writes PAR/REC files. A right handed coordinate system is used with the positive axis pointing (Anterior/Posterior)A->P, (Foot/Head)F->H, and (Right/Left)R->L. * Updated September 16, 2011 by Beth Tyrie // This explains the derivation of the dicom transformation matrix and origin from the PARREC parameters. // The axial PAR file is KKZ_130213_4_1.PAR // The first slice of the axial dicom file is 20131023203338769.MR.dcm // The sagittal PAR file is KKZ_130213_3_1.PAR // The first slice of the sagittal dicom file is 20131107105801812.MR.dcm. // The coronal PAR file is KKZ_130213_10_1.PAR // The first slice of the coronal dicom file is 20131107105805315.MR.dcm. // The angles are the same for the header volume parameters and for every slice int ori; final int axial = 1; final int sagittal = 2; final int coronal = 3; ori = coronal; double angulation_rl = 0.0; double angulation_ap = 0.0; double angulation_fh = 0.0; switch(ori) { case axial: angulation_rl = -8.700; angulation_ap = -4.865; angulation_fh = 3.364; break; case sagittal: angulation_rl = 0.305; angulation_ap = -4.280; angulation_fh = 4.083; break; case coronal: angulation_rl = 3.931; angulation_ap = -4.031; angulation_fh = 4.346; } double angX = 0.0; double angY = 0.0; double angZ = 0.0; switch(ori) { case axial: angX = angulation_rl; angY = angulation_ap; angZ = angulation_fh; break; case sagittal: angX = angulation_ap; angY = -angulation_fh; angZ = -angulation_rl; break; case coronal: angX = angulation_rl; angY = -angulation_fh; angZ = angulation_ap; } double Sx = Math.sin(angX * Math.PI/180.0); double Sy = Math.sin(angY * Math.PI/180.0); double Sz = Math.sin(angZ * Math.PI/180.0); double Cx = Math.cos(angX * Math.PI/180.0); double Cy = Math.cos(angY * Math.PI/180.0); double Cz = Math.cos(angZ * Math.PI/180.0); // EulerOrder = ORDER_XYZ; // This is the Transformation matrix shown in the dicom header // The dicom transformation matrix or image.getMatrix() is the transpose of the matrix given by getPatientOrientation(). // image.getMatrix() and getPatientOrientation() contain just the rotation component. double m00=Cy*Cz; double m01=-Cy*Sz; double m02=Sy; double m10=Cz*Sx*Sy+Cx*Sz; double m11=Cx*Cz-Sx*Sy*Sz; double m12=-Cy*Sx; double m20=-Cx*Cz*Sy+Sx*Sz; double m21=Cz*Sx+Cx*Sy*Sz; double m22=Cx*Cy; TransMatrix tr = new TransMatrix(4); switch (ori) { case axial: tr.M00 = (float)m00; tr.M01 = (float)m01; tr.M02 = (float)m02; tr.M03 = 0; tr.M10 = (float)m10; tr.M11 = (float)m11; tr.M12 = (float)m12; tr.M13 = 0; tr.M20 = (float)m20; tr.M21 = (float)m21; tr.M22 = (float)m22; tr.M23 = 0; tr.M30 = 0; tr.M31 = 0; tr.M32 = 0; tr.M33 = 1; break; case sagittal: tr.M00 = -(float)m20; tr.M01 = -(float)m21; tr.M02 = -(float)m22; tr.M03 = 0; tr.M10 = (float)m00; tr.M11 = (float)m01; tr.M12 = (float)m02; tr.M13 = 0; tr.M20 = -(float)m10; tr.M21 = -(float)m11; tr.M22 = -(float)m12; tr.M23 = 0; tr.M30 = 0; tr.M31 = 0; tr.M32 = 0; tr.M33 = 1; break; case coronal: tr.M00 = (float)m00; tr.M01 = (float)m01; tr.M02 = (float)m02; tr.M03 = 0; tr.M10 = (float)m20; tr.M11 = (float)m21; tr.M12 = (float)m22; tr.M13 = 0; tr.M20 = -(float)m10; tr.M21 = -(float)m11; tr.M22 = -(float)m12; tr.M23 = 0; tr.M30 = 0; tr.M31 = 0; tr.M32 = 0; tr.M33 = 1; } System.out.println("image transMatrix = " + tr); double resX = 0.0; double resY = 0.0; double resZ = 0.0; switch(ori) { case axial: resX = 0.859375; resY = 0.859375; resZ = 1.0; break; case sagittal: resX = 0.42857143; resY = 0.42857143; resZ = 5.0; break; case coronal: resX = 0.3515625; resY = 0.3515625; resZ = 3.3; } // The header volume offsets and the individual slice offsets are all different // The header volume offsets correspond to (xDim - 1)/2, (yDim - 1)/2, (zDim - 1)/2 // The slice offsets correspond to (xDim - 1)/2, (yDim - 1)/2, zSlice. double rl_offset_center = 0.0; double ap_offset_center = 0.0; double fh_offset_center = 0.0; switch(ori) { case axial: rl_offset_center = 6.655; ap_offset_center = 3.537; fh_offset_center = 22.171; break; case sagittal: rl_offset_center = 8.844; ap_offset_center = -3.225; fh_offset_center = -0.535; break; case coronal: rl_offset_center = 6.147; ap_offset_center = 16.846; fh_offset_center = 16.330; } double offsetX = 0.0; double offsetY = 0.0; double offsetZ = 0.0; switch(ori) { case axial: offsetX = rl_offset_center; offsetY = ap_offset_center; offsetZ = fh_offset_center; break; case sagittal: offsetX = ap_offset_center; offsetY = -fh_offset_center; offsetZ = -rl_offset_center; break; case coronal: offsetX = rl_offset_center; offsetY = -fh_offset_center; offsetZ = ap_offset_center; } double dimX = 0.0; double dimY = 0.0; double dimZ = 0.0; switch(ori) { case axial: dimX = 256; dimY = 256; dimZ = 140; break; case sagittal: dimX = 560; dimY = 560; dimZ = 31; case coronal: dimX = 512; dimY = 512; dimZ = 47; } double originX = offsetX - m00 * resX * (dimX-1)/2 - m01 * resY * (dimY-1)/2- m02 * resZ * (dimZ-1)/2; double originY = offsetY - m10 * resX * (dimX-1)/2 - m11 * resY * (dimY-1)/2 - m12 * resZ * (dimZ-1)/2; double originZ = offsetZ - m20 * resX * (dimX-1)/2 - m21 * resY * (dimY-1)/2 - m22 * resZ * (dimZ-1)/2; if (ori == sagittal) { originY = -originY; originZ = -originZ; } else if (ori == coronal) { originY = -originY; } // These are the origins shown for dicom slice 0 System.out.println("originX = " + originX); System.out.println("originY = " + originY); System.out.println("originZ = " + originZ);
-
-
Field Summary
Fields Modifier and Type Field Description private int
bValueIndex
private int
bValuePos
bFactorIndexprivate int[]
cardiacFrequency
private int
cardiacFrequencyIndex
private int
cardiacFrequencyPos
private int[]
cardiacPhaseNumber
private int
cardiacPhaseNumberIndex
private int
cardiacPhaseNumberPos
(package private) boolean
changeToUnsignedInts
private java.lang.String[]
contrastBolusAgent
private int
contrastBolusAgentIndex
private int
contrastBolusAgentPos
private java.lang.String[]
contrastBolusIngredient
private float[]
contrastBolusIngredientConcentration
private int
contrastBolusIngredientConcentrationIndex
private int
contrastBolusIngredientConcentrationPos
private int
contrastBolusIngredientIndex
private int
contrastBolusIngredientPos
private float[]
contrastBolusRoute
private int
contrastBolusRouteIndex
private int
contrastBolusRoutePos
private java.lang.String[]
contrastBolusStartTime
private int
contrastBolusStartTimeIndex
private int
contrastBolusStartTimePos
private float[]
contrastBolusTotalDose
private int
contrastBolusTotalDoseIndex
private int
contrastBolusTotalDosePos
private java.lang.String[]
contrastBolusVolume
private int
contrastBolusVolumeIndex
private int
contrastBolusVolumePos
private java.lang.String[]
contrastType
private int
contrastTypeIndex
private int
contrastTypePos
private int
counter
counterprivate float[][]
diffusion
private java.lang.String[]
diffusionAnisotropyType
private int
diffusionAnisotropyTypeIndex
private int
diffusionAnisotropyTypePos
private float[]
diffusionBFactor
private int[]
diffusionBValueNumber
private int
diffusionBValueNumberIndex
private int
diffusionBValueNumberPos
private DTIParameters
dtiparams
Object to save DWI paramters toprivate float[]
dynamicScanBeginTime
private int
dynamicScanBeginTimeIndex
private int
dynamicScanBeginTimePos
private int[]
dynamicScanNumber
private int
dynamicScanNumberIndex
private int
dynamicScanNumberPos
private int[]
echoNumber
private int
echoNumberIndex
private int
echoNumberPos
private float[]
echoTime
private int
echoTimeIndex
private int
echoTimePos
private java.lang.String
examName
exam nameprivate java.lang.String
fileDir
File directory of the image.private FileInfoPARREC
fileInfo
Reference to the file info. for an Analyze headerprivate FileInfoPARREC[]
fileInfoArray
private java.lang.String
fileName
File name of the image.private float[]
flipAngle
private int
flipAngleIndex
private int
flipAnglePos
private int[]
fmriStatusIndication
private int
fmriStatusIndicationIndex
private int
fmriStatusIndicationPos
private java.lang.String
foldover
private int[]
gradientOrientationNumber
private int
gradientOrientationNumberIndex
private int
gradientOrientationNumberPos
private int
gradIndex
private int
gradPos
bFactorIndexstatic java.lang.String[]
hdrEXTENSIONS
The extensions of ANALYZE file.private ModelImage
image
The image read in from the file.private float[][]
imageAngulation
private int
imageAngulationIndex
private int
imageAngulationPos
private float[][]
imageOffcentre
private int
imageOffcentreIndex
private int
imageOffcentrePos
private int[]
imageTypeEDES
private int
imageTypeEDESIndex
private int
imageTypeEDESPos
private int[]
imageTypeMR
private int
imageTypeMRIndex
private int
imageTypeMRPos
static java.lang.String[]
imgEXTENSIONS
private float[]
inversionDelay
private int
inversionDelayIndex
private int
inversionDelayPos
private boolean
isSortedByVolumes
normal par/rec are sorted by volumes...sometime, they are not sorted like this...instead they are based on slices if that is true, then we need to change around the image dataarray to make it sorted by volumesprivate int[]
labelType
private int
labelTypeIndex
private int
labelTypePos
private int[]
maximumRRInterval
private int
maximumRRIntervalIndex
private int
maximumRRIntervalPos
private int[]
minimumRRInterval
private int
minimumRRIntervalIndex
private int
minimumRRIntervalPos
private int[]
numberOfAverages
private int
numberOfAveragesIndex
private int
numberOfAveragesPos
private int
numSlices
num slices per volumeprivate int
numVolumes
num vols in 4d datasetprivate int
originalDataType
private FileInfoPARREC
outInfo
file infoprivate java.lang.String
patientName
private java.lang.String
patientPosition
patient positionprivate java.lang.String
protocolName
protocol nameprivate float[]
rescaleIntercept
floating point value = raw value/scaleSlope + rescaleIntercept/(rescaleSlope*scaleSlope)private float[]
rescaleSlope
private boolean
sameSliceScalings
True if the 3 values are the same for all slicesprivate float[]
scaleSlope
private int[]
scanningSequence
private int
scanningSequenceIndex
private int
scanningSequencePos
private int[]
scanPercentage
private int
scanPercentageIndex
private int
scanPercentagePos
private java.util.HashMap<java.lang.String,java.lang.Integer>
SliceMap
slice mapprivate int
sliceOrientIndex
private int
sliceOrientPos
private java.util.Vector<java.lang.String>
SliceParameters
slice parametersprivate java.util.Vector<java.lang.String>
Slices
slicesprivate float[]
triggerTime
private int
triggerTimeIndex
private int
triggerTimePos
private int[]
turboFactor
private int
turboFactorIndex
private int
turboFactorPos
private java.lang.String
version
versionprivate java.util.HashMap<java.lang.String,java.lang.String>
VolMap
vol mapprivate java.util.HashMap<java.lang.String,java.lang.String>
VolParameters
vol parametersprivate float
vox_offset
Voxel offset tag used to read in the image.private int[]
windowCenter
private int
windowCenterIndex
private int
windowCenterPos
private int[]
windowWidth
private int
windowWidthIndex
private int
windowWidthPos
-
Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE
-
-
Constructor Summary
Constructors Constructor Description FilePARREC(java.lang.String[] fileNames)
Creates a new FileAnalyze object.FilePARREC(java.lang.String fName, java.lang.String fDir)
Constructs new file object.FilePARREC(java.lang.String fileName, java.lang.String fileDirectory, FileInfoBase fileInfo)
Constructor used by FileIO to write an imageFilePARREC(java.lang.String fileName, java.lang.String fileDirectory, FileInfoPARREC[] fileInfoArray, boolean changeToUnsignedInts)
Constructor used by FileIO to write an image
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.HashMap<java.lang.String,java.lang.Integer>
buildParSliceMap()
private java.util.HashMap<java.lang.String,java.lang.String>
buildParVolMap()
static TransMatrix
ConvertToMIPAVConvention(TransMatrix mat)
Converts translation matrix to mipav specific formatModelImage
createImage()
DOCUMENT ME!void
finalize()
Prepares this class for cleanup.static java.lang.String[]
getCompleteFileNameList(java.lang.String absolutePath)
Returns the complete list of file names according to given file name.java.lang.String[]
getCompleteFileNameListDefault(java.lang.String absolutePath)
Gets the header and image file names given a header or image file nameFileInfoPARREC
getFileInfo()
Returns the FileInfoAnalyze read from the file.java.lang.String
getHeaderFile()
<<<<<<< .working Returns the header file.static java.lang.String
getHeaderFile(java.lang.String[] fileNames)
======= Returns the header file.java.lang.String[]
getImageFiles()
Returns the image file list.static java.lang.String[]
getImageFiles(java.lang.String[] fileNames)
Returns the image file list.private int
getOffset(FileInfoPARREC fileInfo)
Helper method to calculate the offset for getting only the middle analyze image slice from the 3D file.static boolean
isHeaderFile(java.lang.String absolutePath)
Return true if the file specified by absolutePath is header file of PARREC.static boolean
isImageFile(java.lang.String absolutePath)
Return true if the file specified by absolutePath is image file of PARREC.static TransMatrix
makeRotationMatrix(int[] size, double[] rotations)
Makes rotation matrix based on image angulations that were stored in header and converted to orientation-specific values.static TransMatrix
makeTranslationMatrix(double[] translations)
Makes rotation matrix based on image off-centres that were stored in header and converted to orientation-specific values.boolean
readHeader(java.lang.String imageFileName, java.lang.String fileDir)
Reads the analyze header and stores the information in fileInfo.ModelImage
readImage(boolean one)
Reads an PAR/REC image file by reading the header then making a FileRaw to read the image for all filenames in the file list.void
readImage(float[] buffer)
Reads in a PAR/REC image (first the header file, then the raw file)void
setImage(ModelImage image)
private void
updateStartLocations(FileInfoBase[] fileInfo)
Updates the start locations.private void
updateTransformMatrix(FileInfoPARREC fileInfo, ModelImage image)
private void
updateUnitsOfMeasure(FileInfoPARREC fileInfo, ModelImage image)
Updates the units of Measure in the file info based on the voxUnits from an Analyze Header.void
writeHeader(ModelImage writeImage, java.lang.String headerFileName, int beginSlice, int endSlice, int beginTime, int endTime, boolean rescale)
void
writeImage(ModelImage image, FileWriteOptions options)
Writes a PAR/REC format image and header.-
Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, floatToBytes, getBufferDouble, getBufferFloat, getBufferInt, getBufferLong, getBufferShort, getBufferUShort, getDataType, getDouble, getFloat, getInt, getLong, getProgressChangeListeners, getRaFile, getSignedShort, getString, getUInt, getUnsignedByte, getUnsignedShort, intToBytes, isBigEndian, isProgressBarVisible, linkProgress, longToBytes, readDouble, readFloat, readInt, readLong, readShort, readString, readUnsignedShort, removeProgressChangeListener, setBigEndian, setBufferFloat, setBufferInt, setBufferLong, setBufferShort, setBufferString, setDataType, setEndianess, shortToBytes, writeBytes, writeDouble, writeFloat, writeInt, writeLong, writeShort
-
-
-
-
Field Detail
-
hdrEXTENSIONS
public static final java.lang.String[] hdrEXTENSIONS
The extensions of ANALYZE file.
-
imgEXTENSIONS
public static final java.lang.String[] imgEXTENSIONS
-
fileDir
private java.lang.String fileDir
File directory of the image.
-
fileInfo
private FileInfoPARREC fileInfo
Reference to the file info. for an Analyze header
-
fileName
private java.lang.String fileName
File name of the image.
-
image
private ModelImage image
The image read in from the file.
-
dtiparams
private DTIParameters dtiparams
Object to save DWI paramters to
-
vox_offset
private float vox_offset
Voxel offset tag used to read in the image.
-
fileInfoArray
private FileInfoPARREC[] fileInfoArray
-
outInfo
private FileInfoPARREC outInfo
file info
-
VolMap
private java.util.HashMap<java.lang.String,java.lang.String> VolMap
vol map
-
SliceMap
private java.util.HashMap<java.lang.String,java.lang.Integer> SliceMap
slice map
-
VolParameters
private java.util.HashMap<java.lang.String,java.lang.String> VolParameters
vol parameters
-
SliceParameters
private java.util.Vector<java.lang.String> SliceParameters
slice parameters
-
Slices
private java.util.Vector<java.lang.String> Slices
slices
-
version
private java.lang.String version
version
-
patientName
private java.lang.String patientName
-
examName
private java.lang.String examName
exam name
-
protocolName
private java.lang.String protocolName
protocol name
-
patientPosition
private java.lang.String patientPosition
patient position
-
foldover
private java.lang.String foldover
-
sliceOrientPos
private int sliceOrientPos
-
bValuePos
private int bValuePos
bFactorIndex
-
gradPos
private int gradPos
bFactorIndex
-
echoNumberPos
private int echoNumberPos
-
dynamicScanNumberPos
private int dynamicScanNumberPos
-
cardiacPhaseNumberPos
private int cardiacPhaseNumberPos
-
imageTypeMRPos
private int imageTypeMRPos
-
scanningSequencePos
private int scanningSequencePos
-
scanPercentagePos
private int scanPercentagePos
-
windowCenterPos
private int windowCenterPos
-
windowWidthPos
private int windowWidthPos
-
imageAngulationPos
private int imageAngulationPos
-
imageOffcentrePos
private int imageOffcentrePos
-
fmriStatusIndicationPos
private int fmriStatusIndicationPos
-
imageTypeEDESPos
private int imageTypeEDESPos
-
echoTimePos
private int echoTimePos
-
dynamicScanBeginTimePos
private int dynamicScanBeginTimePos
-
triggerTimePos
private int triggerTimePos
-
numberOfAveragesPos
private int numberOfAveragesPos
-
flipAnglePos
private int flipAnglePos
-
cardiacFrequencyPos
private int cardiacFrequencyPos
-
minimumRRIntervalPos
private int minimumRRIntervalPos
-
maximumRRIntervalPos
private int maximumRRIntervalPos
-
turboFactorPos
private int turboFactorPos
-
inversionDelayPos
private int inversionDelayPos
-
diffusionBValueNumberPos
private int diffusionBValueNumberPos
-
gradientOrientationNumberPos
private int gradientOrientationNumberPos
-
contrastTypePos
private int contrastTypePos
-
diffusionAnisotropyTypePos
private int diffusionAnisotropyTypePos
-
labelTypePos
private int labelTypePos
-
contrastBolusAgentPos
private int contrastBolusAgentPos
-
contrastBolusRoutePos
private int contrastBolusRoutePos
-
contrastBolusVolumePos
private int contrastBolusVolumePos
-
contrastBolusStartTimePos
private int contrastBolusStartTimePos
-
contrastBolusTotalDosePos
private int contrastBolusTotalDosePos
-
contrastBolusIngredientPos
private int contrastBolusIngredientPos
-
contrastBolusIngredientConcentrationPos
private int contrastBolusIngredientConcentrationPos
-
sliceOrientIndex
private int sliceOrientIndex
-
bValueIndex
private int bValueIndex
-
gradIndex
private int gradIndex
-
echoNumberIndex
private int echoNumberIndex
-
dynamicScanNumberIndex
private int dynamicScanNumberIndex
-
cardiacPhaseNumberIndex
private int cardiacPhaseNumberIndex
-
imageTypeMRIndex
private int imageTypeMRIndex
-
scanningSequenceIndex
private int scanningSequenceIndex
-
scanPercentageIndex
private int scanPercentageIndex
-
windowCenterIndex
private int windowCenterIndex
-
windowWidthIndex
private int windowWidthIndex
-
imageAngulationIndex
private int imageAngulationIndex
-
imageOffcentreIndex
private int imageOffcentreIndex
-
fmriStatusIndicationIndex
private int fmriStatusIndicationIndex
-
imageTypeEDESIndex
private int imageTypeEDESIndex
-
echoTimeIndex
private int echoTimeIndex
-
dynamicScanBeginTimeIndex
private int dynamicScanBeginTimeIndex
-
triggerTimeIndex
private int triggerTimeIndex
-
numberOfAveragesIndex
private int numberOfAveragesIndex
-
flipAngleIndex
private int flipAngleIndex
-
cardiacFrequencyIndex
private int cardiacFrequencyIndex
-
minimumRRIntervalIndex
private int minimumRRIntervalIndex
-
maximumRRIntervalIndex
private int maximumRRIntervalIndex
-
turboFactorIndex
private int turboFactorIndex
-
inversionDelayIndex
private int inversionDelayIndex
-
diffusionBValueNumberIndex
private int diffusionBValueNumberIndex
-
gradientOrientationNumberIndex
private int gradientOrientationNumberIndex
-
contrastTypeIndex
private int contrastTypeIndex
-
diffusionAnisotropyTypeIndex
private int diffusionAnisotropyTypeIndex
-
labelTypeIndex
private int labelTypeIndex
-
contrastBolusAgentIndex
private int contrastBolusAgentIndex
-
contrastBolusRouteIndex
private int contrastBolusRouteIndex
-
contrastBolusVolumeIndex
private int contrastBolusVolumeIndex
-
contrastBolusStartTimeIndex
private int contrastBolusStartTimeIndex
-
contrastBolusTotalDoseIndex
private int contrastBolusTotalDoseIndex
-
contrastBolusIngredientIndex
private int contrastBolusIngredientIndex
-
contrastBolusIngredientConcentrationIndex
private int contrastBolusIngredientConcentrationIndex
-
echoNumber
private int[] echoNumber
-
dynamicScanNumber
private int[] dynamicScanNumber
-
cardiacPhaseNumber
private int[] cardiacPhaseNumber
-
imageTypeMR
private int[] imageTypeMR
-
scanningSequence
private int[] scanningSequence
-
scanPercentage
private int[] scanPercentage
-
windowCenter
private int[] windowCenter
-
windowWidth
private int[] windowWidth
-
imageAngulation
private float[][] imageAngulation
-
imageOffcentre
private float[][] imageOffcentre
-
fmriStatusIndication
private int[] fmriStatusIndication
-
imageTypeEDES
private int[] imageTypeEDES
-
echoTime
private float[] echoTime
-
dynamicScanBeginTime
private float[] dynamicScanBeginTime
-
triggerTime
private float[] triggerTime
-
numberOfAverages
private int[] numberOfAverages
-
flipAngle
private float[] flipAngle
-
cardiacFrequency
private int[] cardiacFrequency
-
minimumRRInterval
private int[] minimumRRInterval
-
maximumRRInterval
private int[] maximumRRInterval
-
turboFactor
private int[] turboFactor
-
inversionDelay
private float[] inversionDelay
-
diffusionBFactor
private float[] diffusionBFactor
-
diffusionBValueNumber
private int[] diffusionBValueNumber
-
gradientOrientationNumber
private int[] gradientOrientationNumber
-
contrastType
private java.lang.String[] contrastType
-
diffusionAnisotropyType
private java.lang.String[] diffusionAnisotropyType
-
diffusion
private float[][] diffusion
-
labelType
private int[] labelType
-
contrastBolusAgent
private java.lang.String[] contrastBolusAgent
-
contrastBolusRoute
private float[] contrastBolusRoute
-
contrastBolusVolume
private java.lang.String[] contrastBolusVolume
-
contrastBolusStartTime
private java.lang.String[] contrastBolusStartTime
-
contrastBolusTotalDose
private float[] contrastBolusTotalDose
-
contrastBolusIngredient
private java.lang.String[] contrastBolusIngredient
-
contrastBolusIngredientConcentration
private float[] contrastBolusIngredientConcentration
-
counter
private int counter
counter
-
rescaleIntercept
private float[] rescaleIntercept
floating point value = raw value/scaleSlope + rescaleIntercept/(rescaleSlope*scaleSlope)
-
rescaleSlope
private float[] rescaleSlope
-
scaleSlope
private float[] scaleSlope
-
sameSliceScalings
private boolean sameSliceScalings
True if the 3 values are the same for all slices
-
originalDataType
private int originalDataType
-
isSortedByVolumes
private boolean isSortedByVolumes
normal par/rec are sorted by volumes...sometime, they are not sorted like this...instead they are based on slices if that is true, then we need to change around the image dataarray to make it sorted by volumes
-
numSlices
private int numSlices
num slices per volume
-
numVolumes
private int numVolumes
num vols in 4d dataset
-
changeToUnsignedInts
boolean changeToUnsignedInts
-
-
Constructor Detail
-
FilePARREC
public FilePARREC(java.lang.String[] fileNames)
Creates a new FileAnalyze object.- Parameters:
fileNames
- DOCUMENT ME!
-
FilePARREC
public FilePARREC(java.lang.String fName, java.lang.String fDir)
Constructs new file object.- Parameters:
fName
- File name.fDir
- File directory.
-
FilePARREC
public FilePARREC(java.lang.String fileName, java.lang.String fileDirectory, FileInfoPARREC[] fileInfoArray, boolean changeToUnsignedInts)
Constructor used by FileIO to write an image- Parameters:
fileName
-fileDirectory
-fileInfoPARREC
- []changeToUnsignedInts
-
-
FilePARREC
public FilePARREC(java.lang.String fileName, java.lang.String fileDirectory, FileInfoBase fileInfo)
Constructor used by FileIO to write an image- Parameters:
fileName
-fileDirectory
-fileInfo
-
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for cleanup. Calls thefinalize
method for existing elements, closes any open files and sets other elements tonull
.
-
setImage
public void setImage(ModelImage image)
- Parameters:
image
-
-
getCompleteFileNameList
public static java.lang.String[] getCompleteFileNameList(java.lang.String absolutePath)
Returns the complete list of file names according to given file name.- Parameters:
absolutePath
- one file name of PARREC.- Returns:
- the complete list of file names.
-
getHeaderFile
public static java.lang.String getHeaderFile(java.lang.String[] fileNames)
======= Returns the header file.- Parameters:
fileNames
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getImageFiles
public static java.lang.String[] getImageFiles(java.lang.String[] fileNames)
Returns the image file list.- Parameters:
fileNames
- DOCUMENT ME!- Returns:
- the image file list.
-
isHeaderFile
public static boolean isHeaderFile(java.lang.String absolutePath)
Return true if the file specified by absolutePath is header file of PARREC.- Parameters:
absolutePath
- the file name including path information.- Returns:
- true if the specified file is header file.
-
isImageFile
public static boolean isImageFile(java.lang.String absolutePath)
Return true if the file specified by absolutePath is image file of PARREC.- Parameters:
absolutePath
- the file name including path information.- Returns:
- true if the specified file is image file.
-
createImage
public ModelImage createImage() throws java.io.IOException, java.lang.OutOfMemoryError
DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
java.io.IOException
- DOCUMENT ME!java.lang.OutOfMemoryError
- DOCUMENT ME!
-
updateTransformMatrix
private void updateTransformMatrix(FileInfoPARREC fileInfo, ModelImage image)
-
ConvertToMIPAVConvention
public static TransMatrix ConvertToMIPAVConvention(TransMatrix mat)
Converts translation matrix to mipav specific format
-
makeTranslationMatrix
public static TransMatrix makeTranslationMatrix(double[] translations)
Makes rotation matrix based on image off-centres that were stored in header and converted to orientation-specific values.
-
makeRotationMatrix
public static TransMatrix makeRotationMatrix(int[] size, double[] rotations)
Makes rotation matrix based on image angulations that were stored in header and converted to orientation-specific values.
-
getFileInfo
public FileInfoPARREC getFileInfo()
Returns the FileInfoAnalyze read from the file.- Returns:
- File info read from file, or null if it has not been read.
-
getHeaderFile
public java.lang.String getHeaderFile()
<<<<<<< .working Returns the header file.- Returns:
- DOCUMENT ME!
-
getImageFiles
public java.lang.String[] getImageFiles()
Returns the image file list.- Returns:
- the image file list.
-
readHeader
public boolean readHeader(java.lang.String imageFileName, java.lang.String fileDir) throws java.io.IOException
Reads the analyze header and stores the information in fileInfo.- Parameters:
imageFileName
- File name of image.fileDir
- Directory.- Returns:
- Flag to confirm a successful read.
- Throws:
java.io.IOException
- if there is an error reading the header- See Also:
FileInfoAnalyze
-
readImage
public ModelImage readImage(boolean one) throws java.io.IOException, java.lang.OutOfMemoryError
Reads an PAR/REC image file by reading the header then making a FileRaw to read the image for all filenames in the file list. Only the one file directory (currently) supported.- Parameters:
one
- flag indicating one image of a 3D dataset should be read in.- Returns:
- The image.
- Throws:
java.io.IOException
- if there is an error reading the filejava.lang.OutOfMemoryError
- See Also:
FileRaw
-
readImage
public void readImage(float[] buffer) throws java.io.IOException, java.lang.OutOfMemoryError
Reads in a PAR/REC image (first the header file, then the raw file)- Parameters:
buffer
- Image buffer to store image data into.- Throws:
java.io.IOException
- if there is an error reading the filejava.lang.OutOfMemoryError
- See Also:
FileRaw
-
writeImage
public void writeImage(ModelImage image, FileWriteOptions options) throws java.io.IOException
Writes a PAR/REC format image and header.- Parameters:
image
- Image model of data to write.- Throws:
java.io.IOException
- if there is an error writing the file- See Also:
FileInfoAnalyze
,FileRaw
-
getOffset
private int getOffset(FileInfoPARREC fileInfo)
Helper method to calculate the offset for getting only the middle analyze image slice from the 3D file.- Parameters:
fileInfo
- File info.- Returns:
- offset
-
updateStartLocations
private void updateStartLocations(FileInfoBase[] fileInfo)
Updates the start locations. Each image has a fileinfo where the start locations are stored. Note that the start location for the Z (3rd) dimension change with the change is the slice. The origin is in the upper left corner and we are using the right hand rule. + x -> left to right; + y -> top to bottom and + z -> into screen.- Parameters:
fileInfo
- DOCUMENT ME!
-
updateUnitsOfMeasure
private void updateUnitsOfMeasure(FileInfoPARREC fileInfo, ModelImage image)
Updates the units of Measure in the file info based on the voxUnits from an Analyze Header.- Parameters:
fileInfo
- -- an Analyze file Info that has already been readimage
- -- a ModelImage that the fileInfo needs to be attached to
-
getCompleteFileNameListDefault
public java.lang.String[] getCompleteFileNameListDefault(java.lang.String absolutePath)
Gets the header and image file names given a header or image file name- Parameters:
absolutePath
- header or image filename- Returns:
- array [0] headerfilename [1] imagefilename
-
writeHeader
public void writeHeader(ModelImage writeImage, java.lang.String headerFileName, int beginSlice, int endSlice, int beginTime, int endTime, boolean rescale) throws java.io.IOException
- Parameters:
writeImage
-headerFileName
-beginSlice
-endSlice
-beginTime
-endTime
-rescale
-- Throws:
java.io.IOException
-
buildParVolMap
private java.util.HashMap<java.lang.String,java.lang.String> buildParVolMap()
-
buildParSliceMap
private java.util.HashMap<java.lang.String,java.lang.Integer> buildParSliceMap()
-
-