ImageJ宏在ROI分析过程中存在循环错误



我正在尝试分析共聚焦显微镜图像用于cfo分析。从maxstacked图像中取DAPI的ROI,放大ROI来检测转基因标记的表达程度。由此可见转基因Piezo1的表达是否与cof水平升高有关。

这就是问题所在,当我通过处理DAPI图像不同地处理ROI两次时效果很好,但这考虑到两个ROI组的序列可能不相同。所以我试图扩大投资回报率从DAPI图像,但然后我有麻烦的循环分析。宏永远运行,但似乎一次又一次地保存相同的文件名,甚至跳过数组中的一些文件。

感谢您的阅读。

//有麻烦的那个

dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
Array.sort(list);
run("Clear Results");
setBatchMode(true);
for (i=0; i<list.length; i++) {
if (endsWith(list[i],"tif")) {
showProgress(i+1, list.length);
open(dir1+list[i]);
title = getTitle();
saveFilename = replace(list[i], "_Maxstacked.tif","");
selectWindow(title);     
run("Duplicate...", "title=DAPI duplicate channels=4");;

selectWindow("DAPI");
run("Subtract Background...", "rolling=80");     
run("Gaussian Blur...", "sigma=1");
run("8-bit");
run("Auto Threshold", "method=Li white");
run("Convert to Mask");
run("Minimum...", "radius=8");
run("Maximum...", "radius=9");
run("Watershed");
run("Analyze Particles...", "size=20-1000 display exclude clear include overlay add");
roiN = roiManager("count");
if (roiN > 0) {
roiManager("Save", dir2+saveFilename+"_DAPI+_RoiSet.zip");
for(i=0; i<roiN; i++) {
roiManager("Select", i);
run("Enlarge...", "enlarge=2.7");
roiManager("Update");
}
roiManager("Save", dir2+saveFilename+"_DAPI+_for_Piezo1_RoiSet.zip");
roiManager("Delete");
roiManager("Delete");
}    
close("*");
}
}

//那个成功了

dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
Array.sort(list);
run("Clear Results");
setBatchMode(true);
for (i=0; i<list.length; i++) {
if (endsWith(list[i],"tif")) {
showProgress(i+1, list.length);
open(dir1+list[i]);
title = getTitle();
saveFilename = replace(list[i], "_Maxstacked.tif","");
selectWindow(title);     
run("Duplicate...", "title=DAPI duplicate channels=4");
selectWindow(title);    
run("Duplicate...", "title=DAPI_for_Piezo1 duplicate channels=4");

selectWindow("DAPI");
run("Subtract Background...", "rolling=80");     
run("Gaussian Blur...", "sigma=1");
run("8-bit");
run("Auto Threshold", "method=Li white");
run("Convert to Mask");
run("Minimum...", "radius=8");
run("Maximum...", "radius=9");
run("Watershed");
run("Analyze Particles...", "size=20-1000 display exclude clear include overlay add");
roiN = roiManager("count");
if (roiN > 0) {
roiManager("Save", dir2+saveFilename+"_DAPI+_RoiSet.zip");
roiManager("Delete");
}    

selectWindow("DAPI");
run("Subtract Background...", "rolling=80");     
run("Gaussian Blur...", "sigma=1");
run("8-bit");
run("Auto Threshold", "method=Li white");
run("Convert to Mask");
run("Minimum...", "radius=8");
run("Maximum...", "radius=16");
run("Watershed");
run("Analyze Particles...", "size=20-1000 display exclude clear include overlay add");
roiN = roiManager("count");
if (roiN > 0) {
roiManager("Save", dir2+saveFilename+"_DAPI+_for_Piezo1_RoiSet.zip");
roiManager("Delete");
}    
close("*");
}
}

我认为你创造了一个无限循环,因为你两次都使用了i。所以在第二个for循环中,i被设置回0。试着在第二篇中修改一下(你可以选择任何一个字母或单词)。

...
for(n=0; n<roiN; n++) {
roiManager("Select", n);
run("Enlarge...", "enlarge=2.7");
roiManager("Update");
}
...

相关内容

  • 没有找到相关文章

最新更新