run multiple instances of the same macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

run multiple instances of the same macro

John Alexander-7
Hello group,

I wrote a macro to batch process a folder for image analysis.

When I run it it prompts me for a directory to process then off it goes
crunching away on each image in that folder.

All runs well.

What I would like to do is run it on multiple directories simultaneously.

I tried running it on directory #1, then running the macro again and
choosing directory #2.  But I get an "image is locked" error.  I guess
this is referring to the fact that the macro opens an image and creates
another image, then saves the result, then closes both images.  But when
I run more than one instance of the macro - I have more than just those
two windows open and the close() command tries to close the wrong window
(or a window that was opened by the other instance of the macro).

Is there a way I can separate them so this is avoidable?

John
Reply | Threaded
Open this post in threaded view
|

Re: run multiple instances of the same macro

Albert Cardona
Hi John,


> Is there a way I can separate them so this is avoidable?
>  

Macros are not thread safe: executing two macros in parallel is very
likely to result in unexpected results.

You can "work around" by writing a java plugin.


Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona
Reply | Threaded
Open this post in threaded view
|

Re: run multiple instances of the same macro

ctrueden
In reply to this post by John Alexander-7
Hi John,

Does it have to run both directories simultaneously, or would you settle for
sequentially? If you just want to avoid the hassle of manually running the
macro for each folder, you could just change your macro to process the
directory recursively. Then when you run it, choose a folder containing all
folders of interest, and it will work on everything. See the "list files
recursively" macro for an example:
http://rsb.info.nih.gov/ij/macros/ListFilesRecursively.txt

-Curtis

On Tue, Mar 4, 2008 at 12:33 AM, John Alexander <[hidden email]>
wrote:

> Hello group,
>
> I wrote a macro to batch process a folder for image analysis.
>
> When I run it it prompts me for a directory to process then off it goes
> crunching away on each image in that folder.
>
> All runs well.
>
> What I would like to do is run it on multiple directories simultaneously.
>
> I tried running it on directory #1, then running the macro again and
> choosing directory #2.  But I get an "image is locked" error.  I guess
> this is referring to the fact that the macro opens an image and creates
> another image, then saves the result, then closes both images.  But when
> I run more than one instance of the macro - I have more than just those
> two windows open and the close() command tries to close the wrong window
> (or a window that was opened by the other instance of the macro).
>
> Is there a way I can separate them so this is avoidable?
>
> John
>