// Extracts ROI's from frontloaded ROI selections // This script is meant to be run after ROI selection is comlpleted for a given directory. // Given the stacks and ROIs for each video, this script runs through each video and extracts the fluorescence time traces for each ROI. The subsequent file is saved in CSV format and can be batch imported into a matlab file sttructure with the CSV_process_dLight.m script. // ========================================================= // Written by Wilson Adams | Siciliano Lab | Nov 2021 // ========================================================= // Select directory with files directory = getDirectory("Choose a directory..."); filelist = getFileList(directory) ; // Initiate processing print("Starting Processing: " + directory); Array.show(filelist); // Adjust the measurements you want for each ROI run("Set Measurements...", "mean redirect=None decimal=3"); // Loop through each tiff stack for (i = 0; i < lengthOf(filelist); i++) { // Only open if it's a tiff stack if (endsWith(filelist[i], ".tif")) { roiManager("reset"); // Once extracted, the 'Tiff Virtual Stack' command is faster than Bioformats run("TIFF Virtual Stack...", "open=["+directory + File.separator + filelist[i]+"]"); // Get rid of the .tif extension from the file name addname = File.getNameWithoutExtension(directory + File.separator + filelist[i]); // Open the corresponding ROI file for each stack and measure roiManager("open", directory + File.separator + "processing" + File.separator+addname+"_roi.zip"); roiManager("multi-measure one"); // Save Results to a CSV file in the processed directory saveAs("Results", directory + File.separator + "processing" + File.separator+addname+"_results.csv"); // Close everything up close("*"); close("Results"); } }