Commit 0701bbb9 authored by rhaase's avatar rhaase
Browse files

added test and example image for a skeleton containing a loop

parent f797de31
package de.mpicbg.scf.skeletonanalysis;
import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
import ij.gui.WaitForUserDialog;
import org.junit.Before;
import org.junit.Test;
import sc.fiji.analyzeSkeleton.*;
import java.awt.*;
import java.util.ArrayList;
import static org.junit.Assert.assertTrue;
* Author: Robert Haase, Scientific Computing Facility, MPI-CBG Dresden,
* Date: September 2016
public class LoopTest {
SkeletonAnalyser skeletonAnalyser;
ImagePlus target;
public void initialize() {
ImageJ.main(new String[1]);
target = IJ.openImage(
AnalyzeSkeleton_ skel = new AnalyzeSkeleton_();
skel.setup("", target);
// null );
SkeletonResult simpleSkeletonResult =, false, false, target, false, false);
// = skel.assembleResults();
skeletonAnalyser = new SkeletonAnalyser(simpleSkeletonResult);
public void testIfLoopsInSkeletonsAreAnalysable()
Vertex soma = skeletonAnalyser.getLargestJunction();
// ---------------------------------
// get all leafs
ArrayList<Vertex> leafs = skeletonAnalyser.getLeafs();
System.out.println("number of leafs: "+leafs.size());
PathDrawer pathDrawer = new PathDrawer(target);
for (Edge edge : skeletonAnalyser.getAllEdges())
pathDrawer.drawEdge(edge, Color. green);
// ---------------------------------
// get shortest paths from leafs to
// soma and analyse their straightness
for (Vertex leaf :leafs)
ArrayList<Edge> path = skeletonAnalyser.getShortestPath(leaf, soma);
// measure from junction center to junction center
double pathLength = SkeletonAnalyser.getLengthAlongPath(path);
System.out.println("path length " + pathLength);
PathDrawer.drawAllPathsToLargestJunction(skeletonAnalyser, target,;
new WaitForUserDialog("huh").show();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment