Hello fellow Fiji users,
Yesterday I started writing a macro for counting cells from stainings. Now it works and does everything I want it to, but after completing the task its last action is to search for a ROI Manager window, that has already been closed and therefore displaying an error message. I can’t seem to figure my syntax mistake in the loop out. I also installed the Results to excel Plugin.
Here the loop code:
//define the process
function action(input, output, filename) {
//open image
open(input + filename);
selectWindow(filename);
//open ROI Manager and the saved ROIs
run("ROI Manager...");
roiManager("Open", input + "RoiSet_" + filename + ".zip");
//select the correct stained channel
Stack.setChannel(3);
//threshold, watershed and analyze particles for finding the cell somas as Maxima
setAutoThreshold("Default dark");
//run("Threshold...")
setThreshold(100, 255);
run("Convert to Mask", "method=Default background=Dark only black");
run("Watershed", "slice");
run("Analyze Particles...", "size=90-Infinity circularity=0.25-1.00 show=Masks exclude clear slice");
run("Invert");
saveAs("Tiff", output + "Mask_" + filename);
//find Maxima=Cell somas in the different layers
roiManager("Select", 1);
run("Find Maxima...", "prominence=10 exclude output=Count");
roiManager("Select", 2);
run("Find Maxima...", "prominence=10 exclude output=Count");
roiManager("Select", 3);
run("Find Maxima...", "prominence=10 exclude output=Count");
selectWindow("Results");
run("Read and Write Excel", "no_count_column stack_results file=[C:/Users/Admin/Desktop/Interneuron_results.xlsx] sheet=result");
selectWindow("Results");
run("Close");
//close all windows for next Image
run("Close All");
roiManager("deselect");
roiManager("delete");
}
//define parameters
input = "D:/ImageJ_batch_process/input/"
output= "D:/ImageJ_batch_process/output/"
//define batching
setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++)
action(input, output, list[i]);
setBatchMode(false);
I hope someone will be able to explain to me where I messed up. Thank You guys very much for Your time and effort.
Have a nice day,
GGraf