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