Class MatrixHolder

java.lang.Object
gov.nih.mipav.model.structures.ModelSerialCloneable
gov.nih.mipav.model.structures.MatrixHolder
All Implemented Interfaces:
Serializable, Cloneable

public class MatrixHolder extends ModelSerialCloneable
Class that stores matrices (owned by ModelImage) with accessor functions to the matrix map/adding and changing matrices.
Author:
linkb
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • compositeMatrix

      private TransMatrix compositeMatrix
      The composite matrix formed by multiplying (in reverse order) all stored matrices.
    • matrixMap

      private LinkedHashMap<String,TransMatrix> matrixMap
      Linked hash map that will store all of the images associated matrices.
  • Constructor Details

    • MatrixHolder

      public MatrixHolder(int nDims)
      Default constructor.
      Parameters:
      nDims - dimensions of image
  • Method Details

    • addMatrix

      public void addMatrix(TransMatrix mat)
      Adds a matrix to the map. matrices will be keyed by their type and sequential numbering
      Parameters:
      mat - DOCUMENT ME!
    • getNIFTICompositeMatrices

      public TransMatrix[] getNIFTICompositeMatrices()
      Returns up to two composite TransMatrices that are NIFTI specific
      Returns:
      0,1, or 2 TransMatrices (related to NIFTI)
    • clearMatrices

      public void clearMatrices()
      Removes all matrices from the map.
    • clone

      public Object clone()
      Copies the object.
      Overrides:
      clone in class ModelSerialCloneable
      Returns:
      Object A copy of the file info.
    • containsType

      public boolean containsType(int type)
      Determines if the map contains a matrix of the given type (checks for String.contains()).
      Parameters:
      type - transformID to check
      Returns:
      whether the map contains this type of transform
    • getCompositeMatrix

      public TransMatrix getCompositeMatrix(boolean useDICOM)
      Gets the composite (dynamically built) matrix made by multiplying in forward order the image's matrices.
      Parameters:
      useDICOM - whether to include the scanner anatomical matrix (if available)
      Returns:
      the composite TransMatrix
    • getMatrix

      public TransMatrix getMatrix(Object key)
      Accessor that gets a matrix based on the key (for the linkedhashmap)
      Parameters:
      key - key to the matrix
      Returns:
      the matrix associated with the key, null otherwise
    • getMatrices

      public Vector<TransMatrix> getMatrices()
      Gets a cloned copy of the image's matrices stored in a vector.
      Returns:
      Vector of image's matrices
    • getMatrixMap

      public LinkedHashMap<String,TransMatrix> getMatrixMap()
      Gets the matrix map.
      Returns:
      the matrix map
    • removeMatrix

      public void removeMatrix(Object key)
      Safe method for removing matrices from the image
      Parameters:
      key - DOCUMENT ME!
    • replaceMatrices

      public void replaceMatrices(Vector<TransMatrix> matrixVector)
      Helper function for XML type images which may have several associated matrices.
      Parameters:
      matrixVector - Vector of matrices to replace the current matrices in the map
    • replaceMatrix

      public void replaceMatrix(String key, TransMatrix newMatrix)
      Replaces the matrix at the given key (or inserts if that key is not present, which should not happen).
      Parameters:
      key - the key for the matrix
      newMatrix - the new matrix
    • toString

      public String toString()
      Overrides:
      toString in class Object