This is my second go at writing a macro (with virtually zero coding knowledge) after the first one was a success, but I am adding a layer of complexity that I can't seem to make functional.
I am trying to set up a batch process where I count particles of 2 different colors and then which of those particles is positive for both colors. I am getting this error:
Error: ')' expected in line 38: selectWindow ( "Result of " - "+Title" ) ;
I really don't know what I need to fix because it seems that I have closed all open parentheses. However, I know that the root issue is that I don't know how to generically name the window I am interested in. It is a window that is created by the macro and is not one of the input files.
dir1 = getDirectory("Input");
dir2 = getDirectory("Output");
list = getFileList(dir1);
run("Close All");
setBatchMode(true);
for (i=0; i<list.length; i++) {
file1 = dir1 + list[i];
file2 = dir2 + list[i];
file3 = dir2 + list[i];
file3 = replace(file3, ".tif", ".csv");
open(file1);
Title = getTitle();
Title = replace(Title, ".tif", "");
run("Stack to Images");
selectWindow(Title+"-0002");
rename ("mNG-"+Title);
run("Subtract Background...", "rolling=50");
setAutoThreshold("RenyiEntropy dark");
//run("Threshold...");
run("Convert to Mask");
run("Fill Holes");
run("Watershed");
run("Set Measurements...", "area mean min centroid center perimeter integrated median kurtosis area_fraction stack limit display redirect=None decimal=2");
run("Analyze Particles...", "size=9-475 circularity=0.50-1.00 show=Outlines display exclude summarize in_situ");
run("Fill Holes");
selectWindow(Title+"-0003");
rename ("tdT-"+Title);
run("Subtract Background...", "rolling=50");
setAutoThreshold("RenyiEntropy dark");
//run("Threshold...");
run("Convert to Mask");
run("Fill Holes");
run("Watershed");
run("Set Measurements...", "area mean min centroid center perimeter integrated median kurtosis area_fraction stack limit display redirect=None decimal=2");
run("Analyze Particles...", "size=9-475 circularity=0.50-1.00 show=Outlines display exclude summarize in_situ");
run("Fill Holes");
imageCalculator("Add create", "mNG-"+Title,"tdT-"+Title);
rename ("doublepositive"+Title)
selectWindow(Result of "mNG-"+Title);
run("Analyze Particles...", "size=9-475 circularity=0.50-1.00 show=Outlines display exclude summarize in_situ");
run("Images to Stack", "name=[] title=[] use");
saveAs("Tiff", file2);
run("Close All");
}
setBatchMode(false);
selectWindow("Summary");
saveAs("Results", "file3");
run("Close All");
If I could get help on why my syntax is wrong and also feedback on how to generically name the window with the third result, I would greatly appreciate it.
I think, that you just have to change the whole name in to a string
selectWindow("Result of mNG-"+Title);
or
selectWindow("Result of "+"mNG-"+Title);
If this doesn't help, could you give me an example of your data so I can properly test it.