Step 1: Macro for automatically splitting the two channels, adjusting the brightness, and saving the resulting images to a chosen folder.
Before running the macro, have all original images in a folder of any name. This is where your Source Directory will be.
Create a second folder of any name outside of the Source Directory. This is where your resulting images will be saved to (Output Directory).
To open a new Macro window: Plugins -> New -> Macro
Copy and paste this macro script into a new Macro window.
!NOTE: When the macro is running, a popup window for each image may appear, depending on the type of image file, click OK to continue.
An orange colour with “//” in front denotes comments and will not be included in the code when run.
If you want to know what each of the steps does, simply add the double dashes “//” in front of all of the steps that follow, to exclude them out from the pipeline, or simply copy and paste just one of the command lines into a new Macro window, then click Run.
//Choose the folder (Source Directory) where your original images are stored.
selectedFolder = getDirectory("Choose Source Directory ");
//the getFileList function returns an array of all the file names present in the selectedFolder.
fileList = getFileList(selectedFolder);
//the lengthOf function counts the number of files in the fileList array (which, by extension, is in the Source Directory).
numFiles = lengthOf(fileList);
//Choose the folder where the exported images are to be saved.
saveloc = getDirectory("Choose Ouput Directory");
//This is optional, but you can print out the number of files from the Source Directory folder, as a way of checking if the code is working. A window will pop up, showing the number of files.
print(numFiles)
//BatchMode automatically turns off any open image window to avoid cluttering. You can turn this off too.
setBatchMode(true);
//This whole block below is an iteration command that will go through each file in the Source Directory, convert the images to 8-bit, adjust their brightness, and save them in your selected folder.
for (i=0;i<numFiles;i++) {
file = fileList[i];
open(selectedFolder + file);
//Make sure to untick the Split Channels option for multichannel images, in the Bio-Formats Import Option popup window, before the next command. Then, press Enter to continue.
run("Split Channels");
selectWindow("C2-" + file);
run("8-bit");
run("8-bit");
rename("1"); //Rename the image to easier select window later on
run("Duplicate...", " ");
selectWindow("1-1");
run("Brightness/Contrast...");
setMinAndMax(0, 20);
//Save images with a prefix “Area_” or “Dextran_” appended to the original file name.
saveAs("Tiff", saveloc + "Area_" + file);
selectWindow("1");
saveAs("Tiff", saveloc + "Dextran_" + file);
run("Close All");
}