comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_ManualData.m @ 4:92ca03a8fa99 tip

Update to ICASSP 2013 benchmark
author Dawn Black
date Wed, 13 Feb 2013 11:02:39 +0000
parents
children
comparison
equal deleted inserted replaced
3:e1cfa7765647 4:92ca03a8fa99
1 function varargout = vs_ManualData(varargin)
2 % VS_MANUALDATA M-file for vs_ManualData.fig
3 % VS_MANUALDATA, by itself, creates a new VS_MANUALDATA or raises the existing
4 % singleton*.
5 %
6 % H = VS_MANUALDATA returns the handle to a new VS_MANUALDATA or the handle to
7 % the existing singleton*.
8 %
9 % VS_MANUALDATA('CALLBACK',hObject,eventData,handles,...) calls the local
10 % function named CALLBACK in VS_MANUALDATA.M with the given input arguments.
11 %
12 % VS_MANUALDATA('Property','Value',...) creates a new VS_MANUALDATA or raises the
13 % existing singleton*. Starting from the left, property value pairs are
14 % applied to the GUI before vs_ManualData_OpeningFcn gets called. An
15 % unrecognized property name or invalid value makes property application
16 % stop. All inputs are passed to vs_ManualData_OpeningFcn via varargin.
17 %
18 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
19 % instance to run (singleton)".
20 %
21 % See also: GUIDE, GUIDATA, GUIHANDLES
22
23 % Edit the above text to modify the response to help vs_ManualData
24
25 % Last Modified by GUIDE v2.5 22-Oct-2009 12:22:59
26
27 % Begin initialization code - DO NOT EDIT
28 gui_Singleton = 1;
29 gui_State = struct('gui_Name', mfilename, ...
30 'gui_Singleton', gui_Singleton, ...
31 'gui_OpeningFcn', @vs_ManualData_OpeningFcn, ...
32 'gui_OutputFcn', @vs_ManualData_OutputFcn, ...
33 'gui_LayoutFcn', [] , ...
34 'gui_Callback', []);
35 if nargin && ischar(varargin{1})
36 gui_State.gui_Callback = str2func(varargin{1});
37 end
38
39 if nargout
40 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41 else
42 gui_mainfcn(gui_State, varargin{:});
43 end
44 % End initialization code - DO NOT EDIT
45
46
47 % --- Executes just before vs_ManualData is made visible.
48 function vs_ManualData_OpeningFcn(hObject, eventdata, handles, varargin)
49 % This function has no output args, see OutputFcn.
50 % hObject handle to figure
51 % eventdata reserved - to be defined in a future version of MATLAB
52 % handles structure with handles and user data (see GUIDATA)
53 % varargin command line arguments to vs_ManualData (see VARARGIN)
54
55 % Choose default command line output for vs_ManualData
56 handles.output = hObject;
57
58 % YS: get the settings from the main figure
59 if (~isfield(handles, 'VSHandle'))
60 VSHandle = VoiceSauce;
61 handles.VSHandle = VSHandle;
62 end
63
64 VSData = guidata(handles.VSHandle);
65
66 set(handles.edit_wavdir, 'String', VSData.vars.MD_wavdir);
67 set(handles.edit_matdir, 'String', VSData.vars.MD_matdir);
68
69 set(handles.checkbox_matwithwav, 'Value', VSData.vars.MD_matwithwav);
70
71 if (VSData.vars.MD_matwithwav)
72 set(handles.edit_matdir, 'Enable', 'Off');
73 set(handles.pushbutton_matfile_browse, 'Enable', 'Off');
74 else
75 set(handles.edit_matdir, 'Enable', 'On');
76 set(handles.pushbutton_matfile_browse, 'Enable', 'On');
77 end
78
79 if (VSData.vars.recursedir)
80 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
81 else
82 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring);
83 end
84
85 set(handles.listbox_Data_paramlist, 'String', func_getmanualdataparameterlist());
86 set(handles.edit_Data_invalid, 'String', VSData.vars.MD_invalidentry);
87 set(handles.checkbox_resample, 'Value', VSData.vars.MD_resample);
88
89 % Update handles structure
90 guidata(hObject, handles);
91
92 checkParameters(handles);
93 plotParam(handles);
94
95 % UIWAIT makes vs_ManualData wait for user response (see UIRESUME)
96 % uiwait(handles.figure_ManualData);
97
98
99 % -- plot the current selected parameter
100 function plotParam(handles)
101 VSData = guidata(handles.VSHandle);
102 contents = get(handles.listbox_wavfilelist, 'String');
103 OF = str2double(get(handles.edit_Data_offset, 'String'));
104
105 if (isempty(contents))
106 return;
107 end
108
109 shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')};
110 wavfile = [VSData.vars.MD_wavdir VSData.vars.dirdelimiter shortwavfile];
111
112 [y,Fs] = wavread(wavfile);
113 L = floor((length(y) / Fs * 1000) / VSData.vars.frameshift) - 1;
114 set(handles.edit_Data_explen, 'String', num2str(L));
115
116 % set the amount of padding needed
117 figdata = guidata(handles.figure_ManualData);
118 NL = str2double(get(handles.edit_Data_newlen, 'String'));
119 set(handles.edit_Data_pad, 'String', num2str(L - NL - OF));
120
121
122 if (isfield(figdata, 'mdata'))
123 contents = get(handles.listbox_Data_paramlist, 'String');
124
125 if (isempty(contents))
126 return;
127 end
128
129 label = contents{get(handles.listbox_Data_paramlist, 'Value')};
130 C = textscan(label, '%s %s', 'delimiter', '(');
131 param = C{2}{1}(1:end-1);
132
133 % if the parameter exists, plot it in blue
134 if (isfield(figdata.mdata, param))
135 plot(handles.axes_main, figdata.mdata.(param)); % plot the existing param
136 L = length(figdata.mdata.(param));
137 set(handles.edit_Data_explen, 'String', num2str(L));
138 set(handles.edit_Data_pad, 'String', num2str(L - NL - OF));
139 axis(handles.axes_main, 'tight');
140 else
141 cla(handles.axes_main);
142 end
143 end
144
145 if (VSData.vars.MD_resample && isfield(figdata, 'newdata_resamp'))
146 hold(handles.axes_main, 'on');
147 newdata = zeros(L, 1) * NaN;
148 if (OF >= 0)
149 newdata(OF+1:L) = figdata.newdata_resamp;
150 else
151 newdata(1:length(figdata.newdata_resamp) + OF) = figdata.newdata_resamp(abs(OF)+1:end);
152 end
153 plot(handles.axes_main, newdata, 'r');
154 hold(handles.axes_main, 'off');
155 axis(handles.axes_main, 'tight');
156 hold(handles.axes_main, 'off');
157
158 elseif (isfield(figdata, 'newdata'))
159 hold(handles.axes_main, 'on');
160 % create new vector
161 newdata = zeros(L, 1) * NaN;
162 if (length(figdata.newdata) + OF >= L)
163 newdata(OF+1:L) = figdata.newdata(1:L-OF);
164 else
165 if (OF >=0)
166 newdata(OF+1:OF+length(figdata.newdata)) = figdata.newdata;
167 else
168 newdata(1:length(figdata.newdata)+OF) = figdata.newdata(abs(OF)+1:end);
169 end
170 end
171
172 plot(handles.axes_main, newdata, 'r');
173 hold(handles.axes_main, 'off');
174 axis(handles.axes_main, 'tight');
175 %legend(handles.axes_main, {'Original', 'New'});
176 end
177
178
179 % -- build up the matfile if it exists
180 function checkParameters(handles)
181 VSData = guidata(handles.VSHandle);
182 contents = get(handles.listbox_wavfilelist, 'String');
183
184 if (isempty(contents))
185 return;
186 end
187
188 shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')};
189 matfile = [VSData.vars.MD_matdir VSData.vars.dirdelimiter, shortwavfile(1:end-3) 'mat'];
190
191 if (exist(matfile, 'file') == 0)
192 mdata = [];
193 else
194 mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize);
195 end
196
197 % store mdata so it can be accessed by plotData
198 figdata = guidata(handles.figure_ManualData);
199 figdata.mdata = mdata;
200 guidata(handles.figure_ManualData, figdata);
201
202
203
204 % --- Outputs from this function are returned to the command line.
205 function varargout = vs_ManualData_OutputFcn(hObject, eventdata, handles)
206 % varargout cell array for returning output args (see VARARGOUT);
207 % hObject handle to figure
208 % eventdata reserved - to be defined in a future version of MATLAB
209 % handles structure with handles and user data (see GUIDATA)
210
211 % Get default command line output from handles structure
212 varargout{1} = handles.output;
213
214
215
216 function edit_wavdir_Callback(hObject, eventdata, handles)
217 % hObject handle to edit_wavdir (see GCBO)
218 % eventdata reserved - to be defined in a future version of MATLAB
219 % handles structure with handles and user data (see GUIDATA)
220
221 new_dir = get(hObject, 'String');
222
223 VSData = guidata(handles.VSHandle);
224
225 if (exist(new_dir, 'dir') == 7)
226 VSData = func_setwavdir('MD_wavdir', new_dir, VSData);
227
228 if (VSData.vars.recursedir)
229 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
230 else
231 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring);
232 end
233
234 if (VSData.vars.PE_savematwithwav)
235 set(handles.edit_matdir, 'String', new_dir);
236 VSData = func_setmatdir('MD_matdir', new_dir, VSData);
237 end
238 guidata(handles.VSHandle, VSData);
239 else
240 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
241 set(hObject, 'String', VSData.vars.MD_wavdir);
242 end
243
244 % --- Executes during object creation, after setting all properties.
245 function edit_wavdir_CreateFcn(hObject, eventdata, handles)
246 % hObject handle to edit_wavdir (see GCBO)
247 % eventdata reserved - to be defined in a future version of MATLAB
248 % handles empty - handles not created until after all CreateFcns called
249
250 % Hint: edit controls usually have a white background on Windows.
251 % See ISPC and COMPUTER.
252 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
253 set(hObject,'BackgroundColor','white');
254 end
255
256
257 % --- Executes on button press in pushbutton_wavfile_browse.
258 function pushbutton_wavfile_browse_Callback(hObject, eventdata, handles)
259 % hObject handle to pushbutton_wavfile_browse (see GCBO)
260 % eventdata reserved - to be defined in a future version of MATLAB
261 % handles structure with handles and user data (see GUIDATA)
262 current_dir = get(handles.edit_wavdir, 'String');
263 new_dir = uigetdir(current_dir);
264
265 VSData = guidata(handles.VSHandle);
266
267 if (ischar(new_dir))
268 VSData = func_setwavdir('MD_wavdir', new_dir, VSData);
269 set(handles.edit_wavdir, 'String', new_dir);
270
271 if (VSData.vars.recursedir)
272 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
273 else
274 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.MD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring);
275 end
276
277 % assume that mat files are saved with wavs
278 if (VSData.vars.MD_matwithwav == 1)
279 set(handles.edit_matdir, 'String', new_dir);
280 VSData = func_setmatdir('MD_matdir', new_dir, VSData);
281 end
282
283 guidata(handles.VSHandle, VSData);
284
285 end
286
287 checkParameters(handles);
288 plotParam(handles);
289
290
291
292 % --- Executes on selection change in listbox_wavfilelist.
293 function listbox_wavfilelist_Callback(hObject, eventdata, handles)
294 % hObject handle to listbox_wavfilelist (see GCBO)
295 % eventdata reserved - to be defined in a future version of MATLAB
296 % handles structure with handles and user data (see GUIDATA)
297
298 % Hints: contents = get(hObject,'String') returns listbox_wavfilelist contents as cell array
299 % contents{get(hObject,'Value')} returns selected item from listbox_wavfilelist
300 checkParameters(handles);
301 plotParam(handles);
302
303
304 % --- Executes during object creation, after setting all properties.
305 function listbox_wavfilelist_CreateFcn(hObject, eventdata, handles)
306 % hObject handle to listbox_wavfilelist (see GCBO)
307 % eventdata reserved - to be defined in a future version of MATLAB
308 % handles empty - handles not created until after all CreateFcns called
309
310 % Hint: listbox controls usually have a white background on Windows.
311 % See ISPC and COMPUTER.
312 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
313 set(hObject,'BackgroundColor','white');
314 end
315
316
317 % --- Executes on selection change in listbox_Data_paramlist.
318 function listbox_Data_paramlist_Callback(hObject, eventdata, handles)
319 % hObject handle to listbox_Data_paramlist (see GCBO)
320 % eventdata reserved - to be defined in a future version of MATLAB
321 % handles structure with handles and user data (see GUIDATA)
322
323 % Hints: contents = get(hObject,'String') returns listbox_Data_paramlist contents as cell array
324 % contents{get(hObject,'Value')} returns selected item from listbox_Data_paramlist
325 %checkParameters(handles);
326 plotParam(handles);
327
328
329 % --- Executes during object creation, after setting all properties.
330 function listbox_Data_paramlist_CreateFcn(hObject, eventdata, handles)
331 % hObject handle to listbox_Data_paramlist (see GCBO)
332 % eventdata reserved - to be defined in a future version of MATLAB
333 % handles empty - handles not created until after all CreateFcns called
334
335 % Hint: listbox controls usually have a white background on Windows.
336 % See ISPC and COMPUTER.
337 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
338 set(hObject,'BackgroundColor','white');
339 end
340
341
342
343 function edit_Data_datafile_Callback(hObject, eventdata, handles)
344 % hObject handle to edit_Data_datafile (see GCBO)
345 % eventdata reserved - to be defined in a future version of MATLAB
346 % handles structure with handles and user data (see GUIDATA)
347 VSData = guidata(handles.VSHandle);
348 L = str2double(get(handles.edit_Data_explen, 'String'));
349 OF = str2double(get(handles.edit_Data_offset, 'String'));
350
351 filename = get(hObject, 'String');
352
353 if (exist(filename,'file') == 2)
354 % try to read in the file
355 fid = fopen(filename, 'rt');
356 set(handles.edit_Data_datafile, 'String', [pathname filename]);
357
358 if (fid == -1)
359 msgbox('Error: Unable to open data file', 'Error', 'error', 'modal');
360 return;
361 end
362
363 data = textscan(fid, '%s', 'delimiter', '\n');
364 fclose(fid);
365
366 % get the specified labels for invalid entry
367 delimiters = textscan(VSData.vars.MD_invalidentry, '%s', 'delimiter', ',');
368
369 % now check each entry
370 data = data{1};
371 newdata = zeros(length(data), 1) * NaN;
372
373 for k=1:length(data)
374 switch(data{k})
375 case delimiters
376
377 otherwise
378 newdata(k) = str2double(data{k});
379 end
380 end
381
382 figdata = guidata(handles.figure_ManualData);
383 figdata.newdata = newdata;
384
385 if (VSData.vars.MD_resample)
386 guidata(handles.figure_ManualData, figdata);
387 end
388
389 guidata(handles.figure_ManualData, figdata);
390
391 plotParam(handles);
392
393 set(handles.edit_Data_newlen, 'String', num2str(length(newdata)));
394 set(handles.edit_Data_pad, 'String', num2str(L - OF - length(newdata)));
395
396 end
397
398
399 % --- Executes during object creation, after setting all properties.
400 function edit_Data_datafile_CreateFcn(hObject, eventdata, handles)
401 % hObject handle to edit_Data_datafile (see GCBO)
402 % eventdata reserved - to be defined in a future version of MATLAB
403 % handles empty - handles not created until after all CreateFcns called
404
405 % Hint: edit controls usually have a white background on Windows.
406 % See ISPC and COMPUTER.
407 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
408 set(hObject,'BackgroundColor','white');
409 end
410
411
412 % --- Executes on button press in pushbutton_datafile_browse.
413 function pushbutton_datafile_browse_Callback(hObject, eventdata, handles)
414 % hObject handle to pushbutton_datafile_browse (see GCBO)
415 % eventdata reserved - to be defined in a future version of MATLAB
416 % handles structure with handles and user data (see GUIDATA)
417
418 VSData = guidata(handles.VSHandle);
419 L = str2double(get(handles.edit_Data_explen, 'String'));
420 OF = str2double(get(handles.edit_Data_offset, 'String'));
421 current_dir = get(handles.edit_wavdir, 'String');
422
423 [filename, pathname] = uigetfile({'*.txt'; '*.*'}, 'Select data file', current_dir);
424
425 if (filename ~= 0)
426 % try to read in the file
427 fid = fopen([pathname filename], 'rt');
428 set(handles.edit_Data_datafile, 'String', [pathname filename]);
429
430 if (fid == -1)
431 msgbox('Error: Unable to open data file', 'Error', 'error', 'modal');
432 return;
433 end
434
435 data = textscan(fid, '%s', 'delimiter', '\n');
436 fclose(fid);
437
438 % get the specified labels for invalid entry
439 delimiters = textscan(VSData.vars.MD_invalidentry, '%s', 'delimiter', ',');
440
441 % now check each entry
442 data = data{1};
443 newdata = zeros(length(data), 1) * NaN;
444
445 for k=1:length(data)
446 switch(data{k})
447 case delimiters
448
449 otherwise
450 newdata(k) = str2double(data{k});
451 end
452 end
453
454 figdata = guidata(handles.figure_ManualData);
455 figdata.newdata = newdata;
456
457 if (VSData.vars.MD_resample)
458 figdata = resample_signal(figdata, handles);
459 end
460 guidata(handles.figure_ManualData, figdata);
461
462 plotParam(handles);
463
464 set(handles.edit_Data_newlen, 'String', num2str(length(newdata)));
465 set(handles.edit_Data_pad, 'String', num2str(L - OF - length(newdata)));
466
467 end
468
469
470
471 function edit_Data_offset_Callback(hObject, eventdata, handles)
472 % hObject handle to edit_Data_offset (see GCBO)
473 % eventdata reserved - to be defined in a future version of MATLAB
474 % handles structure with handles and user data (see GUIDATA)
475 VSData = guidata(handles.VSHandle);
476
477 str = get(hObject, 'String');
478 num = str2double(str);
479 if (isnan(num))
480 set(hObject, 'String', num2str(VSData.vars.MD_offset));
481 else
482 VSData.vars.MD_offset = num;
483 guidata(handles.VSHandle, VSData);
484
485 % update the other numbers
486 L = str2double(get(handles.edit_Data_explen, 'String'));
487 NDL = str2double(get(handles.edit_Data_newlen, 'String'));
488 set(handles.edit_Data_pad, 'String', num2str(L - num - NDL));
489
490 if (VSData.vars.MD_resample)
491 figdata = guidata(handles.figure_ManualData);
492 figdata = resample_signal(figdata, handles);
493 guidata(handles.figure_ManualData, figdata);
494 end
495
496 plotParam(handles);
497 end
498
499 % --- Executes during object creation, after setting all properties.
500 function edit_Data_offset_CreateFcn(hObject, eventdata, handles)
501 % hObject handle to edit_Data_offset (see GCBO)
502 % eventdata reserved - to be defined in a future version of MATLAB
503 % handles empty - handles not created until after all CreateFcns called
504
505 % Hint: edit controls usually have a white background on Windows.
506 % See ISPC and COMPUTER.
507 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
508 set(hObject,'BackgroundColor','white');
509 end
510
511
512
513 function edit_matdir_Callback(hObject, eventdata, handles)
514 % hObject handle to edit_matdir (see GCBO)
515 % eventdata reserved - to be defined in a future version of MATLAB
516 % handles structure with handles and user data (see GUIDATA)
517
518 new_dir = get(hObject, 'String');
519 VSData = guidata(handles.VSHandle);
520
521 if (exist(new_dir, 'dir') == 7)
522 VSData = func_setmatdir('MD_matdir', new_dir, VSData);
523 set(handles.edit_matdir, 'String', new_dir);
524
525 guidata(handles.VSHandle, VSData);
526 else
527 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
528 set(hObject, 'String', VSData.vars.MD_matdir);
529 end
530
531
532 % --- Executes during object creation, after setting all properties.
533 function edit_matdir_CreateFcn(hObject, eventdata, handles)
534 % hObject handle to edit_matdir (see GCBO)
535 % eventdata reserved - to be defined in a future version of MATLAB
536 % handles empty - handles not created until after all CreateFcns called
537
538 % Hint: edit controls usually have a white background on Windows.
539 % See ISPC and COMPUTER.
540 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
541 set(hObject,'BackgroundColor','white');
542 end
543
544
545 % --- Executes on button press in pushbutton_matfile_browse.
546 function pushbutton_matfile_browse_Callback(hObject, eventdata, handles)
547 % hObject handle to pushbutton_matfile_browse (see GCBO)
548 % eventdata reserved - to be defined in a future version of MATLAB
549 % handles structure with handles and user data (see GUIDATA)
550 current_dir = get(handles.edit_matdir, 'String');
551 new_dir = uigetdir(current_dir);
552
553 VSData = guidata(handles.VSHandle);
554
555 if (ischar(new_dir))
556 VSData = func_setmatdir('MD_matdir', new_dir, VSData);
557 set(handles.edit_matdir, 'String', new_dir);
558
559 guidata(handles.VSHandle, VSData);
560 end
561
562 checkParameters(handles);
563 plotParam(handles);
564
565
566 % --- Executes on button press in pushbutton_Data_save.
567 function pushbutton_Data_save_Callback(hObject, eventdata, handles)
568 % hObject handle to pushbutton_Data_save (see GCBO)
569 % eventdata reserved - to be defined in a future version of MATLAB
570 % handles structure with handles and user data (see GUIDATA)
571 VSData = guidata(handles.VSHandle);
572 figdata = guidata(handles.figure_ManualData);
573
574 L = str2double(get(handles.edit_Data_explen, 'String'));
575 OF = VSData.vars.MD_offset;
576
577 % check we have something to save to
578 wavfilelist = get(handles.listbox_wavfilelist, 'String');
579 if (isempty(wavfilelist))
580 msgbox('Error: no wav files found.', 'Error', 'error', 'modal');
581 return;
582 end
583
584 paramlist = get(handles.listbox_Data_paramlist, 'String');
585 if (isempty(paramlist))
586 msgbox('Error: no parameters found.', 'Error', 'error', 'modal');
587 return;
588 end
589
590 % get the parameter
591 label = paramlist{get(handles.listbox_Data_paramlist, 'Value')};
592 C = textscan(label, '%s %s', 'delimiter', '(');
593 param = C{2}{1}(1:end-1);
594
595 shortwavfile = wavfilelist{get(handles.listbox_wavfilelist, 'Value')};
596 matfile = [VSData.vars.MD_matdir VSData.vars.dirdelimiter shortwavfile(1:end-3) 'mat'];
597
598
599 if (VSData.vars.MD_resample && isfield(figdata, 'newdata_resamp'))
600 data = figdata.newdata_resamp;
601 elseif (~VSData.vars.MD_resample && isfield(figdata, 'newdata'))
602 data = figdata.newdata;
603 else
604 msgbox('Error: no new data loaded.', 'Error', 'error', 'modal');
605 return;
606 end
607
608 newdata = zeros(L, 1) * NaN;
609 if (length(data) + OF >= L)
610 newdata(OF+1:L) = data;
611 else
612 if (OF >= 0)
613 newdata(OF+1:OF+length(data)) = data;
614 else
615 newdata(1:length(data)+OF) = data(abs(OF)+1:end);
616 end
617 end
618
619
620 % create the new parameter here
621 eval([sprintf(param) '= newdata;']);
622 if (exist(matfile, 'file') == 2) % mat file already exist
623 save(matfile, param, '-append');
624 else
625 save(matfile, param);
626 end
627
628 msgbox('Save complete.', 'Save', 'help', 'modal');
629
630
631
632
633 function edit_Data_explen_Callback(hObject, eventdata, handles)
634 % hObject handle to edit_Data_explen (see GCBO)
635 % eventdata reserved - to be defined in a future version of MATLAB
636 % handles structure with handles and user data (see GUIDATA)
637
638 % Hints: get(hObject,'String') returns contents of edit_Data_explen as text
639 % str2double(get(hObject,'String')) returns contents of edit_Data_explen as a double
640
641
642 % --- Executes during object creation, after setting all properties.
643 function edit_Data_explen_CreateFcn(hObject, eventdata, handles)
644 % hObject handle to edit_Data_explen (see GCBO)
645 % eventdata reserved - to be defined in a future version of MATLAB
646 % handles empty - handles not created until after all CreateFcns called
647
648 % Hint: edit controls usually have a white background on Windows.
649 % See ISPC and COMPUTER.
650 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
651 set(hObject,'BackgroundColor','white');
652 end
653
654
655
656 function edit_Data_pad_Callback(hObject, eventdata, handles)
657 % hObject handle to edit_Data_pad (see GCBO)
658 % eventdata reserved - to be defined in a future version of MATLAB
659 % handles structure with handles and user data (see GUIDATA)
660
661 % Hints: get(hObject,'String') returns contents of edit_Data_pad as text
662 % str2double(get(hObject,'String')) returns contents of edit_Data_pad as a double
663
664
665 % --- Executes during object creation, after setting all properties.
666 function edit_Data_pad_CreateFcn(hObject, eventdata, handles)
667 % hObject handle to edit_Data_pad (see GCBO)
668 % eventdata reserved - to be defined in a future version of MATLAB
669 % handles empty - handles not created until after all CreateFcns called
670
671 % Hint: edit controls usually have a white background on Windows.
672 % See ISPC and COMPUTER.
673 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
674 set(hObject,'BackgroundColor','white');
675 end
676
677
678
679 function edit_Data_newlen_Callback(hObject, eventdata, handles)
680 % hObject handle to edit_Data_newlen (see GCBO)
681 % eventdata reserved - to be defined in a future version of MATLAB
682 % handles structure with handles and user data (see GUIDATA)
683
684 % Hints: get(hObject,'String') returns contents of edit_Data_newlen as text
685 % str2double(get(hObject,'String')) returns contents of edit_Data_newlen as a double
686
687
688 % --- Executes during object creation, after setting all properties.
689 function edit_Data_newlen_CreateFcn(hObject, eventdata, handles)
690 % hObject handle to edit_Data_newlen (see GCBO)
691 % eventdata reserved - to be defined in a future version of MATLAB
692 % handles empty - handles not created until after all CreateFcns called
693
694 % Hint: edit controls usually have a white background on Windows.
695 % See ISPC and COMPUTER.
696 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
697 set(hObject,'BackgroundColor','white');
698 end
699
700
701
702 function edit_Data_invalid_Callback(hObject, eventdata, handles)
703 % hObject handle to edit_Data_invalid (see GCBO)
704 % eventdata reserved - to be defined in a future version of MATLAB
705 % handles structure with handles and user data (see GUIDATA)
706
707 % Hints: get(hObject,'String') returns contents of edit_Data_invalid as text
708 % str2double(get(hObject,'String')) returns contents of edit_Data_invalid as a double
709 VSData = guidata(handles.VSHandle);
710 VSData.vars.MD_invalidentry = get(hObject, 'String');
711 guidata(handles.VSHandle, VSData);
712
713
714 % --- Executes during object creation, after setting all properties.
715 function edit_Data_invalid_CreateFcn(hObject, eventdata, handles)
716 % hObject handle to edit_Data_invalid (see GCBO)
717 % eventdata reserved - to be defined in a future version of MATLAB
718 % handles empty - handles not created until after all CreateFcns called
719
720 % Hint: edit controls usually have a white background on Windows.
721 % See ISPC and COMPUTER.
722 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
723 set(hObject,'BackgroundColor','white');
724 end
725
726
727
728 % --- Executes on button press in checkbox_resample.
729 function checkbox_resample_Callback(hObject, eventdata, handles)
730 % hObject handle to checkbox_resample (see GCBO)
731 % eventdata reserved - to be defined in a future version of MATLAB
732 % handles structure with handles and user data (see GUIDATA)
733 VSData = guidata(handles.VSHandle);
734 VSData.vars.MD_resample = get(hObject, 'Value');
735 guidata(handles.VSHandle, VSData);
736
737 if (VSData.vars.MD_resample)
738 figdata = guidata(handles.figure_ManualData);
739 figdata = resample_signal(figdata, handles);
740 guidata(handles.figure_ManualData, figdata);
741 end
742
743 plotParam(handles);
744
745
746
747
748 % -- resample the signal if required
749 function figdata = resample_signal(figdata, handles)
750 VSData = guidata(handles.VSHandle);
751
752 if (~isfield(figdata, 'newdata'))
753 return;
754 end
755
756 newL = str2double(get(handles.edit_Data_explen, 'String'));
757
758 if (length(figdata.newdata)==1)
759 figdata.newdata_resamp = ones(newL, 1) * figdata.newdata;
760
761 else
762 try
763 figdata.newdata_resamp = resample(figdata.newdata, newL, length(figdata.newdata));
764 catch ME
765 msgbox({'Error: Unable to run resample function.', '(Requires Signal Processing Toolbox)'}, 'Error', 'error', 'modal');
766 end
767 end
768
769
770 % --- Executes on button press in checkbox_matwithwav.
771 function checkbox_matwithwav_Callback(hObject, eventdata, handles)
772 % hObject handle to checkbox_matwithwav (see GCBO)
773 % eventdata reserved - to be defined in a future version of MATLAB
774 % handles structure with handles and user data (see GUIDATA)
775
776 VSData = guidata(handles.VSHandle);
777 VSData.vars.MD_matwithwav = get(hObject, 'Value');
778
779 if (VSData.vars.MD_matwithwav)
780 set(handles.edit_matdir, 'Enable', 'Off');
781 set(handles.pushbutton_matfile_browse, 'Enable', 'Off');
782 else
783 set(handles.edit_matdir, 'Enable', 'On');
784 set(handles.pushbutton_matfile_browse, 'Enable', 'On');
785 end
786
787 guidata(handles.VSHandle, VSData);