diff --git a/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapper.java b/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapper.java index d4aa6ac08..f95a228b1 100644 --- a/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapper.java +++ b/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapper.java @@ -34,6 +34,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import ij.ImagePlus; import ij.ImageStack; import ij.gui.Roi; +import ij.measure.Calibration; import io.scif.FormatException; import io.scif.services.FormatService; @@ -302,13 +303,14 @@ private void showAdditionalResults(final SkeletonResult results) { final DefaultGenericTable table = new DefaultGenericTable(); final List> columns = Arrays.asList(new IntColumn( "# Skeleton"), new IntColumn("# Branch"), new DoubleColumn( - "Branch length"), new IntColumn("V1 x"), new IntColumn("V1 y"), - new IntColumn("V1 z"), new IntColumn("V2 x"), new IntColumn("V2 y"), - new IntColumn("V2 z"), new DoubleColumn("Euclidean distance"), + "Branch length"), new DoubleColumn("V1 x"), new DoubleColumn("V1 y"), + new DoubleColumn("V1 z"), new DoubleColumn("V2 x"), new DoubleColumn("V2 y"), + new DoubleColumn("V2 z"), new DoubleColumn("Euclidean distance"), new DoubleColumn("running average length"), new DoubleColumn( "average intensity (inner 3rd)"), new DoubleColumn( "average intensity")); final Graph[] graphs = results.getGraph(); + final Calibration cal = inputImage.getCalibration(); for (int i = 0; i < graphs.length; i++) { final ArrayList edges = graphs[i].getEdges(); // Sort into descending order by length @@ -319,15 +321,18 @@ private void showAdditionalResults(final SkeletonResult results) { ((IntColumn) columns.get(1)).add((j + 1)); ((DoubleColumn) columns.get(2)).add((edge.getLength())); final Point point = edge.getV1().getPoints().get(0); - ((IntColumn) columns.get(3)).add((point.x)); - ((IntColumn) columns.get(4)).add((point.y)); - ((IntColumn) columns.get(5)).add((point.z)); + ((DoubleColumn) columns.get(3)).add((point.x) * cal.pixelWidth); + ((DoubleColumn) columns.get(4)).add((point.y) * cal.pixelHeight); + ((DoubleColumn) columns.get(5)).add((point.z) * cal.pixelDepth); final Point point2 = edge.getV2().getPoints().get(0); - ((IntColumn) columns.get(6)).add((point2.x)); - ((IntColumn) columns.get(7)).add((point2.y)); - ((IntColumn) columns.get(8)).add((point2.z)); - final double distance = MathArrays.distance(new double[] { point.x, - point.y, point.z }, new double[] { point2.x, point2.y, point2.z }); + ((DoubleColumn) columns.get(6)).add((point2.x) * cal.pixelWidth); + ((DoubleColumn) columns.get(7)).add((point2.y) * cal.pixelHeight); + ((DoubleColumn) columns.get(8)).add((point2.z) * cal.pixelDepth); + final double distance = MathArrays.distance( + new double[] { point.x * cal.pixelWidth, + point.y * cal.pixelHeight, point.z * cal.pixelDepth }, + new double[] { point2.x * cal.pixelWidth, + point2.y * cal.pixelHeight, point2.z * cal.pixelDepth }); ((DoubleColumn) columns.get(9)).add((distance)); ((DoubleColumn) columns.get(10)).add((edge.getLength_ra())); ((DoubleColumn) columns.get(11)).add((edge.getColor3rd())); @@ -335,9 +340,7 @@ private void showAdditionalResults(final SkeletonResult results) { } } table.addAll(columns); - if (!table.isEmpty()) { - verboseTable = table; - } + verboseTable = table; } private void showResults(final SkeletonResult results) { diff --git a/Modern/wrapperPlugins/src/test/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapperTest.java b/Modern/wrapperPlugins/src/test/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapperTest.java index cca52dd5c..7b4e5613d 100644 --- a/Modern/wrapperPlugins/src/test/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapperTest.java +++ b/Modern/wrapperPlugins/src/test/java/org/bonej/wrapperPlugins/AnalyseSkeletonWrapperTest.java @@ -42,6 +42,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import ij.IJ; import ij.ImagePlus; import ij.gui.NewImage; +import ij.measure.Calibration; import java.io.File; import java.util.Collection; @@ -70,13 +71,18 @@ public void testAdditionalResultsTable() throws Exception { FILL_BLACK); line.getStack().getProcessor(1).set(1, 1, (byte) 0xFF); line.getStack().getProcessor(1).set(2, 2, (byte) 0xFF); - final String length = String.valueOf(Math.sqrt(2.0)); + final String length = String.valueOf(Math.sqrt(2.0) / 2); + Calibration cal = line.getCalibration(); + cal.pixelWidth = 0.5; + cal.pixelHeight = 0.5; + cal.pixelDepth = 0.5; + line.setCalibration(cal); final String[] expectedHeaders = { "# Skeleton", "# Branch", "Branch length", "V1 x", "V1 y", "V1 z", "V2 x", "V2 y", "V2 z", "Euclidean distance", "running average length", "average intensity (inner 3rd)", "average intensity" }; - final String[] expectedValues = { "1", "1", length, "1", "1", "0", "2", "2", - "0", length, length, "255.0", "255.0" }; + final String[] expectedValues = { "1", "1", length, "0.5", "0.5", "0.0", "1.0", "1.0", + "0.0", length, length, "255.0", "255.0" }; // EXECUTE final CommandModule module = command().run( @@ -94,7 +100,7 @@ public void testAdditionalResultsTable() throws Exception { assertEquals("Column has incorrect header", expectedHeaders[i], column .getHeader()); assertEquals("Column has wrong number of rows", 1, column.size()); - assertEquals("Column has an incorrect value", expectedValues[i], String + assertEquals("Column "+i+" has an incorrect value", expectedValues[i], String .valueOf(column.get(0))); } }