Is there any way to detect whether a stack is currently animated using
macro code? |
Hi Bill,
You can try the following code. You might have to adjust the wait time, depending on the your stack size and speed. ------------------------------------ a = getSliceNumber(); wait(1000); b = getSliceNumber(); if(a!=b) print("Stack is animated."); else print("Stack is not animated."); ------------------------------------- Ved |
Bill, Ved,
The following macro retrieves the animation state of the current stack using a javascript call. The state is returned using the built-in preferences mechanism, because the eval() macro function cannot return a value. s="Prefs.set('is.animated',WindowManager."+ "getCurrentImage().getWindow()."+ "getAnimate());"; eval("script",s) a = call ('ij.Prefs.get','is.animated',false); print ("animated: "+a); Jerome On Sat, Sep 11, 2010 at 12:25 AM, Ved Sharma <[hidden email]> wrote: > Hi Bill, > > You can try the following code. You might have to adjust the wait time, > depending on the your stack size and speed. > > ------------------------------------ > a = getSliceNumber(); > wait(1000); > b = getSliceNumber(); > > if(a!=b) > print("Stack is animated."); > else > print("Stack is not animated."); > ------------------------------------- > > Ved > |
Jerome, Ved, & Wayne
Thanks for your advice. I guess I'll have to experiment to find out how much lag there might be in the disk-access required (I think) for the prefs approach, versus the need to wait for a frame change in the getSliceNumber approach. I'm trying to set up a very quick response in the UI to a keystroke, but need to know whether the stack is currently animated before choosing which actions to perform. It would be best, I think, if a macro command could directly return the current value of StackWindow.getAnimate(). Obviously this means work for Wayne, but I think it would be useful. Thanks to all, Bill On 9/12/10 3:35 p.m., Jerome Mutterer wrote: > Bill, Ved, > > The following macro retrieves the animation state of the current stack using > a javascript call. The state is returned using the built-in preferences > mechanism, because the eval() macro function cannot return a value. > > s="Prefs.set('is.animated',WindowManager."+ > "getCurrentImage().getWindow()."+ > "getAnimate());"; > eval("script",s) > a = call ('ij.Prefs.get','is.animated',false); > print ("animated: "+a); > > > Jerome > > On Sat, Sep 11, 2010 at 12:25 AM, Ved Sharma<[hidden email]> wrote: > >> Hi Bill, >> >> You can try the following code. You might have to adjust the wait time, >> depending on the your stack size and speed. >> >> ------------------------------------ >> a = getSliceNumber(); >> wait(1000); >> b = getSliceNumber(); >> >> if(a!=b) >> print("Stack is animated."); >> else >> print("Stack is not animated."); >> ------------------------------------- >> >> Ved >> |
On Sep 12, 2010, at 9:01 PM, Bill Mohler wrote:
> Jerome, Ved, & Wayne > > Thanks for your advice. I guess I'll have to experiment to find out how > much lag there might be in the disk-access required (I think) for the > prefs approach, versus the need to wait for a frame change in the > getSliceNumber approach. I'm trying to set up a very quick response in > the UI to a keystroke, but need to know whether the stack is currently > animated before choosing which actions to perform. It would be best, I > think, if a macro command could directly return the current value of > StackWindow.getAnimate(). Obviously this means work for Wayne, but I > think it would be useful. The is("animated") macro function, added in the 1.44g daily build, can be used to detect if a stack is currently animated. -wayne > On 9/12/10 3:35 p.m., Jerome Mutterer wrote: >> Bill, Ved, >> >> The following macro retrieves the animation state of the current stack using >> a javascript call. The state is returned using the built-in preferences >> mechanism, because the eval() macro function cannot return a value. >> >> s="Prefs.set('is.animated',WindowManager."+ >> "getCurrentImage().getWindow()."+ >> "getAnimate());"; >> eval("script",s) >> a = call ('ij.Prefs.get','is.animated',false); >> print ("animated: "+a); >> >> >> Jerome >> >> On Sat, Sep 11, 2010 at 12:25 AM, Ved Sharma<[hidden email]> wrote: >> >>> Hi Bill, >>> >>> You can try the following code. You might have to adjust the wait time, >>> depending on the your stack size and speed. >>> >>> ------------------------------------ >>> a = getSliceNumber(); >>> wait(1000); >>> b = getSliceNumber(); >>> >>> if(a!=b) >>> print("Stack is animated."); >>> else >>> print("Stack is not animated."); >>> ------------------------------------- >>> >>> Ved >>> |
Thanks for the amazingly quick response!
Bill On 9/13/10 2:08 PM, Rasband, Wayne (NIH/NIMH) [E] wrote: > On Sep 12, 2010, at 9:01 PM, Bill Mohler wrote: > >> Jerome, Ved,& Wayne >> >> Thanks for your advice. I guess I'll have to experiment to find out how >> much lag there might be in the disk-access required (I think) for the >> prefs approach, versus the need to wait for a frame change in the >> getSliceNumber approach. I'm trying to set up a very quick response in >> the UI to a keystroke, but need to know whether the stack is currently >> animated before choosing which actions to perform. It would be best, I >> think, if a macro command could directly return the current value of >> StackWindow.getAnimate(). Obviously this means work for Wayne, but I >> think it would be useful. > The is("animated") macro function, added in the 1.44g daily build, can be used to detect if a stack is currently animated. > > -wayne > >> On 9/12/10 3:35 p.m., Jerome Mutterer wrote: >>> Bill, Ved, >>> >>> The following macro retrieves the animation state of the current stack using >>> a javascript call. The state is returned using the built-in preferences >>> mechanism, because the eval() macro function cannot return a value. >>> >>> s="Prefs.set('is.animated',WindowManager."+ >>> "getCurrentImage().getWindow()."+ >>> "getAnimate());"; >>> eval("script",s) >>> a = call ('ij.Prefs.get','is.animated',false); >>> print ("animated: "+a); >>> >>> >>> Jerome >>> >>> On Sat, Sep 11, 2010 at 12:25 AM, Ved Sharma<[hidden email]> wrote: >>> >>>> Hi Bill, >>>> >>>> You can try the following code. You might have to adjust the wait time, >>>> depending on the your stack size and speed. >>>> >>>> ------------------------------------ >>>> a = getSliceNumber(); >>>> wait(1000); >>>> b = getSliceNumber(); >>>> >>>> if(a!=b) >>>> print("Stack is animated."); >>>> else >>>> print("Stack is not animated."); >>>> ------------------------------------- >>>> >>>> Ved >>>> -- William A. Mohler Associate Professor Dept. of Genetics and Developmental Biology University of Connecticut Health Center *Physical Address:*** Room R1159 Cell and Genome Sciences Building 400 Farmington Ave. Farmington, CT *Mail Address:* MC-6403 263 Farmington Ave. Farmington, CT 06030-6403 [hidden email] <mailto:[hidden email]> *Mobile: (860) 985-2719* skype: wmohler Office: (860) 679-1833, room R1159 Lab: (860) 679-1834, room R1265 Fax: (314) 689-1833 http://genetics.uchc.edu/Faculty/assoc_professors/mohler.html P Think before you print |
Free forum by Nabble | Edit this page |