On 06/21/2010 06:18 PM, Rasband, Wayne (NIH/NIMH) [E] wrote:
> On Jun 21, 2010, at 4:47 PM, Adam Goode wrote:
>
>> Hi,
>>
>> I am converting some old macros to JavaScript to use with the -batch
>> command line. The macro contains some run(...) commands that call other
>> plugins that open multiple windows. With the old macro system, in batch
>> mode, I could close images and work with the active image, but with
>> JavaScript, there are never any images open. IJ.getImage() produces an
>> error.
>>
>> It looks like the Interpreter class contains a mechanism for holding
>> onto images in batch mode (the imageTable). Can this be made to work
>> when executing JavaScript?
>
> Adam,
>
> Batch mode mode only works with macros. Plugins and scripts need to work with images, in the form of ImagePlus and ImageProcessor objects, that have not been displayed. Do the plugins you are using have public methods that return processed images without displaying them?
>
Hi,
Looking through the ImageJ code, it appears that setting
Interpreter.batchMode to true should be all that is needed to enable the
batch mode window list. Indeed, adding this JavaScript makes things work
again in batch mode:
Packages.ij.macro.Interpreter.batchMode = true;
This is clearly a hacky workaround, would it be possible for this to be
set by ImageJ when "-batch" is specified, even when JavaScript is
executed? Getting JavaScript to work as well as the old macro language
would be very useful for our project and I think would be useful to
others as well. And as far as I can see, there are only a few things
missing at this point.
Thanks,
Adam