Class OCR


  • public class OCR
    extends java.lang.Object

    A class for OCR of GE and Siemens modality dose report screen saves.

    • Field Detail

      • defaultFileNameOfKnownGlyphs

        public static java.lang.String defaultFileNameOfKnownGlyphs
    • Constructor Detail

      • OCR

        public OCR​(java.lang.String screenFilesPath)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.lang.String screenFilesPath,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs,
                   int debugLevel)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image files.

        Parameters:
        screenFilesPath - the path to the dose screen image files on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.lang.String screenFilesPath,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image files.

        Parameters:
        screenFilesPath - the path to the dose screen image files on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.util.List<java.lang.String> screenFilesPaths,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs,
                   int debugLevel)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image files.

        Parameters:
        screenFilesPaths - the paths to the dose screen image files on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.util.List<java.lang.String> screenFilesPaths,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image files.

        Parameters:
        screenFilesPaths - the paths to the dose screen image files on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.util.List<java.lang.String> screenFilesPaths,
                   int debugLevel)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image files.

        Parameters:
        screenFilesPaths - the paths to the dose screen image files on which to perform OCR
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.util.List<java.lang.String> screenFilesPaths)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image files.

        Parameters:
        screenFilesPaths - the paths to the dose screen image files on which to perform OCR
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(AttributeList list,
                   int debugLevel)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(AttributeList list)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(AttributeList list,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs,
                   int debugLevel)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(AttributeList list,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.awt.image.BufferedImage image,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs,
                   int debugLevel)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image.

        Parameters:
        image - the dose screen image on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • OCR

        public OCR​(java.awt.image.BufferedImage image,
                   java.lang.String fileNameOfKnownGlyphs,
                   java.lang.String fileNameToRecordNewGlyphs)
            throws java.io.IOException,
                   javax.xml.parsers.ParserConfigurationException,
                   org.xml.sax.SAXException,
                   java.lang.Exception

        Perform OCR on the supplied image.

        Parameters:
        image - the dose screen image on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
    • Method Detail

      • getCommonAttributeList

        public AttributeList getCommonAttributeList()
      • getEightBitImageSuitableForThresholding

        public static java.awt.image.BufferedImage getEightBitImageSuitableForThresholding​(AttributeList list,
                                                                                           int debugLevel)
                                                                                    throws DicomException

        Get an 8 bit image suitable for thresholding.

        Parameters:
        list - the list
        debugLevel - ignored
        Returns:
        the image
        Throws:
        DicomException
      • getEightBitImageSuitableForThresholding

        public static java.awt.image.BufferedImage getEightBitImageSuitableForThresholding​(AttributeList list)
                                                                                    throws DicomException

        Get an 8 bit image suitable for thresholding.

        Parameters:
        list - the list
        Returns:
        the image
        Throws:
        DicomException
      • doCommonConstructorStuff

        protected void doCommonConstructorStuff​(AttributeList list,
                                                java.lang.String fileNameOfKnownGlyphs,
                                                java.lang.String fileNameToRecordNewGlyphs,
                                                int debugLevel)
                                         throws java.io.IOException,
                                                javax.xml.parsers.ParserConfigurationException,
                                                org.xml.sax.SAXException,
                                                java.lang.Exception

        Perform OCR on the supplied image AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • doCommonConstructorStuff

        protected void doCommonConstructorStuff​(AttributeList list,
                                                java.lang.String fileNameOfKnownGlyphs,
                                                java.lang.String fileNameToRecordNewGlyphs)
                                         throws java.io.IOException,
                                                javax.xml.parsers.ParserConfigurationException,
                                                org.xml.sax.SAXException,
                                                java.lang.Exception

        Perform OCR on the supplied image AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • doCommonConstructorStuff

        protected void doCommonConstructorStuff​(AttributeList list,
                                                java.awt.image.BufferedImage image,
                                                java.lang.String fileNameOfKnownGlyphs,
                                                java.lang.String fileNameToRecordNewGlyphs,
                                                int debugLevel)
                                         throws java.io.IOException,
                                                javax.xml.parsers.ParserConfigurationException,
                                                org.xml.sax.SAXException,
                                                java.lang.Exception

        Perform OCR on the supplied image with AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        image - the dose screen image on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        debugLevel - ignored
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • doCommonConstructorStuff

        protected void doCommonConstructorStuff​(AttributeList list,
                                                java.awt.image.BufferedImage image,
                                                java.lang.String fileNameOfKnownGlyphs,
                                                java.lang.String fileNameToRecordNewGlyphs)
                                         throws java.io.IOException,
                                                javax.xml.parsers.ParserConfigurationException,
                                                org.xml.sax.SAXException,
                                                java.lang.Exception

        Perform OCR on the supplied image with AttributeList.

        Parameters:
        list - the AttributeList of the dose screen image file on which to perform OCR
        image - the dose screen image on which to perform OCR
        fileNameOfKnownGlyphs - file of known glyphs
        fileNameToRecordNewGlyphs - where to record new glyphs
        Throws:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isGEDoseScreenSeriesNumber

        protected static boolean isGEDoseScreenSeriesNumber​(java.lang.String seriesNumber)
      • isPossiblyGEDoseScreenSeries

        public static boolean isPossiblyGEDoseScreenSeries​(java.lang.String manufacturer,
                                                           java.lang.String modality,
                                                           java.lang.String seriesNumber,
                                                           java.lang.String seriesDescription)
      • isPossiblyGEDoseScreenSeries

        public static boolean isPossiblyGEDoseScreenSeries​(AttributeList list)
      • isPossiblyGEDoseScreenInstance

        public static boolean isPossiblyGEDoseScreenInstance​(java.lang.String manufacturer,
                                                             java.lang.String sopClassUID,
                                                             java.lang.String imageType)
      • isPossiblyGEDoseScreenInstance

        public static boolean isPossiblyGEDoseScreenInstance​(AttributeList list)
      • isGEDoseScreenInstance

        public static boolean isGEDoseScreenInstance​(AttributeList list)
      • isPossiblySiemensDoseScreenSeries

        public static boolean isPossiblySiemensDoseScreenSeries​(java.lang.String manufacturer,
                                                                java.lang.String modality,
                                                                java.lang.String seriesNumber,
                                                                java.lang.String seriesDescription)
      • isPossiblySiemensDoseScreenSeries

        public static boolean isPossiblySiemensDoseScreenSeries​(AttributeList list)
      • isPossiblySiemensDoseScreenInstance

        public static boolean isPossiblySiemensDoseScreenInstance​(java.lang.String manufacturer,
                                                                  java.lang.String sopClassUID,
                                                                  java.lang.String imageType)
      • isPossiblySiemensDoseScreenInstance

        public static boolean isPossiblySiemensDoseScreenInstance​(AttributeList list)
      • isSiemensDoseScreenInstance

        public static boolean isSiemensDoseScreenInstance​(AttributeList list)
      • isPossiblyToshibaDoseScreenSeries

        public static boolean isPossiblyToshibaDoseScreenSeries​(java.lang.String manufacturer,
                                                                java.lang.String modality,
                                                                java.lang.String seriesNumber,
                                                                java.lang.String seriesDescription)
      • isPossiblyToshibaDoseScreenSeries

        public static boolean isPossiblyToshibaDoseScreenSeries​(AttributeList list)
      • isPossiblyToshibaDoseScreenInstance

        public static boolean isPossiblyToshibaDoseScreenInstance​(java.lang.String manufacturer,
                                                                  java.lang.String sopClassUID,
                                                                  java.lang.String imageType)
      • isPossiblyToshibaDoseScreenInstance

        public static boolean isPossiblyToshibaDoseScreenInstance​(AttributeList list)
      • isToshibaDoseScreenInstance

        public static boolean isToshibaDoseScreenInstance​(AttributeList list)
      • isPossiblyDoseScreenSeries

        public static boolean isPossiblyDoseScreenSeries​(java.lang.String manufacturer,
                                                         java.lang.String modality,
                                                         java.lang.String seriesNumber,
                                                         java.lang.String seriesDescription)
      • isPossiblyDoseScreenSeries

        public static boolean isPossiblyDoseScreenSeries​(AttributeList list)
      • isPossiblyDoseScreenInstance

        public static boolean isPossiblyDoseScreenInstance​(java.lang.String manufacturer,
                                                           java.lang.String sopClassUID,
                                                           java.lang.String imageType)
      • isPossiblyDoseScreenInstance

        public static boolean isPossiblyDoseScreenInstance​(AttributeList list)
      • isDoseScreenInstance

        public static boolean isDoseScreenInstance​(AttributeList list)
      • getCTDoseFromOCROfGEDoseScreen

        public static CTDose getCTDoseFromOCROfGEDoseScreen​(OCR ocr,
                                                            int debugLevel,
                                                            java.lang.String startDateTime,
                                                            java.lang.String endDateTime,
                                                            CTIrradiationEventDataFromImages eventDataFromImages,
                                                            boolean buildSR)
                                                     throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a GE dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        debugLevel - ignored
        startDateTime - the acquisition start date and time
        endDateTime - the acquisition end date and time
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfGEDoseScreen

        public static CTDose getCTDoseFromOCROfGEDoseScreen​(OCR ocr,
                                                            java.lang.String startDateTime,
                                                            java.lang.String endDateTime,
                                                            CTIrradiationEventDataFromImages eventDataFromImages,
                                                            boolean buildSR)
                                                     throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a GE dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        startDateTime - the acquisition start date and time
        endDateTime - the acquisition end date and time
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfSiemensDoseScreen

        public static CTDose getCTDoseFromOCROfSiemensDoseScreen​(OCR ocr,
                                                                 int debugLevel,
                                                                 java.lang.String startDateTime,
                                                                 java.lang.String endDateTime,
                                                                 CTIrradiationEventDataFromImages eventDataFromImages,
                                                                 boolean buildSR)
                                                          throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a Siemens dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        debugLevel - ignored
        startDateTime - the acquisition start date and time
        endDateTime - the acquisition end date and time
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfSiemensDoseScreen

        public static CTDose getCTDoseFromOCROfSiemensDoseScreen​(OCR ocr,
                                                                 java.lang.String startDateTime,
                                                                 java.lang.String endDateTime,
                                                                 CTIrradiationEventDataFromImages eventDataFromImages,
                                                                 boolean buildSR)
                                                          throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a Siemens dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        startDateTime - the acquisition start date and time
        endDateTime - the acquisition end date and time
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfToshibaDoseScreen

        public static CTDose getCTDoseFromOCROfToshibaDoseScreen​(OCR ocr,
                                                                 int debugLevel,
                                                                 java.lang.String startDateTime,
                                                                 java.lang.String endDateTime,
                                                                 CTIrradiationEventDataFromImages eventDataFromImages,
                                                                 boolean buildSR)
                                                          throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a Toshiba dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        debugLevel - ignored
        startDateTime - the acquisition start date and time
        endDateTime - the acquisition end date and time
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfToshibaDoseScreen

        public static CTDose getCTDoseFromOCROfToshibaDoseScreen​(OCR ocr,
                                                                 java.lang.String startDateTime,
                                                                 java.lang.String endDateTime,
                                                                 CTIrradiationEventDataFromImages eventDataFromImages,
                                                                 boolean buildSR)
                                                          throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a Toshiba dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        startDateTime - the acquisition start date and time
        endDateTime - the acquisition end date and time
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfDoseScreen

        public static CTDose getCTDoseFromOCROfDoseScreen​(OCR ocr,
                                                          int debugLevel,
                                                          CTIrradiationEventDataFromImages eventDataFromImages,
                                                          boolean buildSR)
                                                   throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a dose screen image.

        Parameters:
        ocr - the object from the OCR performed in the image
        debugLevel - ignored
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • getCTDoseFromOCROfDoseScreen

        public static CTDose getCTDoseFromOCROfDoseScreen​(OCR ocr,
                                                          CTIrradiationEventDataFromImages eventDataFromImages,
                                                          boolean buildSR)
                                                   throws java.io.IOException

        Create a CTDose instance from the OCR already performed on a dose screen image.

        Also extracts start and end date and time and default anatomical information.

        Parameters:
        ocr - the object from the OCR performed in the image
        eventDataFromImages - the pre event data from the reconstructed images
        buildSR - whether or not to extract composite context from the list for use later to build an RDSR
        Throws:
        java.io.IOException
      • main

        public static final void main​(java.lang.String[] arg)

        Extract the CT dose information in a screen save image using optical character recognition, correlate it with any acquired CT slice images.

        Parameters:
        arg - an array of 1 to 6 strings - the path to a dose screen save image or folder of screens (or "-" if to search for dose screens amongst acquired images), then optionally the path to a DICOMDIR or folder containing acquired CT slice images (or "-" if none and more arguments) then optionally the name of Dose SR file to write (or "-" if none and more arguments) then optionally the file containing the text glyphs to use during recognition rather than the default (or "-" if none and more arguments), then optionally the name of a file to write any newly trained glyphs to