ImageJ Macro Markdown table issue

Hi @haesleinhuepf,

I just tried the Macro Markdown. Veeeeerrrry nice idea. Thanks for starting and sharing that.

I tried it with the following minimal macro, after receiving an error with a more complex one and it is related to String values in tables (see below).

/*
# Title
text <b> bold text</b>
*/

run("Blobs (25K)");
original = getTitle();
for (i = 1; i < 10; i++) {
	selectWindow(original);
	run("Duplicate...", "title=["+original+"_gauss_"+i+"]");
	run("Gaussian Blur...", "sigma="+i);
	run("Measure");
}

I ran into a problem with tables and can nail it down to the function tableToHtml and there with line 120 and the function getStringValue(...) called there from the ResultsTable class:

The error message is as follows:

(Fiji Is Just) ImageJ 2.1.0/1.53c; Java 1.8.0_172 [64-bit]; Windows 10 10.0; 84MB of 12177MB (<1%)
 
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at ij.macro.Functions.call(Functions.java:4515)
	at ij.macro.Functions.getStringFunction(Functions.java:276)
	at ij.macro.Interpreter.getStringTerm(Interpreter.java:1475)
	at ij.macro.Interpreter.getString(Interpreter.java:1453)
	at ij.macro.Interpreter.doStatement(Interpreter.java:333)
	at ij.macro.Interpreter.doStatements(Interpreter.java:264)
	at ij.macro.Interpreter.run(Interpreter.java:160)
	at ij.macro.Interpreter.run(Interpreter.java:93)
	at ij.macro.Interpreter.run(Interpreter.java:104)
	at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
	at ij.IJ.runMacro(IJ.java:153)
	at ij.IJ.runMacro(IJ.java:142)
	at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
	at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
	at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
	at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
	at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
	at net.haesleinhuepf.imagej.markdown.adapters.IJ1MacroMarkdownEngine.eval(IJ1MacroMarkdownEngine.java:87)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at ij.measure.ResultsTable.getStringValue(ResultsTable.java:443)
	at net.haesleinhuepf.imagej.markdown.ImagejMacroMarkdownRuntime.tableToHTML(ImagejMacroMarkdownRuntime.java:120)
	at net.haesleinhuepf.imagej.markdown.ImagejMacroMarkdownRuntime.markdownToMacroSwitch(ImagejMacroMarkdownRuntime.java:86)
	... 31 more

If I switch of the Display label field under Set Measurements... it works. So, table cells with String values seem to make trouble. I have the suspicion that the line before
int column = table.getColumnIndex(header);
is returning -1 as index for the label column, but not sure. Potentially, instead of using the index the column name (getStringValue(java.lang.String column, int row);) might solve that problem. But I don’t know if you than run into another limitation?

If you prefer that I file an issue on github, I can do that.

1 Like

Hi Jan @biovoxxel ,

I just played a bit with that and I found a different solution. Apparently, the “Label” column is very special. It has its own access-function in the table class. I implemented that for now, a strategy checking if the column index is < 0 and name is “Label”.

Just update Fiji and give it a try. Would you mind confirming that it now also works on your side?

Thanks for reporting this bug!

Cheers,
Robert

Works like a charm :+1:
Thanks

1 Like