|
Hello,
I am trying to find some documentation about calling several ImageJ functions (from the Macro interpreter) like - File.open() - getNumber() - roiManager("...") in a beanshell script, after importing ij.* and using a 'IJ.run()' syntax. But I couldn't get anything to work. I figured that a way of doing this would be to call an imageJ macro from the script (IJ.run(macro)), but I couldn't manage to pass any argument to that macro. Any thought? Thank you |
|
Hi Mael,
> I am trying to find some documentation about calling several ImageJ > functions (from the Macro interpreter) like > - File.open() > - getNumber() > - roiManager("...") > in a beanshell script, after importing ij.* and using a 'IJ.run()' > syntax. > But I couldn't get anything to work. The "IJ.run()" syntax will only work for commands in the macro language that use the "run" method. In Beanshell, you have direct access to the ImageJ functions, i.e., you do not have to use macro commands. So, you can write: import ij.*; IJ.open(); nn = IJ.getNumber("Hello", 1); roim = new ij.plugin.frame.RoiManager(); If you really do want to use the ImageJ macro language, you will have to construct the macro in a string and then invoke the macro runner: import ij.*; myMacro="open(); "; n = new ij.macro.MacroRunner(myMacro); However, you will then need to figure out how to escape quotes in the macro arguments. I am not sure how to do that. Hope this helps. Nico > > I figured that a way of doing this would be to call an imageJ macro > from the > script (IJ.run(macro)), but I couldn't manage to pass any argument > to that > macro. > > Any thought? > > Thank you > -- > View this message in context: http://n2.nabble.com/Beanshell-script-and-imageJ-macros-tp4555033p4555033.html > Sent from the Micro-Manager mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as > DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > micro-manager-general mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/micro-manager-general ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
|
Hello,
Thank you for your help, I've been re-writing the macro in beanshell script, and everything works fine except the IJ.getNumber() function. I have time = IJ.getNumber("time", 100); When I run the script, the dialog box is displayed but clicking the "ok" button on the box stops the script and returns a general error. Thanks again |
|
Administrator
|
> Thank you for your help, I've been re-writing the macro in beanshell script,
> and everything works fine except the IJ.getNumber() function. > I have time = IJ.getNumber("time", 100); > When I run the script, the dialog box is displayed but clicking the "ok" > button on the box stops the script and returns a general error. The general error is most likely caused by one of the next lines in your script. The line on which the error occurs is highlighted in the editor. The script: import ij.*; time = IJ.getNumber("time", 100); executes without errors for me. Best, Nico ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
|
In reply to this post by Mael
Hi Mael,
You need to 'import' the ij package. The following script runs OK import ij.IJ; time = IJ .getNumber ( "time" , 100 ); Best Regards, Karl Hoover ________________________________________ From: Mael [[hidden email]] Sent: Friday, February 12, 2010 09:14 To: [hidden email] Subject: Re: [micro-manager-general] Beanshell script and imageJ macros Hello, Thank you for your help, I've been re-writing the macro in beanshell script, and everything works fine except the IJ.getNumber() function. I have time = IJ.getNumber("time", 100); When I run the script, the dialog box is displayed but clicking the "ok" button on the box stops the script and returns a general error. Thanks again -- View this message in context: http://n2.nabble.com/Beanshell-script-and-imageJ-macros-tp4555033p4562291.html Sent from the Micro-Manager mailing list archive at Nabble.com. ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
|
Thank you for your help,
I had the line import ij.* but apparently the problem was that I declared "time" as a double. |
|
In reply to this post by Nico Stuurman-4
Dear All,
Now I finished one script to take a lot of XY pictures grid and save it in the same folder, and once the script finished I can make a montage with one ImageJ macro. After search on Micro-Manager list I found this message but I need quotes on the macro to process the pictures and it does not work like Nico Stuurman said.
Can I import a very large image sequence with one Script to one stack file? run("Image Sequence...", "open=c:\\temp\\num0.jpg number=1200 starting=1 increment=1 scale=50 file=[] or=[] sort"); With this stack file I can made a full-montage with "ImageJ->Image->Stack->Make Montage". How Can I include this ImageJ-Macro on a beanshell script? run("Make Montage...", "columns=30 rows=40 scale=0.25 first=1 last=1200 increment=1 border=0 font=12"); Best Regards, F.Xavier Gomez ------------------------------------------------------------------------------ Automate Storage Tiering Simply Optimize IT performance and efficiency through flexible, powerful, automated storage tiering capabilities. View this brief to learn how you can reduce costs and improve performance. http://p.sf.net/sfu/dell-sfdev2dev _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
|
Good time of the day,
I've encountered a slightly different problem: I'd like to get some of the results from the Results table or just any value that is calculated in a macro (write it to buffer in macro - read from buffer in beanshell?). Does anyone know if there's a chance to do any of these? I'm trying to get maxima in the predefined ROI during continuous acquisition in each image, so I started with the following script (just two snaps): ------------ import *; int[] x1={1};int[] y1={1};int[] dx1={1};int[] dy1={1}; int[] x2={1};int[] y2={1};int[] dx2={1};int[] dy2={1}; gui.snapSingleImage(); mmc.getROI(x1,y1,dx1,dy1); img=new ImagePlus(); img=IJ.getImage(); int byteDepth = img.getBytesPerPixel(); new WaitForUserDialog("Select ROI").show(); mmc.getROI(x2,y2,dx2,dy2); gui.snapSingleImage(); mmc.setROI(x2[0],y2[0],dx2[0],dy2[0]); ij.IJ.run("Measure"); max = ij.IJ.getResult("Max",1); gui.message("Max"+max); ------------ But all it returns is a general error at ij.IJ.getResult(). Would really appreciate if anyone has any hints on that! |
|
Hi,
There is no method "ij.IJ.getResult()" so I modified your bean shell script. The attached bean shell script works on my computer (tested inside MM 1.4) Best regards, Karl Hoover ________________________________________ From: Zhanna [[hidden email]] Sent: Monday, May 16, 2011 08:41 To: [hidden email] Subject: Re: [micro-manager-general] Beanshell script and imageJ macros Good time of the day, I've encountered a slightly different problem: I'd like to get some of the results from the Results table or just any value that is calculated in a macro (write it to buffer in macro - read from buffer in beanshell?). Does anyone know if there's a chance to do any of these? I'm trying to get maxima in the predefined ROI during continuous acquisition in each image, so I started with the following script (just two snaps): ------------ import *; int[] x1={1};int[] y1={1};int[] dx1={1};int[] dy1={1}; int[] x2={1};int[] y2={1};int[] dx2={1};int[] dy2={1}; gui.snapSingleImage(); mmc.getROI(x1,y1,dx1,dy1); img=new ImagePlus(); img=IJ.getImage(); int byteDepth = img.getBytesPerPixel(); new WaitForUserDialog("Select ROI").show(); mmc.getROI(x2,y2,dx2,dy2); gui.snapSingleImage(); mmc.setROI(x2[0],y2[0],dx2[0],dy2[0]); ij.IJ.run("Measure"); max = ij.IJ.getResult("Max",1); gui.message("Max"+max); ------------ But all it returns is a general error at ij.IJ.getResult(). Would really appreciate if anyone has any hints on that! -- View this message in context: http://micro-manager.3463995.n2.nabble.com/Beanshell-script-and-imageJ-macros-tp4555033p6369155.html Sent from the Micro-Manager mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
|
Hello Karl,
thank you very much for the help! I have one more question: is there any possibility to let the beanshell continue with the script only after the macro execution - otherwise there's a problem of having nothing in the Results table, or no Results table at all (there is actually one created in beanshell, and after some time appears another)? In the macro I have a waitForUser dialog, to let the user choose ROI, which may take some time. I've tried out to make two wait dialogs (or one) both in beanshell and macro: one to wait for user, another to wait for macro, but apparantly it's not the way it works. Also I'm trying to make a dialog with buttons, one of which would call for macro and another lets the bsh script to continue, but there should be a more elegant way to get the script to know that macro has done its job. Is there such? Thanks a lot in advance! |
|
I think I figured out how to make it - use mmc.setROI(x[0],y[0],dx[0],dy[0]) in beanshell and getSelectionBounds(x,y,dx,dy) in macro; during macro execution use gui.sleep(intervalMs) - not very precise timing, but at least something.
But if anyone has ideas on how to get beanshell script to know that macro has finished, would be great! |
|
In reply to this post by Hoover, Karl
Hi,
I have also been having problems trying to get results from the ImageJ results table via a beanshell script in micromanager... Would you be able to send me the beanshell script you previously attached so I can see how you went about doing this? Richard |
|
Administrator
|
On Nov 11, 2011, at 7:03 AM, Richard Wheeler wrote: > I have also been having problems trying to get results from the ImageJ > results table via a beanshell script in micromanager... Would you be able to > send me the beanshell script you previously attached so I can see how you > went about doing this? > - > View this message in context: http://micro-manager.3463995.n2.nabble.com/Beanshell-script-and-imageJ-macros-tp4555033p6985648.html To understand what you were talking about, I followed the link above and found the script you are looking for there: http://micro-manager.3463995.n2.nabble.com/attachment/6369633/0/z.bsh Best, Nico ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
|
Ah, excellent, thank you. Sorry I'm still getting used to this mailing list setup.
Richard > From: [hidden email] > Date: Fri, 11 Nov 2011 08:56:54 -0800 > To: [hidden email] > Subject: Re: [micro-manager-general] Beanshell script and imageJ macros > > > On Nov 11, 2011, at 7:03 AM, Richard Wheeler wrote: > > > I have also been having problems trying to get results from the ImageJ > > results table via a beanshell script in micromanager... Would you be able to > > send me the beanshell script you previously attached so I can see how you > > went about doing this? > > - > > View this message in context: http://micro-manager.3463995.n2.nabble.com/Beanshell-script-and-imageJ-macros-tp4555033p6985648.html > > To understand what you were talking about, I followed the link above and found the script you are looking for there: > > http://micro-manager.3463995.n2.nabble.com/attachment/6369633/0/z.bsh > > Best, > > Nico > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Save $700 by Nov 18 > Register now > http://p.sf.net/sfu/rsa-sfdev2dev1 > _______________________________________________ > micro-manager-general mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/micro-manager-general ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ micro-manager-general mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/micro-manager-general |
| Powered by Nabble | See how NAML generates this page |
