|
39 | 39 | import static org.junit.Assert.assertTrue;
|
40 | 40 | import static org.mockito.ArgumentMatchers.any;
|
41 | 41 | import static org.mockito.ArgumentMatchers.anyString;
|
42 |
| -import static org.mockito.ArgumentMatchers.eq; |
43 |
| -import static org.mockito.ArgumentMatchers.startsWith; |
44 |
| -import static org.mockito.Mockito.after; |
45 | 42 | import static org.mockito.Mockito.doNothing;
|
46 |
| -import static org.mockito.Mockito.mock; |
47 | 43 | import static org.mockito.Mockito.timeout;
|
48 | 44 | import static org.mockito.Mockito.verify;
|
49 |
| -import static org.mockito.Mockito.when; |
50 |
| -import static org.scijava.ui.DialogPrompt.MessageType.WARNING_MESSAGE; |
51 | 45 |
|
52 | 46 | import ij.IJ;
|
53 | 47 | import ij.ImagePlus;
|
54 | 48 | import ij.gui.NewImage;
|
| 49 | +import ij.measure.Calibration; |
55 | 50 |
|
56 | 51 | import java.net.URL;
|
57 | 52 | import java.util.Iterator;
|
|
67 | 62 | import org.junit.experimental.categories.Category;
|
68 | 63 | import org.scijava.command.CommandModule;
|
69 | 64 | import org.scijava.table.DefaultColumn;
|
70 |
| -import org.scijava.ui.swing.sdi.SwingDialogPrompt; |
71 | 65 |
|
72 | 66 | /**
|
73 | 67 | * Tests for {@link IntertrabecularAngleWrapper}
|
|
80 | 74 | public class IntertrabecularAngleWrapperTest extends AbstractWrapperTest {
|
81 | 75 |
|
82 | 76 | @Test
|
83 |
| - public void testAngleResults() throws Exception { |
| 77 | + public void testAngleResultsUncalibratedPixels() throws Exception { |
84 | 78 | // SETUP
|
85 | 79 | final Predicate<Double> nonEmpty = Objects::nonNull;
|
86 | 80 | final URL resource = getClass().getClassLoader().getResource(
|
87 | 81 | "test-skelly.zip");
|
88 | 82 | assert resource != null;
|
89 | 83 | final ImagePlus skelly = IJ.openImage(resource.getFile());
|
90 |
| - |
| 84 | + |
91 | 85 | // EXECUTE
|
92 | 86 | final CommandModule module = command().run(
|
93 | 87 | IntertrabecularAngleWrapper.class, true, "inputImage", skelly,
|
@@ -115,7 +109,91 @@ public void testAngleResults() throws Exception {
|
115 | 109 | assertEquals(2, fiveColumn.stream().filter(nonEmpty)
|
116 | 110 | .filter(d -> d == Math.PI / 2).count());
|
117 | 111 | }
|
| 112 | + |
| 113 | + @Test |
| 114 | + public void testAngleResultsIsotropicBigPixels() throws Exception { |
| 115 | + // SETUP |
| 116 | + final Predicate<Double> nonEmpty = Objects::nonNull; |
| 117 | + final URL resource = getClass().getClassLoader().getResource( |
| 118 | + "test-skelly.zip"); |
| 119 | + assert resource != null; |
| 120 | + final ImagePlus skelly = IJ.openImage(resource.getFile()); |
| 121 | + Calibration cal = new Calibration(); |
| 122 | + cal.pixelDepth = 2; |
| 123 | + cal.pixelHeight = 2; |
| 124 | + cal.pixelWidth = 2; |
| 125 | + skelly.setCalibration(cal); |
118 | 126 |
|
| 127 | + // EXECUTE |
| 128 | + final CommandModule module = command().run( |
| 129 | + IntertrabecularAngleWrapper.class, true, "inputImage", skelly, |
| 130 | + "minimumValence", 3, "maximumValence", 50, "minimumTrabecularLength", 4, |
| 131 | + "marginCutOff", 0, "useClusters", true, "iteratePruning", false).get(); |
| 132 | + |
| 133 | + // VERIFY |
| 134 | + @SuppressWarnings("unchecked") |
| 135 | + final List<DefaultColumn<Double>> table = |
| 136 | + (List<DefaultColumn<Double>>) module.getOutput("resultsTable"); |
| 137 | + assertNotNull(table); |
| 138 | + assertEquals(2, table.size()); |
| 139 | + final DefaultColumn<Double> threeColumn = table.get(0); |
| 140 | + assertEquals("3", threeColumn.getHeader()); |
| 141 | + assertEquals(10, threeColumn.size()); |
| 142 | + assertEquals(3, threeColumn.stream().filter(nonEmpty).count()); |
| 143 | + assertEquals(2, threeColumn.stream().filter(nonEmpty).distinct().count()); |
| 144 | + final DefaultColumn<Double> fiveColumn = table.get(1); |
| 145 | + assertEquals("5", fiveColumn.getHeader()); |
| 146 | + assertEquals(10, fiveColumn.size()); |
| 147 | + assertEquals(10, fiveColumn.stream().filter(nonEmpty).count()); |
| 148 | + assertEquals(6, fiveColumn.stream().filter(nonEmpty).distinct().count()); |
| 149 | + assertEquals(1, fiveColumn.stream().filter(nonEmpty) |
| 150 | + .filter(d -> d == Math.PI).count()); |
| 151 | + assertEquals(2, fiveColumn.stream().filter(nonEmpty) |
| 152 | + .filter(d -> d == Math.PI / 2).count()); |
| 153 | + } |
| 154 | + |
| 155 | + @Test |
| 156 | + public void testAngleResultsIsotropicSmallPixels() throws Exception { |
| 157 | + // SETUP |
| 158 | + final Predicate<Double> nonEmpty = Objects::nonNull; |
| 159 | + final URL resource = getClass().getClassLoader().getResource( |
| 160 | + "test-skelly.zip"); |
| 161 | + assert resource != null; |
| 162 | + final ImagePlus skelly = IJ.openImage(resource.getFile()); |
| 163 | + Calibration cal = new Calibration(); |
| 164 | + cal.pixelDepth = 0.1; |
| 165 | + cal.pixelHeight = 0.1; |
| 166 | + cal.pixelWidth = 0.1; |
| 167 | + skelly.setCalibration(cal); |
| 168 | + |
| 169 | + // EXECUTE |
| 170 | + final CommandModule module = command().run( |
| 171 | + IntertrabecularAngleWrapper.class, true, "inputImage", skelly, |
| 172 | + "minimumValence", 3, "maximumValence", 50, "minimumTrabecularLength", 0.2, |
| 173 | + "marginCutOff", 0, "useClusters", true, "iteratePruning", false).get(); |
| 174 | + |
| 175 | + // VERIFY |
| 176 | + @SuppressWarnings("unchecked") |
| 177 | + final List<DefaultColumn<Double>> table = |
| 178 | + (List<DefaultColumn<Double>>) module.getOutput("resultsTable"); |
| 179 | + assertNotNull(table); |
| 180 | + assertEquals(2, table.size()); |
| 181 | + final DefaultColumn<Double> threeColumn = table.get(0); |
| 182 | + assertEquals("3", threeColumn.getHeader()); |
| 183 | + assertEquals(10, threeColumn.size()); |
| 184 | + assertEquals(3, threeColumn.stream().filter(nonEmpty).count()); |
| 185 | + assertEquals(2, threeColumn.stream().filter(nonEmpty).distinct().count()); |
| 186 | + final DefaultColumn<Double> fiveColumn = table.get(1); |
| 187 | + assertEquals("5", fiveColumn.getHeader()); |
| 188 | + assertEquals(10, fiveColumn.size()); |
| 189 | + assertEquals(10, fiveColumn.stream().filter(nonEmpty).count()); |
| 190 | + assertEquals(6, fiveColumn.stream().filter(nonEmpty).distinct().count()); |
| 191 | + assertEquals(1, fiveColumn.stream().filter(nonEmpty) |
| 192 | + .filter(d -> d == Math.PI).count()); |
| 193 | + assertEquals(2, fiveColumn.stream().filter(nonEmpty) |
| 194 | + .filter(d -> d == Math.PI / 2).count()); |
| 195 | + } |
| 196 | + |
119 | 197 | @Test
|
120 | 198 | public void testAnisotropicImageShowsWarningDialog() {
|
121 | 199 | CommonWrapperTests.testAnisotropyWarning(imageJ(),
|
|
0 commit comments