Login  Register

Re: Area fraction within multiple ROIs

Posted by ved sharma on Mar 18, 2014; 3:56am
URL: http://imagej.273.s1.nabble.com/Area-fraction-within-multiple-ROIs-tp5006915p5006963.html

Hi Linda,

Try the following macro. This should get you started with what you need. First, add all the particles and ROIs to the ROI Manager and then run this macro. The output is a Log file with particle name, followed by its area and area fraction.

Hope it helps!

Ved


// ---------  Macro starts here
n =  roiManager("count");
areaParticles = newArray(n);
nameParticles = newArray(n);
for(i=0; i<n; i++) {
        roiManager("Select", i);
        getStatistics(areaParticles[i]);
        nameParticles[i] = Roi.getName;
}
fraction = newArray(n);
for(i=0; i<n; i++)
        fraction[i] = 0; // initialize fraction array
for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
                if(j != i) {
                        roiManager("Select", newArray(i,j));
                        roiManager("AND");
                        getStatistics(area);
                        if(area == areaParticles[i])
                                fraction[i] = (100*areaParticles[i])/areaParticles[j];
                }
        }
}
for(i=0; i<n; i++) {
        if(fraction[i] > 0)
                print(nameParticles[i]+": area = "+areaParticles[i]+", fraction = "+fraction[i]);
}
// ---------  Macro ends here


___________________________________
Ved Sharma, PhD
Department of Anatomy and Structural Biology
Albert Einstein College of Medicine
Bronx, New York

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