Changed core seg lightbox to be on the ADC image. Tweaks to report based on Marie...
authormccreedy@NIH.GOV <mccreedy@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Fri, 23 Mar 2018 16:19:50 +0000 (16:19 +0000)
committermccreedy@NIH.GOV <mccreedy@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Fri, 23 Mar 2018 16:19:50 +0000 (16:19 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15430 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/plugins/PlugInAlgorithmStrokeSegmentation.java
mipav/src/plugins/PlugInDialogStrokeSegmentation.java
mipav/src/plugins/PlugInDialogStrokeSegmentationListener.java
mipav/src/plugins/StrokeSegmentationDicomReceiver.java

index c3ef480..f73fb82 100644 (file)
@@ -50,8 +50,8 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
     \r
     private float lightboxOpacity = 0.5f;\r
     \r
-    private File adcLightboxFile;\r
-    private File dwiLightboxFile;\r
+    private File threshLightboxFile;\r
+    private File coreLightboxFile;\r
     \r
     /**\r
      * Constructor.\r
@@ -192,7 +192,7 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
         // combine threshold with ADC and save lightbox\r
         ModelImage adcLightbox = generateLightbox(adcImage, dwiSeg, lightboxOpacity);\r
 \r
-        adcLightboxFile = saveImageFile(adcLightbox, coreOutputDir, outputBasename + "_ADC_thresh_lightbox", FileUtility.PNG);\r
+        threshLightboxFile = saveImageFile(adcLightbox, coreOutputDir, outputBasename + "_ADC_thresh_lightbox", FileUtility.PNG);\r
         \r
         adcLightbox.disposeLocal();\r
         \r
@@ -271,12 +271,12 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
         \r
         saveImageFile(dwiSeg, coreOutputDir, outputBasename + "_ADC_thresh_only_largest", FileUtility.XML);\r
         \r
-        // combine core mask with DWI and save lightbox\r
-        ModelImage dwiLightbox = generateLightbox(dwiImage, dwiSeg, lightboxOpacity);\r
+        // combine core mask with ADC and save lightbox\r
+        ModelImage coreLightbox = generateLightbox(adcImage, dwiSeg, lightboxOpacity);\r
         \r
-        dwiLightboxFile = saveImageFile(dwiLightbox, coreOutputDir, outputBasename + "_DWI_core_lightbox", FileUtility.PNG);\r
+        coreLightboxFile = saveImageFile(coreLightbox, coreOutputDir, outputBasename + "_ADC_core_lightbox", FileUtility.PNG);\r
         \r
-        dwiLightbox.disposeLocal();\r
+        coreLightbox.disposeLocal();\r
         \r
         // commented out because masks seem just as useful to users\r
         \r
@@ -697,12 +697,12 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
         return lightbox;\r
     }\r
     \r
-    public File getAdcTheshLightboxFile() {\r
-        return adcLightboxFile;\r
+    public File getTheshLightboxFile() {\r
+        return threshLightboxFile;\r
     }\r
     \r
-    public File getDwiTheshLightboxFile() {\r
-        return dwiLightboxFile;\r
+    public File getCoreLightboxFile() {\r
+        return coreLightboxFile;\r
     }\r
     \r
     public MaskObject getLargestObject() {\r
index 0b94028..00cfacc 100644 (file)
@@ -224,7 +224,7 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
             double coreVolCC = segAlgo.getLargestObject().size * resolCC[0] * resolCC[1] * resolCC[2];\r
             \r
             if (listenerParent != null) {\r
-                listenerParent.emailReport(adcImage, segAlgo.getAdcTheshLightboxFile(), segAlgo.getDwiTheshLightboxFile(), coreVolCC);\r
+                listenerParent.emailReport(adcImage, segAlgo.getTheshLightboxFile(), segAlgo.getCoreLightboxFile(), coreVolCC);\r
             }\r
 \r
             if (segAlgo.isCompleted()) {\r
index 25c9d21..383bea6 100644 (file)
@@ -317,28 +317,40 @@ public class PlugInDialogStrokeSegmentationListener extends JFrame implements Ac
     }\r
     \r
     private boolean readListenerConfig() {\r
-        final InputStream in = getClass().getResourceAsStream(configFileName);\r
-        if (in != null) {\r
-            final Properties prop = new Properties();\r
-            try {\r
-                prop.load(in);\r
-            } catch (final IOException e) {\r
-                Preferences.debug("Unable to load stroke segementation listener plugin preferences file: " + configFileName + "\n", Preferences.DEBUG_MINOR);\r
-                e.printStackTrace();\r
+        try {\r
+            final InputStream in = getClass().getResourceAsStream(configFileName);\r
+            if (in != null) {\r
+                final Properties prop = new Properties();\r
+                try {\r
+                    prop.load(in);\r
+                } catch (final IOException e) {\r
+                    Preferences.debug("Unable to load stroke segementation listener plugin preferences file: " + configFileName + "\n", Preferences.DEBUG_MINOR);\r
+                    e.printStackTrace();\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                ae = prop.getProperty("listenerAETitle", ae);\r
+                \r
+                port = Integer.parseInt(prop.getProperty("listenerPort", "" + port));\r
+                \r
+                outputDir = prop.getProperty("listenerOutputDir", outputDir);\r
+                \r
+                doEmailReport = Boolean.parseBoolean(prop.getProperty("listenerDoEmail", "" + doEmailReport));\r
+                \r
+                if (in != null) {\r
+                    in.close();\r
+                }\r
+                return true;\r
+            } else {\r
+                // couldn't load file\r
                 return false;\r
             }\r
-            \r
-            ae = prop.getProperty("listenerAETitle", ae);\r
-            \r
-            port = Integer.parseInt(prop.getProperty("listenerPort", "" + port));\r
-            \r
-            outputDir = prop.getProperty("listenerOutputDir", outputDir);\r
-            \r
-            doEmailReport = Boolean.parseBoolean(prop.getProperty("listenerDoEmail", "" + doEmailReport));\r
-            \r
-            return true;\r
-        } else {\r
-            // couldn't load file\r
+        } catch (IOException e) {\r
+            e.printStackTrace();\r
+            log("Error loading listener properties file: " + configFileName);\r
             return false;\r
         }\r
     }\r
index b730b6b..fea8963 100644 (file)
@@ -142,8 +142,8 @@ public class StrokeSegmentationDicomReceiver {
     \r
     private boolean doEmailReport;\r
     \r
-    private static final String reportDwiCid = "cid:dwi-image";\r
-    private static final String reportAdcCid = "cid:adc-image";\r
+    private static final String reportCoreCid = "cid:core-image";\r
+    private static final String reportThreshCid = "cid:thresh-image";\r
     \r
     private WidgetFactory.ScrollTextArea logOutputArea;\r
     \r
@@ -381,20 +381,20 @@ public class StrokeSegmentationDicomReceiver {
         logOutputArea.getTextArea().append(line + "\n");\r
     }\r
     \r
-    public void emailReport(ModelImage adcImage, File adcLightboxFile, File dwiLightboxFile, double coreVolCC) {\r
-        String reportTxt = generateReport(adcImage, adcLightboxFile, dwiLightboxFile, coreVolCC);\r
+    public void emailReport(ModelImage adcImage, File threshLightboxFile, File coreLightboxFile, double coreVolCC) {\r
+        String reportTxt = generateReport(adcImage, threshLightboxFile, coreLightboxFile, coreVolCC);\r
         \r
         if (reportTxt == null) {\r
                return;\r
         }\r
         \r
-        String outputDir = adcLightboxFile.getParent();\r
+        String outputDir = threshLightboxFile.getParent();\r
         final String htmlReportPath = outputDir + File.separator + "core_seg_report.html";\r
         \r
         PrintWriter out;\r
         try {\r
-            String fileTxt = reportTxt.replaceAll(reportDwiCid, dwiLightboxFile.getName());\r
-            fileTxt = fileTxt.replaceAll(reportAdcCid, adcLightboxFile.getName());\r
+            String fileTxt = reportTxt.replaceAll(reportCoreCid, coreLightboxFile.getName());\r
+            fileTxt = fileTxt.replaceAll(reportThreshCid, threshLightboxFile.getName());\r
             \r
             out = new PrintWriter(htmlReportPath);\r
             out.println("<html>");\r
@@ -429,15 +429,15 @@ public class StrokeSegmentationDicomReceiver {
                        multipartContent.addBodyPart(messageBody);\r
                        \r
                        messageBody = new MimeBodyPart();\r
-                       DataSource imgDS = new FileDataSource(adcLightboxFile);\r
+                       DataSource imgDS = new FileDataSource(threshLightboxFile);\r
                        messageBody.setDataHandler(new DataHandler(imgDS));\r
-                       messageBody.setHeader("Content-ID", "<adc-image>");\r
+                       messageBody.setHeader("Content-ID", "<core-image>");\r
                        multipartContent.addBodyPart(messageBody);\r
                        \r
                        messageBody = new MimeBodyPart();\r
-                       imgDS = new FileDataSource(dwiLightboxFile);\r
+                       imgDS = new FileDataSource(coreLightboxFile);\r
                        messageBody.setDataHandler(new DataHandler(imgDS));\r
-                       messageBody.setHeader("Content-ID", "<dwi-image>");\r
+                       messageBody.setHeader("Content-ID", "<thresh-image>");\r
                        multipartContent.addBodyPart(messageBody);\r
                        \r
                        Message message = new MimeMessage(session);\r
@@ -463,8 +463,8 @@ public class StrokeSegmentationDicomReceiver {
         }\r
     }\r
     \r
-    private String generateReport(ModelImage adcImage, File adcLightboxFile, File dwiLightboxFile, double coreVolCC) {\r
-        final DecimalFormat format = new DecimalFormat("#######.####");\r
+    private String generateReport(ModelImage adcImage, File threshLightboxFile, File coreLightboxFile, double coreVolCC) {\r
+        final DecimalFormat format = new DecimalFormat("#######.#");\r
         \r
         FileInfoDicom fileInfoDicom = (FileInfoDicom) adcImage.getFileInfo(0);\r
         \r
@@ -482,15 +482,15 @@ public class StrokeSegmentationDicomReceiver {
         reportTxt += "<li>" + "<b>" + "Time of segmentation run: " + "</b>" + curDateTimeStr + "</li>\n";\r
         reportTxt += "<li>" + "<b>" + "Study date and time: " + "</b>" + convertDateTimeToISOFormat(studyDateStr, studyTimeStr) + "</li>\n";\r
         reportTxt += "<li>" + "<b>" + "Patient last name initial: " + "</b>" + getInitialFromName(patientName) + "</li>\n";\r
-        reportTxt += "<li>" + "<b>" + "Core segmentation volume (CC): " + "</b>" + coreSegVol + "</li>\n";\r
+        reportTxt += "<li>" + "<b>" + "Core segmentation volume (mL): " + "</b>" + coreSegVol + "</li>\n";\r
         //reportTxt += "<li>" + "<b>" + "" + "</b>" + "" + "</li>";\r
         reportTxt += "</ul>\n";\r
-        reportTxt += "<h3>" + "DWI volume with core segmentation" + "</h3>\n";\r
-        //reportTxt += "<a href='" + dwiPdfImage + "'><img src='" + dwiPdfImage + "' alt='DWI volume with core segmentation' width='" + imgDisplay + "'/></a>\n";\r
-        reportTxt += "<img src='" + reportDwiCid + "' alt='DWI volume with core segmentation'/>\n";\r
-        reportTxt += "<h3>" + "ADC volume with thresholded regions" + "</h3>\n";\r
+        reportTxt += "<h3>" + "ADC image with core segmentation" + "</h3>\n";\r
+        //reportTxt += "<a href='" + dwiPdfImage + "'><img src='" + dwiPdfImage + "' alt='ADC volume with core segmentation' width='" + imgDisplay + "'/></a>\n";\r
+        reportTxt += "<img src='" + reportCoreCid + "' alt='ADC image with core segmentation'/>\n";\r
+        reportTxt += "<h3>" + "ADC image with thresholded regions prior to core volume calculation" + "</h3>\n";\r
         //reportTxt += "<a href='" + adcPdfImage + "'><img src='" + adcPdfImage + "' alt='ADC volume with thresholded regions' width='" + imgDisplay + "'/></a>\n";\r
-        reportTxt += "<img src='" + reportAdcCid + "' alt='ADC volume with thresholded regions'/>\n";\r
+        reportTxt += "<img src='" + reportThreshCid + "' alt='ADC image with thresholded regions prior to core volume calculation'/>\n";\r
         //reportTxt += "</html>\n";\r
         \r
         return reportTxt;\r
@@ -569,50 +569,80 @@ public class StrokeSegmentationDicomReceiver {
     }\r
     \r
     private boolean readEmailConfig() {\r
-        final InputStream in = getClass().getResourceAsStream(configFileName);\r
-        if (in != null) {\r
-            final Properties prop = new Properties();\r
-            try {\r
-                prop.load(in);\r
-            } catch (final IOException e) {\r
-                Preferences.debug("Unable to load stroke segementation listener plugin preferences file: " + configFileName + "\n", Preferences.DEBUG_MINOR);\r
-                e.printStackTrace();\r
-                return false;\r
-            }\r
-            \r
-            emailFrom = prop.getProperty("emailFrom");\r
-            if (emailFrom == null || emailFrom.equals("")) {\r
-                return false;\r
-            }\r
-            \r
-            emailTo = prop.getProperty("emailTo");\r
-            if (emailTo == null || emailTo.equals("")) {\r
-                return false;\r
-            }\r
-            \r
-            emailUsername = prop.getProperty("emailUsername");\r
-            if (emailUsername == null || emailUsername.equals("")) {\r
-                return false;\r
-            }\r
-            \r
-            emailPassword = prop.getProperty("emailPassword");\r
-            if (emailPassword == null || emailPassword.equals("")) {\r
-                return false;\r
-            }\r
-            \r
-            emailHost = prop.getProperty("emailHost");\r
-            if (emailHost == null || emailHost.equals("")) {\r
-                return false;\r
-            }\r
-            \r
-            emailPort = prop.getProperty("emailPort");\r
-            if (emailPort == null || emailPort.equals("")) {\r
+        try {\r
+            final InputStream in = getClass().getResourceAsStream(configFileName);\r
+            if (in != null) {\r
+                final Properties prop = new Properties();\r
+                try {\r
+                    prop.load(in);\r
+                } catch (final IOException e) {\r
+                    Preferences.debug("Unable to load stroke segementation listener plugin preferences file: " + configFileName + "\n", Preferences.DEBUG_MINOR);\r
+                    e.printStackTrace();\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                emailFrom = prop.getProperty("emailFrom");\r
+                if (emailFrom == null || emailFrom.equals("")) {\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                emailTo = prop.getProperty("emailTo");\r
+                if (emailTo == null || emailTo.equals("")) {\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                emailUsername = prop.getProperty("emailUsername");\r
+                if (emailUsername == null || emailUsername.equals("")) {\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                emailPassword = prop.getProperty("emailPassword");\r
+                if (emailPassword == null || emailPassword.equals("")) {\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                emailHost = prop.getProperty("emailHost");\r
+                if (emailHost == null || emailHost.equals("")) {\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                emailPort = prop.getProperty("emailPort");\r
+                if (emailPort == null || emailPort.equals("")) {\r
+                    if (in != null) {\r
+                        in.close();\r
+                    }\r
+                    return false;\r
+                }\r
+                \r
+                if (in != null) {\r
+                    in.close();\r
+                }\r
+                return true;\r
+            } else {\r
+                // couldn't load file\r
                 return false;\r
             }\r
-            \r
-            return true;\r
-        } else {\r
-            // couldn't load file\r
+        } catch (IOException e) {\r
+            e.printStackTrace();\r
+            log("Error loading listener properties file: " + configFileName);\r
             return false;\r
         }\r
     }\r