command default settings in a macro

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

command default settings in a macro

Fco. Javier Diez Guerra
Dear listers,

I would like to know how default settings for a given command can be
changed within a macro.

For example, if I run the macro:

     run("Rotate... ");

a window appears with the following default values.

angle = 15 º
grid lines = 1
Interpolation = bilinear
Fill with bacground color = inactive
Enlarge image = inactive

What I am looking for are the statements I have to include in the macro
so that when I run it, a window appears with the following default values?

angle = 0.4 º
grid lines = 20
Interpolation = bicubic
Fill with bacground color = inactive
Enlarge image = inactive

I`ve been browsing to find an answer but could not find it.

Thanks in advance for your input.

Javier


--
Fco. Javier Diez-Guerra, PhD

Servicio de Microscopía Confocal
Centro de Biologia Molecular Severo Ochoa
C/ Nicolás Cabrera, 1
Campus de Cantoblanco
28049 Madrid
SPAIN

Tel     +34 91 196 4612
e-mail: [hidden email]


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: command default settings in a macro

Gabriel Landini
On Sunday, 22 September 2019 19:18:30 BST [hidden email] wrote:
> I would like to know how default settings for a given command can be
> changed within a macro.

Hi, run the Macro Recorder before calling the command, and it will show you
how you call all the parameters in the command dialog.
Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: command default settings in a macro

Fco. Javier Diez Guerra
Dear Gabriel,

Thanks for your input.

I have already tried what you suggest:

run("Rotate... ", "angle=0.4 grid=20 interpolation=Bicubic");

However, in this case, the command is executed right away.

On the other hand, when the macro

run("Rotate... ");

is run, the Rotate command is not executed. The macro just opens a
window that lets you modify the settings before excuting the command.

I have a set with a lot of images to be rotated. Each one needs a
different angle of rotation, but the same grid size and interpolation
settings. What I am trying to avoid is to change the grid size and
interpolation settings every time I open a new image, before finding the
right rotation angle and running the Rotate command. The rotation angle
needs to be manually adjusted for each individual image.

Best

Javier


El 22/09/2019 a las 22:33, Gabriel Landini escribió:

> On Sunday, 22 September 2019 19:18:30 BST [hidden email] wrote:
>> I would like to know how default settings for a given command can be
>> changed within a macro.
> Hi, run the Macro Recorder before calling the command, and it will show you
> how you call all the parameters in the command dialog.
> Cheers
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: command default settings in a macro

Stein Rørvik
As you already found out, you must either call the command with parameters which executes it right away, or call it without parameters which opens the dialog and allows you to do the rotation in an interactive mode. Subsequent calls will remember the chosen interpolation and grid settings. So just use run("Rotate... "); in your macro and the dialog should appear and allow you to adjust the rotation as needed. When I tested this, all settings except the "Preview" checkbox was remembered from call to call. A restart of ImageJ reverts to the default settings. A dummy call with the parameters set will result in new "default" values being set for your session.

So you can do something like this pseudocode:

{open sample image}
run("Rotate... ", "angle=0.4 grid=20 interpolation=Bicubic");
close; //the default values for Rotate... are now as specified above
do {
        {open image to be rotated}
        run("Rotate... "); //click the preview checkbox and adjust rotation
} until (finished);

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of F Javier Diez Guerra
Sent: 22. september 2019 23:22
To: [hidden email]
Subject: Re: command default settings in a macro

Dear Gabriel,

Thanks for your input.

I have already tried what you suggest:

run("Rotate... ", "angle=0.4 grid=20 interpolation=Bicubic");

However, in this case, the command is executed right away.

On the other hand, when the macro

run("Rotate... ");

is run, the Rotate command is not executed. The macro just opens a window that lets you modify the settings before excuting the command.

I have a set with a lot of images to be rotated. Each one needs a different angle of rotation, but the same grid size and interpolation settings. What I am trying to avoid is to change the grid size and interpolation settings every time I open a new image, before finding the right rotation angle and running the Rotate command. The rotation angle needs to be manually adjusted for each individual image.

Best

Javier


El 22/09/2019 a las 22:33, Gabriel Landini escribió:

> On Sunday, 22 September 2019 19:18:30 BST [hidden email] wrote:
>> I would like to know how default settings for a given command can be
>> changed within a macro.
> Hi, run the Macro Recorder before calling the command, and it will show you
> how you call all the parameters in the command dialog.
> Cheers
>
> Gabriel
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: command default settings in a macro

Fco. Javier Diez Guerra
Dear Stein,

I understand, many thanks for the clever settlement.

I figure then that the macro can run a first Rotate command with the
desired settings and the angle fixed to 0 (this should do nothing) and a
second Rotate command without parameters, to allow interaction:

run("Rotate... ", "angle=0 grid=20 interpolation=Bicubic");
run("Rotate... ");

In this way, I'd only need to activate preview and find the right angle.

Javier


El 23/09/2019 a las 10:53, Stein Rørvik escribió:

> As you already found out, you must either call the command with parameters which executes it right away, or call it without parameters which opens the dialog and allows you to do the rotation in an interactive mode. Subsequent calls will remember the chosen interpolation and grid settings. So just use run("Rotate... "); in your macro and the dialog should appear and allow you to adjust the rotation as needed. When I tested this, all settings except the "Preview" checkbox was remembered from call to call. A restart of ImageJ reverts to the default settings. A dummy call with the parameters set will result in new "default" values being set for your session.
>
> So you can do something like this pseudocode:
>
> {open sample image}
> run("Rotate... ", "angle=0.4 grid=20 interpolation=Bicubic");
> close; //the default values for Rotate... are now as specified above
> do {
> {open image to be rotated}
> run("Rotate... "); //click the preview checkbox and adjust rotation
> } until (finished);
>
> Stein
>
> -----Original Message-----
> From: ImageJ Interest Group <[hidden email]> On Behalf Of F Javier Diez Guerra
> Sent: 22. september 2019 23:22
> To: [hidden email]
> Subject: Re: command default settings in a macro
>
> Dear Gabriel,
>
> Thanks for your input.
>
> I have already tried what you suggest:
>
> run("Rotate... ", "angle=0.4 grid=20 interpolation=Bicubic");
>
> However, in this case, the command is executed right away.
>
> On the other hand, when the macro
>
> run("Rotate... ");
>
> is run, the Rotate command is not executed. The macro just opens a window that lets you modify the settings before excuting the command.
>
> I have a set with a lot of images to be rotated. Each one needs a different angle of rotation, but the same grid size and interpolation settings. What I am trying to avoid is to change the grid size and interpolation settings every time I open a new image, before finding the right rotation angle and running the Rotate command. The rotation angle needs to be manually adjusted for each individual image.
>
> Best
>
> Javier
>
>
> El 22/09/2019 a las 22:33, Gabriel Landini escribió:
>> On Sunday, 22 September 2019 19:18:30 BST [hidden email] wrote:
>>> I would like to know how default settings for a given command can be
>>> changed within a macro.
>> Hi, run the Macro Recorder before calling the command, and it will show you
>> how you call all the parameters in the command dialog.
>> Cheers
>>
>> Gabriel
>>
>> --
>> 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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: command default settings in a macro

Wayne Rasband-2
In reply to this post by Fco. Javier Diez Guerra
> On Sep 22, 2019, at 2:18 PM, F Javier Diez Guerra <[hidden email]> wrote:
>
> Dear listers,
>
> I would like to know how default settings for a given command can be changed within a macro.

Use the Rotate command with the recorder (Plugins>Macros>Record) running and it will generate the needed code:

  run("Rotate... ", "angle=0.4 grid=20 interpolation=Bicubic”);

These settings will be used the next time you use the Rotate command or run the run("Rotate... “) macro.

-wayne


>
> For example, if I run the macro:
>
>     run("Rotate... ");
>
> a window appears with the following default values.
>
> angle = 15 º
> grid lines = 1
> Interpolation = bilinear
> Fill with bacground color = inactive
> Enlarge image = inactive
>
> What I am looking for are the statements I have to include in the macro so that when I run it, a window appears with the following default values?
>
> angle = 0.4 º
> grid lines = 20
> Interpolation = bicubic
> Fill with bacground color = inactive
> Enlarge image = inactive
>
> I`ve been browsing to find an answer but could not find it.
>
> Thanks in advance for your input.
>
> Javier

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html