-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathedit_call_section.m
496 lines (406 loc) · 20.1 KB
/
edit_call_section.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
function varargout = edit_call_section(varargin)
% EDIT_CALL_SECTION MATLAB code for edit_call_section.fig
% EDIT_CALL_SECTION, by itself, creates a new EDIT_CALL_SECTION or raises the existing
% singleton*.
%
% H = EDIT_CALL_SECTION returns the handle to a new EDIT_CALL_SECTION or the handle to
% the existing singleton*.
%
% EDIT_CALL_SECTION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EDIT_CALL_SECTION.M with the given input arguments.
%
% EDIT_CALL_SECTION('Property','Value',...) creates a new EDIT_CALL_SECTION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before edit_call_section_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to edit_call_section_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help edit_call_section
% Last Modified by GUIDE v2.5 17-Nov-2015 15:51:10
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @edit_call_section_OpeningFcn, ...
'gui_OutputFcn', @edit_call_section_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before edit_call_section is made visible.
function edit_call_section_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to edit_call_section (see VARARGIN)
% Choose default command line output for edit_call_section
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% Set default structure
if ~isappdata(0,'gui_call_op');
gui_call_op.curr_ch = 1;
setappdata(0,'gui_call_op',gui_call_op);
else
gui_call_op = getappdata(0,'gui_call_op');
end
% Load call_align
data = getappdata(0,'data');
gui_op = getappdata(0,'gui_op');
call_align = zeros(data.param.extract_call_len_pt,data.mic_data.num_ch_in_file); % length of signal x number of mics
for iM=1:length(data.mic_loc)
if isnan(data.mic_loc(iM,1))
call_align(:,iM) = nan(data.param.extract_call_len_pt,1);
else
idx = data.proc.call_align_se_idx(gui_op.current_call_idx,iM,:);
call_align(:,iM) = data.mic_data.sig(idx(1):idx(2),iM);
end
end
gui_call_op.call_align = call_align;
gui_call_op.se_idx = squeeze(data.proc.call_align_short_se_idx(gui_op.current_call_idx,:,:));
gui_call_op.fs = data.mic_data.fs;
gui_call_op.time = (0:size(call_align,1)-1)/data.mic_data.fs;
gui_call_op.num_ch_in_file = data.mic_data.num_ch_in_file;
setappdata(0,'gui_call_op',gui_call_op);
plot_everything(handles,gui_op.current_call_idx);
% Set figure handle to appdata
if ~isappdata(0,'edit_call_gui_handles')
setappdata(0,'edit_call_gui_handles',handles);
end
% UIWAIT makes edit_call_section wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = edit_call_section_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in button_start.
function button_start_Callback(hObject, eventdata, handles)
% hObject handle to button_start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data = getappdata(0,'data');
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
hh_main = getappdata(0,'bp_check_gui_handles');
% move start line
[xsel,~] = ginput(1); % time
gui_call_op.se_idx(gui_call_op.curr_ch,1) = round(xsel/1e3*gui_call_op.fs); % convert time to index
% update figure
axes(handles.axes_spectrogram);
set(gui_call_op.sline_spec,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3);
axes(handles.axes_time_series);
set(gui_call_op.sline_time,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3);
% Update call_dB data
data.proc.call_align_short_se_idx(gui_op.current_call_idx,gui_call_op.curr_ch,1) = gui_call_op.se_idx(gui_call_op.curr_ch,1);
data = update_call_time_series_data(data,gui_op,gui_call_op);
data = update_call_dB_data(data,gui_op,gui_call_op);
% Update main GUI figure
reload_bp_timeseries(hh_main,gui_op.mic_config);
% Store data & upload main GUI figure
setappdata(0,'gui_call_op',gui_call_op);
setappdata(0,'data',data);
reload_bp_timeseries(hh_main,gui_op.mic_config);
% --- Executes on button press in button_end.
function button_end_Callback(hObject, eventdata, handles)
% hObject handle to button_end (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data = getappdata(0,'data');
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
hh_main = getappdata(0,'bp_check_gui_handles');
% move end line
[xsel,~] = ginput(1); % time
gui_call_op.se_idx(gui_call_op.curr_ch,2) = round(xsel/1e3*gui_call_op.fs); % convert time to index
% update figure
axes(handles.axes_spectrogram);
set(gui_call_op.eline_spec,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3);
axes(handles.axes_time_series);
set(gui_call_op.eline_time,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3);
% Update call_dB data
data.proc.call_align_short_se_idx(gui_op.current_call_idx,gui_call_op.curr_ch,2) = gui_call_op.se_idx(gui_call_op.curr_ch,2);
data = update_call_time_series_data(data,gui_op,gui_call_op);
data = update_call_dB_data(data,gui_op,gui_call_op);
% Store data & upload main GUI figure
setappdata(0,'gui_call_op',gui_call_op);
setappdata(0,'data',data);
reload_bp_timeseries(hh_main,gui_op.mic_config);
% --- Executes on button press in button_delete_ch.
function button_delete_ch_Callback(hObject, eventdata, handles)
% hObject handle to button_delete_ch (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data = getappdata(0,'data');
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
hh_main = getappdata(0,'bp_check_gui_handles');
% Update data
gui_call_op.se_idx(gui_call_op.curr_ch,:) = nan(1,2); % convert time to index
data.proc.call_align_short_se_idx(gui_op.current_call_idx,gui_call_op.curr_ch,:) = nan(1,2);
% update figure
axes(handles.axes_spectrogram);
set(gui_call_op.sline_spec,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3);
set(gui_call_op.eline_spec,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3);
axes(handles.axes_time_series);
set(gui_call_op.sline_time,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3);
set(gui_call_op.eline_time,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3);
% Update call_dB data
data = update_call_time_series_data(data,gui_op,gui_call_op);
data = update_call_dB_data(data,gui_op,gui_call_op);
% Store data & upload main GUI figure
setappdata(0,'gui_call_op',gui_call_op);
setappdata(0,'data',data);
reload_bp_timeseries(hh_main,gui_op.mic_config);
% --- Executes on button press in button_both.
function button_both_Callback(hObject, eventdata, handles)
% hObject handle to button_both (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data = getappdata(0,'data');
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
hh_main = getappdata(0,'bp_check_gui_handles');
% move end line
[xsel,~] = ginput(2); % time
gui_call_op.se_idx(gui_call_op.curr_ch,:) = round(xsel/1e3*gui_call_op.fs); % convert time to index
% update figure
axes(handles.axes_spectrogram);
set(gui_call_op.sline_spec,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3);
set(gui_call_op.eline_spec,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3);
axes(handles.axes_time_series);
set(gui_call_op.sline_time,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3);
set(gui_call_op.eline_time,'XData',[1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3);
% Update call_dB data
data.proc.call_align_short_se_idx(gui_op.current_call_idx,gui_call_op.curr_ch,:) = gui_call_op.se_idx(gui_call_op.curr_ch,:);
data = update_call_time_series_data(data,gui_op,gui_call_op);
data = update_call_dB_data(data,gui_op,gui_call_op);
% Store data & upload main GUI figure
setappdata(0,'gui_call_op',gui_call_op);
setappdata(0,'data',data);
reload_bp_timeseries(hh_main,gui_op.mic_config);
function reload_bp_timeseries(hh,mic_config)
% Reload bp plot and recording time series in main GUI
plot_time_series_in_gui(hh); % display time series of first call
if strcmp(mic_config,'rb_cross');
plot_bp_cross(hh); % display beampattern
else
plot_bp_2d(hh); % display beampattern
end
function data = update_call_time_series_data(data,gui_op,gui_call_op)
% Update call_align_short time series
tukeywin_prop = data.param.tukeywin_proportion; % tukey window taper porportion
iC = gui_op.current_call_idx;
iM = gui_call_op.curr_ch;
se_idx = gui_call_op.se_idx(iM,:); % new segment start/end index
if any(isnan(se_idx))
call_short = NaN;
else
call_short = gui_call_op.call_align(se_idx(1):se_idx(2),gui_call_op.curr_ch); % extract new short call segment
end
w = tukeywin(size(call_short,1),tukeywin_prop);
call_short_taper = call_short.*repmat(w,1,size(call_short,2)); % taper call for spectrum estimation
call_fft = fft(call_short_taper);
call_freq_vec = linspace(0,data.mic_data.fs/2,round((size(call_short_taper,1)+1)/2));
if ~isfield(data.param,'PSD_type') || strcmp(data.param.PSD_type,'FFT')
% Calculate fft ================================
call_fft_len = length(call_freq_vec);
call_psd = 2*abs(call_fft(1:call_fft_len,:)).^2/(length(call_fft)*data.mic_data.fs);
% call_psd = 2*abs(call_fft(1:call_fft_len,:)).^2;
call_psd_dB = 10*log10(call_psd);
elseif strcmp(data.param.PSD_type,'pwelch')
if length(call_short_taper) > 128
call_psd=pwelch(call_short_taper,128,120,call_freq_vec,data.mic_data.fs);
call_psd_dB = 10*log10(call_psd);
else
disp(['call problematic on call #' num2str(iC)])
call_psd=zeros(0,size(call_short_taper,2));
call_psd_dB =zeros(0,size(call_short_taper,2));
end
end
%calculate RMS ==================================
%generating 1/3 octave bands for filter bank for RMS
N = 6; %order
fcenter = data.param.RMS_freq_vec;
fs = data.mic_data.fs;
fd = 2^(1/6);
fupper = fcenter * fd;
flower = fcenter / fd;
[a,b] = deal(cell(length(data.param.RMS_freq_vec),1));
for iF =1:length(fcenter)
[b{iF},a{iF}]=butter(N,[flower(iF) fupper(iF)]/(fs/2),'bandpass');
end
%calc RMS across freq bands
[call_rms,call_rms_dB]=deal(nan(length(fcenter),size(call_short,2)));
for iF =1:length(fcenter)
sig_filt = filter(b{iF},a{iF},call_short);
call_rms(iF,:) = sqrt(mean(sig_filt.^2));
call_rms_dB(iF,:) = 20*log10(call_rms(iF,:));
end
% call_rms = sqrt(mean(call_short_taper.^2));
data.proc.call_align_short{iC,iM} = call_short;
data.proc.call_align_short_se_idx(iC,iM,:) = se_idx; % update start/end idx for this channel
data.proc.call_fft{iC,iM} = call_fft; % call spectrum
data.proc.call_freq_vec{iC,iM} = call_freq_vec; % frequency vector for call spectrum
data.proc.call_psd_raw_linear{iC,iM} = call_psd; % spectrum of extracted calls, linear scale
data.proc.call_psd_raw_dB{iC,iM} = call_psd_dB; % spectrum of extracted calls, dB scale
data.proc.call_rms{iC,iM} = call_rms';
data.proc.call_rms_dB{iC,iM} = call_rms_dB';
data.proc.call_rms_fcenter{iC,iM} = fcenter; %freq vector for RMS
function data = update_call_dB_data(data,gui_op,gui_call_op)
% Update call_dB data
iC = gui_op.current_call_idx;
iM = gui_call_op.curr_ch;
mic_to_bat_dist = data.proc.mic_to_bat_dist(iC,iM); % distance between bat and mic
bat_to_mic_angle = data.proc.bat_to_mic_angle(iC,iM); % angle to compensate for mic beampattern
call_psd_raw_dB = data.proc.call_psd_raw_dB{iC,iM}; % call spectrum in dB scale
call_freq = data.proc.call_freq_vec{iC,iM}; % frequency vector of the call spectrum
% Transmission loss: air absorption and spreading loss
[alpha, alpha_iso,~,~] = ...
air_absorption_vec(call_freq,data.param.tempC,data.param.humid); % atmospheric aborption [dB/m]
% Attenuation and spreading loss
air_attn_dB = alpha*(mic_to_bat_dist'-data.param.d0); % [dB]
spreading_loss_dB = 20*log10(mic_to_bat_dist'/data.param.d0); % [dB]
TL_dB = air_attn_dB+spreading_loss_dB'; % [dB]
% Mic sensitivity
mic_sens_dB = interp1(data.mic_sens.freq,data.mic_sens.sens(:,iM),call_freq); % interpolate mic sensitivity vector
% Mic beampattern: have to loop because interp2 is needed but bp is in 3D mtx
[X,Y] = meshgrid(data.mic_bp.theta,data.mic_bp.freq);
[XI,YI] = meshgrid(bat_to_mic_angle,call_freq);
bp_compensation = interp2(X,Y,data.mic_bp.bp(:,:,iM),XI,YI)'; % interpolate mic beampattern
% Broadband call SPL and PSD
call_psd_dB_comp_nobp = call_psd_raw_dB + TL_dB - mic_sens_dB;
call_psd_dB_comp_withbp = call_psd_raw_dB + TL_dB - mic_sens_dB - bp_compensation;
gain_dB_fac = data.mic_gain(iM);
call_psd_dB_comp_re20uPa_nobp = call_psd_dB_comp_nobp + 20*log10(1/20e-6) - gain_dB_fac;
call_psd_dB_comp_re20uPa_withbp = call_psd_dB_comp_withbp + 20*log10(1/20e-6) - gain_dB_fac;
% Call SPL using p2p voltage
ch_data = data.proc.call_align_short{iC,iM}';
ch_p2p = max(ch_data,[],2) + ...
abs(min(ch_data,[],2));
call_p2p_ch_dB = 20*log10(ch_p2p);
%using pwelch to calc. the max freq in the data
A=pwelch(ch_data',128,120,call_freq,data.mic_data.fs);
[~,max_freq_idx]=max(A); %where the peak should be...
% max_freq_idx = sub2ind(size(A), max_freq, 1:size(A,2));
TL_dB_ch = TL_dB(max_freq_idx);
mic_sens_dB_mean_ch = mic_sens_dB(max_freq_idx);
call_p2p_SPL_comp_re20uPa = call_p2p_ch_dB + TL_dB_ch - mic_sens_dB_mean_ch +...
20*log10(1/20e-6) - data.mic_gain(iM);
freqs_RMS=data.proc.call_rms_fcenter{iC,1};
TL_dB_RMS_freq = interp1(call_freq,TL_dB,freqs_RMS);
mic_sens_dB_RMS_freq = interp1(call_freq,mic_sens_dB,freqs_RMS);
call_rms_dB = data.proc.call_rms_dB{iC,iM};
call_RMS_SPL_comp_re20uPa=nan(1,length(freqs_RMS));
for iF = 1:length(freqs_RMS)
call_RMS_SPL_comp_re20uPa(iF) = ...
call_rms_dB(iF) + TL_dB_RMS_freq(iF) - mic_sens_dB_RMS_freq(iF) +...
20*log10(1/20e-6) - data.mic_gain(iM);
end
% Save data
data.param.alpha{iC,iM} = alpha;
data.param.alpha_iso{iC,iM} = alpha_iso;
data.proc.air_attn_dB{iC,iM} = air_attn_dB;
data.proc.spreading_loss_dB{iC,iM} = spreading_loss_dB;
data.proc.TL_dB{iC,iM} = TL_dB;
data.proc.mic_bp_compensation_dB{iC,iM} = bp_compensation;
data.proc.mic_sens_dB{iC,iM} = mic_sens_dB;
data.proc.call_psd_dB_comp_nobp{iC,iM} = call_psd_dB_comp_nobp;
data.proc.call_psd_dB_comp_withbp{iC,iM} = call_psd_dB_comp_withbp;
data.proc.call_psd_dB_comp_re20uPa_nobp{iC,iM} = call_psd_dB_comp_re20uPa_nobp;
data.proc.call_psd_dB_comp_re20uPa_withbp{iC,iM} = call_psd_dB_comp_re20uPa_withbp;
data.proc.call_p2p_SPL_comp_re20uPa(iC,iM) = call_p2p_SPL_comp_re20uPa;
data.proc.call_RMS_SPL_comp_re20uPa{iC,iM} = call_RMS_SPL_comp_re20uPa;
% --- Executes on button press in button_ch_next.
function button_ch_next_Callback(hObject, eventdata, handles)
% hObject handle to button_ch_next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
gui_call_op.curr_ch = min(gui_call_op.curr_ch+1,gui_call_op.num_ch_in_file);
set(handles.edit_ch,'String',num2str(gui_call_op.curr_ch));
setappdata(0,'gui_call_op',gui_call_op);
plot_everything(handles,gui_op.current_call_idx); % update spectrogram and time series
% --- Executes on button press in butto_ch_previous.
function butto_ch_previous_Callback(hObject, eventdata, handles)
% hObject handle to butto_ch_previous (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
gui_call_op.curr_ch = max(gui_call_op.curr_ch-1,1);
set(handles.edit_ch,'String',num2str(gui_call_op.curr_ch));
setappdata(0,'gui_call_op',gui_call_op);
plot_everything(handles,gui_op.current_call_idx); % update spectrogram and time series
function edit_ch_Callback(hObject, eventdata, handles)
% hObject handle to edit_ch (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
gui_call_op = getappdata(0,'gui_call_op');
gui_op = getappdata(0,'gui_op');
tmp = mod(str2double(get(hObject,'String')),gui_call_op.num_ch_in_file);
if tmp==0
gui_call_op.curr_ch = gui_call_op.num_ch_in_file;
else
gui_call_op.curr_ch = tmp;
end
setappdata(0,'gui_call_op',gui_call_op);
plot_everything(handles,gui_op.current_call_idx); % update spectrogram and time series
function plot_everything(handles,curr_call_idx)
gui_call_op = getappdata(0,'gui_call_op');
[~,F,T,P] = spectrogram(gui_call_op.call_align(:,gui_call_op.curr_ch),128,120,128,gui_call_op.fs);
P = 10*log10(abs(P));
xlim_curr = T([1 end])*1e3;
axes(handles.axes_spectrogram);
imagesc(T*1e3,F/1e3,P);
axis xy
hold on
gui_call_op.sline_spec = plot([1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3,[0 gui_call_op.fs/1e3/2],'r','linewidth',2);
gui_call_op.eline_spec = plot([1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3,[0 gui_call_op.fs/1e3/2],'r','linewidth',2);
hold off
xlim(xlim_curr);
set(gca,'xticklabel','');
ylabel('Frequency (kHz)');
title(sprintf('Call #%d',curr_call_idx),'fontsize',16);
axes(handles.axes_time_series);
cla
plot(gui_call_op.time*1e3,gui_call_op.call_align(:,gui_call_op.curr_ch));
yybnd = ceil(max(gui_call_op.call_align(:,gui_call_op.curr_ch))/0.01)*0.01*[-1 1];
hold on
gui_call_op.sline_time = plot([1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,1)/gui_call_op.fs*1e3,[-5 5],'r','linewidth',2);
gui_call_op.eline_time = plot([1 1]*gui_call_op.se_idx(gui_call_op.curr_ch,2)/gui_call_op.fs*1e3,[-5 5],'r','linewidth',2);
hold off
xlim(xlim_curr);
ylim(yybnd);
xlabel('Time (ms)');
ylabel('Volt');
setappdata(0,'gui_call_op',gui_call_op);
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isappdata(0,'gui_call_op')
rmappdata(0,'gui_call_op');
end
if isappdata(0,'edit_call_gui_handles')
rmappdata(0,'edit_call_gui_handles');
end
% Hint: delete(hObject) closes the figure
delete(hObject);