@Test public void testPrintCentroids() throws Exception { doNothing().when(MOCK_UI).show(any(ImagePlus.class)); final ImagePlus line = NewImage.createByteImage("Test", 5, 3, 1, FILL_BLACK); line.getStack().getProcessor(1).set(1, 1, (byte) 0xFF); line.getStack().getProcessor(1).set(2, 1, (byte) 0xFF); line.getStack().getProcessor(1).set(3, 1, (byte) 0xFF); final CommandModule module = command().run( IntertrabecularAngleWrapper.class, true, "inputImage", line, "minimumTrabecularLength", 0, "printCentroids", true).get(); final DefaultResultsTable centroids = (DefaultResultsTable) module .getOutput("centroidTable"); assertEquals(6, centroids.getColumnCount()); assertEquals(1, centroids.getRowCount()); final Iterator<String> expectedColumnHeaders = Stream.of("V1x", "V1y", "V1z", "V2x", "V2y", "V2z").iterator(); centroids.forEach(c -> assertEquals(expectedColumnHeaders.next(), c .getHeader())); assertEquals(1.0, centroids.get(0, 0), 1e-12); assertEquals(1.0, centroids.get(1, 0), 1e-12); assertEquals(0.0, centroids.get(2, 0), 1e-12); assertEquals(3.0, centroids.get(3, 0), 1e-12); assertEquals(1.0, centroids.get(4, 0), 1e-12); assertEquals(0.0, centroids.get(5, 0), 1e-12); }
@Override public void run() { statusService.showStatus("Intertrabecular angles: Initialising..."); statusService.showStatus("Intertrabecular angles: skeletonising"); final ImagePlus skeleton = skeletonise(); statusService.showStatus("Intertrabecular angles: analysing skeletons"); statusService.showProgress(0, PROGRESS_STEPS); final Graph[] graphs = analyzeSkeleton(skeleton); if (graphs == null || graphs.length == 0) { cancelMacroSafe(this, NO_SKELETONS); return; } warnMultipleGraphs(graphs); final Graph largestGraph = Arrays.stream(graphs).max(Comparator .comparingInt(a -> a.getVertices().size())).orElse(new Graph()); statusService.showStatus("Intertrabecular angles: pruning graph"); statusService.showProgress(1, PROGRESS_STEPS); final ValuePair<Graph, double[]> pruningResult = GraphPruning .pruneShortEdges(largestGraph, minimumTrabecularLength, iteratePruning, useClusters, coefficients); final Graph cleanGraph = pruningResult.a; statusService.showStatus( "Intertrabecular angles: valence sorting trabeculae"); statusService.showProgress(3, PROGRESS_STEPS); final Map<Integer, List<Vertex>> valenceMap = VertexUtils.groupByValence( cleanGraph.getVertices(), minimumValence, maximumValence); if (valenceMap.isEmpty()) { cancelMacroSafe(this, NO_RESULTS_MSG); } statusService.showStatus("Intertrabecular angles: calculating angles"); statusService.showProgress(4, PROGRESS_STEPS); final Map<Integer, DoubleStream> radianMap = createRadianMap(valenceMap); addResults(radianMap); printEdgeCentroids(cleanGraph.getEdges()); printCulledEdgePercentages(pruningResult.b); reportUsage(); }
IntertrabecularAngleWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Intertrabecular angles: Initialising..."); statusService.showStatus("Intertrabecular angles: skeletonising"); final ImagePlus skeleton = skeletonise(); statusService.showStatus("Intertrabecular angles: analysing skeletons"); statusService.showProgress(0, PROGRESS_STEPS); final Graph[] graphs = analyzeSkeleton(skeleton); if (graphs == null || graphs.length == 0) { cancelMacroSafe(this, NO_SKELETONS); return; } warnMultipleGraphs(graphs); final Graph largestGraph = Arrays.stream(graphs).max(Comparator .comparingInt(a -> a.getVertices().size())).orElse(new Graph()); statusService.showStatus("Intertrabecular angles: pruning graph"); statusService.showProgress(1, PROGRESS_STEPS); final ValuePair<Graph, double[]> pruningResult = GraphPruning .pruneShortEdges(largestGraph, minimumTrabecularLength, iteratePruning, useClusters, coefficients); final Graph cleanGraph = pruningResult.a; statusService.showStatus( "Intertrabecular angles: valence sorting trabeculae"); statusService.showProgress(3, PROGRESS_STEPS); final Map<Integer, List<Vertex>> valenceMap = VertexUtils.groupByValence( cleanGraph.getVertices(), minimumValence, maximumValence); if (valenceMap.isEmpty()) { cancelMacroSafe(this, NO_RESULTS_MSG); } statusService.showStatus("Intertrabecular angles: calculating angles"); statusService.showProgress(4, PROGRESS_STEPS); final Map<Integer, DoubleStream> radianMap = createRadianMap(valenceMap); addResults(radianMap); printEdgeCentroids(cleanGraph.getEdges()); printCulledEdgePercentages(pruningResult.b); reportUsage(); } }
IntertrabecularAngleWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Intertrabecular angles: Initialising..."); statusService.showStatus("Intertrabecular angles: skeletonising"); final ImagePlus skeleton = skeletonise(); statusService.showStatus("Intertrabecular angles: analysing skeletons"); statusService.showProgress(0, PROGRESS_STEPS); final Graph[] graphs = analyzeSkeleton(skeleton); if (graphs == null || graphs.length == 0) { cancelMacroSafe(this, NO_SKELETONS); return; } warnMultipleGraphs(graphs); final Graph largestGraph = Arrays.stream(graphs).max(Comparator .comparingInt(a -> a.getVertices().size())).orElse(new Graph()); statusService.showStatus("Intertrabecular angles: pruning graph"); statusService.showProgress(1, PROGRESS_STEPS); final ValuePair<Graph, double[]> pruningResult = GraphPruning .pruneShortEdges(largestGraph, minimumTrabecularLength, iteratePruning, useClusters, coefficients); final Graph cleanGraph = pruningResult.a; statusService.showStatus( "Intertrabecular angles: valence sorting trabeculae"); statusService.showProgress(3, PROGRESS_STEPS); final Map<Integer, List<Vertex>> valenceMap = VertexUtils.groupByValence( cleanGraph.getVertices(), minimumValence, maximumValence); if (valenceMap.isEmpty()) { cancelMacroSafe(this, NO_RESULTS_MSG); } statusService.showStatus("Intertrabecular angles: calculating angles"); statusService.showProgress(4, PROGRESS_STEPS); final Map<Integer, DoubleStream> radianMap = createRadianMap(valenceMap); addResults(radianMap); printEdgeCentroids(cleanGraph.getEdges()); printCulledEdgePercentages(pruningResult.b); reportUsage(); }  }
IntertrabecularAngleWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Intertrabecular angles: Initialising..."); statusService.showStatus("Intertrabecular angles: skeletonising"); final ImagePlus skeleton = skeletonise(); statusService.showStatus("Intertrabecular angles: analysing skeletons"); statusService.showProgress(0, PROGRESS_STEPS); final Graph[] graphs = analyzeSkeleton(skeleton); if (graphs == null || graphs.length == 0) { cancelMacroSafe(this, NO_SKELETONS); return; } warnMultipleGraphs(graphs); final Graph largestGraph = Arrays.stream(graphs).max(Comparator .comparingInt(a -> a.getVertices().size())).orElse(new Graph()); statusService.showStatus("Intertrabecular angles: pruning graph"); statusService.showProgress(1, PROGRESS_STEPS); final ValuePair<Graph, double[]> pruningResult = GraphPruning .pruneShortEdges(largestGraph, minimumTrabecularLength, iteratePruning, useClusters, coefficients); final Graph cleanGraph = pruningResult.a; statusService.showStatus( "Intertrabecular angles: valence sorting trabeculae"); statusService.showProgress(3, PROGRESS_STEPS); final Map<Integer, List<Vertex>> valenceMap = VertexUtils.groupByValence( cleanGraph.getVertices(), minimumValence, maximumValence); if (valenceMap.isEmpty()) { cancelMacroSafe(this, NO_RESULTS_MSG); } statusService.showStatus("Intertrabecular angles: calculating angles"); statusService.showProgress(4, PROGRESS_STEPS); final Map<Integer, DoubleStream> radianMap = createRadianMap(valenceMap); addResults(radianMap); printEdgeCentroids(cleanGraph.getEdges()); printCulledEdgePercentages(pruningResult.b); reportUsage(); }  @Override void run(); }
IntertrabecularAngleWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Intertrabecular angles: Initialising..."); statusService.showStatus("Intertrabecular angles: skeletonising"); final ImagePlus skeleton = skeletonise(); statusService.showStatus("Intertrabecular angles: analysing skeletons"); statusService.showProgress(0, PROGRESS_STEPS); final Graph[] graphs = analyzeSkeleton(skeleton); if (graphs == null || graphs.length == 0) { cancelMacroSafe(this, NO_SKELETONS); return; } warnMultipleGraphs(graphs); final Graph largestGraph = Arrays.stream(graphs).max(Comparator .comparingInt(a -> a.getVertices().size())).orElse(new Graph()); statusService.showStatus("Intertrabecular angles: pruning graph"); statusService.showProgress(1, PROGRESS_STEPS); final ValuePair<Graph, double[]> pruningResult = GraphPruning .pruneShortEdges(largestGraph, minimumTrabecularLength, iteratePruning, useClusters, coefficients); final Graph cleanGraph = pruningResult.a; statusService.showStatus( "Intertrabecular angles: valence sorting trabeculae"); statusService.showProgress(3, PROGRESS_STEPS); final Map<Integer, List<Vertex>> valenceMap = VertexUtils.groupByValence( cleanGraph.getVertices(), minimumValence, maximumValence); if (valenceMap.isEmpty()) { cancelMacroSafe(this, NO_RESULTS_MSG); } statusService.showStatus("Intertrabecular angles: calculating angles"); statusService.showProgress(4, PROGRESS_STEPS); final Map<Integer, DoubleStream> radianMap = createRadianMap(valenceMap); addResults(radianMap); printEdgeCentroids(cleanGraph.getEdges()); printCulledEdgePercentages(pruningResult.b); reportUsage(); }  @Override void run(); static final String NO_RESULTS_MSG; }