Posted by
Harry Parker on
Sep 21, 2007; 10:22pm
URL: http://imagej.273.s1.nabble.com/race-condition-problem-with-command-line-ImageJ-macro-jobs-tp3698355.html
Hi all,
I hope somebody can help me debug a frustrating ImageJ macro problem I'm experiencing.
I've developed a few complex image processing macros for ImageJ that always work well when started from the ImageJ menu, but only work some of the time when started from the command line with the "-macro" option, and never work with the "-batch" option.
This is on Windows XP SP2 with the latest Java (1.6.0_02) and ImageJ (1.39d). I first noticed the problem in Java 1.6.0_01 and ImageJ 1.38x before I upgraded trying to resolve it.
At first I hoped to be able to use the much faster "-batch" mode option, but this didn't work. Each run had a different error. "Image not found" and other problems. When I switched to the slower "-macro" option the macro sometimes worked perfectly, but often did not.
The problems seem mostly related to calls to Image Calculator or my own plugins. For example:
imageCalculator("Multiply create", title_dA, title_dA);
rename(title_dA2);
imageCalculator("Add create", title_dA2, title_dL2);
will sometime cause an error indicating the image <title_dA2> was not found.
Debugging statements I added to display the image names and ID's showed that the rename statement was returning AFTER the 2nd imageCalculator statement, causing another image to be renamed!! The result of the 1st imageCalculator was found with its default name, (i.e. Result of ...")!
The hard part is that the error occurs on different lines on different runs! Looks like a race condition to me.
Later macro statements are running before the earlier ones have returned. But only once in a while!
What's different about the timing in macro and batch modes?? (Besides not displaying the images in batch mode.)
Looks like too much parallelism is happening, and not enough syncing.
Any ideas on how to track this down?
I haven't been able to reproduce this in a small macro. The smaller the macro, the less likely it is to occur. This macro I'm focusing on now is > 300 lines long with 11 calls to ImageCalculator(), 18 calls to rename(), etc.
--
Harry Parker
Senior Systems Engineer
Digital Imaging Systems, Inc.
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC