// // ******************************************* // * * // * Channel Merging Script * // * made by Nicholas Condon * // * contact n.condon@uq.edu.au * // * * // ******************************************* // //AboutME: //This script is written in the ImageJ Macro Language //This script takes generates 2 or 3 channel images by merging single images into a composite .tif image. //This script lets the user define the output LUTs for each channel (RGBCMYK) // //NOTE: Input image files should be in order, with no duplicate images (ie. Files should all be Red,Green,Blue,Red,Green,Blue...) and be within a single folder. //Note: Output images (merged) must be placed in a seperate directory and not within the input folder. //Currently 4-channel images are not being merged properly and this functionally has been disabled temporarily. //IMB Splash screen showMessage("Institue for Molecular Biosciences ImageJ Script", "" +"

ACRF: Cancer Biology Imaging Facility

+"

The University of Queensland

+"

ImageJ Script Macro: Channel Merging Script

" +"

Created by Nicholas Condon 2018

" +"

This script takes single images from a folder and merges them into user defined channels. Folders should contain only images in the correct order (ie. Red, Green, Blue, Red, Green, Blue...) +" Directory structure should include a folder for Raw Images and one for merged images (not within the Raw Image Folder).

" +"" +"" +" contact n.condon@uq.edu.au" +"

" +" " +""); //Selecting the number of channels for final output images Dialog.create("Number of Channels"); Dialog.addMessage("Select the number of channels for your merged images") Dialog.addMessage(" ") // Dialog.addChoice("Number of channels:", newArray("2", "3", "4")); <------ //Blanked out as 4-channel not currently working Dialog.addChoice("Number of channels:", newArray("2", "3"));Dialog.show(); numChen = Dialog.getChoice(); //print(numChen); //Selecting the LUTs for each channel //For 2 channel images if (numChen=="2") { Dialog.create("Select LUT for Channels"); Dialog.addMessage("Select the LUTs for your two channels") Dialog.addMessage(" ") Dialog.addChoice("Channel1:", newArray("Red", "Green", "Blue", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.addChoice("Chennel2:", newArray("Green", "Red", "Green", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.show(); Channel1 = Dialog.getChoice(); Channel2 = Dialog.getChoice();; } //For 3 channel images else if (numChen=="3") { Dialog.create("Select LUT for Channels"); Dialog.addMessage("Select the LUTs for your three channels") Dialog.addMessage(" ") Dialog.addChoice("Channel1:", newArray("Red", "Green", "Blue", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.addChoice("Chennel2:", newArray("Green", "Red", "Green", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.addChoice("Chennel3:", newArray("Blue", "Red", "Green", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.show(); Channel1 = Dialog.getChoice(); Channel2 = Dialog.getChoice();; Channel3 = Dialog.getChoice();; } //For 4 channel images (Disabled) else if (numChen=="4") { Dialog.create("Select LUT for Channels"); Dialog.addMessage("Select the LUTs for your four channels") Dialog.addMessage(" ") Dialog.addChoice("Channel1:", newArray("Red", "Green", "Blue", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.addChoice("Chennel2:", newArray("Green", "Red", "Blue", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.addChoice("Chennel3:", newArray("Blue", "Red", "Green", "Grays", "Cyan", "Magenta", "Yellow")); Dialog.addChoice("Chennel4:", newArray("Grays", "Red", "Green", "Blue", "Cyan", "Magenta", "Yellow")); Dialog.show(); Channel1 = Dialog.getChoice(); Channel2 = Dialog.getChoice();; Channel3 = Dialog.getChoice();; Channel4 = Dialog.getChoice();; } //Prompt for user about directory structure title = "Folder Selection Selections"; msg = "First Select Input Directory, then Output Directory (must be two different folders)"; waitForUser(title, msg); //Directory selection dir1 = getDirectory("Choose Source Directory "); dir2 = getDirectory("Choose Destination Directory "); list = getFileList(dir1); setBatchMode(true); n = list.length; //2-channel merging section if ((n%numChen)!=0) exit("The number of files must be a multiple of "+numChen); stack = 0; first = 0; if (numChen==2) { for (i=0; i