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 TransformName (menu for coordinate transforms) |
---|
9 | % .menu_coord_val: value for TransformName (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') && exist(h.MenuFile_1,'file') |
---|
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_2')&& exist(h.MenuFile_2,'file') |
---|
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_3')&& exist(h.MenuFile_3,'file') |
---|
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_4')&& exist(h.MenuFile_4,'file') |
---|
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_5')&& exist(h.MenuFile_5,'file') |
---|
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.TransformName,'String',param.menu_coord_str) |
---|
115 | end |
---|
116 | if isfield(param,'menu_coord_val') |
---|
117 | set(handles.TransformName,'Value',param.menu_coord_val); |
---|
118 | else |
---|
119 | set(handles.TransformName,'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.FieldName,'String',param.list_fields);% list menu fields |
---|
133 | set(handles.FieldName,'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 ActionName 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.ActionName,'String',fct_menu) |
---|
195 | set(handles.ActionName,'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.TransformName,'String',menu_str) |
---|
200 | set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
201 | |
---|
202 | % display the GUI for the default actionname 'check_data_files' |
---|
203 | ActionName_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 actionname 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 | oldfile=''; %default |
---|
332 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
333 | dir_perso=prefdir; |
---|
334 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
335 | if exist(profil_perso,'file') |
---|
336 | h=load (profil_perso); |
---|
337 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
338 | oldfile=h.filebase; |
---|
339 | end |
---|
340 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
341 | oldfile=h.RootPath; |
---|
342 | end |
---|
343 | end |
---|
344 | else |
---|
345 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
346 | end |
---|
347 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
348 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
349 | '*.xml', '.xml files '; ... |
---|
350 | '*.xls', '.xls files '; ... |
---|
351 | '*.png','.png image files'; ... |
---|
352 | '*.avi;*.AVI','.avi movie files'; ... |
---|
353 | '*.nc','.netcdf files'; ... |
---|
354 | '*.*', 'All Files (*.*)'}, ... |
---|
355 | 'Pick a file',oldfile); |
---|
356 | fileinput=[PathName FileName];%complete file name |
---|
357 | sizf=size(fileinput); |
---|
358 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
359 | [path,name,ext]=fileparts(fileinput); |
---|
360 | if isequal(ext,'.xml') |
---|
361 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
362 | elseif isequal(ext,'.xls') |
---|
363 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
364 | else |
---|
365 | display_file_name(handles,fileinput,1) |
---|
366 | end |
---|
367 | |
---|
368 | % -------------------------------------------------------------------- |
---|
369 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
370 | % -------------------------------------------------------------------- |
---|
371 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
372 | display_file_name(handles,fileinput,1) |
---|
373 | |
---|
374 | % -------------------------------------------------------------------- |
---|
375 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
376 | % -------------------------------------------------------------------- |
---|
377 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
378 | display_file_name(handles,fileinput,1) |
---|
379 | |
---|
380 | % -------------------------------------------------------------------- |
---|
381 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
382 | % -------------------------------------------------------------------- |
---|
383 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
384 | display_file_name( handles,fileinput,1) |
---|
385 | |
---|
386 | % -------------------------------------------------------------------- |
---|
387 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
388 | % -------------------------------------------------------------------- |
---|
389 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
390 | display_file_name( handles,fileinput,1) |
---|
391 | |
---|
392 | % -------------------------------------------------------------------- |
---|
393 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
394 | % -------------------------------------------------------------------- |
---|
395 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
396 | display_file_name(handles,fileinput,1) |
---|
397 | |
---|
398 | %------------------------------------------------------------------------ |
---|
399 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
400 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
401 | %------------------------------------------------------------------------ |
---|
402 | iview=eventdata.Indices(1); |
---|
403 | InputTable=get(handles.InputTable,'Data'); |
---|
404 | fileinput=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); |
---|
405 | display_file_name(handles,fileinput,0) |
---|
406 | %update the output dir |
---|
407 | SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
408 | SubDirOut=SubDir{1}; |
---|
409 | if numel(SubDir)>1 |
---|
410 | for ilist=2:numel(SubDir) |
---|
411 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
412 | end |
---|
413 | end |
---|
414 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
415 | |
---|
416 | %------------------------------------------------------------------------ |
---|
417 | % --- refresh the GUI data after introduction of a new file |
---|
418 | % INPUT: |
---|
419 | % handles: handles of the elements in the GUI series |
---|
420 | % fileinput: name of the input file |
---|
421 | % 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') |
---|
422 | function display_file_name(handles,fileinput,append) |
---|
423 | %------------------------------------------------------------------------ |
---|
424 | |
---|
425 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
426 | if ~exist(fileinput,'file') |
---|
427 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
428 | return |
---|
429 | end |
---|
430 | |
---|
431 | %% enable other menus and uicontrols |
---|
432 | set(handles.MenuOpen_insert,'Enable','on') |
---|
433 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
434 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
435 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
436 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
437 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
438 | set(handles.RUN, 'Enable','On') |
---|
439 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
440 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
441 | drawnow |
---|
442 | |
---|
443 | %% detect root name, nomenclature and indices in the input file name: |
---|
444 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
445 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
446 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
447 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
448 | if isempty(RootFile)&&isempty(i1_series) |
---|
449 | errormsg='no input file in the series'; |
---|
450 | return |
---|
451 | end |
---|
452 | |
---|
453 | %% fill the list of file series |
---|
454 | InputTable=get(handles.InputTable,'Data'); |
---|
455 | if append % display the input data as a new line in the table |
---|
456 | lastview=size(InputTable,1)+1; |
---|
457 | InputTable(lastview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
458 | set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}]) |
---|
459 | set(handles.ListView,'Value',lastview) |
---|
460 | |
---|
461 | else % or re-initialise the list of input file series |
---|
462 | lastview=1; |
---|
463 | InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
464 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
465 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
466 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
467 | set(handles.ListView,'Value',1) |
---|
468 | set(handles.ListView,'String',{'1'}) |
---|
469 | end |
---|
470 | set(handles.InputTable,'Data',InputTable) |
---|
471 | |
---|
472 | %update the output dir |
---|
473 | SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
474 | SubDirOut=SubDir{1}; |
---|
475 | if numel(SubDir)>1 |
---|
476 | for ilist=2:numel(SubDir) |
---|
477 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
478 | end |
---|
479 | end |
---|
480 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
481 | |
---|
482 | %% determine the selected reference field indices for pair display |
---|
483 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
484 | if ~isempty(i1) |
---|
485 | ref_i=i1; |
---|
486 | if ~isempty(i2) |
---|
487 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
488 | end |
---|
489 | end |
---|
490 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
491 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
492 | if ~isempty(j1) |
---|
493 | ref_j=j1; |
---|
494 | if ~isempty(j2) |
---|
495 | ref_j=floor((j1+j2)/2); |
---|
496 | end |
---|
497 | end |
---|
498 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
499 | |
---|
500 | %% update the list of recent files in the menubar and save it for future opening |
---|
501 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
502 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
503 | str_find=strcmp(fileinput,MenuFile); |
---|
504 | if isempty(find(str_find,1)) |
---|
505 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
506 | end |
---|
507 | for ifile=1:min(length(MenuFile),5) |
---|
508 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
509 | eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
510 | end |
---|
511 | dir_perso=prefdir; |
---|
512 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
513 | if exist(profil_perso,'file') |
---|
514 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
515 | else |
---|
516 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
517 | end |
---|
518 | |
---|
519 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
520 | |
---|
521 | %% initiate input file series and refresh the current field view: |
---|
522 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,lastview); |
---|
523 | |
---|
524 | %------------------------------------------------------------------------ |
---|
525 | % --- Update information about a new field series (indices to scan, timing, |
---|
526 | % calibration from an xml file, then refresh current plots |
---|
527 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) |
---|
528 | %------------------------------------------------------------------------ |
---|
529 | |
---|
530 | %% enable j index visibility |
---|
531 | if isempty(j1_series) |
---|
532 | state='off'; |
---|
533 | else |
---|
534 | state='on'; |
---|
535 | end |
---|
536 | enable_j(handles,state) |
---|
537 | |
---|
538 | %% display the min and max indices for all the file series |
---|
539 | MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex |
---|
540 | MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex |
---|
541 | i_sum=sum(sum(i1_series,2),3); |
---|
542 | MaxIndex_i=max(find(i_sum>0))-1; |
---|
543 | MinIndex_i=min(find(i_sum>0))-1; |
---|
544 | j_sum=sum(sum(i1_series,1),3); |
---|
545 | MaxIndex_j=max(find(j_sum>0))-1; |
---|
546 | MinIndex_j=min(find(j_sum>0))-1; |
---|
547 | MinIndex{iview,1}=MinIndex_i; |
---|
548 | MinIndex{iview,2}=MinIndex_j; |
---|
549 | MaxIndex{iview,1}=MaxIndex_i; |
---|
550 | MaxIndex{iview,2}=MaxIndex_j; |
---|
551 | set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex |
---|
552 | set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex |
---|
553 | |
---|
554 | %% adjust the first and last indices if requested by the bounds |
---|
555 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
556 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
557 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
558 | if isempty(first_i) |
---|
559 | first_i=ref_i; |
---|
560 | elseif first_i < MinIndex_i |
---|
561 | first_i=MinIndex_i; |
---|
562 | end |
---|
563 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
564 | if isempty(first_j) |
---|
565 | first_j=ref_j; |
---|
566 | elseif first_j<MinIndex_j |
---|
567 | first_j=MinIndex_j; |
---|
568 | end |
---|
569 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
570 | if isempty(last_i) |
---|
571 | last_i=ref_i; |
---|
572 | elseif last_i > MaxIndex_i |
---|
573 | last_i=MaxIndex_i; |
---|
574 | end |
---|
575 | last_j=str2num(get(handles.num_first_j,'String')); |
---|
576 | if isempty(last_j) |
---|
577 | last_j=ref_j; |
---|
578 | elseif last_j>MaxIndex_j |
---|
579 | last_j=MaxIndex_j; |
---|
580 | end |
---|
581 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
582 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
583 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
584 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
585 | |
---|
586 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
587 | InputTable=get(handles.InputTable,'Data'); |
---|
588 | FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); |
---|
589 | time=[];%default |
---|
590 | % case of movies |
---|
591 | if strcmp(InputTable{iview,4},'*') |
---|
592 | if ~isempty(VideoObject) |
---|
593 | imainfo=get(VideoObject); |
---|
594 | time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
595 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
596 | ColorType='truecolor'; |
---|
597 | elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image |
---|
598 | if ~isempty(InputTable{iview,2}) |
---|
599 | imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); |
---|
600 | else |
---|
601 | imainfo=imfinfo([FileBase InputTable{iview,5}]); |
---|
602 | end |
---|
603 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
604 | if length(imainfo) >1 %case of image with multiple frames |
---|
605 | nbfield=length(imainfo); |
---|
606 | nbfield_j=1; |
---|
607 | end |
---|
608 | end |
---|
609 | end |
---|
610 | |
---|
611 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
612 | ext_imadoc=''; |
---|
613 | if exist([FileBase '.xml'],'file') |
---|
614 | ext_imadoc='.xml'; |
---|
615 | elseif exist([FileBase '.civ'],'file') |
---|
616 | ext_imadoc='.civ'; |
---|
617 | end |
---|
618 | %read the ImaDoc file |
---|
619 | XmlData=[]; |
---|
620 | NbSlice_calib={}; |
---|
621 | if isequal(ext_imadoc,'.xml') |
---|
622 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
623 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
624 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
625 | end |
---|
626 | if isfield(XmlData,'Time') |
---|
627 | time=XmlData.Time; |
---|
628 | end |
---|
629 | if isfield(XmlData,'Camera') |
---|
630 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
631 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
632 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
633 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
634 | end |
---|
635 | end |
---|
636 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
637 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
638 | end |
---|
639 | end |
---|
640 | if ~isempty(warntext) |
---|
641 | msgbox_uvmat('WARNING',warntext) |
---|
642 | end |
---|
643 | elseif isequal(ext_imadoc,'.civ') |
---|
644 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
645 | time=XmlData.Time; |
---|
646 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
647 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
648 | end |
---|
649 | end |
---|
650 | |
---|
651 | %% update time table |
---|
652 | TimeTable=get(handles.TimeTable,'Data'); |
---|
653 | if isempty(MinIndex_j) |
---|
654 | TimeTable{iview,1}=time(MinIndex_i); |
---|
655 | TimeTable{iview,2}=time(first_i); |
---|
656 | TimeTable{iview,3}=time(last_i); |
---|
657 | TimeTable{iview,4}=time(MaxIndex_i); |
---|
658 | elseif ~isempty(time) |
---|
659 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
660 | TimeTable{iview,2}=time(first_i,first_j); |
---|
661 | TimeTable{iview,3}=time(last_i,last_j); |
---|
662 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
663 | end |
---|
664 | set(handles.TimeTable,'Data',TimeTable) |
---|
665 | |
---|
666 | %% number of slices |
---|
667 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
668 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
669 | if siz(1)>1 |
---|
670 | NbSlice=siz(1); |
---|
671 | else |
---|
672 | NbSlice=1; |
---|
673 | end |
---|
674 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
675 | end |
---|
676 | |
---|
677 | %% update pair menus |
---|
678 | set(handles.Pairs,'Visible','on') |
---|
679 | set(handles.PairString,'Visible','on') |
---|
680 | ListView=get(handles.ListView,'String'); |
---|
681 | ListView{iview}=num2str(iview); |
---|
682 | set(handles.ListView,'String'); |
---|
683 | set(handles.ListView,'Value',iview) |
---|
684 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
685 | |
---|
686 | |
---|
687 | %% display the set of existing files as an image |
---|
688 | set(handles.waitbar_frame,'Units','pixels') |
---|
689 | pos=get(handles.waitbar_frame,'Position'); |
---|
690 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
691 | yima=0.5:pos(4)-0.5; |
---|
692 | [XIma,YIma]=meshgrid(xima,yima); |
---|
693 | nb_i=size(i1_series,1); |
---|
694 | nb_j=size(i1_series,2); |
---|
695 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
696 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
697 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
698 | CData=zeros([size(XIma) 3]); |
---|
699 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
700 | if numel(file_ima)>=2 |
---|
701 | if size(file_ima,1)==1 |
---|
702 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
703 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
704 | else |
---|
705 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
706 | end |
---|
707 | set(handles.waitbar_frame,'CData',CData) |
---|
708 | end |
---|
709 | set(handles.waitbar_frame,'Units','normalized') |
---|
710 | |
---|
711 | %% enable field and veltype menus |
---|
712 | SeriesData=get(handles.series,'UserData'); |
---|
713 | SeriesData.FileType{iview}=FileType; |
---|
714 | check_civ=0; |
---|
715 | check_netcdf=0; |
---|
716 | for iview=1:length(SeriesData.FileType) |
---|
717 | switch SeriesData.FileType{iview} |
---|
718 | case {'civx','civdata'} |
---|
719 | check_civ=check_civ+1; |
---|
720 | case 'netcdf' |
---|
721 | check_netcdf=check_netcdf+1; |
---|
722 | end |
---|
723 | end |
---|
724 | if check_civ |
---|
725 | enable='on'; |
---|
726 | else |
---|
727 | enable='off'; |
---|
728 | end |
---|
729 | set(handles.VelType,'Visible',enable) |
---|
730 | set(handles.VelType_text,'Visible',enable) |
---|
731 | if check_civ>=2 |
---|
732 | enable='on'; |
---|
733 | else |
---|
734 | enable='off'; |
---|
735 | end |
---|
736 | set(handles.VelType_1,'Visible',enable) |
---|
737 | set(handles.VelType_text_1,'Visible',enable) |
---|
738 | if check_civ || check_netcdf |
---|
739 | enable='on'; |
---|
740 | else |
---|
741 | enable='off'; |
---|
742 | end |
---|
743 | set(handles.FieldName,'Visible',enable) |
---|
744 | set(handles.Field_text,'Visible',enable) |
---|
745 | if check_civ+ check_netcdf>=2 |
---|
746 | enable='on'; |
---|
747 | else |
---|
748 | enable='off'; |
---|
749 | end |
---|
750 | set(handles.FieldName_1,'Visible',enable) |
---|
751 | set(handles.Field_text_1,'Visible',enable) |
---|
752 | FieldString={''}; |
---|
753 | if check_civ |
---|
754 | FieldString=[calc_field;{'get_field...'}]; |
---|
755 | elseif check_netcdf |
---|
756 | FieldString={'get_field...'}; |
---|
757 | end |
---|
758 | set(handles.FieldName,'String',FieldString) |
---|
759 | FieldString={''}; |
---|
760 | if check_civ>=2 |
---|
761 | FieldString=[calc_field;{'get_field...'}]; |
---|
762 | elseif check_civ+check_netcdf>=2 |
---|
763 | FieldString={'get_field...'}; |
---|
764 | end |
---|
765 | set(handles.FieldName_1,'String',{'get_field...'}) |
---|
766 | |
---|
767 | |
---|
768 | %% store the series info in 'UserData' |
---|
769 | SeriesData.i1_series{iview}=i1_series; |
---|
770 | SeriesData.i2_series{iview}=i2_series; |
---|
771 | SeriesData.j1_series{iview}=j1_series; |
---|
772 | SeriesData.j2_series{iview}=j2_series; |
---|
773 | SeriesData.FileType{iview}=FileType; |
---|
774 | SeriesData.Time{iview}=time; |
---|
775 | set(handles.series,'UserData',SeriesData) |
---|
776 | |
---|
777 | %% check for pair display |
---|
778 | check_pairs=0; |
---|
779 | for iview=1:numel(SeriesData.i2_series) |
---|
780 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
781 | check_pairs=1; |
---|
782 | end |
---|
783 | end |
---|
784 | if check_pairs |
---|
785 | set(handles.Pairs,'Visible','on') |
---|
786 | set(handles.PairString,'Visible','on') |
---|
787 | else |
---|
788 | set(handles.Pairs,'Visible','off') |
---|
789 | set(handles.PairString,'Visible','off') |
---|
790 | end |
---|
791 | |
---|
792 | return |
---|
793 | |
---|
794 | %% set default options in menu 'Fields'%% TODO: check VelType |
---|
795 | if ~testima |
---|
796 | testcivx=0; |
---|
797 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field) |
---|
798 | set(handles_Fields,'Value',1) |
---|
799 | set(handles_Fields,'String',{'get_field...'}) |
---|
800 | UvData=rmfield(UvData,'FieldsString'); |
---|
801 | else |
---|
802 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); |
---|
803 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx |
---|
804 | FieldList=calc_field; |
---|
805 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
806 | set(handles_Fields,'Value',2) % set menu to 'velocity' |
---|
807 | col_vec=FieldList; |
---|
808 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar) |
---|
809 | testcivx=1; |
---|
810 | end |
---|
811 | if ~testcivx |
---|
812 | set(handles_Fields,'Value',1) % set menu to 'get_field... |
---|
813 | set(handles_Fields,'String',{'get_field...'}) |
---|
814 | col_vec={'get_field...'}; |
---|
815 | end |
---|
816 | set(handles.ColorScalar,'String',col_vec) |
---|
817 | end |
---|
818 | end |
---|
819 | set(handles.uvmat,'UserData',UvData) |
---|
820 | |
---|
821 | %% set index navigation options and refresh plots |
---|
822 | scan_option='i';%default |
---|
823 | state_j='off'; %default |
---|
824 | if index==2 |
---|
825 | if get(handles.scan_j,'Value') |
---|
826 | scan_option='j'; %keep the scan option for the second fiel series |
---|
827 | end |
---|
828 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
829 | state_j='on'; |
---|
830 | end |
---|
831 | end |
---|
832 | if ~isempty(j1_series) |
---|
833 | state_j='on'; |
---|
834 | if isequal(nbfield,1) &&index==1 |
---|
835 | scan_option='j'; %scan j index by default if nbfield=1 |
---|
836 | end |
---|
837 | end |
---|
838 | if isequal(scan_option,'i') |
---|
839 | set(handles.scan_i,'Value',1) |
---|
840 | scan_i_Callback([],[], handles); |
---|
841 | else |
---|
842 | set(handles.scan_j,'Value',1) |
---|
843 | scan_j_Callback([],[], handles); |
---|
844 | end |
---|
845 | set(handles.scan_j,'Visible',state_j) |
---|
846 | set(handles.j1,'Visible',state_j) |
---|
847 | set(handles.j2,'Visible',state_j) |
---|
848 | set(handles.last_j,'Visible',state_j); |
---|
849 | set(handles.frame_j,'Visible',state_j); |
---|
850 | set(handles.j_text,'Visible',state_j); |
---|
851 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
852 | set(handles.CheckFixPair,'Visible','on') |
---|
853 | elseif index==1 |
---|
854 | set(handles.CheckFixPair,'Visible','off') |
---|
855 | end |
---|
856 | |
---|
857 | |
---|
858 | mode_Callback(hObject, eventdata, handles) |
---|
859 | |
---|
860 | set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
861 | InputTable=get(handles.InputTable,'Data'); |
---|
862 | check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
863 | |
---|
864 | %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
865 | for ind_list=1:length(check_lines) |
---|
866 | if check_lines(ind_list) |
---|
867 | InputLine=InputTable(ind_list,:); |
---|
868 | detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
869 | detect_idem=detect_idem(detect_idem>0); |
---|
870 | if ~isempty (detect_idem) |
---|
871 | InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
872 | set(handles.InputTable,'Data',InputTable) |
---|
873 | end |
---|
874 | fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
875 | %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
876 | %update file series defined by the selected line |
---|
877 | [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
878 | if ~isempty(errormsg) |
---|
879 | msgbox_uvmat('ERROR',errormsg) |
---|
880 | return |
---|
881 | end |
---|
882 | end |
---|
883 | end |
---|
884 | set(handles.InputTable,'Data',InputTable) |
---|
885 | SeriesData=get(handles.series,'UserData'); |
---|
886 | |
---|
887 | state_j='off'; |
---|
888 | state_Pairs='off'; |
---|
889 | state_InputFields='off'; |
---|
890 | val=get(handles.ListView,'Value'); |
---|
891 | ListViewString={''}; |
---|
892 | if ~isempty(SeriesData) |
---|
893 | % ListViewString={}; |
---|
894 | for iview=1:size(InputTable,1) |
---|
895 | if ~isempty(SeriesData.j1_series{iview}) |
---|
896 | state_j='on'; |
---|
897 | end |
---|
898 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
899 | state_Pairs='on'; |
---|
900 | ListViewString{iview}=num2str(iview); |
---|
901 | if check_lines(iview) |
---|
902 | val=iview;%select the last pair if it is a new entry |
---|
903 | end |
---|
904 | end |
---|
905 | if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
906 | state_InputFields='on'; |
---|
907 | end |
---|
908 | end |
---|
909 | end |
---|
910 | set(handles.ListView,'Value',val) |
---|
911 | set(handles.ListView,'String',ListViewString) |
---|
912 | if strcmp(state_Pairs,'on') |
---|
913 | ListView_Callback(hObject,eventdata,handles) |
---|
914 | end |
---|
915 | set(handles.PairString,'Visible',state_Pairs) |
---|
916 | enable_j(handles,state_j) |
---|
917 | |
---|
918 | %------------------------------------------------------------------------ |
---|
919 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
920 | %------------------------------------------------------------------------ |
---|
921 | num_last_i_Callback(hObject, eventdata, handles) |
---|
922 | |
---|
923 | %------------------------------------------------------------------------ |
---|
924 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
925 | %------------------------------------------------------------------------ |
---|
926 | SeriesData=get(handles.series,'UserData'); |
---|
927 | if ~isfield(SeriesData,'Time') |
---|
928 | SeriesData.Time{1}=[]; |
---|
929 | end |
---|
930 | displ_time(handles); |
---|
931 | |
---|
932 | %------------------------------------------------------------------------ |
---|
933 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
934 | %------------------------------------------------------------------------ |
---|
935 | num_last_j_Callback(hObject, eventdata, handles) |
---|
936 | |
---|
937 | %------------------------------------------------------------------------ |
---|
938 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
939 | %------------------------------------------------------------------------ |
---|
940 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
941 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
942 | ref_j=ceil((first_j+last_j)/2); |
---|
943 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
944 | num_ref_j_Callback(hObject, eventdata, handles) |
---|
945 | SeriesData=get(handles.series,'UserData'); |
---|
946 | if ~isfield(SeriesData,'Time') |
---|
947 | SeriesData.Time{1}=[]; |
---|
948 | end |
---|
949 | displ_time(handles); |
---|
950 | |
---|
951 | %------------------------------------------------------------------------ |
---|
952 | % ---- find the times corresponding to the first and last indices of a series |
---|
953 | function displ_time(handles) |
---|
954 | %------------------------------------------------------------------------ |
---|
955 | SeriesData=get(handles.series,'UserData');% |
---|
956 | ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; |
---|
957 | ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; |
---|
958 | % last_i=str2num(get(handles.num_last_i,'String')); |
---|
959 | % last_j=str2num(get(handles.num_last_j,'String')); |
---|
960 | TimeTable=get(handles.TimeTable,'Data'); |
---|
961 | Pairs=get(handles.PairString,'Data'); |
---|
962 | for iview=1:size(TimeTable,1) |
---|
963 | if size(SeriesData.Time,1)<iview |
---|
964 | break |
---|
965 | end |
---|
966 | i1=ref_i; |
---|
967 | j1=ref_j; |
---|
968 | i2=ref_i; |
---|
969 | j2=ref_j; |
---|
970 | % case of pairs |
---|
971 | if ~isempty(Pairs{iview,1}) |
---|
972 | r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
973 | if isempty(r) |
---|
974 | r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
975 | end |
---|
976 | switch r.mode |
---|
977 | case 'Di=' % case 'series(Di)') |
---|
978 | i1=ref_i-str2num(r.num1); |
---|
979 | i2=ref_i+str2num(r.num2); |
---|
980 | case 'Dj=' % case 'series(Dj)' |
---|
981 | j1=ref_j-str2num(r.num1); |
---|
982 | j2=ref_j+str2num(r.num2); |
---|
983 | case '-' % case 'bursts' |
---|
984 | j1=str2num(r.num1)*ones(size(ref_i)); |
---|
985 | j2=str2num(r.num2)*ones(size(ref_i)); |
---|
986 | end |
---|
987 | end |
---|
988 | TimeTable{iview,2}=[]; |
---|
989 | TimeTable{iview,3}=[]; |
---|
990 | if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) |
---|
991 | if isempty(ref_j) |
---|
992 | time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2; |
---|
993 | time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2; |
---|
994 | else |
---|
995 | time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2; |
---|
996 | time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2; |
---|
997 | end |
---|
998 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
999 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
1000 | end |
---|
1001 | end |
---|
1002 | set(handles.TimeTable,'Data',TimeTable) |
---|
1003 | |
---|
1004 | %------------------------------------------------------------------------ |
---|
1005 | % --- Executes when selected cell(s) is changed in PairString. |
---|
1006 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
1007 | %------------------------------------------------------------------------ |
---|
1008 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
1009 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
1010 | |
---|
1011 | %------------------------------------------------------------------------ |
---|
1012 | %------------------------------------------------------------------------ |
---|
1013 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
1014 | %------------------------------------------------------------------------ |
---|
1015 | %------------------------------------------------------------------------ |
---|
1016 | % --- Executes on selection change in ListView. |
---|
1017 | function ListView_Callback(hObject, eventdata, handles) |
---|
1018 | %------------------------------------------------------------------------ |
---|
1019 | SeriesData=get(handles.series,'UserData'); |
---|
1020 | i2_series=[]; |
---|
1021 | j2_series=[]; |
---|
1022 | iview=get(handles.ListView,'Value'); |
---|
1023 | if ~isempty(SeriesData.i2_series{iview}) |
---|
1024 | i2_series=SeriesData.i2_series{iview}; |
---|
1025 | end |
---|
1026 | if ~isempty(SeriesData.j2_series{iview}) |
---|
1027 | j2_series=SeriesData.j2_series{iview}; |
---|
1028 | end |
---|
1029 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1030 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1031 | |
---|
1032 | %------------------------------------------------------------------------ |
---|
1033 | % --- Executes on button press in mode. |
---|
1034 | function mode_Callback(hObject, eventdata, handles) |
---|
1035 | %------------------------------------------------------------------------ |
---|
1036 | SeriesData=get(handles.series,'UserData'); |
---|
1037 | iview=get(handles.ListView,'Value'); |
---|
1038 | mode_list=get(handles.mode,'String'); |
---|
1039 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1040 | if isequal(mode,'bursts') |
---|
1041 | enable_i(handles,'On') |
---|
1042 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1043 | else |
---|
1044 | enable_i(handles,'On') |
---|
1045 | enable_j(handles,'Off') |
---|
1046 | end |
---|
1047 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1048 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1049 | ListPairs_Callback([],[],handles) |
---|
1050 | |
---|
1051 | %------------------------------------------------------------- |
---|
1052 | % --- Executes on selection in ListPairs. |
---|
1053 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
1054 | %------------------------------------------------------------ |
---|
1055 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
1056 | if isempty(list_pair) |
---|
1057 | string=''; |
---|
1058 | else |
---|
1059 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
1060 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
1061 | end |
---|
1062 | PairString=get(handles.PairString,'Data'); |
---|
1063 | iview=get(handles.ListView,'Value'); |
---|
1064 | PairString{iview,1}=string; |
---|
1065 | % report the selected pair string to the table PairString |
---|
1066 | set(handles.PairString,'Data',PairString) |
---|
1067 | |
---|
1068 | %------------------------------------------------------------------------ |
---|
1069 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
1070 | %------------------------------------------------------------------------ |
---|
1071 | mode_list=get(handles.mode,'String'); |
---|
1072 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1073 | SeriesData=get(handles.series,'UserData'); |
---|
1074 | iview=get(handles.ListView,'Value'); |
---|
1075 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1076 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files |
---|
1077 | ListPairs_Callback([],[],handles) |
---|
1078 | |
---|
1079 | %------------------------------------------------------------------------ |
---|
1080 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
1081 | %------------------------------------------------------------------------ |
---|
1082 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
1083 | |
---|
1084 | %------------------------------------------------------------------------ |
---|
1085 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1086 | %------------------------------------------------------------------------ |
---|
1087 | check_burst=0; |
---|
1088 | if isempty(j2_series)% no pair menu to display |
---|
1089 | if isempty(i2_series) |
---|
1090 | set(handles.mode,'String',{''}) |
---|
1091 | else |
---|
1092 | set(handles.mode,'Value',1) |
---|
1093 | set(handles.mode,'String',{'series(Di)'}) |
---|
1094 | end |
---|
1095 | else |
---|
1096 | nbfield=size(j2_series,1); |
---|
1097 | nbfield2=size(j2_series,2); |
---|
1098 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
1099 | if nbfield2>10 || nbfield==1 |
---|
1100 | set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values |
---|
1101 | else |
---|
1102 | set(handles.mode,'Value',1); |
---|
1103 | check_burst=1; |
---|
1104 | end |
---|
1105 | end |
---|
1106 | if check_burst |
---|
1107 | enable_i(handles,'On') |
---|
1108 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1109 | else |
---|
1110 | enable_i(handles,'On') |
---|
1111 | enable_j(handles,'On') |
---|
1112 | end |
---|
1113 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1114 | ListPairs_Callback([],[],handles) |
---|
1115 | |
---|
1116 | %-------------------------------------------------------------- |
---|
1117 | % determine the menu for civ1 pairstring depending on existing netcdf files |
---|
1118 | % with the reference indices num_ref_i and num_ref_j |
---|
1119 | %---------------------------------------------------------------- |
---|
1120 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1121 | |
---|
1122 | mode_list=get(handles.mode,'String'); |
---|
1123 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1124 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
1125 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
1126 | if isempty(ref_i) |
---|
1127 | ref_i=1; |
---|
1128 | end |
---|
1129 | if isempty(ref_j) |
---|
1130 | ref_j=1; |
---|
1131 | end |
---|
1132 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
1133 | if length(TimeUnit)>=1 |
---|
1134 | dtunit=['m' TimeUnit]; |
---|
1135 | else |
---|
1136 | dtunit='e-03'; |
---|
1137 | end |
---|
1138 | |
---|
1139 | displ_pair={}; |
---|
1140 | if strcmp(mode,'series(Di)') |
---|
1141 | if isempty(i2_series) |
---|
1142 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
1143 | return |
---|
1144 | end |
---|
1145 | diff_i=i2_series-i1_series; |
---|
1146 | min_diff=min(diff_i(diff_i>0)); |
---|
1147 | max_diff=max(diff_i(diff_i>0)); |
---|
1148 | for ipair=min_diff:max_diff |
---|
1149 | if numel(diff_i(diff_i==ipair))>0 |
---|
1150 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1151 | if ~isempty(time) |
---|
1152 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
1153 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1154 | end |
---|
1155 | displ_pair=[displ_pair;{pair_string}]; |
---|
1156 | end |
---|
1157 | end |
---|
1158 | if ~isempty(displ_pair) |
---|
1159 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
1160 | end |
---|
1161 | elseif strcmp(mode,'series(Dj)') |
---|
1162 | if isempty(j2_series) |
---|
1163 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1164 | return |
---|
1165 | end |
---|
1166 | diff_j=j2_series-j1_series; |
---|
1167 | min_diff=min(diff_j(diff_j>0)); |
---|
1168 | max_diff=max(diff_j(diff_j>0)); |
---|
1169 | for ipair=min_diff:max_diff |
---|
1170 | if numel(diff_j(diff_j==ipair))>0 |
---|
1171 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1172 | if ~isempty(time) |
---|
1173 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
1174 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1175 | end |
---|
1176 | displ_pair=[displ_pair;{pair_string}]; |
---|
1177 | end |
---|
1178 | end |
---|
1179 | if ~isempty(displ_pair) |
---|
1180 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
1181 | end |
---|
1182 | elseif strcmp(mode,'bursts') |
---|
1183 | if isempty(j2_series) |
---|
1184 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1185 | return |
---|
1186 | end |
---|
1187 | diff_j=j2_series-j1_series; |
---|
1188 | min_j1=min(j1_series(j1_series>0)); |
---|
1189 | max_j1=max(j1_series(j1_series>0)); |
---|
1190 | min_j2=min(j2_series(j2_series>0)); |
---|
1191 | max_j2=max(j2_series(j2_series>0)); |
---|
1192 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
1193 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
1194 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
1195 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
1196 | end |
---|
1197 | end |
---|
1198 | end |
---|
1199 | if ~isempty(displ_pair) |
---|
1200 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
1201 | end |
---|
1202 | end |
---|
1203 | |
---|
1204 | %% display list of pairstring |
---|
1205 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
1206 | NewVal=[]; |
---|
1207 | if ~isempty(displ_pair_list) |
---|
1208 | Val=get(handles.ListPairs,'Value'); |
---|
1209 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pï¿œir |
---|
1210 | end |
---|
1211 | if ~isempty(NewVal) |
---|
1212 | set(handles.ListPairs,'Value',NewVal) |
---|
1213 | else |
---|
1214 | set(handles.ListPairs,'Value',1) |
---|
1215 | end |
---|
1216 | set(handles.ListPairs,'String',displ_pair) |
---|
1217 | |
---|
1218 | %------------------------------------- |
---|
1219 | function enable_i(handles,state) |
---|
1220 | set(handles.i_txt,'Visible',state) |
---|
1221 | set(handles.num_first_i,'Visible',state) |
---|
1222 | set(handles.num_last_i,'Visible',state) |
---|
1223 | set(handles.num_incr_i,'Visible',state) |
---|
1224 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
1225 | set(handles.num_ref_i,'Visible',state) |
---|
1226 | set(handles.ref_i_text,'Visible',state) |
---|
1227 | |
---|
1228 | %----------------------------------- |
---|
1229 | function enable_j(handles,state) |
---|
1230 | set(handles.j_txt,'Visible',state) |
---|
1231 | % set(handles.num_MinIndex_j,'Visible',state) |
---|
1232 | set(handles.num_first_j,'Visible',state) |
---|
1233 | set(handles.num_last_j,'Visible',state) |
---|
1234 | set(handles.num_incr_j,'Visible',state) |
---|
1235 | % set(handles.num_MaxIndex_j,'Visible',state) |
---|
1236 | set(handles.num_ref_j,'Visible',state) |
---|
1237 | set(handles.ref_j_text,'Visible',state) |
---|
1238 | |
---|
1239 | %----------------------------------- |
---|
1240 | function view_FieldMenu(handles,state) |
---|
1241 | % set(handles.FieldName,'Visible',state) |
---|
1242 | % set(handles.Field_text,'Visible',state) |
---|
1243 | set(handles.InputFields,'Visible',state) |
---|
1244 | |
---|
1245 | %----------------------------------- |
---|
1246 | function view_FieldMenu_1(handles,state) |
---|
1247 | set(handles.FieldName_1,'Visible',state) |
---|
1248 | set(handles.Field_text_1,'Visible',state) |
---|
1249 | |
---|
1250 | |
---|
1251 | %%%%%%%%%%%%%%%%%%%% |
---|
1252 | %% MAIN ActionName FUNCTIONS |
---|
1253 | %%%%%%%%%%%%%%%%%%%% |
---|
1254 | %------------------------------------------------------------------------ |
---|
1255 | % --- Executes on button press in RUN. |
---|
1256 | function RUN_Callback(hObject, eventdata, handles) |
---|
1257 | %------------------------------------------------------------------------ |
---|
1258 | set(handles.RUN,'BusyAction','queue'); |
---|
1259 | set(0,'CurrentFigure',handles.series) |
---|
1260 | set(handles.RUN, 'Enable','Off') |
---|
1261 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1262 | [h_fun,Series,errormsg]=prepare_jobs(handles); |
---|
1263 | if ~isempty(errormsg) |
---|
1264 | msgbox_uvmat('ERROR',errormsg) |
---|
1265 | else |
---|
1266 | h_fun(Series); |
---|
1267 | end |
---|
1268 | set(handles.RUN, 'Enable','On') |
---|
1269 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1270 | |
---|
1271 | %------------------------------------------------------------------------ |
---|
1272 | function STOP_Callback(hObject, eventdata, handles) |
---|
1273 | %------------------------------------------------------------------------ |
---|
1274 | set(handles.RUN, 'BusyAction','cancel') |
---|
1275 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1276 | set(handles.RUN,'enable','on') |
---|
1277 | |
---|
1278 | %------------------------------------------------------------------------ |
---|
1279 | % --- Executes on button press in BATCH. |
---|
1280 | function BATCH_Callback(hObject, eventdata, handles) |
---|
1281 | %------------------------------------------------------------------------ |
---|
1282 | set(handles.BATCH, 'Enable','Off') |
---|
1283 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1284 | [h_fun,errormsg]=prepare_jobs(handles); |
---|
1285 | set(handles.BATCH, 'Enable','On') |
---|
1286 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
1287 | path_civ=fileparts(which('civ')); |
---|
1288 | filename_bat=[OutputFile '.bat']; |
---|
1289 | [fid,message]=fopen(filename_bat,'w'); |
---|
1290 | if isequal(fid,-1) |
---|
1291 | errormsg= ['creation of .bat file: ' message]; |
---|
1292 | return |
---|
1293 | end |
---|
1294 | text_matlabscript=[... |
---|
1295 | '#!/bin/bash \n'... |
---|
1296 | '. /etc/sysprofile \n'... |
---|
1297 | 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'... |
---|
1298 | 'cd(''' path_civ '''); \n'... |
---|
1299 | 'civ_matlab(''' filename_xml ''',''' OutputFile '.nc''); \n'... |
---|
1300 | 'exit \n'... |
---|
1301 | 'END_MATLAB \n']; |
---|
1302 | fprintf(fid,text_matlabscript); |
---|
1303 | fclose(fid); |
---|
1304 | if isunix |
---|
1305 | system(['chmod +x ' filename_bat]); |
---|
1306 | end |
---|
1307 | |
---|
1308 | %------------------------------------------------------------------------ |
---|
1309 | % --- Executes on button press in BIN. |
---|
1310 | function BIN_Callback(hObject, eventdata, handles) |
---|
1311 | %------------------------------------------------------------------------ |
---|
1312 | cmd=['#!/bin/bash \n '... |
---|
1313 | '#$ -cwd \n '... |
---|
1314 | 'hostname && date \n '... |
---|
1315 | 'umask 002 \n'... |
---|
1316 | Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; |
---|
1317 | |
---|
1318 | %------------------------------------------------------------------------ |
---|
1319 | % --- Main lauch command, called by RUN and BATCH |
---|
1320 | function [h_fun,Series,errormsg]=prepare_jobs(handles) |
---|
1321 | %------------------------------------------------------------------------ |
---|
1322 | errormsg=''; |
---|
1323 | %% Read parameters from series |
---|
1324 | Series=read_GUI(handles.series); |
---|
1325 | if isfield(Series,'Pairs') |
---|
1326 | Series=rmfield(Series,'Pairs'); %info Pairs not needed for output |
---|
1327 | end |
---|
1328 | |
---|
1329 | %% read root name and field type |
---|
1330 | first_i=1; |
---|
1331 | last_i=1; |
---|
1332 | incr_i=1; |
---|
1333 | first_j=1; |
---|
1334 | last_j=1; |
---|
1335 | incr_j=1; |
---|
1336 | if isfield(Series.IndexRange,'first_i') |
---|
1337 | first_i=Series.IndexRange.first_i; |
---|
1338 | incr_i=Series.IndexRange.incr_i; |
---|
1339 | last_i=Series.IndexRange.last_i; |
---|
1340 | end |
---|
1341 | if isfield(Series.IndexRange,'first_j') |
---|
1342 | first_j=Series.IndexRange.first_j; |
---|
1343 | incr_j=Series.IndexRange.incr_j; |
---|
1344 | last_j=Series.IndexRange.last_j; |
---|
1345 | end |
---|
1346 | |
---|
1347 | %% read input file parameters and set menus |
---|
1348 | menu_coord_state=get(handles.TransformName,'Visible'); |
---|
1349 | if isequal(menu_coord_state,'on') |
---|
1350 | menu_index=get(handles.TransformName,'Value'); |
---|
1351 | transform_list=get(handles.TransformName,'UserData'); |
---|
1352 | Series.FieldTransform.TransformHandle=transform_list{menu_index};% transform function handles |
---|
1353 | end |
---|
1354 | |
---|
1355 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
1356 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1357 | |
---|
1358 | %% projection object |
---|
1359 | if isfield(Series,'CheckObject') |
---|
1360 | if Series.CheckObject |
---|
1361 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
1362 | Series.ProjObject=read_GUI(hset_object); |
---|
1363 | GetObject_Callback([], [], handles) |
---|
1364 | end |
---|
1365 | else |
---|
1366 | Series.CheckObject=0; |
---|
1367 | end |
---|
1368 | |
---|
1369 | %% get_field GUI |
---|
1370 | if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field') |
---|
1371 | if strcmp(Series.InputFields.Field,'get_field...') |
---|
1372 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1373 | Series.GetField=read_GUI(hget_field); |
---|
1374 | end |
---|
1375 | end |
---|
1376 | |
---|
1377 | %% defining the ActionName function handle |
---|
1378 | list_action=get(handles.ActionName,'String');% list menu action |
---|
1379 | index=get(handles.ActionName,'Value'); |
---|
1380 | action= list_action{index}; % selected string |
---|
1381 | Series.Action=action;%name of the processing programme |
---|
1382 | Series.hseries=handles.series; % handles to the series GUI |
---|
1383 | path_series=which('series'); |
---|
1384 | list_path=get(handles.ActionName,'UserData'); |
---|
1385 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
1386 | if ~isequal(fct_path,path_series) |
---|
1387 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
1388 | if ~exist(fct_path,'dir') |
---|
1389 | errormsg=['The prescibed function path ' fct_path ' does not exist']; |
---|
1390 | return |
---|
1391 | end |
---|
1392 | if ~isequal(spath,fct_path) |
---|
1393 | addpath(fct_path)% add the prescribed path if not the current one |
---|
1394 | end |
---|
1395 | end |
---|
1396 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
1397 | if ~isequal(fct_path,path_series) |
---|
1398 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
1399 | end |
---|
1400 | |
---|
1401 | %% create the output data directory and write in it the xml file from the GUI config |
---|
1402 | %determine the root file corresponding to the first sub dir |
---|
1403 | if isfield(Series,'OutputSubDir') |
---|
1404 | SubDirOut=[Series.OutputSubDir Series.OutputDirExt]; |
---|
1405 | SubDirOutNew=SubDirOut; |
---|
1406 | iview=1; |
---|
1407 | SeriesData=get(handles.series,'UserData'); |
---|
1408 | if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && isfield(SeriesData.AllowInputSort) |
---|
1409 | [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
1410 | Series.InputTable=Series.InputTable(iview,:); |
---|
1411 | end |
---|
1412 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'file')==2;% test if the dir already exist |
---|
1413 | while detect |
---|
1414 | r=regexp(SubDirOut,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
1415 | if isempty(r) |
---|
1416 | r(1).root=[SubDirOut '_']; |
---|
1417 | r(1).num1='0'; |
---|
1418 | end |
---|
1419 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
1420 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'file')==2;% test if the dir already exists |
---|
1421 | end |
---|
1422 | Series.OutputSubDir=SubDirOutNew; |
---|
1423 | Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results |
---|
1424 | Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output |
---|
1425 | Series=rmfield(Series,'OutputDirExt');%removes redondant information |
---|
1426 | % create output directory |
---|
1427 | answer='No'; |
---|
1428 | if exist(Series.OutputDir,'dir') |
---|
1429 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' Series.OutputDir ', possibly delete previous data']); |
---|
1430 | end |
---|
1431 | if ~isequal(answer,'Yes') |
---|
1432 | [tild,msg1]=mkdir(Series.OutputDir); |
---|
1433 | if ~strcmp(msg1,'') |
---|
1434 | errormsg=['cannot create ' Series.OutputDir ': ' msg1];%error message for directory creation |
---|
1435 | return |
---|
1436 | end |
---|
1437 | end |
---|
1438 | filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory |
---|
1439 | t=struct2xml(Series); |
---|
1440 | save(t,filexml); |
---|
1441 | end |
---|
1442 | |
---|
1443 | %------------------------------------------------------------------------ |
---|
1444 | % --- Executes on selection change in ActionName. |
---|
1445 | function ActionName_Callback(hObject, eventdata, handles) |
---|
1446 | %------------------------------------------------------------------------ |
---|
1447 | global nb_builtin_ACTION |
---|
1448 | list_ACTION=get(handles.ActionName,'String');% list menu fields |
---|
1449 | index_ACTION=get(handles.ActionName,'Value');% selected string index |
---|
1450 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
1451 | path_series=which('series');%path to series.m |
---|
1452 | list_path=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ACTION |
---|
1453 | default_file=fullfile(list_path{end},ACTION); |
---|
1454 | % add a new function to the menu if the selected item is 'more...' |
---|
1455 | if isequal(ACTION,'more...') |
---|
1456 | pathfct=fileparts(path_series); |
---|
1457 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1458 | {'*.m', ' (*.m)'; |
---|
1459 | '*.m', '.m files '; ... |
---|
1460 | '*.*', 'All Files (*.*)'}, ... |
---|
1461 | 'Pick a file',default_file); |
---|
1462 | if length(FileName)<2 |
---|
1463 | return |
---|
1464 | end |
---|
1465 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
1466 | if ~isequal(ext_fct,'.m') |
---|
1467 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1468 | return |
---|
1469 | end |
---|
1470 | |
---|
1471 | % insert the choice in the actionname menu |
---|
1472 | menu_str=update_menu(handles.ActionName,ACTION);%new action menu in which the new item has been appended if needed |
---|
1473 | index_ACTION=get(handles.ActionName,'Value');% currently selected index in the list |
---|
1474 | list_path{index_ACTION}=PathName; |
---|
1475 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1476 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
1477 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
1478 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
1479 | index_ACTION=index_ACTION-nbremove; |
---|
1480 | set(handles.ActionName,'Value',index_ACTION) |
---|
1481 | set(handles.ActionName,'String',menu_str) |
---|
1482 | end |
---|
1483 | list_path{index_ACTION}=PathName; |
---|
1484 | set(handles.ActionName,'UserData',list_path); |
---|
1485 | set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
1486 | |
---|
1487 | %record the current menu in personal file profil_perso |
---|
1488 | dir_perso=prefdir; |
---|
1489 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1490 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
1491 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
1492 | end |
---|
1493 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
1494 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
1495 | save(profil_perso,'series_fct','-append') |
---|
1496 | else |
---|
1497 | txt=ver('MATLAB'); |
---|
1498 | Release=txt.Release; |
---|
1499 | relnumb=str2num(Release(3:4)); |
---|
1500 | if relnumb >= 14%recent relaese of Matlab |
---|
1501 | save(profil_perso,'series_fct','-V6') |
---|
1502 | else |
---|
1503 | save(profil_perso, 'series_fct') |
---|
1504 | end |
---|
1505 | end |
---|
1506 | end |
---|
1507 | end |
---|
1508 | |
---|
1509 | %check the current ActionPath to the selected function |
---|
1510 | PathName=list_path{index_ACTION};%current recorded path |
---|
1511 | set(handles.ActionPath,'String',PathName); %show the path to the senlected function |
---|
1512 | |
---|
1513 | %default setting for the visibility of the GUI elements |
---|
1514 | set(handles.num_NbSlice,'Visible','off') |
---|
1515 | set(handles.NbSlice_title,'Visible','off') |
---|
1516 | set(handles.VelType,'Visible','off'); |
---|
1517 | set(handles.VelType_text,'Visible','off'); |
---|
1518 | set(handles.VelType_1,'Visible','off'); |
---|
1519 | set(handles.VelType_text_1,'Visible','off'); |
---|
1520 | view_FieldMenu(handles,'off') |
---|
1521 | view_FieldMenu_1(handles,'off') |
---|
1522 | set(handles.FieldTransform,'Visible','off') |
---|
1523 | set(handles.CheckObject,'Visible','off'); |
---|
1524 | set(handles.ProjObject,'Visible','off'); |
---|
1525 | set(handles.CheckMask,'Visible','off') |
---|
1526 | set(handles.Mask,'Visible','off') |
---|
1527 | % set(handles.OutputDirExt,'Visible','off'); |
---|
1528 | set(handles.ParamKey,'Visible','off') |
---|
1529 | set(handles.ParamVal,'Visible','off') |
---|
1530 | ParamKey={}; |
---|
1531 | set(handles.FieldName,'Enable','off') |
---|
1532 | set(handles.VelType,'Enable','off') |
---|
1533 | set(handles.FieldName_1,'Enable','off') |
---|
1534 | set(handles.VelType_1,'Enable','off') |
---|
1535 | set(handles.TransformName,'Enable','off') |
---|
1536 | set(handles.OutputDirExt,'Visible','off') |
---|
1537 | set(handles.OutputSubDir,'Visible','off') |
---|
1538 | set(handles.OutputDir_title,'Visible','off') |
---|
1539 | %set the displayed GUI item needed for input parameters |
---|
1540 | if ~isequal(path_series,PathName) |
---|
1541 | addpath(PathName) |
---|
1542 | end |
---|
1543 | eval(['h_function=@' ACTION ';']); |
---|
1544 | try |
---|
1545 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
1546 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
1547 | fclose(fid) |
---|
1548 | set(handles.ActionName,'ToolTipString',InputText{1}{1}) |
---|
1549 | end |
---|
1550 | if ~isequal(path_series,PathName) |
---|
1551 | rmpath(PathName) |
---|
1552 | end |
---|
1553 | varargout=h_function(); |
---|
1554 | Param_list={}; |
---|
1555 | |
---|
1556 | InputTable=get(handles.InputTable,'Data'); |
---|
1557 | nb_series=size(InputTable,1); |
---|
1558 | testima_series=1; %test for a list of images only |
---|
1559 | testima=1; |
---|
1560 | testima_1=1; |
---|
1561 | testciv_series=1; |
---|
1562 | for iview=1:nb_series |
---|
1563 | ext=InputTable{iview,5}; |
---|
1564 | if length(ext)<2 |
---|
1565 | ext='.none'; |
---|
1566 | end |
---|
1567 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
1568 | if ~testimaview |
---|
1569 | if iview==1 |
---|
1570 | testima=0; |
---|
1571 | end |
---|
1572 | if iview==2 |
---|
1573 | testima_1=0; |
---|
1574 | end |
---|
1575 | testima_series=0; |
---|
1576 | end |
---|
1577 | end |
---|
1578 | for ilist=1:length(varargout)-1 |
---|
1579 | switch varargout{ilist} |
---|
1580 | case 'NbViewMax' |
---|
1581 | if ~isempty (varargout{ilist+1}) |
---|
1582 | if size(InputTable,1)>varargout{ilist+1} |
---|
1583 | InputTable=InputTable(1:varargout{ilist+1},:); |
---|
1584 | set(handles.InputTable,'Data',InputTable) |
---|
1585 | end |
---|
1586 | end |
---|
1587 | case 'AllowInputSort' |
---|
1588 | if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir |
---|
1589 | SeriesData=get(handles.series,'UserData'); |
---|
1590 | SeriesData.AllowInputSort=1; |
---|
1591 | set(handles.series,'UserData',SeriesData) |
---|
1592 | end |
---|
1593 | case 'NbSlice' %hidden by default |
---|
1594 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1595 | set(handles.num_NbSlice,'Visible','on') |
---|
1596 | set(handles.NbSlice_title,'Visible','on') |
---|
1597 | end |
---|
1598 | case 'VelType' %hidden by default |
---|
1599 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
1600 | set(handles.VelType,'Enable','on') |
---|
1601 | if nb_series >=1 && ~testima_series |
---|
1602 | set(handles.VelType,'Visible','on') |
---|
1603 | set(handles.VelType_text,'Visible','on'); |
---|
1604 | end |
---|
1605 | end |
---|
1606 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1607 | set(handles.VelType_1,'Enable','on') |
---|
1608 | if nb_series >=2 && ~testima_series |
---|
1609 | set(handles.VelType_1,'Visible','on') |
---|
1610 | set(handles.VelType_text_1,'Visible','on'); |
---|
1611 | end |
---|
1612 | end |
---|
1613 | case 'FieldName' %hidden by default |
---|
1614 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
1615 | set(handles.FieldName,'Enable','on') % test for MenuBorser |
---|
1616 | if nb_series >=1 && ~testima_series |
---|
1617 | view_FieldMenu(handles,'on') |
---|
1618 | end |
---|
1619 | end |
---|
1620 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1621 | set(handles.FieldName_1,'Enable','on') |
---|
1622 | if nb_series >=2 && ~testima_1 |
---|
1623 | view_FieldMenu_1(handles,'on') |
---|
1624 | end |
---|
1625 | end |
---|
1626 | case 'FieldTransform' %hidden by default |
---|
1627 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1628 | set(handles.TransformName,'Enable','on') |
---|
1629 | set(handles.FieldTransform,'Visible','on') |
---|
1630 | end |
---|
1631 | case 'ProjObject' %hidden by default |
---|
1632 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1633 | set(handles.CheckObject,'Visible','on') |
---|
1634 | set(handles.ProjObject,'Visible','on') |
---|
1635 | end |
---|
1636 | case 'Mask' %hidden by default |
---|
1637 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1638 | set(handles.Mask,'Visible','on') |
---|
1639 | set(handles.CheckMask,'Visible','on'); |
---|
1640 | end |
---|
1641 | case 'PARAMETER' % NOT USED |
---|
1642 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
1643 | set(handles.PARAMETERS_title,'Visible','on') |
---|
1644 | set(handles.ParamKey,'Visible','on') |
---|
1645 | %set(handles.ParamVal,'Visible','on') |
---|
1646 | Param_str=varargout{ilist+1}; |
---|
1647 | Param_list=[Param_list; {Param_str}]; |
---|
1648 | case 'OutputDirExt' |
---|
1649 | if ~isempty(varargout{ilist+1}) |
---|
1650 | set(handles.OutputDirExt,'String',varargout{ilist+1}) |
---|
1651 | set(handles.OutputDirExt,'Visible','on') |
---|
1652 | set(handles.OutputSubDir,'Visible','on') |
---|
1653 | set(handles.OutputDir_title,'Visible','on') |
---|
1654 | end |
---|
1655 | end |
---|
1656 | end |
---|
1657 | if ~isempty(Param_list) |
---|
1658 | set(handles.ParamKey,'String',Param_list) |
---|
1659 | set(handles.ParamVal,'Visible','on') |
---|
1660 | end |
---|
1661 | |
---|
1662 | %------------------------------------------------------------------------ |
---|
1663 | % --- Executes on selection change in FieldName. |
---|
1664 | function FieldName_Callback(hObject, eventdata, handles) |
---|
1665 | %------------------------------------------------------------------------ |
---|
1666 | field_str=get(handles.FieldName,'String'); |
---|
1667 | field_index=get(handles.FieldName,'Value'); |
---|
1668 | field=field_str{field_index(1)}; |
---|
1669 | if isequal(field,'get_field...') |
---|
1670 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1671 | if ~isempty(hget_field) |
---|
1672 | delete(hget_field)%delete opened versions of get_field |
---|
1673 | end |
---|
1674 | [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(read_GUI(handles.series)); |
---|
1675 | if exist(filecell{1,1},'file') |
---|
1676 | get_field(filecell{1,1}) |
---|
1677 | end |
---|
1678 | elseif isequal(field,'more...') |
---|
1679 | str=calc_field; |
---|
1680 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1681 | 'SelectionMode','single',... |
---|
1682 | 'ListString',str); |
---|
1683 | % edit the choice in the fields and actionname menu |
---|
1684 | scalar=cell2mat(str(ind_answer)); |
---|
1685 | update_menu(handles.FieldName,scalar) |
---|
1686 | end |
---|
1687 | |
---|
1688 | %------------------------------------------------------------------------ |
---|
1689 | % --- Executes on selection change in FieldName_1. |
---|
1690 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
1691 | %------------------------------------------------------------------------ |
---|
1692 | field_str=get(handles.FieldName_1,'String'); |
---|
1693 | field_index=get(handles.FieldName_1,'Value'); |
---|
1694 | field=field_str{field_index}; |
---|
1695 | if isequal(field,'get_field...') |
---|
1696 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
1697 | if ~isempty(hget_field) |
---|
1698 | delete(hget_field) |
---|
1699 | end |
---|
1700 | SeriesData=get(handles.series,'UserData'); |
---|
1701 | filename=SeriesData.CurrentInputFile_1; |
---|
1702 | if exist(filename,'file') |
---|
1703 | hget_field=get_field(filename); |
---|
1704 | set(hget_field,'name','get_field_1') |
---|
1705 | end |
---|
1706 | elseif isequal(field,'more...') |
---|
1707 | str=calc_field; |
---|
1708 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1709 | 'SelectionMode','single',... |
---|
1710 | 'ListString',str); |
---|
1711 | % edit the choice in the fields and actionname menu |
---|
1712 | scalar=cell2mat(str(ind_answer)); |
---|
1713 | update_menu(handles.FieldName_1,scalar) |
---|
1714 | end |
---|
1715 | |
---|
1716 | |
---|
1717 | %%%%%%%%%%%%% |
---|
1718 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
1719 | indsel=ind_i; |
---|
1720 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
1721 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
1722 | if ~isempty(indiff) |
---|
1723 | indiff2=diff(indiff); |
---|
1724 | indiffp=[indiff2 1]; |
---|
1725 | indiffm=[1 indiff2]; |
---|
1726 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
1727 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
1728 | %for each multiplet, select the most recent file |
---|
1729 | ind_remove=[]; |
---|
1730 | for i=1:length(ind_multi_m) |
---|
1731 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
1732 | for imulti=1:length(ind_pairs) |
---|
1733 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
1734 | end |
---|
1735 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
1736 | ind_s=indsort2(1:end-1);% |
---|
1737 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
1738 | end |
---|
1739 | end |
---|
1740 | |
---|
1741 | %------------------------------------------------------------------------ |
---|
1742 | % --- determine the list of index pairstring of processing file |
---|
1743 | 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) |
---|
1744 | %------------------------------------------------------------------------ |
---|
1745 | num_i1=num_i;% set of first image numbers by default |
---|
1746 | num_i2=num_i; |
---|
1747 | num_j1=num_j; |
---|
1748 | num_j2=num_j; |
---|
1749 | num_i_out=num_i; |
---|
1750 | num_j_out=num_j; |
---|
1751 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
1752 | if isequal(mode,'series(Di)') |
---|
1753 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
1754 | num_i2_line=num_i+ind_shift(4); |
---|
1755 | % adjust the first and last field number |
---|
1756 | indsel=find(num_i1_line >= 1); |
---|
1757 | num_i_out=num_i(indsel); |
---|
1758 | num_i1_line=num_i1_line(indsel); |
---|
1759 | num_i2_line=num_i2_line(indsel); |
---|
1760 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1761 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1762 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
1763 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
1764 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
1765 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
1766 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
1767 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
1768 | else |
---|
1769 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
1770 | num_j2_col=num_j+ind_shift(2); |
---|
1771 | % adjust the first field number |
---|
1772 | indsel=find((num_j1_col >= 1)); |
---|
1773 | num_j_out=num_j(indsel); |
---|
1774 | num_j1_col=num_j1_col(indsel); |
---|
1775 | num_j2_col=num_j2_col(indsel); |
---|
1776 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
1777 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
1778 | end |
---|
1779 | end |
---|
1780 | |
---|
1781 | %------------------------------------------------------------------------ |
---|
1782 | % --- Executes on button press in CheckObject. |
---|
1783 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
1784 | %------------------------------------------------------------------------ |
---|
1785 | % SeriesData=get(handles.series,'UserData'); |
---|
1786 | value=get(handles.CheckObject,'Value'); |
---|
1787 | if value |
---|
1788 | set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
1789 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
1790 | if ishandle(hset_object) |
---|
1791 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
1792 | else |
---|
1793 | %get the object file |
---|
1794 | InputTable=get(handles.InputTable,'Data'); |
---|
1795 | defaultname=InputTable{1,1}; |
---|
1796 | if isempty(defaultname) |
---|
1797 | defaultname={''}; |
---|
1798 | end |
---|
1799 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1800 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
1801 | '*.xml', '.xml files '; ... |
---|
1802 | '*.mat', '.mat matlab files '}, ... |
---|
1803 | 'Pick an xml object file (or use uvmat to create it)',defaultname); |
---|
1804 | fileinput=[PathName FileName];%complete file name |
---|
1805 | sizf=size(fileinput); |
---|
1806 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
1807 | %read the file |
---|
1808 | data=xml2struct(fileinput); |
---|
1809 | if ~isfield(data,'Type') |
---|
1810 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
1811 | return |
---|
1812 | end |
---|
1813 | if ~isfield(data,'ProjMode') |
---|
1814 | data.ProjMode='none'; |
---|
1815 | end |
---|
1816 | hset_object=set_object(data);% call the set_object interface |
---|
1817 | end |
---|
1818 | Object=read_GUI(hset_object); |
---|
1819 | set(handles.ProjObject,'String',Object.Name);%display the object name |
---|
1820 | else |
---|
1821 | set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
1822 | end |
---|
1823 | %set(handles.series,'UserData',SeriesData) |
---|
1824 | |
---|
1825 | %-------------------------------------------------------------- |
---|
1826 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1827 | value=get(handles.CheckMask,'Value'); |
---|
1828 | if value |
---|
1829 | msgbox_uvmat('ERROR','not implemented yet') |
---|
1830 | end |
---|
1831 | %-------------------------------------------------------------- |
---|
1832 | |
---|
1833 | %------------------------------------------------------------------- |
---|
1834 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
1835 | function ncbrowser_uvmat(hObject, eventdata) |
---|
1836 | %------------------------------------------------------------------- |
---|
1837 | bla=get(gcbo,'String'); |
---|
1838 | ind=get(gcbo,'Value'); |
---|
1839 | filename=cell2mat(bla(ind)); |
---|
1840 | blank=find(filename==' '); |
---|
1841 | filename=filename(1:blank-1); |
---|
1842 | get_field(filename) |
---|
1843 | |
---|
1844 | % ------------------------------------------------------------------ |
---|
1845 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
1846 | %------------------------------------------------------------------- |
---|
1847 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
1848 | pathelp=fileparts(path_to_uvmat); |
---|
1849 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
1850 | 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') |
---|
1851 | else |
---|
1852 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
1853 | web([helpfile '#series']) |
---|
1854 | end |
---|
1855 | |
---|
1856 | %------------------------------------------------------------------- |
---|
1857 | % --- Executes on selection change in TransformName. |
---|
1858 | function TransformName_Callback(hObject, eventdata, handles) |
---|
1859 | %------------------------------------------------------------------- |
---|
1860 | global nb_transform |
---|
1861 | |
---|
1862 | menu=get(handles.TransformName,'String'); |
---|
1863 | ind_coord=get(handles.TransformName,'Value'); |
---|
1864 | coord_option=menu{ind_coord}; |
---|
1865 | list_transform=get(handles.TransformName,'UserData'); |
---|
1866 | ff=functions(list_transform{end}); |
---|
1867 | if isequal(coord_option,'more...'); |
---|
1868 | coord_fct=''; |
---|
1869 | prompt = {'Enter the name of the transform function'}; |
---|
1870 | dlg_title = 'user defined transform'; |
---|
1871 | num_lines= 1; |
---|
1872 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1873 | {'*.m', ' (*.m)'; |
---|
1874 | '*.m', '.m files '; ... |
---|
1875 | '*.*', 'All Files (*.*)'}, ... |
---|
1876 | 'Pick a file', ff.file); |
---|
1877 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
1878 | PathName(end)=[]; |
---|
1879 | end |
---|
1880 | transform_selected =fullfile(PathName,FileName); |
---|
1881 | if ~exist(transform_selected,'file') |
---|
1882 | return |
---|
1883 | end |
---|
1884 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
1885 | if ~isequal(ext_fct,'.m') |
---|
1886 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1887 | return |
---|
1888 | end |
---|
1889 | menu=update_menu(handles.TransformName,transform);%add the selected fct to the menu |
---|
1890 | ind_coord=get(handles.TransformName,'Value'); |
---|
1891 | addpath(PathName) |
---|
1892 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
1893 | set(handles.TransformName,'UserData',list_transform) |
---|
1894 | rmpath(PathName) |
---|
1895 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
1896 | dir_perso=prefdir;%personal Matalb directory |
---|
1897 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1898 | if exist(profil_perso,'file') |
---|
1899 | for ilist=nb_transform+1:numel(list_transform) |
---|
1900 | ff=functions(list_transform{ilist}); |
---|
1901 | transform_fct{ilist-nb_transform}=ff.file; |
---|
1902 | end |
---|
1903 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
1904 | end |
---|
1905 | end |
---|
1906 | |
---|
1907 | %check the current ActionPath to the selected function |
---|
1908 | if ~isempty(list_transform{ind_coord}) |
---|
1909 | func=functions(list_transform{ind_coord}); |
---|
1910 | set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function |
---|
1911 | else |
---|
1912 | set(handles.TransformPath,'String',''); %show the path to the senlected function |
---|
1913 | end |
---|
1914 | |
---|
1915 | % %------------------------------------------------------------------------ |
---|
1916 | % % --- Executes on button press in REFRESH_INDICES. |
---|
1917 | % function REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
1918 | % %------------------------------------------------------------------------ |
---|
1919 | % % hObject handle to REFRESH_INDICES (see GCBO) |
---|
1920 | % % eventdata reserved - to be defined in a future version of MATLAB |
---|
1921 | % % handles structure with handles and user data (see GUIDATA) |
---|
1922 | % set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1923 | % InputTable=get(handles.InputTable,'Data'); |
---|
1924 | % check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
1925 | % |
---|
1926 | % %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
1927 | % for ind_list=1:length(check_lines) |
---|
1928 | % if check_lines(ind_list) |
---|
1929 | % InputLine=InputTable(ind_list,:); |
---|
1930 | % detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
1931 | % detect_idem=detect_idem(detect_idem>0); |
---|
1932 | % if ~isempty (detect_idem) |
---|
1933 | % InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
1934 | % set(handles.InputTable,'Data',InputTable) |
---|
1935 | % end |
---|
1936 | % fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
1937 | % %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
1938 | % %update file series defined by the selected line |
---|
1939 | % [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
1940 | % if ~isempty(errormsg) |
---|
1941 | % msgbox_uvmat('ERROR',errormsg) |
---|
1942 | % return |
---|
1943 | % end |
---|
1944 | % end |
---|
1945 | % end |
---|
1946 | % set(handles.InputTable,'Data',InputTable) |
---|
1947 | % SeriesData=get(handles.series,'UserData'); |
---|
1948 | % |
---|
1949 | % state_j='off'; |
---|
1950 | % state_Pairs='off'; |
---|
1951 | % state_InputFields='off'; |
---|
1952 | % val=get(handles.ListView,'Value'); |
---|
1953 | % ListViewString={''}; |
---|
1954 | % if ~isempty(SeriesData) |
---|
1955 | % % ListViewString={}; |
---|
1956 | % for iview=1:size(InputTable,1) |
---|
1957 | % if ~isempty(SeriesData.j1_series{iview}) |
---|
1958 | % state_j='on'; |
---|
1959 | % end |
---|
1960 | % if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
1961 | % state_Pairs='on'; |
---|
1962 | % ListViewString{iview}=num2str(iview); |
---|
1963 | % if check_lines(iview) |
---|
1964 | % val=iview;%select the last pair if it is a new entry |
---|
1965 | % end |
---|
1966 | % end |
---|
1967 | % if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
1968 | % state_InputFields='on'; |
---|
1969 | % end |
---|
1970 | % end |
---|
1971 | % end |
---|
1972 | % set(handles.ListView,'Value',val) |
---|
1973 | % set(handles.ListView,'String',ListViewString) |
---|
1974 | % if strcmp(state_Pairs,'on') |
---|
1975 | % ListView_Callback(hObject,eventdata,handles) |
---|
1976 | % end |
---|
1977 | % set(handles.PairString,'Visible',state_Pairs) |
---|
1978 | % enable_j(handles,state_j) |
---|
1979 | % set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0]) |
---|
1980 | % set(handles.REFRESH_INDICES,'visible','off') |
---|
1981 | |
---|
1982 | % ----------------------------------------------------------------------- |
---|
1983 | % --- Update min and max indices of a file series by scanning with find_file_series |
---|
1984 | % --- which also changes the root file and NomType in case of movie. Also adjust the string representation of indices (e.g; |
---|
1985 | % --- 1 or 001 by the function find_file_series |
---|
1986 | % --- This function also dispaly the set of availbale files in the series |
---|
1987 | % --- and the menus appropriate to the file type as well as timing possibly set |
---|
1988 | % --- by an xml image documentation file |
---|
1989 | function [RootFile,NomType,errormsg]=update_indices(handles,fileinput,iview) |
---|
1990 | % ----------------------------------------------------------------------- |
---|
1991 | %% look for min and max indices existing in the file series and update SeriesData |
---|
1992 | errormsg=''; |
---|
1993 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
1994 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
1995 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
1996 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
1997 | if isempty(RootFile)&&isempty(i1_series) |
---|
1998 | errormsg='no input file in the series'; |
---|
1999 | return |
---|
2000 | end |
---|
2001 | |
---|
2002 | %% adjust the min and max indices common to all the file series |
---|
2003 | MinIndex=get(handles.MinIndex,'Data'); |
---|
2004 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
2005 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
2006 | if ~isempty(i2_series) |
---|
2007 | MaxIndex_i=max(i2_series(i2_series>0)); |
---|
2008 | else |
---|
2009 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
2010 | end |
---|
2011 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
2012 | if ~isempty(j2_series) |
---|
2013 | MaxIndex_j=max(j2_series(j2_series>0)); |
---|
2014 | else |
---|
2015 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
2016 | end |
---|
2017 | MinIndex{iview,1}=MinIndex_i; |
---|
2018 | MinIndex{iview,2}=MinIndex_j; |
---|
2019 | MaxIndex{iview,1}=MaxIndex_i; |
---|
2020 | MaxIndex{iview,2}=MaxIndex_j; |
---|
2021 | set(handles.MinIndex,'Data',MinIndex) |
---|
2022 | set(handles.MaxIndex,'Data',MaxIndex) |
---|
2023 | SeriesData=get(handles.series,'UserData'); |
---|
2024 | SeriesData.i1_series{iview}=i1_series; |
---|
2025 | SeriesData.i2_series{iview}=i2_series; |
---|
2026 | SeriesData.j1_series{iview}=j1_series; |
---|
2027 | SeriesData.j2_series{iview}=j2_series; |
---|
2028 | SeriesData.FileType{iview}=FileType; |
---|
2029 | |
---|
2030 | %% display the set of existing files as an image |
---|
2031 | set(handles.waitbar_frame,'Units','pixels') |
---|
2032 | pos=get(handles.waitbar_frame,'Position'); |
---|
2033 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
2034 | yima=0.5:pos(4)-0.5; |
---|
2035 | [XIma,YIma]=meshgrid(xima,yima); |
---|
2036 | nb_i=size(i1_series,1); |
---|
2037 | nb_j=size(i1_series,2); |
---|
2038 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
2039 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
2040 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
2041 | CData=zeros([size(XIma) 3]); |
---|
2042 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
2043 | if numel(file_ima)>=2 |
---|
2044 | if size(file_ima,1)==1 |
---|
2045 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
2046 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
2047 | else |
---|
2048 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
2049 | end |
---|
2050 | set(handles.waitbar_frame,'CData',CData) |
---|
2051 | end |
---|
2052 | set(handles.waitbar_frame,'Units','normalized') |
---|
2053 | |
---|
2054 | %% enable field and veltype menus |
---|
2055 | testfield=isequal(get(handles.FieldName,'enable'),'on'); |
---|
2056 | testfield_1=isequal(get(handles.FieldName_1,'enable'),'on'); |
---|
2057 | testveltype=isequal(get(handles.VelType,'enable'),'on'); |
---|
2058 | testveltype_1=isequal(get(handles.VelType_1,'enable'),'on'); |
---|
2059 | testtransform=isequal(get(handles.TransformName,'Enable'),'on'); |
---|
2060 | % testnc=0; |
---|
2061 | % testnc_1=0; |
---|
2062 | % testcivx=0; |
---|
2063 | % testcivx_1=0; |
---|
2064 | % testima=0; %test for image input |
---|
2065 | % if isequal(lower(FileExt),'.avi') %.avi file |
---|
2066 | % testima=1; |
---|
2067 | % elseif ~isempty(imformats(FileExt(2:end))) |
---|
2068 | % testima=1; |
---|
2069 | % elseif isequal(FileExt,'.vol') |
---|
2070 | % testima=1; |
---|
2071 | % end |
---|
2072 | %TODO: update |
---|
2073 | % if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
2074 | % for iview=1:length(FileExtCell) |
---|
2075 | % if isequal(FileExtCell{iview},'.nc') |
---|
2076 | % testnc=1; |
---|
2077 | % end |
---|
2078 | % if isequal(FileTypeCell{iview},'civx') |
---|
2079 | % testcivx=1; |
---|
2080 | % end |
---|
2081 | % end |
---|
2082 | % elseif length(FileExtCell)==2 |
---|
2083 | % testnc=isequal(FileExtCell{1},'.nc'); |
---|
2084 | % testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
2085 | % testcivx=isequal(FileTypeCell{1},'civx'); |
---|
2086 | % testcivx_1=isequal(FileTypeCell{2},'civx'); |
---|
2087 | % end |
---|
2088 | switch FileType |
---|
2089 | case {'civx','civdata'} |
---|
2090 | view_FieldMenu(handles,'on') |
---|
2091 | menustr=get(handles.FieldName,'String'); |
---|
2092 | if isequal(menustr,{'get_field...'}) |
---|
2093 | set(handles.FieldName,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
2094 | end |
---|
2095 | set(handles.VelType,'Visible','on') |
---|
2096 | set(handles.FieldTransform,'Visible','on') |
---|
2097 | % view_TRANSFORM(handles,'on') |
---|
2098 | % TODO: second menu |
---|
2099 | % view_FieldMenu_1(handles,'on') |
---|
2100 | % if testcivx_1 |
---|
2101 | % menustr=get(handles.FieldName_1,'String'); |
---|
2102 | % if isequal(menustr,{'get_field...'}) |
---|
2103 | % set(handles.FieldName_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
2104 | % end |
---|
2105 | % else |
---|
2106 | % set(handles.FieldName_1,'Value',1) |
---|
2107 | % set(handles.FieldName_1,'String',{'get_field...'}) |
---|
2108 | % set(handles.VelType_1,'Visible','on') |
---|
2109 | % set(handles.VelType_text_1,'Visible','on'); |
---|
2110 | % end |
---|
2111 | % view_FieldMenu_1(handles,'off') |
---|
2112 | case 'netcdf' |
---|
2113 | view_FieldMenu(handles,'on') |
---|
2114 | set(handles.FieldName,'Value',1) |
---|
2115 | set(handles.FieldName,'String',{'get_field...'}) |
---|
2116 | set(handles.FieldTransform,'Visible','off') |
---|
2117 | % view_TRANSFORM(handles,'off') |
---|
2118 | case {'image','multimage','video'} |
---|
2119 | view_FieldMenu(handles,'off') |
---|
2120 | view_FieldMenu_1(handles,'off') |
---|
2121 | set(handles.VelType,'Visible','off') |
---|
2122 | set(handles.VelType_text,'Visible','off'); |
---|
2123 | end |
---|
2124 | |
---|
2125 | |
---|
2126 | %TODO:update |
---|
2127 | % if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima |
---|
2128 | % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt]) |
---|
2129 | % return |
---|
2130 | % end |
---|
2131 | |
---|
2132 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2133 | ext_imadoc=''; |
---|
2134 | FileBase=fullfile(RootPath,RootFile); |
---|
2135 | if isequal(FileExt,'.xml')||isequal(FileExt,'.civ') |
---|
2136 | ext_imadoc=FileExt; |
---|
2137 | elseif exist([FileBase '.xml'],'file') |
---|
2138 | ext_imadoc='.xml'; |
---|
2139 | elseif exist([FileBase '.civ'],'file') |
---|
2140 | ext_imadoc='.civ'; |
---|
2141 | end |
---|
2142 | %read the ImaDoc file |
---|
2143 | XmlData=[]; |
---|
2144 | NbSlice_calib={}; |
---|
2145 | if isequal(ext_imadoc,'.xml') |
---|
2146 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
2147 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
2148 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
2149 | end |
---|
2150 | if isfield(XmlData,'Time') |
---|
2151 | time{iview}=XmlData.Time; |
---|
2152 | end |
---|
2153 | if isfield(XmlData,'Camera') |
---|
2154 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
2155 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
2156 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
2157 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
2158 | end |
---|
2159 | end |
---|
2160 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
2161 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
2162 | end |
---|
2163 | end |
---|
2164 | if ~isempty(warntext) |
---|
2165 | msgbox_uvmat('WARNING',warntext) |
---|
2166 | end |
---|
2167 | elseif isequal(ext_imadoc,'.civ') |
---|
2168 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
2169 | time{iview}=XmlData.Time; |
---|
2170 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
2171 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
2172 | end |
---|
2173 | end |
---|
2174 | |
---|
2175 | %% update time table |
---|
2176 | TimeTable=get(handles.TimeTable,'Data'); |
---|
2177 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
2178 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
2179 | set(handles.TimeTable,'Data',TimeTable) |
---|
2180 | |
---|
2181 | %% number of slices |
---|
2182 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
2183 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
2184 | if siz(1)>1 |
---|
2185 | NbSlice=siz(1); |
---|
2186 | else |
---|
2187 | NbSlice=1; |
---|
2188 | end |
---|
2189 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
2190 | end |
---|
2191 | % set(handles.mode,'Visible','off') % do not show index pairstring by default |
---|
2192 | set(handles.PairString,'Visible','off') |
---|
2193 | % set(handles.num_ref_i,'Visible','off') |
---|
2194 | % set(handles.ref_i_text,'Visible','off') |
---|
2195 | testpair=0; |
---|
2196 | %set the menus of image pairstring and default selection for series |
---|
2197 | %list pairstring if relevant |
---|
2198 | % Val=get(handles.NomType,'Value'); |
---|
2199 | % synchronise_view(handles,Val) |
---|
2200 | |
---|
2201 | % if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{index}) |
---|
2202 | % state_j='off'; %no need for j index |
---|
2203 | % else |
---|
2204 | % state_j='on'; %case of j index |
---|
2205 | % end |
---|
2206 | % show index pairstring if files exist |
---|
2207 | set(handles.series,'UserData',SeriesData) |
---|
2208 | |
---|
2209 | |
---|
2210 | % -------------------------------------------------------------------- |
---|
2211 | function MenuExportConfig_Callback(hObject, eventdata, handles) |
---|
2212 | global Series |
---|
2213 | [tild,Series,errormsg]=prepare_jobs(handles); |
---|
2214 | % Series=read_GUI(handles.series); |
---|
2215 | |
---|
2216 | evalin('base','global Series')%make CurData global in the workspace |
---|
2217 | display('current series config :') |
---|
2218 | evalin('base','Series') %display CurData in the workspace |
---|
2219 | commandwindow; %brings the Matlab command window to the front |
---|