// General Batch Processing // ============================================== // Wilson R Adams | Vanderbilt Biophotonics Center | 17 Feb 2021 // ============================================== directory = getDirectory("Choose a folder to batch process"); filelist = getFileList(directory); Array.show(filelist); for (i = 0; i < lengthOf(filelist); i++) { if (endsWith(filelist[i], ".tif")) { print("Opening "+ filelist[i]); open(directory + filelist[i]); inputimg = getTitle(); print("Processing " + filelist[i]); // Insert your funtion under here to be processed on each image. elastinlengths(inputimg); } print("Finished " + filelist[i]); } print("Finished Processing"); // Paste function of interest below. Make sure it closes everything at the end function elastinlengths(img) { // Uses ridge detection to segment out elastin fiber features and quantifies their lengths. // Prep roiManager("reset"); imdir = getInfo("image.directory"); pardir = File.getParent(imdir); resdir = imdir+File.separator+"Results"; File.makeDirectory(resdir); // make results directory selectWindow(img); name = File.nameWithoutExtension; // get filename variable to rename outputs // Start Processing - Prep image for function run("Duplicate...", " "); wrk = getTitle(); run("Enhance Contrast", "saturated=0.35"); run("Enhance Contrast", "saturated=0.35"); //run("Gaussian Blur...", "sigma=1"); // does this help? - no not really. run("8-bit"); // Needs 8bit grayscale to run plugin // Run function to get fiber length run("Ridge Detection", "line_width=3 high_contrast=100 low_contrast=0 extend_line displayresults add_to_manager make_binary method_for_overlap_resolution=NONE sigma=1.37 lower_threshold=0 upper_threshold=4.25 minimum_line_length=10 maximum=0"); // Rejecting fibers shorter than 10px close("Junctions"); close("Results"); selectWindow("Summary"); saveAs("Results", resdir+File.separator+name+"_Summary.csv"); close(name+"_Summary.csv"); roiManager("save", resdir+File.separator+name+"_ROI.zip"); selectWindow(wrk+" Detected segments"); save(resdir+File.separator+wrk+" Detected segments.tif"); close(); close(); roiManager("reset"); close(); };