Reputation: 1
I am trying to analyze confocal microscopy image for cFos analysis. From maxstacked image, I took ROI of DAPI and enlarged the ROI to detect the degree of expression of transgene marker. So I can find whether expression of transgene Piezo1 is related to increase of cFof level.
Here's the problem, when I took ROI twice by processing DAPI image differently worked well, but this has a consideration that the sequence of both ROI groups might be not same. So I tried to enlarge the ROI from DAPI image, but then I am having trouble in loop analysis. The macro runs for ever, but seems like to be saving same file names again and again, even with skipping some of the files in array.
Thank you for reading.
//The one is in trouble
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("*");
}
}
//The one worked
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("*");
}
}
Upvotes: 0
Views: 377
Reputation: 63
I think you created an endless loop, because you use i
both times. So in the second for loop the i
is set back to 0. Just try changing it in the second one (you can choose whatever letter or word).
...
for(n=0; n<roiN; n++) {
roiManager("Select", n);
run("Enlarge...", "enlarge=2.7");
roiManager("Update");
}
...
Upvotes: 0