ImageJ saving summary table not working as expected

Dear all,

I’m trying to save the summary of the particle analyser using ImageJ macro. However, it doesn’t work as expected. This is a minimal code example:

// open image
run("Blobs (25K)");

// segment
setAutoThreshold("MaxEntropy dark");
setAutoThreshold("MaxEntropy");
setOption("BlackBackground", true);
run("Convert to Mask");

// measure
run("Set Measurements...", "area redirect=None decimal=3");
run("Analyze Particles...", "summarize");

// save summary
IJ.renameResults("Results");
saveAs("Results", "C:\\structure\\temp\\Summary.csv");

On screen, I still see the Summary table:
image

However, on disc, this table is saved:

I assume this is a bug. Does anybody know a workaround?

Thanks!

Cheers,
Robert

From macros, you can only save the results table named “Results”. The usual solution is to rename the summary table to “Results” (while temporarily renaming any other results table) and then save it. See several threads in the mailing list in the past (sorry I cannot search for them right now).

In any full-fledged scripting language, you should be able to get/keep a reference to the summary table and save it directly. :slight_smile:

Hey @imagejan,

thanks for your hint! I think the renaming method is broken. The line IJ.renameResults("Results"); comes from the recorder but is not functional.

Scripting languages are no alternative as I’m just preparing a macro course. :wink:

Cheers,
Robert

1 Like

Oh, sorry, I missed that you had tried IJ.renameResults in your code already.

What’s “broken” is maybe the recording, as it should better record the macro function IJ.renameResults(oldName,newName) in your case.

That’s it! Thanks @imagejan!

@wayne: Might this be a bug? Renaming a “Summary” table to “Results” gets recorded as

IJ.renameResults("Results");

instead of

IJ.renameResults("Summary", "Results");

Thanks!
Robert

1 Like

Use Table.rename() to rename the “Summary” table to “Results” and it will work as expected, as in this example:

run("Blobs (25K)");
setAutoThreshold("MaxEntropy");
run("Set Measurements...", "area");
run("Analyze Particles...", "summarize");
Table.rename("Summary", "Results");
saveAs("Results", getDirectory("home")+"Summary.csv");

Or better, directly save the “Summary” table using Table.save():

run("Blobs (25K)");
setAutoThreshold("MaxEntropy");
run("Set Measurements...", "area");
run("Analyze Particles...", "summarize");
Table.save(getDirectory("home")+"Summary.csv","Summary");
3 Likes

Thanks @Wayne

However, can we change what the recorder records in this context? The current recording is misleading and not functional… I’d like to improve the user experience of the macro recorder :wink:

You are probably using an older version of ImageJ. This gets recorded when I rename “Summary” to “Results” in ImageJ 1.52o:

Table.rename("Summary", "Results");

1 Like

Upgrade to the current version of ImageJ (1.52o) and the recorder should work as expected.

Indeed. Thanks! Apparently my Fiji was confused with updating… A freshly downloaded and updated Fiji records Table.rename("Summary", "Results"); as expected. Sorry for the trouble :wink:

Thanks a lot!