-
Notifications
You must be signed in to change notification settings - Fork 27
/
motion_ltsa.m
149 lines (138 loc) · 5.51 KB
/
motion_ltsa.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
function motion_ltsa(action)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% motion_ltsa.m
%
% control motion of plot windown with push buttons in control window
%
% Parameters:
% action - a string that represenst the action the user clicked on
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global PARAMS HANDLES
% forward button
if strcmp(action,'forward')
PARAMS.ltsa.save.dnum = PARAMS.ltsa.plot.dnum;
if PARAMS.ltsa.tseg.step ~= -1 && PARAMS.ltsa.tseg.step ~= -2
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.plot.dnum + datenum([0 0 0 PARAMS.ltsa.tseg.step 0 0]);
elseif PARAMS.ltsa.tseg.step == -2
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.plot.dnum + datenum([0 0 0 PARAMS.ltsa.tseg.hr 0 0]);
elseif PARAMS.ltsa.tseg.step == -1
stepPlotTimeLTSA('f')
end
read_ltsadata
plot_triton
% back button
elseif strcmp(action,'back')
PARAMS.ltsa.save.dnum = PARAMS.ltsa.plot.dnum;
if PARAMS.ltsa.tseg.step ~= -1 && PARAMS.ltsa.tseg.step ~= -2
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.plot.dnum - datenum([0 0 0 PARAMS.ltsa.tseg.step 0 0]);
elseif PARAMS.ltsa.tseg.step == -2
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.plot.dnum - datenum([0 0 0 PARAMS.ltsa.tseg.hr 0 0]);
elseif PARAMS.ltsa.tseg.step == -1
stepPlotTimeLTSA('b')
end
read_ltsadata
plot_triton
% autof button - plot next frame
elseif strcmp(action,'autof')
% turn off menus and buttons while autorunning
control_ltsa('menuoff');
control_ltsa('buttoff');
% turn Stop button back on
set(HANDLES.ltsa.motion.stop,'Userdata',1); % turn on while loop condition
set(HANDLES.ltsa.motion.stop,'Enable','on'); % turn on the Stop button
while (get(HANDLES.ltsa.motion.stop,'Userdata') == 1)
motion_ltsa('forward')
if PARAMS.aptime ~= 0
pause(PARAMS.ltsa.aptime);
end
end
% turn buttons and menus back on
control_ltsa('menuon')
% autob button - plot previous frame
elseif strcmp(action,'autob')
% turn off menus and buttons while autorunning
control_ltsa('menuoff');
control_ltsa('buttoff');
% turn Stop button back on
set(HANDLES.ltsa.motion.stop,'Userdata',1); % turn on while loop condition
set(HANDLES.ltsa.motion.stop,'Enable','on'); % turn on the Stop button
while (get(HANDLES.ltsa.motion.stop,'Userdata') == 1)
motion_ltsa('back') % step back one frame
if PARAMS.aptime ~= 0
pause(PARAMS.ltsa.aptime); % wait (needed on fast machines)
end
end
% turn menus back on
control_ltsa('menuon')
elseif strcmp(action,'nextDet')
[~,nextDet] = lt_lVis_envDet_LTSA;
if ~isempty(nextDet)
ltsaPad = PARAMS.ltsa.tseg.hr .* 0.1; %add some padding to where next detection/previous detection displays in window
endLoc = PARAMS.ltsa.dnumEnd(end)-datenum(0,0,0,0,PARAMS.ltsa.tseg.hr,0);
if endLoc< (nextDet-ltsaPad)
PARAMS.ltsa.plot.dnum = endLoc;
else
PARAMS.ltsa.plot.dnum = nextDet - datenum(0,0,0,0,ltsaPad,0);
end
PARAMS.ltsa.save.dnum = PARAMS.ltsa.plot.dnum;
read_ltsadata
plot_triton
else
disp('Last detection! No detections found after current window for this LTSA file')
end
elseif strcmp(action,'prevDet')
[prevDet,~] = lt_lVis_envDet_LTSA;
if ~isempty(prevDet)
ltsaPad = PARAMS.ltsa.tseg.hr.*0.1; %add some padding to where next detection/previous detection displays in window
PARAMS.ltsa.plot.dnum = prevDet - datenum(0,0,0,0,ltsaPad,0);
PARAMS.ltsa.save.dnum = PARAMS.ltsa.plot.dnum;
% if PARAMS.ltsa.plot.dnum
read_ltsadata
plot_triton
else
disp('First detection! No detections found prior to current window for this LTSA file')
end
% stop button doesn't work right away, has to click twice to stop the LTSA
% stop button - keep current frame
elseif strcmp(action,'stop')
set(HANDLES.ltsa.motion.stop,'Userdata',-1)
control_ltsa('button')
control_ltsa('menuon')
set(HANDLES.ltsa.motion.stop,'Enable','off'); % turn off Stop button
% goto beginning of file button - plot first frame
elseif strcmp(action,'seekbof')
set(HANDLES.fig.ctrl, 'Pointer', 'watch');
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.start.dnum;
read_ltsadata
plot_triton
set(HANDLES.ltsa.motion.seekbof,'Enable','off');
set(HANDLES.fig.ctrl, 'Pointer', 'arrow');
% goto end of file button - plot last frame
elseif strcmp(action,'seekeof')
set(HANDLES.fig.ctrl, 'Pointer', 'watch');
if PARAMS.ltsa.tseg.step == -2
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.end.dnum - datenum([0 0 0 PARAMS.ltsa.tseg.hr 0 0]);
% disp_msg(['plot.dnum= ',num2str(PARAMS.ltsa.plot.dnum)])
elseif PARAMS.ltsa.tseg.step == -1
% total number of time bins to plot
tbin = floor((PARAMS.ltsa.tseg.hr * 60 *60 ) / PARAMS.ltsa.tave);
cbin = 0;
k = PARAMS.ltsa.nrftot+1;
% count rawfile Indices backwards
while cbin < tbin
k = k - 1;
cbin = cbin + PARAMS.ltsa.nave(k);
end
sbin = cbin - tbin;
PARAMS.ltsa.plotStartBin = sbin;
PARAMS.ltsa.plotStartRawIndex = k;
PARAMS.ltsa.plot.dnum = PARAMS.ltsa.dnumStart(PARAMS.ltsa.plotStartRawIndex)+ ...
(PARAMS.ltsa.plotStartBin * PARAMS.ltsa.tave) / (60 * 60 * 24);
end
read_ltsadata
plot_triton
set(HANDLES.ltsa.motion.seekeof,'Enable','off');
set(HANDLES.fig.ctrl, 'Pointer', 'arrow');
end;