Class FileInfoMinc

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class FileInfoMinc
    extends FileInfoBase
    This class holds all the file information for a MINC file. In addition, it has three classes to organize the data.

    MINC headers have three main parts: the dimensions, the global attributes, and the variables. There are typically three dimensions, representing the x, y, and z dimensions of the image. There is usually one global attribute, the history. There can be any number of variables.

    Variables have within them any number of attributes. So for example, "rootvariable", the first variable in all the MINC files I have seen so far, has the following attributes: varid (= "MINC standard variable"), vartype (= "group________"), version (= "MINC version 1.0"), parent (blank), and children (image). Usually there is a variable for each dimension, a variable for the image, a variable for image min, and a variable for image max. There can also be variables containing patient information or anything else useful.

    See the documentation for the classes MincDimElem, MincAttElem, and MincVarElem for further information. The classes are structured exactly like a MINC file.

    Version:
    1.0 July 1, 2000
    See Also:
    FileMinc, Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • NC_BYTE

        public static final int NC_BYTE
        NetCDF defined data type - byte.
        See Also:
        Constant Field Values
      • NC_CHAR

        public static final int NC_CHAR
        NetCDF defined data type - character.
        See Also:
        Constant Field Values
      • NC_SHORT

        public static final int NC_SHORT
        NetCDF defined data type - short.
        See Also:
        Constant Field Values
      • NC_INT

        public static final int NC_INT
        NetCDF defined data type - integer.
        See Also:
        Constant Field Values
      • NC_FLOAT

        public static final int NC_FLOAT
        NetCDF defined data type - float.
        See Also:
        Constant Field Values
      • NC_DOUBLE

        public static final int NC_DOUBLE
        NetCDF defined data type - double.
        See Also:
        Constant Field Values
      • NC_DIMENSION

        public static final int NC_DIMENSION
        NetCDF defined data type - dimension.
        See Also:
        Constant Field Values
      • NC_VARIABLE

        public static final int NC_VARIABLE
        NetCDF defined data type - variable.
        See Also:
        Constant Field Values
      • NC_ATTRIBUTE

        public static final int NC_ATTRIBUTE
        NetCDF defined data type - attribute.
        See Also:
        Constant Field Values
      • dicomToMincVarMap

        public static final java.lang.String[] dicomToMincVarMap
        Minc var equivalents to anonymizable Dicom tags. Must be in the same order as FileInfoDicom.anonymizeTagIDs.
        See Also:
        FileInfoDicom.anonymizeTagIDs
      • numrecs

        public int numrecs
        DOCUMENT ME!
      • vmax

        public double vmax
        Valid image maximum value. Default = -1.
      • vmin

        public double vmin
        Valid image minimum value. Default = -1.
    • Constructor Detail

      • FileInfoMinc

        public FileInfoMinc​(java.lang.String name,
                            java.lang.String directory,
                            int format)
        MINC file information constructor.
        Parameters:
        name - file name
        directory - file directory
        format - format (in this case, MINC)
    • Method Detail

      • addAttValue

        public void addAttValue​(FileMincAttElem elem,
                                java.lang.Object value,
                                int index)
        Sets the value of the attribute element; used for setting attribute of variables. A MincVarElem has an array of attributes and this method is called on those attributes.
        Parameters:
        elem - the attribute element to add the value to.
        value - the value to set the element to.
        index - the index into the value array to set this value at.
        See Also:
        FileMincAttElem.setValue(java.lang.Object, int)
      • addDimElem

        public void addDimElem​(java.lang.String name,
                               int length,
                               int index)
        Puts a new dimension element with the specified parameters into the dimension array at the gievn index. The name is usually xspace, yspace, or zspace; the length is the corresponding size of that dimension.
        Parameters:
        name - the name of the dimension element
        length - the length of the dimension element
        index - the index to put this element into the array
      • addGattElem

        public void addGattElem​(java.lang.String name,
                                int type,
                                int length,
                                int index)
        Puts a new global attribute array element with the specified parameters into the global attribute array at the given index. Usually there is only one element in the global attribute array: the history.
        Parameters:
        name - the name of the global attribute element
        type - the data type, i.e. byte, char, int, etc (see statically defined types)
        length - the length of the element
        index - the index into the array to put this element at
      • addVarElem

        public void addVarElem​(java.lang.String name,
                               int nelems,
                               int[] dimid,
                               int index)
        Puts a new variable element with the specified paramenters into the array at the given index. There are other attributes to set for variables, in particular the attribute array, but that gets set in a different place.
        Parameters:
        name - the name of this variable element
        nelems - the number of elements in the attribute array
        dimid - the dimension id array, usually empty but for "image" containing information about the dimensions
        index - index into the variable array to put this variable
        See Also:
        FileMincVarElem
      • anonymize

        public final void anonymize​(boolean[] list)
        Removes requested identifying info. Can remove info stored in the minc header in a dicom-like structure and in a more minc-like info structure.
        Parameters:
        list - the list of tags to remove; it MUST correspond to anonymizeTagIDs list (or spurious errors result), and it must be of the same length, or this will throw an IllegalArgumentException.
        Throws:
        java.lang.IllegalArgumentException - DOCUMENT ME!
      • calculateIntercept

        public static final double calculateIntercept​(double min,
                                                      double slope,
                                                      double validMin)
        Calculates rescale intercept given a min and a slope value.
        Parameters:
        min - Min value.
        slope - Slope value.
        Returns:
        Rescale intercept.
      • calculateRescaleIntercept

        public void calculateRescaleIntercept​(double[] rescaleIntercept,
                                              double[] rescaleSlope)
        In MINC images, "real" values for pixels are calculated by taking the given image min and image max and rescaling the data accordingly. Image min and image max are given per slice.
        Parameters:
        rescaleIntercept - Array of rescale intercepts to set
        rescaleSlope - Array of rescale slopes to set
      • calculateSlope

        public static final double calculateSlope​(double max,
                                                  double min,
                                                  double validMax,
                                                  double validMin)
        Calculates rescale slope given a min and a max value.
        Parameters:
        max - Max value.
        min - Min value.
        Returns:
        Rescale slope
      • convertTagsToTable

        public java.util.Hashtable<java.lang.String,​java.lang.String> convertTagsToTable()
        Returns all of the dicom-converted tags in the minc header as a tag-value hashtable.
        Returns:
        a tag-value hashtable
      • createDimArray

        public final void createDimArray​(int length)
        Constructs the dimension array with the specified length.
        Parameters:
        length - the length of the array
      • createGattArray

        public final void createGattArray​(int length)
        Constructs the global attribute array with the specified length.
        Parameters:
        length - the length of the array
      • createVarArray

        public final void createVarArray​(int length)
        Constructs the variable array with the specified length.
        Parameters:
        length - the length of the array
      • displayAboutInfo

        public void displayAboutInfo​(JDialogBase dlog,
                                     TransMatrix matrix)
        Displays important information about the image.
        Specified by:
        displayAboutInfo in class FileInfoBase
        Parameters:
        dlog - where to display the info
        matrix - the transformation matrix
      • getConvertStartLocationsToDICOM

        public final double[] getConvertStartLocationsToDICOM​(int slice,
                                                              int time)
        Accessor that gets the "start" variable values, adjusted so that [0] holds the image x axis value, [1] the image y axis value, and [2] the image z axis value.

        MINC positive axis is left to right; positive axis is posterior to anterior; postive axis is inferior to superior

        DICOM positive axis is right to left; positive axis is anterior to posterior; postive axis is inferior to superior

        If the space's alignment attribute has the value 'centre', then subtract half the space's step value (doesn't seem to apply to zspace for some reason..). Then transform the point by the inverse of the direction_cosines matrix (extracted from the spaces). The result then has some of the signs of its components flipped (which is determined by the image orientation) to get it from minc to dicom orientation.

        Parameters:
        slice - slice to begin the start variable on.
        timeSlice - time to begin the start variable on
        Returns:
        The slice position in dicom (and mipav) space.
      • getDicomValue

        public java.lang.String getDicomValue​(java.lang.String dicomTag)
        Get the value from the minc info based on a given dicom tag id.
        Parameters:
        dicomTag - dicom tag (group,elem)
        Returns:
        the value stored in the info (or null if it doesn't exist)
      • getDimArray

        public final FileMincDimElem[] getDimArray()
        Gets the array with the dimension information.
        Returns:
        the array
      • getDimElem

        public final FileMincDimElem getDimElem​(int index)
        Accessor that returns the dimension element at the indicated index in the dimension array.
        Parameters:
        index - index where the dimension element is located
        Returns:
        dimArray[index]
      • getGattArray

        public final FileMincAttElem[] getGattArray()
        Gets the array with the attribute information.
        Returns:
        the array
      • getGattElem

        public final FileMincAttElem getGattElem​(int index)
        Accessor that returns the global attribute element at the indicated index in the global attribute array.
        Parameters:
        index - index where the global attribute element is located
        Returns:
        gattArray[index]
      • getStartLocations

        public final float[] getStartLocations()
        Accessor that gets the "start" variable values, with the "xspace" in 0, "yspace" in 1, and "zspace" in 2. This differs from the other methods because it doesn't place the values so that they correspond to image x, y, and z. Gets values as stored in MINC header, not modified to account for the different origin.
        Returns:
        The "start" values for the image.
      • getVarArray

        public final FileMincVarElem[] getVarArray()
        Gets the array with the variable information.
        Returns:
        the array
      • getVarElem

        public final FileMincVarElem getVarElem​(int index)
        Accessor that returns the variable element at the indicated index in the variable array.
        Parameters:
        index - index where the variable element is located
        Returns:
        varArray[index]
      • setImportantImageInfo

        public final void setImportantImageInfo()
        Sets necessary image information.
      • setModality

        public void setModality()
        Sets the image modality based on the.
      • setResolutions

        public void setResolutions​(int orientation)
        Sets the resolutions from the variable array based on the orientation of the image. The "zspace" in MINC refers to the inferior-superior axis, whereas in MIPAV the z resolution variable is the slices (space between slices) regardless of the orientation. Therefore for proper display we must convert between them.
        Parameters:
        orientation - The orientation of the image (sagittal, coronal, or axial).
      • setStartLocations

        public final void setStartLocations​(double[] origin)
        Sets start locations of each axis.
        Parameters:
        origin - the image origin
      • setUnits

        public final void setUnits()
        Sets the units of the dimensions, as in millimeters, inches, etc. Called after the header has been read in so the values within the varArray have been set properly already.
      • getTagElem

        private static java.lang.String getTagElem​(java.lang.String fullTag)
        Extract the element identifier (removing the group id).
        Parameters:
        fullTag - the full element identitfier
        Returns:
        the element id
      • getTagGroup

        private static java.lang.String getTagGroup​(java.lang.String fullTag)
        Extract the group to which a dicom or minc element belongs to.
        Parameters:
        fullTag - the full element identitfier
        Returns:
        the element group
      • getAxisOrientation

        public static int[] getAxisOrientation​(TransMatrix mat)
        Return the 3 axis orientation codes that correspond to the closest standard anatomical orientation of the (i,j,k) axes.
        Parameters:
        mat - 4x4 matrix that transforms (i,j,k) indexes to x,y,z coordinates where +x = Right, +y = Anterior, +z = Superior Only the upper-left 3x3 corner of the matrix is used This routine finds the permutation of (x,y,z) which has the smallest angle to the (i,j,k) axes directions, which are columns of the input matrix Errors: The codes returned will be zero.
        Returns:
        codes
      • getMincSliceThickness

        private double getMincSliceThickness()
        Return the slice thickness value stored in the minc header (var = 'acquisition', attrib = 'slice_thickness').
        Returns:
        The slice thickness, if it is stored in the minc header (0 otherwise).
      • setOrientType

        public static int setOrientType​(java.lang.String space,
                                        boolean positive)
        Helper method to set the axis orientations.
        Parameters:
        space - The space - "xspace", "yspace", or "zspace".
        positive - Flag indicating if the space is moving in a positive direction.
        Returns:
        The proper axis orientation for that space.
      • setStartLocation

        private void setStartLocation​(double originCoord,
                                      int axis)
        Sets the start location of the specified axis.
        Parameters:
        originCoord - origin coord.
        axis - Axis of orientation; x is 0, y is 1, z is 2.