Porting continues.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 24 Apr 2018 20:44:42 +0000 (20:44 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 24 Apr 2018 20:44:42 +0000 (20:44 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15457 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/model/algorithms/StochasticForests.java

index f887555..a4103a1 100644 (file)
@@ -130,6 +130,8 @@ public class StochasticForests extends AlgorithmBase {
        \r
        public static double logprop;\r
        \r
+       private boolean testCode = true;\r
+       \r
        private abstract class Data {\r
                protected Vector<String> variable_names;\r
                protected int num_rows = 0;\r
@@ -834,9 +836,6 @@ public class StochasticForests extends AlgorithmBase {
        }\r
        \r
        private void equalSplit(Vector<Integer> result, int start, int end, int num_parts) {\r
-               if (result.size() < num_parts + 1) {\r
-                       result.setSize(num_parts+1);\r
-               }\r
                \r
                // Return range if only 1 part\r
                if (num_parts == 1) {\r
@@ -924,9 +923,6 @@ public class StochasticForests extends AlgorithmBase {
        private void drawWithoutReplacementSimple(Vector<Integer> result, int max,\r
                    Vector<Integer> skip, int num_samples) {\r
       int i, j;\r
-         if (result.size() < num_samples) {\r
-                 result.setSize(num_samples);\r
-         }\r
 \r
          // Set all to not selected\r
          Vector<Boolean> temp = new Vector<Boolean>();\r
@@ -955,9 +951,7 @@ public class StochasticForests extends AlgorithmBase {
       int i, j;\r
       int temp;\r
          // Create indices\r
-         if (result.size() < max) {\r
-                 result.setSize(max);\r
-         }\r
+         result.clear();\r
          for (i = 0; i < max; i++) {\r
                  result.add(i);\r
          }\r
@@ -985,9 +979,6 @@ public class StochasticForests extends AlgorithmBase {
                int draw = 0;\r
                double sum_of_weight = 0;\r
                double rand;\r
-               if (result.size() < num_samples) {\r
-                       result.setSize(num_samples);\r
-               }\r
                \r
                // Set all to not selected\r
                Vector<Boolean> temp = new Vector<Boolean>();\r
@@ -1025,9 +1016,6 @@ public class StochasticForests extends AlgorithmBase {
                int draw = 0;\r
                double sum_of_weight = 0;\r
                double rand;\r
-               if (result.size() < num_samples) {\r
-                       result.setSize(num_samples);\r
-               }\r
                \r
                // Set all to not selected\r
                Vector<Boolean> temp = new Vector<Boolean>();\r
@@ -1520,8 +1508,563 @@ public class StochasticForests extends AlgorithmBase {
                  return scores;\r
     }\r
 \r
+       private void maxstat(Vector<Double> scores, Vector<Double> x, Vector<Integer> indices,\r
+                       double best_maxstat[], double best_split_value[], double minprop, double maxprop) {\r
+         int n = x.size();\r
 \r
-       public void runAlgorithm() {\r
+         double sum_all_scores = 0;\r
+         for (int i = 0; i < n; ++i) {\r
+           sum_all_scores += scores.get(indices.get(i));\r
+         }\r
+\r
+         // Compute sum of differences from mean for variance\r
+         double mean_scores = sum_all_scores / n;\r
+         double sum_mean_diff = 0;\r
+         for (int i = 0; i < n; ++i) {\r
+           sum_mean_diff += (scores.get(i) - mean_scores) * (scores.get(i) - mean_scores);\r
+         }\r
+\r
+         // Get smallest and largest split to consider, -1 for compatibility with R maxstat\r
+         int minsplit = 0;\r
+         if (n * minprop > 1) {\r
+           minsplit = (int)(n * minprop - 1);\r
+         }\r
+         int maxsplit = (int)(n * maxprop - 1);\r
+\r
+         // For all unique x-values\r
+         best_maxstat[0] = -1;\r
+         best_split_value[0] = -1;\r
+         double sum_scores = 0;\r
+         int n_left = 0;\r
+         for (int i = 0; i <= maxsplit; ++i) {\r
+\r
+           sum_scores += scores.get(indices.get(i));\r
+           n_left++;\r
+\r
+           // Dont consider splits smaller than minsplit for splitting (but count)\r
+           if (i < minsplit) {\r
+             continue;\r
+           }\r
+\r
+           // Consider only unique values\r
+           if (i < n - 1 && x.get(indices.get(i)) == x.get(indices.get(i + 1))) {\r
+             continue;\r
+           }\r
+\r
+           // If value is largest possible value, stop\r
+           if (x.get(indices.get(i)) == x.get(indices.get(n - 1))) {\r
+             break;\r
+           }\r
+\r
+           double S = sum_scores;\r
+           double E = (double) n_left / (double) n * sum_all_scores;\r
+           double V = (double) n_left * (double) (n - n_left) / (double) (n * (n - 1)) * sum_mean_diff;\r
+           double T = Math.abs((S - E) / Math.sqrt(V));\r
+\r
+           if (T > best_maxstat[0]) {\r
+             best_maxstat[0] = T;\r
+\r
+             // Use mid-point split if possible\r
+             if (i < n - 1) {\r
+               best_split_value[0] = (x.get(indices.get(i)) + x.get(indices.get(i + 1))) / 2;\r
+             } else {\r
+               best_split_value[0] = x.get(indices.get(i));\r
+             }\r
+           }\r
+         }\r
+       }\r
+       \r
+       private Vector<Integer> numSamplesLeftOfCutpoint(Vector<Double> x, Vector<Integer> indices) {\r
+         Vector<Integer> num_samples_left = new Vector<Integer>();\r
+         num_samples_left.setSize(x.size());\r
+\r
+         for (int i = 0; i < x.size(); ++i) {\r
+           if (i == 0) {\r
+             num_samples_left.add(1);\r
+           } else if (x.get(indices.get(i)) == x.get(indices.get(i - 1))) {\r
+               int value = num_samples_left.lastElement();\r
+               num_samples_left.set(num_samples_left.size() - 1,value+1);\r
+           } else {\r
+             int value = num_samples_left.lastElement();\r
+             num_samples_left.add(value + 1);\r
+           }\r
+         }\r
+\r
+         return num_samples_left;\r
+       }\r
+       \r
+       /**\r
+        * Write a 1d vector to filestream. First the size is written, then all vector elements.\r
+        * @param vector Vector of type T to save\r
+        * @param file ofstream object to write to.\r
+        */\r
+       private void saveVector1D(Vector<Integer> vector, BufferedWriter bw) {\r
+         // Save length\r
+         int i;\r
+         int length = vector.size();\r
+         try {\r
+             bw.write(String.valueOf(length)+"\n");\r
+         }\r
+         catch (IOException e) {\r
+                 MipavUtil.displayError("IO exception on bw.write(String.valueOf(length))");\r
+                 return;\r
+         }\r
+         for (i = 0; i < length; i++) {\r
+                 try {\r
+                     bw.write(String.valueOf(vector.get(i))+"\n");\r
+                 }\r
+                 catch (IOException e) {\r
+                         MipavUtil.displayError("IO exception on bw.write(String.valueOf(vector.get(i)))");\r
+                         return;\r
+                 }\r
+         }\r
+       }\r
+       \r
+       /**\r
+        * Read a 1d vector written by saveVector1D() from filestream.\r
+        * @param result Result vector with elements of type T.\r
+        * @param file ifstream object to read from.\r
+        */\r
+       private void readVector1D(Vector<Integer> result, BufferedReader br) {\r
+         int i;\r
+         int value;\r
+         // Read length\r
+         int length;\r
+         String line;\r
+         try {\r
+          line = br.readLine();\r
+         }\r
+         catch (IOException e) {\r
+                 MipavUtil.displayError("IO exception on br.readLine()");\r
+                 return;\r
+         }\r
+         length = Integer.valueOf(line).intValue();\r
+         for (i = 0; i < length; i++) {\r
+                 try {\r
+                 line = br.readLine();\r
+                 }\r
+                 catch (IOException e) {\r
+                         MipavUtil.displayError("IO exception on br.readLine()");\r
+                         return;\r
+                 }\r
+                 value = Integer.valueOf(line).intValue();\r
+                 result.add(value);\r
+         }\r
+       }\r
+\r
+       /**\r
+        * Write a 1d vector to filestream. First the size is written, then all vector elements.\r
+        * @param vector Vector of type T to save\r
+        * @param file ofstream object to write to.\r
+        */\r
+       private void saveDVector1D(Vector<Double> vector, BufferedWriter bw) {\r
+         // Save length\r
+         int i;\r
+         int length = vector.size();\r
+         try {\r
+             bw.write(String.valueOf(length)+"\n");\r
+         }\r
+         catch (IOException e) {\r
+                 MipavUtil.displayError("IO exception on bw.write(String.valueOf(length))");\r
+                 return;\r
+         }\r
+         for (i = 0; i < length; i++) {\r
+                 try {\r
+                     bw.write(String.valueOf(vector.get(i))+"\n");\r
+                 }\r
+                 catch (IOException e) {\r
+                         MipavUtil.displayError("IO exception on bw.write(String.valueOf(vector.get(i)))");\r
+                         return;\r
+                 }\r
+         }\r
+       }\r
+       \r
+       /**\r
+        * Read a 1d vector written by saveVector1D() from filestream.\r
+        * @param result Result vector with elements of type T.\r
+        * @param file ifstream object to read from.\r
+        */\r
+       private void readDVector1D(Vector<Double> result, BufferedReader br) {\r
+         int i;\r
+         double value;\r
+         // Read length\r
+         int length;\r
+         String line;\r
+         try {\r
+          line = br.readLine();\r
+         }\r
+         catch (IOException e) {\r
+                 MipavUtil.displayError("IO exception on br.readLine()");\r
+                 return;\r
+         }\r
+         length = Integer.valueOf(line).intValue();\r
+         for (i = 0; i < length; i++) {\r
+                 try {\r
+                 line = br.readLine();\r
+                 }\r
+                 catch (IOException e) {\r
+                         MipavUtil.displayError("IO exception on br.readLine()");\r
+                         return;\r
+                 }\r
+                 value = Double.valueOf(line).doubleValue();\r
+                 result.add(value);\r
+         }\r
+       }\r
+       \r
+       /**\r
+        * Write a 2d vector to filestream. First the size of the first dim is written as size_t, then for all inner vectors the size and elements.\r
+        * @param vector Vector of vectors of type T to write to file.\r
+        * @param file ofstream object to write to.\r
+        */\r
+       private void saveVector2D(Vector<Vector<Integer>> vector, BufferedWriter bw) {\r
+         int i;\r
+         // Save length of first dim\r
+         int length = vector.size();\r
+         try {\r
+             bw.write(String.valueOf(length)+"\n");\r
+         }\r
+         catch (IOException e) {\r
+                 MipavUtil.displayError("IO exception on bw.write(String.valueOf(length))");\r
+                 return;\r
+         }\r
+\r
+         // Save outer vector\r
+         Vector<Integer> inner_vector = new Vector<Integer>();\r
+         for (i = 0; i < vector.size(); i++) {\r
+           // Save inner vector\r
+               inner_vector = vector.get(i);\r
+           saveVector1D(inner_vector, bw);\r
+         }\r
+       }\r
+       \r
+       /**\r
+        * Read a 2d vector written by saveVector2D() from filestream.\r
+        * @param result Result vector of vectors with elements of type T.\r
+        * @param file ifstream object to read from.\r
+        */\r
+       private void readVector2D(Vector<Vector<Integer>> result, BufferedReader br) {\r
+         int i;\r
+         // Read length of first dim\r
+         int length;\r
+         String line;\r
+         try {\r
+          line = br.readLine();\r
+         }\r
+         catch (IOException e) {\r
+                 MipavUtil.displayError("IO exception on br.readLine()");\r
+                 return;\r
+         }\r
+         length = Integer.valueOf(line).intValue();\r
+         for (i = 0; i < length; i++) {\r
+             result.add(new Vector<Integer>());  \r
+         }\r
+\r
+         // Read outer vector\r
+         for (i = 0; i < length; ++i) {\r
+           // Read inner vector\r
+           readVector1D(result.get(i), br);\r
+         }\r
+       }\r
+\r
+\r
+       \r
+       private boolean equalVectorInteger(Vector<Integer> v1, Vector<Integer> v2, String str) {\r
+               // v1 is true answer, v2 is test answer\r
+               int i;\r
+           if (v1.size() != v2.size()) {\r
+               System.out.println("In " + str + " correct size is " + v1.size());\r
+               System.out.println("Test size is " + v2.size());\r
+               return false;\r
+           }\r
+           for (i = 0; i < v1.size(); i++) {\r
+               if (v1.get(i) != v2.get(i)) {\r
+                       System.out.println("In " + str + " correct element " + i + " is " + v1.get(i));\r
+                       System.out.println("Actual test element at " + i + " is " + v2.get(i));\r
+                       return false;\r
+               }\r
+           }\r
+           System.out.println(str + " passed");\r
+           return true;\r
+       }\r
+       \r
+       private boolean equalVectorVectorInteger(Vector<Vector<Integer>> v1, Vector<Vector<Integer>> v2, String str) {\r
+               // v1 is true answer, v2 is test answer\r
+               int i, j;\r
+               Vector<Integer> p1 = new Vector<Integer>();\r
+               Vector<Integer> p2 = new Vector<Integer>();\r
+           if (v1.size() != v2.size()) {\r
+               System.out.println("In " + str + " correct size is " + v1.size());\r
+               System.out.println("Test size is " + v2.size());\r
+               return false;\r
+           }\r
+           for (i = 0; i < v1.size(); i++) {\r
+               if (v1.get(i).size() != v2.get(i).size()) {\r
+                       System.out.println("In " + str + " v1.get("+i+").size() is " + v1.get(i).size());\r
+                       System.out.println("Actual test element v2.get("+i+").size() is " + v2.get(i).size());\r
+                       return false;\r
+               }\r
+               p1 = v1.get(i);\r
+               p2 = v2.get(i);\r
+               for (j = 0; j < p1.size(); j++) {\r
+                       if (p1.get(i) != p2.get(i)) {\r
+                               System.out.println("In " + str + " correct element " + i + "," + j + " is " + p1.get(j));\r
+                               System.out.println("Actual test element at " + i + "," + j + " is " + p2.get(j));\r
+                               return false;\r
+                       }\r
+                   }\r
+           }\r
+           System.out.println(str + " passed");\r
+           return true;\r
+       }\r
+       \r
+       private boolean equalVectorDouble(Vector<Double> v1, Vector<Double> v2, String str) {\r
+               // v1 is true answer, v2 is test answer\r
+               int i;\r
+           if (v1.size() != v2.size()) {\r
+               System.out.println("In " + str + " correct size is " + v1.size());\r
+               System.out.println("Test size is " + v2.size());\r
+               return false;\r
+           }\r
+           for (i = 0; i < v1.size(); i++) {\r
+               if (!v1.get(i).equals(v2.get(i))) {\r
+                       System.out.println("In " + str + " correct element " + i + " is " + v1.get(i));\r
+                       System.out.println("Actual test element at " + i + " is " + v2.get(i));\r
+                       return false;\r
+               }\r
+           }\r
+           System.out.println(str + " passed");\r
+           return true;\r
+       }\r
+       \r
+       public StochasticForests() {\r
                \r
        }\r
+\r
+\r
+       public void runAlgorithm() {\r
+          if (testCode) {\r
+                  Vector<Integer>test = new Vector<Integer>();\r
+                  // Split 0..9 in 1 part\r
+                  String str = "Test equalSplit, onePart";\r
+                  Vector<Integer>answer = new Vector<Integer>();\r
+                  answer.addAll(Arrays.asList(new Integer[]{0,10}));\r
+                  equalSplit(test, 0, 9, 1);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 0..7 in 4 parts\r
+                  str = "Test equalSplit, perfectSplit0";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{0,2,4,6,8}));\r
+                  equalSplit(test, 0, 7, 4);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 2..7 in 2 parts\r
+                  str = "Test equalSplit, perfectSplit2";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{2,5,8}));\r
+                  equalSplit(test, 2, 7, 2);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 13..24 in 3 parts\r
+                  str = "Test equalSplit, perfectSplit13";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{13,17,21,25}));\r
+                  equalSplit(test, 13, 24, 3);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 0..6 in 4 parts\r
+                  str = "Test equalSplit, nonPerfectSplit0";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{0,2,4,6,7}));\r
+                  equalSplit(test, 0, 6, 4);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 2..12 in 5 parts\r
+                  str = "Test equalSplit, nonPerfectSplit2";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{2,5,7,9,11,13}));\r
+                  equalSplit(test, 2, 12, 5);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 15..19 in 2 parts\r
+                  str = "Test equalSplit, nonPerfectSplit15";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{15,18,20}));\r
+                  equalSplit(test, 15, 19, 2);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 30..35 in 1 part\r
+                  str = "Test equalSplit, nonPerfectSplit30";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{30,36}));\r
+                  equalSplit(test, 30, 35, 1);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 0..2 in 6 parts\r
+                  // Result should only contain 3 parts\r
+                  str = "Test equalSplit, moreParts1";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{0,1,2,3}));\r
+                  equalSplit(test, 0, 2, 6);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 0..2 in 4 parts\r
+                  // Result should only contain 3 parts\r
+                  str = "Test equalSplit, moreParts2";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{0,1,2,3}));\r
+                  equalSplit(test, 0, 2, 4);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  // Split 0..2 in 3 parts\r
+                  // Result should contain only 3 parts\r
+                  str = "Test equalSplit, moreParts3";\r
+                  test.clear();\r
+                  answer.clear();\r
+                  answer.addAll(Arrays.asList(new Integer[]{0,1,2,3}));\r
+                  equalSplit(test, 0, 2, 3);\r
+                  equalVectorInteger(answer, test, str);\r
+                  \r
+                  str = "Test readWrite1D, int1";\r
+                  File outfile = new File("testfile1d");\r
+                  FileWriter fw;\r
+                  try {\r
+                      fw = new FileWriter(outfile);\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on fw = new FileWriter(outfile)");\r
+                          return;\r
+                  }\r
+           BufferedWriter bw = new BufferedWriter(fw);\r
+                  Vector<Integer> expect = new Vector<Integer>();\r
+                  expect.addAll(Arrays.asList(new Integer[]{1,2,3,4,5,6}));\r
+                  saveVector1D(expect, bw);\r
+                  try {\r
+                      bw.close();\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on bw.close()");\r
+                          return;\r
+                  }\r
+                  \r
+                  File file = new File("testfile1d");\r
+                  BufferedReader infile;\r
+                  try {\r
+                      infile = new BufferedReader(new FileReader(file));\r
+                  }\r
+                  catch (FileNotFoundException e) {\r
+                          MipavUtil.displayError("Could not find file testfile1d");\r
+                          return;\r
+                  }\r
+                  test.clear();\r
+                  readVector1D(test, infile);\r
+                  try {\r
+                          infile.close();\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on infile.close()");\r
+                          return;\r
+                  }\r
+                  equalVectorInteger(expect, test, str);\r
+                  \r
+                  str = "Test readWrite1D, double1";\r
+                  outfile = new File("testfile1d");\r
+                  try {\r
+                      fw = new FileWriter(outfile);\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on fw = new FileWriter(outfile)");\r
+                          return;\r
+                  }\r
+           bw = new BufferedWriter(fw);\r
+                  Vector<Double> Dexpect = new Vector<Double>();\r
+                  Dexpect.addAll(Arrays.asList(new Double[]{1.5,4.5,10.2,0.0,-5.9}));\r
+                  saveDVector1D(Dexpect, bw);\r
+                  try {\r
+                      bw.close();\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on bw.close()");\r
+                          return;\r
+                  }\r
+                  \r
+                  file = new File("testfile1d");\r
+                  try {\r
+                      infile = new BufferedReader(new FileReader(file));\r
+                  }\r
+                  catch (FileNotFoundException e) {\r
+                          MipavUtil.displayError("Could not find file testfile1d");\r
+                          return;\r
+                  }\r
+                  Vector<Double> Dtest = new Vector<Double>();\r
+                  readDVector1D(Dtest, infile);\r
+                  try {\r
+                          infile.close();\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on infile.close()");\r
+                          return;\r
+                  }\r
+                  equalVectorDouble(Dexpect, Dtest, str);\r
+                  \r
+                  str = "Test readWrite2D, int1";\r
+                  outfile = new File("testfile2d");\r
+                  try {\r
+                      fw = new FileWriter(outfile);\r
+                  }\r
+                  catch (IOException e) {\r
+                          MipavUtil.displayError("IO exception on fw = new FileWriter(outfile)");\r
+                          return;\r
+                  }\r
+           bw = new BufferedWriter(fw);\r
+           Vector<Integer> expect1 = new Vector<Integer>();\r
+           expect1.addAll(Arrays.asList(new Integer[]{1,2,3,4,5,6}));\r
+           Vector<Integer> expect2 = new Vector<Integer>();\r
+           expect2.addAll(Arrays.asList(new Integer[]{7,8,9,10}));\r
+           Vector<Integer> expect3 = new Vector<Integer>();\r
+           expect3.addAll(Arrays.asList(new Integer[]{11,121,3,14,15}));\r
+           Vector<Vector<Integer>> expectAll = new Vector<Vector<Integer>>();\r
+           expectAll.add(expect1);\r
+           expectAll.add(expect2);\r
+           expectAll.add(expect3);\r
+           saveVector2D(expectAll, bw);\r
+           try {\r
+                  bw.close();\r
+           }\r
+           catch (IOException e) {\r
+                  MipavUtil.displayError("IO exception on bw.close()");\r
+                  return;\r
+           }\r
+           \r
+\r
+                  file = new File("testfile2d");\r
+                  try {\r
+                      infile = new BufferedReader(new FileReader(file));\r
+                  }\r
+                  catch (FileNotFoundException e) {\r
+                          MipavUtil.displayError("Could not find file testfile2d");\r
+                          return;\r
+                  }\r
+                  Vector<Vector<Integer>> testAll = new Vector<Vector<Integer>>();\r
+                  readVector2D(testAll, infile);\r
+                  try {\r
+                          infile.close();\r
+                  }\r
+                  catch(IOException e) {\r
+                          MipavUtil.displayError("IO exception on infile.close()");\r
+                          return;\r
+                  }\r
+                  equalVectorVectorInteger(expectAll, testAll, str);\r
+                  return;\r
+          }\r
+       }\r
 }
\ No newline at end of file