706 views

Skip to first unread message

Feb 13, 2017, 2:33:33 PM2/13/17

to idTracker users

Hey

I'm new to idtracker software and have no idea what to do with the trajectory file. Can anyone help me in calculating the distance moved graph and velocity graph?

Mar 26, 2017, 11:37:58 AM3/26/17

to idTracker/idSocial users, v.sudanmadd...@gmail.com

Loading the trajectory or trajectories no gaps file into matlab creates two files, probable trajectories and trajectories in the matlab workspace (bottom right - depending on your configuration).

the trajectories file is a 3 dimensional matrix containing XY coordinates (no. frames, no. objects, XY).

you can use this to determine total distance moved by each individual fish by calculating the absolute difference in both X and Y coordinates between each frame.

first you have to define the x axis and y axis, so for example..

x = trajectories( : , : , 1 ) would be the x coordinates and y = trajectories( : , : , 2 ) will be the y coordinates.

then you can calculate the (absolute) difference (absolute because some values may be negative, but for the purposes of totalling the distance travelled you do not want negative values) between each frame along the x and y axis:

differences = abs(diff(x)+diff(y))

this will give you an output array similar to what you started with but containing inter-value differences.

you should then total up these differences:

totaldistance = sum(differences)

that should look something like this:

value1, value2, value3, value4, value5....

...and so on depending on how many objects the software is tracking

you could then plot the values as a histogram for example:

hist(sumdifferences)

so I have been using the example video of the 5 zebrafish to try and write my code. And I have been aiming to get the same kind of information you asked for.

here is my working code so far for total distance:

load trajectories_nogaps

%Reset NaN to 0

trajectories(isnan(trajectories)) = 0;

%XY trajectories

x = trajectories(:,:,1);

y = trajectories(:,:,2);

%Calculate total distance

xydistance = (abs(diff(x))) + (abs(diff(y)));

totaldistance = sum(xydistance);

%Plot data%

bar(totaldistance)

title('Total Distance Moved')

ylabel('distance(pixels)')

xlabel('individual')

axis([0 6 80000 180000])

I'm still pretty new to coding so and MATLAB in particular so there may be an easier way. I'm still working on velocity.

Hope this helps.

Message has been deleted

Nov 20, 2017, 9:14:40 AM11/20/17

to idTracker/idSocial users

Hi

mikegre...@gmail.com Did you get any improvement from you analysis from distance and velocity? I have a great interest in both distance and velocity, but could not advance much. It seems it is quite simple for regular user, but i am not able even to use this mat lab. any help will be very welcome Marcelo |

Aug 3, 2020, 3:19:57 PM8/3/20

to idTracker/idSocial users

Can you clarify the decision to use "**xydistance = abs(diff(x)+diff(y))**" to determine distance between coordinates? This is not a true calculation of the Euclidean distance.

Regardless, thanks for your input!

Joe

Aug 3, 2020, 3:54:16 PM8/3/20

to idTracker/idSocial users

Courtesy to Mike's steadfast reply, here is the clarification to calculate the Euclidean distance:

**xydistance= abs(sqrt ( (diff(x).^2) + (diff(y).^2) ))**

Thanks again, Mike!

Joe

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu