我正在尝试在 imagej 中设置宏,但我不熟悉该语言
这是我的脚本:
String directory = "dts/";
String[] list = getFileList(directory);
ArrayList<String> meanValuesList = new ArrayList<String>();
for (int i = 0; i < list.length; i++) {
open(directory + list[i]);
run("Find Maxima...", "noise=0 output=[Point Selection]");
run("Measure");
meanValue = getResult("Mean", 0);
meanValuesList.add(list[i] + ": " + meanValue);
close();
}
for (j = 0; j < meanValuesList.size(); j++) {
print(meanValuesList.get(j));
}
这是错误:“。”预计在第 1 行:
谢谢您的帮助
我需要我的脚本才能工作,所以我需要解决问题
您可能想在编写宏时尝试内置编辑器。它将很好地指导您遵循正确的“语法”,因为宏实际上不是 @tevemadar 提到的 Java。
试试这个:
directory="dts/";
list=getFileList(directory);
meanValuesList=newArray();
for ( i = 0; i < list.length; i++) {
open(directory + list[i]);
run("Find Maxima...", "noise=0 output=[Point Selection]");
// noise=0 is very little noise. In most cases, that may yield too many hits.
run("Measure");
meanValue = getResult("Mean", 0); // This gets you only the mean of the first Maximum
// if you want the manes of all Maxima try permutating through the Results table
for (j = 0; j < nResults; j++) {
meanValue=getResult("Mean", j);
// Either print them right here,
//print(meanValue);
// and/or collect them in meanValuesList
meanValuesList=Array.concat(meanValuesList, meanValue);
}
close();
// anyhow, you need to process your meanValuesList for each image, meaning inside of the outer for-loop.
//for (j = 0; j < meanValuesList.length; j++) {
// print(meanValuesList[j]);
//}
// or
Array.print(meanValuesList);
// or what-ever you meant to do with the means.
}