// Batch processing of ROIs, frontloaded // Build arrays of files tabulated //==================================== // Get file directory from user input dir = getDirectory("Navigate to the folder to be processed"); print("STARTING file extraction: "+dir); filelist = getFileList(dir); Array.show(filelist); // Loop through each folder in the parent directory //for (i = 0; i < 1; i++) { // for debugging one folder at a time for (i = 0; i < filelist.length; i++) { // only open folders, not files in the parent direcory if (endsWith(filelist[i], "/")) { // List image files in sub folder sublist = getFileList(filelist[i]); firsttif = dir+filelist[i]+"ChanA_001_001_001_001.tif"; // If folder has images in it, if (File.exists(firsttif)) { // Import image using Bioformats to preserve metadata. // Uses virtual stacks for speed and RAM, especially on server run("Bio-Formats Importer", "open=[&firsttif] color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT use_virtual_stack"); // Rename all of the files once imported (assumes MANTIS) runMacro("SicLab_imgrename_ext.ijm"); // Save in parent directory and close all of the images wins = getList("image.titles"); // DO PROCESSING IN HERE for (j = 0; j < wins.length; j++) { selectWindow(wins[j]); //save(dir+wins[j]+".tif"); n_avg = 50; run("Z Project...", "stop=&n_avg projection=[Average Intensity]"); avgip = getTitle(); run("Enhance Contrast", "saturated=0.35"); save(dir+wins[0]+"_avgip.tif"); // Step 2: Prompt user for ROIs setTool("ellipse"); waitForUser("Draw ROIs on image. Press 'T' to add them to the ROI manager"); roiManager("show all with labels"); roiManager("save", dir+"\\"+wins[0]+"_roi.zip"); // Close out of window close("*"); } // Print progress once images are extracted print(filelist[i]+" COMPLETE"); } // end of 'file exist' if stmt } // end of title folder if statment } // end of image folder for loop print(dir+" COMPLETE");