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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Matiar Jafari
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.

Thank You
----
Matiar

ps sorry if its posted multiple times im still new to this listserv and how it works
Reply | Threaded
Open this post in threaded view
|

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

Wayne Rasband
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;
             }
          }
    }
Reply | Threaded
Open this post in threaded view
|

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

Matiar Jafari
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
Reply | Threaded
Open this post in threaded view
|

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

Wayne Rasband
On Dec 6, 2009, at 10:22 PM, Matiar Jafari wrote:

> 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?

Use the Help>Update ImageJ command to upgrade to the latest version of  
ImageJ (1.43l). The Array.trim macro function was added in v1.42j.

-wayne

> 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