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++) {
	run("Duplicate...", "title=["+original+"_gauss_"+i+"]");
	run("Gaussian Blur...", "sigma="+i);

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%)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at ij.macro.Functions.getStringFunction(
	at ij.macro.Interpreter.getStringTerm(
	at ij.macro.Interpreter.getString(
	at ij.macro.Interpreter.doStatement(
	at ij.macro.Interpreter.doStatements(
	at ij.plugin.Macro_Runner.runMacro(
	at ij.IJ.runMacro(
	at ij.IJ.runMacro(
	at net.imagej.legacy.IJ1Helper$
	at net.imagej.legacy.IJ1Helper$
	at net.imagej.legacy.IJ1Helper.runMacroFriendly(
	at net.imagej.legacy.IJ1Helper.runMacro(
	at net.imagej.legacy.plugin.IJ1MacroEngine.eval(
	at net.haesleinhuepf.imagej.markdown.adapters.IJ1MacroMarkdownEngine.eval(
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at ij.measure.ResultsTable.getStringValue(
	at net.haesleinhuepf.imagej.markdown.ImagejMacroMarkdownRuntime.tableToHTML(
	at net.haesleinhuepf.imagej.markdown.ImagejMacroMarkdownRuntime.markdownToMacroSwitch(
	... 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!


Works like a charm :+1:

1 Like