图像 J 中单正和双正粒子的批处理

Batch process for single and double positive particles in Image J

继第一次成功之后,这是我第二次尝试编写宏(编码知识几乎为零),但我添加了一层似乎无法发挥作用的复杂性。

我正在尝试设置一个批处理过程,在该过程中我计算 2 种不同颜色的粒子,然后计算这些粒子中哪些粒子对两种颜色都是正值。我收到此错误:

第 38 行出现错误:“)”: selectWindow("结果"-"+标题");

我真的不知道我需要修复什么,因为我似乎已经关闭了所有左括号。但是,我知道根本问题是我不知道如何对我感兴趣的 window 进行通用命名。它是由宏创建的 window 而不是其中之一输入文件。

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");

如果我能得到关于为什么我的语法错误的帮助以及关于如何用第三个结果一般命名 window 的反馈,我将不胜感激。

我认为,您只需将整个名称更改为字符串

selectWindow("Result of mNG-"+Title);

selectWindow("Result of "+"mNG-"+Title);

如果这没有帮助,您能否给我一个您的数据示例,以便我可以正确测试它。

非常感谢大家的帮助! @Petra 和另一个评论似乎已被删除的人非常有帮助!我已经解决了保存问题。这是最终代码。它确实有效并且通常会产生良好的结果。我的一些图像的分辨率不是很好,所以我确实得到了一些误报,其中 2 个粒子非常接近,一些未聚焦的光与 2 个信号重叠,但我会继续尝试调整,因为宏完全有效! :) 这是我一直在使用的最终代码:

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];
 file4 = dir2 + list[i];
 file3 =  replace(file3, ".tif", "Summary.csv");
 file4 =  replace(file4, ".tif", "Results.csv");
 open(file1);
 Title = getTitle();
 Title = replace(Title, ".tif", "");
 run("Stack to Images");
 selectWindow(Title+"-0001");
 rename ("mNG-"+Title);
run("Subtract Background...", "rolling=50");
 setAutoThreshold("RenyiEntropy dark");
 //run("Threshold...");
  setThreshold(400, 65535);
 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=[Bare Outlines] display exclude summarize in_situ");
 run("Fill Holes"); 
 run("Watershed");
selectWindow(Title+"-0002");
 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=[Bare Outlines] display exclude summarize in_situ");
 run("Fill Holes");
 run("Watershed");
imageCalculator("ADD create","mNG-"+Title,"tdT-"+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(".tif", file2);
 run("Close All");
} 
setBatchMode(false); 
selectWindow("Summary");
saveAs("text", file3);
selectWindow("Results");
saveAs("text", file4);
run("Close All");

再次感谢大家的帮助!