Hello everyone,
I would like to do the following: - open an image - make a selection automatically - manually alter the automatic selection - measure some variables on this ROI - save the measurements and quit all that with as little user interaction as possible. So I wrote macro (because macros are easy!) that gets executed using the -eval command line switch of ImageJ. What I am currently stuck on is how to "pause" the execution of the macro while the user is tweaking the ROI and resume it once (s)he is finished. I tried popping up a dialog to notify the user but the dialog windows are modal so the user cannot get to the image when the dialog is up. Could you please suggest me an alternative route? Is that something that would be better tackled with a plugin? Thank you very much in advance. Code of the (very simple) macro: ------------ run("Image Sequence...", "open=00001.JPG number=1 starting=1 increment=1 scale=100 file=[] or=[] sort"); makeOval(402, 99, 1137, 1137); Dialog.create("Selection"); Dialog.addMessage("If necessary, alter the selection to fit the aquarium better.\nPress OK when you are done"); Dialog.show() run("Set Measurements...", " centroid perimeter redirect=None decimal=3"); run("Measure"); saveAs("Measurements", "Results.txt"); run("Quit"); ------------ Jean-Olivier Irisson --- Division of Applied Marine Physics Rosenstiel School of Marine and Atmospheric Sciences 4600 Rickenbacker Causeway, Miami, Florida 33149-1098 +1 786 342 3410 http://jo.irisson.free.fr/work/ |
Hello Jean-Olivier,
Just add the following line where you need to pause the macro: waitForUser( "Pause","Some \n Dialog"); The macro will pause until you press "OK". I hope it helps Gabriel Lapointe JiHO wrote: > Hello everyone, > > I would like to do the following: > - open an image > - make a selection automatically > - manually alter the automatic selection > - measure some variables on this ROI > - save the measurements and quit > all that with as little user interaction as possible. > > So I wrote macro (because macros are easy!) that gets executed using > the -eval command line switch of ImageJ. What I am currently stuck on > is how to "pause" the execution of the macro while the user is > tweaking the ROI and resume it once (s)he is finished. I tried popping > up a dialog to notify the user but the dialog windows are modal so the > user cannot get to the image when the dialog is up. > > Could you please suggest me an alternative route? Is that something > that would be better tackled with a plugin? > > Thank you very much in advance. > > > Code of the (very simple) macro: > > ------------ > run("Image Sequence...", "open=00001.JPG number=1 starting=1 > increment=1 scale=100 file=[] or=[] sort"); > > makeOval(402, 99, 1137, 1137); > > Dialog.create("Selection"); > Dialog.addMessage("If necessary, alter the selection to fit the > aquarium better.\nPress OK when you are done"); > Dialog.show() > > run("Set Measurements...", " centroid perimeter redirect=None > decimal=3"); > > run("Measure"); > > saveAs("Measurements", "Results.txt"); > > run("Quit"); > ------------ > > Jean-Olivier Irisson > --- > Division of Applied Marine Physics > Rosenstiel School of Marine and Atmospheric Sciences > 4600 Rickenbacker Causeway, Miami, Florida 33149-1098 > +1 786 342 3410 > http://jo.irisson.free.fr/work/ > |
On 2009-April-01 , at 19:50 , Gabriel Lapointe wrote:
> Just add the following line where you need to pause the macro: > waitForUser( "Pause","Some \n Dialog"); > > The macro will pause until you press "OK". > I hope it helps Thank you very much. That is exactly what I need. Somehow I missed it when reading the macro manual. Thanks again. Jean-Olivier Irisson --- Division of Applied Marine Physics Rosenstiel School of Marine and Atmospheric Sciences 4600 Rickenbacker Causeway, Miami, Florida 33149-1098 +1 786 342 3410 http://jo.irisson.free.fr/work/ |
In reply to this post by JiHO-2
Hello.
Depending on the type of image it is usually possible do some image processing and subsequent segmentation to choose appropriate place for the ROI and than measure variables in the RAW image. All this in macro so user interaction could be avoided. I may help you to write the macro, but the example of image and required data would be needed. Feel free to write me off-list, if you are interested in. Sincerley Ondrej Sebesta JiHO napsal(a): > Hello everyone, > > I would like to do the following: > - open an image > - make a selection automatically > - manually alter the automatic selection > - measure some variables on this ROI > - save the measurements and quit > all that with as little user interaction as possible. > > So I wrote macro (because macros are easy!) that gets executed using > the -eval command line switch of ImageJ. What I am currently stuck on > is how to "pause" the execution of the macro while the user is > tweaking the ROI and resume it once (s)he is finished. I tried popping > up a dialog to notify the user but the dialog windows are modal so the > user cannot get to the image when the dialog is up. > > Could you please suggest me an alternative route? Is that something > that would be better tackled with a plugin? > > Thank you very much in advance. > > > Code of the (very simple) macro: > > ------------ > run("Image Sequence...", "open=00001.JPG number=1 starting=1 > increment=1 scale=100 file=[] or=[] sort"); > > makeOval(402, 99, 1137, 1137); > > Dialog.create("Selection"); > Dialog.addMessage("If necessary, alter the selection to fit the > aquarium better.\nPress OK when you are done"); > Dialog.show() > > run("Set Measurements...", " centroid perimeter redirect=None > decimal=3"); > > run("Measure"); > > saveAs("Measurements", "Results.txt"); > > run("Quit"); > ------------ > > Jean-Olivier Irisson > --- > Division of Applied Marine Physics > Rosenstiel School of Marine and Atmospheric Sciences > 4600 Rickenbacker Causeway, Miami, Florida 33149-1098 > +1 786 342 3410 > http://jo.irisson.free.fr/work/ > |
In reply to this post by Gabriel Lapointe
I am beginning (again) to learn ImageJ by creating simple macros and
plugins. However, when I created the following macro using the Recorder, and converted it to a Plugin using the Edit>Convert to Plugin command, the resulting plugin fails to compile. The IJ.roiManager("Add") and IJ.roiManager("Label") lines result in "cannot find symbol" errors Why is that? Is there a better way to perform those functions in a Plugin? (I'm using ImageJ 1.42k with Java 1.6) Recorded macro: run("ROI Manager..."); makeRectangle(1788, 1392, 489, 249); roiManager("Add"); roiManager("Label"); Converted to Plugin: import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; public class TestroiManager_ implements PlugIn { public void run(String arg) { IJ.run("ROI Manager..."); IJ.makeRectangle(1788, 1392, 489, 249); IJ.roiManager("Add"); IJ.roiManager("Label"); } } Thanks, Chuck ========================= Charles R. Parker, Ph.D. Research Aquatic Biologist U. S. Geological Survey 1316 Cherokee Orchard Road Gatlinburg, TN 37738 E-mail: [hidden email] Phone: (865) 436-1704 |
Free forum by Nabble | Edit this page |