Dear List, I'm starting to write a macro that will need to get a
string with the name of an Roi selected from the Roi Manager but I have no idea how to get the name. Could anyone give me a hint? Cheers, Luciano |
Luciano,
Using jython and the Jython Interpreter, make sure the Roi Manager is the last selected window and then simply type: rm = WindowManager.getFrontWindow() roi_names = rm.getComponents()[0].getItems() for r in roi_names: print r 0160-0416 0211-0369 The last two lines of numbers are the two names of the rois in the Roi Manager. -- Albert Cardona Molecular Cell Developmental Biology University of California Los Angeles Tel +1 310 2067376 http://www.pensament.net/java/ http://www.mcdb.ucla.edu/Research/Hartenstein/ |
Dear Albert,
Many thanks for your answer on how to get the ROI names from RoiManager, I'm new to Jython so it will take me a while to figure out how it works but it is probably worth it. By the way, I tried to install the Open Sequentially as Stack plugin but I couldn't make it work in my system (Windows XP Pro SP2) with SPE files and some tiff files. One of the error messages I got for the tiff files was: java.lang.ArrayIndexOutOfBoundsException: -1 at Open_sequentially_as_stack.run(Open_sequentially_as_stack.java:74) at ij.IJ.runUserPlugIn(IJ.java:271) at ij.IJ.runPlugIn(IJ.java:115) at ij.Executer.runPlugIn(Executer.java:169) at ij.Executer.runCommand(Executer.java:131) at ij.Executer.run(Executer.java:63) at java.lang.Thread.run(Thread.java:595) For the SPE files I got a message box stating that it couldn't read the first image and that it couldn't get the size of it. Is this because the plugin doesn't work with SPE files? Best, Luciano At 12:17 PM 11/15/2005, you wrote: >Luciano, > >Using jython and the Jython Interpreter, make sure the Roi Manager is >the last selected window and then simply type: > >rm = WindowManager.getFrontWindow() >roi_names = rm.getComponents()[0].getItems() >for r in roi_names: > print r > >0160-0416 >0211-0369 > >The last two lines of numbers are the two names of the rois in the Roi >Manager. > >-- >Albert Cardona >Molecular Cell Developmental Biology >University of California Los Angeles >Tel +1 310 2067376 ><http://www.pensament.net/java/>http://www.pensament.net/java/ >http://www.mcdb.ucla.edu/Research/Hartenstein/ |
Luciano,
The plugin "Open sequentially as stack" will only open the kind of images that the Opener class can, which do not include the SPE files. I don't know how your SPE files are opened; if it's a plugin, or even some settings in the "Import/Raw...", you can call it from within a customized version of the "Open sequentially as stack" plugin. Look for the line: Opener o = new Opener(); and replace the ImagePlus imp = o.openImage(dir_name, first_item.name); by whatever method opens the SPE file into an ImagePlus. About jython, anything that can be done with it can also be done on the Java side, but it would took much more code to acomplish the same thing. For example in jython downcasting is automatic, so in the ROI Manager example > roi_names = rm.getComponents()[0].getItems() one can call the method getItems() from class java.awt.List over a java.awt.Component, because such Component instance is but a List that has been stored as a Component. This is because python stores class identity in the object itself, not in the name used to refer to it. The main issue with using jython/python is that it becomes so convenient one doesn't want to program in any clunky languages such as java anymore. Good luck with that! Albert |
Free forum by Nabble | Edit this page |