Login  Register

Re: ImageJ does not wait for ImageJ

Posted by Michael Schmid on Sep 17, 2013; 12:44pm
URL: http://imagej.273.s1.nabble.com/ImageJ-does-not-wait-for-ImageJ-tp5004817p5004821.html

Hi Gabriel,

well, in principle, running a macro in ImageJ should be deterministic...

The current problem sounds like a race condition to me, a frequent problem due to the multi-threaded nature of Java. The user interface runs in a different thread, thus operations like closing a window are not necessarily synchronous with the remaining code.
There are already a lot of fixes for such problems in ImageJ, but there are still unfixed issues.  E.g., it sometimes happens to me that the image window decorated as the front window by the operating system (Mac OS X) is different from the foreground image of ImageJ.  Diagnosing such issues would be certainly welcome.

Anyhow, Johannes, we need one more bit of information: is the macro running in BatchMode or not?

Michael
________________________________________________________________
On Sep 17, 2013, at 12:34, Gabriel Landini wrote:

> On Sep 17, 2013, at 11:56, Johannes Koch wrote:
>> I open a series of images, say 20 and run this macro:
>>
>> //snip
>> run("Set Measurements...", "area mean min integrated redirect=None
>> decimal=2");
>>
>> n=nImages;
>>
>> for(i=0; i<n; i++) {
>> name=getTitle();
>> Stack.setPosition(2, 1, 1);
>> run("Duplicate...", "title=work channels=1-3");
>> selectWindow(name);
>> close();
>> *wait(500);*
>> run("Subtract Background...", "rolling=25 sliding disable");
> [...]
>
> You need to specify this with SelectWindow(your_image_name) just before
> preforming the Subtract Background command to make sure that the process is on
> the correct one.
> The macro above selects an image and immediately closes it on the next line,
> so which image is the one being processed now?
>
> Regards
> Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html