Hi all,
I was wondering if it is possible to check whether a function has finished in a macro, in order to avoid the next command being initiated too early. I have read the following: http://imagej.1557.x6.nabble.com/Is-it-normal-to-use-a-wait-instruction-after-a-command-td5011551.html , and applied the proposed solution therein for functions that produce a new image window as output. For example: while (!isOpen("Resulting-Image")) { wait(100); } However, I would also like to be able to check if filters that don't produce a new image window, such as the "Gaussian Blur 3D", were executed completely. Is there a trick that allows you to do this? Or is it necessary to change the plugin to allow for this? Would that be a hard thing to do (I am only familiar with macros)? Thanks in advance for any ideas! Djoere -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Djoere,
> I was wondering if it is possible to check whether a function has finished in a macro, in order to avoid the next command being initiated too early. I believe this is the purpose of the IJ.macroRunning[1] method. Instead of using wait(100), your while loop would look like this: while (IJ.macroRunning() { // Nothing needed here. Just wait for macro to end. } Hope that helps. Best, Mark [1] https://github.com/imagej/ImageJA/blob/v1.49t/src/main/java/ij/IJ.java#L348-L350 On Fri, Jun 5, 2015 at 6:40 AM, Djoere Gaublomme <[hidden email]> wrote: > Hi all, > > I was wondering if it is possible to check whether a function has finished > in a macro, in order to avoid the next command being initiated too early. > > I have read the following: > http://imagej.1557.x6.nabble.com/Is-it-normal-to-use-a-wait-instruction-after-a-command-td5011551.html > , and applied the proposed solution therein for functions that produce a > new image window as output. > For example: > > while (!isOpen("Resulting-Image")) { > wait(100); > } > > However, I would also like to be able to check if filters that don't > produce a new image window, such as the "Gaussian Blur 3D", were executed > completely. > > Is there a trick that allows you to do this? > Or is it necessary to change the plugin to allow for this? Would that be > a hard thing to do (I am only familiar with macros)? > > Thanks in advance for any ideas! > > Djoere > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Mark,
Thank you for your answer. I am afraid I am going to need some handholding, as I am unfamiliar with IJ methods. Is this usable in a normal ImageJ macro? Or only in a plugin? When I try to run it in a macro, I get the error "Unrecognized IJ function name". Is there a need to somehow import this method? Kind regards Djoere PS: I assume there should be an extra parenthesis? --> while (IJ.macroRunning()) { Quoting Mark Hiner <[hidden email]>: > Hi Djoere, > >> I was wondering if it is possible to check whether a function has > finished in a macro, in order to avoid the next command being initiated too > early. > > I believe this is the purpose of the IJ.macroRunning[1] method. > > Instead of using wait(100), your while loop would look like this: > > while (IJ.macroRunning() { > // Nothing needed here. Just wait for macro to end. > } > > Hope that helps. > > Best, > Mark > > [1] > https://github.com/imagej/ImageJA/blob/v1.49t/src/main/java/ij/IJ.java#L348-L350 > > On Fri, Jun 5, 2015 at 6:40 AM, Djoere Gaublomme <[hidden email]> > wrote: > >> Hi all, >> >> I was wondering if it is possible to check whether a function has finished >> in a macro, in order to avoid the next command being initiated too early. >> >> I have read the following: >> http://imagej.1557.x6.nabble.com/Is-it-normal-to-use-a-wait-instruction-after-a-command-td5011551.html >> , and applied the proposed solution therein for functions that produce a >> new image window as output. >> For example: >> >> while (!isOpen("Resulting-Image")) { >> wait(100); >> } >> >> However, I would also like to be able to check if filters that don't >> produce a new image window, such as the "Gaussian Blur 3D", were executed >> completely. >> >> Is there a trick that allows you to do this? >> Or is it necessary to change the plugin to allow for this? Would that be >> a hard thing to do (I am only familiar with macros)? >> >> Thanks in advance for any ideas! >> >> Djoere >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Djoere Gaublomme
> On Jun 5, 2015, at 7:40 AM, Djoere Gaublomme <[hidden email]> wrote:
> > Hi all, > > I was wondering if it is possible to check whether a function has finished in a macro, in order to avoid the next command being initiated too early. > > I have read the following: http://imagej.1557.x6.nabble.com/Is-it-normal-to-use-a-wait-instruction-after-a-command-td5011551.html , and applied the proposed solution therein for functions that produce a new image window as output. > For example: > > while (!isOpen("Resulting-Image")) { > wait(100); > } > > However, I would also like to be able to check if filters that don't produce a new image window, such as the "Gaussian Blur 3D", were executed completely. Macro functions, including "Gaussian Blur 3D”, do not return before they are finished except for a few external plugins, such as ""LoG 3D”. Please provide example macro code that does not work as expected without wait() calls. -wayne > Is there a trick that allows you to do this? > Or is it necessary to change the plugin to allow for this? Would that be a hard thing to do (I am only familiar with macros)? > > Thanks in advance for any ideas! > > Djoere -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |