|
Hi everyone,
First time in my life I was manage to write couple line of codes which surprisingly were executed, but it is not quite what I would want. What I am trying to do is to count maxima and measure area, mean area fraction within specyfied ROI. First chalenge I am struggling with is to set noise tolerance for maxima. Right now I am getting raw statistics from whole image and than I'm taking mean+std for noise tolerance. Instead of using global image statistics I wish to use mean and std measured within each specyfied Roi. In other words for each Roi the noise tolerance will be different. Next thing I was not able to solve concerns the results table.
What I'm eventually gatting after runing this macro looks like this
Label Area mean StdDev InDen %Area Count
1 Image2.tif:0029-1099 1649 0.38 1.63 620 7.94 0
2 0 0 0 0 0 6
3 Image2.tif:0042-1443 1061 0.66 2.59 699 10.84 0
4 0 0 0 0 0 7
5 Image2.tif:0046-1339 974 0.68 2.27 661 12.32 0
So, count value for line 1 is in line 2 and so on. What is the way to get reed of the secound line and have all measurements in one line only? Also, is there any way to have one extra column where I can put a my label for each sets of measurements (for example; insted of numbers in first colinn I could have the same lebel, let say Exp1,).
Finally there is something wrong with this for (i=0; i<n; n++) loop, because I'm getting error saing that index is outside of range. And the last thing is, how to automaticly close image and roi manager after analysis is done?
Can you help me with this, please.
Pav
macro "CountMaxima [F1]" {
getRawStatistics(area, mean, min, max, std, h);
std = 0;
mean = 0;
a = 0 + mean;
b = 0 + std;
c = (a + b);
roiManager("Select", 0);
run("Set Measurements...", "area mean standard integrated area_fraction display redirect=None decimal=2");
roiManager("Measure");
run("Find Maxima...", "noise="+ c +" output=Count");
n = 1;
roiManager("Select", n);
for (i=0; i<n; n++) {
roiManager("Select", n+1);
setOption("Show All",true);
roiManager("Measure");
run("Find Maxima...", "noise="+ c +" output=Count");
}
while (nImages()>0) {
selectImage(nImages());
run("Close");
}
|