图像J中单个和双阳性粒子的分批处理



这是我在第一个宏成功后第二次尝试编写宏(几乎没有编码知识(,但我添加了一层复杂性,似乎无法使其发挥作用。

我正在尝试建立一个批处理过程,在这个过程中,我计算两种不同颜色的粒子,然后这些粒子中的哪一个对两种颜色都是阳性的。我得到这个错误:

错误:第38行中应为"(":selectWindow("Result of"-"+Title"(;

我真的不知道我需要修复什么,因为我似乎已经关闭了所有的括号。然而,我知道根本问题是我不知道如何通用地命名我感兴趣的窗口。这是一个由宏创建的窗口,而不是输入文件之一。

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

如果我能得到关于为什么我的语法是错误的帮助,以及关于如何用第三个结果对窗口进行通用命名的反馈,我将不胜感激

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

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

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

如果这没有帮助,你能给我一个你的数据的例子,这样我就可以正确地测试它

非常感谢您的帮助@佩特拉和另一个评论似乎已被删除的人非常有帮助!我已经解决了保存问题。这是最后的代码。它确实有效,通常会产生良好的结果。我的一些图像的分辨率不太好,所以我确实得到了一些误报,其中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");

再次感谢您的帮助!

最新更新