Login  Register

Re: how to stop the freehand lines tool at a set distance (20 um)

Posted by Matiar Jafari on Dec 07, 2009; 3:22am
URL: http://imagej.273.s1.nabble.com/how-to-stop-the-freehand-lines-tool-at-a-set-distance-20-um-tp3690197p3690199.html

Dear Wayne Rasband,

Thanks for the macro, but i encountered an error when i use the tool  
to draw i get this error

Undefined variable in line 17 xpoints2= <Array> .trim(xpoints , l);

any help?
On Dec 6, 2009, at 5:38 PM, Wayne Rasband wrote:

> On Dec 6, 2009, at 7:02 AM, Matiar Jafari wrote:
>
> > Dear ImageJ Listserv,
> >
> > I'm looking for a way to draw lines of a set length on
> > ImageJ.  I need to measure spines on dendrites every 20 um
> > from the soma on dissociated neurons grown in tissue
> > culture.  I've tried using a modified Sholl analysis, but
> > without the laminar constraints the dendrites grow with
> > various curves.  I would like to use the freehand lines tool
> > to stop at 20 um as I trace along the dendrite.
>
> Here is a tool that you can use to draw freehand lines of a  
> specified length. The default length of 20 can be changed by  
> assigning a another value to the 'maxLength' variable. The default  
> length is 20um if the image is scaled to micrometers. The online  
> manual explains how to install macro tools:
>
>    http://rsb.info.nih.gov/ij/developer/macro/macros.html#tools
>
> -wayne
>
>  macro "Set Length Line Tool - C00bL1de0L1ee1" {
>        maxLength = 20;
>        leftClick=16
>        i = 0;
>        xpoints = newArray(2000);
>        ypoints = newArray(2000);
>        getCursorLoc(x2, y2, z, flags);
>        xpoints[i]=x2; ypoints[i++]=y2;
>        while (true) {
>            getCursorLoc(x, y, z, flags);
>            if (flags&leftClick==0) exit();
>            if (x!=x2 || y!=y2) {
>               xpoints[i] = x;
>               ypoints[i] = y;
>               i++;
>               x2=x; y2=y;
>               xpoints2 = Array.trim(xpoints, i);
>               ypoints2 = Array.trim(ypoints, i);
>               makeSelection("freeline", xpoints2, ypoints2);
>               List.setMeasurements;
>               length = List.getValue("Length");
>               showStatus("length="+d2s(length,2));
>               if (length>=maxLength) exit;
>            }
>         }
>   }

Thank You
-------
Matiar Jafari