Reputation: 1
I am trying to set up a macro in imagej but I am unfamiliar with the language
This is my script :
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));
}
This is the error : '.' expected in line 1:
Thank you for your help
I need my script to work, so I need to solve the problem
Upvotes: -1
Views: 34
Reputation: 9
You may want to try the build-in editor while writing macros. It'll guide you nicely to stick to the correct 'grammar' as macros really are not Java as @tevemadar mentioned.
Try this:
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.
}
Upvotes: 0