Analyze skeleton 2D/3D not working in headless mode

headless
Tags: #<Tag:0x00007fd542ef3a20>

#1

I am trying to run a macro in headless mode. The macro runs fine when launched from ImageJ itself.

It works almost fine in headless mode except it does not seem to recognise the Analyze skelton 2D/3D plugin. I got the following error:

java.lang.NullPointerException
at sc.fiji.analyzeSkeleton.AnalyzeSkeleton_.dialogItemChanged(AnalyzeSkeleton_.java:370)
at sc.fiji.analyzeSkeleton.AnalyzeSkeleton_.createSettingsDialog(AnalyzeSkeleton_.java:3423)
at sc.fiji.analyzeSkeleton.AnalyzeSkeleton_.run(AnalyzeSkeleton_.java:286)

Any idea what might be causing this and how to fix it?


#2

It seems the code explicitly checks some options of the GUI dialog that, in your case, does not exist.

Let me modify that part and make a release.


#3

OK, I made a new release. Please try it out and let me know if it works now.


#4

Awesome! no error message anymore!

But I cannot find how to retrieve the data from the analysis. My code goes like this:

	run("Analyze Skeleton (2D/3D)", "prune=none calculate");
selectWindow("Longest shortest paths");
close();
selectWindow("Tagged skeleton");
close();

// Get the skeleton variables
//selectWindow("Results");
nLateral = 0;
primLength = 0;
meanSkelLength = 0;
maxSkelLength = 0;
maxPrimLength = 0;
nBranches = 0;
nEndPoints = 0;
for(i = 0; i < nResults; i++){
	if(getResult("Longest Shortest Path", i) > maxPrimLength){
		maxPrimLength = getResult("Longest Shortest Path", i);
		primLength = getResult("Longest Shortest Path", i);
		nLateral = getResult("# Junctions", i);
		nBranches = getResult("# Branches", i);
		nEndPoints = getResult("# End-point voxels", i);			
		meanSkelLength = getResult("Average Branch Length", i);
		maxSkelLength = getResult("Maximum Branch Length", i);
	}
}	
run("Clear Results");

but print(nResults) returns 0. Are the results stored elsewhere?


#5

I guess it has to do with collecting the results of a window when you are in headless mode. I would rather do it with an equivalent script. Have you tried converting your macro to any of the available scripting languages?