Process Stacks?

After running the “Analyze Particles” command, the “Process Stacks” text box appears, asking if I want to apply the analysis to the all of the stacks in my hyperstack. Is there a way that I can make this automatically select “yes,” so that I can automate the function in a script? It seems like it should be a simple bit of code, but I haven’t found a workaround.

  • Press L for Command Finder
  • Check the “Close window after running command” box
  • Type “Record”
  • Press enter to pop up the Macro Recorder
  • Press L
  • Type “analyze p”
  • Press enter for Analyze Particles
  • Make desired choices, press enter
  • Choose “Yes” to “Process Stack?” dialog
  • And behold (in the Recorder window) the line of macro code which automates this—something similar to:
run("Analyze Particles...", "add stack");

I have that line of code in my script already. After the code inputs the options I’ve selected ("…add stack"), a pop-up box with the options “yes,” “no,” and “cancel” appears, which has to be manually clicked in order to move the script forward. Is it possible to make this automatically apply the particle analysis to all of the stacks?

Hmm, that sounds like a bug!

On my system with ImageJ 2.0.0-rc-43/1.50e, the following macro performs particle analysis across all slices of the T1 Head sample image, with no pop-up dialogs:

run("T1 Head (2.4M, 16-bits)");
setAutoThreshold("Default dark");
run("Analyze Particles...", "add stack");

Which version of ImageJ are you using? Have you tried the latest version from ?

It was indeed a bug in my ImageJ. I updated to 1.50f and ran the script again, and the pop-up box didn’t come up again. Thank you for helping me figure it out!

1 Like

Great, glad to hear it is working now!

if you are asking in Java then you need to do a loop. Check this post