combine function of the ROI manager

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

combine function of the ROI manager

SebT
Hello,

I am trying to use the "combine" function of the ROI manager within a macro.
The idea is that I have various ROIs in the manager list and that I want to
merge some of them and add them as new ROIs to the list. The manual way to
do this task is to select the ROIs within the manager (by pressing "Control"
for multi-selection) and to use "combine" followed by "add". I am unable to
make this work in the macro... the "setkeydown" function apparently does not
support the special key "control" and the behavior is not very clear. Any
suggestions?

Regards,
Sébastien
Reply | Threaded
Open this post in threaded view
|

Re: combine function of the ROI manager

Rasband, Wayne (NIH/NIMH) [E]
On Aug 6, 2010, at 6:33 AM, Sebastien Tosi wrote:

> Hello,
>
> I am trying to use the "combine" function of the ROI manager within a macro.
> The idea is that I have various ROIs in the manager list and that I want to
> merge some of them and add them as new ROIs to the list. The manual way to
> do this task is to select the ROIs within the manager (by pressing "Control"
> for multi-selection) and to use "combine" followed by "add". I am unable to
> make this work in the macro... the "setkeydown" function apparently does not
> support the special key "control" and the behavior is not very clear. Any
> suggestions?

This is something that is easier to do in Java or a scripting language. Here is JavaScript that merges the 2nd and 4th ROI on the ROI Manager and adds the merged ROI to the ROI Manager.

  manager = RoiManager.getInstance();
  if (manager==null)
     IJ.error("ROI Manager is not open");
  rois = manager.getRoisAsArray();
  roi1 = new ShapeRoi(rois[1]);
  roi2 = new ShapeRoi(rois[3]);
  combined = roi1.or(roi2);
  manager.addRoi(combined);

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: combine function of the ROI manager

Bill Mohler
Wayne-

Just to be clear, because I have yet to use JavaScript in ImageJ, will
JS code be executed by the Run menu command in a text window in IJ?  Are
there any additional plugins necessary to run JavaScript?

Thanks,
Bill

Rasband, Wayne (NIH/NIMH) [E] wrote:

> On Aug 6, 2010, at 6:33 AM, Sebastien Tosi wrote:
>
>  
>> Hello,
>>
>> I am trying to use the "combine" function of the ROI manager within a macro.
>> The idea is that I have various ROIs in the manager list and that I want to
>> merge some of them and add them as new ROIs to the list. The manual way to
>> do this task is to select the ROIs within the manager (by pressing "Control"
>> for multi-selection) and to use "combine" followed by "add". I am unable to
>> make this work in the macro... the "setkeydown" function apparently does not
>> support the special key "control" and the behavior is not very clear. Any
>> suggestions?
>>    
>
> This is something that is easier to do in Java or a scripting language. Here is JavaScript that merges the 2nd and 4th ROI on the ROI Manager and adds the merged ROI to the ROI Manager.
>
>   manager = RoiManager.getInstance();
>   if (manager==null)
>      IJ.error("ROI Manager is not open");
>   rois = manager.getRoisAsArray();
>   roi1 = new ShapeRoi(rois[1]);
>   roi2 = new ShapeRoi(rois[3]);
>   combined = roi1.or(roi2);
>   manager.addRoi(combined);
>
> -wayne
>
>  
Reply | Threaded
Open this post in threaded view
|

Re: combine function of the ROI manager

SebT
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Thank you Wayne, this works fine. Now I have to find out how to call
javascript from a macro and pass arguments to the script (here basically the
2 indexes of the ROIs to be merged)... what is the best way to do this?

Regards,
Sébastien
Reply | Threaded
Open this post in threaded view
|

Are there any statistics on ImageJ use?

Michael Ellis
In reply to this post by Bill Mohler
Is there any idea floating around in the ether as to how many people  
are using ImageJ and what range of areas it is being applied to?

Are there any stats for how many ImageJ downloads?

What about Java? Apple (the platform I tend to use) seem to be showing  
less enthusiasm for Java. Now Oracle have acquired Sun, does anyone  
have any idea as to the future of Java?

Just questions gnawing at me a little whilst considering how much  
effort to plough into pursuing things with Java and ImageJ.

Michael Ellis
Cambridge, UK
Reply | Threaded
Open this post in threaded view
|

Re: Are there any statistics on ImageJ use?

Gluender-4
Michael,

...only an attempt to answer some of your questions:

>Is there any idea floating around in the ether as to how many people
>are using ImageJ and what range of areas it is being applied to?

If you take a look at the confirmation eMail you've received from the
List-server you will realize that there are 1755 (re 3rd August 2010)
list memebers.

My guess is that at least 3 to 5 times more people use IJ on a regular basis.

The range of areas comprises mostly scientific analysis (and
synthesis) of all kinds of image(-like) data but to a much lesser
extent so-called image cosmetics and art-work.
(This is my very personal impression.)

>Are there any stats for how many ImageJ downloads?
>
>What about Java? Apple (the platform I tend to use) seem to be
>showing less enthusiasm for Java. Now Oracle have acquired Sun, does
>anyone have any idea as to the future of Java?

Well, no doubt, Apple has dropped the Java-to-Cocoa bridge (can a
bridge be dropped?) but Java is still supported by Apple and there
are generally late but regular updates of the OSX-specific VJM.

>Just questions gnawing at me a little whilst considering how much
>effort to plough into pursuing things with Java and ImageJ.

According to more recent investigations, Java and C are the most used
high-level programming languages. Only recently, C was slightly ahead
of Java but currently Java is leading a bit. So no doubt, Java will
stay with us for many years to come, even for Mac-users.

>Michael Ellis
>Cambridge, UK

HTH
--

                   Herbie

          ------------------------
          <http://www.gluender.de>
Reply | Threaded
Open this post in threaded view
|

Re: Are there any statistics on ImageJ use?

Raymond Martin-2
In reply to this post by Michael Ellis
Hi,

On August 6, 2010 02:41:16 pm you wrote:
>
> What about Java? Apple (the platform I tend to use) seem to be showing
> less enthusiasm for Java. Now Oracle have acquired Sun, does anyone
> have any idea as to the future of Java?

The direction is uncertain as of yet from the Oracle side. They have made a
number of promises for positive change, but the results of those will not be
known for at least a few months as the version moves towards 1.7.

In regard to Apple, the Apple Java team has done a really good job in the past
two years of catching up to the Oracle/Sun version. In my opinion, before that
things were shaky at times with 1.6 and in other areas. So I personally have
seen a good amount of stability come into place. But they might end up being
behind again when 1.7 appears.

I do not think Apple will be able to get rid of Java (on the desktop/server)
because there are so many developers using it and from watching the Apple Java
developers list for a few years they received a lot of flack when the Cocoa-
Java bridge was taken out and for a few other things that looked like they
were trying to dump Java. It seems like they had to step back from that to
avoid losing customers.

Raymond
Reply | Threaded
Open this post in threaded view
|

Re: combine function of the ROI manager

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by SebT
On Aug 6, 2010, at 1:13 PM, Sebastien Tosi wrote:

> Thank you Wayne, this works fine. Now I have to find out how to call
> javascript from a macro and pass arguments to the script (here basically the
> 2 indexes of the ROIs to be merged)... what is the best way to do this?

A macro can call JavaScript using the eval() function. Here is an example:

  index1 = 1;
  index2 = 3;

  script =
     "index1="+index1+";\n" +
     "index1="+index2+";\n" +
     "manager = RoiManager.getInstance();\n" +
     "if (manager==null)\n" +
     "  IJ.error(\"ROI Manager is not open\");\n" +
     "rois = manager.getRoisAsArray();\n" +
     "roi1 = new ShapeRoi(rois[1]);\n" +
     "roi2 = new ShapeRoi(rois[3]);\n" +
     "combined = roi1.or(roi2);\n" +
     "manager.addRoi(combined);\n";

  eval("script", script);

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Are there any statistics on ImageJ use?

Michael Ellis
In reply to this post by Raymond Martin-2
To Gluender and Raymond,

Thanks for your opinions. Certainly more positive on the Java front  
than I had feared.

Regards -- Michael Ellis

Michael,

...only an attempt to answer some of your questions:

> Is there any idea floating around in the ether as to how many people  
> are using ImageJ and what range of areas it is being applied to?

If you take a look at the confirmation eMail you've received from the  
List-server you will realize that there are 1755 (re 3rd August 2010)  
list memebers.

My guess is that at least 3 to 5 times more people use IJ on a regular  
basis.

The range of areas comprises mostly scientific analysis (and  
synthesis) of all kinds of image(-like) data but to a much lesser  
extent so-called image cosmetics and art-work.
(This is my very personal impression.)

> Are there any stats for how many ImageJ downloads?
>
> What about Java? Apple (the platform I tend to use) seem to be  
> showing less enthusiasm for Java. Now Oracle have acquired Sun, does  
> anyone have any idea as to the future of Java?

Well, no doubt, Apple has dropped the Java-to-Cocoa bridge (can a  
bridge be dropped?) but Java is still supported by Apple and there are  
generally late but regular updates of the OSX-specific VJM.

> Just questions gnawing at me a little whilst considering how much  
> effort to plough into pursuing things with Java and ImageJ.

According to more recent investigations, Java and C are the most used  
high-level programming languages. Only recently, C was slightly ahead  
of Java but currently Java is leading a bit. So no doubt, Java will  
stay with us for many years to come, even for Mac-users.

> Michael Ellis
> Cambridge, UK

On 6 Aug 2010, at 21:40, Raymond Martin wrote:

> Hi,
>
> On August 6, 2010 02:41:16 pm you wrote:
>>
>> What about Java? Apple (the platform I tend to use) seem to be  
>> showing
>> less enthusiasm for Java. Now Oracle have acquired Sun, does anyone
>> have any idea as to the future of Java?
>
> The direction is uncertain as of yet from the Oracle side. They have  
> made a
> number of promises for positive change, but the results of those  
> will not be
> known for at least a few months as the version moves towards 1.7.
>
> In regard to Apple, the Apple Java team has done a really good job  
> in the past
> two years of catching up to the Oracle/Sun version. In my opinion,  
> before that
> things were shaky at times with 1.6 and in other areas. So I  
> personally have
> seen a good amount of stability come into place. But they might end  
> up being
> behind again when 1.7 appears.
>
> I do not think Apple will be able to get rid of Java (on the desktop/
> server)
> because there are so many developers using it and from watching the  
> Apple Java
> developers list for a few years they received a lot of flack when  
> the Cocoa-
> Java bridge was taken out and for a few other things that looked  
> like they
> were trying to dump Java. It seems like they had to step back from  
> that to
> avoid losing customers.
>
> Raymond
Reply | Threaded
Open this post in threaded view
|

Re: combine function of the ROI manager

SebT
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Thank you Wayne, this works perfectly. I was not aware of the possible use
of Javascript. It seems to be used as a kind of bridge between macro and
plugins and might be useful in some circumstances as this one. Are you using
it a lot yourself?

Regards,
Sébastien
Reply | Threaded
Open this post in threaded view
|

Re: combine function of the ROI manager

Nathaniel Ryckman
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
-wayne
Rasband, Wayne (NIH/NIMH) [E] wrote
On Aug 6, 2010, at 1:13 PM, Sebastien Tosi wrote:

> Thank you Wayne, this works fine. Now I have to find out how to call
> javascript from a macro and pass arguments to the script (here basically the
> 2 indexes of the ROIs to be merged)... what is the best way to do this?

A macro can call JavaScript using the eval() function. Here is an example:

  index1 = 1;
  index2 = 3;

  script =
     "index1="+index1+";\n" +
     "index1="+index2+";\n" +
     "manager = RoiManager.getInstance();\n" +
     "if (manager==null)\n" +
     "  IJ.error(\"ROI Manager is not open\");\n" +
     "rois = manager.getRoisAsArray();\n" +
     "roi1 = new ShapeRoi(rois[1]);\n" +
     "roi2 = new ShapeRoi(rois[3]);\n" +
     "combined = roi1.or(roi2);\n" +
     "manager.addRoi(combined);\n";

  eval("script", script);

-wayne
I am disappointed that script is needed to do such a basic task. I guess it's worth it since ImageJ is really versatile in most other respects.

The problem is that the script hack doesn't work in batch mode for me. I know that there is a RoiManager instance running because roiManager("Count") is working properly, but still the script "RoiManager.getInstance()" is returning null.

Any advice or ideas? Where could I find more about how the ROI Manager works in batch mode?

Thanks!