Class 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 Detail

      • file

        private java.io.File file
        DOCUMENT ME!
      • fileDir

        private java.lang.String fileDir
        DOCUMENT ME!
      • fileName

        private java.lang.String fileName
        DOCUMENT ME!
      • foundEOF

        private boolean foundEOF
        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
      • bMatrixVals

        private double[][] bMatrixVals
      • gradients

        private double[][] gradients
      • bValues

        private double[] bValues
    • Constructor Detail

      • FileBRUKER

        public FileBRUKER​(java.lang.String fileName,
                          java.lang.String fileDir)
                   throws java.io.IOException
        BRUKER reader/writer constructor.
        Parameters:
        fileName - file name
        fileDir - file directory
        Throws:
        java.io.IOException - if there is an error making the file
    • 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 by currentDir.
      • finalize

        public void finalize()
        Prepares this class for cleanup. Calls the finalize method for existing elements, closes any open files and sets other elements to null.
        Overrides:
        finalize in class FileBase
      • 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.IOException
        Reads 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.IOException
        DOCUMENT ME!
        Throws:
        java.io.IOException - DOCUMENT ME!
      • readvisu_pars

        public void readvisu_pars()
                           throws java.io.IOException
        DOCUMENT ME!
        Throws:
        java.io.IOException - DOCUMENT ME!
      • readd3proc

        public void readd3proc()
                        throws java.io.IOException
        DOCUMENT 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.IOException
        DOCUMENT 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.IOException
        Reads a slice of data at a time and stores the results in the buffer.
        Parameters:
        slice - offset into the file stored in the dataOffset array
        buffer - 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.IOException
        Reads 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