Help with setBatchMode(false) when running macro

imagej
batch-processing
macro

#1

Hi!
I have written a macro that performs color deconvolution on immunohistochemistry image to separate out the DAB staining and then akes into binary. I am running it in batch processing on a large set of images. In the macro I am using selectWindow("…"+imageTitle); to select the deconvoluted image that I’d like to make binary. However, when I try to speed up the macro by running it in setBatchMode(false), it crashes. I suspect that the reason is that no window is opened and so it can’t select? Any suggestions on how to circumvent this or am I completely off track :)?
Thank you!


#2

Good day!

“Batch” with ImageJ has at least three quite different meanings.

  1. “Process >> Batch”
  2. BatchMode as a ImageJ macro call.
  3. Terminal operation

re 1.
Please tell us if you use the functionality.

re 2:
Please consult the list of commented Macro functions:
https://imagej.nih.gov/ij/developer/macro/functions.html

setBatchMode(true);
   //your macro code
setBatchMode(false);

Even if images aren’t visible they can be accessed!
I’m quite sure that the crash is not due to proper usage setBatchMode().

Regards

Herbie


#3

Hi,

Please replace selectWindow() with selectImage() this should alleviate any issues in that regard.

Let us know if it works! Otherwise feel free to post your macro and we can have a look!

Best,
Oli


#4

I do the same thing in one of my macros and it works…setBatchMode(false) should be setBatchMode(true)