Class FileMincHDF

java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileMincHDF

public class FileMincHDF extends FileBase
HDF5 based reader/writer for MINC 2.0 Currently, for the image max and image min nodes: in the case of 3d images in which 1 image min and 1 image max is to be written out per slice, the dimorder is hardcoded to zspace. Sometimes minc2 3D images come in with just 1 image min and 1 image max per volume...in that case, we write out the same way and do not write out a dimorder ToDo: We need to make this type of functionality work for 4D images. Currently the code writes out 1 image min nd 1 image max per slice and hardcode the dimorder to time,zspace. We need to write out the same way we read in....yet to do.
Author:
linkb
  • Field Details

  • Constructor Details

    • FileMincHDF

      public FileMincHDF(String fName, String fDir) throws IOException
      MINC reader/writer constructor.
      Parameters:
      fName - File name.
      fDir - File directory.
      Throws:
      IOException - if there is an error constructing the files
  • Method Details

    • readHeader

      public boolean readHeader(DefaultMutableTreeNode rootNode) throws Exception
      Throws:
      Exception
    • getFileInfo

      public FileInfoMincHDF getFileInfo()
      Returns the FileInfoXML read from the file.
      Returns:
      File info read from file, or null if it has not been read.
    • parseHDFHeader

      private void parseHDFHeader(DefaultMutableTreeNode node) throws Exception
      recursively parses the HDF tree into the given file info
      Parameters:
      node -
      fileInfo -
      Throws:
      Exception
    • findNode

      private static final DefaultMutableTreeNode findNode(DefaultMutableTreeNode nodeToSearch, String nodeNameToFind)
      Recursively finds the node within a tree with a given name.
      Parameters:
      nodeToSearch - the root node of the tree to search
      nodeNameToFind - the name of the node to find
      Returns:
      a node with the name given, or null if no node was found within the given tree
    • parseImageDimOrder

      private void parseImageDimOrder(DefaultMutableTreeNode rootNode) throws Exception
      parses the dim order
      Parameters:
      rootNode -
      Throws:
      Exception
    • parseDims

      private void parseDims(DefaultMutableTreeNode dimensionNode) throws Exception
      Determines the dimensions, dirCosines, isCentered, step, and alignment
      Parameters:
      dimensionNode -
      fileInfo -
      Throws:
      Exception
    • parseInfo

      private void parseInfo(DefaultMutableTreeNode infoNode) throws Exception
      Parses the info node (right now only grabs the modality)
      Parameters:
      infoNode -
      fileInfo -
      Throws:
      Exception
    • parseImage

      private ModelImage parseImage(DefaultMutableTreeNode iNode) throws Exception
      Parses the image node and reads in the image data (and image min and max per slice)
      Parameters:
      iNode -
      fileInfo -
      Returns:
      Throws:
      Exception
    • readImage

      public ModelImage readImage(boolean one) throws Exception
      Reads a MINC 2.0 HDF-5 file
      Parameters:
      one -
      Returns:
      the image
      Throws:
      Exception
    • buildDimensionNode

      private void buildDimensionNode(ModelImage image, FileWriteOptions options, ncsa.hdf.object.FileFormat format, FileMincHDF.HDFNode mincNode, DefaultTreeModel model) throws Exception
      Creates the dimension node for files that are not Minc2.0
      Parameters:
      image -
      format -
      mincNode -
      model -
      Throws:
      Exception
    • buildInfoNode

      private void buildInfoNode(ModelImage image, ncsa.hdf.object.FileFormat format, FileMincHDF.HDFNode mincNode, DefaultTreeModel model) throws Exception
      builds the Info node for files that were not originally MINC 2.0 HDF5
      Parameters:
      image -
      format -
      mincNode -
      model -
      Throws:
      Exception
    • buildImageNode

      private void buildImageNode(ModelImage image, FileWriteOptions options, ncsa.hdf.object.FileFormat format, FileMincHDF.HDFNode mincNode, DefaultTreeModel model) throws Exception
      Builds the image node (done for all filetypes when writing to MINC2.0 HDF5
      Parameters:
      image - the image node
      format - the HDF5 FileFormat
      mincNode - the minc root node
      model - the tree model linked to the root node
      Throws:
      Exception
    • writeImage

      public void writeImage(ModelImage image, FileWriteOptions options) throws Exception
      Writes a MINC format type image. Calls the appropriate header method.
      Parameters:
      image - Image model where the data is stored.
      options - Information about how to write this file.
      Throws:
      IOException - if there is an error writing the file
      Exception
      See Also:
    • getMipavOrderFromDimNode

      private int getMipavOrderFromDimNode(String dimNodeStr)
      Gets the proper MIPAV dimension ordering index for a given Minc dim node string using the image info.
      Parameters:
      dimNodeStr - A minc dimension node string (i.e., xspace, yspace, zspace, time).
      Returns:
      The proper MIPAV dimension ordering index.
    • getUnitFromString

      public static final FileInfoBase.Unit getUnitFromString(String val)
      Return the proper unit based on a given unit string (abbrevation or full word).
      Parameters:
      val - The unit name or abbreviation.
      Returns:
      The proper unit for the given string, or Unit.UNKNOWN_MEASURE if not recognized.