Problem using the Batch Processor and saving files

I’m still new at writing macros and my questions is probably a very simple one. I’m using the Process>Batch tool to run analyze particles on a bunch of files in a folder. I can’t seem to get all the results to save into an excel file though. I looked here: http://imagej.1557.x6.nabble.com/Macro-help-result-file-save-td3694038.html but the results don’t seem to work for me and I also don’t really get what is going on in that code.

Right now, I’m simply executing this in the batch processor:

 run("Analyze Particles...", "  show=[Overlay Masks] display exclude clear include summarize in_situ"); 

and would like for the results table to save as filename+results in excel for all the files in the batch. I don’t know if it is possible, but it would be even better if anyone knows how to save all the results into the same excel file as opposed to separate ones fore each image/result, where each new results table just gets added below the previously analyzed one.

You can delete the “clear” command in you macro and the results for each slice will be added to the before made measurements.

By the way you don’t need the batch tool if you import your images e.g. as an image sequence (File->Import->Image Sequence… or simply drag the image folder on the toolbar - if the have the same size). Then add the command “stack” to process all slices.

Then you should add the stack slice name to the measurements to identify the measured image in the table:
https://imagej.net/docs/guide/146-30.html#sub:Set-Measurements

Example for a(n) (image sequence) stack:

run("Set Measurements...", "area mean standard modal perimeter shape feret's stack limit display redirect=None decimal=3");
run("Analyze Particles...", "  show=[Overlay Masks] display exclude include in_situ stack");
homedir = getDirectory("home");
saveAs("Results", homedir + "results.xls");

Add you own commands easily with the macro recorder:

https://imagej.net/docs/guide/146-31.html#sub:Record

See also in this context:

Here are some other resources which might be helpful:

http://imagej.net/developer/macro/functions.html#getStatistics

http://imagej.net/developer/macro/functions.html#setResult

http://imagejdocu.tudor.lu/doku.php?id=macro:calculating_stats_from_a_results_table

http://imagej.net/macros/CustomTabStatFromResults.txt

From this forum:

2 Likes