ROI.getStatistics() is returning NaN values?
I used StarDist to create a label image with a number of coloured cells on a black background. Each cell is associated with a corresponding roi which is stored in the Roi Manager. However when I try to get statistics for these ROIs in a JavaScript macro, everything except area returns NaN.
var rm = RoiManager.getRoiManager();
var rois = rm.getRoisAsArray();
for(var i=0; i<rois.length; i++) {
print(rois[i].getStatistics()); // stats[count=86, mean=NaN, min=NaN, max=NaN]
}
print(rois[0].area) // 86
print(rois[0].mean // NaN
print(rois[0].areaFraction) // NaN - should be 95.
Using the GUI “Measure” function in the Roi Manager lists the values correctly. Rewriting in .ijm format also worked as expected and returned numerical values:
for(i=0; i<roiManager("count"); i++) {
roiManager("select", i);
someValue = getValue("%Area"); // someValue = 95
}
Managed to find a work around, but is this a bug in the JavaScript API, or am I incorrectly implementing the code?
Thanks