/*Makes grid based on multi-purpose grid from Gundersen & Jensen (J Microsc. 1987, 147:229-6) for stereology quantification as non-destructive overlay. Options include lines and crosses of differnet density. Do not forget to "Set Scale" to get correct printout of grid parameters. Parameters of the grid are reflected in "Multipurpose grid parameters" text window. Version: 0.1 Date: 14/08/2011 Author: Aleksandr Mironov amj-box@mail.ru */ //Initial dialog Dialog.create("Multipurpose stereological grid"); Dialog.addMessage("Version: 0.1"); Dialog.addMessage("Based on multipurpose grid from \nGundersen & Jensen, J Microsc. 1987, 147:229-6"); Dialog.addMessage("Please, set scale for correct measurements"); Dialog.addMessage("\n "); Dialog.setInsets(0, 20, 0); Dialog.addChoice("Set grid dimensions:", newArray("by tiles density", "by area per point")); Dialog.addMessage("Grid tile includes 4 regular points and 2 segmented lines"); Dialog.show(); dimensions = Dialog.getChoice(); getPixelSize(unit, pw, ph, pd); //Main dialog box Dialog.create("Grid parameters"); Dialog.addMessage(" GENERAL:"); Dialog.addCheckbox("Random Offset", true); Dialog.addCheckbox("New Overlay", true); Dialog.addNumber("Line thickness =", 1,0,2,"pixels"); if (dimensions=="by tiles density") { Dialog.addNumber("Tile* density =", 3,0,2,"per short side"); } else { Dialog.addNumber("Area per point =", 10000,2,8," "+unit+"^2"); }; Dialog.addMessage(" TEST POINTS:"); Dialog.addCheckbox("Encircled Points (1/4 of regular)", true); Dialog.addCheckbox("Dense Points (x4 of regular)", true); Dialog.addChoice("Regular points color:", newArray("cyan", "red", "yellow", "green", "blue", "magenta", "orange", "black", "white")); Dialog.addChoice("Dense points color:", newArray("green", "yellow", "red", "blue", "cyan", "magenta", "orange", "black", "white")); Dialog.addMessage(" TEST LINES:"); Dialog.addCheckbox("Horizontal segmented", true); Dialog.addCheckbox("Vertical segmented", false); Dialog.addCheckbox("Horizontal solid (x3 of segmented)", false); Dialog.addCheckbox("Vertical solid (x3 of segmented)", false); Dialog.addChoice("Line color:", newArray("cyan", "red", "green", "magenta", "blue", "yellow", "orange", "black", "white")); Dialog.addMessage("=========================================="); Dialog.addMessage("*Tile includes 4 regular points and 2 segmented lines"); Dialog.show(); //grid parameters offset = Dialog.getCheckbox(); new = Dialog.getCheckbox(); t = Dialog.getNumber(); dimens = Dialog.getNumber(); circ = Dialog.getCheckbox(); dense = Dialog.getCheckbox(); rpcolor = Dialog.getChoice(); dpcolor = Dialog.getChoice(); hor_seg = Dialog.getCheckbox(); ver_seg = Dialog.getCheckbox(); hor_sol = Dialog.getCheckbox(); ver_sol= Dialog.getCheckbox(); lcolor = Dialog.getChoice(); //initial settings for l/p vsg=hsg=vsl=hsl=0; //tile size getDimensions(width, height, channels, slices, frames); if (dimensions=="by tiles density") { if (width>=height) { ss = height; } else { ss = width; } tileside = ss/dimens; }else { tileside = sqrt(4*dimens/ph/pw); } pointd = tileside/4; pointr = tileside/2; //check overlay if (new == true) run("Remove Overlay"); //creating random offset off1 = random; off2 = random; if (offset == false) off1 = off2 = 0.5; xoff = round(pointd*off1); yoff = round(pointd*off2); //Horizonal solid lines if (hor_sol == true){ y = yoff; while (true && y