@Test public void testNoSkeletonsCancelsPlugin() throws Exception { final ImagePlus imagePlus = IJ.createImage("test", 3, 3, 3, 8); final CommandModule module = command().run( IntertrabecularAngleWrapper.class, true, "inputImage", imagePlus).get(); assertTrue("Plugin should have cancelled", module.isCanceled()); assertEquals("Cancel reason is incorrect", NO_SKELETONS, module .getCancelReason()); verify(MOCK_UI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(), any()); }
@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; }