it supposed to take all the .nd files from a folder, do z-projection, set the channel color, adjust brightness and contrast and save them in a new folder as .tiff. However when I run it, it does it just for the first file multiple times

dir1 = getDirectory("Choose Source Directory");

dir2 = getDirectory("Choose Destination Directory");

list = getFileList(dir1);

setBatchMode(true);

for(i =0; i < list.length; i++){

if(endsWith(list[i], ".nd")){

open(dir1+list[i]);

run("Z Project...", "projection=[Max Intensity]");

rename("image");

run("Split Channels");

selectWindow("C1-image");

run("Brightness/Contrast...");

setMinAndMax(106, 200);

run("Blue");

run("RGB Color");

newname=replace(list[i], ".nd", "Blue.tif");

saveAs("Tiff", dir2 + newname);

run("Close");

selectWindow("C2-image");

run("Brightness/Contrast...");

setMinAndMax(105, 320);

run("Red");

run("RGB Color");

newname=replace(list[i],".nd", "Red.tif");

saveAs("Tiff", dir2 + newname);

run("Close");

selectWindow("C3-image");

run("Brightness/Contrast...");

setMinAndMax(102, 300);

run("Green");

run("RGB Color");

newname=replace(list[i],".nd", "Green.tif");

saveAs("Tiff", dir2 + newname);

run("Close");

run("Collect Garbage");

}

}

setBatchMode(false);

print("Finished!")

More Gianluigi Nocera's questions See All
Similar questions and discussions