// Split_Channels macro by Christophe Leterrier macro "Split_Channels_Batch" { //*************** Initialization *************** // Default values for the Options Panel ENH_DEF = false; ROLLING_DIAM = 50; UNSHARP_MASK = 0.35; SAT = 0.01; SAVE_DEF="In a folder next to the source folder"; // Get the folder name INPUT_DIR=getDirectory("Select the input stacks directory"); print("\n\n\n*** Split Channels Log ***"); print(""); print("INPUT_DIR :"+INPUT_DIR); // Initialize choices variables SAVE_ARRAY = newArray("In the source folder", "In a subfolder of the source folder", "In a folder next to the source folder", "In a subfolder with custom location"); //*************** Dialog *************** // Creation of the dialog box Dialog.create("Split Channels Options"); Dialog.addCheckbox("Enhance", ENH_DEF); Dialog.addChoice("Save Images", SAVE_ARRAY, SAVE_DEF); Dialog.show(); // Feeding variables from dialog choices ENH = Dialog.getCheckbox(); SAVE_TYPE = Dialog.getChoice(); // Get all file names ALL_NAMES=getFileList(INPUT_DIR); Array.sort(ALL_NAMES); ALL_EXT=newArray(ALL_NAMES.length); // Create extensions array for (i = 0; i < ALL_NAMES.length; i++) { // print(ALL_NAMES[i]); ALL_NAMES_PARTS = getFileExtension(ALL_NAMES[i]); ALL_EXT[i] = ALL_NAMES_PARTS[1]; } //*************** Prepare processing *************** setBatchMode(true); // Create the output folder OUTPUT_DIR="Void"; if (SAVE_TYPE == "In the source folder") { OUTPUT_DIR = INPUT_DIR; } if (SAVE_TYPE == "In a subfolder of the source folder") { OUTPUT_DIR = INPUT_DIR + "split" + File.separator; if (File.isDirectory(OUTPUT_DIR) == false) { File.makeDirectory(OUTPUT_DIR); } } if (SAVE_TYPE == "In a folder next to the source folder") { OUTPUT_DIR = File.getParent(INPUT_DIR); OUTPUT_NAME = File.getName(INPUT_DIR); OUTPUT_SHORTA = split(OUTPUT_NAME, " "); OUTPUT_SHORT = OUTPUT_SHORTA[0]; OUTPUT_DIR = OUTPUT_DIR + File.separator + OUTPUT_SHORT + " split" + File.separator; if (File.isDirectory(OUTPUT_DIR) == false) { File.makeDirectory(OUTPUT_DIR); } } if (SAVE_TYPE == "In a folder with custom location") { OUTPUT_DIR = getDirectory("Choose the save folder"); INPUT_NAME = File.getName(INPUT_DIR); OUTPUT_DIR = OUTPUT_DIR + File.separator + INPUT_NAME + " split" + File.separator; if (File.isDirectory(OUTPUT_DIR) == false) { File.makeDirectory(OUTPUT_DIR); } } OUTPUT_PARENT_DIR=File.getParent(OUTPUT_DIR); print("OUTPUT_DIR: " + OUTPUT_DIR); print("OUTPUT_PARENT_DIR: " + OUTPUT_PARENT_DIR); //*************** Processing *************** // Loop on all .tif extensions for (n=0; n 2) { for (k = 1; k < nameparts.length - 1; k++) { shortname += "." + nameparts[k]; } } extname = "." + nameparts[nameparts.length - 1]; namearray = newArray(shortname, extname); return namearray; }