// Extract_LIF macro by Christophe Leterrier // 19-10-2011 // // Takes a folder of raw Leica LIF images and extracts them to .tif images/stacks, separating channels (C=X). // The extracted images/stacks are located in a folder defined in the menu. // Other options : reset spatial scales, reads ROIs stored in Axiovision, close all images at the end. // // Folder Structure: // // •Experiment folder // |–•Extracted (created from raw images by this macro) // // Updates: // 14-11-2010: Changed the save options, with two options for saving in the 'Data Edit' folder. // these options depend on the folder structure which is specified by SOURCE_DIR and DEST_DIR folder names macro "Extract_LIF" { // Default values for the Options Panel RESET_SCALE_DEF=true; CATCH_ROIS_DEF=false; CLOSE_IMAGES_DEF=true; SAVE_DEF="In a folder next to the source folder"; // Defaults raw and processed image folders for the 'Data Edit' saving modes // These folders MUST BE 'brother folders' next to each other in the path for images // because the switch from one to another is relative. // This allows to work on any computer regardless of the absolute path SOURCE_DIR = "Data Raw"; DEST_DIR = "Data Edit"; // Get the folder name INPUT_DIR=getDirectory("Select a directory"); print("\n\n\n*** Extract_LIF Log ***"); print("INPUT_DIR :"+INPUT_DIR); // Initialize choices variables SAVE_ARRAY = newArray("'Extracted' in the 'Data Edit' folder", "Same folder in the 'Data Edit' folder", "In the source folder", "In a subfolder of the source folder", "In a folder next to the source folder", "In a custom folder"); // Creation of the dialog box Dialog.create("Extractor Options"); Dialog.addCheckbox("Reset Spatial Scale", RESET_SCALE_DEF); Dialog.addCheckbox("Catch ROIs", CATCH_ROIS_DEF); Dialog.addCheckbox("Close Images", CLOSE_IMAGES_DEF); Dialog.addChoice("Save Images", SAVE_ARRAY, SAVE_DEF); Dialog.show(); // Feeding variables from dialog choices RESET_SCALE=Dialog.getCheckbox(); CATCH_ROIS=Dialog.getCheckbox(); CLOSE_IMAGES=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; i0) { run("From ROI Manager"); } // rename image according to processing // 07-09-2011 removed multi-channel condition for TYPE NEW_WINDOW_NAME=FILE_SHORTNAME+"-"+SERIES_NAMES[s]+"-C="+TEMP_CHANNEL; rename(NEW_WINDOW_NAME); // Create output file path and save the output image OUTPUT_PATH=OUTPUT_DIR+NEW_WINDOW_NAME+".tif"; save(OUTPUT_PATH); print("OUTPUT_PATH: "+OUTPUT_PATH); // Close output image if checked if (CLOSE_IMAGES==true) { close(); } } // end of FOR loop on channels } //end of FOR loop on series }// end of IF loop on tif extensions }// end of FOR loop on all files setBatchMode("exit and display"); print(""); print("*** Extract_LIF end ***"); showStatus("Extract LIF finished"); // exec("open", OUTPUT_DIR); }