Package gov.nih.mipav.model.file
Class FileBRUKER
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileBRUKER
-
public class FileBRUKER extends FileBase
Reads a BRUKER file by first reading in the d3proc header file or if the d3proc header file is not\ present the visu_pars file, second the reco header file, third the acqp file in the same directory or up one or two two parent directories, then the method file,l and finally the 2dseq binary file. Paravision uses a subject patient coordinate system (L->R, P->A, F->H), with X = L->R, Y = P->A, and Z = F->H. This is different from the DICOM R->L, A->P, F->H. Paravision also has a (r, p, s) read, phase, slice coordinate system. ND is the total number of diffusion experiments. The B Matrix (PVM_DwBMat)(implemented as symmetric 3x3 matrix array of size ND) is calculated for each diffusion experiment in the imaging coordinate system (r,p,s). Diffusion Gradient Vector (PVM_DwGradVec) - Parameter of dimension ND X 3 specifying the diffusion gradient amplitudes in the x,y,z coordinate system. Eff. B Value (PVM_DwEffBval) - The trace of the b-matrix (is implemented as an array of size ND. ACQ_patient_pos - defines the patient position inside the magnet. According to the defined patient position. ACQ_patient_pos may have the values: Head_Supine - negates Gx and Gz. Head_Prone - negates Gy and Gz. Head_Left - negates Gz. Gx and Gy are exchanged. Head_Right - negates Gx, Gy and Gz. Gx and Gy are exchanged. Foot_Supine - all gradients remain unchanged. Foot_Prone - negates Gx and Gy. Foot_Left - negates Gy. Gx and Gy are exchanged. Foot_Right - negates Gx. Gx and Gy are exchanged. Look at O05_GeoEditor Figure 5.1. The description of gradient interchanges and negations together with the figure show that the x, y, and z must be remaining constant independent of patient position. Therefore, once you have x, y, z directly from PVM_DwGradVec or use ACQ_grad_matrix to convert PVM_DwBMat from r,p,s to x,y,z, there is no need to consider ACQ_patient_pos. ACQ_slice_sepn_mode - defines the slice separation mode of a multi slice experiment. It can be either Contiguous, Equidistant, Var_Parallel or Var_Angle. In case of Contiguous, Equidistant and Var_Parallel, the parameter ACQ_grad_matrix has only one item in the slice dimension, since these slice orientations produce parallel slices. In case of Var_Angle, ACQ_grad_matrix has to have NSLICES items in the slice dimension to define the orientation for each slice separately. NSLICES - defines the number of slices of a multi slice experiment. ACQ_grad_matrix[ ][3][3] - is a three dimensional array describing the slice orientation of the images to be measured. For ACQ_grad_matrix[i][j][k] i = 0, ..., NSLICES - 1 specifies the slice index during the acquisition, j = 0, 1, 2 specifies the read-, phase- and slice gradients, k = 0, 1, 2 specifies the x, y and z components of the slice direction independent of the patient position. The gradient matrix of each slice is orthonormal, which means that the read-, phase- and slice-gradient vectors are normalized to 1.0 and that they are orthogonal to each other. The following Example shows a two slice experiment with slice orientation Cor_Sag_oblique with ACQ_slice_sepn_mode Var_Angle with 0o for the first slice and 30o for the second slice. Example: Cor_Sag_oblique ACQ_slice_sepn_mode = Var_Angle NSLICES = 2, (0 and 30 degree orientation) ACQ_grad_matrix[0][0][0] = 1; 1st slice, read, Gx ACQ_grad_matrix[0][0][1] = 0; 1st slice, read, Gy ACQ_grad_matrix[0][0][2] = 0; 1st slice, read, Gz ACQ_grad_matrix[0][1][0] = 0; 1st slice, phase, Gx ACQ_grad_matrix[0][1][1] = 0; 1st slice, phase, Gy ACQ_grad_matrix[0][1][2] = 1; 1st slice, phase, Gz ACQ_grad_matrix[0][2][0] = 0; 1st slice, slice, Gx ACQ_grad_matrix[0][2][1] = 1; 1st slice, slice, Gy ACQ_grad_matrix[0][2][2] = 0; 1st slice, slice, Gz ACQ_grad_matrix[1][0][0] = 0.866; 2nd slice, read, Gx ACQ_grad_matrix[1][0][1] = 0.5; 2nd slice, read, Gy ACQ_grad_matrix[1][0][2] = 0; 2nd slice, read, Gz ACQ_grad_matrix[1][1][0] = 0; 2nd slice, phase, Gx ACQ_grad_matrix[1][1][1] = 0; 2nd slice, phase, Gy ACQ_grad_matrix[1][1][2] = 1; 2nd slice, phase, Gz ACQ_grad_matrix[1][2][0] = -0,5; 2nd slice, slice, Gx ACQ_grad_matrix[1][2][1] = 0.866; 2nd slice, slice, Gy ACQ_grad_matrix[1][2][2] = 0; 2nd slice, slice, Gz [x, y, z] = [r, p, s] * [ACQ_grad_matrix] Let A = ACQ_grad_matrix [x] [r] [y] = ATranspose [p] [z] [s] [x] [x][y][z] = ATranspose [r] [r][p][s] A [y] [p] [z] [s] so the to the BMatrix expressed in terms of xyz is ATranspose B A [x] [y] [z] [x] = [r][p][s] A ATranspose [r] [y] [p] [z] [s] For orthonormal matrices ATranspose = AInverse, so the trace of the B matrix is the same for both x,y,z and r,p,s coordinates.
-
-
Field Summary
Fields Modifier and Type Field Description private double[][]bMatrixValsprivate double[]bValuesprivate DTIParametersdtiParamsprivate java.io.FilefileDOCUMENT ME!private java.lang.StringfileDirDOCUMENT ME!private FileInfoBRUKERfileInfoDOCUMENT ME!private FileInfoBRUKERfileInfoCopyprivate java.lang.StringfileNameDOCUMENT ME!private booleanfoundEOFDOCUMENT ME!private double[][]gradientsprivate ModelImageimageDOCUMENT ME!private intimageSliceDOCUMENT ME!private float[]imgResolsDOCUMENT ME!private ModelLUTLUTDOCUMENT ME!private intnumVolumesprivate java.lang.StringprefImageNameThe preferred image name, used if inversion time exists.-
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 FileBRUKER(java.lang.String fileName, java.lang.String fileDir)BRUKER reader/writer constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.ArrayList<java.lang.String>childDir(java.io.File currentDir)Returns an ArrayList of all the names of subdirectories of the directory denoted bycurrentDir.voidfinalize()Prepares this class for cleanup.DTIParametersgetDTIParameters()java.lang.StringgetFileDir()This convenience method is needed to establish the location of the 2dseq fileFileInfoBasegetFileInfo()Accessor that returns the file info.ModelLUTgetModelLUT()returns LUT if defined.private java.lang.String[]parse(java.lang.String inString)DOCUMENT ME!voidreadacqp()DOCUMENT ME!private voidreadBuffer(int slice, float[] buffer)Reads a slice of data at a time and stores the results in the buffer.voidreadd3proc()DOCUMENT ME!ModelImagereadImage(boolean one)This method reads one slice from the file into byteBuffer and then transfers into the float array imgBuffer.private java.lang.StringreadLine()Reads lines of the file until a nonnull String results or the end of the file is reached.voidreadMethod()Reads the optional method file that may be part of the Bruker scan.voidreadreco()DOCUMENT ME!voidreadvisu_pars()DOCUMENT ME!private java.lang.StringsearchChildDir(java.io.File currentDir)Utility method for searching for the d3proc file that indicates a BRUKER file has been found, note method is recursive to a maximum level of 3.voidsetFileDir(java.lang.String fDir)Accessor to set the file directory (used for reading BRUKER files).voidsetFileName(java.lang.String fName)Accessor to set the file name (used for reading BRUKER files).-
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
-
file
private java.io.File file
DOCUMENT ME!
-
fileDir
private java.lang.String fileDir
DOCUMENT ME!
-
fileInfo
private FileInfoBRUKER fileInfo
DOCUMENT ME!
-
fileInfoCopy
private FileInfoBRUKER fileInfoCopy
-
fileName
private java.lang.String fileName
DOCUMENT ME!
-
foundEOF
private boolean foundEOF
DOCUMENT ME!
-
image
private ModelImage image
DOCUMENT ME!
-
imageSlice
private int imageSlice
DOCUMENT ME!
-
imgResols
private float[] imgResols
DOCUMENT ME!
-
LUT
private ModelLUT LUT
DOCUMENT ME!
-
prefImageName
private java.lang.String prefImageName
The preferred image name, used if inversion time exists.
-
numVolumes
private int numVolumes
-
dtiParams
private DTIParameters dtiParams
-
bMatrixVals
private double[][] bMatrixVals
-
gradients
private double[][] gradients
-
bValues
private double[] bValues
-
-
Method Detail
-
searchChildDir
private java.lang.String searchChildDir(java.io.File currentDir)
Utility method for searching for the d3proc file that indicates a BRUKER file has been found, note method is recursive to a maximum level of 3.
-
childDir
private java.util.ArrayList<java.lang.String> childDir(java.io.File currentDir)
Returns an ArrayList of all the names of subdirectories of the directory denoted bycurrentDir.
-
finalize
public void finalize()
Prepares this class for cleanup. Calls thefinalizemethod for existing elements, closes any open files and sets other elements tonull.
-
getFileInfo
public FileInfoBase getFileInfo()
Accessor that returns the file info.- Returns:
- FileInfoBase containing the file info
-
getModelLUT
public ModelLUT getModelLUT()
returns LUT if defined.- Returns:
- the LUT if defined else it is null
-
getDTIParameters
public DTIParameters getDTIParameters()
- Returns:
-
readMethod
public void readMethod() throws java.io.IOExceptionReads the optional method file that may be part of the Bruker scan.- Throws:
java.io.IOException- DOCUMENT ME!
-
readacqp
public void readacqp() throws java.io.IOExceptionDOCUMENT ME!- Throws:
java.io.IOException- DOCUMENT ME!
-
readvisu_pars
public void readvisu_pars() throws java.io.IOExceptionDOCUMENT ME!- Throws:
java.io.IOException- DOCUMENT ME!
-
readd3proc
public void readd3proc() throws java.io.IOExceptionDOCUMENT ME!- Throws:
java.io.IOException- DOCUMENT ME!
-
readImage
public ModelImage readImage(boolean one) throws java.io.IOException
This method reads one slice from the file into byteBuffer and then transfers into the float array imgBuffer.- Parameters:
one- DOCUMENT ME!- Returns:
- returns the image
- Throws:
java.io.IOException- if there is an error reading the file
-
readreco
public void readreco() throws java.io.IOExceptionDOCUMENT ME!- Throws:
java.io.IOException- DOCUMENT ME!
-
setFileDir
public void setFileDir(java.lang.String fDir)
Accessor to set the file directory (used for reading BRUKER files).- Parameters:
fDir- file directory of image to read.
-
setFileName
public void setFileName(java.lang.String fName)
Accessor to set the file name (used for reading BRUKER files).- Parameters:
fName- file name of image to read.
-
parse
private java.lang.String[] parse(java.lang.String inString)
DOCUMENT ME!- Parameters:
inString- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
readBuffer
private void readBuffer(int slice, float[] buffer) throws java.io.IOExceptionReads a slice of data at a time and stores the results in the buffer.- Parameters:
slice- offset into the file stored in the dataOffset arraybuffer- buffer where the info is stored- Throws:
java.io.IOException- if there is an error reading the file
-
readLine
private java.lang.String readLine() throws java.io.IOExceptionReads lines of the file until a nonnull String results or the end of the file is reached.- Returns:
- the line read in
- Throws:
java.io.IOException- if there is an error reading the file
-
getFileDir
public java.lang.String getFileDir()
This convenience method is needed to establish the location of the 2dseq file
-
-