set default parameters in dialog Plugin and get used parameters

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

set default parameters in dialog Plugin and get used parameters

Emanuele Martini
Hi to all,
i searched for this topic, but unfortunately I hadn't find reply.
I'm programming in jython.
I have two questions:
1) How can I setup some default parameters in the dialog box of existing plugin (without launch the plugin).
Specifically, I want to setup the dialog box of Find Maxima plugin with noise 150 and output Single Points, and i want to define the binary morphologically operation using the Options plugin with iteration = 2 and type Dilation.

2) the second question is how can I store, after the user press ok and launch these plugins, the parameters actually used by the user.

Thank you,
have a nice day
Emanuele Martini
imaging IFOM campus
Image Analyst @Ifom-IEO research campus -MI-
Reply | Threaded
Open this post in threaded view
|

Re: set default parameters in dialog Plugin and get used parameters

Rasband, Wayne (NIH/NIMH) [E]
On Jun 27, 2014, at 10:04 AM, Emanuele Martini wrote:

> Hi to all,
> i searched for this topic, but unfortunately I hadn't find reply.
> I'm programming in jython.
> I have two questions:
> 1) How can I setup some default parameters in the dialog box of existing
> plugin (without launch the plugin).
> Specifically, I want to setup the dialog box of Find Maxima plugin with
> noise 150 and output Single Points, and i want to define the binary
> morphologically operation using the Options plugin with iteration = 2 and
> type Dilation.

Show the dialog in the script and then call the plugin. Here is a JavaScript example that calls the MaximumFinder plugin:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  types = ["Single Points", "Maxima Within Tolerance", "Segmented Particles",
     "Point Selection", "List", "Count"];
  output = 0;
  noise = 150;
  gd = new GenericDialog("Find Maxima");
  gd.addChoice("Type:", types, output);
  gd.addNumericField("Tolerance:", noise, 0);
  gd.showDialog();
  output = gd.getNextChoiceIndex();
  noise = gd.getNextNumber();
  if (!gd.wasCanceled()) {
     mf = new MaximumFinder();
     ip = mf.findMaxima(imp.getProcessor(), noise, 0, output, false, false);
     if (ip!=null)
        new ImagePlus("Points", ip).show();
  };

-wayne

>
> 2) the second question is how can I store, after the user press ok and
> launch these plugins, the parameters actually used by the user.
>
> Thank you,
> have a nice day
> Emanuele Martini
> imaging IFOM campus
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/set-default-parameters-in-dialog-Plugin-and-get-used-parameters-tp5008470.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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

Re: set default parameters in dialog Plugin and get used parameters

Emanuele Martini
This post was updated on .
----------------------------------
Show the dialog in the script and then call the plugin. Here is a JavaScript example that calls the MaximumFinder plugin:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  types = ["Single Points", "Maxima Within Tolerance", "Segmented Particles",
     "Point Selection", "List", "Count"];
  output = 0;
  noise = 150;
  gd = new GenericDialog("Find Maxima");
  gd.addChoice("Type:", types, output);
  gd.addNumericField("Tolerance:", noise, 0);
  gd.showDialog();
  output = gd.getNextChoiceIndex();
  noise = gd.getNextNumber();
  if (!gd.wasCanceled()) {
     mf = new MaximumFinder();
     ip = mf.findMaxima(imp.getProcessor(), noise, 0, output, false, false);
     if (ip!=null)
        new ImagePlus("Points", ip).show();
  };

-wayne
-----------------------------------------------------------


Thank you, but i'm searching for a solution that permits the user to use the preview button.
So i want only to put some default option in the original dialog box of the plugin.
Ideally, I would like a solution like that :
IJ.run ("find maxima","noise=150, output=[single points]") that only open the dialog box with these default parameters, then wait for the user adjustment with preview button and after the user click OK i would like to store the parametr really used by the user.
Maybe, the only solution is to create a "fake" dialog box with preview button ( and in that case i really appreciate you if you could post here an example of a simple plugin with a dialog box with preview button) but I really hope that there is a more simpler solution.
Thanking you for your attention,
have a nice weekend
Emanuele

Image Analyst @Ifom-IEO research campus -MI-