1 | %'series': master function associated to the GUI series.m for analysis field series |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function varargout = series(varargin) |
---|
4 | % associated with the GUI series.fig |
---|
5 | % |
---|
6 | %INPUT |
---|
7 | % param: structure with input parameters (link with the GUI uvmat) |
---|
8 | % .menu_coord_str: string for the transform_fct (menu for coordinate transforms) |
---|
9 | % .menu_coord_val: value for transform_fct (menu for coordinate transforms) |
---|
10 | % .FileName: input file name |
---|
11 | % .FileName_1: second input file name |
---|
12 | % .list_field: menu of input fields |
---|
13 | % .index_fields: chosen index |
---|
14 | % .civ1=0 or 1, .interp1, ... : input civ field type |
---|
15 | % |
---|
16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
17 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
18 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
19 | % This file is part of the toolbox UVMAT. |
---|
20 | % |
---|
21 | % UVMAT is free software; you can redistribute it and/or modify |
---|
22 | % it under the terms of the GNU General Public License as published by |
---|
23 | % the Free Software Foundation; either version 2 of the License, or |
---|
24 | % (at your option) any later version. |
---|
25 | % |
---|
26 | % UVMAT is distributed in the hope that it will be useful, |
---|
27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
29 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
30 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
31 | |
---|
32 | %------------------------------------------------------------------------ |
---|
33 | %------------------------------------------------------------------------ |
---|
34 | % I - MAIN FUNCTION series |
---|
35 | %------------------------------------------------------------------------ |
---|
36 | %------------------------------------------------------------------------ |
---|
37 | function varargout = series(varargin) |
---|
38 | |
---|
39 | % Begin initialization code - DO NOT EDIT |
---|
40 | gui_Singleton = 1; |
---|
41 | gui_State = struct('gui_Name', mfilename, ... |
---|
42 | 'gui_Singleton', gui_Singleton, ... |
---|
43 | 'gui_OpeningFcn', @series_OpeningFcn, ... |
---|
44 | 'gui_OutputFcn', @series_OutputFcn, ... |
---|
45 | 'gui_LayoutFcn', [] , ... |
---|
46 | 'gui_Callback', []); |
---|
47 | if nargin && ischar(varargin{1}) |
---|
48 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
49 | end |
---|
50 | |
---|
51 | if nargout |
---|
52 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
53 | else |
---|
54 | gui_mainfcn(gui_State, varargin{:}); |
---|
55 | end |
---|
56 | % End initialization code - DO NOT EDIT |
---|
57 | |
---|
58 | %-------------------------------------------------------------------------- |
---|
59 | % --- Executes just before series is made visible. |
---|
60 | %-------------------------------------------------------------------------- |
---|
61 | function series_OpeningFcn(hObject, eventdata, handles,param) |
---|
62 | global nb_builtin_ACTION nb_builtin_transform |
---|
63 | % Choose default command line output for series |
---|
64 | handles.output = hObject; |
---|
65 | % Update handles structure |
---|
66 | guidata(hObject, handles); |
---|
67 | %default initial parameters |
---|
68 | drawnow |
---|
69 | set(hObject,'Units','pixels') |
---|
70 | set(handles.PairString,'ColumnEditable',logical(0)) |
---|
71 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
72 | set(handles.PairString,'ColumnWidth',{60}) |
---|
73 | set(handles.PairString,'Data',{''}) |
---|
74 | % set(0,'Units','pixels') |
---|
75 | % screensize=get(0,'ScreenSize'); %screen size in pixels |
---|
76 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
77 | %set(hObject,'Position',[150 100 1000 600] );%position and size in pixels (get adjusted to the screen size in case of excess) |
---|
78 | %load the list of previously browsed files in menus Open and Open_1 |
---|
79 | dir_perso=prefdir; |
---|
80 | test_profil_perso=0; |
---|
81 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
82 | if exist(profil_perso,'file') |
---|
83 | h=load (profil_perso); |
---|
84 | test_profil_perso=1; |
---|
85 | if isfield(h,'MenuFile_1') |
---|
86 | set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
87 | set(handles.MenuFile_insert_1,'Label',h.MenuFile_1); |
---|
88 | end |
---|
89 | if isfield(h,'MenuFile_1') |
---|
90 | set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
91 | set(handles.MenuFile_insert_2,'Label',h.MenuFile_2); |
---|
92 | end |
---|
93 | if isfield(h,'MenuFile_1') |
---|
94 | set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
95 | set(handles.MenuFile_insert_3,'Label',h.MenuFile_3); |
---|
96 | end |
---|
97 | if isfield(h,'MenuFile_1') |
---|
98 | set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
99 | set(handles.MenuFile_insert_4,'Label',h.MenuFile_4); |
---|
100 | end |
---|
101 | if isfield(h,'MenuFile_1') |
---|
102 | set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
103 | set(handles.MenuFile_insert_5,'Label',h.MenuFile_5); |
---|
104 | end |
---|
105 | end |
---|
106 | |
---|
107 | %check default input data |
---|
108 | if ~exist('param','var') |
---|
109 | param=[]; %default |
---|
110 | end |
---|
111 | |
---|
112 | %% file name and browser initialisation |
---|
113 | if isfield(param,'menu_coord_str') |
---|
114 | set(handles.transform_fct,'String',param.menu_coord_str) |
---|
115 | end |
---|
116 | if isfield(param,'menu_coord_val') |
---|
117 | set(handles.transform_fct,'Value',param.menu_coord_val); |
---|
118 | else |
---|
119 | set(handles.transform_fct,'Value',1);%default |
---|
120 | end |
---|
121 | if isfield(param,'FileName') |
---|
122 | if isfield(param,'FileName_1') |
---|
123 | display_file_name(handles,param.FileName_1,0) |
---|
124 | display_file_name(handles,param.FileName,1) |
---|
125 | else |
---|
126 | display_file_name(handles,param.FileName,0) |
---|
127 | end |
---|
128 | end |
---|
129 | |
---|
130 | %% fields input initialisation |
---|
131 | if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields) |
---|
132 | set(handles.FieldMenu,'String',param.list_fields);% list menu fields |
---|
133 | set(handles.FieldMenu,'Value',param.index_fields);% selected string index |
---|
134 | FieldCell{1}=param.list_fields{param.index_fields}; |
---|
135 | end |
---|
136 | |
---|
137 | %loads the information stored in prefdir to initiate the list of ACTION functions |
---|
138 | fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
139 | transform_menu={'';'phys';'px';'phys_polar'}; |
---|
140 | nb_builtin_ACTION=numel(fct_menu); %number of functions |
---|
141 | nb_transform=numel(transform_menu); |
---|
142 | [path_series,name,ext]=fileparts(which('series')); |
---|
143 | path_series=fullfile(path_series,'series');%path of the function 'series' |
---|
144 | addpath (path_series) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
145 | path_transform=fullfile(path_series,'transform_field');%path to the field transform functions |
---|
146 | for ilist=1:length(fct_menu) |
---|
147 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
148 | end |
---|
149 | |
---|
150 | %% TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions |
---|
151 | menu_str={'';'phys';'px';'phys_polar'}; |
---|
152 | nb_builtin_transform=numel(menu_str); %number of functions |
---|
153 | [path_uvmat,name,ext]=fileparts(which('uvmat')); |
---|
154 | addpath(fullfile(path_uvmat,'transform_field')) |
---|
155 | fct_handle{1,1}=[]; |
---|
156 | testexist(1)=1; |
---|
157 | for ilist=2:length(menu_str) |
---|
158 | if exist(menu_str{ilist},'file') |
---|
159 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
160 | testexist(ilist)=1; |
---|
161 | else |
---|
162 | testexist(ilist)=0; |
---|
163 | end |
---|
164 | end |
---|
165 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
166 | |
---|
167 | %% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir |
---|
168 | if test_profil_perso |
---|
169 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
170 | for ilist=1:length(h.series_fct) |
---|
171 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
172 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
173 | fct_menu=[fct_menu; {file}]; |
---|
174 | end |
---|
175 | end |
---|
176 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
177 | for ilist=1:length(h.transform_fct); |
---|
178 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
179 | addpath(path) |
---|
180 | if exist(file,'file') |
---|
181 | h_func=str2func(file); |
---|
182 | testexist=[testexist 1]; |
---|
183 | else |
---|
184 | h_func=[]; |
---|
185 | testexist=[testexist 0]; |
---|
186 | end |
---|
187 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths |
---|
188 | rmpath(path) |
---|
189 | menu_str=[menu_str; {file}]; |
---|
190 | end |
---|
191 | end |
---|
192 | end |
---|
193 | fct_menu=[fct_menu;{'more...'}]; |
---|
194 | set(handles.ACTION,'String',fct_menu) |
---|
195 | set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
196 | menu_str=menu_str(find(testexist)); |
---|
197 | fct_handle=fct_handle(find(testexist)); |
---|
198 | menu_str=[menu_str;{'more...'}]; |
---|
199 | set(handles.transform_fct,'String',menu_str) |
---|
200 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
201 | |
---|
202 | % display the GUI for the default action 'check_data_files' |
---|
203 | ACTION_Callback(hObject, eventdata, handles) |
---|
204 | |
---|
205 | %------------------------------------------------------------------------ |
---|
206 | % --- Outputs from this function are returned to the command line. |
---|
207 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
208 | %------------------------------------------------------------------------ |
---|
209 | % varargout cell array for returning output args (see VARARGOUT); |
---|
210 | % hObject handle to figure |
---|
211 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
212 | % handles structure with handles and user data (see GUIDATA) |
---|
213 | % Get default command line output from handles structure |
---|
214 | varargout{1} = handles.output; |
---|
215 | |
---|
216 | %------------------------------------------------------------------------ |
---|
217 | %------------------------------------------------------------------------ |
---|
218 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
219 | % automatically sets the global properties when the rootfile name is introduced |
---|
220 | % then activate the view-field action if selected |
---|
221 | % it is activated either by clicking on the RootPath window or by the |
---|
222 | % browser |
---|
223 | %------------------------------------------------------------------------ |
---|
224 | %------------------------------------------------------------------------ |
---|
225 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
226 | %------------------------------------------------------------------------ |
---|
227 | InputTable=get(handles.InputTable,'Data'); |
---|
228 | RootPathCell=InputTable(:,1); |
---|
229 | SubDirCell=InputTable(:,2); |
---|
230 | RootFileCell=InputTable(:,3); |
---|
231 | oldfile=''; %default |
---|
232 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
233 | dir_perso=prefdir; |
---|
234 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
235 | if exist(profil_perso,'file') |
---|
236 | h=load (profil_perso); |
---|
237 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
238 | oldfile=h.filebase; |
---|
239 | end |
---|
240 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
241 | oldfile=h.RootPath; |
---|
242 | end |
---|
243 | end |
---|
244 | else |
---|
245 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
246 | end |
---|
247 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
248 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
249 | '*.xml', '.xml files '; ... |
---|
250 | '*.xls', '.xls files '; ... |
---|
251 | '*.png','.png image files'; ... |
---|
252 | '*.tif','.tif image files'; ... |
---|
253 | '*.avi;*.AVI','.avi movie files'; ... |
---|
254 | '*.nc','.netcdf files'; ... |
---|
255 | '*.*', 'All Files (*.*)'}, ... |
---|
256 | 'Pick a file',oldfile); |
---|
257 | fileinput=[PathName FileName];%complete file name |
---|
258 | sizf=size(fileinput); |
---|
259 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
260 | [path,name,ext]=fileparts(fileinput); |
---|
261 | SeriesData=[];%dfault |
---|
262 | if isequal(ext,'.xml') |
---|
263 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
264 | elseif isequal(ext,'.xls') |
---|
265 | msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
266 | else |
---|
267 | display_file_name(handles,fileinput,0) |
---|
268 | %update list of recent files in the menubar |
---|
269 | MenuFile_1=fileinput; |
---|
270 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
271 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
272 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
273 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
274 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
275 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
276 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
277 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
278 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
279 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
280 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
281 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
282 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
283 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
284 | dir_perso=prefdir; |
---|
285 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
286 | if exist(profil_perso,'file') |
---|
287 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
288 | else |
---|
289 | txt=ver('MATLAB'); |
---|
290 | Release=txt.Release; |
---|
291 | relnumb=str2num(Release(3:4)); |
---|
292 | if relnumb >= 14 |
---|
293 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
294 | else |
---|
295 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
296 | end |
---|
297 | end |
---|
298 | end |
---|
299 | |
---|
300 | % -------------------------------------------------------------------- |
---|
301 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
302 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
303 | display_file_name(handles,fileinput,0) |
---|
304 | |
---|
305 | % -------------------------------------------------------------------- |
---|
306 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
307 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
308 | display_file_name(handles,fileinput,0) |
---|
309 | |
---|
310 | % -------------------------------------------------------------------- |
---|
311 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
312 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
313 | display_file_name( handles,fileinput,0) |
---|
314 | |
---|
315 | % -------------------------------------------------------------------- |
---|
316 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
317 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
318 | display_file_name(handles,fileinput,0) |
---|
319 | |
---|
320 | % -------------------------------------------------------------------- |
---|
321 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
322 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
323 | display_file_name(handles,fileinput,0) |
---|
324 | |
---|
325 | % -------------------------------------------------------------------- |
---|
326 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
327 | InputTable=get(handles.InputTable,'Data'); |
---|
328 | RootPathCell=InputTable(:,1); |
---|
329 | SubDirCell=InputTable(:,3); |
---|
330 | RootFileCell=InputTable(:,2); |
---|
331 | % RootPathCell=get(handles.RootPath,'String'); |
---|
332 | % RootFileCell=get(handles.RootFile,'String'); |
---|
333 | oldfile=''; %default |
---|
334 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
335 | dir_perso=prefdir; |
---|
336 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
337 | if exist(profil_perso,'file') |
---|
338 | h=load (profil_perso); |
---|
339 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
340 | oldfile=h.filebase; |
---|
341 | end |
---|
342 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
343 | oldfile=h.RootPath; |
---|
344 | end |
---|
345 | end |
---|
346 | else |
---|
347 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
348 | end |
---|
349 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
350 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
351 | '*.xml', '.xml files '; ... |
---|
352 | '*.xls', '.xls files '; ... |
---|
353 | '*.png','.png image files'; ... |
---|
354 | '*.avi;*.AVI','.avi movie files'; ... |
---|
355 | '*.nc','.netcdf files'; ... |
---|
356 | '*.*', 'All Files (*.*)'}, ... |
---|
357 | 'Pick a file',oldfile); |
---|
358 | fileinput=[PathName FileName];%complete file name |
---|
359 | sizf=size(fileinput); |
---|
360 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
361 | [path,name,ext]=fileparts(fileinput); |
---|
362 | if isequal(ext,'.xml') |
---|
363 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
364 | elseif isequal(ext,'.xls') |
---|
365 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
366 | else |
---|
367 | display_file_name(handles,fileinput,1) |
---|
368 | end |
---|
369 | |
---|
370 | % -------------------------------------------------------------------- |
---|
371 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
372 | % -------------------------------------------------------------------- |
---|
373 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
374 | display_file_name(handles,fileinput,1) |
---|
375 | |
---|
376 | % -------------------------------------------------------------------- |
---|
377 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
378 | % -------------------------------------------------------------------- |
---|
379 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
380 | display_file_name(handles,fileinput,1) |
---|
381 | |
---|
382 | % -------------------------------------------------------------------- |
---|
383 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
384 | % -------------------------------------------------------------------- |
---|
385 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
386 | display_file_name( handles,fileinput,1) |
---|
387 | |
---|
388 | % -------------------------------------------------------------------- |
---|
389 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
390 | % -------------------------------------------------------------------- |
---|
391 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
392 | display_file_name( handles,fileinput,1) |
---|
393 | |
---|
394 | % -------------------------------------------------------------------- |
---|
395 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
396 | % -------------------------------------------------------------------- |
---|
397 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
398 | display_file_name(handles,fileinput,1) |
---|
399 | |
---|
400 | %------------------------------------------------------------------------ |
---|
401 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
402 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
403 | %------------------------------------------------------------------------ |
---|
404 | iview=eventdata.Indices(1); |
---|
405 | InputTable=get(handles.InputTable,'Data'); |
---|
406 | filename=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]) |
---|
407 | display_file_name(handles,fileinput,0) |
---|
408 | |
---|
409 | % hObject handle to InputTable (see GCBO) |
---|
410 | % eventdata structure with the following fields (see UITABLE) |
---|
411 | % Indices: row and column indices of the cell(s) edited |
---|
412 | % PreviousData: previous data for the cell(s) edited |
---|
413 | % EditData: string(s) entered by the user |
---|
414 | % NewData: EditData or its converted form set on the Data property. Empty if Data was not changed |
---|
415 | % Error: error string when failed to convert EditData to appropriate value for Data |
---|
416 | % handles structure with handles and user data (see GUIDATA) |
---|
417 | % check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
418 | % check_lines(eventdata.Indices(1))=1; %select the edited line for refresh |
---|
419 | % set(handles.REFRESH_INDICES,'UserData',check_lines); |
---|
420 | % set(handles.REFRESH_INDICES,'Visible','on') |
---|
421 | %InputTable=get(handles.InputTable,'Data') |
---|
422 | |
---|
423 | %------------------------------------------------------------------------ |
---|
424 | % --- refresh the GUI data after introduction of a new file |
---|
425 | % INPUT: |
---|
426 | % handles: handles of the elements in the GUI series |
---|
427 | % fileinput: name of the input file |
---|
428 | % append: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert') |
---|
429 | function display_file_name(handles,fileinput,append) |
---|
430 | %------------------------------------------------------------------------ |
---|
431 | |
---|
432 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
433 | if ~exist(fileinput,'file') |
---|
434 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
435 | return |
---|
436 | end |
---|
437 | |
---|
438 | %% enable other menus and uicontrols |
---|
439 | set(handles.MenuOpen_insert,'Enable','on') |
---|
440 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
441 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
442 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
443 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
444 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
445 | set(handles.RUN, 'Enable','On') |
---|
446 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
447 | % set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
448 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
449 | drawnow |
---|
450 | |
---|
451 | |
---|
452 | %% detect root name, nomenclature and indices in the input file name: |
---|
453 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
454 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
455 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
456 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
457 | if isempty(RootFile)&&isempty(i1_series) |
---|
458 | errormsg='no input file in the series'; |
---|
459 | return |
---|
460 | end |
---|
461 | |
---|
462 | %% fill the list of file series |
---|
463 | InputTable=get(handles.InputTable,'Data'); |
---|
464 | if append % display the input data as a new line in the table |
---|
465 | lastview=size(InputTable,1)+1; |
---|
466 | InputTable(lastview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
467 | set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}]) |
---|
468 | set(handles.ListView,'Value',lastview) |
---|
469 | % check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
470 | else % or re-initialise the list of input file series |
---|
471 | lastview=1; |
---|
472 | InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
473 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
474 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
475 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
476 | set(handles.ListView,'Value',1) |
---|
477 | set(handles.ListView,'String',{'1'}) |
---|
478 | end |
---|
479 | set(handles.InputTable,'Data',InputTable) |
---|
480 | % check_lines(lastview)=1; %select the edited line for refresh |
---|
481 | % set(handles.REFRESH_INDICES,'UserData',check_lines); |
---|
482 | |
---|
483 | %% refresh menus with info from the new series: TODO:check |
---|
484 | %REFRESH_INDICES_Callback([],[], handles) |
---|
485 | |
---|
486 | %% determine the selected reference field indices for pair display |
---|
487 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
488 | if ~isempty(i1) |
---|
489 | ref_i=i1; |
---|
490 | if ~isempty(i2) |
---|
491 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
492 | end |
---|
493 | end |
---|
494 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
495 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
496 | if ~isempty(j1) |
---|
497 | ref_j=j1; |
---|
498 | if ~isempty(j2) |
---|
499 | ref_j=floor((j1+j2)/2); |
---|
500 | end |
---|
501 | end |
---|
502 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
503 | |
---|
504 | %% update list of recent files in the menubar and save it for future opening |
---|
505 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
506 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
507 | str_find=strcmp(FileName,MenuFile); |
---|
508 | if isempty(find(str_find,1)) |
---|
509 | MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list |
---|
510 | end |
---|
511 | for ifile=1:min(length(MenuFile),5) |
---|
512 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
513 | eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
514 | end |
---|
515 | dir_perso=prefdir; |
---|
516 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
517 | if exist(profil_perso,'file') |
---|
518 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
519 | else |
---|
520 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
521 | end |
---|
522 | |
---|
523 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
524 | |
---|
525 | %% initiate input file series and refresh the current field view: |
---|
526 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,lastview); |
---|
527 | |
---|
528 | %------------------------------------------------------------------------ |
---|
529 | % --- Update information about a new field series (indices to scan, timing, |
---|
530 | % calibration from an xml file, then refresh current plots |
---|
531 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) |
---|
532 | %------------------------------------------------------------------------ |
---|
533 | |
---|
534 | %% enable j index visibility |
---|
535 | if isempty(j1_series) |
---|
536 | state='off'; |
---|
537 | else |
---|
538 | state='on'; |
---|
539 | end |
---|
540 | enable_j(handles,state) |
---|
541 | |
---|
542 | %% display the min and max indices for all the file series |
---|
543 | MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex |
---|
544 | MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex |
---|
545 | % MinIndex_i=min(i1_series(i1_series>0)); |
---|
546 | % if ~isempty(i2_series) |
---|
547 | % MaxIndex_i=max(i2_series(i2_series>0)); |
---|
548 | % else |
---|
549 | % MaxIndex_i=max(i1_series(i1_series>0)); |
---|
550 | % end |
---|
551 | % MinIndex_j=min(j1_series(j1_series>0)); |
---|
552 | % if ~isempty(j2_series) |
---|
553 | % MaxIndex_j=max(j2_series(j2_series>0)); |
---|
554 | % else |
---|
555 | % MaxIndex_j=max(j1_series(j1_series>0)); |
---|
556 | % end |
---|
557 | i_sum=sum(sum(i1_series,2),3); |
---|
558 | MaxIndex_i=max(find(i_sum>0))-1; |
---|
559 | MinIndex_i=min(find(i_sum>0))-1; |
---|
560 | j_sum=sum(sum(i1_series,1),3); |
---|
561 | MaxIndex_j=max(find(j_sum>0))-1; |
---|
562 | MinIndex_j=min(find(j_sum>0))-1; |
---|
563 | MinIndex{iview,1}=MinIndex_i; |
---|
564 | MinIndex{iview,2}=MinIndex_j; |
---|
565 | MaxIndex{iview,1}=MaxIndex_i; |
---|
566 | MaxIndex{iview,2}=MaxIndex_j; |
---|
567 | set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex |
---|
568 | set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex |
---|
569 | |
---|
570 | %% adjust the first and last indices if requested by the bounds |
---|
571 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
572 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
573 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
574 | if isempty(first_i) |
---|
575 | first_i=ref_i; |
---|
576 | elseif first_i < MinIndex_i |
---|
577 | first_i=MinIndex_i; |
---|
578 | end |
---|
579 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
580 | if isempty(first_j) |
---|
581 | first_j=ref_j; |
---|
582 | elseif first_j<MinIndex_j |
---|
583 | first_j=MinIndex_j; |
---|
584 | end |
---|
585 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
586 | if isempty(last_i) |
---|
587 | last_i=ref_i; |
---|
588 | elseif last_i > MaxIndex_i |
---|
589 | last_i=MaxIndex_i; |
---|
590 | end |
---|
591 | last_j=str2num(get(handles.num_first_j,'String')); |
---|
592 | if isempty(last_j) |
---|
593 | last_j=ref_j; |
---|
594 | elseif last_j>MaxIndex_j |
---|
595 | last_j=MaxIndex_j; |
---|
596 | end |
---|
597 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
598 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
599 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
600 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
601 | |
---|
602 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
603 | InputTable=get(handles.InputTable,'Data'); |
---|
604 | FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); |
---|
605 | time=[];%default |
---|
606 | % case of movies |
---|
607 | if strcmp(InputTable{iview,4},'*') |
---|
608 | if ~isempty(VideoObject) |
---|
609 | imainfo=get(VideoObject); |
---|
610 | time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
611 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
612 | ColorType='truecolor'; |
---|
613 | elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image |
---|
614 | if ~isempty(InputTable{iview,2}) |
---|
615 | imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); |
---|
616 | else |
---|
617 | imainfo=imfinfo([FileBase InputTable{iview,5}]); |
---|
618 | end |
---|
619 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
620 | if length(imainfo) >1 %case of image with multiple frames |
---|
621 | nbfield=length(imainfo); |
---|
622 | nbfield_j=1; |
---|
623 | end |
---|
624 | end |
---|
625 | end |
---|
626 | |
---|
627 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
628 | |
---|
629 | ext_imadoc=''; |
---|
630 | if exist([FileBase '.xml'],'file') |
---|
631 | ext_imadoc='.xml'; |
---|
632 | elseif exist([FileBase '.civ'],'file') |
---|
633 | ext_imadoc='.civ'; |
---|
634 | end |
---|
635 | %read the ImaDoc file |
---|
636 | XmlData=[]; |
---|
637 | NbSlice_calib={}; |
---|
638 | if isequal(ext_imadoc,'.xml') |
---|
639 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
640 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
641 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
642 | end |
---|
643 | if isfield(XmlData,'Time') |
---|
644 | time=XmlData.Time; |
---|
645 | end |
---|
646 | if isfield(XmlData,'Camera') |
---|
647 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
648 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
649 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
650 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
651 | end |
---|
652 | end |
---|
653 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
654 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
655 | end |
---|
656 | end |
---|
657 | if ~isempty(warntext) |
---|
658 | msgbox_uvmat('WARNING',warntext) |
---|
659 | end |
---|
660 | elseif isequal(ext_imadoc,'.civ') |
---|
661 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
662 | time=XmlData.Time; |
---|
663 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
664 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
665 | end |
---|
666 | end |
---|
667 | |
---|
668 | %% update time table |
---|
669 | TimeTable=get(handles.TimeTable,'Data'); |
---|
670 | if isempty(MinIndex_j) |
---|
671 | TimeTable{iview,1}=time(MinIndex_i); |
---|
672 | TimeTable{iview,2}=time(first_i); |
---|
673 | TimeTable{iview,3}=time(last_i); |
---|
674 | TimeTable{iview,4}=time(MaxIndex_i); |
---|
675 | elseif ~isempty(time) |
---|
676 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
677 | TimeTable{iview,2}=time(first_i,first_j); |
---|
678 | TimeTable{iview,3}=time(last_i,last_j); |
---|
679 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
680 | end |
---|
681 | set(handles.TimeTable,'Data',TimeTable) |
---|
682 | |
---|
683 | %% number of slices |
---|
684 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
685 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
686 | if siz(1)>1 |
---|
687 | NbSlice=siz(1); |
---|
688 | else |
---|
689 | NbSlice=1; |
---|
690 | end |
---|
691 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
692 | end |
---|
693 | |
---|
694 | %% update pair menus |
---|
695 | ListView=get(handles.ListView,'String'); |
---|
696 | ListView{iview}=num2str(iview); |
---|
697 | set(handles.ListView,'String'); |
---|
698 | set(handles.ListView,'Value',iview) |
---|
699 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
700 | |
---|
701 | %% display the set of existing files as an image |
---|
702 | set(handles.waitbar_frame,'Units','pixels') |
---|
703 | pos=get(handles.waitbar_frame,'Position'); |
---|
704 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
705 | yima=0.5:pos(4)-0.5; |
---|
706 | [XIma,YIma]=meshgrid(xima,yima); |
---|
707 | nb_i=size(i1_series,1); |
---|
708 | nb_j=size(i1_series,2); |
---|
709 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
710 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
711 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
712 | CData=zeros([size(XIma) 3]); |
---|
713 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
714 | if numel(file_ima)>=2 |
---|
715 | if size(file_ima,1)==1 |
---|
716 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
717 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
718 | else |
---|
719 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
720 | end |
---|
721 | set(handles.waitbar_frame,'CData',CData) |
---|
722 | end |
---|
723 | set(handles.waitbar_frame,'Units','normalized') |
---|
724 | |
---|
725 | %% enable field and veltype menus |
---|
726 | SeriesData=get(handles.series,'UserData'); |
---|
727 | SeriesData.FileType{iview}=FileType; |
---|
728 | check_civ=0; |
---|
729 | check_netcdf=0; |
---|
730 | for iview=1:length(SeriesData.FileType) |
---|
731 | switch SeriesData.FileType{iview} |
---|
732 | case {'civx','civdata'} |
---|
733 | check_civ=check_civ+1; |
---|
734 | case 'netcdf' |
---|
735 | check_netcdf=check_netcdf+1; |
---|
736 | end |
---|
737 | end |
---|
738 | if check_civ |
---|
739 | enable='on'; |
---|
740 | else |
---|
741 | enable='off'; |
---|
742 | end |
---|
743 | set(handles.VelTypeMenu,'Visible',enable) |
---|
744 | set(handles.VelType_text,'Visible',enable) |
---|
745 | if check_civ>=2 |
---|
746 | enable='on'; |
---|
747 | else |
---|
748 | enable='off'; |
---|
749 | end |
---|
750 | set(handles.VelTypeMenu_1,'Visible',enable) |
---|
751 | set(handles.VelType_text_1,'Visible',enable) |
---|
752 | if check_civ || check_netcdf |
---|
753 | enable='on'; |
---|
754 | else |
---|
755 | enable='off'; |
---|
756 | end |
---|
757 | set(handles.FieldMenu,'Visible',enable) |
---|
758 | set(handles.Field_text,'Visible',enable) |
---|
759 | if check_civ+ check_netcdf>=2 |
---|
760 | enable='on'; |
---|
761 | else |
---|
762 | enable='off'; |
---|
763 | end |
---|
764 | set(handles.FieldMenu_1,'Visible',enable) |
---|
765 | set(handles.Field_text_1,'Visible',enable) |
---|
766 | FieldString={''}; |
---|
767 | if check_civ |
---|
768 | FieldString=[calc_field;{'get_field...'}]; |
---|
769 | elseif check_netcdf |
---|
770 | FieldString={'get_field...'}; |
---|
771 | end |
---|
772 | set(handles.FieldMenu,'String',FieldString) |
---|
773 | FieldString={''}; |
---|
774 | if check_civ>=2 |
---|
775 | FieldString=[calc_field;{'get_field...'}]; |
---|
776 | elseif check_civ+check_netcdf>=2 |
---|
777 | FieldString={'get_field...'}; |
---|
778 | end |
---|
779 | set(handles.FieldMenu_1,'String',{'get_field...'}) |
---|
780 | % testfield=isequal(get(handles.FieldMenu,'enable'),'on'); |
---|
781 | % testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on'); |
---|
782 | % testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on'); |
---|
783 | % testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on'); |
---|
784 | % testtransform=isequal(get(handles.transform_fct,'Enable'),'on'); |
---|
785 | % testnc=0; |
---|
786 | % testnc_1=0; |
---|
787 | % testcivx=0; |
---|
788 | % testcivx_1=0; |
---|
789 | % testima=0; %test for image input |
---|
790 | % if isequal(lower(FileExt),'.avi') %.avi file |
---|
791 | % testima=1; |
---|
792 | % elseif ~isempty(imformats(FileExt(2:end))) |
---|
793 | % testima=1; |
---|
794 | % elseif isequal(FileExt,'.vol') |
---|
795 | % testima=1; |
---|
796 | % end |
---|
797 | %TODO: update |
---|
798 | % if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
799 | % for iview=1:length(FileExtCell) |
---|
800 | % if isequal(FileExtCell{iview},'.nc') |
---|
801 | % testnc=1; |
---|
802 | % end |
---|
803 | % if isequal(FileTypeCell{iview},'civx') |
---|
804 | % testcivx=1; |
---|
805 | % end |
---|
806 | % end |
---|
807 | % elseif length(FileExtCell)==2 |
---|
808 | % testnc=isequal(FileExtCell{1},'.nc'); |
---|
809 | % testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
810 | % testcivx=isequal(FileTypeCell{1},'civx'); |
---|
811 | % testcivx_1=isequal(FileTypeCell{2},'civx'); |
---|
812 | % end |
---|
813 | % switch FileType |
---|
814 | % case {'civx','civdata'} |
---|
815 | % view_FieldMenu(handles,'on') |
---|
816 | % menustr=get(handles.FieldMenu,'String'); |
---|
817 | % if isequal(menustr,{'get_field...'}) |
---|
818 | % set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
819 | % end |
---|
820 | % set(handles.VelTypeMenu,'Visible','on') |
---|
821 | % set(handles.FieldTransform,'Visible','on') |
---|
822 | % % view_TRANSFORM(handles,'on') |
---|
823 | % % TODO: second menu |
---|
824 | % % view_FieldMenu_1(handles,'on') |
---|
825 | % % if testcivx_1 |
---|
826 | % % menustr=get(handles.FieldMenu_1,'String'); |
---|
827 | % % if isequal(menustr,{'get_field...'}) |
---|
828 | % % set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
829 | % % end |
---|
830 | % % else |
---|
831 | % % set(handles.FieldMenu_1,'Value',1) |
---|
832 | % % set(handles.FieldMenu_1,'String',{'get_field...'}) |
---|
833 | % % set(handles.VelTypeMenu_1,'Visible','on') |
---|
834 | % % set(handles.VelType_text_1,'Visible','on'); |
---|
835 | % % end |
---|
836 | % % view_FieldMenu_1(handles,'off') |
---|
837 | % case 'netcdf' |
---|
838 | % view_FieldMenu(handles,'on') |
---|
839 | % set(handles.FieldMenu,'Value',1) |
---|
840 | % set(handles.FieldMenu,'String',{'get_field...'}) |
---|
841 | % set(handles.FieldTransform,'Visible','off') |
---|
842 | % % view_TRANSFORM(handles,'off') |
---|
843 | % case {'image','multimage','video'} |
---|
844 | % view_FieldMenu(handles,'off') |
---|
845 | % view_FieldMenu_1(handles,'off') |
---|
846 | % set(handles.VelTypeMenu,'Visible','off') |
---|
847 | % set(handles.VelType_text,'Visible','off'); |
---|
848 | % end |
---|
849 | |
---|
850 | |
---|
851 | |
---|
852 | %% store the series info in 'UserData' |
---|
853 | |
---|
854 | SeriesData.i1_series{iview}=i1_series; |
---|
855 | SeriesData.i2_series{iview}=i2_series; |
---|
856 | SeriesData.j1_series{iview}=j1_series; |
---|
857 | SeriesData.j2_series{iview}=j2_series; |
---|
858 | SeriesData.FileType{iview}=FileType; |
---|
859 | SeriesData.Time{iview}=time; |
---|
860 | set(handles.series,'UserData',SeriesData) |
---|
861 | |
---|
862 | |
---|
863 | |
---|
864 | return |
---|
865 | |
---|
866 | %% set default options in menu 'Fields'%% TODO: check VelType |
---|
867 | if ~testima |
---|
868 | testcivx=0; |
---|
869 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field) |
---|
870 | set(handles_Fields,'Value',1) |
---|
871 | set(handles_Fields,'String',{'get_field...'}) |
---|
872 | UvData=rmfield(UvData,'FieldsString'); |
---|
873 | else |
---|
874 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); |
---|
875 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx |
---|
876 | FieldList=calc_field; |
---|
877 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
878 | set(handles_Fields,'Value',2) % set menu to 'velocity' |
---|
879 | col_vec=FieldList; |
---|
880 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar) |
---|
881 | testcivx=1; |
---|
882 | end |
---|
883 | if ~testcivx |
---|
884 | set(handles_Fields,'Value',1) % set menu to 'get_field... |
---|
885 | set(handles_Fields,'String',{'get_field...'}) |
---|
886 | col_vec={'get_field...'}; |
---|
887 | end |
---|
888 | set(handles.ColorScalar,'String',col_vec) |
---|
889 | end |
---|
890 | end |
---|
891 | set(handles.uvmat,'UserData',UvData) |
---|
892 | |
---|
893 | %% set index navigation options and refresh plots |
---|
894 | scan_option='i';%default |
---|
895 | state_j='off'; %default |
---|
896 | if index==2 |
---|
897 | if get(handles.scan_j,'Value') |
---|
898 | scan_option='j'; %keep the scan option for the second fiel series |
---|
899 | end |
---|
900 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
901 | state_j='on'; |
---|
902 | end |
---|
903 | end |
---|
904 | if ~isempty(j1_series) |
---|
905 | state_j='on'; |
---|
906 | if isequal(nbfield,1) &&index==1 |
---|
907 | scan_option='j'; %scan j index by default if nbfield=1 |
---|
908 | end |
---|
909 | end |
---|
910 | if isequal(scan_option,'i') |
---|
911 | set(handles.scan_i,'Value',1) |
---|
912 | scan_i_Callback([],[], handles); |
---|
913 | else |
---|
914 | set(handles.scan_j,'Value',1) |
---|
915 | scan_j_Callback([],[], handles); |
---|
916 | end |
---|
917 | set(handles.scan_j,'Visible',state_j) |
---|
918 | set(handles.j1,'Visible',state_j) |
---|
919 | set(handles.j2,'Visible',state_j) |
---|
920 | set(handles.last_j,'Visible',state_j); |
---|
921 | set(handles.frame_j,'Visible',state_j); |
---|
922 | set(handles.j_text,'Visible',state_j); |
---|
923 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
924 | set(handles.CheckFixPair,'Visible','on') |
---|
925 | elseif index==1 |
---|
926 | set(handles.CheckFixPair,'Visible','off') |
---|
927 | end |
---|
928 | |
---|
929 | |
---|
930 | mode_Callback(hObject, eventdata, handles) |
---|
931 | |
---|
932 | set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
933 | InputTable=get(handles.InputTable,'Data'); |
---|
934 | check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
935 | |
---|
936 | %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
937 | for ind_list=1:length(check_lines) |
---|
938 | if check_lines(ind_list) |
---|
939 | InputLine=InputTable(ind_list,:); |
---|
940 | detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
941 | detect_idem=detect_idem(detect_idem>0); |
---|
942 | if ~isempty (detect_idem) |
---|
943 | InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
944 | set(handles.InputTable,'Data',InputTable) |
---|
945 | end |
---|
946 | fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
947 | %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
948 | %update file series defined by the selected line |
---|
949 | [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
950 | if ~isempty(errormsg) |
---|
951 | msgbox_uvmat('ERROR',errormsg) |
---|
952 | return |
---|
953 | end |
---|
954 | end |
---|
955 | end |
---|
956 | set(handles.InputTable,'Data',InputTable) |
---|
957 | SeriesData=get(handles.series,'UserData'); |
---|
958 | |
---|
959 | state_j='off'; |
---|
960 | state_Pairs='off'; |
---|
961 | state_InputFields='off'; |
---|
962 | val=get(handles.ListView,'Value'); |
---|
963 | ListViewString={''}; |
---|
964 | if ~isempty(SeriesData) |
---|
965 | % ListViewString={}; |
---|
966 | for iview=1:size(InputTable,1) |
---|
967 | if ~isempty(SeriesData.j1_series{iview}) |
---|
968 | state_j='on'; |
---|
969 | end |
---|
970 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
971 | state_Pairs='on'; |
---|
972 | ListViewString{iview}=num2str(iview); |
---|
973 | if check_lines(iview) |
---|
974 | val=iview;%select the last pair if it is a new entry |
---|
975 | end |
---|
976 | end |
---|
977 | if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
978 | state_InputFields='on'; |
---|
979 | end |
---|
980 | end |
---|
981 | end |
---|
982 | set(handles.ListView,'Value',val) |
---|
983 | set(handles.ListView,'String',ListViewString) |
---|
984 | if strcmp(state_Pairs,'on') |
---|
985 | ListView_Callback(hObject,eventdata,handles) |
---|
986 | end |
---|
987 | set(handles.PairString,'Visible',state_Pairs) |
---|
988 | enable_j(handles,state_j) |
---|
989 | |
---|
990 | |
---|
991 | %------------------------------------------------------------------------ |
---|
992 | % --- Executes when selected cell(s) is changed in PairString. |
---|
993 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
994 | %------------------------------------------------------------------------ |
---|
995 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
996 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
997 | |
---|
998 | %------------------------------------------------------------------------ |
---|
999 | %------------------------------------------------------------------------ |
---|
1000 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
1001 | %------------------------------------------------------------------------ |
---|
1002 | %------------------------------------------------------------------------ |
---|
1003 | % --- Executes on selection change in ListView. |
---|
1004 | function ListView_Callback(hObject, eventdata, handles) |
---|
1005 | %------------------------------------------------------------------------ |
---|
1006 | SeriesData=get(handles.series,'UserData'); |
---|
1007 | i2_series=[]; |
---|
1008 | j2_series=[]; |
---|
1009 | iview=get(handles.ListView,'Value'); |
---|
1010 | if ~isempty(SeriesData.i2_series{iview}) |
---|
1011 | i2_series=SeriesData.i2_series{iview}; |
---|
1012 | end |
---|
1013 | if ~isempty(SeriesData.j2_series{iview}) |
---|
1014 | j2_series=SeriesData.j2_series{iview}; |
---|
1015 | end |
---|
1016 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1017 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1018 | |
---|
1019 | %------------------------------------------------------------------------ |
---|
1020 | % --- Executes on button press in mode. |
---|
1021 | function mode_Callback(hObject, eventdata, handles) |
---|
1022 | %------------------------------------------------------------------------ |
---|
1023 | SeriesData=get(handles.series,'UserData'); |
---|
1024 | iview=get(handles.ListView,'Value'); |
---|
1025 | mode_list=get(handles.mode,'String'); |
---|
1026 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1027 | if isequal(mode,'bursts') |
---|
1028 | enable_i(handles,'On') |
---|
1029 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1030 | else |
---|
1031 | enable_i(handles,'On') |
---|
1032 | enable_j(handles,'Off') |
---|
1033 | end |
---|
1034 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1035 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1036 | ListPairs_Callback([],[],handles) |
---|
1037 | |
---|
1038 | %------------------------------------------------------------- |
---|
1039 | % --- Executes on selection in ListPairs. |
---|
1040 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
1041 | %------------------------------------------------------------ |
---|
1042 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
1043 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
1044 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
1045 | PairString=get(handles.PairString,'Data'); |
---|
1046 | iview=get(handles.ListView,'Value'); |
---|
1047 | PairString{iview,1}=string; |
---|
1048 | % report the selected pair string to the table PairString |
---|
1049 | set(handles.PairString,'Data',PairString) |
---|
1050 | |
---|
1051 | %------------------------------------------------------------------------ |
---|
1052 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
1053 | %------------------------------------------------------------------------ |
---|
1054 | mode_list=get(handles.mode,'String'); |
---|
1055 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1056 | SeriesData=get(handles.series,'UserData'); |
---|
1057 | iview=get(handles.ListView,'Value'); |
---|
1058 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1059 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.time{iview});% update the menu of pairs depending on the available netcdf files |
---|
1060 | ListPairs_Callback([],[],handles) |
---|
1061 | |
---|
1062 | %------------------------------------------------------------------------ |
---|
1063 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
1064 | %------------------------------------------------------------------------ |
---|
1065 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
1066 | |
---|
1067 | %------------------------------------------------------------------------ |
---|
1068 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1069 | %------------------------------------------------------------------------ |
---|
1070 | check_burst=1; |
---|
1071 | if isempty(j2_series)% no pair menu to display |
---|
1072 | if isempty(i2_series) |
---|
1073 | set(handles.mode,'String',{''}) |
---|
1074 | else |
---|
1075 | set(handles.mode,'Value',1) |
---|
1076 | set(handles.mode,'String',{'series(Di)'}) |
---|
1077 | end |
---|
1078 | else |
---|
1079 | nbfield=size(j2_series,1); |
---|
1080 | nbfield2=size(j2_series,2); |
---|
1081 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
1082 | if nbfield2>10 || nbfield==1 |
---|
1083 | set(handles.mode,'Value',2); |
---|
1084 | else |
---|
1085 | set(handles.mode,'Value',1); |
---|
1086 | check_burst=1; |
---|
1087 | end |
---|
1088 | end |
---|
1089 | if check_burst |
---|
1090 | enable_i(handles,'On') |
---|
1091 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1092 | else |
---|
1093 | enable_i(handles,'On') |
---|
1094 | enable_j(handles,'Off') |
---|
1095 | end |
---|
1096 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1097 | ListPairs_Callback([],[],handles) |
---|
1098 | |
---|
1099 | %-------------------------------------------------------------- |
---|
1100 | % determine the menu for civ1 pairstring depending on existing netcdf files |
---|
1101 | % with the reference indices num_ref_i and num_ref_j |
---|
1102 | %---------------------------------------------------------------- |
---|
1103 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1104 | |
---|
1105 | mode_list=get(handles.mode,'String'); |
---|
1106 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1107 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
1108 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
1109 | if isempty(ref_i) |
---|
1110 | ref_i=1; |
---|
1111 | end |
---|
1112 | if isempty(ref_j) |
---|
1113 | ref_j=1; |
---|
1114 | end |
---|
1115 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
1116 | if length(TimeUnit)>=1 |
---|
1117 | dtunit=['m' TimeUnit]; |
---|
1118 | else |
---|
1119 | dtunit='e-03'; |
---|
1120 | end |
---|
1121 | |
---|
1122 | displ_pair={}; |
---|
1123 | if strcmp(mode,'series(Di)') |
---|
1124 | if isempty(i2_series) |
---|
1125 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
1126 | return |
---|
1127 | end |
---|
1128 | diff_i=i2_series-i1_series; |
---|
1129 | min_diff=min(diff_i(diff_i>0)); |
---|
1130 | max_diff=max(diff_i(diff_i>0)); |
---|
1131 | for ipair=min_diff:max_diff |
---|
1132 | if numel(diff_i(diff_i==ipair))>0 |
---|
1133 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1134 | if ~isempty(time) |
---|
1135 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
1136 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1137 | end |
---|
1138 | displ_pair=[displ_pair;{pair_string}]; |
---|
1139 | end |
---|
1140 | end |
---|
1141 | if ~isempty(displ_pair) |
---|
1142 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
1143 | end |
---|
1144 | elseif strcmp(mode,'series(Dj)') |
---|
1145 | if isempty(j2_series) |
---|
1146 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1147 | return |
---|
1148 | end |
---|
1149 | diff_j=j2_series-j1_series; |
---|
1150 | min_diff=min(diff_j(diff_j>0)); |
---|
1151 | max_diff=max(diff_j(diff_j>0)); |
---|
1152 | for ipair=min_diff:max_diff |
---|
1153 | if numel(diff_j(diff_j==ipair))>0 |
---|
1154 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1155 | if ~isempty(time) |
---|
1156 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
1157 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1158 | end |
---|
1159 | displ_pair=[displ_pair;{pair_string}]; |
---|
1160 | end |
---|
1161 | end |
---|
1162 | if ~isempty(displ_pair) |
---|
1163 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
1164 | end |
---|
1165 | elseif strcmp(mode,'bursts') |
---|
1166 | if isempty(j2_series) |
---|
1167 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1168 | return |
---|
1169 | end |
---|
1170 | diff_j=j2_series-j1_series; |
---|
1171 | min_j1=min(j1_series(j1_series>0)); |
---|
1172 | max_j1=max(j1_series(j1_series>0)); |
---|
1173 | min_j2=min(j2_series(j2_series>0)); |
---|
1174 | max_j2=max(j2_series(j2_series>0)); |
---|
1175 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
1176 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
1177 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
1178 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
1179 | end |
---|
1180 | end |
---|
1181 | end |
---|
1182 | if ~isempty(displ_pair) |
---|
1183 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
1184 | end |
---|
1185 | end |
---|
1186 | |
---|
1187 | %% display list of pairstring |
---|
1188 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
1189 | NewVal=[]; |
---|
1190 | if ~isempty(displ_pair_list) |
---|
1191 | Val=get(handles.ListPairs,'Value'); |
---|
1192 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pï¿œir |
---|
1193 | end |
---|
1194 | if ~isempty(NewVal) |
---|
1195 | set(handles.ListPairs,'Value',NewVal) |
---|
1196 | else |
---|
1197 | set(handles.ListPairs,'Value',1) |
---|
1198 | end |
---|
1199 | set(handles.ListPairs,'String',displ_pair) |
---|
1200 | if isempty(displ_pair) |
---|
1201 | msgbox_uvmat('ERROR',['no file available for the selected subdirectory ' subdir]) |
---|
1202 | end |
---|
1203 | |
---|
1204 | |
---|
1205 | |
---|
1206 | % return |
---|
1207 | % %%%%%%%% |
---|
1208 | % %update num_first_i and num_last_i according to the chosen image pairstring |
---|
1209 | % testupdate=0; |
---|
1210 | % |
---|
1211 | % SeriesData=get(handles.series,'UserData'); |
---|
1212 | % NomType=SeriesData.NomType{Val}; |
---|
1213 | % list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
1214 | % index_pair=get(handles.ListPairs,'Value'); |
---|
1215 | % str_pair=list_pair{index_pair}; |
---|
1216 | % ind_equ=strfind(str_pair,'=');%find '=' |
---|
1217 | % ind_sep=strfind(str_pair,'|');%find pair separator '|' |
---|
1218 | % ind_com=strfind(str_pair,':');%find ':' |
---|
1219 | % test_bursts=0; |
---|
1220 | % if isempty(ind_sep) |
---|
1221 | % ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|' |
---|
1222 | % test_bursts=1;% we are in the case of bursts |
---|
1223 | % end |
---|
1224 | % displ_num=[0 0 0 0]; %default |
---|
1225 | % if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-') |
---|
1226 | % num1_str=str_pair(ind_equ(1)+1:ind_sep-1); |
---|
1227 | % num2_str=str_pair(ind_sep+1:ind_com-1); |
---|
1228 | % num1=str2double(num1_str); |
---|
1229 | % num2=str2double(num2_str); |
---|
1230 | % if isequal(num1_str(1),' ') |
---|
1231 | % num1_str(1)=[]; |
---|
1232 | % end |
---|
1233 | % if isequal(num2_str(end),' ') |
---|
1234 | % num2_str(end)=[]; |
---|
1235 | % end |
---|
1236 | % switch NomType |
---|
1237 | % case {'_1-2_1'} |
---|
1238 | % if isequal(num1_str(1),'0') |
---|
1239 | % IndexCell{Val}=['_(i-(i+' num2_str ')_j']; |
---|
1240 | % else |
---|
1241 | % IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j']; |
---|
1242 | % end |
---|
1243 | % displ_num(3)=num1; |
---|
1244 | % displ_num(4)=num2; |
---|
1245 | % case {'_1-2'} |
---|
1246 | % if isequal(num1_str(1),'0') |
---|
1247 | % IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
1248 | % else |
---|
1249 | % IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
1250 | % end |
---|
1251 | % displ_num(3)=num1; |
---|
1252 | % displ_num(4)=num2; |
---|
1253 | % case '_1_1-2' |
---|
1254 | % if test_bursts |
---|
1255 | % IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
1256 | % else |
---|
1257 | % if isequal(num1_str(1),'0') |
---|
1258 | % IndexCell{Val}=['_i_j-(j+' num2_str ')']; |
---|
1259 | % else |
---|
1260 | % IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')']; |
---|
1261 | % end |
---|
1262 | % end |
---|
1263 | % displ_num(1)=num1; |
---|
1264 | % displ_num(2)=num2; |
---|
1265 | % case {'#_ab'} %TO COMPLETE |
---|
1266 | % IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
1267 | % |
---|
1268 | % end |
---|
1269 | % end |
---|
1270 | % set(handles.NomType,'String',IndexCell) |
---|
1271 | % SeriesData.displ_num(Val,:)=displ_num; |
---|
1272 | % set(handles.series,'UserData',SeriesData) |
---|
1273 | % % set(handles.NomType,'Value',Val) |
---|
1274 | % |
---|
1275 | % if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*') |
---|
1276 | % mode_list=get(handles.mode,'String'); |
---|
1277 | % mode_value=get(handles.mode,'Value'); |
---|
1278 | % mode=mode_list{mode_value}; |
---|
1279 | % if isequal(mode,'series(Di)') |
---|
1280 | % first_i=str2num(get(handles.num_first_i,'String')); |
---|
1281 | % last_i=str2num(get(handles.num_last_i,'String')); |
---|
1282 | % incr_i=str2num(get(handles.num_incr_i,'String')); |
---|
1283 | % num1=first_i:incr_i:last_i; |
---|
1284 | % lastfieldCell=get(handles.num_MaxIndex_i,'String'); |
---|
1285 | % lastfield=str2num(lastfieldCell{1}); |
---|
1286 | % if ~isempty(lastfield) |
---|
1287 | % ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
1288 | % num1=num1(ind); |
---|
1289 | % end |
---|
1290 | % if ~isempty(num1) |
---|
1291 | % set(handles.num_first_i,'String',num2str(num1(1))); |
---|
1292 | % set(handles.num_last_i,'String',num2str(num1(end))); |
---|
1293 | % end |
---|
1294 | % testupdate=1; |
---|
1295 | % elseif isequal(mode,'series(Dj)') |
---|
1296 | % first_j=str2num(get(handles.num_first_j,'String')); |
---|
1297 | % last_j=str2num(get(handles.num_last_j,'String')); |
---|
1298 | % incr_j=str2num(get(handles.num_incr_j,'String')); |
---|
1299 | % num_j=first_j:incr_j:last_j; |
---|
1300 | % lastfieldCell=get(handles.num_MaxIndex_j,'String'); |
---|
1301 | % if ~isempty(lastfieldCell) |
---|
1302 | % lastfield2=lastfieldCell{1}; |
---|
1303 | % ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1304 | % (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
1305 | % end |
---|
1306 | % testupdate=1; |
---|
1307 | % end |
---|
1308 | % |
---|
1309 | % %update the first and last times of the series |
---|
1310 | % if testupdate && isfield(SeriesData,'Time') |
---|
1311 | % if ~isempty(SeriesData.Time{1}) |
---|
1312 | % displ_time(handles); |
---|
1313 | % end |
---|
1314 | % end |
---|
1315 | % end |
---|
1316 | |
---|
1317 | %------------------------------------- |
---|
1318 | function enable_i(handles,state) |
---|
1319 | set(handles.i_txt,'Visible',state) |
---|
1320 | set(handles.num_first_i,'Visible',state) |
---|
1321 | set(handles.num_last_i,'Visible',state) |
---|
1322 | set(handles.num_incr_i,'Visible',state) |
---|
1323 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
1324 | set(handles.num_ref_i,'Visible',state) |
---|
1325 | set(handles.ref_i_text,'Visible',state) |
---|
1326 | |
---|
1327 | %----------------------------------- |
---|
1328 | function enable_j(handles,state) |
---|
1329 | set(handles.j_txt,'Visible',state) |
---|
1330 | % set(handles.num_MinIndex_j,'Visible',state) |
---|
1331 | set(handles.num_first_j,'Visible',state) |
---|
1332 | set(handles.num_last_j,'Visible',state) |
---|
1333 | set(handles.num_incr_j,'Visible',state) |
---|
1334 | % set(handles.num_MaxIndex_j,'Visible',state) |
---|
1335 | set(handles.num_ref_j,'Visible',state) |
---|
1336 | set(handles.ref_j_text,'Visible',state) |
---|
1337 | |
---|
1338 | %----------------------------------- |
---|
1339 | function view_FieldMenu(handles,state) |
---|
1340 | % set(handles.FieldMenu,'Visible',state) |
---|
1341 | % set(handles.Field_text,'Visible',state) |
---|
1342 | set(handles.InputFields,'Visible',state) |
---|
1343 | |
---|
1344 | %----------------------------------- |
---|
1345 | function view_FieldMenu_1(handles,state) |
---|
1346 | set(handles.FieldMenu_1,'Visible',state) |
---|
1347 | set(handles.Field_text_1,'Visible',state) |
---|
1348 | |
---|
1349 | % %----------------------------------- |
---|
1350 | % function view_TRANSFORM(handles,state) |
---|
1351 | % set(handles.TRANSFORM_frame,'Visible',state) |
---|
1352 | % set(handles.transform_fct,'Visible',state); |
---|
1353 | % set(handles.TRANSFORM_title,'Visible',state) |
---|
1354 | |
---|
1355 | |
---|
1356 | %list_pair_civ_Callback([],[],handles) |
---|
1357 | |
---|
1358 | |
---|
1359 | |
---|
1360 | %------------------------------------------------------------------------ |
---|
1361 | % --- Executes on button press in RUN. |
---|
1362 | function RUN_Callback(hObject, eventdata, handles) |
---|
1363 | %------------------------------------------------------------------------ |
---|
1364 | %% Read parameters from series |
---|
1365 | Series=read_GUI(handles.series);%TODO: extend to all input param |
---|
1366 | Series.hseries=handles.series; % handles to the series GUI |
---|
1367 | |
---|
1368 | %% read root name and field type |
---|
1369 | set(handles.RUN,'BusyAction','queue'); |
---|
1370 | set(0,'CurrentFigure',handles.series) |
---|
1371 | if isequal(get(handles.GetObject,'Visible'),'on') && isequal(get(handles.GetObject,'Value'),1) |
---|
1372 | Series.GetObject=1; |
---|
1373 | GetObject_Callback(hObject, eventdata, handles) |
---|
1374 | else |
---|
1375 | Series.GetObject=0; |
---|
1376 | end |
---|
1377 | % SeriesData=get(handles.series,'UserData'); |
---|
1378 | |
---|
1379 | % Series.hseries=handles.series; % handles to the series GUI |
---|
1380 | first_i=1; |
---|
1381 | last_i=1; |
---|
1382 | incr_i=1; |
---|
1383 | first_j=1; |
---|
1384 | last_j=1; |
---|
1385 | incr_j=1; |
---|
1386 | if isfield(Series.IndexRange,'first_i') |
---|
1387 | first_i=Series.IndexRange.first_i; |
---|
1388 | incr_i=Series.IndexRange.incr_i; |
---|
1389 | last_i=Series.IndexRange.last_i; |
---|
1390 | end |
---|
1391 | if isfield(Series.IndexRange,'first_j') |
---|
1392 | first_j=Series.IndexRange.first_j; |
---|
1393 | incr_j=Series.IndexRange.incr_j; |
---|
1394 | last_j=Series.IndexRange.last_j; |
---|
1395 | end |
---|
1396 | |
---|
1397 | %% read input file parameters and set menus |
---|
1398 | Series.PathProject=get(handles.PathCampaign,'String'); |
---|
1399 | % InputTable=get(handles.InputTable,'Data'); |
---|
1400 | % RootPath=Series.InputTable(:,1); |
---|
1401 | % SubDir=Series.InputTable(:,2); |
---|
1402 | % RootFile=Series.InputTable(:,3); |
---|
1403 | % NomType=Series.InputTable(:,4); |
---|
1404 | % FileExt=Series.InputTable(:,5); |
---|
1405 | % if isempty(SeriesData) |
---|
1406 | % msgbox_uvmat('ERROR','no input file series') |
---|
1407 | % return |
---|
1408 | % end |
---|
1409 | % NomType=SeriesData.NomType; |
---|
1410 | % if length(RootPath)==1 %string character input for user fct |
---|
1411 | % Series.RootPath=RootPath{1}; |
---|
1412 | % Series.RootFile=RootFile{1}; |
---|
1413 | % Series.SubDir=SubDir{1}; |
---|
1414 | % Series.FileExt=FileExt{1}; |
---|
1415 | % Series.NomType=NomType{1}; |
---|
1416 | % else %cell input for user fct |
---|
1417 | % Series.RootPath=RootPath; |
---|
1418 | % Series.RootFile=RootFile; |
---|
1419 | % Series.SubDir=SubDir; |
---|
1420 | % Series.FileExt=FileExt; |
---|
1421 | % Series.NomType=NomType; |
---|
1422 | % end |
---|
1423 | % if isequal(get(handles.FieldMenu,'Visible'),'on') |
---|
1424 | % FieldMenu=get(handles.FieldMenu,'String'); |
---|
1425 | % FieldValue=get(handles.FieldMenu,'Value'); |
---|
1426 | % Series.Field=FieldMenu(FieldValue); |
---|
1427 | % end |
---|
1428 | menu_coord_state=get(handles.transform_fct,'Visible'); |
---|
1429 | Series.CoordType='';%default |
---|
1430 | if isequal(menu_coord_state,'on') |
---|
1431 | % menu_coord=get(handles.transform_fct,'String'); |
---|
1432 | menu_index=get(handles.transform_fct,'Value'); |
---|
1433 | transform_list=get(handles.transform_fct,'UserData'); |
---|
1434 | Series.FieldTransform.fct_handle=transform_list{menu_index};% transform function handles |
---|
1435 | end |
---|
1436 | |
---|
1437 | %reinitiate waitbar position |
---|
1438 | Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS |
---|
1439 | waitbarpos=Series.WaitbarPos; |
---|
1440 | waitbarpos(4)=0.005;%reinitialize waitbar to zero height |
---|
1441 | waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005; |
---|
1442 | % set(handles.waitbar,'Position',waitbarpos) |
---|
1443 | |
---|
1444 | if isfield(Series.IndexRange,'NbSlice') |
---|
1445 | Series.NbSlice=Series.IndexRange.NbSlice; |
---|
1446 | end |
---|
1447 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
1448 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1449 | num_i=first_i:incr_i:last_i; |
---|
1450 | num_j=first_j:incr_j:last_j; |
---|
1451 | % nbfield_cell=get(handles.num_MaxIndex_i,'String'); |
---|
1452 | nbfield=cell2mat(Series.IndexRange.MaxIndex); |
---|
1453 | nb=min(nbfield,1); |
---|
1454 | % nbfield=nb(1); |
---|
1455 | % nbfield2=nb(2); |
---|
1456 | |
---|
1457 | %get complementary information from the 'series' interface |
---|
1458 | list_action=get(handles.ACTION,'String');% list menu action |
---|
1459 | index_action=get(handles.ACTION,'Value');% selected string index |
---|
1460 | action= list_action{index_action}; % selected string |
---|
1461 | mode_list=get(handles.mode,'String'); |
---|
1462 | index_mode=get(handles.mode,'Value'); |
---|
1463 | mode=mode_list{index_mode}; |
---|
1464 | ind_shift=0;%default |
---|
1465 | |
---|
1466 | |
---|
1467 | %% defining the ACTION function handle |
---|
1468 | path_series=which('series'); |
---|
1469 | list_path=get(handles.ACTION,'UserData'); |
---|
1470 | index=get(handles.ACTION,'Value'); |
---|
1471 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
1472 | if ~isequal(fct_path,path_series) |
---|
1473 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
1474 | if ~exist(fct_path,'dir') |
---|
1475 | msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist']) |
---|
1476 | return |
---|
1477 | end |
---|
1478 | if ~isequal(spath,fct_path) |
---|
1479 | addpath(fct_path)% add the prescribed path if not the current one |
---|
1480 | end |
---|
1481 | end |
---|
1482 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
1483 | if ~isequal(fct_path,path_series) |
---|
1484 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
1485 | end |
---|
1486 | |
---|
1487 | %% RUN ACTION |
---|
1488 | Series.Action=action;%name of the processing programme |
---|
1489 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1490 | h_fun(Series); |
---|
1491 | % if length(RootPath)>1 |
---|
1492 | % h_fun(i1_series_cell,i2_series_cell,j1_series_cell,j2_series_cell,Series); |
---|
1493 | % else |
---|
1494 | % h_fun(i1_series,i2_series,j1_series,j2_series,Series); |
---|
1495 | % end |
---|
1496 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1497 | |
---|
1498 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
1499 | % detect=1; |
---|
1500 | % while detect==1 |
---|
1501 | % namefigfull=[namedoc '.fig']; |
---|
1502 | % hh=dir(namefigfull); |
---|
1503 | % if ~isempty(hh) |
---|
1504 | % detect=1; |
---|
1505 | % namedoc=[namedoc '.0']; |
---|
1506 | % else |
---|
1507 | % detect=0; |
---|
1508 | % end |
---|
1509 | % end |
---|
1510 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
1511 | |
---|
1512 | %------------------------------------------------------------------------ |
---|
1513 | function STOP_Callback(hObject, eventdata, handles) |
---|
1514 | %------------------------------------------------------------------------ |
---|
1515 | set(handles.RUN, 'BusyAction','cancel') |
---|
1516 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1517 | |
---|
1518 | |
---|
1519 | %------------------------------------------------------------------------ |
---|
1520 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
1521 | %------------------------------------------------------------------------ |
---|
1522 | num_last_i_Callback(hObject, eventdata, handles) |
---|
1523 | |
---|
1524 | %------------------------------------------------------------------------ |
---|
1525 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
1526 | %------------------------------------------------------------------------ |
---|
1527 | SeriesData=get(handles.series,'UserData'); |
---|
1528 | if ~isfield(SeriesData,'Time') |
---|
1529 | SeriesData.Time{1}=[]; |
---|
1530 | end |
---|
1531 | displ_time(handles); |
---|
1532 | |
---|
1533 | %------------------------------------------------------------------------ |
---|
1534 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
1535 | %------------------------------------------------------------------------ |
---|
1536 | num_last_j_Callback(hObject, eventdata, handles) |
---|
1537 | |
---|
1538 | %------------------------------------------------------------------------ |
---|
1539 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
1540 | %------------------------------------------------------------------------ |
---|
1541 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
1542 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
1543 | ref_j=ceil((first_j+last_j)/2); |
---|
1544 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
1545 | ref_j_Callback(hObject, eventdata, handles) |
---|
1546 | SeriesData=get(handles.series,'UserData'); |
---|
1547 | if ~isfield(SeriesData,'Time') |
---|
1548 | SeriesData.Time{1}=[]; |
---|
1549 | end |
---|
1550 | displ_time(handles); |
---|
1551 | |
---|
1552 | |
---|
1553 | % NomTypeCell=SeriesData.NomType; |
---|
1554 | % if ~isempty(NomTypeCell) |
---|
1555 | % Val=get(handles.NomType,'Value'); |
---|
1556 | % NomType=NomTypeCell{Val}; |
---|
1557 | % if isequal(NomType,'_1_1-2')|| isequal(NomType,'_1-2_1')|| isequal(NomType,'_1-2') |
---|
1558 | % if isequal(mode,'series(Dj)') |
---|
1559 | % fill_ListPair(handles,Val);% update the menu of pairstring depending on the available netcdf files |
---|
1560 | % end |
---|
1561 | % end |
---|
1562 | % end |
---|
1563 | %------------------------------------------------------------------------ |
---|
1564 | % ---- find the times corresponding to the first and last indices of a series |
---|
1565 | function displ_time(handles) |
---|
1566 | %------------------------------------------------------------------------ |
---|
1567 | SeriesData=get(handles.series,'UserData');% |
---|
1568 | ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; |
---|
1569 | ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; |
---|
1570 | % last_i=str2num(get(handles.num_last_i,'String')); |
---|
1571 | % last_j=str2num(get(handles.num_last_j,'String')); |
---|
1572 | TimeTable=get(handles.TimeTable,'Data'); |
---|
1573 | Pairs=get(handles.PairString,'Data'); |
---|
1574 | for iview=1:size(TimeTable,1) |
---|
1575 | if size(SeriesData.Time,1)<iview |
---|
1576 | break |
---|
1577 | end |
---|
1578 | i1=ref_i; |
---|
1579 | j1=ref_j; |
---|
1580 | i2=ref_i; |
---|
1581 | j2=ref_j; |
---|
1582 | % case of pairs |
---|
1583 | if ~isempty(Pairs{iview,1}) |
---|
1584 | r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
1585 | if isempty(r) |
---|
1586 | r=regexp(Pairs.list_pair_civ,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
1587 | end |
---|
1588 | switch r.mode |
---|
1589 | case 'Di=' % case 'series(Di)') |
---|
1590 | i1=ref_i-str2num(r.num1); |
---|
1591 | i2=ref_i+str2num(r.num2); |
---|
1592 | case 'Dj=' % case 'series(Dj)' |
---|
1593 | j1=ref_j-str2num(r.num1); |
---|
1594 | j2=ref_j+str2num(r.num2); |
---|
1595 | case '-' % case 'bursts' |
---|
1596 | j1=str2num(r.num1)*ones(size(ref_i)); |
---|
1597 | j2=str2num(r.num2)*ones(size(ref_i)); |
---|
1598 | end |
---|
1599 | end |
---|
1600 | TimeTable{iview,2}=[]; |
---|
1601 | TimeTable{iview,3}=[]; |
---|
1602 | if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) |
---|
1603 | if isempty(ref_j) |
---|
1604 | time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2; |
---|
1605 | time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2; |
---|
1606 | else |
---|
1607 | time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2; |
---|
1608 | time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2; |
---|
1609 | end |
---|
1610 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
1611 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
1612 | end |
---|
1613 | end |
---|
1614 | set(handles.TimeTable,'Data',TimeTable) |
---|
1615 | |
---|
1616 | |
---|
1617 | % |
---|
1618 | % NomType=InputTable(:,4); |
---|
1619 | % mode_list=get(handles.mode,'String'); |
---|
1620 | % index_mode=get(handles.mode,'Value'); |
---|
1621 | % |
---|
1622 | % mode=mode_list{index_mode}; |
---|
1623 | % |
---|
1624 | % time_first=[]; |
---|
1625 | % time_last=[]; |
---|
1626 | % if ~isfield(SeriesData,'Time') |
---|
1627 | % SeriesData.Time{1}=[]; |
---|
1628 | % end |
---|
1629 | % TimeTable=get(handles.TimeTable,'Data'); |
---|
1630 | % for iview=1:size(TimeTable,1) |
---|
1631 | % time_first_cell{iview}='?'; |
---|
1632 | % time_last_cell{iview}='?';%default |
---|
1633 | % time=SeriesData.Time{iview}; |
---|
1634 | % if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2') |
---|
1635 | % if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num) |
---|
1636 | % ind_shift=SeriesData.displ_num(iview,:); |
---|
1637 | % if isequal(mode,'bursts') |
---|
1638 | % first_j=0; |
---|
1639 | % last_j=0; |
---|
1640 | % end |
---|
1641 | % first_i1=first_i +ind_shift(3); |
---|
1642 | % first_i2 =first_i +ind_shift(4); |
---|
1643 | % first_j1 =first_j +ind_shift(1); |
---|
1644 | % first_j2 =first_j +ind_shift(2); |
---|
1645 | % last_i1=last_i +ind_shift(3); |
---|
1646 | % last_i2 =last_i +ind_shift(4); |
---|
1647 | % last_j1 =last_j +ind_shift(1); |
---|
1648 | % last_j2 =last_j +ind_shift(2); |
---|
1649 | % siz=size(SeriesData.Time{1}); |
---|
1650 | % if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2 |
---|
1651 | % time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2; |
---|
1652 | % time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2; |
---|
1653 | % else%read the time in the nc files |
---|
1654 | % RootPath=get(handles.RootPath,'String'); |
---|
1655 | % RootFile=get(handles.RootFile,'String'); |
---|
1656 | % SubDir=get(handles.SubDir,'String'); |
---|
1657 | % %VelType=get(handles.VelType,'String'); |
---|
1658 | % VelType_str=get(handles.VelTypeMenu,'String'); |
---|
1659 | % VelType_val=get(handles.VelTypeMenu,'Value'); |
---|
1660 | % VelType=VelType_str{VelType_val}; |
---|
1661 | % filebase=fullfile(RootPath{1},RootFile{1}); |
---|
1662 | % [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview}); |
---|
1663 | % if exist(filefirst,'file') |
---|
1664 | % Attrib=nc2struct(filefirst,[]); |
---|
1665 | % if isfield(Attrib,'Time') |
---|
1666 | % time_first=Attrib.Time; |
---|
1667 | % else |
---|
1668 | % if isfield(Attrib,'absolut_time_T0') |
---|
1669 | % time_first=Attrib.absolut_time_T0; |
---|
1670 | % end |
---|
1671 | % if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
1672 | % time_first=Attrib.absolut_time_T0_2; |
---|
1673 | % end |
---|
1674 | % end |
---|
1675 | % end |
---|
1676 | % [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview}); |
---|
1677 | % if exist(filelast,'file') |
---|
1678 | % Attrib=nc2struct(filelast,[]); |
---|
1679 | % if isfield(Attrib,'Time') |
---|
1680 | % time_last=Attrib.Time; |
---|
1681 | % else |
---|
1682 | % if isfield(Attrib,'absolut_time_T0') |
---|
1683 | % time_last=Attrib.absolut_time_T0; |
---|
1684 | % end |
---|
1685 | % if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
1686 | % time_last=Attrib.absolut_time_T0_2; |
---|
1687 | % end |
---|
1688 | % end |
---|
1689 | % end |
---|
1690 | % end |
---|
1691 | % end |
---|
1692 | % else |
---|
1693 | % siz=size(time); |
---|
1694 | % if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1 |
---|
1695 | % time_first=times(first_i,first_j); |
---|
1696 | % time_last=times(last_i,last_j); |
---|
1697 | % end |
---|
1698 | % end |
---|
1699 | % time_first_cell{iview}=num2str(time_first,4); |
---|
1700 | % time_last_cell{iview}=num2str(time_last,4); |
---|
1701 | % end |
---|
1702 | % |
---|
1703 | |
---|
1704 | %------------------------------------------------------------------------ |
---|
1705 | % --- Executes on selection change in ACTION. |
---|
1706 | function ACTION_Callback(hObject, eventdata, handles) |
---|
1707 | %------------------------------------------------------------------------ |
---|
1708 | global nb_builtin_ACTION |
---|
1709 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
1710 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
1711 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
1712 | path_series=which('series');%path to series.m |
---|
1713 | list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION |
---|
1714 | default_file=fullfile(list_path{end},ACTION); |
---|
1715 | % add a new function to the menu if the selected item is 'more...' |
---|
1716 | if isequal(ACTION,'more...') |
---|
1717 | pathfct=fileparts(path_series); |
---|
1718 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1719 | {'*.m', ' (*.m)'; |
---|
1720 | '*.m', '.m files '; ... |
---|
1721 | '*.*', 'All Files (*.*)'}, ... |
---|
1722 | 'Pick a file',default_file); |
---|
1723 | if length(FileName)<2 |
---|
1724 | return |
---|
1725 | end |
---|
1726 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
1727 | if ~isequal(ext_fct,'.m') |
---|
1728 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1729 | return |
---|
1730 | end |
---|
1731 | |
---|
1732 | % insert the choice in the action menu |
---|
1733 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
1734 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
1735 | list_path{index_ACTION}=PathName; |
---|
1736 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1737 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
1738 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
1739 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
1740 | index_ACTION=index_ACTION-nbremove; |
---|
1741 | set(handles.ACTION,'Value',index_ACTION) |
---|
1742 | set(handles.ACTION,'String',menu_str) |
---|
1743 | end |
---|
1744 | list_path{index_ACTION}=PathName; |
---|
1745 | set(handles.ACTION,'UserData',list_path); |
---|
1746 | set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
1747 | |
---|
1748 | %record the current menu in personal file profil_perso |
---|
1749 | dir_perso=prefdir; |
---|
1750 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1751 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
1752 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
1753 | end |
---|
1754 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
1755 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
1756 | save(profil_perso,'series_fct','-append') |
---|
1757 | else |
---|
1758 | txt=ver('MATLAB'); |
---|
1759 | Release=txt.Release; |
---|
1760 | relnumb=str2num(Release(3:4)); |
---|
1761 | if relnumb >= 14%recent relaese of Matlab |
---|
1762 | save(profil_perso,'series_fct','-V6') |
---|
1763 | else |
---|
1764 | save(profil_perso, 'series_fct') |
---|
1765 | end |
---|
1766 | end |
---|
1767 | end |
---|
1768 | end |
---|
1769 | |
---|
1770 | %check the current path to the selected function |
---|
1771 | PathName=list_path{index_ACTION};%current recorded path |
---|
1772 | set(handles.path,'String',PathName); %show the path to the senlected function |
---|
1773 | |
---|
1774 | %default setting for the visibility of the GUI elements |
---|
1775 | % set(handles.RootPath,'UserData','many') |
---|
1776 | % set(handles.SubDir,'Visible','on') |
---|
1777 | % set(handles.RootFile,'Visible','on') |
---|
1778 | % set(handles.NomType,'Visible','on') |
---|
1779 | % set(handles.FileExt,'Visible','on') |
---|
1780 | set(handles.num_NbSlice,'Visible','off') |
---|
1781 | set(handles.NbSlice_title,'Visible','off') |
---|
1782 | set(handles.VelTypeMenu,'Visible','off'); |
---|
1783 | set(handles.VelType_text,'Visible','off'); |
---|
1784 | set(handles.VelTypeMenu_1,'Visible','off'); |
---|
1785 | set(handles.VelType_text_1,'Visible','off'); |
---|
1786 | view_FieldMenu(handles,'off') |
---|
1787 | view_FieldMenu_1(handles,'off') |
---|
1788 | set(handles.FieldTransform,'Visible','off') |
---|
1789 | % view_TRANSFORM(handles,'off')Visible','off') |
---|
1790 | set(handles.Objects,'Visible','off'); |
---|
1791 | set(handles.GetMask,'Visible','off') |
---|
1792 | set(handles.Mask,'Visible','off') |
---|
1793 | % set(handles.GetObject,'Visible','off'); |
---|
1794 | set(handles.OutputDir,'Visible','off'); |
---|
1795 | % set(handles.PARAMETERS_frame,'Visible','off'); |
---|
1796 | % set(handles.PARAMETERS_title,'Visible','off'); |
---|
1797 | set(handles.ParamKey,'Visible','off') |
---|
1798 | set(handles.ParamVal,'Visible','off') |
---|
1799 | ParamKey={}; |
---|
1800 | set(handles.FieldMenu,'Enable','off') |
---|
1801 | set(handles.VelTypeMenu,'Enable','off') |
---|
1802 | set(handles.FieldMenu_1,'Enable','off') |
---|
1803 | set(handles.VelTypeMenu_1,'Enable','off') |
---|
1804 | set(handles.transform_fct,'Enable','off') |
---|
1805 | %set the displayed GUI item needed for input parameters |
---|
1806 | if ~isequal(path_series,PathName) |
---|
1807 | addpath(PathName) |
---|
1808 | end |
---|
1809 | eval(['h_function=@' ACTION ';']); |
---|
1810 | try |
---|
1811 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
1812 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
1813 | fclose(fid) |
---|
1814 | set(handles.ACTION,'ToolTipString',InputText{1}{1}) |
---|
1815 | end |
---|
1816 | if ~isequal(path_series,PathName) |
---|
1817 | rmpath(PathName) |
---|
1818 | end |
---|
1819 | varargout=h_function(); |
---|
1820 | Param_list={}; |
---|
1821 | |
---|
1822 | %nb_series=length(RootFile); |
---|
1823 | % FileExt=get(handles.FileExt,'String'); |
---|
1824 | % nb_series=length(FileExt); |
---|
1825 | InputTable=get(handles.InputTable,'Data'); |
---|
1826 | nb_series=size(InputTable,1); |
---|
1827 | % if ~isempty(checkcell) |
---|
1828 | % nb_series=checkcell(end); |
---|
1829 | % end |
---|
1830 | % nb_series=size(InputFiles,1) |
---|
1831 | testima_series=1; %test for a list of images only |
---|
1832 | testima=1; |
---|
1833 | testima_1=1; |
---|
1834 | testciv_series=1; |
---|
1835 | for iview=1:nb_series |
---|
1836 | ext=InputTable{iview,5}; |
---|
1837 | if length(ext)<2 |
---|
1838 | ext='.none'; |
---|
1839 | end |
---|
1840 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
1841 | if ~testimaview |
---|
1842 | if iview==1 |
---|
1843 | testima=0; |
---|
1844 | end |
---|
1845 | if iview==2 |
---|
1846 | testima_1=0; |
---|
1847 | end |
---|
1848 | testima_series=0; |
---|
1849 | end |
---|
1850 | end |
---|
1851 | for ilist=1:length(varargout)-1 |
---|
1852 | switch varargout{ilist} |
---|
1853 | |
---|
1854 | %RootFile always visible |
---|
1855 | % case 'RootPath' %visible by default |
---|
1856 | % value=lower(varargout{ilist+1}); |
---|
1857 | % if isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
1858 | % set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
1859 | % end |
---|
1860 | % case 'SubDir' %visible by default |
---|
1861 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
1862 | % set(handles.SubDir,'Visible','off') |
---|
1863 | % end |
---|
1864 | % case 'RootFile' %visible by default |
---|
1865 | % value=lower(varargout{ilist+1}); |
---|
1866 | % if isequal(value,'off') |
---|
1867 | % set(handles.RootFile,'Visible','off') |
---|
1868 | % elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
1869 | % set(handles.RootFile,'Visible','on') |
---|
1870 | % set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
1871 | % end |
---|
1872 | % case 'NomType' %visible by default |
---|
1873 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
1874 | % set(handles.NomType,'Visible','off') |
---|
1875 | % end |
---|
1876 | % case 'FileExt' %visible by default |
---|
1877 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
1878 | % set(handles.FileExt,'Visible','off') |
---|
1879 | % end |
---|
1880 | case 'NbSlice' %hidden by default |
---|
1881 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1882 | set(handles.num_NbSlice,'Visible','on') |
---|
1883 | set(handles.NbSlice_title,'Visible','on') |
---|
1884 | end |
---|
1885 | case 'VelTypeMenu' %hidden by default |
---|
1886 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
1887 | set(handles.VelTypeMenu,'Enable','on') |
---|
1888 | if nb_series >=1 && ~testima_series |
---|
1889 | set(handles.VelTypeMenu,'Visible','on') |
---|
1890 | set(handles.VelType_text,'Visible','on'); |
---|
1891 | % set(handles.Field_frame,'Visible','on') |
---|
1892 | end |
---|
1893 | end |
---|
1894 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1895 | set(handles.VelTypeMenu_1,'Enable','on') |
---|
1896 | if nb_series >=2 && ~testima_series |
---|
1897 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
1898 | set(handles.VelType_text_1,'Visible','on'); |
---|
1899 | end |
---|
1900 | end |
---|
1901 | case 'FieldMenu' %hidden by default |
---|
1902 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
1903 | set(handles.FieldMenu,'Enable','on') % test for MenuBorser |
---|
1904 | if nb_series >=1 && ~testima_series |
---|
1905 | view_FieldMenu(handles,'on') |
---|
1906 | end |
---|
1907 | end |
---|
1908 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1909 | set(handles.FieldMenu_1,'Enable','on') |
---|
1910 | if nb_series >=2 && ~testima_1 |
---|
1911 | view_FieldMenu_1(handles,'on') |
---|
1912 | end |
---|
1913 | end |
---|
1914 | case 'CoordType' %hidden by default |
---|
1915 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1916 | set(handles.transform_fct,'Enable','on') |
---|
1917 | set(handles.FieldTransform,'Visible','on') |
---|
1918 | % view_TRANSFORM(handles,'on') |
---|
1919 | end |
---|
1920 | case 'GetObject' %hidden by default |
---|
1921 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1922 | set(handles.Objects,'Visible','on') |
---|
1923 | % set(handles.GetObject,'Visible','on'); |
---|
1924 | end |
---|
1925 | case 'Mask' %hidden by default |
---|
1926 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1927 | set(handles.Objects,'Visible','on') |
---|
1928 | % set(handles.GetMask,'Visible','on'); |
---|
1929 | end |
---|
1930 | case 'PARAMETER' |
---|
1931 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
1932 | set(handles.PARAMETERS_title,'Visible','on') |
---|
1933 | set(handles.ParamKey,'Visible','on') |
---|
1934 | %set(handles.ParamVal,'Visible','on') |
---|
1935 | Param_str=varargout{ilist+1}; |
---|
1936 | Param_list=[Param_list; {Param_str}]; |
---|
1937 | end |
---|
1938 | end |
---|
1939 | if ~isempty(Param_list) |
---|
1940 | set(handles.ParamKey,'String',Param_list) |
---|
1941 | set(handles.ParamVal,'Visible','on') |
---|
1942 | end |
---|
1943 | |
---|
1944 | %------------------------------------------------------------------------ |
---|
1945 | % --- Executes on selection change in FieldMenu. |
---|
1946 | function FieldMenu_Callback(hObject, eventdata, handles) |
---|
1947 | %------------------------------------------------------------------------ |
---|
1948 | field_str=get(handles.FieldMenu,'String'); |
---|
1949 | field_index=get(handles.FieldMenu,'Value'); |
---|
1950 | field=field_str{field_index(1)}; |
---|
1951 | if isequal(field,'get_field...') |
---|
1952 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1953 | if ~isempty(hget_field) |
---|
1954 | delete(hget_field)%delete opened versions of get_field |
---|
1955 | end |
---|
1956 | SeriesData=get(handles.series,'UserData'); |
---|
1957 | filename=SeriesData.CurrentInputFile; |
---|
1958 | if exist(filename,'file') |
---|
1959 | get_field(filename) |
---|
1960 | end |
---|
1961 | elseif isequal(field,'more...') |
---|
1962 | str=calc_field; |
---|
1963 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1964 | 'SelectionMode','single',... |
---|
1965 | 'ListString',str); |
---|
1966 | % edit the choice in the fields and action menu |
---|
1967 | scalar=cell2mat(str(ind_answer)); |
---|
1968 | update_menu(handles.FieldMenu,scalar) |
---|
1969 | end |
---|
1970 | |
---|
1971 | %------------------------------------------------------------------------ |
---|
1972 | % --- Executes on selection change in FieldMenu_1. |
---|
1973 | function FieldMenu_1_Callback(hObject, eventdata, handles) |
---|
1974 | %------------------------------------------------------------------------ |
---|
1975 | field_str=get(handles.FieldMenu_1,'String'); |
---|
1976 | field_index=get(handles.FieldMenu_1,'Value'); |
---|
1977 | field=field_str{field_index}; |
---|
1978 | if isequal(field,'get_field...') |
---|
1979 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
1980 | if ~isempty(hget_field) |
---|
1981 | delete(hget_field) |
---|
1982 | end |
---|
1983 | SeriesData=get(handles.series,'UserData'); |
---|
1984 | filename=SeriesData.CurrentInputFile_1; |
---|
1985 | if exist(filename,'file') |
---|
1986 | hget_field=get_field(filename); |
---|
1987 | set(hget_field,'name','get_field_1') |
---|
1988 | end |
---|
1989 | elseif isequal(field,'more...') |
---|
1990 | str=calc_field; |
---|
1991 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1992 | 'SelectionMode','single',... |
---|
1993 | 'ListString',str); |
---|
1994 | % edit the choice in the fields and action menu |
---|
1995 | scalar=cell2mat(str(ind_answer)); |
---|
1996 | update_menu(handles.FieldMenu_1,scalar) |
---|
1997 | end |
---|
1998 | |
---|
1999 | |
---|
2000 | %%%%%%%%%%%%% |
---|
2001 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
2002 | indsel=ind_i; |
---|
2003 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
2004 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
2005 | if ~isempty(indiff) |
---|
2006 | indiff2=diff(indiff); |
---|
2007 | indiffp=[indiff2 1]; |
---|
2008 | indiffm=[1 indiff2]; |
---|
2009 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
2010 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
2011 | %for each multiplet, select the most recent file |
---|
2012 | ind_remove=[]; |
---|
2013 | for i=1:length(ind_multi_m) |
---|
2014 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
2015 | for imulti=1:length(ind_pairs) |
---|
2016 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
2017 | end |
---|
2018 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
2019 | ind_s=indsort2(1:end-1);% |
---|
2020 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
2021 | end |
---|
2022 | end |
---|
2023 | |
---|
2024 | %------------------------------------------------------------------------ |
---|
2025 | % --- determine the list of index pairstring of processing file |
---|
2026 | function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode) |
---|
2027 | %------------------------------------------------------------------------ |
---|
2028 | num_i1=num_i;% set of first image numbers by default |
---|
2029 | num_i2=num_i; |
---|
2030 | num_j1=num_j; |
---|
2031 | num_j2=num_j; |
---|
2032 | num_i_out=num_i; |
---|
2033 | num_j_out=num_j; |
---|
2034 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
2035 | if isequal(mode,'series(Di)') |
---|
2036 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
2037 | num_i2_line=num_i+ind_shift(4); |
---|
2038 | % adjust the first and last field number |
---|
2039 | indsel=find(num_i1_line >= 1); |
---|
2040 | num_i_out=num_i(indsel); |
---|
2041 | num_i1_line=num_i1_line(indsel); |
---|
2042 | num_i2_line=num_i2_line(indsel); |
---|
2043 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
2044 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
2045 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
2046 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
2047 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
2048 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
2049 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
2050 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
2051 | else |
---|
2052 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
2053 | num_j2_col=num_j+ind_shift(2); |
---|
2054 | % adjust the first field number |
---|
2055 | indsel=find((num_j1_col >= 1)); |
---|
2056 | num_j_out=num_j(indsel); |
---|
2057 | num_j1_col=num_j1_col(indsel); |
---|
2058 | num_j2_col=num_j2_col(indsel); |
---|
2059 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
2060 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
2061 | end |
---|
2062 | end |
---|
2063 | |
---|
2064 | |
---|
2065 | % set(handles.time_first,'Value',1) |
---|
2066 | % set(handles.time_last,'Value',1) |
---|
2067 | % set(handles.time_first,'String',time_first_cell); |
---|
2068 | % set(handles.time_last,'String',time_last_cell); |
---|
2069 | |
---|
2070 | %------------------------------------------------------------------------ |
---|
2071 | % --- Executes on button press in GetObject. |
---|
2072 | function GetObject_Callback(hObject, eventdata, handles) |
---|
2073 | %------------------------------------------------------------------------ |
---|
2074 | SeriesData=get(handles.series,'UserData'); |
---|
2075 | value=get(handles.GetObject,'Value'); |
---|
2076 | if value |
---|
2077 | set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
2078 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
2079 | if ishandle(hset_object) |
---|
2080 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
2081 | else |
---|
2082 | %get the object file |
---|
2083 | InputTable=get(handles.InputTable,'Data'); |
---|
2084 | defaultname=InputTable{1,1}; |
---|
2085 | if isempty(defaultname) |
---|
2086 | defaultname={''}; |
---|
2087 | end |
---|
2088 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
2089 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
2090 | '*.xml', '.xml files '; ... |
---|
2091 | '*.mat', '.mat matlab files '}, ... |
---|
2092 | 'Pick an xml object file (or use uvmat to create it)',defaultname{1}); |
---|
2093 | fileinput=[PathName FileName];%complete file name |
---|
2094 | sizf=size(fileinput); |
---|
2095 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
2096 | %read the file |
---|
2097 | t=xmltree(fileinput); |
---|
2098 | data=convert(t); |
---|
2099 | if ~isfield(data,'Style') |
---|
2100 | data.Style='points'; |
---|
2101 | end |
---|
2102 | if ~isfield(data,'ProjMode') |
---|
2103 | data.ProjMode='projection'; |
---|
2104 | end |
---|
2105 | % data.desable_plot=1; |
---|
2106 | [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface |
---|
2107 | end |
---|
2108 | else |
---|
2109 | set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
2110 | end |
---|
2111 | set(handles.series,'UserData',SeriesData) |
---|
2112 | |
---|
2113 | %-------------------------------------------------------------- |
---|
2114 | function GetMask_Callback(hObject, eventdata, handles) |
---|
2115 | value=get(handles.GetMask,'Value'); |
---|
2116 | if value |
---|
2117 | msgbox_uvmat('ERROR','not implemented yet') |
---|
2118 | end |
---|
2119 | %-------------------------------------------------------------- |
---|
2120 | |
---|
2121 | %------------------------------------------------------------------- |
---|
2122 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
2123 | function ncbrowser_uvmat(hObject, eventdata) |
---|
2124 | %------------------------------------------------------------------- |
---|
2125 | bla=get(gcbo,'String'); |
---|
2126 | ind=get(gcbo,'Value'); |
---|
2127 | filename=cell2mat(bla(ind)); |
---|
2128 | blank=find(filename==' '); |
---|
2129 | filename=filename(1:blank-1); |
---|
2130 | get_field(filename) |
---|
2131 | |
---|
2132 | % ------------------------------------------------------------------ |
---|
2133 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
2134 | %------------------------------------------------------------------- |
---|
2135 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
2136 | pathelp=fileparts(path_to_uvmat); |
---|
2137 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
2138 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
2139 | else |
---|
2140 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
2141 | web([helpfile '#series']) |
---|
2142 | end |
---|
2143 | |
---|
2144 | %------------------------------------------------------------------- |
---|
2145 | % --- Executes on selection change in transform_fct. |
---|
2146 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
2147 | %------------------------------------------------------------------- |
---|
2148 | global nb_transform |
---|
2149 | |
---|
2150 | menu=get(handles.transform_fct,'String'); |
---|
2151 | ind_coord=get(handles.transform_fct,'Value'); |
---|
2152 | coord_option=menu{ind_coord}; |
---|
2153 | list_transform=get(handles.transform_fct,'UserData'); |
---|
2154 | ff=functions(list_transform{end}); |
---|
2155 | if isequal(coord_option,'more...'); |
---|
2156 | coord_fct=''; |
---|
2157 | prompt = {'Enter the name of the transform function'}; |
---|
2158 | dlg_title = 'user defined transform'; |
---|
2159 | num_lines= 1; |
---|
2160 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
2161 | {'*.m', ' (*.m)'; |
---|
2162 | '*.m', '.m files '; ... |
---|
2163 | '*.*', 'All Files (*.*)'}, ... |
---|
2164 | 'Pick a file', ff.file); |
---|
2165 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
2166 | PathName(end)=[]; |
---|
2167 | end |
---|
2168 | transform_selected =fullfile(PathName,FileName); |
---|
2169 | if ~exist(transform_selected,'file') |
---|
2170 | return |
---|
2171 | end |
---|
2172 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
2173 | if ~isequal(ext_fct,'.m') |
---|
2174 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
2175 | return |
---|
2176 | end |
---|
2177 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu |
---|
2178 | ind_coord=get(handles.transform_fct,'Value'); |
---|
2179 | addpath(PathName) |
---|
2180 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
2181 | set(handles.transform_fct,'UserData',list_transform) |
---|
2182 | rmpath(PathName) |
---|
2183 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
2184 | dir_perso=prefdir;%personal Matalb directory |
---|
2185 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2186 | if exist(profil_perso,'file') |
---|
2187 | for ilist=nb_transform+1:numel(list_transform) |
---|
2188 | ff=functions(list_transform{ilist}); |
---|
2189 | transform_fct{ilist-nb_transform}=ff.file; |
---|
2190 | end |
---|
2191 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
2192 | end |
---|
2193 | end |
---|
2194 | |
---|
2195 | %check the current path to the selected function |
---|
2196 | if ~isempty(list_transform{ind_coord}) |
---|
2197 | func=functions(list_transform{ind_coord}); |
---|
2198 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function |
---|
2199 | else |
---|
2200 | set(handles.path_transform,'String',''); %show the path to the senlected function |
---|
2201 | end |
---|
2202 | |
---|
2203 | %------------------------------------------------------------------------ |
---|
2204 | % --- Executes on button press in REFRESH_INDICES. |
---|
2205 | function REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
2206 | %------------------------------------------------------------------------ |
---|
2207 | % hObject handle to REFRESH_INDICES (see GCBO) |
---|
2208 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
2209 | % handles structure with handles and user data (see GUIDATA) |
---|
2210 | set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2211 | InputTable=get(handles.InputTable,'Data'); |
---|
2212 | check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
2213 | |
---|
2214 | %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
2215 | for ind_list=1:length(check_lines) |
---|
2216 | if check_lines(ind_list) |
---|
2217 | InputLine=InputTable(ind_list,:); |
---|
2218 | detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
2219 | detect_idem=detect_idem(detect_idem>0); |
---|
2220 | if ~isempty (detect_idem) |
---|
2221 | InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
2222 | set(handles.InputTable,'Data',InputTable) |
---|
2223 | end |
---|
2224 | fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
2225 | %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
2226 | %update file series defined by the selected line |
---|
2227 | [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
2228 | if ~isempty(errormsg) |
---|
2229 | msgbox_uvmat('ERROR',errormsg) |
---|
2230 | return |
---|
2231 | end |
---|
2232 | end |
---|
2233 | end |
---|
2234 | set(handles.InputTable,'Data',InputTable) |
---|
2235 | SeriesData=get(handles.series,'UserData'); |
---|
2236 | |
---|
2237 | state_j='off'; |
---|
2238 | state_Pairs='off'; |
---|
2239 | state_InputFields='off'; |
---|
2240 | val=get(handles.ListView,'Value'); |
---|
2241 | ListViewString={''}; |
---|
2242 | if ~isempty(SeriesData) |
---|
2243 | % ListViewString={}; |
---|
2244 | for iview=1:size(InputTable,1) |
---|
2245 | if ~isempty(SeriesData.j1_series{iview}) |
---|
2246 | state_j='on'; |
---|
2247 | end |
---|
2248 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
2249 | state_Pairs='on'; |
---|
2250 | ListViewString{iview}=num2str(iview); |
---|
2251 | if check_lines(iview) |
---|
2252 | val=iview;%select the last pair if it is a new entry |
---|
2253 | end |
---|
2254 | end |
---|
2255 | if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
2256 | state_InputFields='on'; |
---|
2257 | end |
---|
2258 | end |
---|
2259 | end |
---|
2260 | set(handles.ListView,'Value',val) |
---|
2261 | set(handles.ListView,'String',ListViewString) |
---|
2262 | if strcmp(state_Pairs,'on') |
---|
2263 | ListView_Callback(hObject,eventdata,handles) |
---|
2264 | end |
---|
2265 | set(handles.PairString,'Visible',state_Pairs) |
---|
2266 | enable_j(handles,state_j) |
---|
2267 | set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0]) |
---|
2268 | set(handles.REFRESH_INDICES,'visible','off') |
---|
2269 | |
---|
2270 | % ----------------------------------------------------------------------- |
---|
2271 | % --- Update min and max indices of a file series by scanning with find_file_series |
---|
2272 | % --- which also changes the root file and NomType in case of movie. Also adjust the string representation of indices (e.g; |
---|
2273 | % --- 1 or 001 by the function find_file_series |
---|
2274 | % --- This function also dispaly the set of availbale files in the series |
---|
2275 | % --- and the menus appropriate to the file type as well as timing possibly set |
---|
2276 | % --- by an xml image documentation file |
---|
2277 | function [RootFile,NomType,errormsg]=update_indices(handles,fileinput,iview) |
---|
2278 | % ----------------------------------------------------------------------- |
---|
2279 | %% look for min and max indices existing in the file series and update SeriesData |
---|
2280 | errormsg=''; |
---|
2281 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
2282 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
2283 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
2284 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
2285 | if isempty(RootFile)&&isempty(i1_series) |
---|
2286 | errormsg='no input file in the series'; |
---|
2287 | return |
---|
2288 | end |
---|
2289 | |
---|
2290 | %% adjust the min and max indices common to all the file series |
---|
2291 | MinIndex=get(handles.MinIndex,'Data'); |
---|
2292 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
2293 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
2294 | if ~isempty(i2_series) |
---|
2295 | MaxIndex_i=max(i2_series(i2_series>0)); |
---|
2296 | else |
---|
2297 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
2298 | end |
---|
2299 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
2300 | if ~isempty(j2_series) |
---|
2301 | MaxIndex_j=max(j2_series(j2_series>0)); |
---|
2302 | else |
---|
2303 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
2304 | end |
---|
2305 | MinIndex{iview,1}=MinIndex_i; |
---|
2306 | MinIndex{iview,2}=MinIndex_j; |
---|
2307 | MaxIndex{iview,1}=MaxIndex_i; |
---|
2308 | MaxIndex{iview,2}=MaxIndex_j; |
---|
2309 | set(handles.MinIndex,'Data',MinIndex) |
---|
2310 | set(handles.MaxIndex,'Data',MaxIndex) |
---|
2311 | SeriesData=get(handles.series,'UserData'); |
---|
2312 | SeriesData.i1_series{iview}=i1_series; |
---|
2313 | SeriesData.i2_series{iview}=i2_series; |
---|
2314 | SeriesData.j1_series{iview}=j1_series; |
---|
2315 | SeriesData.j2_series{iview}=j2_series; |
---|
2316 | SeriesData.FileType{iview}=FileType; |
---|
2317 | |
---|
2318 | %% display the set of existing files as an image |
---|
2319 | set(handles.waitbar_frame,'Units','pixels') |
---|
2320 | pos=get(handles.waitbar_frame,'Position'); |
---|
2321 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
2322 | yima=0.5:pos(4)-0.5; |
---|
2323 | [XIma,YIma]=meshgrid(xima,yima); |
---|
2324 | nb_i=size(i1_series,1); |
---|
2325 | nb_j=size(i1_series,2); |
---|
2326 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
2327 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
2328 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
2329 | CData=zeros([size(XIma) 3]); |
---|
2330 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
2331 | if numel(file_ima)>=2 |
---|
2332 | if size(file_ima,1)==1 |
---|
2333 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
2334 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
2335 | else |
---|
2336 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
2337 | end |
---|
2338 | set(handles.waitbar_frame,'CData',CData) |
---|
2339 | end |
---|
2340 | set(handles.waitbar_frame,'Units','normalized') |
---|
2341 | |
---|
2342 | %% enable field and veltype menus |
---|
2343 | testfield=isequal(get(handles.FieldMenu,'enable'),'on'); |
---|
2344 | testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on'); |
---|
2345 | testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on'); |
---|
2346 | testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on'); |
---|
2347 | testtransform=isequal(get(handles.transform_fct,'Enable'),'on'); |
---|
2348 | % testnc=0; |
---|
2349 | % testnc_1=0; |
---|
2350 | % testcivx=0; |
---|
2351 | % testcivx_1=0; |
---|
2352 | % testima=0; %test for image input |
---|
2353 | % if isequal(lower(FileExt),'.avi') %.avi file |
---|
2354 | % testima=1; |
---|
2355 | % elseif ~isempty(imformats(FileExt(2:end))) |
---|
2356 | % testima=1; |
---|
2357 | % elseif isequal(FileExt,'.vol') |
---|
2358 | % testima=1; |
---|
2359 | % end |
---|
2360 | %TODO: update |
---|
2361 | % if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
2362 | % for iview=1:length(FileExtCell) |
---|
2363 | % if isequal(FileExtCell{iview},'.nc') |
---|
2364 | % testnc=1; |
---|
2365 | % end |
---|
2366 | % if isequal(FileTypeCell{iview},'civx') |
---|
2367 | % testcivx=1; |
---|
2368 | % end |
---|
2369 | % end |
---|
2370 | % elseif length(FileExtCell)==2 |
---|
2371 | % testnc=isequal(FileExtCell{1},'.nc'); |
---|
2372 | % testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
2373 | % testcivx=isequal(FileTypeCell{1},'civx'); |
---|
2374 | % testcivx_1=isequal(FileTypeCell{2},'civx'); |
---|
2375 | % end |
---|
2376 | switch FileType |
---|
2377 | case {'civx','civdata'} |
---|
2378 | view_FieldMenu(handles,'on') |
---|
2379 | menustr=get(handles.FieldMenu,'String'); |
---|
2380 | if isequal(menustr,{'get_field...'}) |
---|
2381 | set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
2382 | end |
---|
2383 | set(handles.VelTypeMenu,'Visible','on') |
---|
2384 | set(handles.FieldTransform,'Visible','on') |
---|
2385 | % view_TRANSFORM(handles,'on') |
---|
2386 | % TODO: second menu |
---|
2387 | % view_FieldMenu_1(handles,'on') |
---|
2388 | % if testcivx_1 |
---|
2389 | % menustr=get(handles.FieldMenu_1,'String'); |
---|
2390 | % if isequal(menustr,{'get_field...'}) |
---|
2391 | % set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
2392 | % end |
---|
2393 | % else |
---|
2394 | % set(handles.FieldMenu_1,'Value',1) |
---|
2395 | % set(handles.FieldMenu_1,'String',{'get_field...'}) |
---|
2396 | % set(handles.VelTypeMenu_1,'Visible','on') |
---|
2397 | % set(handles.VelType_text_1,'Visible','on'); |
---|
2398 | % end |
---|
2399 | % view_FieldMenu_1(handles,'off') |
---|
2400 | case 'netcdf' |
---|
2401 | view_FieldMenu(handles,'on') |
---|
2402 | set(handles.FieldMenu,'Value',1) |
---|
2403 | set(handles.FieldMenu,'String',{'get_field...'}) |
---|
2404 | set(handles.FieldTransform,'Visible','off') |
---|
2405 | % view_TRANSFORM(handles,'off') |
---|
2406 | case {'image','multimage','video'} |
---|
2407 | view_FieldMenu(handles,'off') |
---|
2408 | view_FieldMenu_1(handles,'off') |
---|
2409 | set(handles.VelTypeMenu,'Visible','off') |
---|
2410 | set(handles.VelType_text,'Visible','off'); |
---|
2411 | end |
---|
2412 | |
---|
2413 | |
---|
2414 | %TODO:update |
---|
2415 | % if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima |
---|
2416 | % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt]) |
---|
2417 | % return |
---|
2418 | % end |
---|
2419 | |
---|
2420 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2421 | ext_imadoc=''; |
---|
2422 | FileBase=fullfile(RootPath,RootFile); |
---|
2423 | if isequal(FileExt,'.xml')||isequal(FileExt,'.civ') |
---|
2424 | ext_imadoc=FileExt; |
---|
2425 | elseif exist([FileBase '.xml'],'file') |
---|
2426 | ext_imadoc='.xml'; |
---|
2427 | elseif exist([FileBase '.civ'],'file') |
---|
2428 | ext_imadoc='.civ'; |
---|
2429 | end |
---|
2430 | %read the ImaDoc file |
---|
2431 | XmlData=[]; |
---|
2432 | NbSlice_calib={}; |
---|
2433 | if isequal(ext_imadoc,'.xml') |
---|
2434 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
2435 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
2436 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
2437 | end |
---|
2438 | if isfield(XmlData,'Time') |
---|
2439 | time{iview}=XmlData.Time; |
---|
2440 | end |
---|
2441 | if isfield(XmlData,'Camera') |
---|
2442 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
2443 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
2444 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
2445 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
2446 | end |
---|
2447 | end |
---|
2448 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
2449 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
2450 | end |
---|
2451 | end |
---|
2452 | if ~isempty(warntext) |
---|
2453 | msgbox_uvmat('WARNING',warntext) |
---|
2454 | end |
---|
2455 | elseif isequal(ext_imadoc,'.civ') |
---|
2456 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
2457 | time{iview}=XmlData.Time; |
---|
2458 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
2459 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
2460 | end |
---|
2461 | end |
---|
2462 | |
---|
2463 | %% update time table |
---|
2464 | TimeTable=get(handles.TimeTable,'Data') |
---|
2465 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
2466 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
2467 | set(handles.TimeTable,'Data',TimeTable) |
---|
2468 | |
---|
2469 | %% number of slices |
---|
2470 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
2471 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
2472 | if siz(1)>1 |
---|
2473 | NbSlice=siz(1); |
---|
2474 | else |
---|
2475 | NbSlice=1; |
---|
2476 | end |
---|
2477 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
2478 | end |
---|
2479 | % set(handles.mode,'Visible','off') % do not show index pairstring by default |
---|
2480 | set(handles.PairString,'Visible','off') |
---|
2481 | % set(handles.num_ref_i,'Visible','off') |
---|
2482 | % set(handles.ref_i_text,'Visible','off') |
---|
2483 | testpair=0; |
---|
2484 | %set the menus of image pairstring and default selection for series |
---|
2485 | %list pairstring if relevant |
---|
2486 | % Val=get(handles.NomType,'Value'); |
---|
2487 | % synchronise_view(handles,Val) |
---|
2488 | |
---|
2489 | % if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{index}) |
---|
2490 | % state_j='off'; %no need for j index |
---|
2491 | % else |
---|
2492 | % state_j='on'; %case of j index |
---|
2493 | % end |
---|
2494 | % show index pairstring if files exist |
---|
2495 | set(handles.series,'UserData',SeriesData) |
---|
2496 | |
---|
2497 | |
---|
2498 | |
---|
2499 | % --- Executes on button press in BATCH. |
---|
2500 | function BATCH_Callback(hObject, eventdata, handles) |
---|
2501 | % hObject handle to BATCH (see GCBO) |
---|
2502 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
2503 | % handles structure with handles and user data (see GUIDATA) |
---|
2504 | Series=read_GUI(handles.series); |
---|
2505 | t=struct2xml(Series); |
---|
2506 | save(t); %TODO: determine a xml file name |
---|
2507 | |
---|
2508 | % list_action=get(handles.ACTION,'String');% list menu action |
---|
2509 | % index_action=get(handles.ACTION,'Value');% selected string index |
---|
2510 | % action= list_action{index_action}; % selected string |
---|
2511 | |
---|
2512 | %% defining the ACTION function handle |
---|
2513 | path_series=which('series'); |
---|
2514 | list_path=get(handles.ACTION,'UserData'); |
---|
2515 | index=get(handles.ACTION,'Value'); |
---|
2516 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
2517 | if ~isequal(fct_path,path_series) |
---|
2518 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
2519 | if ~exist(fct_path,'dir') |
---|
2520 | msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist']) |
---|
2521 | return |
---|
2522 | end |
---|
2523 | if ~isequal(spath,fct_path) |
---|
2524 | addpath(fct_path)% add the prescribed path if not the current one |
---|
2525 | end |
---|
2526 | end |
---|
2527 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
2528 | if ~isequal(fct_path,path_series) |
---|
2529 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
2530 | end |
---|
2531 | |
---|
2532 | h_fun('BATCH');% TODO modify the called function to read the xml file as input parameter |
---|