I have approximately 350 hexagonal grids spread across an image of particles using a macro. Is there a way I could calculate the mean and standard deviation of the particle sizes in each hexagon?

I know you can use the summarise tab to get mean and SD values from the results but it does it for the entire image and not for each separate grid. Is there anything I could add to the code to analyse the particles in each hexagonal grid, and calculate the mean and SD size, then export the ,mean and SD values somewhere else, (maybe the log) and move onto the next grid and do the same? I’ve tried a few things but can’t seem to get it to work.

Any help would be greatly appreciated

My current code is:

```
l = 230; // length of hexagon side (pixels)
// hexagon geometry parameters
xIni = 1.0;
yIni = sqrt (3.0) / 2.0;
xSiz = xIni;
ySiz = yIni;
xDel = 3.0;
yDel = yIni;
xOff = 1.5; // offset for every other row of hexagons
// scale up to get desired size
xIni *= l;
yIni *= l;
xSiz *= l;
ySiz *= l;
xDel *= l;
yDel *= l;
xOff *= l;
getDimensions (width, height, dummy, dummy, dummy);
// loop over rows of hexagons
iOff = 0; // which staggered row of hexagons
y = yIni;
while (y + ySiz < height) {
// loop over hexagons in a row
x = xIni + (iOff % 2) * xOff;
while (x + xSiz < width) {
// build hexagonal ROI
x1 = x + xSiz;
y1 = y;
x2 = x + xSiz / 2.0;
y2 = y - ySiz;
x3 = x - xSiz / 2.0;
y3 = y - ySiz;
x4 = x - xSiz;
y4 = y;
x5 = x - xSiz / 2.0;
y5 = y + ySiz;
x6 = x + xSiz / 2.0;
y6 = y + ySiz;
makePolygon (x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6);
// add to ROI Manager
roiManager ("add");
x += xDel;
}
iOff++;
y += yDel;
}
// display all hexagonal ROIs
roiManager ("deselect");
roiManager ("show all");
run("Analyze Particles...", "include");
numROIs= roiManager("Count");
for (j=0; j<numROIs; j++)
{
imgID= getImageID();
roiManager("select",j);
run("Analyze Particles...", "include");
}
```