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:
    VOI
    • Field Detail

      • W3C_XML_SCHEMA

        private static final java.lang.String W3C_XML_SCHEMA
        The W3C XML schema.
        See Also:
        Constant Field Values
      • XML_ENCODING

        private static final java.lang.String XML_ENCODING
        The charset the XML file is written in.
        See Also:
        Constant Field Values
      • XML_HEADER

        private static final java.lang.String XML_HEADER
        The XML version description header.
        See Also:
        Constant Field Values
      • VOI_HEADER

        private static final java.lang.String VOI_HEADER
        The MIPAV XML header comment.
        See Also:
        Constant Field Values
      • file

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

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

        protected java.lang.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 java.lang.String trimmedFileName
        File name without the extension.
      • extension

        private java.lang.String extension
    • Constructor Detail

      • FileVOI

        public FileVOI​(java.lang.String fileName,
                       java.lang.String fileDir,
                       ModelImage image)
                throws java.io.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:
        java.io.IOException - if there is an error making the files
    • Method Detail

      • readVOI

        public VOI[] readVOI​(boolean doLabel)
                      throws java.io.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:
        java.io.IOException - if there is an error reading the file
      • readOtherOrientationVOI

        public VOI[] readOtherOrientationVOI()
                                      throws java.io.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:
        java.io.IOException - if there is an error reading the file
      • writeAnnotationXML

        public void writeAnnotationXML​(boolean writeAll)
                                throws java.io.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:
        java.io.IOException - exception thrown if there is an error writing the file
      • writeAnnotationInVoiAsXML

        public void writeAnnotationInVoiAsXML​(java.lang.String voiName,
                                              boolean writeAllContours)
                                       throws java.io.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:
        java.io.IOException - exception thrown if there is an error writing the file
      • writeNaugeVOI

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

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

        public void writeVOI​(VOI voi,
                             boolean saveAllContours)
                      throws java.io.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:
        java.io.IOException - if there is an error writing the file
      • writeXML

        public void writeXML​(VOI voi,
                             boolean saveAllContours)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeXML

        public void writeXML​(VOI voi,
                             boolean saveAllContours,
                             boolean overwriteFile)
                      throws java.io.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:
        java.io.IOException - exception thrown if there is an error writing the file
      • decodeLine

        private void decodeLine​(java.lang.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 java.io.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:
        java.io.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 java.lang.String readLine()
                                   throws java.io.IOException
        Reads a line of the file and strips comments indicated by the # symbol.
        Returns:
        the line read in
        Throws:
        java.io.IOException - if there is an error reading the file
      • readNaugeVOI

        private VOI readNaugeVOI​(java.lang.String firstStr)
                          throws java.io.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:
        java.io.IOException - if there is an error reading the file
      • readPointVOI

        private VOI readPointVOI()
                          throws java.io.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:
        java.io.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