Run macros/commands in Plugin

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

Run macros/commands in Plugin

Nikolay
Dear all,

Is it possible to run macros or command sequence from my plugin?
I wrote the acquire plugin and would like to apply some commands.

Thank you.

--
Rogoshchenkov Nikolay

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

Re: Run macros/commands in Plugin

Volker Baecker
Hello,
look at the different run commands of IJ, see:
http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html


|static void| |*run
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#run%28ij.ImagePlus,%20java.lang.String,%20java.lang.String%29>*(ImagePlus
<http://rsbweb.nih.gov/ij/developer/api/ij/ImagePlus.html> imp,
java.lang.String command, java.lang.String options)|
          Runs an ImageJ command using the specified image and options.
|static void| |*run
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#run%28java.lang.String%29>*(java.lang.String command)|

          Runs an ImageJ command.
|static void| |*run
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#run%28java.lang.String,%20java.lang.String%29>*(java.lang.String command,
java.lang.String options)|
          Runs an ImageJ command, with options that are passed to the
GenericDialog and OpenDialog classes.
|static java.lang.String| |*runMacro
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runMacro%28java.lang.String%29>*(java.lang.String macro)|

          Runs the macro contained in the string |macro|.
|static java.lang.String| |*runMacro
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runMacro%28java.lang.String,%20java.lang.String%29>*(java.lang.String macro,
java.lang.String arg)|
          Runs the macro contained in the string |macro|.
|static java.lang.String| |*runMacroFile
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runMacroFile%28java.lang.String%29>*(java.lang.String name)|

          Runs the specified macro file.
|static java.lang.String| |*runMacroFile
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runMacroFile%28java.lang.String,%20java.lang.String%29>*(java.lang.String name,
java.lang.String arg)|
          Runs the specified macro or script file in the current thread.
|static java.lang.Object| |*runPlugIn
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runPlugIn%28ij.ImagePlus,%20java.lang.String,%20java.lang.String%29>*(ImagePlus
<http://rsbweb.nih.gov/ij/developer/api/ij/ImagePlus.html> imp,
java.lang.String className, java.lang.String arg)|
          Runs the specified plugin using the specified image.
|static java.lang.Object| |*runPlugIn
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runPlugIn%28java.lang.String,%20java.lang.String%29>*(java.lang.String className,
java.lang.String arg)|
          Runs the specified plugin and returns a reference to it.
|static java.lang.Object| |*runPlugIn
<http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html#runPlugIn%28java.lang.String,%20java.lang.String,%20java.lang.String%29>*(java.lang.String commandName,
java.lang.String className, java.lang.String arg)|
          Runs the specified plugin and returns a reference to it.


Volker
On 08/11/12 17:20, Nikolay Rogoshchenkov wrote:

> Dear all,
>
> Is it possible to run macros or command sequence from my plugin?
> I wrote the acquire plugin and would like to apply some commands.
>
> Thank you.
>
> --
> Rogoshchenkov Nikolay
>
> --
> 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: Run macros/commands in Plugin

BenTupper
In reply to this post by Nikolay
Hi,

On Nov 8, 2012, at 11:20 AM, Nikolay Rogoshchenkov wrote:

> Dear all,
>
> Is it possible to run macros or command sequence from my plugin?
> I wrote the acquire plugin and would like to apply some commands.
>

Yes, you can run macros from a plugin.  Check out the documentation for IJ.runMacro and IJ.runMacroFile (look in the ij.IJ class documented here http://rsb.info.nih.gov/ij/developer/api/index.html )

Cheers,
Ben



> Thank you.
>
> --
> Rogoshchenkov Nikolay
>
> --
> 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: Run macros/commands in Plugin

mia589
In reply to this post by Volker Baecker
Hi,

I was wondering if someone can help with a related problem.

I've been trying to implement the IJ.run() command in my ImageJ plugin to call upon some ImageJ functions.
However, it doesn't seem to work even though the syntax of my code is correct. When I write the following code to enhance contrast, the IJ.run() command works:

IJ.run("Enhance Contrast");

But when I want to run a denoising command "Despeckle" or use a "Median..." filter the code doesn't initiate any processes. I am writing the code for these as follows:

IJ.run("Despeckle");
IJ.run("Median...");

Similarly, I am also having trouble using the IJ.runPlugIn() command where I get the error message "Class not found" even though the target PlugIn class is in the ImageJ plugin directory.

Your advice would be most appreciated!
Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: Run macros/commands in Plugin

gankaku
Hi Mia,

Your first problem might be related the activation of an image. For simple
IJ-functions it is best and easiest if you record your commands with the
Macro Recorder (>Plugins >Macros > Record...).
Therefore, you need to select "Java" from the dropdown menu to not record
it in the IJ macro language.

In your first case, I would expect something like this:
IJ.run(imp, "Enhance Contrast...", "saturated=0 normalize");

the "imp" makes sure that the enhancement is applied to the ImagePlus you
really want to apply it, so you need to specify the correct one.

The same is true for the "Despeckle" command and so on.
IJ.run(imp, "Despeckle", "");

This might solve the problem.
If you are more familiar with Java you can also implement it directly by
using the respective methods (http://rsbweb.nih.gov/ij/developer/api/).

I can unfortunately not comment on your second "Class not found" problem at
the moment.

Kind regards,
Jan




2014-08-19 17:17 GMT+02:00 mia589 <[hidden email]>:

> Hi,
>
> I was wondering if someone can help with a related problem.
>
> I've been trying to implement the IJ.run() command in my ImageJ plugin to
> call upon some ImageJ functions.
> However, it doesn't seem to work even though the syntax of my code is
> correct. When I write the following code to enhance contrast, the IJ.run()
> command works:
>
> IJ.run("Enhance Contrast");
>
> But when I want to run a denoising command "Despeckle" or use a "Median..."
> filter the code doesn't initiate any processes. I am writing the code for
> these as follows:
>
> IJ.run("Despeckle");
> IJ.run("Median...");
>
> Similarly, I am also having trouble using the IJ.runPlugIn() command where
> I
> get the error message "Class not found" even though the target PlugIn class
> is in the ImageJ plugin directory.
>
> Your advice would be most appreciated!
> Thank you!
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Run-macros-commands-in-Plugin-tp5000744p5009268.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--

CEO: Dr. rer. nat. Jan Brocher
phone:  +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
e-mail: [hidden email]
info: [hidden email]
inquiries: [hidden email]
web: www.biovoxxel.de

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

Re: Run macros/commands in Plugin

mia589
Hi Jan,

Thanks for your reply.

I have also tried your suggested approach of specifying the ImagePlus with no luck. 

With regards to macro recording, would it be possible to record a sequence and then call that sequence using a java command in the plugin code?

I'm trying to create a plugin for imageJ as part of my project and I'm using the Eclipse IDE. I've coupled the ImageJ jar file and source code to the Eclipse build path library. 

If you have any other suggestions I would be extremely grateful.

Many thanks!

On 19 Aug 2014, at 18:34, "gankaku [via ImageJ]" <[hidden email]> wrote:

Hi Mia,

Your first problem might be related the activation of an image. For simple
IJ-functions it is best and easiest if you record your commands with the
Macro Recorder (>Plugins >Macros > Record...).
Therefore, you need to select "Java" from the dropdown menu to not record
it in the IJ macro language.

In your first case, I would expect something like this:
IJ.run(imp, "Enhance Contrast...", "saturated=0 normalize");

the "imp" makes sure that the enhancement is applied to the ImagePlus you
really want to apply it, so you need to specify the correct one.

The same is true for the "Despeckle" command and so on.
IJ.run(imp, "Despeckle", "");

This might solve the problem.
If you are more familiar with Java you can also implement it directly by
using the respective methods (http://rsbweb.nih.gov/ij/developer/api/).

I can unfortunately not comment on your second "Class not found" problem at
the moment.

Kind regards,
Jan




2014-08-19 17:17 GMT+02:00 mia589 <[hidden email]>:

> Hi,
>
> I was wondering if someone can help with a related problem.
>
> I've been trying to implement the IJ.run() command in my ImageJ plugin to
> call upon some ImageJ functions.
> However, it doesn't seem to work even though the syntax of my code is
> correct. When I write the following code to enhance contrast, the IJ.run()
> command works:
>
> IJ.run("Enhance Contrast");
>
> But when I want to run a denoising command "Despeckle" or use a "Median..."
> filter the code doesn't initiate any processes. I am writing the code for
> these as follows:
>
> IJ.run("Despeckle");
> IJ.run("Median...");
>
> Similarly, I am also having trouble using the IJ.runPlugIn() command where
> I
> get the error message "Class not found" even though the target PlugIn class
> is in the ImageJ plugin directory.
>
> Your advice would be most appreciated!
> Thank you!
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Run-macros-commands-in-Plugin-tp5000744p5009268.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>


--

CEO: Dr. rer. nat. Jan Brocher
phone:  +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
e-mail: [hidden email]
info: [hidden email]
inquiries: [hidden email]
web: www.biovoxxel.de

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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Run-macros-commands-in-Plugin-tp5000744p5009270.html
To unsubscribe from Run macros/commands in Plugin, click here.
NAML