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 | |
---|
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 0])% set REFRESH button to red color (end of activation) |
---|
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 0])% set REFRESH button to red color (end of activation) |
---|
597 | return |
---|
598 | end |
---|
599 | if strcmp(FileType,'txt') |
---|
600 | edit(fileinput) |
---|
601 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) |
---|
602 | return |
---|
603 | elseif strcmp(FileType,'xml') |
---|
604 | editxml(fileinput) |
---|
605 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) |
---|
606 | return |
---|
607 | elseif strcmp(FileType,'figure') |
---|
608 | open(fileinput) |
---|
609 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red 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 | |
---|
627 | %% fill the list of file series |
---|
628 | InputTable=get(handles.InputTable,'Data'); |
---|
629 | SeriesData=get(handles.series,'UserData'); |
---|
630 | if strcmp(iview,'append') % display the input data as a new line in the table |
---|
631 | iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line |
---|
632 | %InputTable(iview+1,:)={'','','','',''}; |
---|
633 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
634 | elseif strcmp(iview,'one') % refresh the list of input file series |
---|
635 | iview=1; %the first line in InputTable becomes the current line |
---|
636 | InputTable={'','','','',''}; |
---|
637 | %InputTable=[{'','','','',''};{'','','','',''}]; |
---|
638 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
639 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
640 | set(handles.MinIndex_i,'Data',[]) |
---|
641 | set(handles.MaxIndex_i,'Data',[]) |
---|
642 | set(handles.MinIndex_j,'Data',[]) |
---|
643 | set(handles.MaxIndex_j,'Data',[]) |
---|
644 | set(handles.ListView,'Value',1) |
---|
645 | set(handles.ListView,'String',{'1'}) |
---|
646 | set(handles.PairString,'Data',{''}) |
---|
647 | SeriesData.i1_series={}; |
---|
648 | SeriesData.i2_series={}; |
---|
649 | SeriesData.j1_series={}; |
---|
650 | SeriesData.j2_series={}; |
---|
651 | SeriesData.FileType={}; |
---|
652 | SeriesData.FileInfo={}; |
---|
653 | SeriesData.Time={}; |
---|
654 | end |
---|
655 | %nbview=size(InputTable,1)-1;% rmq: the last line is set blank to allow manual addition of a line |
---|
656 | nbview=size(InputTable,1); |
---|
657 | set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1))) |
---|
658 | set(handles.ListView,'Value',iview) |
---|
659 | set(handles.InputTable,'Data',InputTable) |
---|
660 | |
---|
661 | %% determine the selected reference field indices for pair display |
---|
662 | if isempty(i1) |
---|
663 | i1=1; |
---|
664 | end |
---|
665 | if isempty(i2) |
---|
666 | i2=i1; |
---|
667 | end |
---|
668 | ref_i=floor((i1+i2)/2);% reference image number corresponding to the file |
---|
669 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
670 | % set(handles.num_ref_i,'UserData',[i1 i2])%store the indices for future opening |
---|
671 | if isempty(j1) |
---|
672 | j1=1; |
---|
673 | end |
---|
674 | if isempty(j2) |
---|
675 | j2=j1; |
---|
676 | end |
---|
677 | ref_j=floor((j1+j2)/2);% reference image number corresponding to the file |
---|
678 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
679 | |
---|
680 | %% update first and last indices if they do not exist |
---|
681 | Param=read_GUI(handles.series); |
---|
682 | first_j=[]; |
---|
683 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end |
---|
684 | last_j=[]; |
---|
685 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end |
---|
686 | PairString=''; |
---|
687 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end |
---|
688 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString); |
---|
689 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... |
---|
690 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); |
---|
691 | if ~exist(FirstFileName,'file') |
---|
692 | set(handles.num_first_i,'String',num2str(ref_i)) |
---|
693 | set(handles.num_first_j,'String',num2str(ref_j)) |
---|
694 | end |
---|
695 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString); |
---|
696 | LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... |
---|
697 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); |
---|
698 | if ~exist(LastFileName,'file') |
---|
699 | set(handles.num_last_i,'String',num2str(ref_i)) |
---|
700 | set(handles.num_last_j,'String',num2str(ref_j)) |
---|
701 | end |
---|
702 | |
---|
703 | %% update the list of recent files in the menubar and save it for future opening |
---|
704 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
705 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
706 | str_find=strcmp(fileinput,MenuFile); |
---|
707 | if isempty(find(str_find,1)) |
---|
708 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
709 | end |
---|
710 | for ifile=1:min(length(MenuFile),5) |
---|
711 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
712 | end |
---|
713 | dir_perso=prefdir; |
---|
714 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
715 | if exist(profil_perso,'file') |
---|
716 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
717 | else |
---|
718 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
719 | end |
---|
720 | % save the opened file to initiate future opening |
---|
721 | SeriesData.RefFile{iview}=fileinput;% reference opening file for line iview |
---|
722 | SeriesData.Ref_i1=i1; |
---|
723 | SeriesData.Ref_i2=i2; |
---|
724 | SeriesData.Ref_j1=j1; |
---|
725 | SeriesData.Ref_j2=j2; |
---|
726 | set(handles.series,'UserData',SeriesData) |
---|
727 | |
---|
728 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
729 | |
---|
730 | %% initiate input file series and refresh the current field view: |
---|
731 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,iview); |
---|
732 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation) |
---|
733 | |
---|
734 | %------------------------------------------------------------------------ |
---|
735 | % --- Update information about a new field series (indices to scan, timing, |
---|
736 | % calibration from an xml file |
---|
737 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,VideoObject,iview) |
---|
738 | %------------------------------------------------------------------------ |
---|
739 | InputTable=get(handles.InputTable,'Data'); |
---|
740 | |
---|
741 | %% display the min and max indices for the whole file series |
---|
742 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 |
---|
743 | MinIndex_j=1;% index j set to 1 by default |
---|
744 | MaxIndex_j=1; |
---|
745 | 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) |
---|
746 | 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) |
---|
747 | else |
---|
748 | ref_i=squeeze(max(i1_series(1,:,:),[],2));% select ref_j index for each ref_i |
---|
749 | ref_j=squeeze(max(j1_series(1,:,:),[],3));% select ref_i index for each ref_j |
---|
750 | MinIndex_i=min(find(ref_i))-1; |
---|
751 | MaxIndex_i=max(find(ref_i))-1; |
---|
752 | MaxIndex_j=max(find(ref_j))-1; |
---|
753 | MinIndex_j=min(find(ref_j))-1; |
---|
754 | diff_j_max=diff(ref_j); |
---|
755 | diff_i_max=diff(ref_i); |
---|
756 | if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) |
---|
757 | set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default |
---|
758 | end |
---|
759 | if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) |
---|
760 | set(handles.num_incr_j,'String',num2str(diff_j_max(1))) |
---|
761 | end |
---|
762 | end |
---|
763 | if isequal(MinIndex_i,-1) |
---|
764 | MinIndex_i=0; |
---|
765 | end |
---|
766 | if isequal(MinIndex_j,-1) |
---|
767 | MinIndex_j=0; |
---|
768 | end |
---|
769 | MinIndex_i_table=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex |
---|
770 | MinIndex_j_table=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex |
---|
771 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex |
---|
772 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex |
---|
773 | MinIndex_i_table(iview,1)=MinIndex_i; |
---|
774 | MinIndex_j_table(iview,1)=MinIndex_j; |
---|
775 | MaxIndex_i_table(iview,1)=MaxIndex_i; |
---|
776 | MaxIndex_j_table(iview,1)=MaxIndex_j; |
---|
777 | set(handles.MinIndex_i,'Data',MinIndex_i_table)%display the min indices in the table MinIndex |
---|
778 | set(handles.MinIndex_j,'Data',MinIndex_j_table)%display the max indices in the table MaxIndex |
---|
779 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table)%display the min indices in the table MinIndex |
---|
780 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex |
---|
781 | |
---|
782 | %% adjust the first and last indices for the selected series, only if requested by the bounds |
---|
783 | % i index, compare input to min index i |
---|
784 | first_i=str2num(get(handles.num_first_i,'String'));%retrieve previous first i |
---|
785 | ref_i=str2num(get(handles.num_ref_i,'String'));%index i given by the input field |
---|
786 | if isempty(first_i) |
---|
787 | first_i=ref_i;% first_i updated by the input value |
---|
788 | elseif first_i < MinIndex_i |
---|
789 | first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines) |
---|
790 | elseif first_i >MaxIndex_i |
---|
791 | first_i=MaxIndex_i;% first_i set to the max i index (restricted by oter input lines) |
---|
792 | end |
---|
793 | % j index, compare input to min index j |
---|
794 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
795 | ref_j=str2num(get(handles.num_ref_j,'String'));%index j given by the input field |
---|
796 | if isempty(first_j) |
---|
797 | first_j=ref_j;% first_j updated by the input value |
---|
798 | elseif first_j<MinIndex_j |
---|
799 | first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines) |
---|
800 | elseif first_j >MaxIndex_j |
---|
801 | first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines) |
---|
802 | end |
---|
803 | % i index, compare input to max index i |
---|
804 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
805 | if isempty(last_i) |
---|
806 | last_i=ref_i; |
---|
807 | elseif last_i > MaxIndex_i |
---|
808 | last_i=MaxIndex_i; |
---|
809 | elseif last_i<first_i |
---|
810 | last_i=first_i; |
---|
811 | end |
---|
812 | % j index, compare input to max index j |
---|
813 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
814 | if isempty(last_j) |
---|
815 | last_j=ref_j; |
---|
816 | elseif last_j>MaxIndex_j |
---|
817 | last_j=MaxIndex_j; |
---|
818 | elseif last_j<first_j |
---|
819 | last_j=first_j; |
---|
820 | end |
---|
821 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
822 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
823 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
824 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
825 | |
---|
826 | %% number of slices set by default |
---|
827 | NbSlice=1;%default |
---|
828 | % read value set by the first series for the checkappend mode (iwiew >1) |
---|
829 | if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on') |
---|
830 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
831 | end |
---|
832 | |
---|
833 | %% default time unit |
---|
834 | TimeUnit=''; |
---|
835 | % read value set by the first series for the checkappend mode (iwiew >1) |
---|
836 | if iview>1 |
---|
837 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
838 | end |
---|
839 | TimeSource=''; |
---|
840 | Time=[];%default |
---|
841 | |
---|
842 | %% read image documentation file if found |
---|
843 | XmlData=[]; |
---|
844 | check_calib=0; |
---|
845 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5}); |
---|
846 | if ~isempty(XmlFileName) |
---|
847 | [XmlData,errormsg]=imadoc2struct(XmlFileName); |
---|
848 | if ~isempty(errormsg) |
---|
849 | msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]); |
---|
850 | end |
---|
851 | % read time if available |
---|
852 | if isfield(XmlData,'Time') |
---|
853 | Time=XmlData.Time; |
---|
854 | TimeSource='xml'; |
---|
855 | end |
---|
856 | if isfield(XmlData,'Camera') |
---|
857 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
858 | if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,XmlData.Camera.NbSlice) |
---|
859 | msgbox_uvmat('WARNING','inconsistent number of slices with the first field series'); |
---|
860 | end |
---|
861 | NbSlice=XmlData.Camera.NbSlice;% Nbre of slices from camera |
---|
862 | end |
---|
863 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
864 | if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit) |
---|
865 | msgbox_uvmat('WARNING','inconsistent time unit with the first field series'); |
---|
866 | end |
---|
867 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
868 | end |
---|
869 | end |
---|
870 | % number of slices |
---|
871 | if isfield(XmlData,'GeometryCalib') |
---|
872 | check_calib=1; |
---|
873 | if isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
874 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
875 | if siz(1)>1 |
---|
876 | if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,siz(1)) |
---|
877 | msgbox_uvmat('WARNING','inconsistent number of Z indices with the first field series'); |
---|
878 | end |
---|
879 | NbSlice=siz(1); |
---|
880 | end |
---|
881 | end |
---|
882 | end |
---|
883 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
884 | end |
---|
885 | |
---|
886 | %% read timing and total frame number from the current file (movie files) if not already set by the xml file (prioritary) |
---|
887 | InputTable=get(handles.InputTable,'Data'); |
---|
888 | |
---|
889 | % case of movies |
---|
890 | if isempty(Time) |
---|
891 | if ~isempty(VideoObject) |
---|
892 | imainfo=get(VideoObject); |
---|
893 | if isempty(j1_series); %frame index along i |
---|
894 | Time=zeros(imainfo.NumberOfFrames+1,2); |
---|
895 | Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
896 | else |
---|
897 | Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
898 | end |
---|
899 | TimeSource='video'; |
---|
900 | end |
---|
901 | end |
---|
902 | |
---|
903 | %% update time table |
---|
904 | if ~isempty(Time) |
---|
905 | TimeTable=get(handles.TimeTable,'Data'); |
---|
906 | TimeTable{iview,1}=Time(MinIndex_i+1,MinIndex_j+1); |
---|
907 | if size(Time)>=[first_i+1 first_j+1] |
---|
908 | TimeTable{iview,2}=Time(first_i+1,first_j+1); |
---|
909 | end |
---|
910 | if size(Time)>=[last_i+1 last_j+1] |
---|
911 | TimeTable{iview,3}=Time(last_i+1,last_j+1); |
---|
912 | end |
---|
913 | if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]; |
---|
914 | TimeTable{iview,4}=Time(MaxIndex_i+1,MaxIndex_j+1); |
---|
915 | end |
---|
916 | set(handles.TimeTable,'Data',TimeTable) |
---|
917 | end |
---|
918 | |
---|
919 | %% update the series info in 'UserData' |
---|
920 | SeriesData=get(handles.series,'UserData'); |
---|
921 | SeriesData.i1_series{iview}=i1_series; |
---|
922 | SeriesData.i2_series{iview}=i2_series; |
---|
923 | SeriesData.j1_series{iview}=j1_series; |
---|
924 | SeriesData.j2_series{iview}=j2_series; |
---|
925 | SeriesData.FileType{iview}=FileType; |
---|
926 | SeriesData.FileInfo{iview}=FileInfo; |
---|
927 | SeriesData.Time{iview}=Time; |
---|
928 | if ~isempty(TimeSource) |
---|
929 | SeriesData.TimeSource=TimeSource; |
---|
930 | end |
---|
931 | % if ~isempty(TimeUnit) |
---|
932 | % SeriesData.TimeUnit=TimeUnit; |
---|
933 | % end |
---|
934 | if check_calib |
---|
935 | SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib; |
---|
936 | end |
---|
937 | set(handles.series,'UserData',SeriesData) |
---|
938 | |
---|
939 | %% update pair menus |
---|
940 | ListView=get(handles.ListView,'String'); |
---|
941 | ListView{iview}=num2str(iview); |
---|
942 | set(handles.ListView,'String',ListView); |
---|
943 | set(handles.ListView,'Value',iview) |
---|
944 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,Time) |
---|
945 | |
---|
946 | %% enable j index visibility |
---|
947 | status_j='on';%default |
---|
948 | if isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)); % case of empty j indices |
---|
949 | status_j='off'; % no j index needed |
---|
950 | elseif strcmp(get(handles.PairString,'Visible'),'on') |
---|
951 | PairString=get(handles.PairString,'Data'); |
---|
952 | check_burst=cellfun(@isempty,regexp(PairString,'^j'));%=0 for burst case, 1 otherwise |
---|
953 | if isempty(find(check_burst, 1))% if all pair string begins by j (burst) |
---|
954 | status_j='off'; % no j index needed for bust case |
---|
955 | end |
---|
956 | end |
---|
957 | enable_j(handles,status_j) % no j index needed |
---|
958 | |
---|
959 | %% display the set of existing files as an image |
---|
960 | set(handles.FileStatus,'Units','pixels') |
---|
961 | Position=get(handles.FileStatus,'Position'); |
---|
962 | set(handles.FileStatus,'Units','normalized') |
---|
963 | %xI=0.5:Position(3)-0.5; |
---|
964 | nbview=numel(SeriesData.i1_series); |
---|
965 | j_max=cell(1,nbview); |
---|
966 | MaxIndex_i=ones(1,nbview);%default |
---|
967 | MinIndex_i=ones(1,nbview);%default |
---|
968 | for iview=1:nbview |
---|
969 | pair_max=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
970 | j_max{iview}=max(pair_max,[],1);%max on j index |
---|
971 | MaxIndex_i(iview)=max(find(j_max{iview}))-1;% max ref index i |
---|
972 | MinIndex_i(iview)=min(find(j_max{iview}))-1;% min ref index i |
---|
973 | end |
---|
974 | MinIndex_i=min(MinIndex_i); |
---|
975 | MaxIndex_i=max(MaxIndex_i); |
---|
976 | range_index=MaxIndex_i-MinIndex_i+1; |
---|
977 | % scale_y=Position(4)/nbview; |
---|
978 | % scale_x=Position(3)/range_index; |
---|
979 | %x=(0.5:range_index-0.5)*Position(3)/range_index;% set of abscissa representing the whole i index range |
---|
980 | % y=(0.5:nbview-0.5)*Position(4)/nbview; |
---|
981 | range_y=max(1,floor(Position(4)/nbview)); |
---|
982 | npx=floor(Position(3)); |
---|
983 | file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1; |
---|
984 | CData=zeros(nbview*range_y,npx);% initiate the image representing the existing files |
---|
985 | for iview=1:nbview |
---|
986 | ind_y=1+(iview-1)*range_y:iview*range_y; |
---|
987 | LineData=zeros(size(file_indices)); |
---|
988 | file_select=file_indices(file_indices<=numel(j_max{iview})); |
---|
989 | ind_select=find(file_indices<=numel(j_max{iview})); |
---|
990 | LineData(ind_select)=j_max{iview}(file_select)~=0; |
---|
991 | CData(ind_y,:)=ones(size(ind_y'))*LineData; |
---|
992 | end |
---|
993 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));%make color images r=0,g,b=0 |
---|
994 | set(handles.FileStatus,'CData',CData); |
---|
995 | |
---|
996 | %% check for pair display |
---|
997 | check_pairs=0; |
---|
998 | for iview=1:numel(SeriesData.i2_series) |
---|
999 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
1000 | check_pairs=1; |
---|
1001 | end |
---|
1002 | end |
---|
1003 | if check_pairs |
---|
1004 | set(handles.Pairs,'Visible','on') |
---|
1005 | set(handles.PairString,'Visible','on') |
---|
1006 | else |
---|
1007 | set(handles.Pairs,'Visible','off') |
---|
1008 | set(handles.PairString,'Visible','off') |
---|
1009 | end |
---|
1010 | |
---|
1011 | |
---|
1012 | %% enable field and veltype menus, in accordance with the current action |
---|
1013 | ActionName_Callback([],[], handles) |
---|
1014 | |
---|
1015 | %% set length of waitbar |
---|
1016 | displ_time(handles) |
---|
1017 | |
---|
1018 | %% set default options in menu 'Fields' |
---|
1019 | switch FileType |
---|
1020 | case {'civx','civdata'} |
---|
1021 | [FieldList,ColorList]=set_field_list('U','V','C'); |
---|
1022 | set(handles.FieldName,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
1023 | set(handles.FieldName,'Value',2) % set menu to 'velocity |
---|
1024 | set(handles.Coord_x,'Value',1); |
---|
1025 | set(handles.Coord_x,'String',{'X'}); |
---|
1026 | set(handles.Coord_y,'Value',1); |
---|
1027 | set(handles.Coord_y,'String',{'Y'}); |
---|
1028 | case 'netcdf' |
---|
1029 | set(handles.FieldName,'Value',1) |
---|
1030 | set(handles.FieldName,'String',{'get_field...'}) |
---|
1031 | if isempty(i2_series) |
---|
1032 | i2=[]; |
---|
1033 | else |
---|
1034 | i2=i2_series(1,ref_j+1,ref_i+1); |
---|
1035 | end |
---|
1036 | if isempty(j1_series) |
---|
1037 | j1=[];j2=[]; |
---|
1038 | else |
---|
1039 | j1=j1_series(1,ref_j+1,ref_i+1); |
---|
1040 | if isempty(j2_series) |
---|
1041 | j2=[]; |
---|
1042 | else |
---|
1043 | j2=j2_series(1,ref_j+1,ref_i+1); |
---|
1044 | end |
---|
1045 | end |
---|
1046 | FieldName_Callback([], [], handles) |
---|
1047 | % FileName=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1_series(1,ref_j+1,ref_i+1),i2,j1,j2); |
---|
1048 | % hget_field=get_field(FileName); |
---|
1049 | % hhget_field=guidata(hget_field); |
---|
1050 | % get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
1051 | otherwise |
---|
1052 | set(handles.FieldName,'Value',1) % set menu to 'image' |
---|
1053 | set(handles.FieldName,'String',{'image'}) |
---|
1054 | set(handles.Coord_x,'Value',1); |
---|
1055 | set(handles.Coord_x,'String',{'AX'}); |
---|
1056 | set(handles.Coord_y,'Value',1); |
---|
1057 | set(handles.Coord_y,'String',{'AY'}); |
---|
1058 | end |
---|
1059 | |
---|
1060 | %------------------------------------------------------------------------ |
---|
1061 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
1062 | %------------------------------------------------------------------------ |
---|
1063 | num_last_i_Callback(hObject, eventdata, handles) |
---|
1064 | |
---|
1065 | %------------------------------------------------------------------------ |
---|
1066 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
1067 | %------------------------------------------------------------------------ |
---|
1068 | SeriesData=get(handles.series,'UserData'); |
---|
1069 | if ~isfield(SeriesData,'Time') |
---|
1070 | SeriesData.Time{1}=[]; |
---|
1071 | end |
---|
1072 | displ_time(handles); |
---|
1073 | |
---|
1074 | %------------------------------------------------------------------------ |
---|
1075 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
1076 | %------------------------------------------------------------------------ |
---|
1077 | num_last_j_Callback(hObject, eventdata, handles) |
---|
1078 | |
---|
1079 | %------------------------------------------------------------------------ |
---|
1080 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
1081 | %------------------------------------------------------------------------ |
---|
1082 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
1083 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
1084 | ref_j=ceil((first_j+last_j)/2); |
---|
1085 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
1086 | num_ref_j_Callback(hObject, eventdata, handles) |
---|
1087 | SeriesData=get(handles.series,'UserData'); |
---|
1088 | if ~isfield(SeriesData,'Time') |
---|
1089 | SeriesData.Time{1}=[]; |
---|
1090 | end |
---|
1091 | displ_time(handles); |
---|
1092 | |
---|
1093 | |
---|
1094 | %------------------------------------------------------------------------ |
---|
1095 | % ---- find the times corresponding to the first and last indices of a series |
---|
1096 | function displ_time(handles) |
---|
1097 | %------------------------------------------------------------------------ |
---|
1098 | SeriesData=get(handles.series,'UserData');% |
---|
1099 | PairString=get(handles.PairString,'Data'); |
---|
1100 | ref_i_1=str2num(get(handles.num_first_i,'String'));%first reference index |
---|
1101 | ref_i_2=str2num(get(handles.num_last_i,'String'));%last reference index |
---|
1102 | ref_j_1=[];ref_j_2=[]; |
---|
1103 | if strcmp(get(handles.num_first_j,'Visible'),'on') |
---|
1104 | ref_j_1=str2num(get(handles.num_first_j,'String')); |
---|
1105 | ref_j_2=str2num(get(handles.num_last_j,'String')); |
---|
1106 | end |
---|
1107 | [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString); |
---|
1108 | [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString); |
---|
1109 | TimeTable=get(handles.TimeTable,'Data'); |
---|
1110 | |
---|
1111 | %Pairs=get(handles.PairString,'Data'); |
---|
1112 | for iview=1:size(TimeTable,1) |
---|
1113 | if size(SeriesData.Time,1)<iview |
---|
1114 | break |
---|
1115 | end |
---|
1116 | TimeTable{iview,2}=[]; |
---|
1117 | TimeTable{iview,3}=[]; |
---|
1118 | if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1) |
---|
1119 | if isempty(ref_j_1) |
---|
1120 | time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2; |
---|
1121 | time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2; |
---|
1122 | else |
---|
1123 | time_first=(SeriesData.Time{iview}(i1_1+1,j1_1+1)+SeriesData.Time{iview}(i2_1+1,j2_1+1))/2; |
---|
1124 | time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2; |
---|
1125 | end |
---|
1126 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
1127 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
1128 | end |
---|
1129 | end |
---|
1130 | set(handles.TimeTable,'Data',TimeTable) |
---|
1131 | |
---|
1132 | %% set the waitbar position with respect to the min and max in the series |
---|
1133 | MinIndex_i=min(get(handles.MinIndex_i,'Data')); |
---|
1134 | MaxIndex_i=max(get(handles.MaxIndex_i,'Data')); |
---|
1135 | pos_first=(ref_i_1-MinIndex_i)/(MaxIndex_i-MinIndex_i+1); |
---|
1136 | pos_last=(ref_i_2-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1); |
---|
1137 | Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] |
---|
1138 | Position_status=get(handles.FileStatus,'Position'); |
---|
1139 | Position(1)=Position_status(1)+Position_status(3)*pos_first; |
---|
1140 | Position(3)=Position_status(3)*(pos_last-pos_first); |
---|
1141 | set(handles.Waitbar,'Position',Position) |
---|
1142 | update_waitbar(handles.Waitbar,0) |
---|
1143 | |
---|
1144 | %------------------------------------------------------------------------ |
---|
1145 | % --- Executes when selected cell(s) is changed in PairString. |
---|
1146 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
1147 | %------------------------------------------------------------------------ |
---|
1148 | if numel(eventdata.Indices)>=1 |
---|
1149 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
1150 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
1151 | end |
---|
1152 | |
---|
1153 | %------------------------------------------------------------------------ |
---|
1154 | %------------------------------------------------------------------------ |
---|
1155 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
1156 | %------------------------------------------------------------------------ |
---|
1157 | %------------------------------------------------------------------------ |
---|
1158 | % --- Executes on selection change in ListView. |
---|
1159 | function ListView_Callback(hObject, eventdata, handles) |
---|
1160 | %------------------------------------------------------------------------ |
---|
1161 | SeriesData=get(handles.series,'UserData'); |
---|
1162 | i2_series=[]; |
---|
1163 | j2_series=[]; |
---|
1164 | iview=get(handles.ListView,'Value'); |
---|
1165 | if ~isempty(SeriesData.i2_series{iview}) |
---|
1166 | i2_series=SeriesData.i2_series{iview}; |
---|
1167 | end |
---|
1168 | if ~isempty(SeriesData.j2_series{iview}) |
---|
1169 | j2_series=SeriesData.j2_series{iview}; |
---|
1170 | end |
---|
1171 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1172 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1173 | |
---|
1174 | %------------------------------------------------------------------------ |
---|
1175 | % --- Executes on button press in mode. |
---|
1176 | function mode_Callback(hObject, eventdata, handles) |
---|
1177 | %------------------------------------------------------------------------ |
---|
1178 | SeriesData=get(handles.series,'UserData'); |
---|
1179 | iview=get(handles.ListView,'Value'); |
---|
1180 | mode_list=get(handles.mode,'String'); |
---|
1181 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1182 | if isequal(mode,'bursts') |
---|
1183 | enable_i(handles,'On') |
---|
1184 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1185 | else |
---|
1186 | enable_i(handles,'On') |
---|
1187 | enable_j(handles,'Off') |
---|
1188 | end |
---|
1189 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1190 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1191 | ListPairs_Callback([],[],handles) |
---|
1192 | |
---|
1193 | %------------------------------------------------------------- |
---|
1194 | % --- Executes on selection in ListPairs. |
---|
1195 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
1196 | %------------------------------------------------------------ |
---|
1197 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
1198 | if isempty(list_pair) |
---|
1199 | string=''; |
---|
1200 | else |
---|
1201 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
1202 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
1203 | end |
---|
1204 | PairString=get(handles.PairString,'Data'); |
---|
1205 | iview=get(handles.ListView,'Value'); |
---|
1206 | PairString{iview,1}=string; |
---|
1207 | % report the selected pair string to the table PairString |
---|
1208 | set(handles.PairString,'Data',PairString) |
---|
1209 | |
---|
1210 | %------------------------------------------------------------------------ |
---|
1211 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
1212 | %------------------------------------------------------------------------ |
---|
1213 | mode_list=get(handles.mode,'String'); |
---|
1214 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1215 | SeriesData=get(handles.series,'UserData'); |
---|
1216 | iview=get(handles.ListView,'Value'); |
---|
1217 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1218 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files |
---|
1219 | ListPairs_Callback([],[],handles) |
---|
1220 | |
---|
1221 | %------------------------------------------------------------------------ |
---|
1222 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
1223 | %------------------------------------------------------------------------ |
---|
1224 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
1225 | |
---|
1226 | %------------------------------------------------------------------------ |
---|
1227 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1228 | %------------------------------------------------------------------------ |
---|
1229 | % check_burst=0; |
---|
1230 | if isempty(j2_series)% no j pair |
---|
1231 | if isempty(i2_series) |
---|
1232 | set(handles.mode,'Value',1) |
---|
1233 | set(handles.mode,'String',{''})% no pair menu to display |
---|
1234 | else |
---|
1235 | set(handles.mode,'Value',1) |
---|
1236 | set(handles.mode,'String',{'series(Di)'}) % pair menu with only option Di |
---|
1237 | end |
---|
1238 | else %existence of j pairs |
---|
1239 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
1240 | j_max=max(pair_max,[],1); |
---|
1241 | MaxIndex_i=max(find(j_max))-1;% max ref index i |
---|
1242 | MinIndex_i=min(find(j_max))-1;% min ref index i |
---|
1243 | i_max=max(pair_max,[],2); |
---|
1244 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
1245 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
1246 | if MaxIndex_j==MinIndex_j |
---|
1247 | set(handles.mode,'Value',1); |
---|
1248 | set(handles.mode,'String',{'bursts'}) |
---|
1249 | % check_burst=1; |
---|
1250 | elseif MaxIndex_i==MinIndex_i |
---|
1251 | set(handles.mode,'Value',1); |
---|
1252 | set(handles.mode,'String',{'series(Dj)'}) |
---|
1253 | else |
---|
1254 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
1255 | if (MaxIndex_j-MinIndex_j)>10 |
---|
1256 | set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values |
---|
1257 | else |
---|
1258 | set(handles.mode,'Value',1); |
---|
1259 | % check_burst=1; |
---|
1260 | end |
---|
1261 | end |
---|
1262 | end |
---|
1263 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1264 | ListPairs_Callback([],[],handles) |
---|
1265 | |
---|
1266 | %-------------------------------------------------------------- |
---|
1267 | % determine the menu for pairstring depending on existing netcdf files |
---|
1268 | % with the reference indices num_ref_i and num_ref_j |
---|
1269 | %---------------------------------------------------------------- |
---|
1270 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1271 | |
---|
1272 | mode_list=get(handles.mode,'String'); |
---|
1273 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1274 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
1275 | if isempty(ref_i) |
---|
1276 | ref_i=1; |
---|
1277 | end |
---|
1278 | if strcmp(get(handles.num_ref_j,'Visible'),'on') |
---|
1279 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
1280 | if isempty(ref_j) |
---|
1281 | ref_j=1; |
---|
1282 | end |
---|
1283 | else |
---|
1284 | ref_j=1; |
---|
1285 | end |
---|
1286 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
1287 | if length(TimeUnit)>=1 |
---|
1288 | dtunit=['m' TimeUnit]; |
---|
1289 | else |
---|
1290 | dtunit='e-03'; |
---|
1291 | end |
---|
1292 | |
---|
1293 | displ_pair={}; |
---|
1294 | if strcmp(mode,'series(Di)') |
---|
1295 | if isempty(i2_series) |
---|
1296 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
1297 | return |
---|
1298 | end |
---|
1299 | diff_i=i2_series-i1_series; |
---|
1300 | min_diff=min(diff_i(diff_i>0)); |
---|
1301 | max_diff=max(diff_i(diff_i>0)); |
---|
1302 | for ipair=min_diff:max_diff |
---|
1303 | if numel(diff_i(diff_i==ipair))>0 |
---|
1304 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1305 | if ~isempty(time) |
---|
1306 | if ref_i<=floor(ipair/2) |
---|
1307 | ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
1308 | end |
---|
1309 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
1310 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1311 | end |
---|
1312 | displ_pair=[displ_pair;{pair_string}]; |
---|
1313 | end |
---|
1314 | end |
---|
1315 | if ~isempty(displ_pair) |
---|
1316 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
1317 | end |
---|
1318 | elseif strcmp(mode,'series(Dj)') |
---|
1319 | if isempty(j2_series) |
---|
1320 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1321 | return |
---|
1322 | end |
---|
1323 | diff_j=j2_series-j1_series; |
---|
1324 | min_diff=min(diff_j(diff_j>0)); |
---|
1325 | max_diff=max(diff_j(diff_j>0)); |
---|
1326 | for ipair=min_diff:max_diff |
---|
1327 | if numel(diff_j(diff_j==ipair))>0 |
---|
1328 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1329 | if ~isempty(time) |
---|
1330 | if ref_j<=floor(ipair/2) |
---|
1331 | ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
1332 | end |
---|
1333 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
1334 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1335 | end |
---|
1336 | displ_pair=[displ_pair;{pair_string}]; |
---|
1337 | end |
---|
1338 | end |
---|
1339 | if ~isempty(displ_pair) |
---|
1340 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
1341 | end |
---|
1342 | elseif strcmp(mode,'bursts') |
---|
1343 | if isempty(j2_series) |
---|
1344 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1345 | return |
---|
1346 | end |
---|
1347 | diff_j=j2_series-j1_series; |
---|
1348 | min_j1=min(j1_series(j1_series>0)); |
---|
1349 | max_j1=max(j1_series(j1_series>0)); |
---|
1350 | min_j2=min(j2_series(j2_series>0)); |
---|
1351 | max_j2=max(j2_series(j2_series>0)); |
---|
1352 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
1353 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
1354 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
1355 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
1356 | end |
---|
1357 | end |
---|
1358 | end |
---|
1359 | if ~isempty(displ_pair) |
---|
1360 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
1361 | end |
---|
1362 | end |
---|
1363 | set(handles.num_ref_i,'String',num2str(ref_i)) % update ref_i and ref_j |
---|
1364 | set(handles.num_ref_j,'String',num2str(ref_j)) |
---|
1365 | |
---|
1366 | %% display list of pairstring |
---|
1367 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
1368 | NewVal=[]; |
---|
1369 | if ~isempty(displ_pair_list) |
---|
1370 | Val=get(handles.ListPairs,'Value'); |
---|
1371 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pï¿œir |
---|
1372 | end |
---|
1373 | if ~isempty(NewVal) |
---|
1374 | set(handles.ListPairs,'Value',NewVal) |
---|
1375 | else |
---|
1376 | set(handles.ListPairs,'Value',1) |
---|
1377 | end |
---|
1378 | set(handles.ListPairs,'String',displ_pair) |
---|
1379 | |
---|
1380 | %------------------------------------- |
---|
1381 | function enable_i(handles,state) |
---|
1382 | set(handles.i_txt,'Visible',state) |
---|
1383 | set(handles.num_first_i,'Visible',state) |
---|
1384 | set(handles.num_last_i,'Visible',state) |
---|
1385 | set(handles.num_incr_i,'Visible',state) |
---|
1386 | set(handles.num_ref_i,'Visible',state) |
---|
1387 | set(handles.ref_i_text,'Visible',state) |
---|
1388 | |
---|
1389 | %----------------------------------- |
---|
1390 | function enable_j(handles,state) |
---|
1391 | set(handles.j_txt,'Visible',state) |
---|
1392 | set(handles.num_first_j,'Visible',state) |
---|
1393 | set(handles.num_last_j,'Visible',state) |
---|
1394 | set(handles.num_incr_j,'Visible',state) |
---|
1395 | set(handles.num_ref_j,'Visible',state) |
---|
1396 | set(handles.ref_j_text,'Visible',state) |
---|
1397 | set(handles.MinIndex_j,'Visible',state) |
---|
1398 | set(handles.MaxIndex_j,'Visible',state) |
---|
1399 | |
---|
1400 | |
---|
1401 | %%%%%%%%%%%%%%%%%%%% |
---|
1402 | %% MAIN ActionName FUNCTIONS |
---|
1403 | %%%%%%%%%%%%%%%%%%%% |
---|
1404 | %------------------------------------------------------------------------ |
---|
1405 | % --- Executes on button press in RUN. |
---|
1406 | %------------------------------------------------------------------------ |
---|
1407 | function RUN_Callback(hObject, eventdata, handles) |
---|
1408 | |
---|
1409 | %% settings of the button RUN |
---|
1410 | set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel' |
---|
1411 | set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished |
---|
1412 | set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color |
---|
1413 | drawnow |
---|
1414 | set(handles.status,'Value',0)% desable status display if relevant |
---|
1415 | status_Callback(hObject, eventdata, handles) |
---|
1416 | |
---|
1417 | %% read the data on the GUI series |
---|
1418 | Param=read_GUI_series(handles);%displayed parameters |
---|
1419 | SeriesData=get(handles.series,'UserData');%hidden parameters |
---|
1420 | |
---|
1421 | %% create the output data directory if needed |
---|
1422 | if isfield(Param,'OutputSubDir') |
---|
1423 | SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt]; |
---|
1424 | SubDirOutNew=SubDirOut; |
---|
1425 | detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist |
---|
1426 | check_create=1; %need to create the result directory by default |
---|
1427 | while detect |
---|
1428 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); |
---|
1429 | if strcmp(answer,'Cancel') |
---|
1430 | errormsg='Cancel'; |
---|
1431 | return |
---|
1432 | elseif strcmp(answer,'Yes') |
---|
1433 | detect=0; |
---|
1434 | check_create=0; |
---|
1435 | else |
---|
1436 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
1437 | if isempty(r) |
---|
1438 | r(1).root=[SubDirOutNew '_']; |
---|
1439 | r(1).num1='0'; |
---|
1440 | end |
---|
1441 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
1442 | detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists |
---|
1443 | check_create=1; |
---|
1444 | end |
---|
1445 | end |
---|
1446 | Param.OutputDirExt=regexprep(SubDirOutNew,Param.OutputSubDir,''); |
---|
1447 | Param.OutputRootFile=Param.InputTable{1,3};% the first sorted RootFile taken for output |
---|
1448 | set(handles.OutputDirExt,'String',Param.OutputDirExt) |
---|
1449 | OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);% full name (with path) of output directory |
---|
1450 | if check_create % create output directory if it does not exist |
---|
1451 | [tild,msg1]=mkdir(OutputDir); |
---|
1452 | if ~strcmp(msg1,'') |
---|
1453 | msgbox_uvmat('ERROR',['cannot create ' OutputDir ': ' msg1]);%error message for directory creation |
---|
1454 | return |
---|
1455 | end |
---|
1456 | [success,msg] = fileattrib(OutputDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder |
---|
1457 | if success==0 |
---|
1458 | msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation |
---|
1459 | return |
---|
1460 | end |
---|
1461 | end |
---|
1462 | OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files |
---|
1463 | DirXml=fullfile(OutputDir,'0_XML'); |
---|
1464 | if ~exist(DirXml,'dir') |
---|
1465 | [tild,msg1]=mkdir(DirXml); |
---|
1466 | if ~strcmp(msg1,'') |
---|
1467 | msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation |
---|
1468 | return |
---|
1469 | end |
---|
1470 | [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder |
---|
1471 | if success==0 |
---|
1472 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg1});%error message for directory creation |
---|
1473 | return |
---|
1474 | end |
---|
1475 | end |
---|
1476 | end |
---|
1477 | |
---|
1478 | %% select the Action mode, 'local', 'background' or 'cluster' (if available) |
---|
1479 | RunMode='local';%default (needed for first opening of the GUI series) |
---|
1480 | if isfield(Param.Action,'RunMode') |
---|
1481 | RunMode=Param.Action.RunMode; |
---|
1482 | end |
---|
1483 | ActionExt='.m';%default |
---|
1484 | if isfield(Param.Action,'ActionExt') |
---|
1485 | ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled) |
---|
1486 | end |
---|
1487 | ActionName=Param.Action.ActionName; |
---|
1488 | ActionPath=Param.Action.ActionPath; |
---|
1489 | path_series=fileparts(which('series')); |
---|
1490 | |
---|
1491 | %% create the Action fct handle if RunMode option = 'local' |
---|
1492 | if strcmp(RunMode,'local') |
---|
1493 | if ~isequal(ActionPath,path_series) |
---|
1494 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION |
---|
1495 | if ~exist(ActionPath,'dir') |
---|
1496 | msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']); |
---|
1497 | return |
---|
1498 | end |
---|
1499 | if ~isequal(spath,ActionPath) |
---|
1500 | addpath(ActionPath)% add the prescribed path if not the current one |
---|
1501 | end |
---|
1502 | end |
---|
1503 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION |
---|
1504 | if ~isequal(ActionPath,path_series) |
---|
1505 | rmpath(ActionPath)% add the prescribed path if not the current one |
---|
1506 | end |
---|
1507 | end |
---|
1508 | |
---|
1509 | %% Get RunTime code from the file PARAM.xml (needed to run compiled functions) |
---|
1510 | errormsg='';%default error message |
---|
1511 | xmlfile=fullfile(path_series,'PARAM.xml'); |
---|
1512 | test_batch=0;%default: ,no batch mode available |
---|
1513 | if ~exist(xmlfile,'file') |
---|
1514 | [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile); |
---|
1515 | end |
---|
1516 | RunTime=''; |
---|
1517 | if strcmp(ActionExt,'.sh') |
---|
1518 | if exist(xmlfile,'file') |
---|
1519 | s=xml2struct(xmlfile); |
---|
1520 | if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam') |
---|
1521 | if isfield(s.BatchParam,'RunTime') |
---|
1522 | RunTime=s.BatchParam.RunTime; |
---|
1523 | end |
---|
1524 | if isfield(s.BatchParam,'NbCore') |
---|
1525 | NbCore=s.BatchParam.NbCore; |
---|
1526 | end |
---|
1527 | elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam') |
---|
1528 | if isfield(s.RunParam,'RunTime') |
---|
1529 | RunTime=s.RunParam.RunTime; |
---|
1530 | end |
---|
1531 | if isfield(s.RunParam,'NbCore') |
---|
1532 | NbCore=s.RunParam.NbCore; |
---|
1533 | end |
---|
1534 | end |
---|
1535 | end |
---|
1536 | if isempty(RunTime) && strcmp(RunMode,'cluster_oar') |
---|
1537 | msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster') |
---|
1538 | return |
---|
1539 | end |
---|
1540 | end |
---|
1541 | |
---|
1542 | %% set nbre of cluster cores and processes |
---|
1543 | switch RunMode |
---|
1544 | case {'local','background'} |
---|
1545 | NbCore=1;% no need to split the calculation |
---|
1546 | case 'cluster_oar' |
---|
1547 | if strcmp(Param.Action.ActionExt,'.m')% case of Matlab function (uncompiled) |
---|
1548 | NbCore=1;% one core used only (limitation of Matlab licences) |
---|
1549 | msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing'); |
---|
1550 | extra_oar=''; |
---|
1551 | else |
---|
1552 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); |
---|
1553 | NbCore=str2double(answer{1}); |
---|
1554 | extra_oar=answer{2}; |
---|
1555 | end |
---|
1556 | end |
---|
1557 | if ~isfield(Param.IndexRange,'NbSlice') |
---|
1558 | Param.IndexRange.NbSlice=[]; |
---|
1559 | end |
---|
1560 | if isempty(Param.IndexRange.NbSlice) |
---|
1561 | NbProcess=NbCore;% choose one process per core |
---|
1562 | else |
---|
1563 | NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices |
---|
1564 | NbCore=min(NbCore,NbProcess);% at least one process per core |
---|
1565 | end |
---|
1566 | |
---|
1567 | %% get the set of reference field indices |
---|
1568 | first_i=1; |
---|
1569 | last_i=1; |
---|
1570 | incr_i=1; |
---|
1571 | first_j=1; |
---|
1572 | last_j=1; |
---|
1573 | incr_j=1; |
---|
1574 | if isfield(Param.IndexRange,'first_i') |
---|
1575 | first_i=Param.IndexRange.first_i; |
---|
1576 | incr_i=Param.IndexRange.incr_i; |
---|
1577 | last_i=Param.IndexRange.last_i; |
---|
1578 | end |
---|
1579 | if isfield(Param.IndexRange,'first_j') |
---|
1580 | first_j=Param.IndexRange.first_j; |
---|
1581 | last_j=Param.IndexRange.last_j; |
---|
1582 | incr_j=Param.IndexRange.incr_j; |
---|
1583 | end |
---|
1584 | if last_i < first_i || last_j < first_j |
---|
1585 | msgbox_uvmat('ERROR', 'series/Run_Callback:last field index must be larger or equal to the first one') |
---|
1586 | set(handles.RUN, 'Enable','On'), |
---|
1587 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1588 | return |
---|
1589 | end |
---|
1590 | %incr_i must be defined, =1 by default, if NbSlice is active |
---|
1591 | if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice) |
---|
1592 | incr_i=1; |
---|
1593 | set(handles.num_incr_i,'String','1') |
---|
1594 | end |
---|
1595 | if isempty(incr_i) |
---|
1596 | if isempty(incr_j) |
---|
1597 | [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); |
---|
1598 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); |
---|
1599 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); |
---|
1600 | ref_j=ref_j-1; |
---|
1601 | ref_i=ref_i-1; |
---|
1602 | else |
---|
1603 | ref_j=first_j:incr_j:last_j; |
---|
1604 | [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); |
---|
1605 | ref_i=ref_i-1; |
---|
1606 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); |
---|
1607 | end |
---|
1608 | else |
---|
1609 | ref_i=first_i:incr_i:last_i; |
---|
1610 | if isempty(incr_j) |
---|
1611 | [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); |
---|
1612 | ref_j=ref_j-1; |
---|
1613 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); |
---|
1614 | else |
---|
1615 | ref_j=first_j:incr_j:last_j; |
---|
1616 | end |
---|
1617 | end |
---|
1618 | BlockLength=ceil(numel(ref_i)/NbProcess); |
---|
1619 | nbfield_j=numel(ref_j); |
---|
1620 | |
---|
1621 | %% record nbre of output files and starting time for computation for status |
---|
1622 | StatusData=get(handles.status,'UserData'); |
---|
1623 | if isfield(StatusData,'OutputFileMode') |
---|
1624 | switch StatusData.OutputFileMode |
---|
1625 | case 'NbInput' |
---|
1626 | StatusData.NbOutputFile=numel(ref_i)*nbfield_j; |
---|
1627 | case 'NbInput_i' |
---|
1628 | StatusData.NbOutputFile=numel(ref_i); |
---|
1629 | case 'NbSlice' |
---|
1630 | StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String')); |
---|
1631 | end |
---|
1632 | end |
---|
1633 | StatusData.TimeStart=now; |
---|
1634 | set(handles.status,'UserData',StatusData) |
---|
1635 | |
---|
1636 | %% direct processing on the current Matlab session |
---|
1637 | if strcmp (RunMode,'local') |
---|
1638 | for iprocess=1:NbProcess |
---|
1639 | if isempty(Param.IndexRange.NbSlice) |
---|
1640 | %Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; |
---|
1641 | Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength); |
---|
1642 | if Param.IndexRange.first_i>last_i |
---|
1643 | break |
---|
1644 | end |
---|
1645 | Param.IndexRange.last_i=min(ref_i(iprocess*BlockLength),last_i); |
---|
1646 | %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i); |
---|
1647 | else %multislices (then incr_i is not empty) |
---|
1648 | Param.IndexRange.first_i= first_i+incr_i*(iprocess-1); |
---|
1649 | Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; |
---|
1650 | end |
---|
1651 | if isfield(Param,'OutputSubDir') |
---|
1652 | t=struct2xml(Param); |
---|
1653 | t=set(t,1,'name','Series'); |
---|
1654 | filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... |
---|
1655 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1656 | save(t,filexml); |
---|
1657 | end |
---|
1658 | switch ActionExt |
---|
1659 | case '.m' |
---|
1660 | h_fun(Param); |
---|
1661 | case '.sh' |
---|
1662 | switch computer |
---|
1663 | case {'PCWIN','PCWIN64'} %Windows system |
---|
1664 | filexml=regexprep(filexml,'\\','\\\\');% add '\' so that '\' are left as characters |
---|
1665 | system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]);% TODO: adapt to DOS system |
---|
1666 | case {'GLNX86','GLNXA64','MACI64'}%Linux system |
---|
1667 | system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]); |
---|
1668 | end |
---|
1669 | end |
---|
1670 | end |
---|
1671 | elseif strcmp(get(handles.OutputDirExt,'Visible'),'off') |
---|
1672 | msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option |
---|
1673 | return |
---|
1674 | else |
---|
1675 | %% processing on a different session of the same computer (background) or cluster, create executable files |
---|
1676 | batch_file_list=cell(NbProcess,1);% initiate the list of executable files |
---|
1677 | DirBat=fullfile(OutputDir,'0_EXE'); |
---|
1678 | switch computer |
---|
1679 | case {'PCWIN','PCWIN64'} %Windows system |
---|
1680 | ExeExt='.bat'; |
---|
1681 | case {'GLNX86','GLNXA64','MACI64'}%Linux system |
---|
1682 | ExeExt='.sh'; |
---|
1683 | end |
---|
1684 | %create subdirectory for executable files |
---|
1685 | if ~exist(DirBat,'dir') |
---|
1686 | [tild,msg1]=mkdir(DirBat); |
---|
1687 | if ~strcmp(msg1,'') |
---|
1688 | msgbox_uvmat('ERROR',['cannot create ' DirBat ': ' msg1]);%error message for directory creation |
---|
1689 | return |
---|
1690 | end |
---|
1691 | end |
---|
1692 | %create subdirectory for log files |
---|
1693 | DirLog=fullfile(OutputDir,'0_LOG'); |
---|
1694 | if ~exist(DirLog,'dir') |
---|
1695 | [tild,msg1]=mkdir(DirLog); |
---|
1696 | if ~strcmp(msg1,'') |
---|
1697 | msgbox_uvmat('ERROR',['cannot create ' DirLog ': ' msg1]);%error message for directory creation |
---|
1698 | return |
---|
1699 | end |
---|
1700 | end |
---|
1701 | for iprocess=1:NbProcess |
---|
1702 | if isempty(Param.IndexRange.NbSlice)% process by blocks of i index |
---|
1703 | Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; |
---|
1704 | if Param.IndexRange.first_i>last_i |
---|
1705 | NbProcess=iprocess-1; |
---|
1706 | break% leave the loop, we are at the end of the calculation |
---|
1707 | end |
---|
1708 | Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1); |
---|
1709 | else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1 |
---|
1710 | Param.IndexRange.first_i= first_i+iprocess-1; |
---|
1711 | Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; |
---|
1712 | end |
---|
1713 | |
---|
1714 | % create, fill and save the xml parameter file |
---|
1715 | t=struct2xml(Param); |
---|
1716 | t=set(t,1,'name','Series'); |
---|
1717 | filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... |
---|
1718 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1719 | save(t,filexml);% save the parameter file |
---|
1720 | |
---|
1721 | %create the executable file |
---|
1722 | filebat=fullfile_uvmat(DirBat,'',Param.InputTable{1,3},ExeExt,OutputNomType,... |
---|
1723 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1724 | batch_file_list{iprocess}=filebat; |
---|
1725 | [fid,message]=fopen(filebat,'w');% create the executable file |
---|
1726 | if isequal(fid,-1) |
---|
1727 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); |
---|
1728 | return |
---|
1729 | end |
---|
1730 | |
---|
1731 | % set the log file name |
---|
1732 | filelog=fullfile_uvmat(DirLog,'',Param.InputTable{1,3},'.log',OutputNomType,... |
---|
1733 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); |
---|
1734 | |
---|
1735 | % fill and save the executable file |
---|
1736 | switch ActionExt |
---|
1737 | case '.m'% Matlab function |
---|
1738 | switch computer |
---|
1739 | case {'GLNX86','GLNXA64','MACI64'} |
---|
1740 | cmd=[... |
---|
1741 | '#!/bin/bash \n'... |
---|
1742 | '. /etc/sysprofile \n'... |
---|
1743 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... |
---|
1744 | 'addpath(''' path_series '''); \n'... |
---|
1745 | 'addpath(''' Param.Action.ActionPath '''); \n'... |
---|
1746 | '' Param.Action.ActionName '( ''' filexml '''); \n'... |
---|
1747 | 'exit \n'... |
---|
1748 | 'END_MATLAB \n']; |
---|
1749 | fprintf(fid,cmd);%fill the executable file with the char string cmd |
---|
1750 | fclose(fid);% close the executable file |
---|
1751 | system(['chmod +x ' filebat]);% set the file to executable |
---|
1752 | case {'PCWIN','PCWIN64'} |
---|
1753 | text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
1754 | ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... |
---|
1755 | 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'... |
---|
1756 | '' Param.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
1757 | fprintf(fid,text_matlabscript);%fill the executable file with the char string cmd |
---|
1758 | fclose(fid);% close the executable file |
---|
1759 | end |
---|
1760 | case '.sh' % compiled Matlab function |
---|
1761 | switch computer |
---|
1762 | case {'GLNX86','GLNXA64','MACI64'} |
---|
1763 | cmd=['#!/bin/bash \n '... |
---|
1764 | '#$ -cwd \n '... |
---|
1765 | 'hostname && date \n '... |
---|
1766 | 'umask 002 \n'... |
---|
1767 | fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml];%allow writting access to created files for user group |
---|
1768 | fprintf(fid,cmd);%fill the executable file with the char string cmd |
---|
1769 | fclose(fid);% close the executable file |
---|
1770 | system(['chmod +x ' filebat]);% set the file to executable |
---|
1771 | |
---|
1772 | case {'PCWIN','PCWIN64'} % TODO: adapt to Windows system |
---|
1773 | % cmd=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
1774 | % ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... |
---|
1775 | % 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'... |
---|
1776 | % '' Param.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
1777 | fprintf(fid,cmd); |
---|
1778 | fclose(fid); |
---|
1779 | % dos([filebat ' &']); |
---|
1780 | end |
---|
1781 | end |
---|
1782 | end |
---|
1783 | end |
---|
1784 | |
---|
1785 | %% launch the executable files for background or cluster processing |
---|
1786 | switch RunMode |
---|
1787 | case 'background' |
---|
1788 | for iprocess=1:NbProcess |
---|
1789 | system([batch_file_list{iprocess} ' &'])% directly execute the command file for each process |
---|
1790 | end |
---|
1791 | case 'cluster_oar' % option 'oar-parexec' used |
---|
1792 | %create subdirectory for oar command and log files |
---|
1793 | DirOAR=fullfile(OutputDir,'0_OAR'); |
---|
1794 | if exist(DirOAR,'dir')% delete the content of the dir 0_OAR to allow new input |
---|
1795 | curdir=pwd; |
---|
1796 | cd(DirOAR) |
---|
1797 | delete('*') |
---|
1798 | cd(curdir) |
---|
1799 | else |
---|
1800 | [tild,msg1]=mkdir(DirOAR); |
---|
1801 | if ~strcmp(msg1,'') |
---|
1802 | msgbox_uvmat('ERROR',['cannot create ' DirOAR ': ' msg1]);%error message for directory creation |
---|
1803 | return |
---|
1804 | end |
---|
1805 | end |
---|
1806 | max_walltime=3600*12; % 12h max total calculation |
---|
1807 | walltime_onejob=600;%seconds, max estimated time for asingle file index value |
---|
1808 | filename_joblist=fullfile(DirOAR,'job_list.txt');%create name of the global executable file |
---|
1809 | fid=fopen(filename_joblist,'w'); |
---|
1810 | for p=1:length(batch_file_list) |
---|
1811 | fprintf(fid,[batch_file_list{p} '\n']);% list of exe files |
---|
1812 | end |
---|
1813 | fclose(fid); |
---|
1814 | system(['chmod +x ' filename_joblist]);% set the file to executable |
---|
1815 | oar_command=['oarsub -n CIVX '... |
---|
1816 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... |
---|
1817 | '-l /core=' num2str(NbCore) ','... |
---|
1818 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '... |
---|
1819 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
1820 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
1821 | extra_oar ' '... |
---|
1822 | '"oar-parexec -s -f ' filename_joblist ' '... |
---|
1823 | '-l ' filename_joblist '.log"\n']; |
---|
1824 | filename_oarcommand=fullfile(DirOAR,'oar_command'); |
---|
1825 | fid=fopen(filename_oarcommand,'w'); |
---|
1826 | fprintf(fid,oar_command); |
---|
1827 | fclose(fid); |
---|
1828 | fprintf(oar_command);% display in command line |
---|
1829 | %system(['chmod +x ' oar_command]);% set the file to executable |
---|
1830 | system(oar_command); |
---|
1831 | end |
---|
1832 | |
---|
1833 | %% reset the GUI series |
---|
1834 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished |
---|
1835 | set(handles.RUN, 'Enable','On') |
---|
1836 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1837 | set(handles.RUN, 'Value',0) |
---|
1838 | |
---|
1839 | %------------------------------------------------------------------------ |
---|
1840 | function STOP_Callback(hObject, eventdata, handles) |
---|
1841 | %------------------------------------------------------------------------ |
---|
1842 | set(handles.RUN, 'BusyAction','cancel') |
---|
1843 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1844 | set(handles.RUN,'enable','on') |
---|
1845 | set(handles.RUN, 'Value',0) |
---|
1846 | |
---|
1847 | |
---|
1848 | %------------------------------------------------------------------------ |
---|
1849 | % --- read parameters from the GUI series |
---|
1850 | %------------------------------------------------------------------------ |
---|
1851 | function Param=read_GUI_series(handles) |
---|
1852 | |
---|
1853 | %% read raw parameters from the GUI series |
---|
1854 | Param=read_GUI(handles.series); |
---|
1855 | |
---|
1856 | %% clean the output structure by removing unused information |
---|
1857 | if isfield(Param,'Pairs') |
---|
1858 | Param=rmfield(Param,'Pairs'); %info Pairs not needed for output |
---|
1859 | end |
---|
1860 | Param.IndexRange=rmfield(Param.IndexRange,'TimeTable'); |
---|
1861 | empty_line=false(size(Param.InputTable,1),1); |
---|
1862 | for iline=1:size(Param.InputTable,1) |
---|
1863 | empty_line(iline)=isempty(cell2mat(Param.InputTable(iline,1:3))); |
---|
1864 | end |
---|
1865 | Param.InputTable(empty_line,:)=[]; |
---|
1866 | |
---|
1867 | %------------------------------------------------------------------------ |
---|
1868 | % --- Executes on selection change in ActionName. |
---|
1869 | function ActionName_Callback(hObject, eventdata, handles) |
---|
1870 | %------------------------------------------------------------------------ |
---|
1871 | |
---|
1872 | %% stop any ongoing series processing |
---|
1873 | if isequal(get(handles.RUN,'Value'),1) |
---|
1874 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); |
---|
1875 | if strcmp(answer,'Yes') |
---|
1876 | STOP_Callback(hObject, eventdata, handles) |
---|
1877 | else |
---|
1878 | return |
---|
1879 | end |
---|
1880 | end |
---|
1881 | set(handles.ActionName,'BackgroundColor',[1 1 0]) |
---|
1882 | huigetfile=findobj(allchild(0),'tag','status_display'); |
---|
1883 | if ~isempty(huigetfile) |
---|
1884 | delete(huigetfile) |
---|
1885 | end |
---|
1886 | drawnow |
---|
1887 | |
---|
1888 | %% get Action name and path |
---|
1889 | nb_builtin_ACTION=4; %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series) |
---|
1890 | ActionList=get(handles.ActionName,'String');% list menu fields |
---|
1891 | ActionIndex=get(handles.ActionName,'Value'); |
---|
1892 | if ~isequal(ActionIndex,1)% if we are not just opening series |
---|
1893 | InputTable=get(handles.InputTable,'Data'); |
---|
1894 | if isempty(InputTable{1,4}) |
---|
1895 | msgbox_uvmat('ERROR','no input file available: use Open in the menu bar') |
---|
1896 | return |
---|
1897 | end |
---|
1898 | end |
---|
1899 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name |
---|
1900 | ActionPathList=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ActionName |
---|
1901 | |
---|
1902 | %% add a new function to the menu if 'more...' has been selected in the menu ActionName |
---|
1903 | if isequal(ActionName,'more...') |
---|
1904 | [FileName, PathName] = uigetfile( ... |
---|
1905 | {'*.m', ' (*.m)'; |
---|
1906 | '*.m', '.m files '; ... |
---|
1907 | '*.*', 'All Files (*.*)'}, ... |
---|
1908 | 'Pick a series processing function ',get(handles.ActionPath,'String')); |
---|
1909 | if length(FileName)<2 |
---|
1910 | return |
---|
1911 | end |
---|
1912 | [ActionPath,ActionName,ActionExt]=fileparts(FileName); |
---|
1913 | |
---|
1914 | % insert the choice in the menu ActionName |
---|
1915 | ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action |
---|
1916 | if isempty(ActionIndex)%the input string does not exist in the menu |
---|
1917 | ActionIndex= length(ActionList); |
---|
1918 | ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)];% the selected function is appended in the menu, before the last item 'more...' |
---|
1919 | set(handles.ActionName,'String',ActionList) |
---|
1920 | end |
---|
1921 | |
---|
1922 | % record the file extension and extend the path list if it is a new extension |
---|
1923 | ActionExtList=get(handles.ActionExt,'String'); |
---|
1924 | ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1); |
---|
1925 | if isempty(ActionExtIndex) |
---|
1926 | set(handles.ActionExt,'String',[ActionExtList;{ActionExt}]) |
---|
1927 | ActionExtIndex=numel(ActionExtList)+1; |
---|
1928 | ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath |
---|
1929 | ActionPathList=[ActionPathList ActionPathNew]; |
---|
1930 | end |
---|
1931 | set(handles.ActionName,'UserData',ActionPathList); |
---|
1932 | |
---|
1933 | % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5) |
---|
1934 | if length(ActionList)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1935 | nbremove=length(ActionList)-nb_builtin_ACTION-5; |
---|
1936 | ActionList(nb_builtin_ACTION+1:end-5)=[]; |
---|
1937 | ActionPathList(nb_builtin_ACTION+1:end-4,:)=[]; |
---|
1938 | ActionIndex=ActionIndex-nbremove; |
---|
1939 | end |
---|
1940 | |
---|
1941 | % record action menu, choice and path |
---|
1942 | set(handles.ActionName,'Value',ActionIndex) |
---|
1943 | set(handles.ActionName,'String',ActionList) |
---|
1944 | set(handles.ActionExt,'Value',ActionExtIndex) |
---|
1945 | ActionPathList{ActionIndex,ActionExtIndex}=PathName; |
---|
1946 | |
---|
1947 | %record the user defined menu additions in personal file profil_perso |
---|
1948 | dir_perso=prefdir; |
---|
1949 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1950 | if nb_builtin_ACTION+1<=numel(ActionList)-1 |
---|
1951 | ActionListUser=ActionList(nb_builtin_ACTION+1:numel(ActionList)-1); |
---|
1952 | ActionPathListUser=ActionPathList(nb_builtin_ACTION+1:numel(ActionList)-1,:); |
---|
1953 | ActionExtListUser={}; |
---|
1954 | if numel(ActionExtList)>2 |
---|
1955 | ActionExtListUser=ActionExtList(3:end); |
---|
1956 | end |
---|
1957 | if exist(profil_perso,'file') |
---|
1958 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append') |
---|
1959 | else |
---|
1960 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6') |
---|
1961 | end |
---|
1962 | end |
---|
1963 | end |
---|
1964 | |
---|
1965 | %% check the current ActionPath to the selected function |
---|
1966 | ActionPath=ActionPathList{ActionIndex};%current recorded path |
---|
1967 | set(handles.ActionPath,'String',ActionPath); %show the path to the senlected function |
---|
1968 | |
---|
1969 | %% reinitialise the waitbar |
---|
1970 | update_waitbar(handles.Waitbar,0) |
---|
1971 | |
---|
1972 | %% create the function handle for Action |
---|
1973 | path_series=which('series'); |
---|
1974 | if ~isequal(ActionPath,path_series) |
---|
1975 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION |
---|
1976 | if ~exist(ActionPath,'dir') |
---|
1977 | errormsg=['The prescribed function path ' ActionPath ' does not exist']; |
---|
1978 | return |
---|
1979 | end |
---|
1980 | if ~isequal(spath,ActionPath) |
---|
1981 | addpath(ActionPath)% add the prescribed path if not the current one |
---|
1982 | end |
---|
1983 | end |
---|
1984 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION |
---|
1985 | if ~isequal(ActionPath,path_series) |
---|
1986 | rmpath(ActionPath)% add the prescribed path if not the current one |
---|
1987 | end |
---|
1988 | |
---|
1989 | %% Activate the Action fct |
---|
1990 | Param=read_GUI_series(handles);% read the parameters from the GUI series |
---|
1991 | ParamOut=h_fun(Param);%run the selected Action function to get the relevant input |
---|
1992 | |
---|
1993 | %% Put the first line of the selected Action fct as tooltip help |
---|
1994 | try |
---|
1995 | [fid,errormsg] =fopen([ActionName '.m']); |
---|
1996 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
1997 | fclose(fid); |
---|
1998 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help |
---|
1999 | end |
---|
2000 | |
---|
2001 | %% Detect the types of input files |
---|
2002 | SeriesData=get(handles.series,'UserData'); |
---|
2003 | iview_civ=[];nb_netcdf=0; |
---|
2004 | if ~isempty(SeriesData)&&isfield(SeriesData,'FileType') |
---|
2005 | iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); |
---|
2006 | nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType))); |
---|
2007 | end |
---|
2008 | if numel(iview_civ)>=1 |
---|
2009 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(1)}.CivStage,SeriesData.FileType{iview_civ(1)}); |
---|
2010 | set(handles.VelType,'String',[{'*'};menu]) |
---|
2011 | if numel(iview_civ)>=2 |
---|
2012 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)}); |
---|
2013 | set(handles.VelType_1,'String',[{'*'};menu]) |
---|
2014 | end |
---|
2015 | end |
---|
2016 | |
---|
2017 | %% Check whether alphabetical sorting of input Subdir is allowed by the Action fct (for multiples series entries) |
---|
2018 | if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1 |
---|
2019 | [tild,iview]=sort(InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
2020 | set(handles.InputTable,'Data',InputTable(iview,:)); |
---|
2021 | MinIndex_i=get(handles.MinIndex_i,'Data'); |
---|
2022 | MinIndex_j=get(handles.MinIndex_j,'Data'); |
---|
2023 | MaxIndex_i=get(handles.MaxIndex_i,'Data'); |
---|
2024 | MaxIndex_j=get(handles.MaxIndex_j,'Data'); |
---|
2025 | set(handles.MinIndex_i,'Data',MinIndex_i(iview,:)); |
---|
2026 | set(handles.MinIndex_j,'Data',MinIndex_j(iview,:)); |
---|
2027 | set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:)); |
---|
2028 | set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:)); |
---|
2029 | TimeTable=get(handles.TimeTable,'Data'); |
---|
2030 | set(handles.TimeTable,'Data',TimeTable(iview,:)); |
---|
2031 | PairString=get(handles.PairString,'Data'); |
---|
2032 | set(handles.PairString,'Data',PairString(iview,:)); |
---|
2033 | end |
---|
2034 | |
---|
2035 | %% Impose the whole input file index range if requested |
---|
2036 | if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on') |
---|
2037 | MinIndex_i=get(handles.MinIndex_i,'Data'); |
---|
2038 | MinIndex_j=get(handles.MinIndex_j,'Data'); |
---|
2039 | MaxIndex_i=get(handles.MaxIndex_i,'Data'); |
---|
2040 | MaxIndex_j=get(handles.MaxIndex_j,'Data'); |
---|
2041 | set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line) |
---|
2042 | set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line) |
---|
2043 | set(handles.num_incr_i,'String','1') |
---|
2044 | set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line) |
---|
2045 | set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line) |
---|
2046 | set(handles.num_incr_j,'String','1') |
---|
2047 | else % check index ranges |
---|
2048 | first_i=1;last_i=1;first_j=1;last_j=1; |
---|
2049 | if isfield(Param.IndexRange,'first_i') |
---|
2050 | first_i=Param.IndexRange.first_i; |
---|
2051 | % incr_i=Param.IndexRange.incr_i; |
---|
2052 | last_i=Param.IndexRange.last_i; |
---|
2053 | end |
---|
2054 | if isfield(Param.IndexRange,'first_j') |
---|
2055 | first_j=Param.IndexRange.first_j; |
---|
2056 | % incr_j=Param.IndexRange.incr_j; |
---|
2057 | last_j=Param.IndexRange.last_j; |
---|
2058 | end |
---|
2059 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
2060 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
2061 | end |
---|
2062 | |
---|
2063 | %% desable j index if if set by the civ_input GUI |
---|
2064 | if isfield(ParamOut,'Desable_j_index')&&isequal(ParamOut.Desable_j_index,'on') |
---|
2065 | set(handles.num_first_j,'Enable','off') |
---|
2066 | set(handles.num_last_j,'Enable','off') |
---|
2067 | set(handles.num_incr_j,'Enable','off') |
---|
2068 | set(handles.num_incr_j,'String','') |
---|
2069 | else |
---|
2070 | set(handles.num_first_j,'Enable','on') |
---|
2071 | set(handles.num_last_j,'Enable','on') |
---|
2072 | set(handles.num_incr_j,'Enable','on') |
---|
2073 | end |
---|
2074 | |
---|
2075 | %% NbSlice visibility |
---|
2076 | NbSliceVisible='off';%default |
---|
2077 | if isfield(ParamOut,'NbSlice') && isequal(ParamOut.NbSlice,'on') |
---|
2078 | NbSliceVisible='on'; |
---|
2079 | set(handles.num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices |
---|
2080 | else |
---|
2081 | set(handles.num_NbProcess,'String','')% free nbre of processes |
---|
2082 | end |
---|
2083 | set(handles.num_NbSlice,'Visible',NbSliceVisible) |
---|
2084 | set(handles.NbSlice_title,'Visible',NbSliceVisible) |
---|
2085 | |
---|
2086 | %% Visibility of VelType and VelType_1 menus |
---|
2087 | VelTypeVisible='off'; %hidden by default |
---|
2088 | VelType_1Visible='off'; |
---|
2089 | InputFieldsVisible='off';%visibility of the frame Fields |
---|
2090 | if isfield(ParamOut,'VelType') |
---|
2091 | if strcmp( ParamOut.VelType,'on')||strcmp(ParamOut.VelType,'one')||strcmp( ParamOut.VelType,'two') |
---|
2092 | if numel(iview_civ)>=1 |
---|
2093 | VelTypeVisible='on'; |
---|
2094 | InputFieldsVisible='on'; |
---|
2095 | end |
---|
2096 | end |
---|
2097 | if strcmp( ParamOut.VelType,'two') |
---|
2098 | if numel(iview_civ)>=2 |
---|
2099 | VelType_1Visible='on'; |
---|
2100 | end |
---|
2101 | end |
---|
2102 | end |
---|
2103 | set(handles.VelType,'Visible',VelTypeVisible) |
---|
2104 | set(handles.VelType_text,'Visible',VelTypeVisible); |
---|
2105 | set(handles.VelType_1,'Visible',VelType_1Visible) |
---|
2106 | set(handles.VelType_text_1,'Visible',VelType_1Visible); |
---|
2107 | |
---|
2108 | %% Visibility of FieldName and FieldName_1 menus |
---|
2109 | FieldNameVisible='off'; %hidden by default |
---|
2110 | FieldName_1Visible='off'; %hidden by default |
---|
2111 | if isfield(ParamOut,'FieldName') |
---|
2112 | if strcmp( ParamOut.FieldName,'on') || strcmp(ParamOut.FieldName,'one')||strcmp( ParamOut.FieldName,'two') |
---|
2113 | if (numel(iview_civ)+nb_netcdf)>=1 |
---|
2114 | InputFieldsVisible='on'; |
---|
2115 | FieldNameVisible='on'; |
---|
2116 | end |
---|
2117 | end |
---|
2118 | if strcmp( ParamOut.FieldName,'two') |
---|
2119 | if (numel(iview_civ)+nb_netcdf)>=1 |
---|
2120 | FieldName_1Visible='on'; |
---|
2121 | end |
---|
2122 | end |
---|
2123 | end |
---|
2124 | set(handles.InputFields,'Visible',InputFieldsVisible) |
---|
2125 | set(handles.FieldName,'Visible',FieldNameVisible) % test for MenuBorser |
---|
2126 | set(handles.FieldName_1,'Visible',FieldName_1Visible) |
---|
2127 | |
---|
2128 | %% Visibility of FieldTransform menu |
---|
2129 | FieldTransformVisible='off'; %hidden by default |
---|
2130 | if isfield(ParamOut,'FieldTransform') |
---|
2131 | FieldTransformVisible=ParamOut.FieldTransform; |
---|
2132 | TransformName_Callback([],[], handles) |
---|
2133 | end |
---|
2134 | set(handles.FieldTransform,'Visible',FieldTransformVisible) |
---|
2135 | if isfield(ParamOut,'TransformPath') |
---|
2136 | set(handles.ActionExt,'UserData',ParamOut.TransformPath) |
---|
2137 | else |
---|
2138 | set(handles.ActionExt,'UserData',[]) |
---|
2139 | end |
---|
2140 | |
---|
2141 | %% Visibility of projection object |
---|
2142 | ProjObjectVisible='off'; %hidden by default |
---|
2143 | if isfield(ParamOut,'ProjObject') |
---|
2144 | ProjObjectVisible=ParamOut.ProjObject; |
---|
2145 | end |
---|
2146 | set(handles.CheckObject,'Visible',ProjObjectVisible) |
---|
2147 | if ~get(handles.CheckObject,'Value') |
---|
2148 | ProjObjectVisible='off'; |
---|
2149 | end |
---|
2150 | set(handles.ProjObject,'Visible',ProjObjectVisible) |
---|
2151 | set(handles.DeleteObject,'Visible',ProjObjectVisible) |
---|
2152 | set(handles.ViewObject,'Visible',ProjObjectVisible) |
---|
2153 | set(handles.EditObject,'Visible',ProjObjectVisible) |
---|
2154 | |
---|
2155 | %% Visibility of mask input |
---|
2156 | MaskVisible='off'; %hidden by default |
---|
2157 | if isfield(ParamOut,'Mask') |
---|
2158 | MaskVisible=ParamOut.Mask; |
---|
2159 | end |
---|
2160 | %set(handles.Mask,'Visible',MaskVisible) |
---|
2161 | set(handles.CheckMask,'Visible',MaskVisible); |
---|
2162 | |
---|
2163 | %% definition of the directory containing the output files |
---|
2164 | OutputDirVisible='off'; |
---|
2165 | if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt) |
---|
2166 | OutputSubDirMode='all';%default |
---|
2167 | if isfield(ParamOut,'OutputSubDirMode') |
---|
2168 | OutputSubDirMode=ParamOut.OutputSubDirMode; |
---|
2169 | end |
---|
2170 | set(handles.OutputDirExt,'String',ParamOut.OutputDirExt) |
---|
2171 | OutputDirVisible='on'; |
---|
2172 | SubDir=InputTable(1:end,2); %set of subdirectories sorted in alphabetical order |
---|
2173 | if strcmp(OutputSubDirMode,'last') |
---|
2174 | SubDirOut=SubDir{end}; |
---|
2175 | else |
---|
2176 | SubDirOut=SubDir{1}; |
---|
2177 | if ~strcmp(OutputSubDirMode,'first') && numel(SubDir)>1 |
---|
2178 | for ilist=2:numel(SubDir) |
---|
2179 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
2180 | end |
---|
2181 | end |
---|
2182 | end |
---|
2183 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
2184 | end |
---|
2185 | set(handles.OutputDirExt,'Visible',OutputDirVisible) |
---|
2186 | set(handles.OutputSubDir,'Visible',OutputDirVisible) |
---|
2187 | set(handles.OutputDir_title,'Visible',OutputDirVisible) |
---|
2188 | set(handles.RunMode,'Visible',OutputDirVisible) |
---|
2189 | set(handles.ActionExt,'Visible',OutputDirVisible) |
---|
2190 | set(handles.RunMode_title,'Visible',OutputDirVisible) |
---|
2191 | set(handles.ActionExt_title,'Visible',OutputDirVisible) |
---|
2192 | |
---|
2193 | |
---|
2194 | %% Expected nbre of output files |
---|
2195 | if isfield(ParamOut,'OutputFileMode') |
---|
2196 | StatusData.OutputFileMode=ParamOut.OutputFileMode; |
---|
2197 | set(handles.status,'UserData',StatusData) |
---|
2198 | end |
---|
2199 | |
---|
2200 | %% definition of an additional parameter set, determined by an ancillary GUI |
---|
2201 | if isfield(ParamOut,'ActionInput') |
---|
2202 | % set(handles.ActionInput,'Visible','on') |
---|
2203 | % set(handles.ActionInput_title,'Visible','on') |
---|
2204 | set(handles.ActionInput,'Visible','on') |
---|
2205 | % set(handles.ActionInput,'Value',0) |
---|
2206 | % set(handles.ActionInput,'String',ActionName) |
---|
2207 | ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput |
---|
2208 | SeriesData.ActionInput=ParamOut.ActionInput; |
---|
2209 | else |
---|
2210 | % set(handles.ActionInput,'Visible','off') |
---|
2211 | % set(handles.ActionInput_title,'Visible','off') |
---|
2212 | set(handles.ActionInput,'Visible','off') |
---|
2213 | if isfield(SeriesData,'ActionInput') |
---|
2214 | SeriesData=rmfield(SeriesData,'ActionInput'); |
---|
2215 | end |
---|
2216 | end |
---|
2217 | set(handles.series,'UserData',SeriesData) |
---|
2218 | set(handles.ActionName,'BackgroundColor',[1 1 1]) |
---|
2219 | |
---|
2220 | %------------------------------------------------------------------------ |
---|
2221 | % --- Executes on button press in ActionInput. |
---|
2222 | function ActionInput_Callback(hObject, eventdata, handles) |
---|
2223 | %------------------------------------------------------------------------ |
---|
2224 | % if get(handles.ActionInput,'Value') |
---|
2225 | ActionName_Callback(hObject, eventdata, handles) |
---|
2226 | % end |
---|
2227 | |
---|
2228 | %------------------------------------------------------------------------ |
---|
2229 | % --- Executes on selection change in FieldName. |
---|
2230 | function FieldName_Callback(hObject, eventdata, handles) |
---|
2231 | %------------------------------------------------------------------------ |
---|
2232 | field_str=get(handles.FieldName,'String'); |
---|
2233 | field_index=get(handles.FieldName,'Value'); |
---|
2234 | field=field_str{field_index(1)}; |
---|
2235 | if isequal(field,'get_field...') |
---|
2236 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
2237 | if ~isempty(hget_field) |
---|
2238 | delete(hget_field)%delete opened versions of get_field |
---|
2239 | end |
---|
2240 | Param=read_GUI(handles.series); |
---|
2241 | Param.InputTable=Param.InputTable(1,:); |
---|
2242 | filecell=get_file_series(Param); |
---|
2243 | |
---|
2244 | if exist(filecell{1,1},'file') |
---|
2245 | GetFieldData=get_field(filecell{1,1}); |
---|
2246 | FieldList={}; |
---|
2247 | switch GetFieldData.FieldOption |
---|
2248 | case 'vectors' |
---|
2249 | UName=GetFieldData.PanelVectors.vector_x; |
---|
2250 | VName=GetFieldData.PanelVectors.vector_y; |
---|
2251 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
2252 | CName=GetFieldData.PanelVectors.vec_color; |
---|
2253 | FieldList={['vec(' UName ',' VName ')'];... |
---|
2254 | ['norm(' UName ',' VName ')'];... |
---|
2255 | UName;VName}; |
---|
2256 | VecColorList={['norm(' UName ',' VName ')'];... |
---|
2257 | UName;VName}; |
---|
2258 | if ~isempty(CName) |
---|
2259 | VecColorList=[{CName};VecColorList]; |
---|
2260 | end |
---|
2261 | case 'scalar' |
---|
2262 | AName=GetFieldData.PanelScalar.scalar; |
---|
2263 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
2264 | FieldList={AName}; |
---|
2265 | case '1D plot' |
---|
2266 | YName=GetFieldData.PanelOrdinate.ordinate; |
---|
2267 | % case 'civdata...'%reinitiate input, return to automatic civ data reading |
---|
2268 | % display_file_name(handles,FileName,1) |
---|
2269 | end |
---|
2270 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
2271 | XName=GetFieldData.Coordinates.Coord_x; |
---|
2272 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
2273 | switch TimeNameStr |
---|
2274 | case 'file index' |
---|
2275 | set(handles.TimeName,'String',''); |
---|
2276 | case 'attribute' |
---|
2277 | set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]); |
---|
2278 | case 'variable' |
---|
2279 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) |
---|
2280 | set(handles.NomType,'String','*') |
---|
2281 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!! |
---|
2282 | set(handles.FileIndex,'String','') |
---|
2283 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
2284 | case 'matrix_index' |
---|
2285 | set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]); |
---|
2286 | set(handles.NomType,'String','*') |
---|
2287 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
2288 | set(handles.FileIndex,'String','') |
---|
2289 | ParamIn.TimeDimName=GetFieldData.Time.TimeName; |
---|
2290 | end |
---|
2291 | set(handles.Coord_x,'String',{XName}) |
---|
2292 | set(handles.Coord_y,'String',YName) |
---|
2293 | set(handles.FieldName,'Value',1) |
---|
2294 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
2295 | end |
---|
2296 | end |
---|
2297 | end |
---|
2298 | |
---|
2299 | %------------------------------------------------------------------------ |
---|
2300 | % --- Executes on selection change in FieldName_1. |
---|
2301 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
2302 | %------------------------------------------------------------------------ |
---|
2303 | field_str=get(handles.FieldName_1,'String'); |
---|
2304 | field_index=get(handles.FieldName_1,'Value'); |
---|
2305 | field=field_str{field_index}; |
---|
2306 | if isequal(field,'get_field...') |
---|
2307 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
2308 | if ~isempty(hget_field) |
---|
2309 | delete(hget_field) |
---|
2310 | end |
---|
2311 | SeriesData=get(handles.series,'UserData'); |
---|
2312 | filename=SeriesData.CurrentInputFile_1; |
---|
2313 | if exist(filename,'file') |
---|
2314 | hget_field=get_field(filename); |
---|
2315 | set(hget_field,'name','get_field_1') |
---|
2316 | end |
---|
2317 | % elseif isequal(field,'more...') |
---|
2318 | % str=calc_field; |
---|
2319 | % [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
2320 | % 'SelectionMode','single',... |
---|
2321 | % 'ListString',str); |
---|
2322 | % % edit the choice in the fields and actionname menu |
---|
2323 | % scalar=cell2mat(str(ind_answer)); |
---|
2324 | % update_menu(handles.FieldName_1,scalar) |
---|
2325 | end |
---|
2326 | |
---|
2327 | |
---|
2328 | %%%%%%%%%%%%% |
---|
2329 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
2330 | indsel=ind_i; |
---|
2331 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
2332 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
2333 | if ~isempty(indiff) |
---|
2334 | indiff2=diff(indiff); |
---|
2335 | indiffp=[indiff2 1]; |
---|
2336 | indiffm=[1 indiff2]; |
---|
2337 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
2338 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
2339 | %for each multiplet, select the most recent file |
---|
2340 | ind_remove=[]; |
---|
2341 | for i=1:length(ind_multi_m) |
---|
2342 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
2343 | for imulti=1:length(ind_pairs) |
---|
2344 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
2345 | end |
---|
2346 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
2347 | ind_s=indsort2(1:end-1);% |
---|
2348 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
2349 | end |
---|
2350 | end |
---|
2351 | |
---|
2352 | %------------------------------------------------------------------------ |
---|
2353 | % --- determine the list of index pairstring of processing file |
---|
2354 | 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) |
---|
2355 | %------------------------------------------------------------------------ |
---|
2356 | num_i1=num_i;% set of first image numbers by default |
---|
2357 | num_i2=num_i; |
---|
2358 | num_j1=num_j; |
---|
2359 | num_j2=num_j; |
---|
2360 | num_i_out=num_i; |
---|
2361 | num_j_out=num_j; |
---|
2362 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
2363 | if isequal(mode,'series(Di)') |
---|
2364 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
2365 | num_i2_line=num_i+ind_shift(4); |
---|
2366 | % adjust the first and last field number |
---|
2367 | indsel=find(num_i1_line >= 1); |
---|
2368 | num_i_out=num_i(indsel); |
---|
2369 | num_i1_line=num_i1_line(indsel); |
---|
2370 | num_i2_line=num_i2_line(indsel); |
---|
2371 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
2372 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
2373 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
2374 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
2375 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
2376 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
2377 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
2378 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
2379 | else |
---|
2380 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
2381 | num_j2_col=num_j+ind_shift(2); |
---|
2382 | % adjust the first field number |
---|
2383 | indsel=find((num_j1_col >= 1)); |
---|
2384 | num_j_out=num_j(indsel); |
---|
2385 | num_j1_col=num_j1_col(indsel); |
---|
2386 | num_j2_col=num_j2_col(indsel); |
---|
2387 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
2388 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
2389 | end |
---|
2390 | end |
---|
2391 | |
---|
2392 | %------------------------------------------------------------------------ |
---|
2393 | % --- Executes on button press in CheckObject. |
---|
2394 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
2395 | %------------------------------------------------------------------------ |
---|
2396 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
2397 | if get(handles.CheckObject,'Value') |
---|
2398 | SeriesData=get(handles.series,'UserData'); |
---|
2399 | if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject) |
---|
2400 | set(handles.ViewObject,'Value',1) |
---|
2401 | ViewObject_Callback(hObject, eventdata, handles) |
---|
2402 | else |
---|
2403 | if ishandle(hset_object) |
---|
2404 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
2405 | else |
---|
2406 | %get the object file |
---|
2407 | InputTable=get(handles.InputTable,'Data'); |
---|
2408 | defaultname=InputTable{1,1}; |
---|
2409 | if isempty(defaultname) |
---|
2410 | defaultname={''}; |
---|
2411 | end |
---|
2412 | fileinput=uigetfile_uvmat('pick a xml object file (or use uvmat to create it)',defaultname,'.xml'); |
---|
2413 | if isempty(fileinput)% exit if no object file is selected |
---|
2414 | set(handles.CheckObject,'Value',0) |
---|
2415 | return |
---|
2416 | end |
---|
2417 | %read the file |
---|
2418 | data=xml2struct(fileinput); |
---|
2419 | if ~isfield(data,'Type') |
---|
2420 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
2421 | set(handles.CheckObject,'Value',0) |
---|
2422 | return |
---|
2423 | end |
---|
2424 | if ~isfield(data,'ProjMode') |
---|
2425 | data.ProjMode='none'; |
---|
2426 | end |
---|
2427 | hset_object=set_object(data);% call the set_object interface |
---|
2428 | end |
---|
2429 | ProjObject=read_GUI(hset_object); |
---|
2430 | set(handles.ProjObject,'String',ProjObject.Name);%display the object name |
---|
2431 | SeriesData=get(handles.series,'UserData'); |
---|
2432 | SeriesData.ProjObject=ProjObject; |
---|
2433 | set(handles.series,'UserData',SeriesData); |
---|
2434 | end |
---|
2435 | set(handles.EditObject,'Visible','on'); |
---|
2436 | set(handles.DeleteObject,'Visible','on'); |
---|
2437 | set(handles.ViewObject,'Visible','on'); |
---|
2438 | set(handles.ProjObject,'Visible','on'); |
---|
2439 | else |
---|
2440 | set(handles.EditObject,'Visible','off'); |
---|
2441 | set(handles.DeleteObject,'Visible','off'); |
---|
2442 | set(handles.ViewObject,'Visible','off'); |
---|
2443 | if ~ishandle(hset_object) |
---|
2444 | set(handles.ViewObject,'Value',0); |
---|
2445 | end |
---|
2446 | set(handles.ProjObject,'Visible','off'); |
---|
2447 | end |
---|
2448 | |
---|
2449 | %------------------------------------------------------------------------ |
---|
2450 | % --- Executes on button press in ViewObject. |
---|
2451 | %------------------------------------------------------------------------ |
---|
2452 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
2453 | |
---|
2454 | UserData=get(handles.series,'UserData'); |
---|
2455 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
2456 | if ~isempty(hset_object) |
---|
2457 | delete(hset_object)% refresh set_object if already opened |
---|
2458 | end |
---|
2459 | hset_object=set_object(UserData.ProjObject); |
---|
2460 | set(hset_object,'Name','view_object_series') |
---|
2461 | |
---|
2462 | |
---|
2463 | %------------------------------------------------------------------------ |
---|
2464 | % --- Executes on button press in EditObject. |
---|
2465 | function EditObject_Callback(hObject, eventdata, handles) |
---|
2466 | %------------------------------------------------------------------------ |
---|
2467 | if get(handles.EditObject,'Value') |
---|
2468 | set(handles.ViewObject,'Value',0) |
---|
2469 | UserData=get(handles.series,'UserData'); |
---|
2470 | hset_object=set_object(UserData.ProjObject); |
---|
2471 | set(hset_object,'Name','edit_object_series') |
---|
2472 | set(get(hset_object,'Children'),'Enable','on') |
---|
2473 | else |
---|
2474 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
2475 | if ~isempty(hset_object) |
---|
2476 | set(get(hset_object,'Children'),'Enable','off') |
---|
2477 | end |
---|
2478 | end |
---|
2479 | |
---|
2480 | %------------------------------------------------------------------------ |
---|
2481 | % --- Executes on button press in DeleteObject. |
---|
2482 | function DeleteObject_Callback(hObject, eventdata, handles) |
---|
2483 | %------------------------------------------------------------------------ |
---|
2484 | SeriesData=get(handles.series,'UserData'); |
---|
2485 | SeriesData.ProjObject=[]; |
---|
2486 | set(handles.series,'UserData',SeriesData) |
---|
2487 | set(handles.ProjObject,'String','') |
---|
2488 | set(handles.ProjObject,'Visible','off') |
---|
2489 | set(handles.CheckObject,'Value',0) |
---|
2490 | set(handles.ViewObject,'Visible','off') |
---|
2491 | set(handles.EditObject,'Visible','off') |
---|
2492 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
2493 | if ~isempty(hset_object) |
---|
2494 | delete(hset_object) |
---|
2495 | end |
---|
2496 | set(handles.DeleteObject,'Visible','off') |
---|
2497 | |
---|
2498 | %------------------------------------------------------------------------ |
---|
2499 | % --- Executed when CheckMask is activated |
---|
2500 | %------------------------------------------------------------------------ |
---|
2501 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
2502 | |
---|
2503 | if get(handles.CheckMask,'Value') |
---|
2504 | InputTable=get(handles.InputTable,'Data'); |
---|
2505 | nbview=size(InputTable,1); |
---|
2506 | MaskTable=cell(nbview,1);%default |
---|
2507 | ListMask=cell(nbview,1);%default |
---|
2508 | MaskData=get(handles.MaskTable,'Data'); |
---|
2509 | MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1);%complement if undefined lines |
---|
2510 | for iview=1:nbview |
---|
2511 | ListMask{iview,1}=num2str(iview); |
---|
2512 | RootPath=InputTable{iview,1}; |
---|
2513 | if ~isempty(RootPath) |
---|
2514 | if isempty(MaskData{iview}) |
---|
2515 | SubDir=InputTable{iview,2}; |
---|
2516 | MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']);%take the root part of SubDir, before the first dot '.' |
---|
2517 | if exist(MaskPath,'dir') |
---|
2518 | ListStruct=dir(MaskPath);%look for a mask file |
---|
2519 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
2520 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
2521 | ListFiles=ListCells(1,:);%list of file and dri names |
---|
2522 | ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) |
---|
2523 | mdetect=0; |
---|
2524 | if ~isempty(ListFiles) |
---|
2525 | for ifile=1:numel(ListFiles) |
---|
2526 | [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0); |
---|
2527 | if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) |
---|
2528 | mdetect=1; |
---|
2529 | MaskName=ListFiles{ifile}; |
---|
2530 | end |
---|
2531 | if ~strcmp(MaskFile{ifile},MaskFile{1}) |
---|
2532 | mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection |
---|
2533 | break |
---|
2534 | end |
---|
2535 | end |
---|
2536 | end |
---|
2537 | if mdetect==1 |
---|
2538 | MaskName=fullfile(MaskPath,'mask_1.png'); |
---|
2539 | else |
---|
2540 | MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image'); |
---|
2541 | end |
---|
2542 | else |
---|
2543 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image'); |
---|
2544 | end |
---|
2545 | MaskTable{iview,1}=MaskName ; |
---|
2546 | ListMask{iview,1}=num2str(iview); |
---|
2547 | end |
---|
2548 | end |
---|
2549 | end |
---|
2550 | set(handles.MaskTable,'Data',MaskTable) |
---|
2551 | set(handles.MaskTable,'Visible','on') |
---|
2552 | set(handles.MaskBrowse,'Visible','on') |
---|
2553 | set(handles.ListMask,'Visible','on') |
---|
2554 | set(handles.ListMask,'String',ListMask) |
---|
2555 | set(handles.ListMask,'Value',1) |
---|
2556 | else |
---|
2557 | set(handles.MaskTable,'Visible','off') |
---|
2558 | set(handles.MaskBrowse,'Visible','off') |
---|
2559 | set(handles.ListMask,'Visible','off') |
---|
2560 | end |
---|
2561 | |
---|
2562 | %------------------------------------------------------------------------ |
---|
2563 | % --- Executes on button press in MaskBrowse. |
---|
2564 | %------------------------------------------------------------------------ |
---|
2565 | function MaskBrowse_Callback(hObject, eventdata, handles) |
---|
2566 | |
---|
2567 | InputTable=get(handles.InputTable,'Data'); |
---|
2568 | iview=get(handles.ListMask,'Value'); |
---|
2569 | RootPath=InputTable{iview,1}; |
---|
2570 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image'); |
---|
2571 | if ~isempty(MaskName) |
---|
2572 | MaskTable=get(handles.MaskTable,'Data'); |
---|
2573 | MaskTable{iview,1}=MaskName ; |
---|
2574 | set(handles.MaskTable,'Data',MaskTable) |
---|
2575 | end |
---|
2576 | |
---|
2577 | %------------------------------------------------------------------------ |
---|
2578 | % --- Executes when selected cell(s) is changed in MaskTable. |
---|
2579 | %------------------------------------------------------------------------ |
---|
2580 | function MaskTable_CellSelectionCallback(hObject, eventdata, handles) |
---|
2581 | |
---|
2582 | if numel(eventdata.Indices)>=1 |
---|
2583 | set(handles.ListMask,'Value',eventdata.Indices(1)) |
---|
2584 | end |
---|
2585 | |
---|
2586 | %------------------------------------------------------------------- |
---|
2587 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
2588 | %------------------------------------------------------------------- |
---|
2589 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
2590 | pathelp=fileparts(path_to_uvmat); |
---|
2591 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
2592 | 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') |
---|
2593 | else |
---|
2594 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
2595 | web([helpfile '#series']) |
---|
2596 | end |
---|
2597 | |
---|
2598 | %------------------------------------------------------------------- |
---|
2599 | % --- Executes on selection change in TransformName. |
---|
2600 | function TransformName_Callback(hObject, eventdata, handles) |
---|
2601 | %---------------------------------------------------------------------- |
---|
2602 | TransformList=get(handles.TransformName,'String'); |
---|
2603 | TransformIndex=get(handles.TransformName,'Value'); |
---|
2604 | TransformName=TransformList{TransformIndex}; |
---|
2605 | TransformPathList=get(handles.TransformName,'UserData'); |
---|
2606 | nb_builtin_transform=4; |
---|
2607 | if isequal(TransformName,'more...'); |
---|
2608 | FileName=uigetfile_uvmat('Pick a transform function',get(handles.TransformPath,'String'),'.m'); |
---|
2609 | if isempty(FileName) |
---|
2610 | return %browser closed without choice |
---|
2611 | end |
---|
2612 | [TransformPath,TransformName,TransformExt]=fileparts(FileName);% removes extension .m |
---|
2613 | if ~strcmp(TransformExt,'.m') |
---|
2614 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
2615 | return |
---|
2616 | end |
---|
2617 | % insert the choice in the menu |
---|
2618 | TransformIndex=find(strcmp(TransformName,TransformList),1);% look for the selected function in the menu Action |
---|
2619 | if isempty(TransformIndex)%the input string does not exist in the menu |
---|
2620 | TransformIndex= length(TransformList); |
---|
2621 | TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...' |
---|
2622 | set(handles.TransformName,'String',TransformList) |
---|
2623 | TransformPathList=[TransformPathList;{TransformPath}]; |
---|
2624 | else% the input function already exist, we update its path (possibly new) |
---|
2625 | TransformPathList{TransformIndex}=TransformPath;% |
---|
2626 | set(handles.TransformName,'Value',TransformIndex) |
---|
2627 | end |
---|
2628 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
2629 | dir_perso=prefdir;%personal Matalb directory |
---|
2630 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2631 | if exist(profil_perso,'file') |
---|
2632 | for ilist=nb_builtin_transform+1:numel(TransformPathList) |
---|
2633 | TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist}; |
---|
2634 | TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist}; |
---|
2635 | end |
---|
2636 | TransformPathListUser=TransformPathListUser'; |
---|
2637 | TransformListUser=TransformListUser'; |
---|
2638 | save (profil_perso,'TransformPathListUser','TransformListUser','-append'); %store the root name for future opening of uvmat |
---|
2639 | end |
---|
2640 | end |
---|
2641 | |
---|
2642 | %display the current function path |
---|
2643 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}); %show the path to the senlected function |
---|
2644 | set(handles.TransformName,'UserData',TransformPathList); |
---|
2645 | |
---|
2646 | %------------------------------------------------------------------------ |
---|
2647 | % --- fct activated by the upper bar menu ExportConfig |
---|
2648 | %------------------------------------------------------------------------ |
---|
2649 | function MenuExportConfig_Callback(hObject, eventdata, handles) |
---|
2650 | |
---|
2651 | global Param |
---|
2652 | Param=read_GUI_series(handles); |
---|
2653 | evalin('base','global Param')%make CurData global in the workspace |
---|
2654 | display('current series config :') |
---|
2655 | evalin('base','Param') %display CurData in the workspace |
---|
2656 | commandwindow; %brings the Matlab command window to the front |
---|
2657 | |
---|
2658 | %------------------------------------------------------------------------ |
---|
2659 | % --- fct activated by the upper bar menu InportConfig: import |
---|
2660 | % menu settings from an xml file (stored in /0_XML for each run) |
---|
2661 | %------------------------------------------------------------------------ |
---|
2662 | function MenuImportConfig_Callback(hObject, eventdata, handles) |
---|
2663 | % SeriesData=get(handles.series,'UserData'); |
---|
2664 | % if isfield(SeriesData,'RefFile') |
---|
2665 | % oldfile=SeriesData.RefFile{1}; |
---|
2666 | % end |
---|
2667 | %% use a strating file name for browserr |
---|
2668 | InputTable=get(handles.InputTable,'Data'); |
---|
2669 | oldfile=InputTable{1,1}; |
---|
2670 | if isempty(oldfile) |
---|
2671 | % use a file name stored in prefdir |
---|
2672 | dir_perso=prefdir; |
---|
2673 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2674 | if exist(profil_perso,'file') |
---|
2675 | h=load (profil_perso); |
---|
2676 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
2677 | oldfile=h.RootPath; |
---|
2678 | end |
---|
2679 | end |
---|
2680 | end |
---|
2681 | filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters |
---|
2682 | %proceed only if a file has been introduced by the browser |
---|
2683 | if ~isempty(filexml) |
---|
2684 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
2685 | % ask to stop current Action if button RUN is in action (another process is already running) |
---|
2686 | if isequal(get(handles.RUN,'Value'),1) |
---|
2687 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); |
---|
2688 | if strcmp(answer,'Yes') |
---|
2689 | STOP_Callback(hObject, eventdata, handles) |
---|
2690 | else |
---|
2691 | return |
---|
2692 | end |
---|
2693 | end |
---|
2694 | Param.Action.RUN=0; %desactivate the input RUN=1 |
---|
2695 | fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters |
---|
2696 | SeriesData=get(handles.series,'UserData'); |
---|
2697 | if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters |
---|
2698 | set(handles.ActionInput,'Visible','on') |
---|
2699 | set(handles.ActionInput,'Value',0) |
---|
2700 | SeriesData.ActionInput=Param.ActionInput; |
---|
2701 | end |
---|
2702 | if isfield(Param,'ProjObject') %introduce projection object if relevant |
---|
2703 | SeriesData.ProjObject=Param.ProjObject; |
---|
2704 | end |
---|
2705 | set(handles.series,'UserData',SeriesData) |
---|
2706 | if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1) |
---|
2707 | set(handles.ProjObject,'String',Param.ProjObject.Name) |
---|
2708 | set(handles.ViewObject,'Visible','on') |
---|
2709 | set(handles.EditObject,'Visible','on') |
---|
2710 | set(handles.DeleteObject,'Visible','on') |
---|
2711 | else |
---|
2712 | set(handles.ProjObject,'String','') |
---|
2713 | set(handles.ProjObject,'Visible','off') |
---|
2714 | set(handles.ViewObject,'Visible','off') |
---|
2715 | set(handles.EditObject,'Visible','off') |
---|
2716 | set(handles.DeleteObject,'Visible','off') |
---|
2717 | end |
---|
2718 | set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated |
---|
2719 | end |
---|
2720 | |
---|
2721 | %------------------------------------------------------------------------ |
---|
2722 | % --- Executes when the GUI series is resized. |
---|
2723 | %------------------------------------------------------------------------ |
---|
2724 | function series_ResizeFcn(hObject, eventdata, handles) |
---|
2725 | |
---|
2726 | %% input table |
---|
2727 | set(handles.InputTable,'Unit','pixel') |
---|
2728 | Pos=get(handles.InputTable,'Position'); |
---|
2729 | set(handles.InputTable,'Unit','normalized') |
---|
2730 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52)); |
---|
2731 | ColumnWidth=num2cell(ColumnWidth); |
---|
2732 | set(handles.InputTable,'ColumnWidth',ColumnWidth) |
---|
2733 | |
---|
2734 | %% MinIndex_j and MaxIndex_i |
---|
2735 | unit=get(handles.MinIndex_i,'Unit'); |
---|
2736 | set(handles.MinIndex_i,'Unit','pixel') |
---|
2737 | Pos=get(handles.MinIndex_i,'Position'); |
---|
2738 | set(handles.MinIndex_i,'Unit',unit) |
---|
2739 | set(handles.MinIndex_i,'ColumnWidth',{Pos(3)-18}) |
---|
2740 | set(handles.MaxIndex_i,'ColumnWidth',{Pos(3)-18}) |
---|
2741 | set(handles.MinIndex_j,'ColumnWidth',{Pos(3)-18}) |
---|
2742 | set(handles.MaxIndex_j,'ColumnWidth',{Pos(3)-18}) |
---|
2743 | |
---|
2744 | %% TimeTable |
---|
2745 | set(handles.TimeTable,'Unit','pixel') |
---|
2746 | Pos=get(handles.TimeTable,'Position'); |
---|
2747 | set(handles.TimeTable,'Unit','normalized') |
---|
2748 | % ColumnWidth=get(handles.TimeTable,'ColumnWidth'); |
---|
2749 | ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20))); |
---|
2750 | set(handles.TimeTable,'ColumnWidth',ColumnWidth) |
---|
2751 | |
---|
2752 | |
---|
2753 | %% PairString |
---|
2754 | set(handles.PairString,'Unit','pixel') |
---|
2755 | Pos=get(handles.PairString,'Position'); |
---|
2756 | set(handles.PairString,'Unit','normalized') |
---|
2757 | set(handles.PairString,'ColumnWidth',{Pos(3)-5}) |
---|
2758 | |
---|
2759 | %% MaskTable |
---|
2760 | set(handles.MaskTable,'Unit','pixel') |
---|
2761 | Pos=get(handles.MaskTable,'Position'); |
---|
2762 | set(handles.MaskTable,'Unit','normalized') |
---|
2763 | set(handles.MaskTable,'ColumnWidth',{Pos(3)-5}) |
---|
2764 | |
---|
2765 | %------------------------------------------------------------------------ |
---|
2766 | % --- Executes on button press in status. |
---|
2767 | %------------------------------------------------------------------------ |
---|
2768 | function status_Callback(hObject, eventdata, handles) |
---|
2769 | |
---|
2770 | if get(handles.status,'Value') |
---|
2771 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
2772 | drawnow |
---|
2773 | Param=read_GUI(handles.series); |
---|
2774 | RootPath=Param.InputTable{1,1}; |
---|
2775 | if ~isfield(Param,'OutputSubDir') |
---|
2776 | msgbox_uvmat('ERROR','no directory defined for output files') |
---|
2777 | return |
---|
2778 | end |
---|
2779 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files |
---|
2780 | OutputDir=fullfile(RootPath,OutputSubDir); |
---|
2781 | if exist(OutputDir,'dir') |
---|
2782 | uigetfile_uvmat('status_display',OutputDir) |
---|
2783 | else |
---|
2784 | msgbox_uvmat('ERROR','output folder not created yet: calculation did not start') |
---|
2785 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
2786 | end |
---|
2787 | else |
---|
2788 | %% delete current display fig if selection is off |
---|
2789 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
2790 | hfig=findobj(allchild(0),'name','status_display'); |
---|
2791 | if ~isempty(hfig) |
---|
2792 | delete(hfig) |
---|
2793 | end |
---|
2794 | return |
---|
2795 | end |
---|
2796 | |
---|
2797 | |
---|
2798 | %------------------------------------------------------------------------ |
---|
2799 | % launched by selecting a file on the list |
---|
2800 | %------------------------------------------------------------------------ |
---|
2801 | function view_file(hObject, eventdata) |
---|
2802 | |
---|
2803 | list=get(hObject,'String'); |
---|
2804 | index=get(hObject,'Value'); |
---|
2805 | rootroot=get(hObject,'UserData'); |
---|
2806 | selectname=list{index}; |
---|
2807 | ind_dot=regexp(selectname,'\.\.\.'); |
---|
2808 | if ~isempty(ind_dot) |
---|
2809 | selectname=selectname(1:ind_dot-1); |
---|
2810 | end |
---|
2811 | FullSelectName=fullfile(rootroot,selectname); |
---|
2812 | if exist(FullSelectName,'dir')% a directory has been selected |
---|
2813 | ListFiles=dir(FullSelectName); |
---|
2814 | ListDisplay=cell(numel(ListFiles),1); |
---|
2815 | for ilist=2:numel(ListDisplay)% suppress the first line '.' |
---|
2816 | ListDisplay{ilist-1}=ListFiles(ilist).name; |
---|
2817 | end |
---|
2818 | set(hObject,'Value',1) |
---|
2819 | set(hObject,'String',ListDisplay) |
---|
2820 | if strcmp(selectname,'..') |
---|
2821 | FullSelectName=fileparts(fileparts(FullSelectName)); |
---|
2822 | end |
---|
2823 | set(hObject,'UserData',FullSelectName) |
---|
2824 | hfig=get(hObject,'parent'); |
---|
2825 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
2826 | set(htitlebox,'String',FullSelectName) |
---|
2827 | elseif exist(FullSelectName,'file')%visualise the vel field if it exists |
---|
2828 | FileType=get_file_type(FullSelectName); |
---|
2829 | if strcmp(FileType,'txt') |
---|
2830 | edit(FullSelectName) |
---|
2831 | elseif strcmp(FileType,'xml') |
---|
2832 | editxml(FullSelectName) |
---|
2833 | else |
---|
2834 | uvmat(FullSelectName) |
---|
2835 | end |
---|
2836 | set(gcbo,'Value',1) |
---|
2837 | end |
---|
2838 | |
---|
2839 | |
---|
2840 | %------------------------------------------------------------------------ |
---|
2841 | % launched by refreshing the status figure |
---|
2842 | %------------------------------------------------------------------------ |
---|
2843 | function refresh_GUI(hfig) |
---|
2844 | |
---|
2845 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
2846 | hlist=findobj(hfig,'tag','list'); |
---|
2847 | hseries=findobj(allchild(0),'tag','series'); |
---|
2848 | hstatus=findobj(hseries,'tag','status'); |
---|
2849 | StatusData=get(hstatus,'UserData'); |
---|
2850 | OutputDir=get(htitlebox,'String'); |
---|
2851 | if ischar(OutputDir),OutputDir={OutputDir};end |
---|
2852 | ListFiles=dir(OutputDir{1}); |
---|
2853 | if numel(ListFiles)<1 |
---|
2854 | return |
---|
2855 | end |
---|
2856 | ListFiles(1)=[];%removes the first line ='.' |
---|
2857 | ListDisplay=cell(numel(ListFiles),1); |
---|
2858 | testrecent=0; |
---|
2859 | datnum=zeros(numel(ListDisplay),1); |
---|
2860 | for ilist=1:numel(ListDisplay) |
---|
2861 | ListDisplay{ilist}=ListFiles(ilist).name; |
---|
2862 | if ~ListFiles(ilist).isdir && isfield(ListFiles(ilist),'datenum') |
---|
2863 | datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions |
---|
2864 | testrecent=1; |
---|
2865 | end |
---|
2866 | end |
---|
2867 | set(hlist,'String',ListDisplay) |
---|
2868 | |
---|
2869 | %% Look at date of creation |
---|
2870 | ListDisplay=ListDisplay(datnum~=0); |
---|
2871 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
2872 | NbOutputFile=[]; |
---|
2873 | if isempty(datnum) |
---|
2874 | if testrecent |
---|
2875 | message='no civ result created yet'; |
---|
2876 | else |
---|
2877 | message=''; |
---|
2878 | end |
---|
2879 | else |
---|
2880 | [first,indfirst]=min(datnum); |
---|
2881 | [last,indlast]=max(datnum); |
---|
2882 | NbOutputFile_str='?'; |
---|
2883 | NbOutputFile=[]; |
---|
2884 | if isfield(StatusData,'NbOutputFile') |
---|
2885 | NbOutputFile=StatusData.NbOutputFile; |
---|
2886 | NbOutputFile_str=num2str(NbOutputFile); |
---|
2887 | end |
---|
2888 | message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];... |
---|
2889 | ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]}; |
---|
2890 | end |
---|
2891 | set(htitlebox,'String', [OutputDir{1};message]) |
---|
2892 | |
---|
2893 | %% update the waitbar |
---|
2894 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
2895 | if ~isempty(NbOutputFile) |
---|
2896 | BarPosition=get(hwaitbar,'Position'); |
---|
2897 | BarPosition(3)=0.9*numel(datnum)/NbOutputFile; |
---|
2898 | set(hwaitbar,'Position',BarPosition) |
---|
2899 | end |
---|
2900 | |
---|
2901 | %------------------------------------------------------------------------ |
---|
2902 | % --- Executes on selection change in ActionExt. |
---|
2903 | %------------------------------------------------------------------------ |
---|
2904 | function ActionExt_Callback(hObject, eventdata, handles) |
---|
2905 | |
---|
2906 | ActionExtList=get(handles.ActionExt,'String'); |
---|
2907 | ActionExt=ActionExtList{get(handles.ActionExt,'Value')}; |
---|
2908 | ActionList=get(handles.ActionName,'String'); |
---|
2909 | ActionName=ActionList{get(handles.ActionName,'Value')}; |
---|
2910 | TransformPath=''; |
---|
2911 | if ~isempty(get(handles.ActionExt,'UserData')) |
---|
2912 | TransformPath=get(handles.ActionExt,'UserData'); |
---|
2913 | end |
---|
2914 | if strcmp(ActionExt,'.sh') |
---|
2915 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
2916 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
2917 | ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']); |
---|
2918 | if ~exist(ActionFullName,'file') |
---|
2919 | answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?'); |
---|
2920 | if strcmp(answer,'Yes') |
---|
2921 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
2922 | path_uvmat=fileparts(which('series')); |
---|
2923 | currentdir=pwd; |
---|
2924 | cd(get(handles.ActionPath,'String'))% go to the directory of Action |
---|
2925 | % addpath(get(handles.TransformPath,'String')) |
---|
2926 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile' |
---|
2927 | % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile' |
---|
2928 | compile(ActionName,TransformPath) |
---|
2929 | cd(currentdir) |
---|
2930 | end |
---|
2931 | else |
---|
2932 | sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh'])); |
---|
2933 | m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m'])); |
---|
2934 | if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum |
---|
2935 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
2936 | drawnow |
---|
2937 | answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']); |
---|
2938 | if strcmp(answer,'Yes') |
---|
2939 | path_uvmat=fileparts(which('series')); |
---|
2940 | currentdir=pwd; |
---|
2941 | cd(get(handles.ActionPath,'String'))% go to the directory of Action |
---|
2942 | % addpath(get(handles.TransformPath,'String')) |
---|
2943 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile' |
---|
2944 | addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile' |
---|
2945 | compile(ActionName,TransformPath) |
---|
2946 | cd(currentdir) |
---|
2947 | end |
---|
2948 | end |
---|
2949 | end |
---|
2950 | set(handles.ActionExt,'BackgroundColor',[1 1 1]) |
---|
2951 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch |
---|
2952 | end |
---|
2953 | |
---|
2954 | |
---|
2955 | |
---|
2956 | |
---|
2957 | function num_NbProcess_Callback(hObject, eventdata, handles) |
---|
2958 | |
---|
2959 | |
---|
2960 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
2961 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
2962 | set(handles.num_NbProcess,'String',num2str(NbSlice)) |
---|
2963 | |
---|
2964 | %------------------------------------------------------------------------ |
---|
2965 | % --- set the visibility of relevant velocity type menus: |
---|
2966 | function menu=set_veltype_display(Civ,FileType) |
---|
2967 | %------------------------------------------------------------------------ |
---|
2968 | if ~exist('FileType','var') |
---|
2969 | FileType='civx'; |
---|
2970 | end |
---|
2971 | switch FileType |
---|
2972 | case 'civx' |
---|
2973 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
2974 | if isequal(Civ,0) |
---|
2975 | imax=0; |
---|
2976 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
2977 | imax=1; |
---|
2978 | elseif isequal(Civ,3) |
---|
2979 | imax=3; |
---|
2980 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
2981 | imax=4; |
---|
2982 | elseif isequal(Civ,6) %patch2 |
---|
2983 | imax=6; |
---|
2984 | end |
---|
2985 | case 'civdata' |
---|
2986 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
2987 | if isequal(Civ,0) |
---|
2988 | imax=0; |
---|
2989 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
2990 | imax=1; |
---|
2991 | elseif isequal(Civ,3) |
---|
2992 | imax=2; |
---|
2993 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
2994 | imax=3; |
---|
2995 | elseif isequal(Civ,6) %patch2 |
---|
2996 | imax=4; |
---|
2997 | end |
---|
2998 | end |
---|
2999 | menu=menu(1:imax); |
---|
3000 | |
---|
3001 | |
---|
3002 | % --- Executes on mouse motion over figure - except title and menu. |
---|
3003 | function series_WindowButtonMotionFcn(hObject, eventdata, handles) |
---|
3004 | set(hObject,'Pointer','arrow'); |
---|