Login  Register

4 measurements macro

Posted by Adam Huttenlocker on Jun 02, 2014; 3:34am
URL: http://imagej.273.s1.nabble.com/4-measurements-macro-tp5007976.html

Hello ImageJ enthusiasts.

I am trying to write code for a series of macros that record 'n'
measurements (in this case 4) in 'n' separate columns. I did this by
modifying an old script called the 'Measure3lengths' macro and trying to
add a 4th column, but I keep getting an error message when I try to run it.

Can anyone see what the problem is in my code (copied below)?


var length1=-1, length2=-1, length3=-1, length4=-1;

macro "Measure Length 1 [a]" {
    requires("1.30h");
    length1 = getLength(1);
 }

macro "Measure Length 2 [s]" {
    length2 = getLength(2);
 }

macro "Measure Length 3 [d]" {
    if (length1==-1)
        exit("Length1 is missing");
    if (length2==-1)
        exit("Length2 is missing");
    length3 = getLength(3);
}

macro "Measure Length 4 [f]” {
    if (length1==-1)
        exit("Length1 is missing");
    if (length2==-1)
        exit("Length2 is missing");
if (length3==-1)
        exit("Length3 is missing");
    length4 = getLength(4);
    print(getTitle()+" \t"+length1+" \t"+length2+" \t"+length3+”
\t”+length4+”);
    length1=-1; length2=-1; length3=-1; length4=-1;
}


function getLength(n) {
    getLine(x1, y1, x2, y2, width);
    getVoxelSize(width, height, depth, unit);
    length = sqrt((x2-x1)*(x2-x1)*width*width +
(y2-y1)*(y2-y1)*height*height);
    if (x1==-1)
        exit("Stright line selection required");
    showStatus("Length"+n+" = "+length+" "+unit);
    return length;
}




Adam K. Huttenlocker, PhD
Postdoctoral Research Fellow
Department of Biology, University of Utah
& Natural History Museum of Utah
Salt Lake City, UT 84112
Office: 801-585-7756
Cell: 303-808-6792

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html