Scripts calling scripts with @Parameters

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

Scripts calling scripts with @Parameters

Jan Eglinger
Hi all,

how can I call a script using @Parameters (e.g. @ij.ImagePlus) from
another script? Is this possible already?

I tried the following Javascript:

     // @ij.ImagePlus imp
     // @String name
     // @OUTPUT String result

     result = "Hello, " + name + ", the title is " + imp.getTitle();


and saved it into ./plugins/Print_Title.js
When I run it, the macro recorder records something like:

     IJ.run(imp, "Print Title", "imp=[img[blobs.gif (256x254x1x1x1)]]
name=Jan");


When I now run this (Beanshell) script (with blobs.gif still open):

     import ij.IJ;

     imp = IJ.getImage();
     IJ.run(imp, "Print Title", "imp=[img[blobs.gif (256x254x1x1x1)]]
name=Jan");

the String is initialized correctly, but `imp` seems to be `null`.
(Leaving away the imp=.. yields an error "'imp' is required but unset.")

Is there a way to configure an ImagePlus (or Dataset or File) in this case?

Thx,
Jan

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Scripts calling scripts with @Parameters

Curtis Rueden
Hi Jan,

> Is there a way to configure an ImagePlus (or Dataset or File) in this
> case?

Thanks for reporting this issue!

It is (partially) fixed in:

At the moment, you will have to write:

  imp=blobs.gif

Or:

  imp=-2

(where -2 is the image ID you want)

instead of the string generated by the recorder.

I guess we could make that string (which is what ImagePlus.toString() produces, probably) work as well, if you feel strongly. Though IMO it just clutters the macro.

Regards,
Curtis

On Wed, Aug 26, 2015 at 9:46 AM, Jan Eglinger <[hidden email]> wrote:
Hi all,

how can I call a script using @Parameters (e.g. @ij.ImagePlus) from another script? Is this possible already?

I tried the following Javascript:

    // @ij.ImagePlus imp
    // @String name
    // @OUTPUT String result

    result = "Hello, " + name + ", the title is " + imp.getTitle();


and saved it into ./plugins/Print_Title.js
When I run it, the macro recorder records something like:

    IJ.run(imp, "Print Title", "imp=[img[blobs.gif (256x254x1x1x1)]] name=Jan");


When I now run this (Beanshell) script (with blobs.gif still open):

    import ij.IJ;

    imp = IJ.getImage();
    IJ.run(imp, "Print Title", "imp=[img[blobs.gif (256x254x1x1x1)]] name=Jan");

the String is initialized correctly, but `imp` seems to be `null`. (Leaving away the imp=.. yields an error "'imp' is required but unset.")

Is there a way to configure an ImagePlus (or Dataset or File) in this case?

Thx,
Jan

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Scripts calling scripts with @Parameters

Curtis Rueden
Hi again Jan,

I have now changed the macro recording to generate the correct string, with image title as the value [1]. So when you record your Print Title script, you will now see:

  run("Print Title", "imp=blobs.gif name=Jan");

And executing that line will repeat the action as expected.

These changes will be released and uploaded within the next few days.

Regards,
Curtis


On Wed, Aug 26, 2015 at 5:16 PM, Curtis Rueden <[hidden email]> wrote:
Hi Jan,

> Is there a way to configure an ImagePlus (or Dataset or File) in this
> case?

Thanks for reporting this issue!

It is (partially) fixed in:

At the moment, you will have to write:

  imp=blobs.gif

Or:

  imp=-2

(where -2 is the image ID you want)

instead of the string generated by the recorder.

I guess we could make that string (which is what ImagePlus.toString() produces, probably) work as well, if you feel strongly. Though IMO it just clutters the macro.

Regards,
Curtis

On Wed, Aug 26, 2015 at 9:46 AM, Jan Eglinger <[hidden email]> wrote:
Hi all,

how can I call a script using @Parameters (e.g. @ij.ImagePlus) from another script? Is this possible already?

I tried the following Javascript:

    // @ij.ImagePlus imp
    // @String name
    // @OUTPUT String result

    result = "Hello, " + name + ", the title is " + imp.getTitle();


and saved it into ./plugins/Print_Title.js
When I run it, the macro recorder records something like:

    IJ.run(imp, "Print Title", "imp=[img[blobs.gif (256x254x1x1x1)]] name=Jan");


When I now run this (Beanshell) script (with blobs.gif still open):

    import ij.IJ;

    imp = IJ.getImage();
    IJ.run(imp, "Print Title", "imp=[img[blobs.gif (256x254x1x1x1)]] name=Jan");

the String is initialized correctly, but `imp` seems to be `null`. (Leaving away the imp=.. yields an error "'imp' is required but unset.")

Is there a way to configure an ImagePlus (or Dataset or File) in this case?

Thx,
Jan

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel