Printing text to analyse particles summary table and save the table

dear forum,

I am trying to write some settings to the Summary table of the analyse particles function. This works, but when I save the table, this extra information is gone. Is this expected behaviour? The macro below illustrates the issue. Compare the Summary table with the saved file summary.xls to see what I mean.

Thanks, Martin

homedir = getDirectory("home");

minsize = 10;
maxsize = 250;
settings = "minsize= " + minsize + "\n" 
           + "maxsize= " + maxsize + "\n";

run("Blobs (25K)");
setOption("BlackBackground", true);
run("Make Binary");
run("Analyze Particles...", "size=&minsize-&maxsize summarize add");

// settings are written to the summary table, but
// are not saved in the summary.xls file ???
print("[Summary]", settings);

saveAs("Results", homedir + File.separator + "summary.xls");

Did anyone try to reproduce this?
It would already be helpful to know that this behaviour is not due to any weird settings I may have on my computer.


Yes I can confirm this behavior. My naive guess at an explanation is that there is a backing data structure that created the summary window, and when you print to the window it updates the graphical element but not the backing structure.

Any thoughts @wayne?

Indeed, I observe the same thing on my system (ImageJ 2.0.0-rc-42/1.50e26; Java 1.7.0_80 [x86_64]).

I also tried filling in the extra rows with the correct number of columns with numerical data, and it made no difference.

From the code, it looks like only the exporter only writes canonical rows as incremented in certain ways. And only ResultsTable.setValue(column, row, value) increments the counter as needed for that. I couldn’t immediately find an appropriate macro function that calls that method, unfortunately.

You have to add the text to the ResultsTable that contains the Summary table values. One way to to this in a macro is to rename the table as “Results” and use the setResult() macro function to add the text. Here is an example:

homedir = getDirectory("home");
minsize = 10;
maxsize = 250;
run("Blobs (25K)");
run("Analyze Particles...", "size=&minsize-&maxsize summarize");
setResult("Slice", 1, "minsize="+minsize)
setResult("Slice", 2, "maxsize="+maxsize)
saveAs("Results", homedir + "summary.xls");

Perfect. Thank you Wayne.