Delete ROIs depending on their Results

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

Delete ROIs depending on their Results

Giuseppe Lucarelli
Hi there,

I get a large number of ROIs for my yeast cells (>400) but some of them represent either cells that have too low fluorescence or too high and skew my analysis.

So I came up with a macro that can go through the list of ROIs and delete those that have too high or too low "IntDen" value. Here is the code:

num=roiManager("count");
for (i=0;i<num;i++){
        one = getResult("IntDen", i);
        two = getResult("Mean", i);
        print(one);
        if (one > 40000){
                roiManager("select",i);
                roiManager("Delete");
                roiManager("Update");
        }
        print(one+ " "+two);
}

The print() function is to check that the macro is doing the right thing and IT'S NOT!!!
It deletes ROIs even if their IntDen is <40000 (i should mention that I analyse 16 bit images).

What am I doing wrong? Can you help please.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Delete ROIs depending on their Results

Krs5
Most likely the reason is that as soon as an ROI is deleted from your ROI list the results in the results table and the selected ROI don't match up anymore as you have deleted an ROI but still increase i with 1. So if you delete ROI nr 10, nr 11 becomes nr 10 but you select nr 11 in the next round what was actually ROI nr 12 before you started the operation.

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of giuseppe3
Sent: 12 June 2014 07:10
To: [hidden email]
Subject: Delete ROIs depending on their Results

Hi there,

I get a large number of ROIs for my yeast cells (>400) but some of them represent either cells that have too low fluorescence or too high and skew my analysis.

So I came up with a macro that can go through the list of ROIs and delete those that have too high or too low "IntDen" value. Here is the code:

num=roiManager("count");
for (i=0;i<num;i++){
        one = getResult(&quot;IntDen&quot;, i);
        two = getResult(&quot;Mean&quot;, i);
        print(one);
        if (one > 40000){
                roiManager("select",i);
                roiManager("Delete");
                roiManager("Update");
        }
        print(one+ " "+two);
}

The print() function is to check that the macro is doing the right thing and IT'S NOT!!!
It deletes ROIs even if their IntDen is <40000 (i should mention that I analyse 16 bit images).

What am I doing wrong? Can you help please.

Thanks



--
View this message in context: http://imagej.1557.x6.nabble.com/Delete-ROIs-depending-on-their-Results-tp5008152.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Delete ROIs depending on their Results

Aryeh Weiss
On 6/12/14, 5:19 PM, Straatman, Kees (Dr.) wrote:

> Most likely the reason is that as soon as an ROI is deleted from your ROI list the results in the results table and the selected ROI don't match up anymore as you have deleted an ROI but still increase i with 1. So if you delete ROI nr 10, nr 11 becomes nr 10 but you select nr 11 in the next round what was actually ROI nr 12 before you started the operation.
>
> Best wishes
>
> Kees
>
>
> Dr Ir K.R. Straatman
> Senior Experimental Officer
> Advanced Imaging Facility
> Centre for Core Biotechnology Services
> University of Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of giuseppe3
> Sent: 12 June 2014 07:10
> To: [hidden email]
> Subject: Delete ROIs depending on their Results
>
> Hi there,
>
> I get a large number of ROIs for my yeast cells (>400) but some of them represent either cells that have too low fluorescence or too high and skew my analysis.
>
> So I came up with a macro that can go through the list of ROIs and delete those that have too high or too low "IntDen" value. Here is the code:
>
> num=roiManager("count");
> for (i=0;i<num;i++){
> one = getResult(&quot;IntDen&quot;, i);
>          two = getResult(&quot;Mean&quot;, i);
> print(one);
> if (one > 40000){
> roiManager("select",i);
> roiManager("Delete");
> roiManager("Update");
> }
> print(one+ " "+two);
> }
>
> The print() function is to check that the macro is doing the right thing and IT'S NOT!!!
> It deletes ROIs even if their IntDen is <40000 (i should mention that I analyse 16 bit images).
>
> What am I doing wrong? Can you help please.
>
> Thanks
>
>
>


I just ran into this same problem. The solution is to run your loop from
the highest roi index down to 0.

Here is a code fragment:

roiCount = roiManager("count");

for (j=roiCount-1; j>=0; j--) {
     if (score[j] < 2) {
         roiManager("select", j);
         roiManager("Delete");
     }
}

I hope this helps you.
--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Delete ROIs depending on their Results

Giuseppe Lucarelli
Thanks for your responses guys!

I'll try your suggestions and see if it works!
Reply | Threaded
Open this post in threaded view
|

Re: Delete ROIs depending on their Results

Giuseppe Lucarelli
Thanks guys that worked beautifully!!