Package gov.nih.mipav.model.file
Class FileVOI
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileXML
-
- gov.nih.mipav.model.file.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
FileVOI.MyXMLHandler
Handle events generated while parsing the XML file.private class
FileVOI.VOIComparator
DOCUMENT ME!private class
FileVOI.VOISortItem
DOCUMENT ME!private class
FileVOI.XMLAnnotationHandler
Handle events generated while parsing the Annotation XML file.private class
FileVOI.XMLCoordHandler
Handle events generated while parsing the XML file.-
Nested classes/interfaces inherited from class gov.nih.mipav.model.file.FileXML
FileXML.XMLAttributes
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
extension
protected java.io.File
file
File reference, it and its components are able to be modified by extending classes.protected java.lang.String
fileDir
File directory where the VOI is to read or written.protected java.lang.String
fileName
File name of the VOI.private ModelImage
image
Image used to reference properties of the image to aid reading and writing of the VOI.private boolean
isXML
Flag indicating whether the VOI should be written in MIPAV's XML format.private short
numVOIs
The number of VOIs in the image.private int
sliceNum
File directory where the VOI is to read or written.private static java.lang.String
TEXT_HEADER
private java.lang.String
trimmedFileName
File name without the extension.private static java.lang.String
VOI_HEADER
The MIPAV XML header comment.private static java.lang.String
W3C_XML_SCHEMA
The W3C XML schema.private static java.lang.String
XML_ENCODING
The charset the XML file is written in.private static java.lang.String
XML_HEADER
The XML version description header.-
Fields inherited from class gov.nih.mipav.model.file.FileXML
bw, fileInfo, m_kHandler, MIPAV_HEADER, pInterface, TAB, tabLevel
-
Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE
-
-
Constructor Summary
Constructors Constructor Description FileVOI(java.lang.String fileName, java.lang.String fileDir, ModelImage image)
VOI reader/writer constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
decodeLine(java.lang.String str, WildMagic.LibFoundation.Mathematics.Vector2f pt)
Converts string point (x,y) to Vector2f point.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)private VOI
readContourVOI()
This method read a VOI file that has been saved in the MIPAV VOI format.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 spaceprivate java.lang.String
readLine()
Reads a line of the file and strips comments indicated by the # symbol.private VOI
readNaugeVOI(java.lang.String firstStr)
This method read a VOI file that has been saved in the Nauge VOI format.VOI[]
readOtherOrientationVOI()
This method read a VOI file that has been saved in the MIPAV VOI format (MIPAV *.voi, Nuages, and MIPAV *.xml).private VOI
readPointVOI()
This method read a VOI.POINT file that has been saved in the MIPAV PTS format.VOI[]
readVOI(boolean doLabel)
This method read a VOI file that has been saved in the MIPAV VOI format (MIPAV *.voi, Nuages, and MIPAV *.xml).private boolean
readXML(VOI voi)
Reads in the older VOI XML schema (using pixel coordinates)void
writeAnnotationInVoiAsXML(java.lang.String voiName, boolean writeAllContours)
Writes VOIText(s) to a .lbl file (XML based)void
writeAnnotationXML(boolean writeAll)
Writes VOIText(s) to a .lbl file (XML based)void
writeNaugeVOI(VOI voi)
Writes a single VOI to a file in Nauge format.void
writePointVOI(VOI voi)
Writes a single VOI.POINT to a file MIPAV format.void
writeVOI(VOI voi, boolean saveAllContours)
Writes a single VOI to a file MIPAV format.void
writeXML(VOI voi, boolean saveAllContours)
void
writeXML(VOI voi, boolean saveAllContours, boolean overwriteFile)
Writes VOI to an XML formatted file.-
Methods inherited from class gov.nih.mipav.model.file.FileXML
closedTag, closedTag, closedTag, finalize, openTag, readHeader, setPBar
-
Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, floatToBytes, getBufferDouble, getBufferFloat, getBufferInt, getBufferLong, getBufferShort, getBufferUShort, getDataType, getDouble, getFloat, getInt, getLong, getProgressChangeListeners, getRaFile, getSignedShort, getString, getUInt, getUnsignedByte, getUnsignedShort, intToBytes, isBigEndian, isProgressBarVisible, linkProgress, longToBytes, readDouble, readFloat, readInt, readLong, readShort, readString, readUnsignedShort, removeProgressChangeListener, setBigEndian, setBufferFloat, setBufferInt, setBufferLong, setBufferShort, setBufferString, setDataType, setEndianess, shortToBytes, writeBytes, writeDouble, writeFloat, writeInt, writeLong, writeShort
-
-
-
-
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
-
TEXT_HEADER
private static final java.lang.String TEXT_HEADER
- 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 namefileDir
- file directoryimage
- 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 outboolean
- 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 writesaveAllContours
- 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 savedsaveAllContours
- 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 convertpt
- 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
-
-