Measuring fly coordinates in ctrax

186 views
Skip to first unread message

andrew bellemer

unread,
Aug 11, 2011, 4:01:36 PM8/11/11
to ctrax
I am interested in using ctrax to measure the chemosensory preference
of wild-type and mutant flies. For an arena, I am using a petri dish
filled almost to the brim with agar and then covered with a lid,
forcing the flies to walk on the agar's surface. I have been able to
reliably obtain high quality movies by backlighting this arena with an
acrylic diffuser and ambient room lighting (I can provide more details
of the imaging setup if anyone is interested).

To measure chemosensory preference, I would like to add different
compounds to the agar in different regions of the arena and then
measure whether individual flies spend more or less time in these
areas. The heat map and individual fly paths give me a good way of
eyeballing whether this is working or not, but it would be even better
if I could determine how many frames each fly spent within a specific
range of coordinates in the arena. Does the behavioral microarray
toolbox already have a feature that will let me do this? Or if not,
would it be reasonable to try to write code that would do this? I
should mention that I am new-ish to Matlab.

Thanks very much for any help. I'll be happy to provide more
information if needed.

Best,
Andy

John Bender

unread,
Aug 11, 2011, 4:36:46 PM8/11/11
to ct...@googlegroups.com
Hi Andy,

I don't think that functionality exists already in the toolbox, but it
would be quite straightforward to write your own script to perform
that analysis.

Start by loading the data into your script using load_tracks(), which
will return a 'trx' variable including the following fields:
http://ctrax.sourceforge.net/bmat.html#load-tracks-m

You can use 'x' and 'y' to get the raw positions of each fly in
pixels, or if you also run convert_units(), you can have the x and y
positions in millimeters. Matlab's find() function will give you the
frame numbers where your fly meets certain criteria, and if you just
want to know the number of frames, use length().

For example, here's a really simple script that will get you partway there:

% define some constants
target_x = 10; % left boundary of target area
target_y = 50; % top boundary of target area
target_width = 30; % width of target area
target_height = 30; % height of target area
n_flies = length( trx ); % number of flies tracked

% do the calculation
for f = 1:n_flies % for each fly
frames_in_target = find( trx(f).x > target_x & trx(f).x <
target_x+target_width & trx(f).y > target_y & trx(f).y <
target_y+target_height );
n_frames(f) = length( frames_in_target );
end

% a simple plot of the results
hist( n_frames )
xlabel( 'number of frames in target area' )
ylabel( 'number of flies' )


Hope that helps!

JB

> --
> You received this message because you are subscribed to the Google Groups "ctrax" group.
> To post to this group, send email to ct...@googlegroups.com.
> To unsubscribe from this group, send email to ctrax+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ctrax?hl=en.
>
>

andrew bellemer

unread,
Aug 12, 2011, 1:45:50 PM8/12/11
to ctrax
Thanks very much! This is fantastic! I will follow up and let you know
how it all ends up working.
Reply all
Reply to author
Forward
0 new messages