// Time_Profiles macro by Christophe Leterrier macro "Time Profiles" { // Save Settings saveSettings(); // Default values for the Options Panel ROIS_EXT = "_ROIs.zip"; /* SUBTRACT_DEF = false; BG_DEF = false; UM_DEF = false; NORM_DEF = false; NORM_SNR_DEF = 2; // SNR for the Normalize_Movie macro STABILIZE_DEF = true; FTIM_DEF = false; FINT_DEF = 1; */ //*************** Dialog 1 : get the input images folder path *************** // Get the folder name INPUT_DIR = getDirectory("Select the input stacks directory"); print("\n\n\n*** Filter Timelapse Log ***"); print("INPUT_DIR :" + INPUT_DIR); //*************** Dialog 2 : options *************** // Creation of the dialog box /* Dialog.create("Time Profiles Options"); Dialog.addCheckbox("Running subtraction", SUBTRACT_DEF); Dialog.addCheckbox("Subtract background", BG_DEF); Dialog.addCheckbox("Unsharp Mask", UM_DEF); Dialog.addCheckbox("Normalize Intensity", NORM_DEF); Dialog.addNumber("Normalize SNR", NORM_SNR_DEF); Dialog.addCheckbox("Stabilize", STABILIZE_DEF); Dialog.addCheckbox("Force time interval", FTIM_DEF); Dialog.addNumber("Interval", FINT_DEF, 5, 3, "sec"); Dialog.show(); // Feeding variables from dialog choices SUBTRACT = Dialog.getCheckbox(); BG = Dialog.getCheckbox(); UM = Dialog.getCheckbox(); NORM = Dialog.getCheckbox(); NORM_SNR = Dialog.getNumber(); STABILIZE = Dialog.getCheckbox(); FTIM = Dialog.getCheckbox(); FINT = Dialog.getNumber(); */ //********************************************* // Get all file names ALL_NAMES = getFileList(INPUT_DIR); Array.sort(ALL_NAMES); PARENT_DIR = File.getParent(INPUT_DIR); // Loop on all .tif extensions for (n = 0; n < ALL_NAMES.length; n++) { FILE_NAME = ALL_NAMES[n]; FILE_EXT = substring(FILE_NAME, lastIndexOf(FILE_NAME, "."), lengthOf(FILE_NAME)); if (FILE_EXT == ".tif") { // Get the file path FILE_PATH = INPUT_DIR + FILE_NAME; print(""); print("INPUT_PATH:", FILE_PATH); // print("FILE_NAME:", FILE_NAME); // print("FILE_DIR:", INPUT_DIR); // print("FILE_SHORTNAME:", FILE_SHORTNAME); open(FILE_PATH); // Store file name without extension and extension FILE_SHORTNAME = File.nameWithoutExtension; STACK_ID = getImageID(); Stack.getDimensions(IM_W, IM_H, STACK_CH, STACK_SLICES, STACK_FRAMES); getPixelSize(pixelUnit, pixelWidth, pixelHeight); TIME_INT = Stack.getFrameInterval(); Stack.getUnits(X, Y, Z, timeUnit, Value); STACK_TITLE = getTitle(); // Open ROIset for this movie ROIS_NAME = FILE_SHORTNAME + ROIS_EXT; ROIS_PATH = INPUT_DIR + ROIS_NAME; print("ROIs_path: " + ROIS_PATH); ROINUMBER = roiManager("count"); if (ROINUMBER >0) { roiManager("Deselect"); roiManager("Delete"); } roiManager("Open", ROIS_PATH); ROINUMBER = roiManager("count"); for (i = 0; i < ROINUMBER; i++) { selectImage(STACK_ID); roiManager("select", i); imTitle = getTitle(); imNumber = getSliceNumber(); roiTitle = getInfo("selection.name"); RoiSplit = split(roiTitle, "-"); if (RoiSplit.length > 3) { Roi.setProperty("TracingType", RoiSplit[3]); Roi.setProperty("TypeName", RoiSplit[4]); } roiType = Roi.getProperty("TracingType"); roiTypeName = Roi.getProperty("TypeName"); ProfileName = imTitle + "-" + roiTitle; run("Plot Z-axis Profile"); rename(ProfileName); } selectImage(STACK_ID); close(); }// end of IF loop on tif extensions }// end of FOR loop on all files if (ROINUMBER >0) { roiManager("Deselect"); roiManager("Delete"); } run("Images to Stack", "name=[Profiles Stack] use"); save(INPUT_DIR + "Profiles.tif"); print(""); print("*** Time Profiles end ***"); showStatus("Time Profiles finished"); }