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