Class FileVOI


public class FileVOI extends FileXML
VOI reader/writer. This classes incorporates the ability to write/read VOIs in three formats (MIPAV *.voi, Nuages, and MIPAV *.xml . The first is a simple text format in which the points of the VOIs are stored in text format. The VOIs can be also stored in a second format, also a text format, termed a Nauges. Nauges is a program that forms triangles (i.e., tesselates) from contours. Therefore, if one wishes to render a surface of a VOI, first save the VOI in Nauges format and supply the VOI file to the Nauges executable. MIPAV's lastest file format is based on XML and should be used in the future.

Note: A single VOI per file. However, a VOI can be formed from multiple contours.

Version:
0.1 Feb 24, 1998
Author:
Matthew J. McAuliffe, Ph.D.
See Also:
  • Field Details

    • W3C_XML_SCHEMA

      private static final String W3C_XML_SCHEMA
      The W3C XML schema.
      See Also:
    • XML_ENCODING

      private static final String XML_ENCODING
      The charset the XML file is written in.
      See Also:
    • XML_HEADER

      private static final String XML_HEADER
      The XML version description header.
      See Also:
    • VOI_HEADER

      private static final String VOI_HEADER
      The MIPAV XML header comment.
      See Also:
    • TEXT_HEADER

      private static final String TEXT_HEADER
      See Also:
    • file

      protected File file
      File reference, it and its components are able to be modified by extending classes.
    • fileDir

      protected String fileDir
      File directory where the VOI is to read or written.
    • fileName

      protected String fileName
      File name of the VOI.
    • image

      private final ModelImage image
      Image used to reference properties of the image to aid reading and writing of the VOI.
    • isXML

      private boolean isXML
      Flag indicating whether the VOI should be written in MIPAV's XML format.
    • numVOIs

      private final short numVOIs
      The number of VOIs in the image.
    • sliceNum

      private int sliceNum
      File directory where the VOI is to read or written.
    • trimmedFileName

      private String trimmedFileName
      File name without the extension.
    • extension

      private String extension
  • Constructor Details

    • FileVOI

      public FileVOI(String fileName, String fileDir, ModelImage image) throws IOException
      VOI reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      image - image model: needed during the read process to ensure the VOI "fits" in the image space.
      Throws:
      IOException - if there is an error making the files
  • Method Details

    • readVOI

      public VOI[] readVOI(boolean doLabel) throws IOException
      This method read a VOI file that has been saved in the MIPAV VOI format (MIPAV *.voi, Nuages, and MIPAV *.xml).
      Parameters:
      doLabel - boolean telling to read the files as VOITexts (labels)
      Returns:
      the VOI read off the disk
      Throws:
      IOException - if there is an error reading the file
    • readOtherOrientationVOI

      public VOI[] readOtherOrientationVOI() throws IOException
      This method read a VOI file that has been saved in the MIPAV VOI format (MIPAV *.voi, Nuages, and MIPAV *.xml).
      Returns:
      the VOI read off the disk
      Throws:
      IOException - if there is an error reading the file
    • writeAnnotationXML

      public void writeAnnotationXML(boolean writeAll) throws IOException
      Writes VOIText(s) to a .lbl file (XML based)
      Parameters:
      writeAll - whether or not to write all VOITexts into the same file, or only the selected VOIText
      Throws:
      IOException - exception thrown if there is an error writing the file
    • writeAnnotationInVoiAsXML

      public void writeAnnotationInVoiAsXML(String voiName, boolean writeAllContours) throws IOException
      Writes VOIText(s) to a .lbl file (XML based)
      Parameters:
      String - voiName Name of VOIText to write out
      boolean - writeAllContours Whether to write all contours or only selected contours
      Throws:
      IOException - exception thrown if there is an error writing the file
    • writeNaugeVOI

      public void writeNaugeVOI(VOI voi) throws IOException
      Writes a single VOI to a file in Nauge format.
      Parameters:
      voi - VOI to write
      Throws:
      IOException - if there is an error writing the file
    • writePointVOI

      public void writePointVOI(VOI voi) throws IOException
      Writes a single VOI.POINT to a file MIPAV format.
      Parameters:
      voi - VOI.POINT to write
      Throws:
      IOException - if there is an error writing the file
    • writeVOI

      public void writeVOI(VOI voi, boolean saveAllContours) throws IOException
      Writes a single VOI to a file MIPAV format.
      Parameters:
      voi - VOI to write
      saveAllContours - if true save all contours, not just the active ones
      Throws:
      IOException - if there is an error writing the file
    • writeXML

      public void writeXML(VOI voi, boolean saveAllContours) throws IOException
      Throws:
      IOException
    • writeXML

      public void writeXML(VOI voi, boolean saveAllContours, boolean overwriteFile) throws IOException
      Writes VOI to an XML formatted file.
      Parameters:
      voi - VOI to be saved
      saveAllContours - if true save all contours, not just the active ones
      Throws:
      IOException - exception thrown if there is an error writing the file
    • decodeLine

      private void decodeLine(String str, WildMagic.LibFoundation.Mathematics.Vector2f pt)
      Converts string point (x,y) to Vector2f point.
      Parameters:
      str - string to convert
      pt - point to return
    • readAnnotationXML

      private boolean readAnnotationXML(VOIVector voiVector)
      Reads in an annotation xml (.lbl) file and puts all VOITexts into a VOIVector (to be added to the image)
      Parameters:
      voiVector - a VOIVector for holding the VOIs before they are transferred to the image
      Returns:
      boolean
    • readContourVOI

      private VOI readContourVOI() throws IOException
      This method read a VOI file that has been saved in the MIPAV VOI format.
      Returns:
      the new VOI read from the file
      Throws:
      IOException - if there is an error reading the file
    • readCoordXML

      private boolean readCoordXML(VOI voi, boolean isLPS)
      Reads in a VOI from a file using the new VOI schema based on Scanner coordinates rather than pixel space
      Parameters:
      voi - VOI to be read in
      Returns:
      boolean whether or not the VOI read in successfully
    • readLine

      private String readLine() throws IOException
      Reads a line of the file and strips comments indicated by the # symbol.
      Returns:
      the line read in
      Throws:
      IOException - if there is an error reading the file
    • readNaugeVOI

      private VOI readNaugeVOI(String firstStr) throws IOException
      This method read a VOI file that has been saved in the Nauge VOI format.
      Parameters:
      firstStr - first line of the Nauge VOI file
      Returns:
      the VOI
      Throws:
      IOException - if there is an error reading the file
    • readPointVOI

      private VOI readPointVOI() throws IOException
      This method read a VOI.POINT file that has been saved in the MIPAV PTS format.
      Returns:
      the new VOI read from the file
      Throws:
      IOException - if there is an error reading the file
    • readXML

      private boolean readXML(VOI voi)
      Reads in the older VOI XML schema (using pixel coordinates)
      Parameters:
      voi - VOI
      Returns:
      boolean