Calculating the percent overlap of one ROI over another

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

Calculating the percent overlap of one ROI over another

LyleBabcock
I've written a macro program that analyzes the number of nuclei per muscle
fiber by counting the number of nuclei that intersect the muscle fiber
border. The problem is that the program over estimates these counts, and I
want to ensure that only nuclei with a 50% or greater overlap with a fiber
border is counted. Below is the portion of the macro that determines whether
or not the nuclei and fiber borders overlap. How do I calculate the
percentage of over lap, and then only count those nuclei that have a 50% or
greater overlap?

        selectWindow("DAPI");
for (i=0;i<counts; i++){
        nuclei_counts[i] = 0;
  for (j=0;j&lt;roiManager(&quot;count&quot;);j++){
    roiManager('select',newArray(i,j));
    roiManager(&quot;AND&quot;);
   if ((i!=j)&amp;&amp;(selectionType>-1)) {
    nuclei_counts[i]++;
    }
  }
}

Thank you.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

Re: Calculating the percent overlap of one ROI over another

George Patterson
Hi Lyle,
If you measure the area of the nuclear ROI and the area of the "AND" ROI
which should be the overlap, I think that will give you what you want.
Something like the changes to your macro below.
I didn't test it.
Best,
George


for (i=0;i<counts; i++){
        nuclei_counts[i] = 0;
  roiManager("select",i);
  getStatistics(nucleusArea);
  for (j=0;j<roiManager("count");j++){
    roiManager("select",newArray(i,j));
    roiManager("AND");
    getStatistics(overlapArea);
    percentOverlap=overlapArea/nucleusArea;
   if ((i!=j)&&(selectionType>-1)&&percentOverlap>0.5) {
        nuclei_counts[i]++;
    }
  }
}


On Mon, Mar 30, 2020 at 12:45 PM LyleBabcock <[hidden email]> wrote:

> I've written a macro program that analyzes the number of nuclei per muscle
> fiber by counting the number of nuclei that intersect the muscle fiber
> border. The problem is that the program over estimates these counts, and I
> want to ensure that only nuclei with a 50% or greater overlap with a fiber
> border is counted. Below is the portion of the macro that determines
> whether
> or not the nuclei and fiber borders overlap. How do I calculate the
> percentage of over lap, and then only count those nuclei that have a 50% or
> greater overlap?
>
>         selectWindow("DAPI");
> for (i=0;i<counts; i++){
>         nuclei_counts[i] = 0;
>   for (j=0;j&lt;roiManager(&quot;count&quot;);j++){
>     roiManager('select',newArray(i,j));
>     roiManager(&quot;AND&quot;);
>    if ((i!=j)&amp;&amp;(selectionType>-1)) {
>         nuclei_counts[i]++;
>     }
>   }
> }
>
> Thank you.
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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