//Please set following parameters: //(Remeber to save changes) //The value should be an area [number in pixel^2 e.g. 20] area_of_the_smallest_region_of_interest = 20; //Choose "auto" (with quotes) for auto local threshold processing, or "manual" (with quotes) for manual adjustment of global threshold threshold_type = "manual"; /////////////////////////////////////////////////////Do not change code below this line//////////////////////////////////////////////////////////////////////////////// run("Set Measurements...", "area display redirect=None decimal=3"); macro_path = getInfo("macro.filepath"); upplim = area_of_the_smallest_region_of_interest*500; choice = "Analyze next image"; while(choice == "Analyze next image" ){ run("Close All"); run("Open..."); path=getDirectory("image"); name=getTitle; output="Drawing of "+name; newfolder = path+substring(path,lengthOf(path)-1,lengthOf(path))+"results"+substring(path,lengthOf(path)-1,lengthOf(path)); selectWindow(name); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); setLocation(1097, 122); run("Duplicate...", " "); duplicate = substring(name,0,lengthOf(name)-4)+"-1.tif"; run("Subtract Background...", "rolling=50 sliding"); if(threshold_type == "manual"){ run("Threshold..."); call("ij.plugin.frame.ThresholdAdjuster.setMode", "B&W"); wait(500); setThreshold(30, 255); waitForUser("Set threshold"); getThreshold(lower, upper); run("Analyze Particles...", "size=area_of_the_smallest_region_of_interest-upplim pixel show=Outlines clear summarize"); selectWindow(name); selectWindow("Drawing of "+duplicate); run("Add Image...", "image=[name] x=0 y=0 opacity=70"); waitForUser("Compare images"); Dialog.create("Is correction needed?"); Dialog.addCheckbox("Is correction needed?", false); Dialog.show(); correction = Dialog.getCheckbox(); while (correction) { selectWindow("Drawing of "+duplicate); close(); selectWindow(duplicate); run("Threshold..."); setThreshold(lower, 255); waitForUser("Set threshold"); IJ.deleteRows(0, 0); getThreshold(lower, upper); run("Analyze Particles...", "size=area_of_the_smallest_region_of_interest-upplim pixel show=Outlines clear summarize"); selectWindow(name); selectWindow("Drawing of "+duplicate); run("Add Image...", "image=[name] x=0 y=0 opacity=70"); waitForUser("Compare images"); Dialog.create("Is correction needed?"); Dialog.addCheckbox("Is correction needed?", false); Dialog.show(); correction = Dialog.getCheckbox(); } } if(threshold_type == "auto"){ run("Auto Local Threshold...", "method=Phansalkar radius=15 parameter_1=0 parameter_2=0 white"); run("Invert"); run("Analyze Particles...", "size=area_of_the_smallest_region_of_interest-upplim pixel show=Outlines clear summarize"); } if (!File.exists(newfolder)){ File.makeDirectory(newfolder); } selectWindow(name); selectWindow("Drawing of "+duplicate); run("Add Image...", "image=[name] x=0 y=0 opacity=70"); selectWindow("Drawing of "+duplicate); saveAs("Tiff", newfolder+output); if (threshold_type == "manual") {print(output); print("Lower threshold value:"); print(lower); print(" ");} selectWindow(duplicate); close(); Dialog.create("Work finished."); Dialog.addMessage("Remeber to copy and store data from 'Summary' window"); if (threshold_type == "manual") {Dialog.addMessage("Lower threshold value is displayed in 'Log' window");} Dialog.addChoice("What would you do next?:", newArray("Analyze next image", "Set FA size boundaries","Nothing - Close this window", "Change threshold type", "Quit")); Dialog.show(); choice = Dialog.getChoice(); if(choice == "Set FA size boundaries"){ if (threshold_type == "manual"){ selectWindow("Log"); run("Close"); selectWindow("Threshold"); run("Close");} selectWindow("Summary"); run("Close"); selectWindow("Drawing of "+name); close(); run("Edit...", "open=["+macro_path+"]"); selectWindow(name); run("ROI Manager..."); //setTool("polygon"); waitForUser("Measure area of smallests focal adhesion sites"); } if(choice == "Change threshold type"){ if (threshold_type == "manual"){ selectWindow("Log"); run("Close"); selectWindow("Threshold"); run("Close");} run("Close All"); run("Edit...", "open=["+macro_path+"]"); } if(choice == "Quit"){ if (threshold_type == "manual"){ selectWindow("Log"); run("Close"); selectWindow("Threshold"); run("Close");} run("Close All"); } }