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 | |
---|
63 | % Choose default command line output for series |
---|
64 | handles.output = hObject; |
---|
65 | % Update handles structure |
---|
66 | guidata(hObject, handles); |
---|
67 | |
---|
68 | %% initial settings |
---|
69 | % position and size of the GUI at opening |
---|
70 | set(0,'Unit','points') |
---|
71 | ScreenSize=get(0,'ScreenSize');%size of the current screen, in points (1/72 inch) |
---|
72 | Width=900;% prefered width of the GUI in points (1/72 inch) |
---|
73 | Height=624;% prefered height of the GUI in points (1/72 inch) |
---|
74 | %adjust to screen size (reduced by a min margin) |
---|
75 | RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height); |
---|
76 | if RescaleFactor>1 |
---|
77 | RescaleFactor=min(RescaleFactor,1); |
---|
78 | end |
---|
79 | Width=Width*RescaleFactor; |
---|
80 | Height=Height*RescaleFactor; |
---|
81 | LeftX=80*RescaleFactor;%position of the left fig side, in pixels (put to the left side, with some margin) |
---|
82 | LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen |
---|
83 | set(hObject,'Units','points') |
---|
84 | set(hObject,'Position',[LeftX LowY Width Height])% position and size of the GUI at opening |
---|
85 | |
---|
86 | % settings of table MinIndex_j |
---|
87 | set(handles.MinIndex_i,'ColumnFormat',{'numeric'}) |
---|
88 | set(handles.MinIndex_i,'ColumnEditable',false) |
---|
89 | set(handles.MinIndex_i,'ColumnName',{'i min'}) |
---|
90 | set(handles.MinIndex_i,'Data',[])% initiate Data to double (not cell) |
---|
91 | |
---|
92 | % settings of table MinIndex_j |
---|
93 | set(handles.MinIndex_j,'ColumnFormat',{'numeric'}) |
---|
94 | set(handles.MinIndex_j,'ColumnEditable',false) |
---|
95 | set(handles.MinIndex_j,'ColumnName',{'j min'}) |
---|
96 | set(handles.MinIndex_j,'Data',[])% initiate Data to double (not cell) |
---|
97 | |
---|
98 | % settings of table MaxIndex_i |
---|
99 | set(handles.MaxIndex_i,'ColumnFormat',{'numeric'}) |
---|
100 | set(handles.MaxIndex_i,'ColumnEditable',false) |
---|
101 | set(handles.MaxIndex_i,'ColumnName',{'i max'}) |
---|
102 | set(handles.MaxIndex_i,'Data',[])% initiate Data to double (not cell) |
---|
103 | |
---|
104 | % settings of table MaxIndex_j |
---|
105 | set(handles.MaxIndex_j,'ColumnFormat',{'numeric'}) |
---|
106 | set(handles.MaxIndex_j,'ColumnEditable',false) |
---|
107 | set(handles.MaxIndex_j,'ColumnName',{'j max'}) |
---|
108 | set(handles.MaxIndex_j,'Data',[])% initiate Data to double (not cell) |
---|
109 | |
---|
110 | % settings of table PairString |
---|
111 | set(handles.PairString,'ColumnName',{'pairs'}) |
---|
112 | set(handles.PairString,'ColumnEditable',false) |
---|
113 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
114 | set(handles.PairString,'Data',{''}) |
---|
115 | |
---|
116 | % settings of table MaskTable |
---|
117 | set(handles.MaskTable,'ColumnName',{'mask name'}) |
---|
118 | set(handles.PairString,'ColumnEditable',false) |
---|
119 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
120 | set(handles.PairString,'Data',{''}) |
---|
121 | |
---|
122 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size |
---|
123 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
124 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
125 | |
---|
126 | % check default input data |
---|
127 | if ~exist('Param','var') |
---|
128 | Param=[]; %default |
---|
129 | end |
---|
130 | |
---|
131 | %% list of builtin functions in the mebu ActionName |
---|
132 | ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback |
---|
133 | NbBuiltinAction=numel(ActionList); |
---|
134 | [path_series,name,ext]=fileparts(which('series'));% path to the GUI series |
---|
135 | path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series' |
---|
136 | ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh |
---|
137 | ActionPathList=cell(NbBuiltinAction,numel(ActionExtList));%initiate the cell matrix of Action fct paths |
---|
138 | ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members |
---|
139 | RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh) |
---|
140 | [s,w]=system('oarstat');% look for cluster system 'oar' |
---|
141 | if isequal(s,0) |
---|
142 | RunModeList=[RunModeList;{'cluster_oar'}]; |
---|
143 | end |
---|
144 | [s,w]=system('qstat');% look for cluster system 'sge' |
---|
145 | if isequal(s,0) |
---|
146 | RunModeList=[RunModeList;{'cluster_sge'}]; |
---|
147 | end |
---|
148 | set(handles.RunMode,'String',RunModeList) |
---|
149 | |
---|
150 | %% list of builtin transform functions in the mebu TransformName |
---|
151 | TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback |
---|
152 | NbBuiltinTransform=numel(TransformList); |
---|
153 | path_transform_fct=fullfile(path_series,'transform_field'); |
---|
154 | TransformPathList=cell(NbBuiltinTransform,1);%initiate the cell matrix of Action fct paths |
---|
155 | TransformPathList(:)={path_transform_fct}; %set the default path to series fcts to all list members |
---|
156 | |
---|
157 | %% get the user defined functions stored in the personal file uvmat_perso.mat |
---|
158 | dir_perso=prefdir; |
---|
159 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
160 | if exist(profil_perso,'file') |
---|
161 | h=load (profil_perso); |
---|
162 | %get the list of previous input files in the upper bar menu Open |
---|
163 | if isfield(h,'MenuFile') |
---|
164 | for ifile=1:min(length(h.MenuFile),5) |
---|
165 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile}); |
---|
166 | set(handles.(['MenuFile_' num2str(ifile+5)]),'Label',h.MenuFile{ifile}); |
---|
167 | end |
---|
168 | end |
---|
169 | %get the list of previous camapigns in the upper bar menu Open campaign |
---|
170 | if isfield(h,'MenuCampaign') |
---|
171 | for ifile=1:min(length(h.MenuCampaign),5) |
---|
172 | set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile}); |
---|
173 | end |
---|
174 | end |
---|
175 | %get the menu of actions |
---|
176 | if isfield(h,'ActionExtListUser') && iscell(h.ActionExtListUser) |
---|
177 | ActionExtList=[ActionExtList; h.ActionExtListUser]; |
---|
178 | end |
---|
179 | if isfield(h,'ActionListUser') && iscell(h.ActionListUser) && isfield(h,'ActionPathListUser') && iscell(h.ActionPathListUser) |
---|
180 | ActionList=[ActionList;h.ActionListUser]; |
---|
181 | ActionPathList=[ActionPathList;h.ActionPathListUser]; |
---|
182 | end |
---|
183 | %get the menu of transform fct |
---|
184 | if isfield(h,'TransformListUser') && iscell(h.TransformListUser) && isfield(h,'TransformPathListUser') && iscell(h.TransformPathListUser) |
---|
185 | TransformList=[TransformList;h.TransformListUser]; |
---|
186 | TransformPathList=[TransformPathList;h.TransformPathListUser]; |
---|
187 | end |
---|
188 | end |
---|
189 | |
---|
190 | %% selection of the input Action fct |
---|
191 | ActionCheckExist=true(size(ActionList));%initiate the check of the path to the listed action fct |
---|
192 | for ilist=NbBuiltinAction+1:numel(ActionList)%check the validity of the path of the user defined Action fct |
---|
193 | ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file'); |
---|
194 | end |
---|
195 | ActionPathList=ActionPathList(ActionCheckExist,:);% suppress the menu options which are not valid anymore |
---|
196 | ActionList=ActionList(ActionCheckExist); |
---|
197 | set(handles.ActionName,'String',[ActionList;{'more...'}]) |
---|
198 | set(handles.ActionName,'UserData',ActionPathList) |
---|
199 | ActionIndex=[]; |
---|
200 | if isfield(Param,'ActionName')% copy the selected menu index transferred in Param from uvmat |
---|
201 | ActionIndex=find(strcmp(Param.ActionName,ActionList),1); |
---|
202 | end |
---|
203 | if isempty(ActionIndex) |
---|
204 | ActionIndex=1; |
---|
205 | end |
---|
206 | set(handles.ActionName,'Value',ActionIndex) |
---|
207 | set(handles.ActionPath,'String',ActionPathList{ActionIndex}) |
---|
208 | set(handles.ActionExt,'Value',1) |
---|
209 | set(handles.ActionExt,'String',ActionExtList) |
---|
210 | |
---|
211 | %% selection of the input transform fct |
---|
212 | TransformCheckExist=true(size(TransformList)); |
---|
213 | for ilist=NbBuiltinTransform+1:numel(TransformList) |
---|
214 | TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file'); |
---|
215 | end |
---|
216 | TransformPathList=TransformPathList(TransformCheckExist); |
---|
217 | TransformList=TransformList(TransformCheckExist); |
---|
218 | set(handles.TransformName,'String',[TransformList;{'more...'}]) |
---|
219 | set(handles.TransformName,'UserData',TransformPathList) |
---|
220 | TransformIndex=[]; |
---|
221 | if isfield(Param,'TransformName')% copy the selected menu index transferred in Param from uvmat |
---|
222 | TransformIndex=find(strcmp(Param.TransformName,TransformList),1); |
---|
223 | end |
---|
224 | if isempty(TransformIndex) |
---|
225 | TransformIndex=1; |
---|
226 | end |
---|
227 | set(handles.TransformName,'Value',TransformIndex) |
---|
228 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}) |
---|
229 | |
---|
230 | %% fields input initialisation |
---|
231 | if isfield(Param,'list_fields')&& isfield(Param,'index_fields') &&~isempty(Param.list_fields) &&~isempty(Param.index_fields) |
---|
232 | set(handles.FieldName,'String',Param.list_fields);% list menu fields |
---|
233 | set(handles.FieldName,'Value',Param.index_fields);% selected string index |
---|
234 | end |
---|
235 | if isfield(Param,'Coord_x_str') && ischar(Param.Coord_x_str) |
---|
236 | set(handles.Coord_x,'String',Param.Coord_x_str);% list menu fields |
---|
237 | end |
---|
238 | if isfield(Param,'Coord_y_str')&& ischar(Param.Coord_y_str) |
---|
239 | set(handles.Coord_y,'String',Param.Coord_y_str);% list menu fields |
---|
240 | end |
---|
241 | |
---|
242 | %% introduce the input file name(s) if defined from input Param, TODO: avoid the file checking if Param.i1_series defined |
---|
243 | if isfield(Param,'InputFile') |
---|
244 | |
---|
245 | %% fill the list of file series |
---|
246 | InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}]; |
---|
247 | TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}]; |
---|
248 | if isfield(Param.InputFile,'RootPath_1') |
---|
249 | InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]]; |
---|
250 | TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]]; |
---|
251 | end |
---|
252 | set(handles.InputTable,'Data',InputTable) |
---|
253 | |
---|
254 | % display_file_name(handles,Param,'one')%refresh the input table |
---|
255 | update_rootinfo(handles,Param.HiddenData.i1_series{1},Param.HiddenData.i2_series{1},Param.HiddenData.j1_series{1},Param.HiddenData.j2_series{1},... |
---|
256 | Param.HiddenData.FileInfo{1},Param.HiddenData.MovieObject{1},1) |
---|
257 | if isfield(Param,'FileName_1') |
---|
258 | |
---|
259 | % display_file_name(handles,Param,2) |
---|
260 | update_rootinfo(handles,Param.HiddenData.i1_series{2},Param.HiddenData.i2_series{2},Param.HiddenData.j1_series{2},Param.HiddenData.j2_series{2},... |
---|
261 | Param.HiddenData.FileInfo{2},Param.HiddenData.MovieObject{2},2) |
---|
262 | end |
---|
263 | else |
---|
264 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed |
---|
265 | end |
---|
266 | if isfield(Param,'incr_i') |
---|
267 | set(handles.num_incr_i,'String',num2str(Param.incr_i)) |
---|
268 | end |
---|
269 | if isfield(Param,'incr_j') |
---|
270 | set(handles.num_incr_j,'String',num2str(Param.incr_j)) |
---|
271 | end |
---|
272 | |
---|
273 | %------------------------------------------------------------------------ |
---|
274 | % --- Outputs from this function are returned to the command line. |
---|
275 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
276 | %------------------------------------------------------------------------ |
---|
277 | varargout{1} = handles.output; |
---|
278 | |
---|
279 | %------------------------------------------------------------------------ |
---|
280 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
281 | function closefcn(gcbo,eventdata) |
---|
282 | %------------------------------------------------------------------------ |
---|
283 | |
---|
284 | % delete set_object_series if detected |
---|
285 | hh=findobj(allchild(0),'name','view_object_series'); |
---|
286 | if ~isempty(hh) |
---|
287 | delete(hh) |
---|
288 | end |
---|
289 | hh=findobj(allchild(0),'name','edit_object_series'); |
---|
290 | if ~isempty(hh) |
---|
291 | delete(hh) |
---|
292 | end |
---|
293 | |
---|
294 | %delete the bowser if detected |
---|
295 | hh=findobj(allchild(0),'tag','browser'); |
---|
296 | if ~isempty(hh) |
---|
297 | delete(hh) |
---|
298 | end |
---|
299 | |
---|
300 | |
---|
301 | %------------------------------------------------------------------------ |
---|
302 | %------------------------------------------------------------------------ |
---|
303 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
304 | % automatically sets the global properties when the rootfile name is introduced |
---|
305 | % then activate the view-field actionname if selected |
---|
306 | % it is activated either by clicking on the RootPath window or by the |
---|
307 | % browser |
---|
308 | %------------------------------------------------------------------------ |
---|
309 | %------------------------------------------------------------------------ |
---|
310 | % --- fct activated by the browser under 'Open' |
---|
311 | %------------------------------------------------------------------------ |
---|
312 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
313 | %% look for the previously opened file 'oldfile' |
---|
314 | InputTable=get(handles.InputTable,'Data'); |
---|
315 | oldfile=InputTable{1,1}; |
---|
316 | if isempty(oldfile) |
---|
317 | % use a file name stored in prefdir |
---|
318 | dir_perso=prefdir; |
---|
319 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
320 | if exist(profil_perso,'file') |
---|
321 | h=load (profil_perso); |
---|
322 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
323 | oldfile=h.RootPath; |
---|
324 | end |
---|
325 | end |
---|
326 | end |
---|
327 | %% launch the browser |
---|
328 | fileinput=uigetfile_uvmat('pick an input file in the series',oldfile); |
---|
329 | hh=dir(fileinput); |
---|
330 | if numel(hh)>1 |
---|
331 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
332 | else |
---|
333 | if ~isempty(fileinput) |
---|
334 | display_file_name(handles,fileinput,'one') |
---|
335 | end |
---|
336 | end |
---|
337 | |
---|
338 | % -------------------------------------------------------------------- |
---|
339 | function MenuBrowseAppend_Callback(hObject, eventdata, handles) |
---|
340 | |
---|
341 | %% look for the previously opened file 'oldfile' |
---|
342 | InputTable=get(handles.InputTable,'Data'); |
---|
343 | RootPathCell=InputTable(:,1); |
---|
344 | if isempty(RootPathCell{1})% no input file in the table |
---|
345 | MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append |
---|
346 | return |
---|
347 | end |
---|
348 | SubDirCell=InputTable(:,2); |
---|
349 | oldfile=fullfile(RootPathCell{1},SubDirCell{1}); |
---|
350 | |
---|
351 | %% use a file name stored in prefdir |
---|
352 | dir_perso=prefdir; |
---|
353 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
354 | if exist(profil_perso,'file') |
---|
355 | h=load (profil_perso); |
---|
356 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
357 | oldfile=h.RootPath; |
---|
358 | end |
---|
359 | end |
---|
360 | |
---|
361 | %% launch the browser |
---|
362 | fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile); |
---|
363 | hh=dir(fileinput); |
---|
364 | if numel(hh)>1 |
---|
365 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
366 | else |
---|
367 | if ~isempty(fileinput) |
---|
368 | display_file_name(handles,fileinput,'append') |
---|
369 | end |
---|
370 | end |
---|
371 | |
---|
372 | %------------------------------------------------------------------------ |
---|
373 | % --- fct activated by selecting a previous file under the menu Open |
---|
374 | %------------------------------------------------------------------------ |
---|
375 | function MenuFile_Callback(hObject, eventdata, handles) |
---|
376 | |
---|
377 | errormsg=display_file_name(handles,get(hObject,'Label'),'one'); |
---|
378 | if ~isempty(errormsg) |
---|
379 | set(hObject,'Label','') |
---|
380 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
381 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
382 | str_find=strcmp(get(hObject,'Label'),MenuFile); |
---|
383 | MenuFile(str_find)=[];% suppress the input file to the list |
---|
384 | for ifile=1:numel(MenuFile) |
---|
385 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); |
---|
386 | end |
---|
387 | end |
---|
388 | |
---|
389 | %------------------------------------------------------------------------ |
---|
390 | % --- fct activated by selecting a previous file under the menu Open/append |
---|
391 | %------------------------------------------------------------------------ |
---|
392 | function MenuFile_append_Callback(hObject, eventdata, handles) |
---|
393 | |
---|
394 | InputTable=get(handles.InputTable,'Data'); |
---|
395 | if isempty(InputTable{1,1})% no input file in the table |
---|
396 | display_file_name(handles,get(hObject,'Label'),'one') %refresh the input table, not append |
---|
397 | else |
---|
398 | display_file_name(handles,get(hObject,'Label'),'append')% append the selected file to the current list of InputTable |
---|
399 | end |
---|
400 | |
---|
401 | %------------------------------------------------------------------------ |
---|
402 | % --- fct activated by the browser under 'Open campaign' |
---|
403 | %------------------------------------------------------------------------ |
---|
404 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles) |
---|
405 | |
---|
406 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) |
---|
407 | drawnow |
---|
408 | InputTable=get(handles.InputTable,'Data'); |
---|
409 | RootPath=InputTable{1,1}; |
---|
410 | CampaignPath=fileparts(fileparts(RootPath)); |
---|
411 | DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); |
---|
412 | if ~ischar(DirFull)|| ~exist(DirFull,'dir') |
---|
413 | return |
---|
414 | end |
---|
415 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
416 | if ~isfield(OutPut,'Campaign') |
---|
417 | return |
---|
418 | end |
---|
419 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}); |
---|
420 | ListStruct=dir(DirName); %list files and the dir DataSeries |
---|
421 | % select the first appropriate file in the dir |
---|
422 | FileName=''; |
---|
423 | for ilist=1:numel(ListStruct) |
---|
424 | if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir |
---|
425 | FileName=ListStruct(ilist).name; |
---|
426 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
427 | switch FileType |
---|
428 | case {'image','multimage','civx','civdata','netcdf'} |
---|
429 | break |
---|
430 | end |
---|
431 | end |
---|
432 | end |
---|
433 | if isempty(FileName) |
---|
434 | msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)]) |
---|
435 | return |
---|
436 | end |
---|
437 | |
---|
438 | %% update the list of campaigns in the menubar |
---|
439 | MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};... |
---|
440 | {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}]; |
---|
441 | check_dir=isempty(find(strcmp(DirFull,MenuCampaign))); |
---|
442 | if check_dir %insert the new campaign in the list if it is not found |
---|
443 | MenuCampaign(end)=[]; %suppress the last item |
---|
444 | MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign |
---|
445 | for ilist=1:numel(MenuCampaign) |
---|
446 | set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist}) |
---|
447 | end |
---|
448 | % save the list for future opening: |
---|
449 | dir_perso=prefdir; |
---|
450 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
451 | if exist(profil_perso,'file') |
---|
452 | save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat |
---|
453 | else |
---|
454 | save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
455 | end |
---|
456 | end |
---|
457 | |
---|
458 | %% display the selected field and related information |
---|
459 | if get(handles.CheckAppend,'Value') |
---|
460 | display_file_name(handles,fullfile(DirName,FileName),'append') |
---|
461 | else |
---|
462 | display_file_name(handles,fullfile(DirName,FileName),'one') |
---|
463 | end |
---|
464 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) |
---|
465 | |
---|
466 | % -------------------------------------------------------------------- |
---|
467 | function MenuCampaign_Callback(hObject, eventdata, handles) |
---|
468 | % -------------------------------------------------------------------- |
---|
469 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) |
---|
470 | OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
471 | if ~isfield(OutPut,'Campaign') |
---|
472 | return |
---|
473 | end |
---|
474 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}); |
---|
475 | hdir=dir(DirName); %list files and dirs |
---|
476 | for ilist=1:numel(hdir) |
---|
477 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir |
---|
478 | FileName=hdir(ilist).name; |
---|
479 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
480 | switch FileType |
---|
481 | case {'image','multimage','civx','civdata','netcdf'} |
---|
482 | break |
---|
483 | end |
---|
484 | end |
---|
485 | end |
---|
486 | if get(handles.CheckAppend,'Value') |
---|
487 | display_file_name(handles,fullfile(DirName,FileName),'append') |
---|
488 | else |
---|
489 | display_file_name(handles,fullfile(DirName,FileName),'one') |
---|
490 | end |
---|
491 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) |
---|
492 | |
---|
493 | |
---|
494 | % --- Executes when selected cell(s) is changed in InputTable. |
---|
495 | function InputTable_CellSelectionCallback(hObject, eventdata, handles) |
---|
496 | iline=[]; |
---|
497 | if ~isempty(eventdata.Indices) |
---|
498 | iline=eventdata.Indices(1); |
---|
499 | end |
---|
500 | set(handles.InputTable,'UserData',iline); |
---|
501 | |
---|
502 | %------------------------------------------------------------------------ |
---|
503 | % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard |
---|
504 | %------------------------------------------------------------------------ |
---|
505 | function InputTable_KeyPressFcn(hObject, eventdata, handles) |
---|
506 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed |
---|
507 | xx=double(get(handles.series,'CurrentCharacter')); %get the keyboard character |
---|
508 | switch xx |
---|
509 | case 31 %downward arrow |
---|
510 | InputTable=get(handles.InputTable,'Data'); |
---|
511 | iline=get(handles.InputTable,'UserData'); |
---|
512 | if isequal(iline,size(InputTable,1))% arrow downward |
---|
513 | InputTable=[InputTable;InputTable(iline,:)];% create a new line as a copy of the last one |
---|
514 | set(handles.InputTable,'Data',InputTable); |
---|
515 | end |
---|
516 | case 127 %key 'Suppress' |
---|
517 | InputTable=get(handles.InputTable,'Data'); |
---|
518 | iline=get(handles.InputTable,'UserData'); |
---|
519 | if iline>1 |
---|
520 | InputTable(iline,:)=[];% suppress the current line if not the first |
---|
521 | set(handles.InputTable,'Data',InputTable); |
---|
522 | end |
---|
523 | end |
---|
524 | |
---|
525 | |
---|
526 | %------------------------------------------------------------------------ |
---|
527 | % --- Executes on button press in REFRESH. |
---|
528 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
529 | %------------------------------------------------------------------------ |
---|
530 | InputTable=get(handles.InputTable,'Data'); |
---|
531 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
532 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation) |
---|
533 | drawnow |
---|
534 | empty_line=false(size(InputTable,1),1); |
---|
535 | for iline=1:size(InputTable,1) |
---|
536 | empty_line(iline)= isempty(cell2mat(InputTable(iline,1:3))); |
---|
537 | end |
---|
538 | if ~isempty(find(empty_line)); |
---|
539 | InputTable(empty_line,:)=[];%remove empty lines |
---|
540 | set(handles.InputTable,'Data',InputTable) |
---|
541 | ListTable={'MinIndex_i','MaxIndex_i','MinIndex_j','MaxIndex_j','PairString','TimeTable'}; |
---|
542 | for ilist=1:numel(ListTable) |
---|
543 | Table=get(handles.(ListTable{ilist}),'Data'); |
---|
544 | Table(empty_line,:)=[];%remove empty lines |
---|
545 | set(handles.(ListTable{ilist}),'Data',Table); |
---|
546 | end |
---|
547 | set(handles.series,'UserData',[])%refresh the stored info |
---|
548 | end |
---|
549 | for iview=1:size(InputTable,1) |
---|
550 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2}); |
---|
551 | if ~exist(RootPath,'dir') |
---|
552 | i1_series=[]; |
---|
553 | RootPath=fileparts(RootPath); %will try the upper folder |
---|
554 | else %scan the input folder |
---|
555 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=... |
---|
556 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); |
---|
557 | end |
---|
558 | % if no file is found, open a browser |
---|
559 | if isempty(i1_series) |
---|
560 | fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath); |
---|
561 | if isempty(fileinput) |
---|
562 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH back to red color |
---|
563 | return |
---|
564 | else |
---|
565 | display_file_name(handles,fileinput,iview) |
---|
566 | end |
---|
567 | else |
---|
568 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview) |
---|
569 | end |
---|
570 | end |
---|
571 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (indicate activation finished) |
---|
572 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch' |
---|
573 | |
---|
574 | %------------------------------------------------------------------------ |
---|
575 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser |
---|
576 | function errormsg=display_file_name(handles,Param,iview) |
---|
577 | %------------------------------------------------------------------------ |
---|
578 | % |
---|
579 | % INPUT: |
---|
580 | % handles: handles of elements in the GUI |
---|
581 | % Param: structure of input parameters, including input file name and path |
---|
582 | % iview: line index in the input table |
---|
583 | % or 'one': refresh the list |
---|
584 | % 'append': add a new line to the input table |
---|
585 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation) |
---|
586 | drawnow |
---|
587 | errormsg='';%default |
---|
588 | if ischar(Param) |
---|
589 | fileinput=Param; |
---|
590 | else% input set when series is opened (called by the GUI uvmat) |
---|
591 | fileinput=Param.FileName; |
---|
592 | end |
---|
593 | |
---|
594 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
595 | if ~exist(fileinput,'file') |
---|
596 | errormsg=['input file ' fileinput ' does not exist']; |
---|
597 | msgbox_uvmat('ERROR',errormsg) |
---|
598 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (refresh still needed) |
---|
599 | return |
---|
600 | end |
---|
601 | |
---|
602 | %% detect root name, nomenclature and indices in the input file name: |
---|
603 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
604 | %%%%%%%%%%%%%%%%%% |
---|
605 | %TODO: case of input by uvmat: do not check agai the input seies %%%%%%% |
---|
606 | %%%%%%%%%%%%%%%%%%% |
---|
607 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
608 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
609 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
610 | if isempty(RootFile)&&isempty(i1_series) |
---|
611 | errormsg='no input file in the series'; |
---|
612 | msgbox_uvmat('ERROR',errormsg) |
---|
613 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation) |
---|
614 | return |
---|
615 | end |
---|
616 | if strcmp(FileType,'txt') |
---|
617 | edit(fileinput) |
---|
618 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation) |
---|
619 | return |
---|
620 | elseif strcmp(FileType,'xml') |
---|
621 | editxml(fileinput) |
---|
622 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation) |
---|
623 | return |
---|
624 | elseif strcmp(FileType,'figure') |
---|
625 | open(fileinput) |
---|
626 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation) |
---|
627 | return |
---|
628 | end |
---|
629 | |
---|
630 | %% enable other menus and uicontrols |
---|
631 | set(handles.MenuOpenCampaign,'Enable','on') |
---|
632 | set(handles.MenuCampaign_1,'Enable','on') |
---|
633 | set(handles.MenuCampaign_2,'Enable','on') |
---|
634 | set(handles.MenuCampaign_3,'Enable','on') |
---|
635 | set(handles.MenuCampaign_4,'Enable','on') |
---|
636 | set(handles.MenuCampaign_5,'Enable','on') |
---|
637 | set(handles.RUN, 'Enable','On') |
---|
638 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
639 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
640 | drawnow |
---|
641 | |
---|
642 | |
---|
643 | %% fill the list of file series |
---|
644 | InputTable=get(handles.InputTable,'Data'); |
---|
645 | SeriesData=get(handles.series,'UserData'); |
---|
646 | if strcmp(iview,'append') % display the input data as a new line in the table |
---|
647 | iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line |
---|
648 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
649 | % SeriesData.ListViewMenu(iview)=zeros(1,nbview) |
---|
650 | elseif strcmp(iview,'one') % refresh the list of input file series |
---|
651 | iview=1; %the first line in InputTable becomes the current line |
---|
652 | InputTable={'','','','',''}; |
---|
653 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
654 | set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}]) |
---|
655 | set(handles.MinIndex_i,'Data',[]) |
---|
656 | set(handles.MaxIndex_i,'Data',[]) |
---|
657 | set(handles.MinIndex_j,'Data',[]) |
---|
658 | set(handles.MaxIndex_j,'Data',[]) |
---|
659 | set(handles.PairString,'Data',{''}) |
---|
660 | SeriesData.CheckPair=0;%reset the list of input lines with pairs |
---|
661 | SeriesData.i1_series={}; |
---|
662 | SeriesData.i2_series={}; |
---|
663 | SeriesData.j1_series={}; |
---|
664 | SeriesData.j2_series={}; |
---|
665 | SeriesData.FileType={}; |
---|
666 | SeriesData.FileInfo={}; |
---|
667 | SeriesData.Time={}; |
---|
668 | end |
---|
669 | set(handles.InputTable,'Data',InputTable) |
---|
670 | |
---|
671 | %% determine the selected reference field indices for pair display |
---|
672 | if isempty(i1) |
---|
673 | i1=1; |
---|
674 | end |
---|
675 | if isempty(i2) |
---|
676 | i2=i1; |
---|
677 | end |
---|
678 | ref_i=floor((i1+i2)/2);% reference image number corresponding to the file |
---|
679 | % set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
680 | if isempty(j1) |
---|
681 | j1=1; |
---|
682 | end |
---|
683 | if isempty(j2) |
---|
684 | j2=j1; |
---|
685 | end |
---|
686 | ref_j=floor((j1+j2)/2);% reference image number corresponding to the file |
---|
687 | SeriesData.ref_i=ref_i; |
---|
688 | SeriesData.ref_j=ref_j; |
---|
689 | |
---|
690 | %% update first and last indices if they do not exist |
---|
691 | Param=read_GUI(handles.series); |
---|
692 | first_j=[]; |
---|
693 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end |
---|
694 | last_j=[]; |
---|
695 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end |
---|
696 | PairString=''; |
---|
697 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end |
---|
698 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString); |
---|
699 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... |
---|
700 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); |
---|
701 | if ~exist(FirstFileName,'file') |
---|
702 | set(handles.num_first_i,'String',num2str(ref_i)) |
---|
703 | set(handles.num_first_j,'String',num2str(ref_j)) |
---|
704 | end |
---|
705 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString); |
---|
706 | LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... |
---|
707 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); |
---|
708 | if ~exist(LastFileName,'file') |
---|
709 | set(handles.num_last_i,'String',num2str(ref_i)) |
---|
710 | set(handles.num_last_j,'String',num2str(ref_j)) |
---|
711 | end |
---|
712 | |
---|
713 | %% update the list of recent files in the menubar and save it for future opening |
---|
714 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
715 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
716 | str_find=strcmp(fileinput,MenuFile); |
---|
717 | if isempty(find(str_find,1)) |
---|
718 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
719 | end |
---|
720 | for ifile=1:min(length(MenuFile),5) |
---|
721 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
722 | end |
---|
723 | dir_perso=prefdir; |
---|
724 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
725 | if exist(profil_perso,'file') |
---|
726 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
727 | else |
---|
728 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
729 | end |
---|
730 | % save the opened file to initiate future opening |
---|
731 | SeriesData.RefFile{iview}=fileinput;% reference opening file for line iview |
---|
732 | SeriesData.Ref_i1=i1; |
---|
733 | SeriesData.Ref_i2=i2; |
---|
734 | SeriesData.Ref_j1=j1; |
---|
735 | SeriesData.Ref_j2=j2; |
---|
736 | set(handles.series,'UserData',SeriesData) |
---|
737 | |
---|
738 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
739 | |
---|
740 | %% initiate input file series and refresh the current field view: |
---|
741 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview); |
---|
742 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) |
---|
743 | |
---|
744 | %------------------------------------------------------------------------ |
---|
745 | % --- Update information about a new field series (indices to scan, timing, |
---|
746 | % calibration from an xml file |
---|
747 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,iview) |
---|
748 | %------------------------------------------------------------------------ |
---|
749 | InputTable=get(handles.InputTable,'Data'); |
---|
750 | |
---|
751 | %% display the min and max indices for the whole file series |
---|
752 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 |
---|
753 | MinIndex_j=1;% index j set to 1 by default |
---|
754 | MaxIndex_j=1; |
---|
755 | MinIndex_i=find(i1_series(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) |
---|
756 | MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series) |
---|
757 | else |
---|
758 | ref_i=squeeze(max(i1_series(1,:,:),[],2));% select ref_j index for each ref_i |
---|
759 | ref_j=squeeze(max(j1_series(1,:,:),[],3));% select ref_i index for each ref_j |
---|
760 | MinIndex_i=min(find(ref_i))-1; |
---|
761 | MaxIndex_i=max(find(ref_i))-1; |
---|
762 | MaxIndex_j=max(find(ref_j))-1; |
---|
763 | MinIndex_j=min(find(ref_j))-1; |
---|
764 | diff_j_max=diff(ref_j); |
---|
765 | diff_i_max=diff(ref_i); |
---|
766 | if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) |
---|
767 | set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default |
---|
768 | end |
---|
769 | if ~isempty(diff_j_max) && isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) |
---|
770 | set(handles.num_incr_j,'String',num2str(diff_j_max(1))) |
---|
771 | end |
---|
772 | end |
---|
773 | if isequal(MinIndex_i,-1) |
---|
774 | MinIndex_i=0; |
---|
775 | end |
---|
776 | if isequal(MinIndex_j,-1) |
---|
777 | MinIndex_j=0; |
---|
778 | end |
---|
779 | MinIndex_i_table=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex |
---|
780 | MinIndex_j_table=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex |
---|
781 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex |
---|
782 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex |
---|
783 | if ~isempty(MinIndex_i)&&~isempty(MaxIndex_i) |
---|
784 | MinIndex_i_table(iview,1)=MinIndex_i; |
---|
785 | MaxIndex_i_table(iview,1)=MaxIndex_i; |
---|
786 | end |
---|
787 | if ~isempty(MinIndex_j)&&~isempty(MaxIndex_j) |
---|
788 | MinIndex_j_table(iview,1)=MinIndex_j; |
---|
789 | MaxIndex_j_table(iview,1)=MaxIndex_j; |
---|
790 | end |
---|
791 | set(handles.MinIndex_i,'Data',MinIndex_i_table)%display the min indices in the table MinIndex |
---|
792 | set(handles.MinIndex_j,'Data',MinIndex_j_table)%display the max indices in the table MaxIndex |
---|
793 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table)%display the min indices in the table MinIndex |
---|
794 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex |
---|
795 | SeriesData=get(handles.series,'UserData'); |
---|
796 | |
---|
797 | %% adjust the first and last indices for the selected series, only if requested by the bounds |
---|
798 | % i index, compare input to min index i |
---|
799 | first_i=str2num(get(handles.num_first_i,'String'));%retrieve previous first i |
---|
800 | % ref_i=str2num(get(handles.num_ref_i,'String'));%index i given by the input field |
---|
801 | ref_i=1; |
---|
802 | if isfield(SeriesData,'ref_i') |
---|
803 | ref_i=SeriesData.ref_i; |
---|
804 | end |
---|
805 | if isempty(first_i) |
---|
806 | first_i=ref_i;% first_i updated by the input value |
---|
807 | elseif first_i < MinIndex_i |
---|
808 | first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines) |
---|
809 | elseif first_i >MaxIndex_i |
---|
810 | first_i=MaxIndex_i;% first_i set to the max i index (restricted by oter input lines) |
---|
811 | end |
---|
812 | % j index, compare input to min index j |
---|
813 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
814 | ref_j=1; |
---|
815 | if isfield(SeriesData,'ref_j') |
---|
816 | ref_j=SeriesData.ref_j; |
---|
817 | end |
---|
818 | if isempty(first_j) |
---|
819 | first_j=ref_j;% first_j updated by the input value |
---|
820 | elseif first_j<MinIndex_j |
---|
821 | first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines) |
---|
822 | elseif first_j >MaxIndex_j |
---|
823 | first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines) |
---|
824 | end |
---|
825 | % i index, compare input to max index i |
---|
826 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
827 | if isempty(last_i) |
---|
828 | last_i=ref_i; |
---|
829 | elseif last_i > MaxIndex_i |
---|
830 | last_i=MaxIndex_i; |
---|
831 | elseif last_i<first_i |
---|
832 | last_i=first_i; |
---|
833 | end |
---|
834 | % j index, compare input to max index j |
---|
835 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
836 | if isempty(last_j) |
---|
837 | last_j=ref_j; |
---|
838 | elseif last_j>MaxIndex_j |
---|
839 | last_j=MaxIndex_j; |
---|
840 | elseif last_j<first_j |
---|
841 | last_j=first_j; |
---|
842 | end |
---|
843 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
844 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
845 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
846 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
847 | |
---|
848 | %% number of slices set by default |
---|
849 | NbSlice=1;%default |
---|
850 | % read value set by the first series for the append mode (iwiew >1) |
---|
851 | if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on') |
---|
852 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
853 | end |
---|
854 | |
---|
855 | %% default time settings |
---|
856 | TimeUnit=''; |
---|
857 | % read value set by the first series for the append mode (iwiew >1) |
---|
858 | if iview>1 |
---|
859 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
860 | end |
---|
861 | TimeName=''; |
---|
862 | Time=[];%default |
---|
863 | TimeMin=[]; |
---|
864 | TimeFirst=[]; |
---|
865 | TimeLast=[]; |
---|
866 | TimeMax=[]; |
---|
867 | |
---|
868 | %% read image documentation file if found |
---|
869 | XmlData=[]; |
---|
870 | check_calib=0; |
---|
871 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5}); |
---|
872 | if ~isempty(XmlFileName) |
---|
873 | [XmlData,errormsg]=imadoc2struct(XmlFileName); |
---|
874 | if ~isempty(errormsg) |
---|
875 | msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]); |
---|
876 | end |
---|
877 | % read time if available |
---|
878 | if isfield(XmlData,'Time') |
---|
879 | Time=XmlData.Time; |
---|
880 | TimeName='xml'; |
---|
881 | end |
---|
882 | if isfield(XmlData,'Camera') |
---|
883 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
884 | if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,XmlData.Camera.NbSlice) |
---|
885 | msgbox_uvmat('WARNING','inconsistent number of slices with the first field series'); |
---|
886 | end |
---|
887 | NbSlice=XmlData.Camera.NbSlice;% Nbre of slices from camera |
---|
888 | end |
---|
889 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
890 | if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit) |
---|
891 | msgbox_uvmat('WARNING','inconsistent time unit with the first field series'); |
---|
892 | end |
---|
893 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
894 | end |
---|
895 | end |
---|
896 | % number of slices |
---|
897 | if isfield(XmlData,'GeometryCalib') |
---|
898 | check_calib=1; |
---|
899 | if isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
900 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
901 | if siz(1)>1 |
---|
902 | if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,siz(1)) |
---|
903 | msgbox_uvmat('WARNING','inconsistent number of Z indices with the first field series'); |
---|
904 | end |
---|
905 | NbSlice=siz(1); |
---|
906 | end |
---|
907 | end |
---|
908 | end |
---|
909 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
910 | end |
---|
911 | |
---|
912 | %% read timing from the current file (prioritary) |
---|
913 | if ~isempty(VideoObject)% case of movies |
---|
914 | imainfo=get(VideoObject); |
---|
915 | if isempty(j1_series); %frame index along i |
---|
916 | Time=zeros(imainfo.NumberOfFrames+1,2); |
---|
917 | Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
918 | else |
---|
919 | Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
920 | end |
---|
921 | TimeName='video'; |
---|
922 | end |
---|
923 | |
---|
924 | |
---|
925 | %% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback |
---|
926 | if ~isempty(TimeName) |
---|
927 | TimeMin=Time(MinIndex_i+1,MinIndex_j+1); |
---|
928 | if size(Time)>=[first_i+1 first_j+1] |
---|
929 | TimeFirst=Time(first_i+1,first_j+1); |
---|
930 | end |
---|
931 | if size(Time)>=[last_i+1 last_j+1] |
---|
932 | TimeLast=Time(last_i+1,last_j+1); |
---|
933 | end |
---|
934 | if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]; |
---|
935 | TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1); |
---|
936 | end |
---|
937 | end |
---|
938 | |
---|
939 | %% update the time table |
---|
940 | TimeTable=get(handles.TimeTable,'Data'); |
---|
941 | TimeTable{iview,1}=TimeName; |
---|
942 | TimeTable{iview,2}=TimeMin; |
---|
943 | TimeTable{iview,3}=TimeFirst; |
---|
944 | TimeTable{iview,4}=TimeLast; |
---|
945 | TimeTable{iview,5}=TimeMax; |
---|
946 | set(handles.TimeTable,'Data',TimeTable) |
---|
947 | |
---|
948 | %% update the series info in 'UserData' |
---|
949 | SeriesData.i1_series{iview}=i1_series; |
---|
950 | SeriesData.i2_series{iview}=i2_series; |
---|
951 | SeriesData.j1_series{iview}=j1_series; |
---|
952 | SeriesData.j2_series{iview}=j2_series; |
---|
953 | SeriesData.FileType{iview}=FileInfo.FileType; |
---|
954 | SeriesData.FileInfo{iview}=FileInfo; |
---|
955 | SeriesData.Time{iview}=Time; |
---|
956 | % if ~isempty(TimeName) |
---|
957 | % SeriesData.TimeSource=TimeSource; |
---|
958 | % end |
---|
959 | if check_calib |
---|
960 | SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib; |
---|
961 | end |
---|
962 | set(handles.series,'UserData',SeriesData) |
---|
963 | |
---|
964 | %% update pair menus |
---|
965 | hset_pair=findobj(allchild(0),'Tag','set_pairs'); |
---|
966 | if ~isempty(hset_pair), delete(hset_pair); end % delete the GUI set_pair if opened |
---|
967 | CheckPair= ~isempty(i2_series)||~isempty(j2_series); % check whether index pairs need to be defined |
---|
968 | PairString=get(handles.PairString,'Data'); |
---|
969 | if CheckPair% if pairs need to be display for line iview |
---|
970 | [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series); |
---|
971 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j,TimeName,InputTable(iview,:),FileInfo); |
---|
972 | PairString{iview,1}=Menu{1}; |
---|
973 | else |
---|
974 | PairString{iview,1}='';%no pair for #iview |
---|
975 | end |
---|
976 | set(handles.PairString,'Data',PairString) |
---|
977 | if isempty(find(cellfun('isempty',get(handles.PairString,'Data'))==0, 1))% if all lines of pairs are empty |
---|
978 | set(handles.PairString,'Visible','off') |
---|
979 | set(handles.SetPairs,'Visible','off') |
---|
980 | else |
---|
981 | set(handles.PairString,'Visible','on') |
---|
982 | set(handles.SetPairs,'Visible','on') |
---|
983 | end |
---|
984 | |
---|
985 | |
---|
986 | %% display the set of existing files as an image |
---|
987 | set(handles.FileStatus,'Units','pixels') |
---|
988 | Position=get(handles.FileStatus,'Position'); |
---|
989 | set(handles.FileStatus,'Units','normalized') |
---|
990 | %xI=0.5:Position(3)-0.5; |
---|
991 | nbview=numel(SeriesData.i1_series); |
---|
992 | j_max=cell(1,nbview); |
---|
993 | MaxIndex_i=ones(1,nbview);%default |
---|
994 | MinIndex_i=ones(1,nbview);%default |
---|
995 | for iline=1:nbview |
---|
996 | pair_max=squeeze(max(SeriesData.i1_series{iline},[],1)); %max on pair index |
---|
997 | j_max{iline}=max(pair_max,[],1);%max on j index |
---|
998 | if ~isempty(j_max{iline}) |
---|
999 | MaxIndex_i(iline)=max(find(j_max{iline}))-1;% max ref index i |
---|
1000 | MinIndex_i(iline)=min(find(j_max{iline}))-1;% min ref index i |
---|
1001 | end |
---|
1002 | end |
---|
1003 | MinIndex_i=min(MinIndex_i); |
---|
1004 | MaxIndex_i=max(MaxIndex_i); |
---|
1005 | range_index=MaxIndex_i-MinIndex_i+1; |
---|
1006 | range_y=max(1,floor(Position(4)/nbview)); |
---|
1007 | npx=floor(Position(3)); |
---|
1008 | file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1; |
---|
1009 | CData=zeros(nbview*range_y,npx);% initiate the image representing the existing files |
---|
1010 | for iline=1:nbview |
---|
1011 | ind_y=1+(iline-1)*range_y:iline*range_y; |
---|
1012 | LineData=zeros(size(file_indices)); |
---|
1013 | file_select=file_indices(file_indices<=numel(j_max{iline})); |
---|
1014 | ind_select=find(file_indices<=numel(j_max{iline})); |
---|
1015 | LineData(ind_select)=j_max{iline}(file_select)~=0; |
---|
1016 | CData(ind_y,:)=ones(size(ind_y'))*LineData; |
---|
1017 | end |
---|
1018 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));%make color images r=0,g,b=0 |
---|
1019 | set(handles.FileStatus,'CData',CData); |
---|
1020 | |
---|
1021 | %% enable field and veltype menus, in accordance with the current action |
---|
1022 | ActionName_Callback([],[], handles) |
---|
1023 | |
---|
1024 | %% set length of waitbar |
---|
1025 | displ_time(handles) |
---|
1026 | |
---|
1027 | |
---|
1028 | % look for netcdf data as input |
---|
1029 | % switch FileType |
---|
1030 | % case {'civx','civdata'} |
---|
1031 | % FieldList=[set_field_list('U','V');{'C'}];%standard menu for civx data |
---|
1032 | % set(handles.Coord_x,'String','X'); |
---|
1033 | % set(handles.Coord_y,'String','Y'); |
---|
1034 | % case 'netcdf' |
---|
1035 | % ind_x=find(strcmp(get(handles.Coord_x,'String'),FileInfo.ListVarName)); |
---|
1036 | % if isempty(ind_x) |
---|
1037 | % FieldList={};% new kind of file opened, we need to pick variables with get_field... |
---|
1038 | % set(handles.Coord_x,'String','') |
---|
1039 | % set(handles.Coord_y,'String','') |
---|
1040 | % else |
---|
1041 | % FileInfo.ListVarName(ind_x)=[];%remove coord-x from the list of variables to display |
---|
1042 | % ind_y=find(strcmp(get(handles.Coord_y,'String'),FileInfo.ListVarName)); |
---|
1043 | % if isempty(ind_y) |
---|
1044 | % FieldList={};% new kind of file opened, we need to pick variables with get_field... |
---|
1045 | % set(handles.Coord_x,'String','') |
---|
1046 | % set(handles.Coord_y,'String','') |
---|
1047 | % else |
---|
1048 | % FileInfo.ListVarName(ind_y)=[];%remove coord-y from the list of variables to display |
---|
1049 | % FieldList=(FileInfo.ListVarName)'; |
---|
1050 | % end |
---|
1051 | % end |
---|
1052 | % otherwise |
---|
1053 | % set(handles.FieldName,'Value',1) % set menu to 'image' |
---|
1054 | % set(handles.FieldName,'String',{'image'}) |
---|
1055 | % set(handles.Coord_x,'String','AX'); |
---|
1056 | % set(handles.Coord_y,'String','AY'); |
---|
1057 | % end |
---|
1058 | % if ismember(FileType,{'civx','civdata','netcdf'}) |
---|
1059 | % PrevMenu=get(handles.FieldName,'String'); |
---|
1060 | % PrevValue=get(handles.FieldName,'Value'); |
---|
1061 | % PrevMenu=PrevMenu(PrevValue(PrevValue<=numel(PrevMenu))); |
---|
1062 | % FieldValue=[]; |
---|
1063 | % for ilist=1:numel(PrevMenu) |
---|
1064 | % index_menu=find(strcmp(PrevMenu{ilist},FieldList)); |
---|
1065 | % if ~isempty(index_menu) |
---|
1066 | % FieldValue=[FieldValue index_menu]; |
---|
1067 | % end |
---|
1068 | % end |
---|
1069 | % if isempty(FieldValue) |
---|
1070 | % FieldValue=1; |
---|
1071 | % end |
---|
1072 | % set(handles.FieldName,'Value',FieldValue) |
---|
1073 | % set(handles.FieldName,'String',[FieldList;{'get_field...'}]) |
---|
1074 | % end |
---|
1075 | |
---|
1076 | |
---|
1077 | %-----------------------------------------------------------guide ------------- |
---|
1078 | %------------------------------------------------------------------------ |
---|
1079 | % III - FUNCTIONS ASSOCIATED TO THE FRAME IndexRange |
---|
1080 | %------------------------------------------------------------------------ |
---|
1081 | |
---|
1082 | |
---|
1083 | % ---- determine the menu to put in mode and advice a default choice |
---|
1084 | %------------------------------------------------------------------------ |
---|
1085 | function [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series) |
---|
1086 | %------------------------------------------------------------------------ |
---|
1087 | ModeMenu={''}; |
---|
1088 | if isempty(j2_series)% no j pair |
---|
1089 | ModeValue=1; |
---|
1090 | if ~isempty(i2_series) |
---|
1091 | ModeMenu={'series(Di)'}; % pair menu with only option Di |
---|
1092 | end |
---|
1093 | else %existence of j pairs |
---|
1094 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
1095 | j_max=max(pair_max,[],1); |
---|
1096 | MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i |
---|
1097 | MinIndex_i=find(j_max, 1 )-1;% min ref index i |
---|
1098 | i_max=max(pair_max,[],2); |
---|
1099 | MaxIndex_j=find(i_max, 1, 'last' )-1;% max ref index i |
---|
1100 | MinIndex_j=find(i_max, 1 )-1;% min ref index i |
---|
1101 | if MaxIndex_j==MinIndex_j |
---|
1102 | ModeValue=1; |
---|
1103 | ModeMenu={'bursts'}; |
---|
1104 | elseif MaxIndex_i==MinIndex_i |
---|
1105 | ModeValue=1; |
---|
1106 | ModeMenu={'series(Dj)'}; |
---|
1107 | else |
---|
1108 | ModeMenu={'bursts';'series(Dj)'}; |
---|
1109 | if (MaxIndex_j-MinIndex_j)>10 |
---|
1110 | ModeValue=2;%set mode to series(Dj) if more than 10 j values |
---|
1111 | else |
---|
1112 | ModeValue=1; |
---|
1113 | end |
---|
1114 | end |
---|
1115 | end |
---|
1116 | |
---|
1117 | |
---|
1118 | %------------------------------------------------------------------------ |
---|
1119 | function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo) |
---|
1120 | %------------------------------------------------------------------------ |
---|
1121 | displ_pair={}; |
---|
1122 | if isempty(TimeUnit) |
---|
1123 | dtunit='e-03'; |
---|
1124 | else |
---|
1125 | dtunit=['m' TimeUnit]; |
---|
1126 | end |
---|
1127 | switch mode |
---|
1128 | case 'series(Di)' |
---|
1129 | diff_i=i2_series-i1_series; |
---|
1130 | min_diff=min(diff_i(diff_i>0)); |
---|
1131 | max_diff=max(diff_i(diff_i>0)); |
---|
1132 | for ipair=min_diff:max_diff |
---|
1133 | if numel(diff_i(diff_i==ipair))>0 |
---|
1134 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1135 | if ~isempty(time) |
---|
1136 | if ref_i<=floor(ipair/2) |
---|
1137 | ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
1138 | end |
---|
1139 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
1140 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1141 | end |
---|
1142 | displ_pair=[displ_pair;{pair_string}]; |
---|
1143 | end |
---|
1144 | end |
---|
1145 | if ~isempty(displ_pair) |
---|
1146 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
1147 | end |
---|
1148 | case 'series(Dj)' |
---|
1149 | if isempty(j2_series) |
---|
1150 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1151 | return |
---|
1152 | end |
---|
1153 | diff_j=j2_series-j1_series; |
---|
1154 | min_diff=min(diff_j(diff_j>0)); |
---|
1155 | max_diff=max(diff_j(diff_j>0)); |
---|
1156 | for ipair=min_diff:max_diff |
---|
1157 | if numel(diff_j(diff_j==ipair))>0 |
---|
1158 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1159 | if ~isempty(time) |
---|
1160 | if ref_j<=floor(ipair/2) |
---|
1161 | ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
1162 | end |
---|
1163 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
1164 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1165 | end |
---|
1166 | displ_pair=[displ_pair;{pair_string}]; |
---|
1167 | end |
---|
1168 | end |
---|
1169 | if ~isempty(displ_pair) |
---|
1170 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
1171 | end |
---|
1172 | case 'bursts' |
---|
1173 | if isempty(j2_series) |
---|
1174 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1175 | return |
---|
1176 | end |
---|
1177 | %diff_j=j2_series-j1_series; |
---|
1178 | min_j1=min(j1_series(j1_series>0)); |
---|
1179 | max_j1=max(j1_series(j1_series>0)); |
---|
1180 | min_j2=min(j2_series(j2_series>0)); |
---|
1181 | max_j2=max(j2_series(j2_series>0)); |
---|
1182 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
1183 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
1184 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
1185 | pair_string=['j= ' num2str(pair1) '-' num2str(pair2)]; |
---|
1186 | [TimeValue,DtValue]=get_time(ref_i,[],pair_string,InputTable,FileInfo,TimeName,'Dt'); |
---|
1187 | %Dt=time(ref_i,pair2+1)-time(ref_i,pair1+1); |
---|
1188 | pair_string=[pair_string ', Dt=' num2str(DtValue) ' ' dtunit]; |
---|
1189 | displ_pair=[displ_pair;{pair_string}]; |
---|
1190 | end |
---|
1191 | end |
---|
1192 | end |
---|
1193 | if ~isempty(displ_pair) |
---|
1194 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
1195 | end |
---|
1196 | end |
---|
1197 | |
---|
1198 | %------------------------------------------------------------------------ |
---|
1199 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
1200 | %------------------------------------------------------------------------ |
---|
1201 | num_last_i_Callback(hObject, eventdata, handles) |
---|
1202 | |
---|
1203 | %------------------------------------------------------------------------ |
---|
1204 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
1205 | %------------------------------------------------------------------------ |
---|
1206 | SeriesData=get(handles.series,'UserData'); |
---|
1207 | if ~isfield(SeriesData,'Time') |
---|
1208 | SeriesData.Time{1}=[]; |
---|
1209 | end |
---|
1210 | displ_time(handles); |
---|
1211 | |
---|
1212 | %------------------------------------------------------------------------ |
---|
1213 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
1214 | %------------------------------------------------------------------------ |
---|
1215 | num_last_j_Callback(hObject, eventdata, handles) |
---|
1216 | |
---|
1217 | %------------------------------------------------------------------------ |
---|
1218 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
1219 | %------------------------------------------------------------------------ |
---|
1220 | % first_j=str2num(get(handles.num_first_j,'String')); |
---|
1221 | % last_j=str2num(get(handles.num_last_j,'String')); |
---|
1222 | % ref_j=ceil((first_j+last_j)/2); |
---|
1223 | % set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
1224 | % num_ref_j_Callback(hObject, eventdata, handles) |
---|
1225 | SeriesData=get(handles.series,'UserData'); |
---|
1226 | if ~isfield(SeriesData,'Time') |
---|
1227 | SeriesData.Time{1}=[]; |
---|
1228 | end |
---|
1229 | displ_time(handles); |
---|
1230 | |
---|
1231 | %------------------------------------------------------------------------ |
---|
1232 | % ---- find the times corresponding to the first and last indices of a series |
---|
1233 | function displ_time(handles) |
---|
1234 | %------------------------------------------------------------------------ |
---|
1235 | SeriesData=get(handles.series,'UserData');% |
---|
1236 | if ~isfield(SeriesData,'Time') |
---|
1237 | return |
---|
1238 | end |
---|
1239 | PairString=get(handles.PairString,'Data'); |
---|
1240 | ref_i_1=str2num(get(handles.num_first_i,'String'));%first reference index |
---|
1241 | ref_i_2=str2num(get(handles.num_last_i,'String'));%last reference index |
---|
1242 | ref_j_1=[];ref_j_2=[]; |
---|
1243 | if strcmp(get(handles.num_first_j,'Visible'),'on') |
---|
1244 | ref_j_1=str2num(get(handles.num_first_j,'String')); |
---|
1245 | ref_j_2=str2num(get(handles.num_last_j,'String')); |
---|
1246 | end |
---|
1247 | [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString); |
---|
1248 | [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString); |
---|
1249 | TimeTable=get(handles.TimeTable,'Data'); |
---|
1250 | %%%%%% |
---|
1251 | %TODO: read time in netcdf file, see ActionName_Callback |
---|
1252 | %%%%%%% |
---|
1253 | %Pairs=get(handles.PairString,'Data'); |
---|
1254 | for iview=1:size(TimeTable,1) |
---|
1255 | if size(SeriesData.Time,1)<iview |
---|
1256 | break |
---|
1257 | end |
---|
1258 | TimeTable{iview,3}=[]; |
---|
1259 | TimeTable{iview,4}=[]; |
---|
1260 | if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1) |
---|
1261 | if isempty(ref_j_1) |
---|
1262 | time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2; |
---|
1263 | time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2; |
---|
1264 | else |
---|
1265 | time_first=(SeriesData.Time{iview}(i1_1+1,j1_1+1)+SeriesData.Time{iview}(i2_1+1,j2_1+1))/2; |
---|
1266 | time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2; |
---|
1267 | end |
---|
1268 | TimeTable{iview,3}=time_first; %TODO: take into account pairs |
---|
1269 | TimeTable{iview,4}=time_last; %TODO: take into account pairs |
---|
1270 | end |
---|
1271 | end |
---|
1272 | set(handles.TimeTable,'Data',TimeTable) |
---|
1273 | |
---|
1274 | %% set the waitbar position with respect to the min and max in the series |
---|
1275 | MinIndex_i=min(get(handles.MinIndex_i,'Data')); |
---|
1276 | MaxIndex_i=max(get(handles.MaxIndex_i,'Data')); |
---|
1277 | pos_first=(ref_i_1-MinIndex_i)/(MaxIndex_i-MinIndex_i+1); |
---|
1278 | pos_last=(ref_i_2-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1); |
---|
1279 | if isempty(pos_first), pos_first=0; end |
---|
1280 | if isempty(pos_last), pos_last=1; end |
---|
1281 | Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] |
---|
1282 | Position_status=get(handles.FileStatus,'Position'); |
---|
1283 | Position(1)=Position_status(1)+Position_status(3)*pos_first; |
---|
1284 | Position(3)=max(Position_status(3)*(pos_last-pos_first),0.001);% width must remain positive |
---|
1285 | set(handles.Waitbar,'Position',Position) |
---|
1286 | update_waitbar(handles.Waitbar,0) |
---|
1287 | |
---|
1288 | %------------------------------------------------------------------------ |
---|
1289 | % --- Executes when selected cell(s) is changed in PairString. |
---|
1290 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
1291 | %------------------------------------------------------------------------ |
---|
1292 | if numel(eventdata.Indices)>=1 |
---|
1293 | PairString=get(hObject,'Data'); |
---|
1294 | if ~isempty(PairString{eventdata.Indices(1)}) |
---|
1295 | SetPairs_Callback(hObject, eventdata.Indices(1), handles) |
---|
1296 | end |
---|
1297 | end |
---|
1298 | |
---|
1299 | %------------------------------------- |
---|
1300 | function enable_i(handles,state) |
---|
1301 | set(handles.i_txt,'Visible',state) |
---|
1302 | set(handles.num_first_i,'Visible',state) |
---|
1303 | set(handles.num_last_i,'Visible',state) |
---|
1304 | set(handles.num_incr_i,'Visible',state) |
---|
1305 | |
---|
1306 | %----------------------------------- |
---|
1307 | function enable_j(handles,state) |
---|
1308 | set(handles.j_txt,'Visible',state) |
---|
1309 | set(handles.num_first_j,'Visible',state) |
---|
1310 | set(handles.num_last_j,'Visible',state) |
---|
1311 | set(handles.num_incr_j,'Visible',state) |
---|
1312 | set(handles.MinIndex_j,'Visible',state) |
---|
1313 | set(handles.MaxIndex_j,'Visible',state) |
---|
1314 | |
---|
1315 | |
---|
1316 | %%%%%%%%%%%%%%%%%%%% |
---|
1317 | %% MAIN ActionName FUNCTIONS |
---|
1318 | %%%%%%%%%%%%%%%%%%%% |
---|
1319 | %------------------------------------------------------------------------ |
---|
1320 | % --- Executes on button press in RUN. |
---|
1321 | %------------------------------------------------------------------------ |
---|
1322 | function RUN_Callback(hObject, eventdata, handles) |
---|
1323 | |
---|
1324 | %% read the data on the GUI series |
---|
1325 | Param=read_GUI_series(handles);%displayed parameters |
---|
1326 | SeriesData=get(handles.series,'UserData');%hidden parameters |
---|
1327 | if ~isfield(SeriesData,'i1_series') |
---|
1328 | msgbox_uvmat('ERROR','The input field series needs to be refreshed: press REFRESH') |
---|
1329 | return |
---|
1330 | end |
---|
1331 | if isfield(Param,'InputFields')&& isequal(Param.InputFields.FieldName,'get_field...') |
---|
1332 | msgbox_uvmat('ERROR','input field name(s) not defined, select get_field...') |
---|
1333 | return |
---|
1334 | end |
---|
1335 | |
---|
1336 | %% settings of the button RUN |
---|
1337 | set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel' |
---|
1338 | set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished |
---|
1339 | set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color |
---|
1340 | drawnow |
---|
1341 | set(handles.status,'Value',0)% desable status display if relevant |
---|
1342 | status_Callback(hObject, eventdata, handles) |
---|
1343 | |
---|
1344 | %% select the Action mode, 'local', 'background' or 'cluster' (if available) |
---|
1345 | RunMode='local';%default (needed for first opening of the GUI series) |
---|
1346 | if isfield(Param.Action,'RunMode') |
---|
1347 | RunMode=Param.Action.RunMode; |
---|
1348 | Param.Action=rmfield(Param.Action,'RunMode');%remove from the recorded xml file to avoid interference during ImportConfig |
---|
1349 | end |
---|
1350 | ActionExt='.m';%default |
---|
1351 | if isfield(Param.Action,'ActionExt') |
---|
1352 | ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled) |
---|
1353 | Param.Action=rmfield(Param.Action,'ActionExt');%remove from the recorded xml file to avoid interference during ImportConfig |
---|
1354 | end |
---|
1355 | ActionName=Param.Action.ActionName; |
---|
1356 | ActionPath=Param.Action.ActionPath; |
---|
1357 | |
---|
1358 | path_series=fileparts(which('series')); |
---|
1359 | |
---|
1360 | %% create the Action fct handle if RunMode option = 'local' |
---|
1361 | if strcmp(RunMode,'local') |
---|
1362 | if ~isequal(ActionPath,path_series) |
---|
1363 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION |
---|
1364 | if ~exist(ActionPath,'dir') |
---|
1365 | msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']); |
---|
1366 | return |
---|
1367 | end |
---|
1368 | if ~isequal(spath,ActionPath) |
---|
1369 | addpath(ActionPath)% add the prescribed path if not the current one |
---|
1370 | end |
---|
1371 | end |
---|
1372 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION |
---|
1373 | if ~isequal(ActionPath,path_series) |
---|
1374 | rmpath(ActionPath)% add the prescribed path if not the current one |
---|
1375 | end |
---|
1376 | end |
---|
1377 | |
---|
1378 | %% Get RunTime code from the file PARAM.xml (needed to run compiled functions) |
---|
1379 | errormsg='';%default error message |
---|
1380 | xmlfile=fullfile(path_series,'PARAM.xml'); |
---|
1381 | test_batch=0;%default: ,no batch mode available |
---|
1382 | if ~exist(xmlfile,'file') |
---|
1383 | [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile); |
---|
1384 | end |
---|
1385 | RunTime=''; |
---|
1386 | if strcmp(ActionExt,'.sh') |
---|
1387 | if exist(xmlfile,'file') |
---|
1388 | s=xml2struct(xmlfile); |
---|
1389 | if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam') |
---|
1390 | if isfield(s.BatchParam,'RunTime') |
---|
1391 | RunTime=s.BatchParam.RunTime; |
---|
1392 | end |
---|
1393 | if isfield(s.BatchParam,'NbCore') |
---|
1394 | NbCore=s.BatchParam.NbCore; |
---|
1395 | end |
---|
1396 | elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam') |
---|
1397 | if isfield(s.RunParam,'RunTime') |
---|
1398 | RunTime=s.RunParam.RunTime; |
---|
1399 | end |
---|
1400 | if isfield(s.RunParam,'NbCore') |
---|
1401 | NbCore=s.RunParam.NbCore; |
---|
1402 | end |
---|
1403 | end |
---|
1404 | end |
---|
1405 | if isempty(RunTime) && strcmp(RunMode,'cluster_oar') |
---|
1406 | msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster') |
---|
1407 | return |
---|
1408 | end |
---|
1409 | end |
---|
1410 | |
---|
1411 | %% If a compiled version has been selected (ext .sh) check weather it needs to be recompiled |
---|
1412 | if strcmp(ActionExt,'.sh') |
---|
1413 | TransformPath=''; |
---|
1414 | if ~isempty(get(handles.ActionExt,'UserData')) |
---|
1415 | TransformPath=get(handles.ActionExt,'UserData'); |
---|
1416 | end |
---|
1417 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
1418 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
1419 | ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']); |
---|
1420 | if ~exist(ActionFullName,'file') |
---|
1421 | answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?'); |
---|
1422 | if strcmp(answer,'Yes') |
---|
1423 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
1424 | path_uvmat=fileparts(which('series')); |
---|
1425 | currentdir=pwd; |
---|
1426 | cd(get(handles.ActionPath,'String'))% go to the directory of Action |
---|
1427 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile' |
---|
1428 | compile(ActionName,TransformPath) |
---|
1429 | cd(currentdir) |
---|
1430 | end |
---|
1431 | else |
---|
1432 | sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh'])); |
---|
1433 | m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m'])); |
---|
1434 | if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum |
---|
1435 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
1436 | drawnow |
---|
1437 | answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']); |
---|
1438 | if strcmp(answer,'Yes') |
---|
1439 | path_uvmat=fileparts(which('series')); |
---|
1440 | currentdir=pwd; |
---|
1441 | cd(get(handles.ActionPath,'String'))% go to the directory of Action |
---|
1442 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile' |
---|
1443 | addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile' |
---|
1444 | compile(ActionName,TransformPath) |
---|
1445 | cd(currentdir) |
---|
1446 | end |
---|
1447 | end |
---|
1448 | end |
---|
1449 | set(handles.ActionExt,'BackgroundColor',[1 1 1]) |
---|
1450 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch |
---|
1451 | end |
---|
1452 | |
---|
1453 | %% set nbre of cluster cores and processes |
---|
1454 | switch RunMode |
---|
1455 | case {'local','background'} |
---|
1456 | NbCore=1;% no need to split the calculation |
---|
1457 | case 'cluster_oar' |
---|
1458 | if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled) |
---|
1459 | NbCore=1;% one core used only (limitation of Matlab licences) |
---|
1460 | msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing'); |
---|
1461 | extra_oar=''; |
---|
1462 | else |
---|
1463 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); |
---|
1464 | NbCore=str2double(answer{1}); |
---|
1465 | extra_oar=answer{2}; |
---|
1466 | end |
---|
1467 | end |
---|
1468 | if ~isfield(Param.IndexRange,'NbSlice') |
---|
1469 | Param.IndexRange.NbSlice=[]; |
---|
1470 | end |
---|
1471 | if isempty(Param.IndexRange.NbSlice) |
---|
1472 | NbProcess=NbCore;% choose one process per core |
---|
1473 | else |
---|
1474 | NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices |
---|
1475 | NbCore=min(NbCore,NbProcess);% at least one process per core |
---|
1476 | end |
---|
1477 | |
---|
1478 | %% create the output data directory if needed |
---|
1479 | if isfield(Param,'OutputSubDir') |
---|
1480 | SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt]; |
---|
1481 | SubDirOutNew=SubDirOut; |
---|
1482 | detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist |
---|
1483 | check_create=1; %need to create the result directory by default |
---|
1484 | while detect |
---|
1485 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); |
---|
1486 | if strcmp(answer,'Cancel') |
---|
1487 | errormsg='Cancel'; |
---|
1488 | return |
---|
1489 | elseif strcmp(answer,'Yes') |
---|
1490 | detect=0; |
---|
1491 | check_create=0; |
---|
1492 | else |
---|
1493 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
1494 | if isempty(r) |
---|
1495 | r(1).root=[SubDirOutNew '_']; |
---|
1496 | r(1).num1='0'; |
---|
1497 | end |
---|
1498 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
1499 | detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists |
---|
1500 | check_create=1; |
---|
1501 | end |
---|
1502 | end |
---|
1503 | Param.OutputDirExt=regexprep(SubDirOutNew,Param.OutputSubDir,''); |
---|
1504 | Param.OutputRootFile=Param.InputTable{1,3};% the first sorted RootFile taken for output |
---|
1505 | set(handles.OutputDirExt,'String',Param.OutputDirExt) |
---|
1506 | OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);% full name (with path) of output directory |
---|
1507 | if check_create % create output directory if it does not exist |
---|
1508 | [tild,msg1]=mkdir(OutputDir); |
---|
1509 | if ~strcmp(msg1,'') |
---|
1510 | msgbox_uvmat('ERROR',['cannot create ' OutputDir ': ' msg1]);%error message for directory creation |
---|
1511 | return |
---|
1512 | end |
---|
1513 | [success,msg] = fileattrib(OutputDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder |
---|
1514 | if success==0 |
---|
1515 | msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation |
---|
1516 | return |
---|
1517 | end |
---|
1518 | end |
---|
1519 | OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files |
---|
1520 | DirXml=fullfile(OutputDir,'0_XML'); |
---|
1521 | if ~exist(DirXml,'dir') |
---|
1522 | [tild,msg1]=mkdir(DirXml); |
---|
1523 | if ~strcmp(msg1,'') |
---|
1524 | msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation |
---|
1525 | return |
---|
1526 | end |
---|
1527 | [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder |
---|
1528 | if success==0 |
---|
1529 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg});%error message for directory creation |
---|
1530 | end |
---|
1531 | end |
---|
1532 | end |
---|
1533 | |
---|
1534 | %% get the set of reference field indices |
---|
1535 | first_i=1; |
---|
1536 | last_i=1; |
---|
1537 | incr_i=1; |
---|
1538 | first_j=1; |
---|
1539 | last_j=1; |
---|
1540 | incr_j=1; |
---|
1541 | if isfield(Param.IndexRange,'first_i') |
---|
1542 | first_i=Param.IndexRange.first_i; |
---|
1543 | incr_i=Param.IndexRange.incr_i; |
---|
1544 | last_i=Param.IndexRange.last_i; |
---|
1545 | end |
---|
1546 | if isfield(Param.IndexRange,'first_j') |
---|
1547 | first_j=Param.IndexRange.first_j; |
---|
1548 | last_j=Param.IndexRange.last_j; |
---|
1549 | incr_j=Param.IndexRange.incr_j; |
---|
1550 | end |
---|
1551 | if last_i < first_i || last_j < first_j |
---|
1552 | msgbox_uvmat('ERROR', 'series/Run_Callback:last field index must be larger or equal to the first one') |
---|
1553 | set(handles.RUN, 'Enable','On'), |
---|
1554 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1555 | return |
---|
1556 | end |
---|
1557 | %incr_i must be defined, =1 by default, if NbSlice is active |
---|
1558 | if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice) |
---|
1559 | incr_i=1; |
---|
1560 | set(handles.num_incr_i,'String','1') |
---|
1561 | end |
---|
1562 | if isempty(incr_i) |
---|
1563 | if isempty(incr_j) |
---|
1564 | [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); |
---|
1565 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); |
---|
1566 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); |
---|
1567 | ref_j=ref_j-1; |
---|
1568 | ref_i=ref_i-1; |
---|
1569 | else |
---|
1570 | ref_j=first_j:incr_j:last_j; |
---|
1571 | [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); |
---|
1572 | ref_i=ref_i-1; |
---|
1573 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); |
---|
1574 | end |
---|
1575 | else |
---|
1576 | ref_i=first_i:incr_i:last_i; |
---|
1577 | if isempty(incr_j) |
---|
1578 | [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); |
---|
1579 | ref_j=ref_j-1; |
---|
1580 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); |
---|
1581 | else |
---|
1582 | ref_j=first_j:incr_j:last_j; |
---|
1583 | end |
---|
1584 | end |
---|
1585 | BlockLength=ceil(numel(ref_i)/NbProcess); |
---|
1586 | nbfield_j=numel(ref_j); |
---|
1587 | |
---|
1588 | %% record nbre of output files and starting time for computation for status |
---|
1589 | StatusData=get(handles.status,'UserData'); |
---|
1590 | if isfield(StatusData,'OutputFileMode') |
---|
1591 | switch StatusData.OutputFileMode |
---|
1592 | case 'NbInput' |
---|
1593 | StatusData.NbOutputFile=numel(ref_i)*nbfield_j; |
---|
1594 | case 'NbInput_i' |
---|
1595 | StatusData.NbOutputFile=numel(ref_i); |
---|
1596 | case 'NbSlice' |
---|
1597 | StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String')); |
---|
1598 | end |
---|
1599 | end |
---|
1600 | StatusData.TimeStart=now; |
---|
1601 | set(handles.status,'UserData',StatusData) |
---|
1602 | |
---|
1603 | %% direct processing on the current Matlab session |
---|
1604 | if strcmp (RunMode,'local') |
---|
1605 | for iprocess=1:NbProcess |
---|
1606 | if isempty(Param.IndexRange.NbSlice) |
---|
1607 | %Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; |
---|
1608 | Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength); |
---|
1609 | if Param.IndexRange.first_i>last_i |
---|
1610 | break |
---|
1611 | end |
---|
1612 | Param.IndexRange.last_i=min(ref_i(iprocess*BlockLength),last_i); |
---|
1613 | %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i); |
---|
1614 | else %multislices (then incr_i is not empty) |
---|
1615 | Param.IndexRange.first_i= first_i+incr_i*(iprocess-1); |
---|
1616 | Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; |
---|
1617 | end |
---|
1618 | if isfield(Param,'OutputSubDir') |
---|
1619 | t=struct2xml(Param); |
---|
1620 | t=set(t,1,'name','Series'); |
---|
1621 | filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... |
---|
1622 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1623 | save(t,filexml); |
---|
1624 | end |
---|
1625 | switch ActionExt |
---|
1626 | case '.m' |
---|
1627 | h_fun(Param); |
---|
1628 | case '.sh' |
---|
1629 | switch computer |
---|
1630 | case {'PCWIN','PCWIN64'} %Windows system |
---|
1631 | filexml=regexprep(filexml,'\\','\\\\');% add '\' so that '\' are left as characters |
---|
1632 | system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]);% TODO: adapt to DOS system |
---|
1633 | case {'GLNX86','GLNXA64','MACI64'}%Linux system |
---|
1634 | system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]); |
---|
1635 | end |
---|
1636 | end |
---|
1637 | end |
---|
1638 | elseif strcmp(get(handles.OutputDirExt,'Visible'),'off') |
---|
1639 | msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option |
---|
1640 | return |
---|
1641 | else |
---|
1642 | %% processing on a different session of the same computer (background) or cluster, create executable files |
---|
1643 | batch_file_list=cell(NbProcess,1);% initiate the list of executable files |
---|
1644 | DirBat=fullfile(OutputDir,'0_EXE'); |
---|
1645 | switch computer |
---|
1646 | case {'PCWIN','PCWIN64'} %Windows system |
---|
1647 | ExeExt='.bat'; |
---|
1648 | case {'GLNX86','GLNXA64','MACI64'}%Linux system |
---|
1649 | ExeExt='.sh'; |
---|
1650 | end |
---|
1651 | %create subdirectory for executable files |
---|
1652 | if ~exist(DirBat,'dir') |
---|
1653 | [tild,msg1]=mkdir(DirBat); |
---|
1654 | if ~strcmp(msg1,'') |
---|
1655 | msgbox_uvmat('ERROR',['cannot create ' DirBat ': ' msg1]);%error message for directory creation |
---|
1656 | return |
---|
1657 | end |
---|
1658 | end |
---|
1659 | %create subdirectory for log files |
---|
1660 | DirLog=fullfile(OutputDir,'0_LOG'); |
---|
1661 | if ~exist(DirLog,'dir') |
---|
1662 | [tild,msg1]=mkdir(DirLog); |
---|
1663 | if ~strcmp(msg1,'') |
---|
1664 | msgbox_uvmat('ERROR',['cannot create ' DirLog ': ' msg1]);%error message for directory creation |
---|
1665 | return |
---|
1666 | end |
---|
1667 | end |
---|
1668 | for iprocess=1:NbProcess |
---|
1669 | if isempty(Param.IndexRange.NbSlice)% process by blocks of i index |
---|
1670 | Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; |
---|
1671 | if Param.IndexRange.first_i>last_i |
---|
1672 | NbProcess=iprocess-1; |
---|
1673 | break% leave the loop, we are at the end of the calculation |
---|
1674 | end |
---|
1675 | Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1); |
---|
1676 | else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1 |
---|
1677 | Param.IndexRange.first_i= first_i+iprocess-1; |
---|
1678 | Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; |
---|
1679 | end |
---|
1680 | |
---|
1681 | % create, fill and save the xml parameter file |
---|
1682 | t=struct2xml(Param); |
---|
1683 | t=set(t,1,'name','Series'); |
---|
1684 | filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... |
---|
1685 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1686 | save(t,filexml);% save the parameter file |
---|
1687 | |
---|
1688 | %create the executable file |
---|
1689 | filebat=fullfile_uvmat(DirBat,'',Param.InputTable{1,3},ExeExt,OutputNomType,... |
---|
1690 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1691 | batch_file_list{iprocess}=filebat; |
---|
1692 | [fid,message]=fopen(filebat,'w');% create the executable file |
---|
1693 | if isequal(fid,-1) |
---|
1694 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); |
---|
1695 | return |
---|
1696 | end |
---|
1697 | |
---|
1698 | % set the log file name |
---|
1699 | filelog=fullfile_uvmat(DirLog,'',Param.InputTable{1,3},'.log',OutputNomType,... |
---|
1700 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1701 | |
---|
1702 | % fill and save the executable file |
---|
1703 | switch ActionExt |
---|
1704 | case '.m'% Matlab function |
---|
1705 | switch computer |
---|
1706 | case {'GLNX86','GLNXA64','MACI64'} |
---|
1707 | cmd=[... |
---|
1708 | '#!/bin/bash \n'... |
---|
1709 | '. /etc/sysprofile \n'... |
---|
1710 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... |
---|
1711 | 'addpath(''' path_series '''); \n'... |
---|
1712 | 'addpath(''' Param.Action.ActionPath '''); \n'... |
---|
1713 | '' Param.Action.ActionName '( ''' filexml '''); \n'... |
---|
1714 | 'exit \n'... |
---|
1715 | 'END_MATLAB \n']; |
---|
1716 | fprintf(fid,cmd);%fill the executable file with the char string cmd |
---|
1717 | fclose(fid);% close the executable file |
---|
1718 | system(['chmod +x ' filebat]);% set the file to executable |
---|
1719 | case {'PCWIN','PCWIN64'} |
---|
1720 | text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
1721 | ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... |
---|
1722 | 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'... |
---|
1723 | '' Param.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
1724 | fprintf(fid,text_matlabscript);%fill the executable file with the char string cmd |
---|
1725 | fclose(fid);% close the executable file |
---|
1726 | end |
---|
1727 | case '.sh' % compiled Matlab function |
---|
1728 | switch computer |
---|
1729 | case {'GLNX86','GLNXA64','MACI64'} |
---|
1730 | cmd=['#!/bin/bash \n '... |
---|
1731 | '#$ -cwd \n '... |
---|
1732 | 'hostname && date \n '... |
---|
1733 | 'umask 002 \n'... |
---|
1734 | fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml];%allow writting access to created files for user group |
---|
1735 | fprintf(fid,cmd);%fill the executable file with the char string cmd |
---|
1736 | fclose(fid);% close the executable file |
---|
1737 | system(['chmod +x ' filebat]);% set the file to executable |
---|
1738 | |
---|
1739 | case {'PCWIN','PCWIN64'} |
---|
1740 | fprintf(fid,cmd); |
---|
1741 | fclose(fid); |
---|
1742 | end |
---|
1743 | end |
---|
1744 | end |
---|
1745 | end |
---|
1746 | |
---|
1747 | %% launch the executable files for background or cluster processing |
---|
1748 | switch RunMode |
---|
1749 | case 'background' |
---|
1750 | for iprocess=1:NbProcess |
---|
1751 | system([batch_file_list{iprocess} ' &'])% directly execute the command file for each process |
---|
1752 | msgbox_uvmat('CONFIRMATION',[ActionName 'launched in background: press STATUS to see results']) |
---|
1753 | end |
---|
1754 | case 'cluster_oar' % option 'oar-parexec' used |
---|
1755 | %create subdirectory for oar command and log files |
---|
1756 | DirOAR=fullfile(OutputDir,'0_OAR'); |
---|
1757 | if exist(DirOAR,'dir')% delete the content of the dir 0_OAR to allow new input |
---|
1758 | curdir=pwd; |
---|
1759 | cd(DirOAR) |
---|
1760 | delete('*') |
---|
1761 | cd(curdir) |
---|
1762 | else |
---|
1763 | [tild,msg1]=mkdir(DirOAR); |
---|
1764 | if ~strcmp(msg1,'') |
---|
1765 | msgbox_uvmat('ERROR',['cannot create ' DirOAR ': ' msg1]);%error message for directory creation |
---|
1766 | return |
---|
1767 | end |
---|
1768 | end |
---|
1769 | max_walltime=3600*20; % 20h max total calculation (cannot exceed 24 h) |
---|
1770 | walltime_onejob=600;%seconds, max estimated time for asingle file index value |
---|
1771 | filename_joblist=fullfile(DirOAR,'job_list.txt');%create name of the global executable file |
---|
1772 | fid=fopen(filename_joblist,'w'); |
---|
1773 | for p=1:length(batch_file_list) |
---|
1774 | fprintf(fid,[batch_file_list{p} '\n']);% list of exe files |
---|
1775 | end |
---|
1776 | fclose(fid); |
---|
1777 | system(['chmod +x ' filename_joblist]);% set the file to executable |
---|
1778 | oar_command=['oarsub -n CIVX '... |
---|
1779 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... |
---|
1780 | '-l /core=' num2str(NbCore) ','... |
---|
1781 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '... |
---|
1782 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
1783 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
1784 | extra_oar ' '... |
---|
1785 | '"oar-parexec -s -f ' filename_joblist ' '... |
---|
1786 | '-l ' filename_joblist '.log"\n']; |
---|
1787 | filename_oarcommand=fullfile(DirOAR,'oar_command'); |
---|
1788 | fid=fopen(filename_oarcommand,'w'); |
---|
1789 | fprintf(fid,oar_command); |
---|
1790 | fclose(fid); |
---|
1791 | fprintf(oar_command);% display in command line |
---|
1792 | system(oar_command); |
---|
1793 | msgbox_uvmat('CONFIRMATION',[ActionName ' launched in cluster: press STATUS to see results']) |
---|
1794 | end |
---|
1795 | |
---|
1796 | %% reset the GUI series |
---|
1797 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished |
---|
1798 | set(handles.RUN, 'Enable','On') |
---|
1799 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1800 | set(handles.RUN, 'Value',0) |
---|
1801 | |
---|
1802 | %------------------------------------------------------------------------ |
---|
1803 | function STOP_Callback(hObject, eventdata, handles) |
---|
1804 | %------------------------------------------------------------------------ |
---|
1805 | set(handles.RUN, 'BusyAction','cancel') |
---|
1806 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1807 | set(handles.RUN,'enable','on') |
---|
1808 | set(handles.RUN, 'Value',0) |
---|
1809 | |
---|
1810 | |
---|
1811 | %------------------------------------------------------------------------ |
---|
1812 | % --- read parameters from the GUI series |
---|
1813 | %------------------------------------------------------------------------ |
---|
1814 | function Param=read_GUI_series(handles) |
---|
1815 | |
---|
1816 | %% read raw parameters from the GUI series |
---|
1817 | Param=read_GUI(handles.series); |
---|
1818 | |
---|
1819 | %% clean the output structure by removing unused information |
---|
1820 | if isfield(Param,'Pairs') |
---|
1821 | Param=rmfield(Param,'Pairs'); %info Pairs not needed for output |
---|
1822 | end |
---|
1823 | Param.IndexRange=rmfield(Param.IndexRange,'TimeTable'); |
---|
1824 | empty_line=false(size(Param.InputTable,1),1); |
---|
1825 | for iline=1:size(Param.InputTable,1) |
---|
1826 | empty_line(iline)=isempty(cell2mat(Param.InputTable(iline,1:3))); |
---|
1827 | end |
---|
1828 | Param.InputTable(empty_line,:)=[]; |
---|
1829 | |
---|
1830 | %------------------------------------------------------------------------ |
---|
1831 | % --- Executes on selection change in ActionName. |
---|
1832 | function ActionName_Callback(hObject, eventdata, handles) |
---|
1833 | %------------------------------------------------------------------------ |
---|
1834 | |
---|
1835 | %% stop any ongoing series processing |
---|
1836 | if isequal(get(handles.RUN,'Value'),1) |
---|
1837 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); |
---|
1838 | if strcmp(answer,'Yes') |
---|
1839 | STOP_Callback(hObject, eventdata, handles) |
---|
1840 | else |
---|
1841 | return |
---|
1842 | end |
---|
1843 | end |
---|
1844 | set(handles.ActionName,'BackgroundColor',[1 1 0]) |
---|
1845 | huigetfile=findobj(allchild(0),'tag','status_display'); |
---|
1846 | if ~isempty(huigetfile) |
---|
1847 | delete(huigetfile) |
---|
1848 | end |
---|
1849 | drawnow |
---|
1850 | |
---|
1851 | %% get Action name and path |
---|
1852 | nb_builtin_ACTION=4; %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series) |
---|
1853 | ActionList=get(handles.ActionName,'String');% list menu fields |
---|
1854 | ActionIndex=get(handles.ActionName,'Value'); |
---|
1855 | if ~isequal(ActionIndex,1)% if we are not just opening series |
---|
1856 | InputTable=get(handles.InputTable,'Data'); |
---|
1857 | if isempty(InputTable{1,4}) |
---|
1858 | msgbox_uvmat('ERROR','no input file available: use Open in the menu bar') |
---|
1859 | return |
---|
1860 | end |
---|
1861 | end |
---|
1862 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name |
---|
1863 | ActionPathList=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ActionName |
---|
1864 | |
---|
1865 | %% add a new function to the menu if 'more...' has been selected in the menu ActionName |
---|
1866 | if isequal(ActionName,'more...') |
---|
1867 | [FileName, PathName] = uigetfile( ... |
---|
1868 | {'*.m', ' (*.m)'; |
---|
1869 | '*.m', '.m files '; ... |
---|
1870 | '*.*', 'All Files (*.*)'}, ... |
---|
1871 | 'Pick a series processing function ',get(handles.ActionPath,'String')); |
---|
1872 | if length(FileName)<2 |
---|
1873 | return |
---|
1874 | end |
---|
1875 | [ActionPath,ActionName,ActionExt]=fileparts(FileName); |
---|
1876 | |
---|
1877 | % insert the choice in the menu ActionName |
---|
1878 | ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action |
---|
1879 | if isempty(ActionIndex)%the input string does not exist in the menu |
---|
1880 | ActionIndex= length(ActionList); |
---|
1881 | ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)];% the selected function is appended in the menu, before the last item 'more...' |
---|
1882 | set(handles.ActionName,'String',ActionList) |
---|
1883 | end |
---|
1884 | |
---|
1885 | % record the file extension and extend the path list if it is a new extension |
---|
1886 | ActionExtList=get(handles.ActionExt,'String'); |
---|
1887 | ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1); |
---|
1888 | if isempty(ActionExtIndex) |
---|
1889 | set(handles.ActionExt,'String',[ActionExtList;{ActionExt}]) |
---|
1890 | ActionExtIndex=numel(ActionExtList)+1; |
---|
1891 | ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath |
---|
1892 | ActionPathList=[ActionPathList ActionPathNew]; |
---|
1893 | end |
---|
1894 | set(handles.ActionName,'UserData',ActionPathList); |
---|
1895 | |
---|
1896 | % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5) |
---|
1897 | if length(ActionList)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1898 | nbremove=length(ActionList)-nb_builtin_ACTION-5; |
---|
1899 | ActionList(nb_builtin_ACTION+1:end-5)=[]; |
---|
1900 | ActionPathList(nb_builtin_ACTION+1:end-4,:)=[]; |
---|
1901 | ActionIndex=ActionIndex-nbremove; |
---|
1902 | end |
---|
1903 | |
---|
1904 | % record action menu, choice and path |
---|
1905 | set(handles.ActionName,'Value',ActionIndex) |
---|
1906 | set(handles.ActionName,'String',ActionList) |
---|
1907 | set(handles.ActionExt,'Value',ActionExtIndex) |
---|
1908 | ActionPathList{ActionIndex,ActionExtIndex}=PathName; |
---|
1909 | |
---|
1910 | %record the user defined menu additions in personal file profil_perso |
---|
1911 | dir_perso=prefdir; |
---|
1912 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1913 | if nb_builtin_ACTION+1<=numel(ActionList)-1 |
---|
1914 | ActionListUser=ActionList(nb_builtin_ACTION+1:numel(ActionList)-1); |
---|
1915 | ActionPathListUser=ActionPathList(nb_builtin_ACTION+1:numel(ActionList)-1,:); |
---|
1916 | ActionExtListUser={}; |
---|
1917 | if numel(ActionExtList)>2 |
---|
1918 | ActionExtListUser=ActionExtList(3:end); |
---|
1919 | end |
---|
1920 | if exist(profil_perso,'file') |
---|
1921 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append') |
---|
1922 | else |
---|
1923 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6') |
---|
1924 | end |
---|
1925 | end |
---|
1926 | end |
---|
1927 | |
---|
1928 | %% check the current ActionPath to the selected function |
---|
1929 | ActionPath=ActionPathList{ActionIndex};%current recorded path |
---|
1930 | set(handles.ActionPath,'String',ActionPath); %show the path to the senlected function |
---|
1931 | |
---|
1932 | %% reinitialise the waitbar |
---|
1933 | update_waitbar(handles.Waitbar,0) |
---|
1934 | |
---|
1935 | %% create the function handle for Action |
---|
1936 | path_series=which('series'); |
---|
1937 | if ~isequal(ActionPath,path_series) |
---|
1938 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION |
---|
1939 | if ~exist(ActionPath,'dir') |
---|
1940 | errormsg=['The prescribed function path ' ActionPath ' does not exist']; |
---|
1941 | return |
---|
1942 | end |
---|
1943 | if ~isequal(spath,ActionPath) |
---|
1944 | addpath(ActionPath)% add the prescribed path if not the current one |
---|
1945 | end |
---|
1946 | end |
---|
1947 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION |
---|
1948 | if ~isequal(ActionPath,path_series) |
---|
1949 | rmpath(ActionPath)% add the prescribed path if not the current one |
---|
1950 | end |
---|
1951 | |
---|
1952 | %% Activate the Action fct |
---|
1953 | Param=read_GUI_series(handles);% read the parameters from the GUI series |
---|
1954 | ParamOut=h_fun(Param);%run the selected Action function to get the relevant input |
---|
1955 | |
---|
1956 | %% Put the first line of the selected Action fct as tooltip help |
---|
1957 | try |
---|
1958 | [fid,errormsg] =fopen([ActionName '.m']); |
---|
1959 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
1960 | fclose(fid); |
---|
1961 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help |
---|
1962 | end |
---|
1963 | |
---|
1964 | |
---|
1965 | %% Visibility of VelType and VelType_1 menus asked by ActionName |
---|
1966 | VelTypeRequest=1;%VelType requested by default |
---|
1967 | VelTypeRequest_1=1;%VelType requested by default |
---|
1968 | if isfield(ParamOut,'VelType') |
---|
1969 | VelTypeRequest=ismember(ParamOut.VelType,{'on','one','two'}); |
---|
1970 | VelTypeRequest_1=strcmp( ParamOut.VelType,'two'); |
---|
1971 | end |
---|
1972 | FieldNameRequest=0; %hidden by default |
---|
1973 | FieldNameRequest_1=0; %hidden by default |
---|
1974 | if isfield(ParamOut,'FieldName') |
---|
1975 | FieldNameRequest=ismember(ParamOut.FieldName,{'on','one','two'}); |
---|
1976 | FieldNameRequest_1=strcmp( ParamOut.FieldName,'two'); |
---|
1977 | end |
---|
1978 | |
---|
1979 | %% Detect the types of input files and set menus and default options in 'VelType' |
---|
1980 | SeriesData=get(handles.series,'UserData');% info on the input file series |
---|
1981 | iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); |
---|
1982 | iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ |
---|
1983 | FieldList=get(handles.FieldName,'String');% previous list as default |
---|
1984 | if ~iscell(FieldList),FieldList={FieldList};end |
---|
1985 | FieldList_1=get(handles.FieldName_1,'String');% previous list as default |
---|
1986 | if ~iscell(FieldList_1),FieldList_1={FieldList_1};end |
---|
1987 | CheckList=0;% indicate whether FieldName has been updated |
---|
1988 | CheckList_1=1;% indicate whether FieldName_1 has been updated |
---|
1989 | handles_coord=[handles.Coord_x handles.Coord_y handles.Coord_z handles.Coord_x_title handles.Coord_y_title handles.Coord_z_title]; |
---|
1990 | if VelTypeRequest && numel(iview_civ)>=1 |
---|
1991 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(1)}.CivStage,SeriesData.FileType{iview_civ(1)}); |
---|
1992 | set(handles.VelType,'Value',1)% set first choice by default |
---|
1993 | set(handles.VelType,'String',[{'*'};menu]) |
---|
1994 | set(handles.VelType,'Visible','on') |
---|
1995 | set(handles.VelType_title,'Visible','on') |
---|
1996 | FieldList=[set_field_list('U','V');{'C'};{'get_field...'}];%standard menu for civx data |
---|
1997 | CheckList=1; |
---|
1998 | set(handles.FieldName,'Value',1); %velocity vector choice by default |
---|
1999 | if VelTypeRequest_1 && numel(iview_civ)>=2 |
---|
2000 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)}); |
---|
2001 | set(handles.VelType_1,'Value',1)% set first choice by default |
---|
2002 | set(handles.VelType_1,'String',[{'*'};menu]) |
---|
2003 | set(handles.VelType_1,'Visible','on') |
---|
2004 | set(handles.VelType_title_1,'Visible','on') |
---|
2005 | FieldList_1=[set_field_list('U','V');{'C'};{'get_field...'}];%standard menu for civx data |
---|
2006 | CheckList_1=1; |
---|
2007 | set(handles.FieldName_1,'Value',1); %velocity vector choice by default |
---|
2008 | else |
---|
2009 | set(handles.VelType_1,'Visible','off') |
---|
2010 | set(handles.VelType_title_1,'Visible','off') |
---|
2011 | end |
---|
2012 | else |
---|
2013 | set(handles.VelType,'Visible','off') |
---|
2014 | set(handles.VelType_title,'Visible','off') |
---|
2015 | end |
---|
2016 | |
---|
2017 | %% Detect the types of input files and set menus and default options in 'FieldName' |
---|
2018 | if FieldNameRequest && numel(iview_netcdf)>=1 |
---|
2019 | set(handles.InputFields,'Visible','on') |
---|
2020 | % set(handles.FieldName,'Visible','on') |
---|
2021 | if CheckList==0 % not civ input made |
---|
2022 | ListVarName=SeriesData.FileInfo{iview_netcdf(1)}.ListVarName; |
---|
2023 | ind_var=get(handles.FieldName,'Value');%indices of previously selected variables |
---|
2024 | for ilist=1:numel(ind_var) |
---|
2025 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName))) |
---|
2026 | FieldList={};% previous choice not consistent with new input field |
---|
2027 | set(handles.FieldName,'Value',1) |
---|
2028 | break |
---|
2029 | end |
---|
2030 | end |
---|
2031 | if ~isempty(FieldList) |
---|
2032 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName)))||... |
---|
2033 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName))) |
---|
2034 | FieldList={}; |
---|
2035 | set(handles.Coord_x,'String','') |
---|
2036 | set(handles.Coord_y,'String','') |
---|
2037 | end |
---|
2038 | Coord_z=get(handles.Coord_z,'String'); |
---|
2039 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName))) |
---|
2040 | FieldList={}; |
---|
2041 | set(handles.Coord_z,'String','') |
---|
2042 | end |
---|
2043 | end |
---|
2044 | set(handles_coord,'Visible','on') |
---|
2045 | FieldList=[FieldList;{'get_field...'}]; |
---|
2046 | if FieldNameRequest_1 && numel(iview_netcdf)>=2 |
---|
2047 | set(handles.FieldName_1,'Visible','on') |
---|
2048 | if CheckList_1==0 % not civ input made |
---|
2049 | ListVarName=SeriesData.FileInfo{iview_netcdf(2)}.ListVarName; |
---|
2050 | ind_var=get(handles.FieldName,'Value');%indices of previously selected variables |
---|
2051 | for ilist=1:numel(ind_var) |
---|
2052 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName))) |
---|
2053 | FieldList_1={};% previous choice not consistent with new input field |
---|
2054 | set(handles.FieldName_1,'Value',1) |
---|
2055 | break |
---|
2056 | end |
---|
2057 | end |
---|
2058 | warn_coord=0; |
---|
2059 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName)))||... |
---|
2060 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName))) |
---|
2061 | warn_coord=1; |
---|
2062 | end |
---|
2063 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName))) |
---|
2064 | FieldList_1={}; |
---|
2065 | warn_coord=1; |
---|
2066 | end |
---|
2067 | if warn_coord |
---|
2068 | msgbox_uvmat('WARNING','coordiante names do not exist in the second netcdf input file') |
---|
2069 | end |
---|
2070 | set(handles.FieldName,'String',[FieldList;{'get_field...'}]) |
---|
2071 | set(handles.FieldName_1,'Visible','on') |
---|
2072 | set(handles.FieldName_1,'Value',1) |
---|
2073 | set(handles.FieldName_1,'String',FieldList_1) |
---|
2074 | end |
---|
2075 | else |
---|
2076 | set(handles.FieldName_1,'Visible','off') |
---|
2077 | end |
---|
2078 | else |
---|
2079 | set(handles_coord,'Visible','off')% no coord display for civ data |
---|
2080 | end |
---|
2081 | set(handles.FieldName,'String',FieldList) |
---|
2082 | else |
---|
2083 | set(handles.InputFields,'Visible','off') |
---|
2084 | end |
---|
2085 | |
---|
2086 | |
---|
2087 | %% Check whether alphabetical sorting of input Subdir is allowed by the Action fct (for multiples series entries) |
---|
2088 | if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1 |
---|
2089 | [tild,iview]=sort(InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
2090 | set(handles.InputTable,'Data',InputTable(iview,:)); |
---|
2091 | MinIndex_i=get(handles.MinIndex_i,'Data'); |
---|
2092 | MinIndex_j=get(handles.MinIndex_j,'Data'); |
---|
2093 | MaxIndex_i=get(handles.MaxIndex_i,'Data'); |
---|
2094 | MaxIndex_j=get(handles.MaxIndex_j,'Data'); |
---|
2095 | set(handles.MinIndex_i,'Data',MinIndex_i(iview,:)); |
---|
2096 | set(handles.MinIndex_j,'Data',MinIndex_j(iview,:)); |
---|
2097 | set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:)); |
---|
2098 | set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:)); |
---|
2099 | TimeTable=get(handles.TimeTable,'Data'); |
---|
2100 | set(handles.TimeTable,'Data',TimeTable(iview,:)); |
---|
2101 | PairString=get(handles.PairString,'Data'); |
---|
2102 | set(handles.PairString,'Data',PairString(iview,:)); |
---|
2103 | end |
---|
2104 | |
---|
2105 | %% Impose the whole input file index range if requested |
---|
2106 | if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on') |
---|
2107 | MinIndex_i=get(handles.MinIndex_i,'Data'); |
---|
2108 | MinIndex_j=get(handles.MinIndex_j,'Data'); |
---|
2109 | MaxIndex_i=get(handles.MaxIndex_i,'Data'); |
---|
2110 | MaxIndex_j=get(handles.MaxIndex_j,'Data'); |
---|
2111 | set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line) |
---|
2112 | set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line) |
---|
2113 | set(handles.num_incr_i,'String','1') |
---|
2114 | set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line) |
---|
2115 | set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line) |
---|
2116 | set(handles.num_incr_j,'String','1') |
---|
2117 | else % check index ranges |
---|
2118 | first_i=1;last_i=1;first_j=1;last_j=1; |
---|
2119 | if isfield(Param.IndexRange,'first_i') |
---|
2120 | first_i=Param.IndexRange.first_i; |
---|
2121 | last_i=Param.IndexRange.last_i; |
---|
2122 | end |
---|
2123 | if isfield(Param.IndexRange,'first_j') |
---|
2124 | first_j=Param.IndexRange.first_j; |
---|
2125 | last_j=Param.IndexRange.last_j; |
---|
2126 | end |
---|
2127 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
2128 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
2129 | end |
---|
2130 | |
---|
2131 | %% enable or desable j index visibility |
---|
2132 | status_j='on';%default |
---|
2133 | if isfield(ParamOut,'Desable_j_index')&&isequal(ParamOut.Desable_j_index,'on') |
---|
2134 | status_j='off'; |
---|
2135 | end |
---|
2136 | if isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)); % case of empty j indices |
---|
2137 | status_j='off'; % no j index needed |
---|
2138 | elseif strcmp(get(handles.PairString,'Visible'),'on') |
---|
2139 | check_burst=cellfun(@isempty,regexp(get(handles.PairString,'Data'),'^j'));%=0 for burst case, 1 otherwise |
---|
2140 | if isempty(find(check_burst, 1))% if all pair string begins by j (burst) |
---|
2141 | status_j='off'; % no j index needed for bust case |
---|
2142 | end |
---|
2143 | end |
---|
2144 | enable_j(handles,status_j) % no j index needed |
---|
2145 | |
---|
2146 | |
---|
2147 | %% NbSlice visibility |
---|
2148 | NbSliceVisible='off';%default |
---|
2149 | if isfield(ParamOut,'NbSlice') && isequal(ParamOut.NbSlice,'on') |
---|
2150 | NbSliceVisible='on'; |
---|
2151 | set(handles.num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices |
---|
2152 | else |
---|
2153 | set(handles.num_NbProcess,'String','')% free nbre of processes |
---|
2154 | end |
---|
2155 | set(handles.num_NbSlice,'Visible',NbSliceVisible) |
---|
2156 | set(handles.NbSlice_title,'Visible',NbSliceVisible) |
---|
2157 | |
---|
2158 | |
---|
2159 | |
---|
2160 | %% Visibility of FieldTransform menu |
---|
2161 | FieldTransformVisible='off'; %hidden by default |
---|
2162 | if isfield(ParamOut,'FieldTransform') |
---|
2163 | FieldTransformVisible=ParamOut.FieldTransform; |
---|
2164 | TransformName_Callback([],[], handles) |
---|
2165 | end |
---|
2166 | set(handles.FieldTransform,'Visible',FieldTransformVisible) |
---|
2167 | if isfield(ParamOut,'TransformPath') |
---|
2168 | set(handles.ActionExt,'UserData',ParamOut.TransformPath) |
---|
2169 | else |
---|
2170 | set(handles.ActionExt,'UserData',[]) |
---|
2171 | end |
---|
2172 | |
---|
2173 | %% Visibility of projection object |
---|
2174 | ProjObjectVisible='off'; %hidden by default |
---|
2175 | if isfield(ParamOut,'ProjObject') |
---|
2176 | ProjObjectVisible=ParamOut.ProjObject; |
---|
2177 | end |
---|
2178 | set(handles.CheckObject,'Visible',ProjObjectVisible) |
---|
2179 | if ~get(handles.CheckObject,'Value') |
---|
2180 | ProjObjectVisible='off'; |
---|
2181 | end |
---|
2182 | set(handles.ProjObject,'Visible',ProjObjectVisible) |
---|
2183 | set(handles.DeleteObject,'Visible',ProjObjectVisible) |
---|
2184 | set(handles.ViewObject,'Visible',ProjObjectVisible) |
---|
2185 | set(handles.EditObject,'Visible',ProjObjectVisible) |
---|
2186 | |
---|
2187 | %% Visibility of mask input |
---|
2188 | MaskVisible='off'; %hidden by default |
---|
2189 | if isfield(ParamOut,'Mask') |
---|
2190 | MaskVisible=ParamOut.Mask; |
---|
2191 | end |
---|
2192 | set(handles.CheckMask,'Visible',MaskVisible); |
---|
2193 | |
---|
2194 | %% definition of the directory containing the output files |
---|
2195 | OutputDirVisible='off'; |
---|
2196 | if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt) |
---|
2197 | OutputSubDirMode='all';%default |
---|
2198 | if isfield(ParamOut,'OutputSubDirMode') |
---|
2199 | OutputSubDirMode=ParamOut.OutputSubDirMode; |
---|
2200 | end |
---|
2201 | set(handles.OutputDirExt,'String',ParamOut.OutputDirExt) |
---|
2202 | OutputDirVisible='on'; |
---|
2203 | SubDir=InputTable(1:end,2); %set of subdirectories sorted in alphabetical order |
---|
2204 | if strcmp(OutputSubDirMode,'last') |
---|
2205 | SubDirOut=SubDir{end}; |
---|
2206 | else |
---|
2207 | SubDirOut=SubDir{1}; |
---|
2208 | if ~strcmp(OutputSubDirMode,'first') && numel(SubDir)>1 |
---|
2209 | for ilist=2:numel(SubDir) |
---|
2210 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
2211 | end |
---|
2212 | end |
---|
2213 | end |
---|
2214 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
2215 | end |
---|
2216 | set(handles.OutputDirExt,'Visible',OutputDirVisible) |
---|
2217 | set(handles.OutputSubDir,'Visible',OutputDirVisible) |
---|
2218 | set(handles.OutputDir_title,'Visible',OutputDirVisible) |
---|
2219 | set(handles.RunMode,'Visible',OutputDirVisible) |
---|
2220 | set(handles.ActionExt,'Visible',OutputDirVisible) |
---|
2221 | set(handles.RunMode_title,'Visible',OutputDirVisible) |
---|
2222 | set(handles.ActionExt_title,'Visible',OutputDirVisible) |
---|
2223 | |
---|
2224 | |
---|
2225 | %% Expected nbre of output files |
---|
2226 | if isfield(ParamOut,'OutputFileMode') |
---|
2227 | StatusData.OutputFileMode=ParamOut.OutputFileMode; |
---|
2228 | set(handles.status,'UserData',StatusData) |
---|
2229 | end |
---|
2230 | |
---|
2231 | %% definition of an additional parameter set, determined by an ancillary GUI |
---|
2232 | if isfield(ParamOut,'ActionInput') |
---|
2233 | set(handles.ActionInput,'Visible','on') |
---|
2234 | ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput |
---|
2235 | SeriesData.ActionInput=ParamOut.ActionInput; |
---|
2236 | else |
---|
2237 | set(handles.ActionInput,'Visible','off') |
---|
2238 | if isfield(SeriesData,'ActionInput') |
---|
2239 | SeriesData=rmfield(SeriesData,'ActionInput'); |
---|
2240 | end |
---|
2241 | end |
---|
2242 | set(handles.series,'UserData',SeriesData) |
---|
2243 | set(handles.ActionName,'BackgroundColor',[1 1 1]) |
---|
2244 | |
---|
2245 | %------------------------------------------------------------------------ |
---|
2246 | % --- Executes on button press in ActionInput. |
---|
2247 | function ActionInput_Callback(hObject, eventdata, handles) |
---|
2248 | %------------------------------------------------------------------------ |
---|
2249 | % if get(handles.ActionInput,'Value') |
---|
2250 | ActionName_Callback(hObject, eventdata, handles) |
---|
2251 | % end |
---|
2252 | |
---|
2253 | %------------------------------------------------------------------------ |
---|
2254 | % --- Executes on selection change in FieldName. |
---|
2255 | function FieldName_Callback(hObject, eventdata, handles) |
---|
2256 | %------------------------------------------------------------------------ |
---|
2257 | field_str=get(handles.FieldName,'String'); |
---|
2258 | field_index=get(handles.FieldName,'Value'); |
---|
2259 | field=field_str{field_index(1)}; |
---|
2260 | if isequal(field,'get_field...') |
---|
2261 | SeriesData=get(handles.series,'UserData'); |
---|
2262 | % input line for which the field choice is relevant |
---|
2263 | iview=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ |
---|
2264 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
2265 | if ~isempty(hget_field) |
---|
2266 | delete(hget_field)%delete opened versions of get_field |
---|
2267 | end |
---|
2268 | Param=read_GUI(handles.series); |
---|
2269 | InputTable=Param.InputTable(iview,:); |
---|
2270 | % check the existence of the first file in the series |
---|
2271 | first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1;%default setting for index j |
---|
2272 | if isfield(Param.IndexRange,'first_j');% if index j is used |
---|
2273 | first_j=Param.IndexRange.first_j; |
---|
2274 | last_j=Param.IndexRange.last_j; |
---|
2275 | MinIndex_j=Param.IndexRange.MinIndex_j(iview); |
---|
2276 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview); |
---|
2277 | end |
---|
2278 | PairString=''; |
---|
2279 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end |
---|
2280 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString); |
---|
2281 | FirstFileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},... |
---|
2282 | InputTable{5},InputTable{4},i1,i2,j1,j2); |
---|
2283 | if exist(FirstFileName,'file') |
---|
2284 | ParamIn.Title='get_field: pick input variables and coordinates for series processing'; |
---|
2285 | ParamIn.SeriesInput=1; |
---|
2286 | GetFieldData=get_field(FirstFileName,ParamIn); |
---|
2287 | FieldList={}; |
---|
2288 | switch GetFieldData.FieldOption |
---|
2289 | case 'vectors' |
---|
2290 | UName=GetFieldData.PanelVectors.vector_x; |
---|
2291 | VName=GetFieldData.PanelVectors.vector_y; |
---|
2292 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
2293 | FieldList={['vec(' UName ',' VName ')'];... |
---|
2294 | ['norm(' UName ',' VName ')'];... |
---|
2295 | UName;VName}; |
---|
2296 | case {'scalar'} |
---|
2297 | FieldList=GetFieldData.PanelScalar.scalar; |
---|
2298 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
2299 | if ischar(FieldList) |
---|
2300 | FieldList={FieldList}; |
---|
2301 | end |
---|
2302 | case 'civdata...' |
---|
2303 | FieldList=[set_field_list('U','V') ;{'C'}]; |
---|
2304 | set(handles.FieldName,'Value',1) % set menu to 'velocity |
---|
2305 | XName='X'; |
---|
2306 | YName='y'; |
---|
2307 | set(handles.VelType,'visible','on') |
---|
2308 | set(handles.VelType_title,'visible','on') |
---|
2309 | end |
---|
2310 | set(handles.FieldName,'Value',1) |
---|
2311 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
2312 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
2313 | set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default |
---|
2314 | set(handles.VelType,'visible','off') |
---|
2315 | set(handles.VelType_title,'visible','off') |
---|
2316 | XName=GetFieldData.Coordinates.Coord_x; |
---|
2317 | YName=GetFieldData.Coordinates.Coord_y; |
---|
2318 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
2319 | % get the time info |
---|
2320 | TimeTable=get(handles.TimeTable,'Data'); |
---|
2321 | switch TimeNameStr |
---|
2322 | case 'file index' |
---|
2323 | TimeName=''; |
---|
2324 | case 'attribute' |
---|
2325 | TimeName=['att:' GetFieldData.Time.TimeName]; |
---|
2326 | % update the time table |
---|
2327 | TimeTable{iview,2}=get_time(Param.IndexRange.MinIndex_i(iview),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName); % Min time |
---|
2328 | TimeTable{iview,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName); % first time |
---|
2329 | TimeTable{iview,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName); % last time |
---|
2330 | TimeTable{iview,5}=get_time(Param.IndexRange.MaxIndex_i(iview),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName); % Max time |
---|
2331 | case 'variable' |
---|
2332 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) |
---|
2333 | set(handles.NomType,'String','*') |
---|
2334 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!! |
---|
2335 | set(handles.FileIndex,'String','') |
---|
2336 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
2337 | case 'matrix_index' |
---|
2338 | TimeName=['dim:' GetFieldData.Time.TimeName]; |
---|
2339 | set(handles.NomType,'String','*') |
---|
2340 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
2341 | set(handles.FileIndex,'String','') |
---|
2342 | ParamIn.TimeDimName=GetFieldData.Time.TimeName; |
---|
2343 | end |
---|
2344 | TimeTable{iview,1}=TimeName; |
---|
2345 | set(handles.TimeTable,'Data',TimeTable); |
---|
2346 | end |
---|
2347 | set(handles.Coord_x,'String',XName) |
---|
2348 | set(handles.Coord_y,'String',YName) |
---|
2349 | end |
---|
2350 | end |
---|
2351 | |
---|
2352 | function [TimeValue,DtValue]=get_time(ref_i,ref_j,PairString,InputTable,FileInfo,TimeName,DtName) |
---|
2353 | [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString); |
---|
2354 | FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2); |
---|
2355 | Data=nc2struct(FileName,[]); |
---|
2356 | TimeValue=[]; |
---|
2357 | DtValue=[]; |
---|
2358 | if isequal(FileInfo.FileType,'civdata') |
---|
2359 | if ismember(TimeName,{'civ1','filter1'}) |
---|
2360 | TimeValue=Data.Civ1_Time; |
---|
2361 | DtValue=Data.Civ1_Dt; |
---|
2362 | else |
---|
2363 | TimeValue=Data.Civ2_Time; |
---|
2364 | DtValue=Data.Civ2_Dt; |
---|
2365 | end |
---|
2366 | else |
---|
2367 | if ~isempty(TimeName)&& isfield(Data,TimeName) |
---|
2368 | TimeValue=Data.(TimeName); |
---|
2369 | end |
---|
2370 | if exist('DtName','var') && isfield(Data,DtName) |
---|
2371 | DtValue=Data.(DtName); |
---|
2372 | end |
---|
2373 | end |
---|
2374 | |
---|
2375 | %------------------------------------------------------------------------ |
---|
2376 | % --- Executes on selection change in FieldName_1. |
---|
2377 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
2378 | %------------------------------------------------------------------------ |
---|
2379 | field_str=get(handles.FieldName_1,'String'); |
---|
2380 | field_index=get(handles.FieldName_1,'Value'); |
---|
2381 | field=field_str{field_index(1)}; |
---|
2382 | if isequal(field,'get_field...') |
---|
2383 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
2384 | if ~isempty(hget_field) |
---|
2385 | delete(hget_field)%delete opened versions of get_field |
---|
2386 | end |
---|
2387 | Param=read_GUI(handles.series); |
---|
2388 | Param.InputTable=Param.InputTable(1,:); |
---|
2389 | % check the existence of the first file in the series |
---|
2390 | first_j=[]; |
---|
2391 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end |
---|
2392 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end |
---|
2393 | PairString=''; |
---|
2394 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end |
---|
2395 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString); |
---|
2396 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... |
---|
2397 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); |
---|
2398 | if exist(FirstFileName,'file') |
---|
2399 | ParamIn.SeriesInput=1; |
---|
2400 | GetFieldData=get_field(FirstFileName,ParamIn); |
---|
2401 | FieldList={}; |
---|
2402 | switch GetFieldData.FieldOption |
---|
2403 | case 'vectors' |
---|
2404 | UName=GetFieldData.PanelVectors.vector_x; |
---|
2405 | VName=GetFieldData.PanelVectors.vector_y; |
---|
2406 | FieldList={['vec(' UName ',' VName ')'];... |
---|
2407 | ['norm(' UName ',' VName ')'];... |
---|
2408 | UName;VName}; |
---|
2409 | case {'scalar','pick variables'} |
---|
2410 | FieldList=GetFieldData.PanelScalar.scalar; |
---|
2411 | if ischar(FieldList) |
---|
2412 | FieldList={FieldList}; |
---|
2413 | end |
---|
2414 | case '1D plot' |
---|
2415 | |
---|
2416 | case 'civdata...' |
---|
2417 | FieldList=set_field_list('U','V','C'); |
---|
2418 | set(handles.FieldName,'Value',2) % set menu to 'velocity |
---|
2419 | end |
---|
2420 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
2421 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
2422 | switch TimeNameStr |
---|
2423 | case 'file index' |
---|
2424 | set(handles.TimeName,'String',''); |
---|
2425 | case 'attribute' |
---|
2426 | set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]); |
---|
2427 | case 'variable' |
---|
2428 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) |
---|
2429 | set(handles.NomType,'String','*') |
---|
2430 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!! |
---|
2431 | set(handles.FileIndex,'String','') |
---|
2432 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
2433 | case 'matrix_index' |
---|
2434 | set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]); |
---|
2435 | set(handles.NomType,'String','*') |
---|
2436 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
2437 | set(handles.FileIndex,'String','') |
---|
2438 | ParamIn.TimeDimName=GetFieldData.Time.TimeName; |
---|
2439 | end |
---|
2440 | end |
---|
2441 | set(handles.FieldName_1,'Value',1) |
---|
2442 | set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]); |
---|
2443 | end |
---|
2444 | end |
---|
2445 | |
---|
2446 | |
---|
2447 | %%%%%%%%%%%%% |
---|
2448 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
2449 | indsel=ind_i; |
---|
2450 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
2451 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
2452 | if ~isempty(indiff) |
---|
2453 | indiff2=diff(indiff); |
---|
2454 | indiffp=[indiff2 1]; |
---|
2455 | indiffm=[1 indiff2]; |
---|
2456 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
2457 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
2458 | %for each multiplet, select the most recent file |
---|
2459 | ind_remove=[]; |
---|
2460 | for i=1:length(ind_multi_m) |
---|
2461 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
2462 | for imulti=1:length(ind_pairs) |
---|
2463 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
2464 | end |
---|
2465 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
2466 | ind_s=indsort2(1:end-1);% |
---|
2467 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
2468 | end |
---|
2469 | end |
---|
2470 | |
---|
2471 | %------------------------------------------------------------------------ |
---|
2472 | % --- determine the list of index pairstring of processing file |
---|
2473 | 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) |
---|
2474 | %------------------------------------------------------------------------ |
---|
2475 | num_i1=num_i;% set of first image numbers by default |
---|
2476 | num_i2=num_i; |
---|
2477 | num_j1=num_j; |
---|
2478 | num_j2=num_j; |
---|
2479 | num_i_out=num_i; |
---|
2480 | num_j_out=num_j; |
---|
2481 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
2482 | if isequal(mode,'series(Di)') |
---|
2483 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
2484 | num_i2_line=num_i+ind_shift(4); |
---|
2485 | % adjust the first and last field number |
---|
2486 | indsel=find(num_i1_line >= 1); |
---|
2487 | num_i_out=num_i(indsel); |
---|
2488 | num_i1_line=num_i1_line(indsel); |
---|
2489 | num_i2_line=num_i2_line(indsel); |
---|
2490 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
2491 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
2492 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
2493 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
2494 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
2495 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
2496 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
2497 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
2498 | else |
---|
2499 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
2500 | num_j2_col=num_j+ind_shift(2); |
---|
2501 | % adjust the first field number |
---|
2502 | indsel=find((num_j1_col >= 1)); |
---|
2503 | num_j_out=num_j(indsel); |
---|
2504 | num_j1_col=num_j1_col(indsel); |
---|
2505 | num_j2_col=num_j2_col(indsel); |
---|
2506 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
2507 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
2508 | end |
---|
2509 | end |
---|
2510 | |
---|
2511 | %------------------------------------------------------------------------ |
---|
2512 | % --- Executes on button press in CheckObject. |
---|
2513 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
2514 | %------------------------------------------------------------------------ |
---|
2515 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
2516 | if get(handles.CheckObject,'Value') |
---|
2517 | SeriesData=get(handles.series,'UserData'); |
---|
2518 | if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject) |
---|
2519 | set(handles.ViewObject,'Value',1) |
---|
2520 | ViewObject_Callback(hObject, eventdata, handles) |
---|
2521 | else |
---|
2522 | if ishandle(hset_object) |
---|
2523 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
2524 | else |
---|
2525 | %get the object file |
---|
2526 | InputTable=get(handles.InputTable,'Data'); |
---|
2527 | defaultname=InputTable{1,1}; |
---|
2528 | if isempty(defaultname) |
---|
2529 | defaultname={''}; |
---|
2530 | end |
---|
2531 | fileinput=uigetfile_uvmat('pick a xml object file (or use uvmat to create it)',defaultname,'.xml'); |
---|
2532 | if isempty(fileinput)% exit if no object file is selected |
---|
2533 | set(handles.CheckObject,'Value',0) |
---|
2534 | return |
---|
2535 | end |
---|
2536 | %read the file |
---|
2537 | data=xml2struct(fileinput); |
---|
2538 | if ~isfield(data,'Type') |
---|
2539 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
2540 | set(handles.CheckObject,'Value',0) |
---|
2541 | return |
---|
2542 | end |
---|
2543 | if ~isfield(data,'ProjMode') |
---|
2544 | data.ProjMode='none'; |
---|
2545 | end |
---|
2546 | hset_object=set_object(data);% call the set_object interface |
---|
2547 | set(hset_object,'Name','set_object_series')% name to distinguish from set_object used with uvmat |
---|
2548 | end |
---|
2549 | ProjObject=read_GUI(hset_object); |
---|
2550 | set(handles.ProjObject,'String',ProjObject.Name);%display the object name |
---|
2551 | SeriesData=get(handles.series,'UserData'); |
---|
2552 | SeriesData.ProjObject=ProjObject; |
---|
2553 | set(handles.series,'UserData',SeriesData); |
---|
2554 | end |
---|
2555 | set(handles.EditObject,'Visible','on'); |
---|
2556 | set(handles.DeleteObject,'Visible','on'); |
---|
2557 | set(handles.ViewObject,'Visible','on'); |
---|
2558 | set(handles.ProjObject,'Visible','on'); |
---|
2559 | else |
---|
2560 | set(handles.EditObject,'Visible','off'); |
---|
2561 | set(handles.DeleteObject,'Visible','off'); |
---|
2562 | set(handles.ViewObject,'Visible','off'); |
---|
2563 | if ~ishandle(hset_object) |
---|
2564 | set(handles.ViewObject,'Value',0); |
---|
2565 | end |
---|
2566 | set(handles.ProjObject,'Visible','off'); |
---|
2567 | end |
---|
2568 | |
---|
2569 | %------------------------------------------------------------------------ |
---|
2570 | % --- Executes on button press in ViewObject. |
---|
2571 | %------------------------------------------------------------------------ |
---|
2572 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
2573 | |
---|
2574 | UserData=get(handles.series,'UserData'); |
---|
2575 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
2576 | if ~isempty(hset_object) |
---|
2577 | delete(hset_object)% refresh set_object if already opened |
---|
2578 | end |
---|
2579 | hset_object=set_object(UserData.ProjObject); |
---|
2580 | set(hset_object,'Name','view_object_series') |
---|
2581 | |
---|
2582 | |
---|
2583 | %------------------------------------------------------------------------ |
---|
2584 | % --- Executes on button press in EditObject. |
---|
2585 | function EditObject_Callback(hObject, eventdata, handles) |
---|
2586 | %------------------------------------------------------------------------ |
---|
2587 | if get(handles.EditObject,'Value') |
---|
2588 | set(handles.ViewObject,'Value',0) |
---|
2589 | UserData=get(handles.series,'UserData'); |
---|
2590 | hset_object=set_object(UserData.ProjObject); |
---|
2591 | set(hset_object,'Name','edit_object_series') |
---|
2592 | set(get(hset_object,'Children'),'Enable','on') |
---|
2593 | else |
---|
2594 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
2595 | if ~isempty(hset_object) |
---|
2596 | set(get(hset_object,'Children'),'Enable','off') |
---|
2597 | end |
---|
2598 | end |
---|
2599 | |
---|
2600 | %------------------------------------------------------------------------ |
---|
2601 | % --- Executes on button press in DeleteObject. |
---|
2602 | function DeleteObject_Callback(hObject, eventdata, handles) |
---|
2603 | %------------------------------------------------------------------------ |
---|
2604 | SeriesData=get(handles.series,'UserData'); |
---|
2605 | SeriesData.ProjObject=[]; |
---|
2606 | set(handles.series,'UserData',SeriesData) |
---|
2607 | set(handles.ProjObject,'String','') |
---|
2608 | set(handles.ProjObject,'Visible','off') |
---|
2609 | set(handles.CheckObject,'Value',0) |
---|
2610 | set(handles.ViewObject,'Visible','off') |
---|
2611 | set(handles.EditObject,'Visible','off') |
---|
2612 | hset_object=findobj(allchild(0),'name','set_object_series'); |
---|
2613 | if ~isempty(hset_object) |
---|
2614 | delete(hset_object) |
---|
2615 | end |
---|
2616 | set(handles.DeleteObject,'Visible','off') |
---|
2617 | |
---|
2618 | %------------------------------------------------------------------------ |
---|
2619 | % --- Executed when CheckMask is activated |
---|
2620 | %------------------------------------------------------------------------ |
---|
2621 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
2622 | |
---|
2623 | if get(handles.CheckMask,'Value') |
---|
2624 | InputTable=get(handles.InputTable,'Data'); |
---|
2625 | nbview=size(InputTable,1); |
---|
2626 | MaskTable=cell(nbview,1);%default |
---|
2627 | ListMask=cell(nbview,1);%default |
---|
2628 | MaskData=get(handles.MaskTable,'Data'); |
---|
2629 | MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1);%complement if undefined lines |
---|
2630 | for iview=1:nbview |
---|
2631 | ListMask{iview,1}=num2str(iview); |
---|
2632 | RootPath=InputTable{iview,1}; |
---|
2633 | if ~isempty(RootPath) |
---|
2634 | if isempty(MaskData{iview}) |
---|
2635 | SubDir=InputTable{iview,2}; |
---|
2636 | MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']);%take the root part of SubDir, before the first dot '.' |
---|
2637 | if exist(MaskPath,'dir') |
---|
2638 | ListStruct=dir(MaskPath);%look for a mask file |
---|
2639 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
2640 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
2641 | ListFiles=ListCells(1,:);%list of file and dri names |
---|
2642 | ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) |
---|
2643 | mdetect=0; |
---|
2644 | if ~isempty(ListFiles) |
---|
2645 | for ifile=1:numel(ListFiles) |
---|
2646 | [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0); |
---|
2647 | if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) |
---|
2648 | mdetect=1; |
---|
2649 | MaskName=ListFiles{ifile}; |
---|
2650 | end |
---|
2651 | if ~strcmp(MaskFile{ifile},MaskFile{1}) |
---|
2652 | mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection |
---|
2653 | break |
---|
2654 | end |
---|
2655 | end |
---|
2656 | end |
---|
2657 | if mdetect==1 |
---|
2658 | MaskName=fullfile(MaskPath,'mask_1.png'); |
---|
2659 | else |
---|
2660 | MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image'); |
---|
2661 | end |
---|
2662 | else |
---|
2663 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image'); |
---|
2664 | end |
---|
2665 | MaskTable{iview,1}=MaskName ; |
---|
2666 | ListMask{iview,1}=num2str(iview); |
---|
2667 | end |
---|
2668 | end |
---|
2669 | end |
---|
2670 | set(handles.MaskTable,'Data',MaskTable) |
---|
2671 | set(handles.MaskTable,'Visible','on') |
---|
2672 | set(handles.MaskBrowse,'Visible','on') |
---|
2673 | set(handles.ListMask,'Visible','on') |
---|
2674 | set(handles.ListMask,'String',ListMask) |
---|
2675 | set(handles.ListMask,'Value',1) |
---|
2676 | else |
---|
2677 | set(handles.MaskTable,'Visible','off') |
---|
2678 | set(handles.MaskBrowse,'Visible','off') |
---|
2679 | set(handles.ListMask,'Visible','off') |
---|
2680 | end |
---|
2681 | |
---|
2682 | %------------------------------------------------------------------------ |
---|
2683 | % --- Executes on button press in MaskBrowse. |
---|
2684 | %------------------------------------------------------------------------ |
---|
2685 | function MaskBrowse_Callback(hObject, eventdata, handles) |
---|
2686 | |
---|
2687 | InputTable=get(handles.InputTable,'Data'); |
---|
2688 | iview=get(handles.ListMask,'Value'); |
---|
2689 | RootPath=InputTable{iview,1}; |
---|
2690 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image'); |
---|
2691 | if ~isempty(MaskName) |
---|
2692 | MaskTable=get(handles.MaskTable,'Data'); |
---|
2693 | MaskTable{iview,1}=MaskName ; |
---|
2694 | set(handles.MaskTable,'Data',MaskTable) |
---|
2695 | end |
---|
2696 | |
---|
2697 | %------------------------------------------------------------------------ |
---|
2698 | % --- Executes when selected cell(s) is changed in MaskTable. |
---|
2699 | %------------------------------------------------------------------------ |
---|
2700 | function MaskTable_CellSelectionCallback(hObject, eventdata, handles) |
---|
2701 | |
---|
2702 | if numel(eventdata.Indices)>=1 |
---|
2703 | set(handles.ListMask,'Value',eventdata.Indices(1)) |
---|
2704 | end |
---|
2705 | |
---|
2706 | %------------------------------------------------------------------- |
---|
2707 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
2708 | %------------------------------------------------------------------- |
---|
2709 | |
---|
2710 | |
---|
2711 | % path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
2712 | % pathelp=fileparts(path_to_uvmat); |
---|
2713 | % helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
2714 | % 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') |
---|
2715 | % else |
---|
2716 | % addpath (fullfile(pathelp,'uvmat_doc')) |
---|
2717 | % web([helpfile '#series']) |
---|
2718 | % end |
---|
2719 | |
---|
2720 | %------------------------------------------------------------------- |
---|
2721 | % --- Executes on selection change in TransformName. |
---|
2722 | function TransformName_Callback(hObject, eventdata, handles) |
---|
2723 | %---------------------------------------------------------------------- |
---|
2724 | TransformList=get(handles.TransformName,'String'); |
---|
2725 | TransformIndex=get(handles.TransformName,'Value'); |
---|
2726 | TransformName=TransformList{TransformIndex}; |
---|
2727 | TransformPathList=get(handles.TransformName,'UserData'); |
---|
2728 | nb_builtin_transform=4; |
---|
2729 | if isequal(TransformName,'more...'); |
---|
2730 | FileName=uigetfile_uvmat('Pick a transform function',get(handles.TransformPath,'String'),'.m'); |
---|
2731 | if isempty(FileName) |
---|
2732 | return %browser closed without choice |
---|
2733 | end |
---|
2734 | [TransformPath,TransformName,TransformExt]=fileparts(FileName);% removes extension .m |
---|
2735 | if ~strcmp(TransformExt,'.m') |
---|
2736 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
2737 | return |
---|
2738 | end |
---|
2739 | % insert the choice in the menu |
---|
2740 | TransformIndex=find(strcmp(TransformName,TransformList),1);% look for the selected function in the menu Action |
---|
2741 | if isempty(TransformIndex)%the input string does not exist in the menu |
---|
2742 | TransformIndex= length(TransformList); |
---|
2743 | TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...' |
---|
2744 | set(handles.TransformName,'String',TransformList) |
---|
2745 | TransformPathList=[TransformPathList;{TransformPath}]; |
---|
2746 | else% the input function already exist, we update its path (possibly new) |
---|
2747 | TransformPathList{TransformIndex}=TransformPath;% |
---|
2748 | set(handles.TransformName,'Value',TransformIndex) |
---|
2749 | end |
---|
2750 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
2751 | dir_perso=prefdir;%personal Matalb directory |
---|
2752 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2753 | if exist(profil_perso,'file') |
---|
2754 | for ilist=nb_builtin_transform+1:numel(TransformPathList) |
---|
2755 | TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist}; |
---|
2756 | TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist}; |
---|
2757 | end |
---|
2758 | TransformPathListUser=TransformPathListUser'; |
---|
2759 | TransformListUser=TransformListUser'; |
---|
2760 | save (profil_perso,'TransformPathListUser','TransformListUser','-append'); %store the root name for future opening of uvmat |
---|
2761 | end |
---|
2762 | end |
---|
2763 | |
---|
2764 | %display the current function path |
---|
2765 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}); %show the path to the senlected function |
---|
2766 | set(handles.TransformName,'UserData',TransformPathList); |
---|
2767 | |
---|
2768 | %------------------------------------------------------------------------ |
---|
2769 | % --- fct activated by the upper bar menu ExportConfig |
---|
2770 | %------------------------------------------------------------------------ |
---|
2771 | function MenuDisplayConfig_Callback(hObject, eventdata, handles) |
---|
2772 | |
---|
2773 | global Param |
---|
2774 | Param=read_GUI_series(handles); |
---|
2775 | evalin('base','global Param')%make CurData global in the workspace |
---|
2776 | display('current series config :') |
---|
2777 | evalin('base','Param') %display CurData in the workspace |
---|
2778 | commandwindow; %brings the Matlab command window to the front |
---|
2779 | |
---|
2780 | %------------------------------------------------------------------------ |
---|
2781 | % --- fct activated by the upper bar menu InportConfig: import |
---|
2782 | % menu settings from an xml file (stored in /0_XML for each run) |
---|
2783 | %------------------------------------------------------------------------ |
---|
2784 | function MenuImportConfig_Callback(hObject, eventdata, handles) |
---|
2785 | |
---|
2786 | %% use a starting file name for browserr |
---|
2787 | InputTable=get(handles.InputTable,'Data'); |
---|
2788 | oldfile=InputTable{1,1}; |
---|
2789 | if isempty(oldfile) |
---|
2790 | % use a file name stored in prefdir |
---|
2791 | dir_perso=prefdir; |
---|
2792 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2793 | if exist(profil_perso,'file') |
---|
2794 | h=load (profil_perso); |
---|
2795 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
2796 | oldfile=h.RootPath; |
---|
2797 | end |
---|
2798 | end |
---|
2799 | end |
---|
2800 | filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters |
---|
2801 | %proceed only if a file has been introduced by the browser |
---|
2802 | if ~isempty(filexml) |
---|
2803 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
2804 | % ask to stop current Action if button RUN is in action (another process is already running) |
---|
2805 | if isequal(get(handles.RUN,'Value'),1) |
---|
2806 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); |
---|
2807 | if strcmp(answer,'Yes') |
---|
2808 | STOP_Callback(hObject, eventdata, handles) |
---|
2809 | else |
---|
2810 | return |
---|
2811 | end |
---|
2812 | end |
---|
2813 | Param.Action.RUN=0; %desactivate the input RUN=1 |
---|
2814 | fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters |
---|
2815 | SeriesData=get(handles.series,'UserData'); |
---|
2816 | if isfield(Param,'InputFields') |
---|
2817 | ListField=Param.InputFields.FieldName; |
---|
2818 | set(handles.FieldName,'String',[ListField;{'get-field...'}]) |
---|
2819 | set(handles.FieldName,'Value',1:numel(ListField)) |
---|
2820 | end |
---|
2821 | if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters |
---|
2822 | set(handles.ActionInput,'Visible','on') |
---|
2823 | set(handles.ActionInput,'Value',0) |
---|
2824 | Param.ActionInput.ConfigSource=filexml;% record the source of config for future info |
---|
2825 | SeriesData.ActionInput=Param.ActionInput; |
---|
2826 | end |
---|
2827 | if isfield(Param,'ProjObject') %introduce projection object if relevant |
---|
2828 | SeriesData.ProjObject=Param.ProjObject; |
---|
2829 | end |
---|
2830 | set(handles.series,'UserData',SeriesData) |
---|
2831 | if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1) |
---|
2832 | set(handles.ProjObject,'String',Param.ProjObject.Name) |
---|
2833 | set(handles.ViewObject,'Visible','on') |
---|
2834 | set(handles.EditObject,'Visible','on') |
---|
2835 | set(handles.DeleteObject,'Visible','on') |
---|
2836 | else |
---|
2837 | set(handles.ProjObject,'String','') |
---|
2838 | set(handles.ProjObject,'Visible','off') |
---|
2839 | set(handles.ViewObject,'Visible','off') |
---|
2840 | set(handles.EditObject,'Visible','off') |
---|
2841 | set(handles.DeleteObject,'Visible','off') |
---|
2842 | end |
---|
2843 | set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated |
---|
2844 | end |
---|
2845 | |
---|
2846 | |
---|
2847 | |
---|
2848 | % -------------------------------------------------------------------- |
---|
2849 | function MenuImportParam_Callback(hObject, eventdata, handles) |
---|
2850 | %% use a starting file name for browserr |
---|
2851 | InputTable=get(handles.InputTable,'Data'); |
---|
2852 | oldfile=InputTable{1,1}; |
---|
2853 | if isempty(oldfile) |
---|
2854 | % use a file name stored in prefdir |
---|
2855 | dir_perso=prefdir; |
---|
2856 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2857 | if exist(profil_perso,'file') |
---|
2858 | h=load (profil_perso); |
---|
2859 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
2860 | oldfile=h.RootPath; |
---|
2861 | end |
---|
2862 | end |
---|
2863 | end |
---|
2864 | filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters |
---|
2865 | %proceed only if a file has been introduced by the browser |
---|
2866 | if ~isempty(filexml) |
---|
2867 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
2868 | % ask to stop current Action if button RUN is in action (another process is already running) |
---|
2869 | if isequal(get(handles.RUN,'Value'),1) |
---|
2870 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); |
---|
2871 | if strcmp(answer,'Yes') |
---|
2872 | STOP_Callback(hObject, eventdata, handles) |
---|
2873 | else |
---|
2874 | return |
---|
2875 | end |
---|
2876 | end |
---|
2877 | Param.Action.RUN=0; %desactivate the input RUN=1 |
---|
2878 | if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange') |
---|
2879 | msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''') |
---|
2880 | return |
---|
2881 | end |
---|
2882 | Param=rmfield(Param,'InputTable');% do not refresh Input files and index range |
---|
2883 | Param=rmfield(Param,'IndexRange'); |
---|
2884 | fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters |
---|
2885 | SeriesData=get(handles.series,'UserData'); |
---|
2886 | if isfield(Param,'InputFields') |
---|
2887 | ListField=Param.InputFields.FieldName; |
---|
2888 | set(handles.FieldName,'String',[ListField;{'get-field...'}]) |
---|
2889 | set(handles.FieldName,'Value',1:numel(ListField)) |
---|
2890 | end |
---|
2891 | if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters |
---|
2892 | set(handles.ActionInput,'Visible','on') |
---|
2893 | set(handles.ActionInput,'Value',0) |
---|
2894 | Param.ActionInput.ConfigSource=filexml;% record the source of config for future info |
---|
2895 | SeriesData.ActionInput=Param.ActionInput; |
---|
2896 | end |
---|
2897 | if isfield(Param,'ProjObject') %introduce projection object if relevant |
---|
2898 | SeriesData.ProjObject=Param.ProjObject; |
---|
2899 | end |
---|
2900 | set(handles.series,'UserData',SeriesData) |
---|
2901 | if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1) |
---|
2902 | set(handles.ProjObject,'String',Param.ProjObject.Name) |
---|
2903 | set(handles.ViewObject,'Visible','on') |
---|
2904 | set(handles.EditObject,'Visible','on') |
---|
2905 | set(handles.DeleteObject,'Visible','on') |
---|
2906 | else |
---|
2907 | set(handles.ProjObject,'String','') |
---|
2908 | set(handles.ProjObject,'Visible','off') |
---|
2909 | set(handles.ViewObject,'Visible','off') |
---|
2910 | set(handles.EditObject,'Visible','off') |
---|
2911 | set(handles.DeleteObject,'Visible','off') |
---|
2912 | end |
---|
2913 | set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated |
---|
2914 | end |
---|
2915 | |
---|
2916 | |
---|
2917 | |
---|
2918 | %------------------------------------------------------------------------ |
---|
2919 | % --- Executes when the GUI series is resized. |
---|
2920 | %------------------------------------------------------------------------ |
---|
2921 | function series_ResizeFcn(hObject, eventdata, handles) |
---|
2922 | |
---|
2923 | %% input table |
---|
2924 | set(handles.InputTable,'Unit','pixel') |
---|
2925 | Pos=get(handles.InputTable,'Position'); |
---|
2926 | set(handles.InputTable,'Unit','normalized') |
---|
2927 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52)); |
---|
2928 | ColumnWidth=num2cell(ColumnWidth); |
---|
2929 | set(handles.InputTable,'ColumnWidth',ColumnWidth) |
---|
2930 | |
---|
2931 | %% MinIndex_j and MaxIndex_i |
---|
2932 | unit=get(handles.MinIndex_i,'Unit'); |
---|
2933 | set(handles.MinIndex_i,'Unit','pixel') |
---|
2934 | Pos=get(handles.MinIndex_i,'Position'); |
---|
2935 | set(handles.MinIndex_i,'Unit',unit) |
---|
2936 | set(handles.MinIndex_i,'ColumnWidth',{Pos(3)-18}) |
---|
2937 | set(handles.MaxIndex_i,'ColumnWidth',{Pos(3)-18}) |
---|
2938 | set(handles.MinIndex_j,'ColumnWidth',{Pos(3)-18}) |
---|
2939 | set(handles.MaxIndex_j,'ColumnWidth',{Pos(3)-18}) |
---|
2940 | |
---|
2941 | %% TimeTable |
---|
2942 | set(handles.TimeTable,'Unit','pixel') |
---|
2943 | Pos=get(handles.TimeTable,'Position'); |
---|
2944 | set(handles.TimeTable,'Unit','normalized') |
---|
2945 | % ColumnWidth=get(handles.TimeTable,'ColumnWidth'); |
---|
2946 | ColumnWidth=num2cell(floor([0.2 0.2 0.2 0.2 0.2]*(Pos(3)-20))); |
---|
2947 | set(handles.TimeTable,'ColumnWidth',ColumnWidth) |
---|
2948 | |
---|
2949 | |
---|
2950 | %% PairString |
---|
2951 | set(handles.PairString,'Unit','pixel') |
---|
2952 | Pos=get(handles.PairString,'Position'); |
---|
2953 | set(handles.PairString,'Unit','normalized') |
---|
2954 | set(handles.PairString,'ColumnWidth',{Pos(3)-5}) |
---|
2955 | |
---|
2956 | %% MaskTable |
---|
2957 | set(handles.MaskTable,'Unit','pixel') |
---|
2958 | Pos=get(handles.MaskTable,'Position'); |
---|
2959 | set(handles.MaskTable,'Unit','normalized') |
---|
2960 | set(handles.MaskTable,'ColumnWidth',{Pos(3)-5}) |
---|
2961 | |
---|
2962 | %------------------------------------------------------------------------ |
---|
2963 | % --- Executes on button press in status. |
---|
2964 | %------------------------------------------------------------------------ |
---|
2965 | function status_Callback(hObject, eventdata, handles) |
---|
2966 | |
---|
2967 | if get(handles.status,'Value') |
---|
2968 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
2969 | drawnow |
---|
2970 | Param=read_GUI(handles.series); |
---|
2971 | RootPath=Param.InputTable{1,1}; |
---|
2972 | if ~isfield(Param,'OutputSubDir') |
---|
2973 | msgbox_uvmat('ERROR','no directory defined for output files') |
---|
2974 | return |
---|
2975 | end |
---|
2976 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files |
---|
2977 | OutputDir=fullfile(RootPath,OutputSubDir); |
---|
2978 | if exist(OutputDir,'dir') |
---|
2979 | uigetfile_uvmat('status_display',OutputDir) |
---|
2980 | else |
---|
2981 | msgbox_uvmat('ERROR','output folder not created yet: calculation did not start') |
---|
2982 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
2983 | end |
---|
2984 | else |
---|
2985 | %% delete current display fig if selection is off |
---|
2986 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
2987 | hfig=findobj(allchild(0),'name','status_display'); |
---|
2988 | if ~isempty(hfig) |
---|
2989 | delete(hfig) |
---|
2990 | end |
---|
2991 | return |
---|
2992 | end |
---|
2993 | |
---|
2994 | |
---|
2995 | %------------------------------------------------------------------------ |
---|
2996 | % launched by selecting a file on the list |
---|
2997 | %------------------------------------------------------------------------ |
---|
2998 | function view_file(hObject, eventdata) |
---|
2999 | |
---|
3000 | list=get(hObject,'String'); |
---|
3001 | index=get(hObject,'Value'); |
---|
3002 | rootroot=get(hObject,'UserData'); |
---|
3003 | selectname=list{index}; |
---|
3004 | ind_dot=regexp(selectname,'\.\.\.'); |
---|
3005 | if ~isempty(ind_dot) |
---|
3006 | selectname=selectname(1:ind_dot-1); |
---|
3007 | end |
---|
3008 | FullSelectName=fullfile(rootroot,selectname); |
---|
3009 | if exist(FullSelectName,'dir')% a directory has been selected |
---|
3010 | ListFiles=dir(FullSelectName); |
---|
3011 | ListDisplay=cell(numel(ListFiles),1); |
---|
3012 | for ilist=2:numel(ListDisplay)% suppress the first line '.' |
---|
3013 | ListDisplay{ilist-1}=ListFiles(ilist).name; |
---|
3014 | end |
---|
3015 | set(hObject,'Value',1) |
---|
3016 | set(hObject,'String',ListDisplay) |
---|
3017 | if strcmp(selectname,'..') |
---|
3018 | FullSelectName=fileparts(fileparts(FullSelectName)); |
---|
3019 | end |
---|
3020 | set(hObject,'UserData',FullSelectName) |
---|
3021 | hfig=get(hObject,'parent'); |
---|
3022 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
3023 | set(htitlebox,'String',FullSelectName) |
---|
3024 | elseif exist(FullSelectName,'file')%visualise the vel field if it exists |
---|
3025 | FileType=get_file_type(FullSelectName); |
---|
3026 | if strcmp(FileType,'txt') |
---|
3027 | edit(FullSelectName) |
---|
3028 | elseif strcmp(FileType,'xml') |
---|
3029 | editxml(FullSelectName) |
---|
3030 | else |
---|
3031 | uvmat(FullSelectName) |
---|
3032 | end |
---|
3033 | set(gcbo,'Value',1) |
---|
3034 | end |
---|
3035 | |
---|
3036 | |
---|
3037 | %------------------------------------------------------------------------ |
---|
3038 | % launched by refreshing the status figure |
---|
3039 | %------------------------------------------------------------------------ |
---|
3040 | function refresh_GUI(hfig) |
---|
3041 | |
---|
3042 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
3043 | hlist=findobj(hfig,'tag','list'); |
---|
3044 | hseries=findobj(allchild(0),'tag','series'); |
---|
3045 | hstatus=findobj(hseries,'tag','status'); |
---|
3046 | StatusData=get(hstatus,'UserData'); |
---|
3047 | OutputDir=get(htitlebox,'String'); |
---|
3048 | if ischar(OutputDir),OutputDir={OutputDir};end |
---|
3049 | ListFiles=dir(OutputDir{1}); |
---|
3050 | if numel(ListFiles)<1 |
---|
3051 | return |
---|
3052 | end |
---|
3053 | ListFiles(1)=[];%removes the first line ='.' |
---|
3054 | ListDisplay=cell(numel(ListFiles),1); |
---|
3055 | testrecent=0; |
---|
3056 | datnum=zeros(numel(ListDisplay),1); |
---|
3057 | for ilist=1:numel(ListDisplay) |
---|
3058 | ListDisplay{ilist}=ListFiles(ilist).name; |
---|
3059 | if ~ListFiles(ilist).isdir && isfield(ListFiles(ilist),'datenum') |
---|
3060 | datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions |
---|
3061 | testrecent=1; |
---|
3062 | end |
---|
3063 | end |
---|
3064 | set(hlist,'String',ListDisplay) |
---|
3065 | |
---|
3066 | %% Look at date of creation |
---|
3067 | ListDisplay=ListDisplay(datnum~=0); |
---|
3068 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
3069 | NbOutputFile=[]; |
---|
3070 | if isempty(datnum) |
---|
3071 | if testrecent |
---|
3072 | message='no civ result created yet'; |
---|
3073 | else |
---|
3074 | message=''; |
---|
3075 | end |
---|
3076 | else |
---|
3077 | [first,indfirst]=min(datnum); |
---|
3078 | [last,indlast]=max(datnum); |
---|
3079 | NbOutputFile_str='?'; |
---|
3080 | NbOutputFile=[]; |
---|
3081 | if isfield(StatusData,'NbOutputFile') |
---|
3082 | NbOutputFile=StatusData.NbOutputFile; |
---|
3083 | NbOutputFile_str=num2str(NbOutputFile); |
---|
3084 | end |
---|
3085 | message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];... |
---|
3086 | ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]}; |
---|
3087 | end |
---|
3088 | set(htitlebox,'String', [OutputDir{1};message]) |
---|
3089 | |
---|
3090 | %% update the waitbar |
---|
3091 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
3092 | if ~isempty(NbOutputFile) |
---|
3093 | BarPosition=get(hwaitbar,'Position'); |
---|
3094 | BarPosition(3)=0.9*numel(datnum)/NbOutputFile; |
---|
3095 | set(hwaitbar,'Position',BarPosition) |
---|
3096 | end |
---|
3097 | |
---|
3098 | %------------------------------------------------------------------------ |
---|
3099 | % --- Executes on selection change in ActionExt. |
---|
3100 | %------------------------------------------------------------------------ |
---|
3101 | function ActionExt_Callback(hObject, eventdata, handles) |
---|
3102 | |
---|
3103 | ActionExtList=get(handles.ActionExt,'String'); |
---|
3104 | ActionExt=ActionExtList{get(handles.ActionExt,'Value')}; |
---|
3105 | ActionList=get(handles.ActionName,'String'); |
---|
3106 | ActionName=ActionList{get(handles.ActionName,'Value')}; |
---|
3107 | % TransformPath=''; |
---|
3108 | % if ~isempty(get(handles.ActionExt,'UserData')) |
---|
3109 | % TransformPath=get(handles.ActionExt,'UserData'); |
---|
3110 | % end |
---|
3111 | % if strcmp(ActionExt,'.sh') |
---|
3112 | % set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
3113 | % set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
3114 | % ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']); |
---|
3115 | % if ~exist(ActionFullName,'file') |
---|
3116 | % answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?'); |
---|
3117 | % if strcmp(answer,'Yes') |
---|
3118 | % set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
3119 | % path_uvmat=fileparts(which('series')); |
---|
3120 | % currentdir=pwd; |
---|
3121 | % cd(get(handles.ActionPath,'String'))% go to the directory of Action |
---|
3122 | % % addpath(get(handles.TransformPath,'String')) |
---|
3123 | % addpath(path_uvmat)% add the path to uvmat to run the fct 'compile' |
---|
3124 | % % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile' |
---|
3125 | % compile(ActionName,TransformPath) |
---|
3126 | % cd(currentdir) |
---|
3127 | % end |
---|
3128 | % else |
---|
3129 | % sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh'])); |
---|
3130 | % m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m'])); |
---|
3131 | % if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum |
---|
3132 | % set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
3133 | % drawnow |
---|
3134 | % answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']); |
---|
3135 | % if strcmp(answer,'Yes') |
---|
3136 | % path_uvmat=fileparts(which('series')); |
---|
3137 | % currentdir=pwd; |
---|
3138 | % cd(get(handles.ActionPath,'String'))% go to the directory of Action |
---|
3139 | % % addpath(get(handles.TransformPath,'String')) |
---|
3140 | % addpath(path_uvmat)% add the path to uvmat to run the fct 'compile' |
---|
3141 | % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile' |
---|
3142 | % compile(ActionName,TransformPath) |
---|
3143 | % cd(currentdir) |
---|
3144 | % end |
---|
3145 | % end |
---|
3146 | % end |
---|
3147 | % set(handles.ActionExt,'BackgroundColor',[1 1 1]) |
---|
3148 | % set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch |
---|
3149 | % end |
---|
3150 | |
---|
3151 | |
---|
3152 | function num_NbProcess_Callback(hObject, eventdata, handles) |
---|
3153 | |
---|
3154 | |
---|
3155 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
3156 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
3157 | set(handles.num_NbProcess,'String',num2str(NbSlice)) |
---|
3158 | |
---|
3159 | %------------------------------------------------------------------------ |
---|
3160 | % --- set the visibility of relevant velocity type menus: |
---|
3161 | function menu=set_veltype_display(Civ,FileType) |
---|
3162 | %------------------------------------------------------------------------ |
---|
3163 | if ~exist('FileType','var') |
---|
3164 | FileType='civx'; |
---|
3165 | end |
---|
3166 | switch FileType |
---|
3167 | case 'civx' |
---|
3168 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
3169 | if isequal(Civ,0) |
---|
3170 | imax=0; |
---|
3171 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3172 | imax=1; |
---|
3173 | elseif isequal(Civ,3) |
---|
3174 | imax=3; |
---|
3175 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3176 | imax=4; |
---|
3177 | elseif isequal(Civ,6) %patch2 |
---|
3178 | imax=6; |
---|
3179 | end |
---|
3180 | case 'civdata' |
---|
3181 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
3182 | if isequal(Civ,0) |
---|
3183 | imax=0; |
---|
3184 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3185 | imax=1; |
---|
3186 | elseif isequal(Civ,3) |
---|
3187 | imax=2; |
---|
3188 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3189 | imax=3; |
---|
3190 | elseif isequal(Civ,6) %patch2 |
---|
3191 | imax=4; |
---|
3192 | end |
---|
3193 | end |
---|
3194 | menu=menu(1:imax); |
---|
3195 | |
---|
3196 | |
---|
3197 | % --- Executes on mouse motion over figure - except title and menu. |
---|
3198 | function series_WindowButtonMotionFcn(hObject, eventdata, handles) |
---|
3199 | set(hObject,'Pointer','arrow'); |
---|
3200 | |
---|
3201 | |
---|
3202 | % --- Executes on button press in SetPairs. |
---|
3203 | function SetPairs_Callback(hObject, iview, handles) |
---|
3204 | |
---|
3205 | %% delete previous occurrence of 'set_pairs' |
---|
3206 | hfig=findobj(allchild(0),'Tag','set_pairs'); |
---|
3207 | if ~isempty(hfig) |
---|
3208 | delete(hfig) |
---|
3209 | end |
---|
3210 | |
---|
3211 | %% create the GUI set_pairs |
---|
3212 | set(0,'Unit','points') |
---|
3213 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
3214 | Width=220;% fig width in points (1/72 inch) |
---|
3215 | Height=min(0.8*ScreenSize(4),300); |
---|
3216 | Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 |
---|
3217 | Bottom=ScreenSize(4)-Height-40; %put fig at top right |
---|
3218 | hfig=findobj(allchild(0),'Tag','set_slice'); |
---|
3219 | if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI |
---|
3220 | hfig=figure('name','set_pairs','tag','set_pairs','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height]); |
---|
3221 | BackgroundColor=get(hfig,'Color'); |
---|
3222 | SeriesData=get(handles.series,'UserData'); |
---|
3223 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
3224 | PairString=get(handles.PairString,'Data'); |
---|
3225 | ListViewLines=find(cellfun('isempty',PairString)==0);%find list of non empty pairs |
---|
3226 | ListViewMenu=cell(numel(ListViewLines),1); |
---|
3227 | for ilist=1:numel(ListViewLines) |
---|
3228 | ListViewMenu{ilist}=num2str(ListViewLines(ilist)); |
---|
3229 | end |
---|
3230 | if isempty(iview) |
---|
3231 | ListViewValue=numel(ListViewLines);% we work by default on the pair option for the last line which requires pairs |
---|
3232 | iview=ListViewLines(end); |
---|
3233 | else |
---|
3234 | ListViewValue=find(ListViewLines==iview); |
---|
3235 | end |
---|
3236 | ref_i=str2num(get(handles.num_first_i,'String')); |
---|
3237 | ref_j=str2num(get(handles.num_first_j,'String')); |
---|
3238 | [ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j2_series{iview}); |
---|
3239 | displ_pair=update_listpair(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j1_series{iview},SeriesData.j2_series{iview},ModeMenu{ModeValue},... |
---|
3240 | SeriesData.Time{iview},TimeUnit,ref_i,ref_j,SeriesData.FileInfo{iview}); |
---|
3241 | % first raw of the GUI |
---|
3242 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.88 0.5 0.1],'BackgroundColor',BackgroundColor,... |
---|
3243 | 'String','row to edit #','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title |
---|
3244 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.54 0.8 0.3 0.2],'BackgroundColor',[1 1 1],... |
---|
3245 | 'Callback',@(hObject,eventdata)ListView_Callback(hObject,eventdata),'String',ListViewMenu,'Value',ListViewValue,'FontUnits','points','FontSize',12,'FontWeight','bold',... |
---|
3246 | 'Tag','ListView','TooltipString','''ListView'':choice of the file series w for pair display'); |
---|
3247 | % second raw of the GUI |
---|
3248 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.79 0.7 0.1],'BackgroundColor',BackgroundColor,... |
---|
3249 | 'String','mode of index pairing:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');%title |
---|
3250 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.05 0.62 0.9 0.2],'BackgroundColor',[1 1 1],... |
---|
3251 | 'Callback',@(hObject,eventdata)Mode_Callback(hObject,eventdata),'String',ModeMenu,'Value',ModeValue,'FontUnits','points','FontSize',12,'FontWeight','bold',... |
---|
3252 | 'Tag','Mode','TooltipString','''Mode'': choice of the image pair mode'); |
---|
3253 | % third raw |
---|
3254 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.6 0.7 0.1],'BackgroundColor',BackgroundColor,... |
---|
3255 | 'String','pair choice:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');%title |
---|
3256 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.42 0.9 0.2],'BackgroundColor',[1 1 1],... |
---|
3257 | 'Callback',@(hObject,eventdata)ListPair_Callback(hObject,eventdata),'String',displ_pair,'Value',1,'FontUnits','points','FontSize',12,'FontWeight','bold',... |
---|
3258 | 'Tag','ListPair','TooltipString','''ListPair'': menu for selecting the image pair'); |
---|
3259 | uicontrol('Style','text','Units','normalized', 'Position', [0.1 0.22 0.8 0.1],'BackgroundColor',BackgroundColor,... |
---|
3260 | 'String','ref_i ref_j','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
3261 | uicontrol('Style','edit','Units','normalized', 'Position', [0.15 0.17 0.3 0.08],'BackgroundColor',[1 1 1],... |
---|
3262 | 'Callback',@(hObject,eventdata)num_ref_i_Callback(hObject,eventdata),'String',num2str(ref_i),'FontUnits','points','FontSize',12,'FontWeight','bold',... |
---|
3263 | 'Tag','num_ref_i','TooltipString','''num_ref_i'': reference field index i used to display dt in ''list_pair_civ'''); |
---|
3264 | uicontrol('Style','edit','Units','normalized', 'Position', [0.55 0.17 0.3 0.08],'BackgroundColor',[1 1 1],... |
---|
3265 | 'Callback',@(hObject,eventdata)num_ref_j_Callback(hObject,eventdata),'String',num2str(ref_j),'FontUnits','points','FontSize',12,'FontWeight','bold',... |
---|
3266 | 'Tag','num_ref_j','TooltipString','''num_ref_j'': reference field index i used to display dt in ''list_pair_civ'''); |
---|
3267 | % last raw of the GUI: pushbuttons |
---|
3268 | % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.35 0.01 0.3 0.15],'BackgroundColor',[0 1 0],'String','OK','Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),... |
---|
3269 | % 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''OK'': apply the output to the current field series in uvmat'); |
---|
3270 | drawnow |
---|
3271 | |
---|
3272 | %------------------------------------------------------------------------ |
---|
3273 | function ListView_Callback(hObject,eventdata) |
---|
3274 | Mode_Callback(hObject,eventdata) |
---|
3275 | |
---|
3276 | %------------------------------------------------------------------------ |
---|
3277 | function Mode_Callback(hObject,eventdata) |
---|
3278 | %% get input info |
---|
3279 | hseries=findobj(allchild(0),'tag','series');%handles of the GUI series |
---|
3280 | hhseries=guidata(hseries);%handles of the elements in the GUI series |
---|
3281 | TimeUnit=get(hhseries.TimeUnit,'String'); |
---|
3282 | SeriesData=get(hseries,'UserData'); |
---|
3283 | mode_list=get(hObject,'String'); |
---|
3284 | mode=mode_list{get(hObject,'Value')}; |
---|
3285 | hListView=findobj(get(hObject,'parent'),'Tag','ListView'); |
---|
3286 | iview=get(hListView,'Value'); |
---|
3287 | i1_series=SeriesData.i1_series{iview}; |
---|
3288 | i2_series=SeriesData.i2_series{iview}; |
---|
3289 | j1_series=SeriesData.j1_series{iview}; |
---|
3290 | j2_series=SeriesData.j2_series{iview}; |
---|
3291 | |
---|
3292 | %% enable j index visibility after the new choice |
---|
3293 | status_j='on';%default |
---|
3294 | if isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)); % case of empty j indices |
---|
3295 | status_j='off'; % no j index needed |
---|
3296 | elseif strcmp(get(handles.PairString,'Visible'),'on') |
---|
3297 | check_burst=cellfun(@isempty,regexp(PairString,'^j'));%=0 for burst case, 1 otherwise |
---|
3298 | if isempty(find(check_burst, 1))% if all pair string begins by j (burst) |
---|
3299 | status_j='off'; % no j index needed for bust case |
---|
3300 | end |
---|
3301 | end |
---|
3302 | enable_j(handles,status_j) % no j index needed |
---|
3303 | |
---|
3304 | %% get the reference indices for the time interval Dt |
---|
3305 | href_i=findobj(get(hObject,'parent'),'Tag','ref_i'); |
---|
3306 | ref_i=[];ref_j=[]; |
---|
3307 | if strcmp(get(href_i,'Visible'),'on') |
---|
3308 | ref_i=str2num(get(href_i,'String')); |
---|
3309 | end |
---|
3310 | if isempty(ref_i) |
---|
3311 | ref_i=1; |
---|
3312 | end |
---|
3313 | if isempty(ref_j) |
---|
3314 | ref_j=1; |
---|
3315 | end |
---|
3316 | |
---|
3317 | %% update the menu ListPair |
---|
3318 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j,FileInfo); |
---|
3319 | hlist_pairs=findobj(get(hObject,'parent'),'Tag','ListPair'); |
---|
3320 | set(hlist_pairs,'Value',1)% set the first choice by default in ListPair |
---|
3321 | set(hlist_pairs,'String',Menu)% set the menu in ListPair |
---|
3322 | ListPair_Callback(hlist_pairs,[])% apply the default choice in ListPair |
---|
3323 | |
---|
3324 | %------------------------------------------------------------- |
---|
3325 | % --- Executes on selection in ListPair. |
---|
3326 | function ListPair_Callback(hObject,eventdata) |
---|
3327 | %------------------------------------------------------------ |
---|
3328 | list_pair=get(hObject,'String');%get the menu of image pairs |
---|
3329 | if isempty(list_pair) |
---|
3330 | string=''; |
---|
3331 | else |
---|
3332 | string=list_pair{get(hObject,'Value')}; |
---|
3333 | % string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
3334 | end |
---|
3335 | hseries=findobj(allchild(0),'tag','series'); |
---|
3336 | hPairString=findobj(hseries,'tag','PairString'); |
---|
3337 | PairString=get(hPairString,'Data'); |
---|
3338 | hListView=findobj(get(hObject,'parent'),'Tag','ListView'); |
---|
3339 | iview=get(hListView,'Value'); |
---|
3340 | PairString{iview,1}=string; |
---|
3341 | % report the selected pair string to the table PairString |
---|
3342 | set(hPairString,'Data',PairString) |
---|
3343 | |
---|
3344 | |
---|
3345 | %------------------------------------------------------------------------ |
---|
3346 | function num_ref_i_Callback(hObject, eventdata) |
---|
3347 | %------------------------------------------------------------------------ |
---|
3348 | Mode_Callback([],[]) |
---|
3349 | |
---|
3350 | %------------------------------------------------------------------------ |
---|
3351 | function num_ref_j_Callback(hObject, eventdata) |
---|
3352 | %------------------------------------------------------------------------ |
---|
3353 | Mode_Callback([],[]) |
---|
3354 | |
---|
3355 | |
---|