I am using ImageJ code to measure the same parameters in many pictures. I have an ImageJ code that used to work. It asked to locate the folder with the pictures and then you were able to choose current, next or previous picture for analysis with a mix of automatic and user interface data collection items. The 'previous' option now is stuck and you stay at the 'current' image when you choose it. A further issue is that a collaborator in Spain needs to open the first image manually. I tried replacing s with i (seen somewhere online) and -- with -1, but that didn't solve it.
//code to extract leaf morphology for oak leaves which is the saved as a csv file
//there should be a folder called 'Data' in the folder with the images where the csv file will be saved.
var ps = 1;
folder = getDirectory("Choose the folder with the pictures");
mfiles = getFileList(folder);
time = gettimestamp();
for (s=0; s<mfiles.length; s++)
{
open(folder + mfiles[s]);
run("Select None");
Dialog.create("Correct image?");
items = newArray("Next", "Previous","Current");
Dialog.addChoice("choose the image to perform operation", items, "Current")
Dialog.show()
resp=Dialog.getChoice();
if (resp == "Previous")
{
s--;
close();
}
else if(resp == "Next")
{
s++;
close();
}
else if (resp== "Current")
{
current = mfiles[s];
measure();
close();
}
}
function measure () {
run("Select None");
measured();
savestuff();
}
//records color data about leaf
function measured ()
{
bd = "[LeafColor]";
run("New... ", "name="+bd+" type=Table");
// These lines are supposed to set up the table where data will be entered
print(bd, "\\Headings:Directory\tSample");
wins = bd;
Dialog.create(getInfo("image.filename"));
Sample=getTitle();
// here the data are supposed to be entered into the table created before
print(wins, getInfo("image.directory")+"\t"+Sample);
};
};
)
// to save everything
function savestuff()
{
bdd = "LeafColor";
Sample=getTitle(); //only 1 simple trait in this example version being the name of the image file
selectWindow(bdd);
saveAs("Text", "" + folder + "/"+"Data/" + Sample + "_" + bdd + ".csv");
if(isOpen("Results")==true){
selectWindow("Results");
run("Close");
}
}
// to get time
function gettimestamp() {
MonthNames = newArray("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec);
time = "" + dayOfMonth + "" + MonthNames[month] + "" + year + "_" + hour + "." + minute + "." + second;
return time;
}
Solving this problem can safe us time, so any advise is welcome.