//**************************************************************************************** //Macro to calculate the Comet Assay and display the results. ImageJ 1.44C or later required. //Based on an NIH Image Comet Assay by Herbert M. Miller 1997 // //The image should have a dark background and light comets. The comets can have any orientation. //It is advisable to do a camera noise subtraction, flat field correction, and a background //subtraction before running the macro. // //The macro calculates tail length, tail moment, and % of DNA in the tail. // //There seems to be some imprecision in the definitions of "center" and "center of gravity" //in the literature. Here I define "center" as the "Centroid" - average of the X Y cordinates of all //pixels in a selection. This is sometimes called the "center of gravity" (Russ p489*). //The "Center of Mass" is the brightness weighted average of X Y cordinates of a selection. I use //Center of Mass of the tail and Centroid of the head in calculating the tail length. //The tail length as used here is the distance from the Centroid of the head to the Center of Mass //of the tail. It is calculated as the Pythagoran distance between these two points (Russ p520*). //The tail length variable is called CometLen in the code. // //Tail Moment is the length of the tail times the integrated density of the tail. // //Percent of DNA in the tail is the integrated density of the tail divided by the integrated density //of the tail plus the integrated density of the head times 100. // //The user is asked to draw an oval first around the head and then the tail. // //Results are placed on the results table. Each comet has two lines of results the first (odd numbered) //line has the head values the second (even numbered) line has the tail values. The values are as follows: //X and Y are coordinates of the Centroid, XM and YM are coordinates of the Center of Mass, //IntDen and RawIntDen are the same and are the integrated density, TailLen is the tail length, //TailMoment is the tail moment and %TailDNA is percent of total DNA that is in the tail. // //I have added options to mark the center of mass with the corresponding row number for the comet //being measured and to have the tail length, tail moment and % tail DNA data displayed in a separate window. //To implement these, remove the // marks from the beginning of the lines of code. // //*The Image Processing Handbook, 2nd ed, John Russ 1995 ISBN 0-8493-2516-1. // // R Bagnell, May 2011 //© C. Robert Bagnell, Jr., Ph.D. 2011 //****************************************************************************************** run("Set Measurements...", "centroid center integrated redirect=None decimal=3"); setFont("SansSerif", 18); setColor(255, 255, 255); //print("Tail Length Tail Moment % Tail DNA"); do { setTool("oval"); waitForUser("Draw an oval around the comet head; Click OK"); run("Measure"); waitForUser("Draw an oval around the comet tail; Click OK"); run("Measure"); i = nResults -1; tailx = getResult("XM", i); headx = getResult("X", i-1); taily = getResult("YM", i); heady = getResult("Y", i-1); tailden = getResult("RawIntDen",i); headden = getResult("RawIntDen",i-1); CometLen = sqrt( ((tailx-headx)* (tailx-headx)) + ((taily-heady)*(taily-heady)) ); setResult("TailLen",i,(CometLen)); setResult("TailMoment",i , (CometLen * tailden)); setResult("%TailDNA",i ,(tailden/(tailden + headden))*100); //print(CometLen," ", (CometLen * tailden)," ", (tailden/(tailden + headden))*100); updateResults(); label =toString (i + 1); drawString(label, tailx, taily); Dialog.create("Do Another?"); Dialog.addCheckbox("Yes", true); Dialog.show(); again = Dialog.getCheckbox(); } while (again ==true);