//Jan Wisniewski, Experimental Immunology Branch, National Cancer Institute, National Institutes of Health, Bethesda, Maryland 20892, USA //This macro measures relative area (%) covered by growing cells. //It requires 16-bit grayscale DIC or similar image taken with 10x objective. //Results are compiled into spreadsheet and maps showing selected cell areas are save for inspection. print("Measurement of cell growth area\nJan Wisniewski, Experimental Immunology Branch\nNational Cancer Institute, NIH, Bethesda, Maryland 20892, USA"); getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec); print(""); print("run: ", month, "/", dayOfMonth, "/", year, " at ", hour, ":", minute); print(""); //set measured parameters run("Set Measurements...", "area mean min bounding integrated median display redirect=None decimal=2"); //create custom table title1 = "Analysis Table"; title2 = "["+title1+"]"; f=title2; run("New... ", "name="+title2+" type=Table"); print(f,"\\Headings:Image\tGrowth_Area_(%)"); results=getDirectory("Choose a Folder to store Results"); source=getDirectory("Select Source Directory"); NAMES=getFileList(source); for (i = 0; i < NAMES.length; i++) {open(source+NAMES[i]); ttl=File.nameWithoutExtension; getDimensions(width, height, channels, slices, frames); whole=width*height; rename("x"); run("Duplicate...", "title=m"); run("Find Edges"); run("Threshold..."); setAutoThreshold("Default dark"); waitForUser("Adjust Threshold - In a Threshold box use use Only Slider!\nWhen done, click OK here!\nLeave quite generous scatter of pixels even in areas to be excluded!\n- those will be filtered out by software"); run("Convert to Mask"); run("Median...", "radius=5"); run("32-bit"); run("Divide...", "value=255"); setMinAndMax(0, 1); run("Invert"); run("Macro...", "code=[if(v>0) {v=1; }]"); setMinAndMax(0, 1); run("Invert"); run("Measure"); cells=getResult("RawIntDen"); growth=100*cells/whole; print(ttl, "growth area=", growth, "%"); close("Result of x"); selectWindow("m"); run("Make Binary"); run("Outline"); run("Red"); run("RGB Color"); selectWindow("x"); run("RGB Color"); imageCalculator("Max create", "x","m"); saveAs("Tiff", results+ttl+"_masked"); close(); close(); close(); close("Results"); selectWindow("Analysis Table"); print(f,ttl+"\t"+growth); } close("Log"); selectWindow("Analysis Table"); saveAs("Text", results+"Analysis_Results.csv"); close("Analysis Table");