Removing multiple ROIs

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

Removing multiple ROIs

Ohkyung
Dear ImageJ users,

I am trying to remove several ROIs from ROI manager in a macro. I know
there is a way to do so in plugin programming. However, I want to do
this in macro if it is not impossible.

1. No problem to delete one ROI from the manager.

roiManager("Select", index);
roiManager("Delete");.

2. However, when I try to delete several ROIs at the same time, it is
not working. I think that it is due to the fact that roi manager
automatically reassign new index starting from 0 when I delete one Roi
from roi manager. Thus, I cannot delete  several ROIs that I want to
delete.

                for (iRow = 0; iRow <nResults; iRow++) {
                        area = getResult("Area", iRow);
                        if (area >= 200) {
                                roiManager("Select", iRow);
                                roiManager("Delete");
                        }
                }

3. I also tried to select multiple ROIs first. Then delete them. But
this also did not work.

                for (iRow = 0; iRow <nResults; iRow++) {
                        area = getResult("Area", iRow);
                        if (area >= 200) {
                                roiManager("Select", iRow);
                        }
                }
                roiManager("Delete");


Any good ideas? Thanks very much in advance.

Best regards,
Ohkyung


P.S.
To select unwated ROIs, I want to use different parameters that are
not currently supported by ImageJ. I used "Area" just to demonstrate
what I want to do.
Reply | Threaded
Open this post in threaded view
|

Re: Removing multiple ROIs

dscho
Hi,

On Fri, 11 Jun 2010, Ohkyung wrote:

> I am trying to remove several ROIs from ROI manager in a macro. I know
> there is a way to do so in plugin programming. However, I want to do
> this in macro if it is not impossible.
>
> 1. No problem to delete one ROI from the manager.
>
> roiManager("Select", index);
> roiManager("Delete");.
>
> 2. However, when I try to delete several ROIs at the same time, it is
> not working. I think that it is due to the fact that roi manager
> automatically reassign new index starting from 0 when I delete one Roi
> from roi manager.

Yes, it must do that, as there cannot be a ROI without an index all of a
sudden.

> Thus, I cannot delete several ROIs that I want to delete.
>
> for (iRow = 0; iRow <nResults; iRow++) {
> area = getResult("Area", iRow);
> if (area >= 200) {
> roiManager("Select", iRow);
>                roiManager("Delete");
> }
> }

Why not just go backwards?

                for (iRow = nResults - 1; iRow >= 0; iRow--)
                ...

Hth,
Johannes
Oky
Reply | Threaded
Open this post in threaded view
|

Re: Removing multiple ROIs

Oky
Yes, it is working. Simple. :)

Thanks very much.

On Fri, Jun 11, 2010 at 2:50 PM, Johannes Schindelin
<[hidden email]> wrote:

> Hi,
>
> On Fri, 11 Jun 2010, Ohkyung wrote:
>
>> I am trying to remove several ROIs from ROI manager in a macro. I know
>> there is a way to do so in plugin programming. However, I want to do
>> this in macro if it is not impossible.
>>
>> 1. No problem to delete one ROI from the manager.
>>
>> roiManager("Select", index);
>> roiManager("Delete");.
>>
>> 2. However, when I try to delete several ROIs at the same time, it is
>> not working. I think that it is due to the fact that roi manager
>> automatically reassign new index starting from 0 when I delete one Roi
>> from roi manager.
>
> Yes, it must do that, as there cannot be a ROI without an index all of a
> sudden.
>
>> Thus, I cannot delete several ROIs that I want to delete.
>>
>>               for (iRow = 0; iRow <nResults; iRow++) {
>>                       area = getResult("Area", iRow);
>>                       if (area >= 200) {
>>                               roiManager("Select", iRow);
>>                               roiManager("Delete");
>>                       }
>>               }
>
> Why not just go backwards?
>
>                for (iRow = nResults - 1; iRow >= 0; iRow--)
>                ...
>
> Hth,
> Johannes
>



--
Ohkyung Kwon

http://www.linkedin.com/in/ohkyung
http://www.wpskorea.org
http://ncmir.ucsd.edu
Reply | Threaded
Open this post in threaded view
|

Scripting Plugins that don;t use GenericFialog

Michael Ellis
I've written a plugin that implements a custom user interface based on  
a Swing JFrame containing some custom user interface items. I'd like  
to add the ability for my plugin to be recordable and to execute as a  
macro.

How can add macro recordability/runability in the absence of using  
GenericDialog?

Any tips gratefully appreciated!


Michael Ellis
Managing Director
Digital Scientific UK Ltd.
http://www.digitalscientific.co.uk
[hidden email]
tel: +44(0)1223 329993
fax: +44(0)1223 370040

Sheraton House
Castle Park
Cambridge
CB3 0AX


The contents of this e-mail may be privileged and are confidential.  
It may not be disclosed to or used by anyone other than the  
addressee(s), nor copied in any way.  If received in error, please  
advise the sender and delete it from your system.
Reply | Threaded
Open this post in threaded view
|

Re: Scripting Plugins that don;t use GenericFialog

dscho
Hi,

On Sat, 12 Jun 2010, Michael Ellis wrote:

> I've written a plugin that implements a custom user interface based on a
> Swing JFrame containing some custom user interface items. I'd like to
> add the ability for my plugin to be recordable and to execute as a
> macro.
>
> How can add macro recordability/runability in the absence of using
> GenericDialog?

Will your plugin be Open Source? If so, I am happy to help (as I get
something back for my efforts).

Ciao,
Johannes