Multiple "summary" results windows for a batch of samples?

Hi all~

I’m using ImageJ to do some clean up and counting of pollen cell images. This is my first exposure to the program and I’m struggling. I’ve written a macro that seems to work reasonably well for image clean up and works with batches of images. However, when I run it, the “summary” window repopulates every one to two images…therefore I get A LOT of windows to manually rename, save, and copy data from to an excel file. Is there an “easy” way to accomplish getting all the image counts to display in one “summary” window? Or even to just automatically move all the lines of data into an Excel sheet for saving?

This is my simple, but mostly effective macro:

run("Subtract Background...", "rolling=50 light");
run("8-bit");
setOption("BlackBackground", false);
run("Make Binary");
run("Watershed");
run("Analyze Particles...", "size=2000-Infinity circularity=0.40-1.00 show=Overlay exclude clear summarize");
saveAs("Results", "C:\\Users\\cope\\Desktop\\Test Images\\Summary.xls");

Dear @Sara_Etter,
Yes the problem is that when you save you change the name of ResultsTable from “Summary” to “Summary.xls”, and that doesn’t permit to ImageJ/Fiji to append results to a main ResultsTable that Fiji thinks is called “Summary” (without “.xls”).

An easy way to accomplish what you are asking is to save the ResultsTable at the end of the batch analysis.
So I don’t know how to you perform batch analysis (I suggest you to start from the IJ1 macro “Process Folder” template), but in the single image analysis don’t put saveAs("Results…), instead put it after all your images are analyzed.
Let’s say that this is a workaround, it doesn’t save single Summary.xls image per image but only the last one with the whole analysis: if you need also single excel files I think that you have to use functions like IJ.renameResults( https://imagej.nih.gov/ij/developer/macro/functions.html#IJ.renameResults) but it starts to become tricky.
I tried one time, but at the end I was struggling me too and I decided to pass to a programming language.

I also suggest you to put a close() after the Analyze Particles to avoid having all your windows opened at end of the batch analysis.

I hope this helps,
have a nice day
Emanuele

2 Likes

Instead of clearing (clear) and summarize the analysis (in the command run(“Analyze Particles”…) you can append the measurements in one results table and then afterwards summarize and save the table after all images have been analyzed:

run(“Subtract Background…”, “rolling=50 light”);
run(“8-bit”);
setOption(“BlackBackground”, false);
run(“Make Binary”);
run(“Watershed”);
run(“Analyze Particles…”, “size=2000-Infinity circularity=0.40-1.00 show=Overlay exclude”);

I would also enable the option “Display Label” in the “Set Measurements” dialog to include the name of the current measured image which will be the current filename.

1 Like

While I agree with most of @emartini’s suggestions (and the Process Folder template is definitely the more powerful way to do batch processing), I want to add that for very simple macros like the one posted by @Sara_Etter, it is absolutely sufficient to use the Process > Batch > Macro… command.

As already suggested by the others, just leave away your last line (saveAs...) and use your macro in Process > Batch > Macro…. You won’t have to care about closing the images, and the summary window will be populated with one line per image in the folder you’re processing.

2 Likes

Good morning! Thank you for all your help. I’ve been able to successfully analyze and save a summary for more than 600 images this am. My little macro just chugged along and the summary grew as images were processed. An easy “save as” works to get the file into an excel format. Thank you very much for the advice. I’ll be back for help as I demand more of my macro and data analysis from ImageJ!

1 Like