i wrote a little macro, that locates spheres on a spatially calibrated (Dicom-) image. Once found, it draws lots! of lines and saves the brightness profiles along these lines to a csv file. So far, this works nice and fast. This is the piece of code, that extracts the profiles and saves them:
for (i=0; i < 360; i++){
run("Clear Results");
angle = i*2*PI/360;
makeLine(xm,ym,(xm+(length*sin(angle))), (ym-(length*cos(angle))));
profile = getProfile();
for (j=0; j<profile.length; j++) {
setResult("Value", j, profile[j]);
}
updateResults;
saveAs("Results",path + "\\angle_"+i+".csv");
}
My problem is, that the actual scale is not exported. I get something like this:
1,3070.070
2,3069.000
3,3069.986
4,3053.646
but i want
0.4395 3070
0.8789 3070
1.3184 3070
1.7578 069.8994
And so on. I tried to modify this line a little:
setResult("Value", j*xscale, profile[j]);
but this does not work. I also tried to plot the profiles and then read and save them.
for (i=0; i < 360; i++){
run("Clear Results");
angle = i*2*PI/360;
makeLine(xm,ym,(xm+(length*sin(angle))), (ym-(length*cos(angle))));
run ("Plot Profile");
Plot.getValues(xplot,yplot);
for (j=0; j< xplot.length; j++){
print (xplot[j],yplot [j]);
}
selectWindow("Log");
saveAs("Text",path + "\\angle_"+i+".csv");
print("\\Clear");
selectWindow("04");
}
(Sorry, the window switching is still experimental and the profiles are not closing..)
This works in principle but it is of course PAINFULLY slow. So my question is.... How do i extract not online line numbers but the correct scale in a profile? Thank you all very much!
The first column is just a non editable line number. The code must be changed like this:
for (i=0; i < 360; i++){
run("Clear Results");
angle = i*2*PI/360;
makeLine(xm,ym,(xm+(length*sin(angle))), (ym-(length*cos(angle))));
profile = getProfile();
for (j=0; j<profile.length; j++) {
setResult("xvalues", j, j*dx);
setResult("yvalues", j, profile[j]);
}
updateResults;
saveAs("Results",path + "\\angle_"+i+".csv");
}