/*Makes grid based on multi-purpose grid from Gundersen & Jensen
(J Microsc. 1987, 147:229-6) for stereological 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 the "Multipurpose grid parameters" window.
Grid constant a/l (area per line unit) is used to estimate total lenght
of a flat stucture. Total lenght equals to number of intersections (between
linear feature and test lines) multiplied by PI/2 times the grid constant a/l.
Area per point can be used to estimate an area in 2D samples or volume density
in isotropic uniform random sections.
Test line per point (l/p) constant is used to estimate surface density (surface
area per unit volume in isotropic uniform random sections.
Version: 1.0
Date: 04/09/2014
Author: Aleksandr Mironov amj-box@mail.ru
*/
//help
html = ""
+"
Multipurpose Stereological Grid
"
+"based on Gundersen & Jensen (J Microsc. 1987, 147:229-6)
"
+"Standard grid tile includes 4 regular points and 2 segmented lines
"
+"Grid density can be set by number of tiles or by area per point
"
+"Options:
"
+"New Overlay - removes previous overlays
"
+"Random Offset - randomizes grid location
"
+"Tile density - determines density of the grid
"
+"Encircled Points - one additional point per grid tile
"
+"Dense Points - 16 additional points per grid tile
"
+"Points ratio:
"
+"Encircled:Regular:Dense = 1:4:16
"
+"Set Scale to get correct printout of the grid parameters,
"
+"which are reflected in the 'Multipurpose grid parameters' window
"
+"Useful parameters:
"
+" Area per point can be used to estimate an area in 2D samples
"
+"or volume density isotropic uniform random sections
"
+"Test line per point constant is used to estimate surface density
"
+"(surface area per unit volume) in isotropic uniform random sections
"
+"Grid constant a/l (area per line unit) is used to estimate total lenght
"
+"of a flat stucture. Total lenght equals to number of intersections
"
+"multiplied by PI/2 times the grid constant a/l
"
//Initial dialog
Dialog.create("Multipurpose Stereological Grid, ver. 1.0");
Dialog.setInsets(0, 20, 0);
Dialog.addChoice("Set grid dimensions:", newArray("by tiles density", "by area per point"));
Dialog.addHelp(html);
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.addHelp(html);
Dialog.show();
name = getTitle();
//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) Overlay.remove;
//creating random offset
off1 = random;
off2 = random;
if (offset == false) off1 = off2 = 0.5;
xoff = round(pointd*off1);
yoff = round(pointd*off2);
setColor(lcolor);
setLineWidth(t);
//Horizonal solid lines
if (hor_sol == true){
y = yoff;
while (true && y