run("Rotate... ") with variable - only works once - why?

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

run("Rotate... ") with variable - only works once - why?

Michael Weber-4
Dear IJ list,

I am trying to rotate a stack step by step using a macro. The angle
depends on the orientation of the sample which gets measured and stored in
the "Result" table:

a = getResult("Angle", 0)
selectWindow("stack")
run("Rotate... ", "angle=a grid=1 interpolation=Bicubic fill enlarge stack");

The first step works fine. But if I want to apply exactly the same
rotation again, just in the next line:

run("Rotate... ", "angle=a grid=1 interpolation=Bicubic fill enlarge stack");

IJ complains:

"Macro error: Numeric value expected in run() function. Dialog box title:
'Rotate' key: 'angle (degrees):' Value or variable name: 'a'"

Why? Any ideas? It works in the first run. Am I missing something
fundamental? I also tried the TJ Rotate plugin, but that does not seem to
accept variables at all.

cheers,
Michael


_____________

Michael Weber, B.Sc.
Tomancak lab
Max Planck Institute of
Molecular Cell Biology and Genetics
Pfotenhauerstrasse 108
01307 Dresden

Imaging Facility Network
https://ifn.mpi-cbg.de
Reply | Threaded
Open this post in threaded view
|

Re: run("Rotate... ") with variable - only works once - why?

Gabriel Landini
On Thursday 04 Mar 2010  13:55:18 Michael Weber wrote:

> I am trying to rotate a stack step by step using a macro. The angle
> depends on the orientation of the sample which gets measured and stored in
> the "Result" table:
>
> a = getResult("Angle", 0)
> selectWindow("stack")
> run("Rotate... ", "angle=a grid=1 interpolation=Bicubic fill enlarge
> stack");
>
> The first step works fine. But if I want to apply exactly the same
> rotation again, just in the next line:
>

>
try

run("Rotate... ", "angle="+a+" grid=1 interpolation=Bicubic fill enlarge
stack");

or

run("Rotate... ", "angle=&a grid=1 interpolation=Bicubic fill enlarge stack");

You put the name of the variable within quotations and that is taken as a
string, not a variable name.
G.
Reply | Threaded
Open this post in threaded view
|

Re: run("Rotate... ") with variable - only works once - why?

dscho
In reply to this post by Michael Weber-4
Hi,

On Thu, 4 Mar 2010, Michael Weber wrote:

> a = getResult("Angle", 0)
> selectWindow("stack")
> run("Rotate... ", "angle=a grid=1 interpolation=Bicubic fill enlarge stack");

The second parameter is a string, but you want to use the _value_ of the
variable "a" rather than the name. So you have to concatenate it:

        "angle=" + a + " grid=1 interpolation=Bicubic fill enlarge stack"

Ciao,
Johannes