|
Hello all,
I am an ImageJ macro newbie, but am trying my best to figure things out. Essentially, I am trying to write a macro which uses the "Colocalization" plugin to check the colocalization of my images, and then perform further analysis like Analyze Particles. The problem is that in the parameters of the "Colocalization" plugin, I have to write which images to choose as the two ones being analyzed. So far I wrote:
imageTitle=getTitle();
run("Colocalization ", "channel_1=[(imageTitle + " (red)")] channel_2=[(imageTitle + " (green)")]
ratio=50 threshold_channel_1=50 threshold_channel_2=50 display=255") ;
However, the parameters for the Colocalization plugin are in "quotations", but I also need to put "(red)"and (green) in quotations.
So I am getting an error message which says unexpected (') in this line.
Any way that I can fix this problem? Thanks so much!!
Total code below:
// "BatchProcessFolders"
//
// This macro batch processes all the files in a folder and any
// subfolders in that folder. In this example, it runs the Subtract
// Background command of TIFF files. For other kinds of processing,
// edit the processFile() function at the end of this macro.
requires("1.33s");
dir = getDirectory("Choose a Directory ");
setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
//print(count+" files processed");
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i]);
else {
showProgress(n++, count);
path = dir+list[i];
processFile(path);
}
}
}
function processFile(path) {
if (endsWith(path, ".tif")) {
open(path);
imageTitle=getTitle();
run("Split Channels");
run("Colocalization ", "channel_1=[imageTitle + "(red)"] channel_2=[imageTitle + '(green)'] ratio=50 threshold_channel_1=50 threshold_channel_2=50 display=255") ;
run("Split Channels");
setAutoThreshold("Default dark");
//run("Threshold...");
setAutoThreshold("Otsu dark");
setOption("BlackBackground", false);
run("Convert to Mask", "method=Otsu background=Dark calculate");
run("Analyze Particles...", "size=10-1000 show=Nothing summarize stack");
run("Analyze Particles...", "size=10-1000 show=Nothing summarize stack");
save(path);
close();
}
}
|