Dawn@4
|
1 function varargout = vs_OutputToEMU(varargin)
|
Dawn@4
|
2 % VS_OUTPUTTOEMU M-file for vs_OutputToEMU.fig
|
Dawn@4
|
3 % VS_OUTPUTTOEMU, by itself, creates a new VS_OUTPUTTOEMU or raises the existing
|
Dawn@4
|
4 % singleton*.
|
Dawn@4
|
5 %
|
Dawn@4
|
6 % H = VS_OUTPUTTOEMU returns the handle to a new VS_OUTPUTTOEMU or the handle to
|
Dawn@4
|
7 % the existing singleton*.
|
Dawn@4
|
8 %
|
Dawn@4
|
9 % VS_OUTPUTTOEMU('CALLBACK',hObject,eventData,handles,...) calls the local
|
Dawn@4
|
10 % function named CALLBACK in VS_OUTPUTTOEMU.M with the given input arguments.
|
Dawn@4
|
11 %
|
Dawn@4
|
12 % VS_OUTPUTTOEMU('Property','Value',...) creates a new VS_OUTPUTTOEMU 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_OutputToEMU_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_OutputToEMU_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_OutputToEMU
|
Dawn@4
|
24
|
Dawn@4
|
25 % Last Modified by GUIDE v2.5 15-Oct-2009 12:44:26
|
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_OutputToEMU_OpeningFcn, ...
|
Dawn@4
|
32 'gui_OutputFcn', @vs_OutputToEMU_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_OutputToEMU is made visible.
|
Dawn@4
|
48 function vs_OutputToEMU_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_OutputToEMU (see VARARGIN)
|
Dawn@4
|
54
|
Dawn@4
|
55 % Choose default command line output for vs_OutputToEMU
|
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 % Update handles structure
|
Dawn@4
|
65 guidata(hObject, handles);
|
Dawn@4
|
66
|
Dawn@4
|
67 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
68 set(handles.edit_matdir, 'String', VSData.vars.OTE_matdir);
|
Dawn@4
|
69 set(handles.edit_outputdir, 'String', VSData.vars.OTE_outputdir);
|
Dawn@4
|
70
|
Dawn@4
|
71 if (VSData.vars.recursedir)
|
Dawn@4
|
72 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat');
|
Dawn@4
|
73 else
|
Dawn@4
|
74 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat');
|
Dawn@4
|
75 end
|
Dawn@4
|
76
|
Dawn@4
|
77 paramlist = func_getoutputparameterlist();
|
Dawn@4
|
78
|
Dawn@4
|
79 % default is everything selected
|
Dawn@4
|
80 if (isempty(VSData.vars.OTE_paramselection))
|
Dawn@4
|
81 VSData.vars.OTE_paramselection = 1:length(paramlist);
|
Dawn@4
|
82 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
83 end
|
Dawn@4
|
84
|
Dawn@4
|
85 set(handles.listbox_paramlist, 'String', paramlist, 'Value', VSData.vars.OTE_paramselection);
|
Dawn@4
|
86
|
Dawn@4
|
87 set(handles.checkbox_saveEMUwithmat, 'Value', VSData.vars.OTE_saveEMUwithmat);
|
Dawn@4
|
88
|
Dawn@4
|
89 if (VSData.vars.OTE_saveEMUwithmat)
|
Dawn@4
|
90 set(handles.edit_outputdir, 'Enable', 'Off');
|
Dawn@4
|
91 set(handles.pushbutton_outputdir_browse, 'Enable', 'Off');
|
Dawn@4
|
92 else
|
Dawn@4
|
93 set(handles.edit_outputdir, 'Enable', 'On');
|
Dawn@4
|
94 set(handles.pushbutton_outputdir_browse, 'Enable', 'On');
|
Dawn@4
|
95 end
|
Dawn@4
|
96
|
Dawn@4
|
97 set(handles.listbox_matfilelist, 'KeyPressFcn', @filelist_listbox_KeyPressFcn);
|
Dawn@4
|
98
|
Dawn@4
|
99
|
Dawn@4
|
100
|
Dawn@4
|
101 % UIWAIT makes vs_OutputToEMU wait for user response (see UIRESUME)
|
Dawn@4
|
102 % uiwait(handles.figure_OutputToEMU);
|
Dawn@4
|
103
|
Dawn@4
|
104
|
Dawn@4
|
105 % --- Outputs from this function are returned to the command line.
|
Dawn@4
|
106 function varargout = vs_OutputToEMU_OutputFcn(hObject, eventdata, handles)
|
Dawn@4
|
107 % varargout cell array for returning output args (see VARARGOUT);
|
Dawn@4
|
108 % hObject handle to figure
|
Dawn@4
|
109 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
110 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
111
|
Dawn@4
|
112 % Get default command line output from handles structure
|
Dawn@4
|
113 varargout{1} = handles.output;
|
Dawn@4
|
114
|
Dawn@4
|
115
|
Dawn@4
|
116
|
Dawn@4
|
117 function edit_matdir_Callback(hObject, eventdata, handles)
|
Dawn@4
|
118 % hObject handle to edit_matdir (see GCBO)
|
Dawn@4
|
119 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
120 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
121 new_dir = get(handles.edit_matdir, 'String');
|
Dawn@4
|
122 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
123
|
Dawn@4
|
124 if (exist(new_dir, 'dir') == 7)
|
Dawn@4
|
125 VSData = func_setmatdir('OTE_matdir', new_dir, VSData);
|
Dawn@4
|
126 set(handles.edit_matdir, 'String', new_dir);
|
Dawn@4
|
127
|
Dawn@4
|
128 if (VSData.vars.recursedir)
|
Dawn@4
|
129 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat');
|
Dawn@4
|
130 else
|
Dawn@4
|
131 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat');
|
Dawn@4
|
132 end
|
Dawn@4
|
133
|
Dawn@4
|
134 if (VSData.vars.OTE_saveEMUwithmat)
|
Dawn@4
|
135 set(handles.edit_outputdir, 'String', new_dir);
|
Dawn@4
|
136 VSData.vars.OTE_outputdir = new_dir;
|
Dawn@4
|
137 end
|
Dawn@4
|
138
|
Dawn@4
|
139 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
140 else
|
Dawn@4
|
141 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
|
Dawn@4
|
142 set(hObject, 'String', VSData.vars.OTE_matdir);
|
Dawn@4
|
143 end
|
Dawn@4
|
144
|
Dawn@4
|
145 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
146 function edit_matdir_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
147 % hObject handle to edit_matdir (see GCBO)
|
Dawn@4
|
148 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
149 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
150
|
Dawn@4
|
151 % Hint: edit controls usually have a white background on Windows.
|
Dawn@4
|
152 % See ISPC and COMPUTER.
|
Dawn@4
|
153 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
154 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
155 end
|
Dawn@4
|
156
|
Dawn@4
|
157
|
Dawn@4
|
158 % --- Executes on button press in pushbutton_matdir_browse.
|
Dawn@4
|
159 function pushbutton_matdir_browse_Callback(hObject, eventdata, handles)
|
Dawn@4
|
160 % hObject handle to pushbutton_matdir_browse (see GCBO)
|
Dawn@4
|
161 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
162 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
163 current_dir = get(handles.edit_matdir, 'String');
|
Dawn@4
|
164 new_dir = uigetdir(current_dir);
|
Dawn@4
|
165 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
166
|
Dawn@4
|
167 if (ischar(new_dir))
|
Dawn@4
|
168 VSData = func_setmatdir('OTE_matdir', new_dir, VSData);
|
Dawn@4
|
169 set(handles.edit_matdir, 'String', new_dir);
|
Dawn@4
|
170
|
Dawn@4
|
171 if (VSData.vars.recursedir)
|
Dawn@4
|
172 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat');
|
Dawn@4
|
173 else
|
Dawn@4
|
174 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat');
|
Dawn@4
|
175 end
|
Dawn@4
|
176
|
Dawn@4
|
177 if (VSData.vars.OTE_saveEMUwithmat)
|
Dawn@4
|
178 set(handles.edit_outputdir, 'String', new_dir);
|
Dawn@4
|
179 VSData.vars.OTE_outputdir = new_dir;
|
Dawn@4
|
180 end
|
Dawn@4
|
181
|
Dawn@4
|
182 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
183 end
|
Dawn@4
|
184
|
Dawn@4
|
185
|
Dawn@4
|
186
|
Dawn@4
|
187 % --- Executes on selection change in listbox_matfilelist.
|
Dawn@4
|
188 function listbox_matfilelist_Callback(hObject, eventdata, handles)
|
Dawn@4
|
189 % hObject handle to listbox_matfilelist (see GCBO)
|
Dawn@4
|
190 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
191 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
192
|
Dawn@4
|
193 % Hints: contents = get(hObject,'String') returns listbox_matfilelist contents as cell array
|
Dawn@4
|
194 % contents{get(hObject,'Value')} returns selected item from listbox_matfilelist
|
Dawn@4
|
195
|
Dawn@4
|
196
|
Dawn@4
|
197 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
198 function listbox_matfilelist_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
199 % hObject handle to listbox_matfilelist (see GCBO)
|
Dawn@4
|
200 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
201 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
202
|
Dawn@4
|
203 % Hint: listbox controls usually have a white background on Windows.
|
Dawn@4
|
204 % See ISPC and COMPUTER.
|
Dawn@4
|
205 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
206 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
207 end
|
Dawn@4
|
208
|
Dawn@4
|
209
|
Dawn@4
|
210 % --- Executes on selection change in listbox_paramlist.
|
Dawn@4
|
211 function listbox_paramlist_Callback(hObject, eventdata, handles)
|
Dawn@4
|
212 % hObject handle to listbox_paramlist (see GCBO)
|
Dawn@4
|
213 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
214 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
215 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
216
|
Dawn@4
|
217 inx = get(hObject, 'Value');
|
Dawn@4
|
218 VSData.vars.OTE_paramselection = setxor(VSData.vars.OTE_paramselection, inx);
|
Dawn@4
|
219 set(hObject, 'Value', [VSData.vars.OTE_paramselection]);
|
Dawn@4
|
220 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
221
|
Dawn@4
|
222
|
Dawn@4
|
223 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
224 function listbox_paramlist_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
225 % hObject handle to listbox_paramlist (see GCBO)
|
Dawn@4
|
226 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
227 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
228
|
Dawn@4
|
229 % Hint: listbox controls usually have a white background on Windows.
|
Dawn@4
|
230 % See ISPC and COMPUTER.
|
Dawn@4
|
231 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
232 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
233 end
|
Dawn@4
|
234
|
Dawn@4
|
235
|
Dawn@4
|
236
|
Dawn@4
|
237 function edit_outputdir_Callback(hObject, eventdata, handles)
|
Dawn@4
|
238 % hObject handle to edit_outputdir (see GCBO)
|
Dawn@4
|
239 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
240 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
241 new_dir = get(handles.edit_outputdir, 'String');
|
Dawn@4
|
242 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
243
|
Dawn@4
|
244 if (exist(new_dir, 'dir') == 7)
|
Dawn@4
|
245 VSData.vars.OTE_outputdir = new_dir;
|
Dawn@4
|
246 set(handles.edit_outputdir, 'String', new_dir);
|
Dawn@4
|
247 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
248 else
|
Dawn@4
|
249 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
|
Dawn@4
|
250 end
|
Dawn@4
|
251
|
Dawn@4
|
252 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
253 function edit_outputdir_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
254 % hObject handle to edit_outputdir (see GCBO)
|
Dawn@4
|
255 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
256 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
257
|
Dawn@4
|
258 % Hint: edit controls usually have a white background on Windows.
|
Dawn@4
|
259 % See ISPC and COMPUTER.
|
Dawn@4
|
260 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
261 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
262 end
|
Dawn@4
|
263
|
Dawn@4
|
264
|
Dawn@4
|
265 % --- Executes on button press in pushbutton_outputdir_browse.
|
Dawn@4
|
266 function pushbutton_outputdir_browse_Callback(hObject, eventdata, handles)
|
Dawn@4
|
267 % hObject handle to pushbutton_outputdir_browse (see GCBO)
|
Dawn@4
|
268 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
269 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
270 current_dir = get(handles.edit_outputdir, 'String');
|
Dawn@4
|
271 new_dir = uigetdir(current_dir);
|
Dawn@4
|
272 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
273
|
Dawn@4
|
274 if (ischar(new_dir))
|
Dawn@4
|
275 VSData.vars.OTE_outputdir = new_dir;
|
Dawn@4
|
276 set(handles.edit_outputdir, 'String', new_dir);
|
Dawn@4
|
277
|
Dawn@4
|
278 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
279 end
|
Dawn@4
|
280
|
Dawn@4
|
281
|
Dawn@4
|
282 % --- Executes on button press in togglebutton_start.
|
Dawn@4
|
283 function togglebutton_start_Callback(hObject, eventdata, handles)
|
Dawn@4
|
284 % hObject handle to togglebutton_start (see GCBO)
|
Dawn@4
|
285 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
286 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
287
|
Dawn@4
|
288 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
289 matfilelist = get(handles.listbox_matfilelist, 'String');
|
Dawn@4
|
290 if (isempty(matfilelist))
|
Dawn@4
|
291 msgbox('Error: no mat files found.', 'Error', 'error', 'modal');
|
Dawn@4
|
292 return;
|
Dawn@4
|
293 end
|
Dawn@4
|
294
|
Dawn@4
|
295 if (isempty(VSData.vars.OTE_paramselection))
|
Dawn@4
|
296 msgbox('Error: no parameters selected.', 'Error', 'error', 'modal');
|
Dawn@4
|
297 return;
|
Dawn@4
|
298 end
|
Dawn@4
|
299
|
Dawn@4
|
300 if (get(hObject, 'Value') == 1) % start the process
|
Dawn@4
|
301 set(hObject, 'String', 'Processing...', 'ForegroundColor', 'red');
|
Dawn@4
|
302
|
Dawn@4
|
303 WriteEMUfiles(handles);
|
Dawn@4
|
304
|
Dawn@4
|
305 set(hObject, 'String', 'Start!', 'ForegroundColor', 'black', 'Value', 0);
|
Dawn@4
|
306 end
|
Dawn@4
|
307
|
Dawn@4
|
308
|
Dawn@4
|
309
|
Dawn@4
|
310
|
Dawn@4
|
311 function filelist_listbox_KeyPressFcn(hObject, eventdata)
|
Dawn@4
|
312 handles = guidata(hObject);
|
Dawn@4
|
313
|
Dawn@4
|
314 key = double(get(gcbf, 'CurrentCharacter'));
|
Dawn@4
|
315 if (gcbo == handles.listbox_matfilelist)
|
Dawn@4
|
316 if (key == 127) % delete key
|
Dawn@4
|
317
|
Dawn@4
|
318 inx = get(handles.listbox_matfilelist, 'Value');
|
Dawn@4
|
319 contents = get(handles.listbox_matfilelist, 'String');
|
Dawn@4
|
320
|
Dawn@4
|
321 %nothing to do
|
Dawn@4
|
322 if (isempty(contents))
|
Dawn@4
|
323 return;
|
Dawn@4
|
324 end
|
Dawn@4
|
325
|
Dawn@4
|
326 newinx = setxor(inx, [1:length(contents)]);
|
Dawn@4
|
327
|
Dawn@4
|
328 newcontents = contents(newinx);
|
Dawn@4
|
329 set(handles.listbox_matfilelist, 'String', newcontents);
|
Dawn@4
|
330
|
Dawn@4
|
331 if (inx(end) > length(newcontents))
|
Dawn@4
|
332 set(handles.listbox_matfilelist, 'Value', length(newcontents));
|
Dawn@4
|
333 else
|
Dawn@4
|
334 set(handles.listbox_matfilelist, 'Value', inx(end));
|
Dawn@4
|
335 end
|
Dawn@4
|
336 end
|
Dawn@4
|
337 end
|
Dawn@4
|
338
|
Dawn@4
|
339
|
Dawn@4
|
340 % --- Executes on button press in checkbox_saveEMUwithmat.
|
Dawn@4
|
341 function checkbox_saveEMUwithmat_Callback(hObject, eventdata, handles)
|
Dawn@4
|
342 % hObject handle to checkbox_saveEMUwithmat (see GCBO)
|
Dawn@4
|
343 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
344 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
345
|
Dawn@4
|
346 % Hint: get(hObject,'Value') returns toggle state of checkbox_saveEMUwithmat
|
Dawn@4
|
347 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
348 VSData.vars.OTE_saveEMUwithmat = get(hObject, 'Value');
|
Dawn@4
|
349
|
Dawn@4
|
350 if (VSData.vars.OTE_saveEMUwithmat)
|
Dawn@4
|
351 set(handles.edit_outputdir, 'Enable', 'Off');
|
Dawn@4
|
352 set(handles.pushbutton_outputdir_browse, 'Enable', 'Off');
|
Dawn@4
|
353
|
Dawn@4
|
354 set(handles.edit_outputdir, 'String', VSData.vars.OTE_matdir);
|
Dawn@4
|
355 VSData.vars.OTE_outputdir = VSData.vars.OTE_matdir;
|
Dawn@4
|
356
|
Dawn@4
|
357 else
|
Dawn@4
|
358 set(handles.edit_outputdir, 'Enable', 'On');
|
Dawn@4
|
359 set(handles.pushbutton_outputdir_browse, 'Enable', 'On');
|
Dawn@4
|
360 end
|
Dawn@4
|
361
|
Dawn@4
|
362 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
363
|
Dawn@4
|
364
|
Dawn@4
|
365 % -- main outputting function
|
Dawn@4
|
366 function WriteEMUfiles(handles)
|
Dawn@4
|
367
|
Dawn@4
|
368 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
369 MBox = MessageBox;
|
Dawn@4
|
370 MBoxHandles = guidata(MBox);
|
Dawn@4
|
371
|
Dawn@4
|
372 matfilelist = get(handles.listbox_matfilelist, 'String');
|
Dawn@4
|
373 messages = cell(length(matfilelist) + 1, 1);
|
Dawn@4
|
374
|
Dawn@4
|
375 paramlist = get(handles.listbox_paramlist, 'String');
|
Dawn@4
|
376 params = paramlist(VSData.vars.OTE_paramselection);
|
Dawn@4
|
377
|
Dawn@4
|
378 errcnt = 0;
|
Dawn@4
|
379
|
Dawn@4
|
380 for k=1:length(matfilelist)
|
Dawn@4
|
381 messages{k} = sprintf('%d/%d. %s: ', k, length(matfilelist), matfilelist{k});
|
Dawn@4
|
382 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
383 set(handles.listbox_matfilelist, 'Value', k);
|
Dawn@4
|
384 drawnow;
|
Dawn@4
|
385
|
Dawn@4
|
386 matfile = [VSData.vars.OTE_matdir VSData.vars.dirdelimiter matfilelist{k}];
|
Dawn@4
|
387 mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize);
|
Dawn@4
|
388
|
Dawn@4
|
389 for n=1:length(params)
|
Dawn@4
|
390 C = textscan(params{n}, '%s %s', 'delimiter', '(');
|
Dawn@4
|
391 param = C{2}{1}(1:end-1);
|
Dawn@4
|
392
|
Dawn@4
|
393 if (~isfield(mdata, param))
|
Dawn@4
|
394 messages{k} = [messages{k} param ' not found, '];
|
Dawn@4
|
395 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
396 set(handles.listbox_matfilelist, 'Value', k);
|
Dawn@4
|
397 drawnow;
|
Dawn@4
|
398 errcnt = errcnt + 1;
|
Dawn@4
|
399 continue;
|
Dawn@4
|
400 end
|
Dawn@4
|
401
|
Dawn@4
|
402 messages{k} = [messages{k} param ', '];
|
Dawn@4
|
403 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
404 set(handles.listbox_matfilelist, 'Value', k);
|
Dawn@4
|
405 drawnow;
|
Dawn@4
|
406
|
Dawn@4
|
407 outfile = [VSData.vars.OTE_outputdir VSData.vars.dirdelimiter matfilelist{k}(1:end-3) param];
|
Dawn@4
|
408
|
Dawn@4
|
409 % check that the outputdir exists
|
Dawn@4
|
410 pathname = fileparts(outfile);
|
Dawn@4
|
411 if (exist(pathname, 'dir') ~= 7)
|
Dawn@4
|
412 mkdir(pathname);
|
Dawn@4
|
413 end
|
Dawn@4
|
414
|
Dawn@4
|
415 func_VS2ssff(mdata.(param), param, outfile, VSData.vars);
|
Dawn@4
|
416
|
Dawn@4
|
417 % check if user has requested a halt
|
Dawn@4
|
418 if (get(MBoxHandles.figure_MessageBox, 'UserData') == 1)
|
Dawn@4
|
419 messages{k+1} = 'Stop button pressed.';
|
Dawn@4
|
420 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
421 break;
|
Dawn@4
|
422 end
|
Dawn@4
|
423
|
Dawn@4
|
424 end
|
Dawn@4
|
425
|
Dawn@4
|
426 if (get(MBoxHandles.figure_MessageBox, 'UserData') == 1)
|
Dawn@4
|
427 break;
|
Dawn@4
|
428 end
|
Dawn@4
|
429
|
Dawn@4
|
430 end
|
Dawn@4
|
431
|
Dawn@4
|
432 messages{length(matfilelist)+1} = sprintf('Completed. %d errors found.', errcnt);
|
Dawn@4
|
433 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
434 set(handles.listbox_matfilelist, 'Value', k);
|
Dawn@4
|
435 drawnow;
|
Dawn@4
|
436
|
Dawn@4
|
437 set(MBoxHandles.pushbutton_close, 'Enable', 'On');
|
Dawn@4
|
438 set(MBoxHandles.pushbutton_stop, 'Enable', 'Off'); |