这是我处理这项任务的方式:
macro "Change and Resave" {
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
// Make an array of files ending " - GFP.vsi"
nd2list = newArray(0);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], " - GFP.vsi")) {
vsilist = append(vsilist, list[i]);
}
}
setBatchMode(true);
// loop through files
for (i=0; i<vsilist.length; i++) {
showProgress(i+1, vsilist.length);
// open file using Bio-Formats, you may need to edit these two lines
s = "open=["+dir1+vsilist[i]+"] autoscale color_mode=Composite rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT";
run("Bio-Formats Importer", s);
// your commands from your question
run("Green");
run("RGB Color");
saveAs("tiff", dir2+replace(vsilist[i],".vsi",".tif"));
close();
}
setBatchMode(false);
}
function append(arr, value) {
arr2 = newArray(arr.length+1);
for (i=0; i<arr.length; i++)
arr2[i] = arr[i];
arr2[arr.length] = value;
return arr2;
}