-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpscr_speedindidsonexample.m
70 lines (55 loc) · 1.8 KB
/
cpscr_speedindidsonexample.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
%% Create avi from Didson data relative to each "passing"
clear
close all
% Read test data
par.datadir = '\\callisto\collpen\AustevollExp\data\HERRINGexp';
par.parfile ='\\callisto\collpen\AustevollExp\data\HERRINGexp\CollPenAustevollLog.xls';
%\\callisto\collpen\AustevollExp\data\HERRINGexp\temporary files
D=dir(fullfile(par.datadir,'temporary files','*.mat'));
%22 4 4
fil = fullfile(par.datadir,'\scoring_package\didson\didson_block22_sub4_treat4.avi');
mov=aviread(fil);
%%
%
%bottle =[];
%wave =[];
pm = 512/9;% pixels per meter
dt = 8;% pings per second
load(fullfile(par.datadir,'bottlewavespeed_22_sub4_treat4.mat'))
for k=1:20
clf
m=imshow(mov(1).cdata);
t=text(22,34,num2str(i));
axis equal
hold on
for i=55:68
set(m,'Cdata',mov(i).cdata)
delete(t)
t=text(22,34,num2str(i),'Color','w');
if i>=bottle(1,1) && i<=bottle(end,1)
% Draw bottle
ind = (i==bottle(:,1));
plot(bottle(ind,2),bottle(ind,3),'r*')
end
if i>=wave(1,1) && i<=wave(end,1)
% Draw bottle
ind = (i==wave(:,1));
plot(wave(ind,2),wave(ind,3),'c*')
end
pause
% [x,y]=ginput(1);
% bottle = [bottle;[i x y]];
% [x,y]=ginput(1);
% wave = [wave;[i x y]];
end
end
%save(fullfile(par.datadir,'bottlewavespeed_22_sub4_treat4.mat'),'bottle','wave')
%% Speed of bottle
v=sqrt(diff(bottle(:,2)).^2 + diff(bottle(:,3)).^2)*pm^-1*dt;
vb=sqrt(diff(wave(:,2)).^2 + diff(wave(:,3)).^2)*pm^-1*dt;
figure
plot(bottle(1:end-1,1)./dt,v,'r',wave(1:end-1,1)./dt,vb,'c');
xlabel('Time (s)')
ylabel('speed (m/s)')
title('Bottle speed')
legend('Bottle','Behavioural wave')