Added TRACEW imageType to DWI sorting. Added step to remove the first N slices ...
authormccreedy@NIH.GOV <mccreedy@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Fri, 9 Mar 2018 20:55:13 +0000 (20:55 +0000)
committermccreedy@NIH.GOV <mccreedy@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Fri, 9 Mar 2018 20:55:13 +0000 (20:55 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15410 ba61647d-9d00-f842-95cd-605cb4296b96

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

index 2b7d901..b18ac92 100644 (file)
@@ -27,6 +27,10 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
     \r
     private int maxSymmetryRemovalSlice = 10;\r
     \r
+    private boolean doCerebellumSkip;\r
+    \r
+    private int cerebellumSkipSliceMax;\r
+    \r
     private VOI coreVOI;\r
     \r
     private MaskObject largestObject;\r
@@ -50,13 +54,15 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
      * @param  dwi  DWI image\r
      * @param  adc  ADC image\r
      */\r
-    public PlugInAlgorithmStrokeSegmentation(ModelImage dwi, ModelImage adc, int threshold, boolean symmetryRemoval, String outputDir) {\r
+    public PlugInAlgorithmStrokeSegmentation(ModelImage dwi, ModelImage adc, int threshold, boolean symmetryRemoval, boolean cerebellumSkip, int cerebellumSkipMax, String outputDir) {\r
         super();\r
         \r
         dwiImage = dwi;\r
         adcImage = adc;\r
         adcThreshold = threshold;\r
         doSymmetryRemoval = symmetryRemoval;\r
+        doCerebellumSkip = cerebellumSkip;\r
+        cerebellumSkipSliceMax = cerebellumSkipMax;\r
         coreOutputDir = outputDir;\r
         \r
         outputBasename = new File(coreOutputDir).getName() + "_" + outputLabel;\r
@@ -182,8 +188,32 @@ public class PlugInAlgorithmStrokeSegmentation extends AlgorithmBase {
         fireProgressStateChanged("Finding core lesion ...");\r
         fireProgressStateChanged(70);\r
         \r
+        short[] removedBuffer = null;\r
+        if (doCerebellumSkip) {\r
+            if (removedBuffer == null) {\r
+                removedBuffer = new short[volLength];\r
+            }\r
+            \r
+            // if values are mirrored across the the l->r of the image, cancel them out.  core values should only be on one side, while the cerebelum will have values on both sides\r
+            for (int iZ = 0; iZ < cerebellumSkipSliceMax && iZ < extents[2]; iZ++) {\r
+                for (int iY = 0; iY < extents[1]; iY++) {\r
+                    for (int iX = 0; iX < extents[0]; iX++) {\r
+                        int index = (iZ * sliceLength) + (iY * extents[0]) + iX;\r
+                        \r
+                        if (dwiSegBuffer[index] > 0) {\r
+                            dwiSegBuffer[index] = 0;\r
+                            \r
+                            removedBuffer[index] = 1;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        \r
         if (doSymmetryRemoval) {\r
-            short[] removedBuffer = new short[volLength];\r
+            if (removedBuffer == null) {\r
+                removedBuffer = new short[volLength];\r
+            }\r
             \r
             // if values are mirrored across the the l->r of the image, cancel them out.  core values should only be on one side, while the cerebelum will have values on both sides\r
             for (int iZ = 0; iZ < maxSymmetryRemovalSlice && iZ < extents[2]; iZ++) {\r
index ff0290d..53d3f41 100644 (file)
@@ -40,6 +40,9 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
     private JTextField adcThresholdField;\r
     \r
     private JCheckBox symmetryCheckbox;\r
+    \r
+    private JCheckBox cerebellumCheckbox;\r
+    private JTextField cerebellumSliceMaxField;\r
 \r
     private boolean adcImageMultifile = false;\r
     private ModelImage adcImage;\r
@@ -51,6 +54,10 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
     \r
     private boolean doSymmetryRemoval = true;\r
     \r
+    private boolean doCerebellumSkip = true;\r
+    \r
+    private int cerebellumSkipSliceMax = 7;\r
+    \r
     private PlugInAlgorithmStrokeSegmentation segAlgo = null;\r
     \r
     private static final String svnVersion = "$Rev$";\r
@@ -228,6 +235,9 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
         \r
         doSymmetryRemoval = symmetryCheckbox.isSelected();\r
         \r
+        doCerebellumSkip = cerebellumCheckbox.isSelected();\r
+        cerebellumSkipSliceMax = Integer.parseInt(cerebellumSliceMaxField.getText());\r
+        \r
         return true;\r
     }\r
 \r
@@ -238,7 +248,7 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
     protected void callAlgorithm() {\r
 \r
         try {\r
-            segAlgo = new PlugInAlgorithmStrokeSegmentation(dwiImage, adcImage, adcThreshold, doSymmetryRemoval, outputDir);\r
+            segAlgo = new PlugInAlgorithmStrokeSegmentation(dwiImage, adcImage, adcThreshold, doSymmetryRemoval, doCerebellumSkip, cerebellumSkipSliceMax, outputDir);\r
 \r
             // This is very important. Adding this object as a listener allows the algorithm to\r
             // notify this object when it has completed or failed. See algorithm performed event.\r
@@ -284,6 +294,8 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
         \r
         doSymmetryRemoval = scriptParameters.getParams().getBoolean("do_symmetry_removal");\r
         \r
+        // TODO cerebellum skip\r
+        \r
         outputDir = adcImage.getImageDirectory() + File.separator;\r
     }\r
 \r
@@ -292,6 +304,7 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
         scriptParameters.storeImage(dwiImage, "dwi_image");\r
         scriptParameters.getParams().put(ParameterFactory.newParameter("adc_threshold", adcThreshold));\r
         scriptParameters.getParams().put(ParameterFactory.newParameter("do_symmetry_removal", doSymmetryRemoval));\r
+        // TODO cerebellum skip\r
     }\r
     \r
     /**\r
@@ -342,9 +355,31 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
         symmetryCheckbox.setFont(serif12);\r
         mainPanel.add(symmetryCheckbox, gbc);\r
         \r
+        // TODO cerebellum skip fields\r
+        \r
         gbc.gridy++;\r
         gbc.gridx = 0;\r
         \r
+        gbc.gridwidth = 1;\r
+        \r
+        cerebellumCheckbox = new JCheckBox("Ignore thresholded ADC values up to slice", doCerebellumSkip);\r
+        cerebellumCheckbox.setForeground(Color.black);\r
+        cerebellumCheckbox.setFont(serif12);\r
+        mainPanel.add(cerebellumCheckbox, gbc);\r
+        \r
+        gbc.gridwidth = 1;\r
+        \r
+        cerebellumSliceMaxField = new JTextField(10);\r
+        cerebellumSliceMaxField.setText("" + cerebellumSkipSliceMax);\r
+        gbc.fill = GridBagConstraints.NONE;\r
+        gbc.gridx++;\r
+        mainPanel.add(cerebellumSliceMaxField, gbc);\r
+        \r
+        gbc.gridy++;\r
+        gbc.gridx = 0;\r
+        \r
+        gbc.gridwidth = 3;\r
+        \r
         dirMethodRadio = new JRadioButton("Select directory with Baseline_ADC and Baseline_DWI files/subdirectories");\r
         dirMethodRadio.setForeground(Color.black);\r
         dirMethodRadio.setFont(serif12);\r
@@ -471,7 +506,7 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
         final JFileChooser chooser = new JFileChooser(initDir);\r
 \r
         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\r
-        chooser.setDialogTitle("Choose output directory for Validation Tool files");\r
+        chooser.setDialogTitle("Choose directory containing ADC and DWI volumes");\r
         final int returnValue = chooser.showOpenDialog(this);\r
         if (returnValue == JFileChooser.APPROVE_OPTION) {\r
             dirFileField.setText(chooser.getSelectedFile().getAbsolutePath() + File.separator);\r
@@ -686,7 +721,7 @@ public class PlugInDialogStrokeSegmentation extends JDialogStandaloneScriptableP
                                     adcImageMultifile = true;\r
                                     foundADC = true;\r
                                     break;\r
-                                } else if (val.equalsIgnoreCase("SE") || val.equalsIgnoreCase("M_SE")) {\r
+                                } else if (val.equalsIgnoreCase("SE") || val.equalsIgnoreCase("M_SE") || val.equalsIgnoreCase("TRACEW")) {\r
                                     dwiPath = file.getAbsolutePath();\r
                                     dwiImageMultifile = true;\r
                                     foundDWI = true;\r