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 |
|
---|
17 | %=======================================================================
|
---|
18 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
---|
19 | % http://www.legi.grenoble-inp.fr
|
---|
20 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
|
---|
21 | %
|
---|
22 | % This file is part of the toolbox UVMAT.
|
---|
23 | %
|
---|
24 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
25 | % it under the terms of the GNU General Public License as published
|
---|
26 | % by the Free Software Foundation; either version 2 of the license,
|
---|
27 | % or (at your option) any later version.
|
---|
28 | %
|
---|
29 | % UVMAT is distributed in the hope that it will be useful,
|
---|
30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
32 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
33 | %=======================================================================
|
---|
34 |
|
---|
35 | %------------------------------------------------------------------------
|
---|
36 | %------------------------------------------------------------------------
|
---|
37 | % I - MAIN FUNCTION series
|
---|
38 | %------------------------------------------------------------------------
|
---|
39 | %------------------------------------------------------------------------
|
---|
40 | function varargout = series(varargin)
|
---|
41 |
|
---|
42 | % Begin initialization code - DO NOT EDIT
|
---|
43 | gui_Singleton = 1;
|
---|
44 | gui_State = struct('gui_Name', mfilename, ...
|
---|
45 | 'gui_Singleton', gui_Singleton, ...
|
---|
46 | 'gui_OpeningFcn', @series_OpeningFcn, ...
|
---|
47 | 'gui_OutputFcn', @series_OutputFcn, ...
|
---|
48 | 'gui_LayoutFcn', [] , ...
|
---|
49 | 'gui_Callback', []);
|
---|
50 | if nargin && ischar(varargin{1})
|
---|
51 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
52 | end
|
---|
53 |
|
---|
54 | if nargout
|
---|
55 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
56 | else
|
---|
57 | gui_mainfcn(gui_State, varargin{:});
|
---|
58 | end
|
---|
59 | % End initialization code - DO NOT EDIT
|
---|
60 |
|
---|
61 | %--------------------------------------------------------------------------
|
---|
62 | % --- Executes just before series is made visible.
|
---|
63 | %--------------------------------------------------------------------------
|
---|
64 | function series_OpeningFcn(hObject, eventdata, handles,Param)
|
---|
65 |
|
---|
66 | % Choose default command line output for series
|
---|
67 | handles.output = hObject;
|
---|
68 | % Update handles structure
|
---|
69 | guidata(hObject, handles);
|
---|
70 |
|
---|
71 | %% initial settings
|
---|
72 | % position and size of the GUI at opening
|
---|
73 | set(0,'Unit','points')
|
---|
74 | ScreenSize=get(0,'ScreenSize'); % size of the current screen, in points (1/72 inch)
|
---|
75 | Width=900; % prefered width of the GUI in points (1/72 inch)
|
---|
76 | Height=624; % prefered height of the GUI in points (1/72 inch)
|
---|
77 | %adjust to screen size (reduced by a min margin)
|
---|
78 | RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
|
---|
79 | if RescaleFactor>1
|
---|
80 | RescaleFactor=min(RescaleFactor,1);
|
---|
81 | end
|
---|
82 | Width=Width*RescaleFactor;
|
---|
83 | Height=Height*RescaleFactor;
|
---|
84 | LeftX=80*RescaleFactor; % position of the left fig side, in pixels (put to the left side, with some margin)
|
---|
85 | LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
|
---|
86 | set(hObject,'Units','points')
|
---|
87 | set(hObject,'Position',[LeftX LowY Width Height])% position and size of the GUI at opening
|
---|
88 |
|
---|
89 | % settings of table MinIndex_j
|
---|
90 | set(handles.MinIndex_i,'ColumnFormat',{'numeric'})
|
---|
91 | set(handles.MinIndex_i,'ColumnEditable',false)
|
---|
92 | set(handles.MinIndex_i,'ColumnName',{'i min'})
|
---|
93 | set(handles.MinIndex_i,'Data',[])% initiate Data to double (not cell)
|
---|
94 |
|
---|
95 | % settings of table MinIndex_j
|
---|
96 | set(handles.MinIndex_j,'ColumnFormat',{'numeric'})
|
---|
97 | set(handles.MinIndex_j,'ColumnEditable',false)
|
---|
98 | set(handles.MinIndex_j,'ColumnName',{'j min'})
|
---|
99 | set(handles.MinIndex_j,'Data',[])% initiate Data to double (not cell)
|
---|
100 |
|
---|
101 | % settings of table MaxIndex_i
|
---|
102 | set(handles.MaxIndex_i,'ColumnFormat',{'numeric'})
|
---|
103 | set(handles.MaxIndex_i,'ColumnEditable',false)
|
---|
104 | set(handles.MaxIndex_i,'ColumnName',{'i max'})
|
---|
105 | set(handles.MaxIndex_i,'Data',[])% initiate Data to double (not cell)
|
---|
106 |
|
---|
107 | % settings of table MaxIndex_j
|
---|
108 | set(handles.MaxIndex_j,'ColumnFormat',{'numeric'})
|
---|
109 | set(handles.MaxIndex_j,'ColumnEditable',false)
|
---|
110 | set(handles.MaxIndex_j,'ColumnName',{'j max'})
|
---|
111 | set(handles.MaxIndex_j,'Data',[])% initiate Data to double (not cell)
|
---|
112 |
|
---|
113 | % settings of table PairString
|
---|
114 | set(handles.PairString,'ColumnName',{'pairs'})
|
---|
115 | set(handles.PairString,'ColumnEditable',false)
|
---|
116 | set(handles.PairString,'ColumnFormat',{'char'})
|
---|
117 | set(handles.PairString,'Data',{''})
|
---|
118 |
|
---|
119 | % settings of table MaskTable
|
---|
120 | %set(handles.MaskTable,'ColumnName',{'mask name'})
|
---|
121 | set(handles.PairString,'ColumnEditable',false)
|
---|
122 | set(handles.PairString,'ColumnFormat',{'char'})
|
---|
123 | set(handles.PairString,'Data',{''})
|
---|
124 |
|
---|
125 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
|
---|
126 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
|
---|
127 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
128 |
|
---|
129 | % check default input data
|
---|
130 | if ~exist('Param','var')
|
---|
131 | Param=[]; % default
|
---|
132 | end
|
---|
133 |
|
---|
134 | %% Read the parameter file series.xml, or created from series.xml.default if it does not exist
|
---|
135 | SeriesData=[];
|
---|
136 | [path_series,name,ext]=fileparts(which('series'));% path to the GUI series
|
---|
137 | xmlfile=fullfile(path_series,'series.xml');
|
---|
138 | if ~exist(xmlfile,'file')
|
---|
139 | [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile);
|
---|
140 | end
|
---|
141 | if exist(xmlfile,'file')
|
---|
142 | SeriesData.SeriesParam=xml2struct(xmlfile);
|
---|
143 | if ~(isfield(SeriesData.SeriesParam,'ClusterParam')&& isfield(SeriesData.SeriesParam.ClusterParam,'LaunchCmdFcn'))
|
---|
144 | [success,message]=copyfile(xmlfile,fullfile(path_series,'series_old.xml'));% update the file series.xml inot correctly documented
|
---|
145 | delete(xmlfile);
|
---|
146 | [success,message]=copyfile(fullfile(path_series,'series.xml.default'),xmlfile);
|
---|
147 | end
|
---|
148 | SeriesData.SeriesParam=xml2struct(xmlfile);
|
---|
149 | end
|
---|
150 |
|
---|
151 | %% list of builtin functions in the menu ActionName
|
---|
152 | ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'}; % WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
|
---|
153 | NbBuiltinAction=numel(ActionList);
|
---|
154 | set(handles.Action,'UserData',NbBuiltinAction)
|
---|
155 | path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
|
---|
156 | [path_series,name,ext]=fileparts(which('series')); % path to the GUI series
|
---|
157 | path_series_fct=fullfile(path_series,'series'); % path of the functions in subdirectroy 'series'
|
---|
158 | ActionExtList={'.m';'.sh';'fluidimage'}; % default choice of extensions (Matlab fct .m or compiled version .sh
|
---|
159 | ActionPathList=cell(NbBuiltinAction,1); % initiate the cell matrix of Action fct paths
|
---|
160 | ActionPathList(:)={path_series_fct}; % set the default path to series fcts to all list members
|
---|
161 | RunModeList={'local';'background'}; % default choice of extensions (Matlab fct .m or compiled version .sh)
|
---|
162 | [s,w]=system(SeriesData.SeriesParam.ClusterParam.ExistenceTest); % look for cluster system presence
|
---|
163 | if isequal(s,0)
|
---|
164 | RunModeList=[RunModeList;{'cluster'}];
|
---|
165 | set(handles.MonitorCluster,'Visible','on'); % make visible button for access to Monika
|
---|
166 | set(handles.num_CPUTime,'Visible','on'); % make visible button for CPU time estimate for one ref index
|
---|
167 | set(handles.num_CPUTime,'String','')% default CPU time undefined
|
---|
168 | set(handles.CPUTime_txt,'Visible','on'); % make visible button for CPU time title
|
---|
169 | end
|
---|
170 | set(handles.RunMode,'String',RunModeList)% display the menu of available run modes, local, background or cluster manager
|
---|
171 |
|
---|
172 | %% list of builtin transform functions in the menu TransformName
|
---|
173 | TransformList={'';'sub_field';'phys';'phys_polar'}; % WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback
|
---|
174 | NbBuiltinTransform=numel(TransformList);
|
---|
175 | path_transform_fct=fullfile(path_series,'transform_field');
|
---|
176 | TransformPathList=cell(NbBuiltinTransform,1); % initiate the cell matrix of Action fct paths
|
---|
177 | TransformPathList(:)={path_transform_fct}; % set the default path to series fcts to all list members
|
---|
178 | SeriesData.TransformPath=path_transform_fct;% store the standard path for trqnsform functions (needed for compilation)
|
---|
179 |
|
---|
180 | %% get the user defined functions stored in the personal file uvmat_perso.mat
|
---|
181 | dir_perso=prefdir;
|
---|
182 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
183 | if exist(profil_perso,'file')
|
---|
184 | h=load (profil_perso);
|
---|
185 | %get the list of previous input files in the upper bar menu Open
|
---|
186 | if isfield(h,'MenuFile')
|
---|
187 | for ifile=1:min(length(h.MenuFile),5)
|
---|
188 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
|
---|
189 | set(handles.(['MenuFile_' num2str(ifile+5)]),'Label',h.MenuFile{ifile});
|
---|
190 | end
|
---|
191 | end
|
---|
192 | %get the menu of actions
|
---|
193 | if isfield(h,'ActionListUser') && iscell(h.ActionListUser) && isfield(h,'ActionPathListUser') && iscell(h.ActionPathListUser)
|
---|
194 | ActionList=[ActionList;h.ActionListUser];
|
---|
195 | ActionPathList=[ActionPathList;h.ActionPathListUser(:,1)];
|
---|
196 | end
|
---|
197 | %get the menu of transform fct
|
---|
198 | if isfield(h,'TransformListUser') && iscell(h.TransformListUser) && isfield(h,'TransformPathListUser') && iscell(h.TransformPathListUser)
|
---|
199 | TransformList=[TransformList;h.TransformListUser];
|
---|
200 | TransformPathList=[TransformPathList;h.TransformPathListUser];
|
---|
201 | end
|
---|
202 | end
|
---|
203 |
|
---|
204 | %% selection of the input Action fct
|
---|
205 | ActionCheckExist=true(size(ActionList)); % initiate the check of the path to the listed action fct
|
---|
206 | for ilist=NbBuiltinAction+1:numel(ActionList)%check the validity of the path of the user defined Action fct
|
---|
207 | ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file');
|
---|
208 | end
|
---|
209 | ActionPathList=ActionPathList(ActionCheckExist,:); % suppress the menu options which are not valid anymore
|
---|
210 | ActionList=ActionList(ActionCheckExist);
|
---|
211 | set(handles.ActionName,'String',[ActionList;{'more...'}])
|
---|
212 | set(handles.ActionName,'UserData',ActionPathList)
|
---|
213 | ActionIndex=[];
|
---|
214 | if isfield(Param,'ActionName')% copy the selected menu index transferred in Param from uvmat
|
---|
215 | ActionIndex=find(strcmp(Param.ActionName,ActionList),1);
|
---|
216 | end
|
---|
217 | if isempty(ActionIndex)
|
---|
218 | ActionIndex=1;
|
---|
219 | end
|
---|
220 | set(handles.ActionName,'Value',ActionIndex)
|
---|
221 | set(handles.ActionPath,'String',ActionPathList{ActionIndex})
|
---|
222 | set(handles.ActionExt,'Value',1)
|
---|
223 | set(handles.ActionExt,'String',ActionExtList)
|
---|
224 |
|
---|
225 | %% selection of the input transform fct
|
---|
226 | TransformCheckExist=true(size(TransformList));
|
---|
227 | for ilist=NbBuiltinTransform+1:numel(TransformList)
|
---|
228 | TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file');
|
---|
229 | end
|
---|
230 | TransformPathList=TransformPathList(TransformCheckExist);
|
---|
231 | TransformList=TransformList(TransformCheckExist);
|
---|
232 | set(handles.TransformName,'String',[TransformList;{'more...'}])
|
---|
233 | set(handles.TransformName,'UserData',TransformPathList)
|
---|
234 | TransformIndex=[];
|
---|
235 | if isfield(Param,'TransformName')% copy the selected menu index transferred in Param from uvmat
|
---|
236 | TransformIndex=find(strcmp(Param.TransformName,TransformList),1);
|
---|
237 | end
|
---|
238 | if isempty(TransformIndex)
|
---|
239 | TransformIndex=1;
|
---|
240 | end
|
---|
241 | set(handles.TransformName,'Value',TransformIndex)
|
---|
242 | set(handles.TransformPath,'String',TransformPathList{TransformIndex})
|
---|
243 |
|
---|
244 | %% fields input initialisation
|
---|
245 | if isfield(Param,'list_fields')&& isfield(Param,'index_fields') &&~isempty(Param.list_fields) &&~isempty(Param.index_fields)
|
---|
246 | set(handles.FieldName,'String',Param.list_fields); % list menu fields
|
---|
247 | set(handles.FieldName,'Value',Param.index_fields); % selected string index
|
---|
248 | end
|
---|
249 | if isfield(Param,'Coordinates')
|
---|
250 | if isfield(Param.Coordinates,'Coord_x')
|
---|
251 | set(handles.Coord_x,'String',Param.Coordinates.Coord_x)
|
---|
252 | end
|
---|
253 | if isfield(Param.Coordinates,'Coord_y')
|
---|
254 | set(handles.Coord_y,'String',Param.Coordinates.Coord_y)
|
---|
255 | end
|
---|
256 | if isfield(Param.Coordinates,'Coord_z')
|
---|
257 | set(handles.Coord_z,'String',Param.Coordinates.Coord_z)
|
---|
258 | end
|
---|
259 | end
|
---|
260 |
|
---|
261 | %% introduce the input file name(s) if defined from input Param,
|
---|
262 | set(handles.series,'UserData',SeriesData)% initiate Userdata
|
---|
263 | if isfield(Param,'InputFile')
|
---|
264 |
|
---|
265 | %% fill the list of input file series
|
---|
266 | InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}];
|
---|
267 | if isempty(find(cellfun('isempty',InputTable)==0)) % if there is no input file, do not introduce input info
|
---|
268 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
269 | return
|
---|
270 | end
|
---|
271 | TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
|
---|
272 | if isfield(Param.InputFile,'RootPath_1')
|
---|
273 | InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]];
|
---|
274 | TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
|
---|
275 | end
|
---|
276 | set(handles.InputTable,'Data',InputTable)
|
---|
277 |
|
---|
278 | %% define the default path for the output files
|
---|
279 | [InputPath,Device,DeviceExt]=fileparts(InputTable{1,1});
|
---|
280 | [InputPath,Experiment,ExperimentExt]=fileparts(InputPath);
|
---|
281 | set(handles.Device,'String',[Device DeviceExt])
|
---|
282 | set(handles.Experiment,'String',[Experiment ExperimentExt])
|
---|
283 | if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)'))
|
---|
284 | set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
|
---|
285 | end
|
---|
286 |
|
---|
287 | %update the output path if needed
|
---|
288 | if ~(isfield(SeriesData,'InputPath') && strcmp(SeriesData.InputPath,InputPath))
|
---|
289 | if get(handles.OutputPathBrowse,'Value')==1 % fix the output path in manual mode
|
---|
290 | OutputPathOld=get(handles.OutputPath,'String');
|
---|
291 | OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
|
---|
292 | set(handles.OutputPath,'String',OutputPath)
|
---|
293 | else %reproduce the input path for output
|
---|
294 | set(handles.OutputPath,'String',InputPath)
|
---|
295 | end
|
---|
296 | end
|
---|
297 |
|
---|
298 | %% determine the selected reference field indices for pair display
|
---|
299 |
|
---|
300 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex);
|
---|
301 | if isempty(i1)
|
---|
302 | i1=1;
|
---|
303 | end
|
---|
304 | if isempty(i2)
|
---|
305 | i2=i1;
|
---|
306 | end
|
---|
307 | ref_i=floor((i1+i2)/2); % reference image number corresponding to the file
|
---|
308 | % set(handles.num_ref_i,'String',num2str(ref_i));
|
---|
309 | if isempty(j1)
|
---|
310 | j1=1;
|
---|
311 | end
|
---|
312 | if isempty(j2)
|
---|
313 | j2=j1;
|
---|
314 | end
|
---|
315 | ref_j=floor((j1+j2)/2); % reference image number corresponding to the file
|
---|
316 | SeriesData.ref_i=ref_i;
|
---|
317 | SeriesData.ref_j=ref_j;
|
---|
318 | set(handles.series,'UserData',SeriesData)
|
---|
319 | update_rootinfo(handles,Param.HiddenData.i1_series{1},Param.HiddenData.i2_series{1},Param.HiddenData.j1_series{1},Param.HiddenData.j2_series{1},...
|
---|
320 | Param.HiddenData.FileInfo{1},Param.HiddenData.MovieObject{1},1)
|
---|
321 | if isfield(Param,'FileName_1')
|
---|
322 | % display_file_name(handles,Param,2)
|
---|
323 | update_rootinfo(handles,Param.HiddenData.i1_series{2},Param.HiddenData.i2_series{2},Param.HiddenData.j1_series{2},Param.HiddenData.j2_series{2},...
|
---|
324 | Param.HiddenData.FileInfo{2},Param.HiddenData.MovieObject{2},2)
|
---|
325 | end
|
---|
326 | %% enable field and veltype menus, in accordance with the current action
|
---|
327 | ActionName_Callback([],[], handles)
|
---|
328 |
|
---|
329 | %% set length of waitbar
|
---|
330 | displ_time(handles)
|
---|
331 |
|
---|
332 | else
|
---|
333 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
334 | end
|
---|
335 | if isfield(Param,'incr_i')
|
---|
336 | set(handles.num_incr_i,'String',num2str(Param.incr_i))
|
---|
337 | else
|
---|
338 | set(handles.num_incr_i,'String','1')
|
---|
339 | end
|
---|
340 | if isfield(Param,'incr_j')
|
---|
341 | set(handles.num_incr_j,'String',num2str(Param.incr_j))
|
---|
342 | else
|
---|
343 | set(handles.num_incr_j,'String','1')
|
---|
344 | end
|
---|
345 |
|
---|
346 | %------------------------------------------------------------------------
|
---|
347 | % --- Outputs from this function are returned to the command line.
|
---|
348 | function varargout = series_OutputFcn(hObject, eventdata, handles)
|
---|
349 | %------------------------------------------------------------------------
|
---|
350 | varargout{1} = handles.output;
|
---|
351 |
|
---|
352 | %------------------------------------------------------------------------
|
---|
353 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist
|
---|
354 | function closefcn(gcbo,eventdata)
|
---|
355 | %------------------------------------------------------------------------
|
---|
356 |
|
---|
357 | % delete set_object_series if detected
|
---|
358 | hh=findobj(allchild(0),'name','view_object_series');
|
---|
359 | if ~isempty(hh)
|
---|
360 | delete(hh)
|
---|
361 | end
|
---|
362 | hh=findobj(allchild(0),'name','edit_object_series');
|
---|
363 | if ~isempty(hh)
|
---|
364 | delete(hh)
|
---|
365 | end
|
---|
366 |
|
---|
367 | %delete the bowser if detected
|
---|
368 | hh=findobj(allchild(0),'tag','browser');
|
---|
369 | if ~isempty(hh)
|
---|
370 | delete(hh)
|
---|
371 | end
|
---|
372 |
|
---|
373 |
|
---|
374 | %------------------------------------------------------------------------
|
---|
375 | %------------------------------------------------------------------------
|
---|
376 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
377 | % automatically sets the global properties when the rootfile name is introduced
|
---|
378 | % then activate the view-field actionname if selected
|
---|
379 | % it is activated either by clicking on the RootPath window or by the
|
---|
380 | % browser
|
---|
381 | %------------------------------------------------------------------------
|
---|
382 | %------------------------------------------------------------------------
|
---|
383 | % --- fct activated by the browser under 'Open'
|
---|
384 | %------------------------------------------------------------------------
|
---|
385 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
386 | %% look for the previously opened file 'oldfile'
|
---|
387 | InputTable=get(handles.InputTable,'Data');
|
---|
388 | oldfile=InputTable{1,1};
|
---|
389 | if isempty(oldfile)
|
---|
390 | % use a file name stored in prefdir
|
---|
391 | dir_perso=prefdir;
|
---|
392 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
393 | if exist(profil_perso,'file')
|
---|
394 | h=load (profil_perso);
|
---|
395 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
396 | oldfile=h.RootPath;
|
---|
397 | end
|
---|
398 | end
|
---|
399 | end
|
---|
400 | %% launch the browser
|
---|
401 | fileinput=uigetfile_uvmat('pick an input file in the series',oldfile);
|
---|
402 | hh=dir(fileinput);
|
---|
403 | if numel(hh)>1
|
---|
404 | msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
405 | else
|
---|
406 | if ~isempty(fileinput)
|
---|
407 | display_file_name(handles,fileinput,'one')
|
---|
408 | end
|
---|
409 | end
|
---|
410 |
|
---|
411 | % --------------------------------------------------------------------
|
---|
412 | function MenuBrowseAppend_Callback(hObject, eventdata, handles)
|
---|
413 |
|
---|
414 | %% look for the previously opened file 'oldfile'
|
---|
415 | InputTable=get(handles.InputTable,'Data');
|
---|
416 | RootPathCell=InputTable(:,1);
|
---|
417 | if isempty(RootPathCell{1})% no input file in the table
|
---|
418 | MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append
|
---|
419 | return
|
---|
420 | end
|
---|
421 | SubDirCell=InputTable(:,2);
|
---|
422 | oldfile=fullfile(RootPathCell{1},SubDirCell{1});
|
---|
423 |
|
---|
424 | %% use a file name stored in prefdir
|
---|
425 | dir_perso=prefdir;
|
---|
426 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
427 | if exist(profil_perso,'file')
|
---|
428 | h=load (profil_perso);
|
---|
429 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
430 | oldfile=h.RootPath;
|
---|
431 | end
|
---|
432 | end
|
---|
433 |
|
---|
434 | %% launch the browser
|
---|
435 | fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
|
---|
436 | hh=dir(fileinput);
|
---|
437 | if numel(hh)>1
|
---|
438 | msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
439 | else
|
---|
440 | if ~isempty(fileinput)
|
---|
441 | display_file_name(handles,fileinput,'append')
|
---|
442 | end
|
---|
443 | end
|
---|
444 |
|
---|
445 | %------------------------------------------------------------------------
|
---|
446 | % --- fct activated by selecting a previous file under the menu Open
|
---|
447 | %------------------------------------------------------------------------
|
---|
448 | function MenuFile_Callback(hObject, eventdata, handles)
|
---|
449 |
|
---|
450 | errormsg=display_file_name(handles,get(hObject,'Label'),'one');
|
---|
451 | if ~isempty(errormsg)
|
---|
452 | set(hObject,'Label','')
|
---|
453 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
454 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
455 | str_find=strcmp(get(hObject,'Label'),MenuFile);
|
---|
456 | MenuFile(str_find)=[]; % suppress the input file to the list
|
---|
457 | for ifile=1:numel(MenuFile)
|
---|
458 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile});
|
---|
459 | end
|
---|
460 | end
|
---|
461 |
|
---|
462 | %------------------------------------------------------------------------
|
---|
463 | % --- fct activated by selecting a previous file under the menu Open/append
|
---|
464 | %------------------------------------------------------------------------
|
---|
465 | function MenuFile_append_Callback(hObject, eventdata, handles)
|
---|
466 |
|
---|
467 | InputTable=get(handles.InputTable,'Data');
|
---|
468 | if isempty(InputTable{1,1})% no input file in the table
|
---|
469 | display_file_name(handles,get(hObject,'Label'),'one') %refresh the input table, not append
|
---|
470 | else
|
---|
471 | display_file_name(handles,get(hObject,'Label'),'append')% append the selected file to the current list of InputTable
|
---|
472 | end
|
---|
473 |
|
---|
474 | %------------------------------------------------------------------------
|
---|
475 | % --- fct activated by the browser under 'Open campaign/Browse...'
|
---|
476 | %------------------------------------------------------------------------
|
---|
477 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
|
---|
478 |
|
---|
479 | %% look for the previously opened file 'oldfile'
|
---|
480 | InputTable=get(handles.InputTable,'Data');
|
---|
481 | if ~isempty(InputTable)
|
---|
482 | oldfile=[InputTable{1,1} InputTable{1,2}];
|
---|
483 | else
|
---|
484 | % use a file name stored in prefdir
|
---|
485 | dir_perso=prefdir;
|
---|
486 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
487 | if exist(profil_perso,'file')
|
---|
488 | h=load (profil_perso);
|
---|
489 | if isfield(h,'MenuCampaign') && ~isempty(h.MenuCampaign)&& ischar(h.MenuCampaign{1})
|
---|
490 | oldfile=h.MenuCampaign{1};
|
---|
491 | end
|
---|
492 | end
|
---|
493 | end
|
---|
494 | InputTable{1,1}='...';
|
---|
495 | set(handles.InputTable,'Data',InputTable)
|
---|
496 | browse_data(oldfile,'on','on'); % open the GUI browse_data to get select a campaign dir, experiment and device
|
---|
497 |
|
---|
498 |
|
---|
499 |
|
---|
500 | % --- Executes when selected cell(s) is changed in InputTable.
|
---|
501 | function InputTable_CellSelectionCallback(hObject, eventdata, handles)
|
---|
502 | iline=[];
|
---|
503 | if ~isempty(eventdata.Indices)
|
---|
504 | iline=eventdata.Indices(1);
|
---|
505 | end
|
---|
506 | set(handles.InputLine,'String',num2str(iline));
|
---|
507 |
|
---|
508 | %------------------------------------------------------------------------
|
---|
509 | % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
|
---|
510 | %------------------------------------------------------------------------
|
---|
511 | function InputTable_KeyPressFcn(hObject, eventdata, handles)
|
---|
512 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
513 | set(handles.OutputSubDir,'BackgroundColor',[1 0 1])% set edit box OutputSubDir to magenta color to indicate that refresh may be needed
|
---|
514 | xx=double(get(handles.series,'CurrentCharacter')); % get the keyboard character
|
---|
515 | if ~isempty(xx)
|
---|
516 | switch xx
|
---|
517 | case 31 %downward arrow
|
---|
518 | InputTable=get(handles.InputTable,'Data');
|
---|
519 | iline=str2double(get(handles.InputLine,'String'));
|
---|
520 | if isequal(iline,size(InputTable,1))% arrow downward
|
---|
521 | InputTable=[InputTable;InputTable(iline,:)]; % create a new line as a copy of the last one
|
---|
522 | set(handles.InputTable,'Data',InputTable);
|
---|
523 | end
|
---|
524 | case 127 %key 'Suppress'
|
---|
525 | ClearLine_Callback(hObject, eventdata, handles)
|
---|
526 | end
|
---|
527 | end
|
---|
528 |
|
---|
529 | %------------------------------------------------------------------------
|
---|
530 | % --- Executes on button press in REFRESH.
|
---|
531 | function REFRESH_Callback(hObject, eventdata, handles)
|
---|
532 | %------------------------------------------------------------------------
|
---|
533 | check_input_file_series(handles)
|
---|
534 |
|
---|
535 | %% enable field and veltype menus, in accordance with the current action
|
---|
536 | ActionInput_Callback([],[], handles)
|
---|
537 |
|
---|
538 | %------------------------------------------------------------------------
|
---|
539 | % --- check the input file series.
|
---|
540 | function check_input_file_series(handles)
|
---|
541 | %------------------------------------------------------------------------
|
---|
542 | InputTable=get(handles.InputTable,'Data');%read the table of input file series
|
---|
543 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
|
---|
544 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation)
|
---|
545 | drawnow
|
---|
546 | empty_line=false(size(InputTable,1),1);
|
---|
547 | for iline=1:size(InputTable,1)
|
---|
548 | empty_line(iline)= isempty(cell2mat(InputTable(iline,1:3)));%check the empty lines in the input table
|
---|
549 | end
|
---|
550 | if ~isempty(find(empty_line,1))%removes the empty lines in the table
|
---|
551 | InputTable(empty_line,:)=[]; % remove empty lines
|
---|
552 | set(handles.InputTable,'Data',InputTable)
|
---|
553 | ListTable={'MinIndex_i','MaxIndex_i','MinIndex_j','MaxIndex_j','PairString','TimeTable'};
|
---|
554 | for ilist=1:numel(ListTable)
|
---|
555 | Table=get(handles.(ListTable{ilist}),'Data');
|
---|
556 | Table(empty_line,:)=[]; % remove empty lines
|
---|
557 | set(handles.(ListTable{ilist}),'Data',Table);
|
---|
558 | end
|
---|
559 | set(handles.series,'UserData',[])%refresh the stored info
|
---|
560 | end
|
---|
561 | nbview=size(InputTable,1);
|
---|
562 | for iview=1:nbview
|
---|
563 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2});
|
---|
564 | if ~exist(RootPath,'dir')
|
---|
565 | i1_series=[];
|
---|
566 | RootFile='';
|
---|
567 | else %scan the input folder
|
---|
568 | InputTable{iview,3}=regexprep(InputTable{iview,3},'^/','');%suppress '/' at the beginning of the input name
|
---|
569 | i1=str2double(get(handles.num_first_i,'String'));
|
---|
570 | j1=str2double(get(handles.num_first_j,'String'));
|
---|
571 | j2=[];%default
|
---|
572 | PairString=get(handles.PairString,'Data');
|
---|
573 | if numel(PairString)>=iview
|
---|
574 | r=regexp(PairString{iview},'(?<num1>\d+)-(?<num2>\d+)' ,'names');
|
---|
575 | if ~isempty(r)
|
---|
576 | j1=str2double(r.num1);
|
---|
577 | j2=str2double(r.num2);
|
---|
578 | end
|
---|
579 | end
|
---|
580 | InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2);
|
---|
581 | [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,~,FileInfo,MovieObject]=...
|
---|
582 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
|
---|
583 | end
|
---|
584 | % if no file is found, open a browser
|
---|
585 | if isempty(RootFile)&& isempty(i1_series)
|
---|
586 | fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
|
---|
587 | if isempty(fileinput)
|
---|
588 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH back to red color
|
---|
589 | return
|
---|
590 | else
|
---|
591 | display_file_name(handles,fileinput,iview)% update the table of input file series, then call update_rootinfo
|
---|
592 | end
|
---|
593 | else
|
---|
594 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview)
|
---|
595 | end
|
---|
596 | end
|
---|
597 |
|
---|
598 | %% update MinIndex_i and MaxIndex_i if the input table content has been reduced in line nbre
|
---|
599 | MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
600 | set(handles.MinIndex_i,'Data',MinIndex_i_table(1:nbview,:));
|
---|
601 | MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
602 | set(handles.MinIndex_j,'Data',MinIndex_j_table(1:nbview,:));
|
---|
603 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
604 |
|
---|
605 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table(1:nbview,:));
|
---|
606 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
607 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table(1:nbview,:));
|
---|
608 | PairString=get(handles.PairString,'Data'); % retrieve the min indices in the table MinIndex
|
---|
609 | set(handles.PairString,'Data',PairString(1:nbview,:));
|
---|
610 | TimeTable=get(handles.TimeTable,'Data'); % retrieve the min indices in the table MinIndex
|
---|
611 | set(handles.TimeTable,'Data',TimeTable(1:nbview,:));
|
---|
612 |
|
---|
613 | %% set length of waitbar
|
---|
614 | displ_time(handles)
|
---|
615 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (indicate activation finished)
|
---|
616 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch'
|
---|
617 |
|
---|
618 |
|
---|
619 |
|
---|
620 | %------------------------------------------------------------------------
|
---|
621 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser
|
---|
622 | %------------------------------------------------------------------------
|
---|
623 | % INPUT:
|
---|
624 | % handles: handles of elements in the GUI
|
---|
625 | % Param: structure of input parameters, including input file name and path
|
---|
626 | % iview: line index in the input table
|
---|
627 | % or 'one': refresh the list
|
---|
628 | % 'append': add a new line to the input table
|
---|
629 | function errormsg=display_file_name(handles,Param,iview)
|
---|
630 |
|
---|
631 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation)
|
---|
632 | drawnow
|
---|
633 | errormsg=''; % default
|
---|
634 | if ischar(Param)
|
---|
635 | fileinput=Param;
|
---|
636 | else% input set when series is opened (called by the GUI uvmat)
|
---|
637 | fileinput=Param.FileName;
|
---|
638 | end
|
---|
639 |
|
---|
640 | %% get the input root name, indices, file extension and nomenclature NomType
|
---|
641 | if isempty(regexp(fileinput,'^http')) && ~exist(fileinput,'file')
|
---|
642 | errormsg=['input file ' fileinput ' does not exist'];
|
---|
643 | msgbox_uvmat('ERROR',errormsg)
|
---|
644 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (refresh still needed)
|
---|
645 | return
|
---|
646 | end
|
---|
647 |
|
---|
648 | %% detect root name, nomenclature and indices in the input file name:
|
---|
649 | [FilePath,FileName,FileExt]=fileparts(fileinput);
|
---|
650 | %%%%%%%%%%%%%%%%%%
|
---|
651 | %TODO: case of input by uvmat: do not check agai the input series %%%%%%%
|
---|
652 | %%%%%%%%%%%%%%%%%%%
|
---|
653 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
654 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
|
---|
655 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
|
---|
656 | FileType=FileInfo.FileType;
|
---|
657 | if isempty(RootFile)&&isempty(i1_series)
|
---|
658 | errormsg='no input file in the series';
|
---|
659 | msgbox_uvmat('ERROR',errormsg)
|
---|
660 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
661 | return
|
---|
662 | end
|
---|
663 | if strcmp(FileType,'txt')
|
---|
664 | edit(fileinput)
|
---|
665 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
666 | return
|
---|
667 | elseif strcmp(FileType,'xml')
|
---|
668 | editxml(fileinput)
|
---|
669 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
670 | return
|
---|
671 | elseif strcmp(FileType,'figure')
|
---|
672 | open(fileinput)
|
---|
673 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
674 | return
|
---|
675 | end
|
---|
676 |
|
---|
677 | %% enable other menus and uicontrols
|
---|
678 | set(handles.RUN, 'Enable','On')
|
---|
679 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
|
---|
680 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow
|
---|
681 | drawnow
|
---|
682 |
|
---|
683 |
|
---|
684 | %% fill the list of file series
|
---|
685 | InputTable=get(handles.InputTable,'Data');
|
---|
686 | SeriesData=get(handles.series,'UserData');
|
---|
687 |
|
---|
688 | if strcmp(iview,'append') % display the input data as a new line in the table
|
---|
689 | iview=size(InputTable,1)+1; % the next line in InputTable becomes the current line
|
---|
690 | elseif strcmp(iview,'one') % refresh the list of input file series
|
---|
691 | iview=1; % the first line in InputTable becomes the current line
|
---|
692 | InputTable={'','','','',''};
|
---|
693 | set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}])
|
---|
694 | set(handles.MinIndex_i,'Data',[])
|
---|
695 | set(handles.MaxIndex_i,'Data',[])
|
---|
696 | set(handles.MinIndex_j,'Data',[])
|
---|
697 | set(handles.MaxIndex_j,'Data',[])
|
---|
698 | set(handles.PairString,'Data',{''})
|
---|
699 | SeriesData.CheckPair=0; % reset the list of input lines with pairs
|
---|
700 | SeriesData.i1_series={};
|
---|
701 | SeriesData.i2_series={};
|
---|
702 | SeriesData.j1_series={};
|
---|
703 | SeriesData.j2_series={};
|
---|
704 | SeriesData.FileType={};
|
---|
705 | SeriesData.FileInfo={};
|
---|
706 | SeriesData.Time={};
|
---|
707 | end
|
---|
708 | if isfield(SeriesData,'i1_series')
|
---|
709 | SeriesData.i1_series(iview+1:end)=[];
|
---|
710 | SeriesData.i2_series(iview+1:end)=[];
|
---|
711 | SeriesData.j1_series(iview+1:end)=[];
|
---|
712 | SeriesData.j2_series(iview+1:end)=[];
|
---|
713 | SeriesData.FileType(iview+1:end)=[];
|
---|
714 | SeriesData.FileInfo(iview+1:end)=[];
|
---|
715 | SeriesData.Time(iview+1:end)=[];
|
---|
716 | end
|
---|
717 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
|
---|
718 | if iview >1
|
---|
719 | set(handles.InputLine,'String',num2str(iview))
|
---|
720 | end
|
---|
721 | set(handles.InputTable,'Data',InputTable)
|
---|
722 |
|
---|
723 | %% determine the selected reference field indices for pair display
|
---|
724 | if isempty(i1)
|
---|
725 | i1=1;
|
---|
726 | end
|
---|
727 | if isempty(i2)
|
---|
728 | i2=i1;
|
---|
729 | end
|
---|
730 | ref_i=floor((i1+i2)/2); % reference image number corresponding to the file
|
---|
731 | % set(handles.num_ref_i,'String',num2str(ref_i));
|
---|
732 | if isempty(j1)
|
---|
733 | j1=1;
|
---|
734 | end
|
---|
735 | if isempty(j2)
|
---|
736 | j2=j1;
|
---|
737 | end
|
---|
738 | ref_j=floor((j1+j2)/2); % reference image number corresponding to the file
|
---|
739 | SeriesData.ref_i=ref_i;
|
---|
740 | SeriesData.ref_j=ref_j;
|
---|
741 |
|
---|
742 | %% update first and last indices if they do not exist
|
---|
743 | Param=read_GUI(handles.series);
|
---|
744 | first_j=[];
|
---|
745 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
746 | last_j=[];
|
---|
747 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
748 | PairString='';
|
---|
749 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
750 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
751 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
752 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
753 | if ~exist(FirstFileName,'file')
|
---|
754 | set(handles.num_first_i,'String',num2str(ref_i))
|
---|
755 | set(handles.num_first_j,'String',num2str(ref_j))
|
---|
756 | end
|
---|
757 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
|
---|
758 | LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
759 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
760 | if ~exist(LastFileName,'file')
|
---|
761 | set(handles.num_last_i,'String',num2str(ref_i))
|
---|
762 | set(handles.num_last_j,'String',num2str(ref_j))
|
---|
763 | end
|
---|
764 |
|
---|
765 | %% update the list of recent files in the menubar and save it for future opening
|
---|
766 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
767 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
768 | str_find=strcmp(fileinput,MenuFile);
|
---|
769 | if isempty(find(str_find,1))
|
---|
770 | MenuFile=[{fileinput};MenuFile]; % insert the current file if not already in the list
|
---|
771 | end
|
---|
772 | for ifile=1:min(length(MenuFile),5)
|
---|
773 | ffname=['MenuFile_' num2str(ifile)];
|
---|
774 | set(handles.(ffname),'Label',MenuFile{ifile});
|
---|
775 | end
|
---|
776 | dir_perso=prefdir;
|
---|
777 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
778 | if exist(profil_perso,'file')
|
---|
779 | save (profil_perso,'MenuFile','-append'); % store the file names for future opening of uvmat
|
---|
780 | else
|
---|
781 | save (profil_perso,'MenuFile','-V6'); % store the file names for future opening of uvmat
|
---|
782 | end
|
---|
783 | % save the opened file to initiate future opening
|
---|
784 | SeriesData.RefFile{iview}=fileinput; % reference opening file for line iview
|
---|
785 | SeriesData.Ref_i1=i1;
|
---|
786 | SeriesData.Ref_i2=i2;
|
---|
787 | SeriesData.Ref_j1=j1;
|
---|
788 | SeriesData.Ref_j2=j2;
|
---|
789 |
|
---|
790 | %% define the path for the output files
|
---|
791 | [InputPath,Device,DeviceExt]=fileparts(InputTable{1,1});
|
---|
792 | [InputPath,Experiment,ExperimentExt]=fileparts(InputPath);
|
---|
793 | set(handles.Device,'String',[Device DeviceExt])
|
---|
794 | set(handles.Experiment,'String',[Experiment ExperimentExt])
|
---|
795 | if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)', 'once'))
|
---|
796 | set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data
|
---|
797 | end
|
---|
798 |
|
---|
799 | %update the output path if needed
|
---|
800 | if ~(isfield(SeriesData,'InputPath') && strcmp(SeriesData.InputPath,InputPath))
|
---|
801 | if get(handles.OutputPathBrowse,'Value')==1 % fix the output path in manual mode
|
---|
802 | OutputPathOld=get(handles.OutputPath,'String');
|
---|
803 | OutputPath=uigetdir(OutputPathOld,'pick a root folder for output data');
|
---|
804 | set(handles.OutputPath,'String',OutputPath)
|
---|
805 | else %reproduce the input path for output
|
---|
806 | set(handles.OutputPath,'String',InputPath)
|
---|
807 | end
|
---|
808 | SeriesData.InputPath=InputPath;
|
---|
809 | end
|
---|
810 |
|
---|
811 | set(handles.series,'UserData',SeriesData)
|
---|
812 |
|
---|
813 | set(handles.InputTable,'BackgroundColor',[1 1 1])
|
---|
814 |
|
---|
815 | %% initiate input file series and refresh the current field view:
|
---|
816 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview);
|
---|
817 |
|
---|
818 | %% enable field and veltype menus, in accordance with the current action
|
---|
819 | ActionName_Callback([],[], handles)
|
---|
820 |
|
---|
821 | %% set length of waitbar
|
---|
822 | displ_time(handles)
|
---|
823 |
|
---|
824 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation)
|
---|
825 |
|
---|
826 | %------------------------------------------------------------------------
|
---|
827 | % --- Update information about a new field series (indices to scan, timing,
|
---|
828 | % calibration from an xml file
|
---|
829 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,iview)
|
---|
830 | %------------------------------------------------------------------------
|
---|
831 | InputTable=get(handles.InputTable,'Data');
|
---|
832 |
|
---|
833 | %% make the j indices visible if relevant
|
---|
834 | if (isempty(j1_series)|| ~isempty(j2_series))% no j series or j1-j2 pair
|
---|
835 | enable_j(handles,'off');
|
---|
836 | else
|
---|
837 | enable_j(handles,'on')%%%%remark: put series with j index at the end in the case of a list
|
---|
838 | end
|
---|
839 |
|
---|
840 | %% display the min and max indices for the whole file series
|
---|
841 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
|
---|
842 | MinIndex_j=1; % index j set to 1 by default
|
---|
843 | MaxIndex_j=1;
|
---|
844 | 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)
|
---|
845 | 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)
|
---|
846 | else
|
---|
847 | ref_i=squeeze(max(i1_series(1,:,:),[],2)); % select ref_j index for each ref_i
|
---|
848 | ref_j=squeeze(max(j1_series(1,:,:),[],3)); % select ref_i index for each ref_j
|
---|
849 | MinIndex_i=find(ref_i, 1 )-1;
|
---|
850 | MaxIndex_i=find(ref_i, 1, 'last' )-1;
|
---|
851 | MaxIndex_j=find(ref_j, 1, 'last' )-1;
|
---|
852 | MinIndex_j=find(ref_j, 1 )-1;
|
---|
853 | diff_j_max=diff(ref_j);
|
---|
854 | diff_i_max=diff(ref_i);
|
---|
855 | if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
|
---|
856 | set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
|
---|
857 | end
|
---|
858 | if ~isempty(diff_j_max) && isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
|
---|
859 | set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
|
---|
860 | end
|
---|
861 | end
|
---|
862 | if isequal(MinIndex_i,-1)
|
---|
863 | MinIndex_i=0;
|
---|
864 | end
|
---|
865 | if isequal(MinIndex_j,-1)
|
---|
866 | MinIndex_j=0;
|
---|
867 | end
|
---|
868 | MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
869 | MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
870 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data'); % retrieve the min indices in the table MinIndex
|
---|
871 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data'); % retrieve the min indices in the table MinIndex
|
---|
872 | if ~isempty(MinIndex_i)&&~isempty(MaxIndex_i)
|
---|
873 | MinIndex_i_table(iview,1)=MinIndex_i;
|
---|
874 | MaxIndex_i_table(iview,1)=MaxIndex_i;
|
---|
875 | end
|
---|
876 | if ~isempty(MinIndex_j)&&~isempty(MaxIndex_j)
|
---|
877 | MinIndex_j_table(iview,1)=MinIndex_j;
|
---|
878 | MaxIndex_j_table(iview,1)=MaxIndex_j;
|
---|
879 | end
|
---|
880 | set(handles.MinIndex_i,'Data',MinIndex_i_table)%display the min indices in the table MinIndex
|
---|
881 | set(handles.MinIndex_j,'Data',MinIndex_j_table)%display the max indices in the table MaxIndex
|
---|
882 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table)%display the min indices in the table MinIndex
|
---|
883 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex
|
---|
884 |
|
---|
885 |
|
---|
886 | SeriesData=get(handles.series,'UserData');
|
---|
887 |
|
---|
888 | %% adjust the first and last indices for the selected series, only if requested by the bounds
|
---|
889 | % i index, compare input to min index i
|
---|
890 | first_i=str2num(get(handles.num_first_i,'String')); % retrieve previous first i
|
---|
891 | % ref_i=str2num(get(handles.num_ref_i,'String')); % index i given by the input field
|
---|
892 | ref_i=1;
|
---|
893 | if isfield(SeriesData,'ref_i')
|
---|
894 | ref_i=SeriesData.ref_i;
|
---|
895 | end
|
---|
896 | if isempty(first_i)
|
---|
897 | first_i=ref_i; % first_i updated by the input value
|
---|
898 | elseif first_i < MinIndex_i
|
---|
899 | first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines)
|
---|
900 | elseif first_i >MaxIndex_i
|
---|
901 | first_i=MaxIndex_i; % first_i set to the max i index (restricted by oter input lines)
|
---|
902 | end
|
---|
903 | % j index, compare input to min index j
|
---|
904 | first_j=str2num(get(handles.num_first_j,'String'));
|
---|
905 | ref_j=1;
|
---|
906 | if isfield(SeriesData,'ref_j')
|
---|
907 | ref_j=SeriesData.ref_j;
|
---|
908 | end
|
---|
909 | if isempty(first_j)
|
---|
910 | first_j=ref_j; % first_j updated by the input value
|
---|
911 | elseif first_j<MinIndex_j
|
---|
912 | first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines)
|
---|
913 | elseif first_j >MaxIndex_j
|
---|
914 | first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines)
|
---|
915 | end
|
---|
916 | % i index, compare input to max index i
|
---|
917 | last_i=str2num(get(handles.num_last_i,'String'));
|
---|
918 | if isempty(last_i)
|
---|
919 | last_i=ref_i;
|
---|
920 | elseif last_i > MaxIndex_i
|
---|
921 | last_i=MaxIndex_i;
|
---|
922 | elseif last_i<first_i
|
---|
923 | last_i=first_i;
|
---|
924 | end
|
---|
925 | % j index, compare input to max index j
|
---|
926 | last_j=str2num(get(handles.num_last_j,'String'));
|
---|
927 | if isempty(last_j)
|
---|
928 | last_j=ref_j;
|
---|
929 | elseif last_j>MaxIndex_j
|
---|
930 | last_j=MaxIndex_j;
|
---|
931 | elseif last_j<first_j
|
---|
932 | last_j=first_j;
|
---|
933 | end
|
---|
934 | set(handles.num_first_i,'String',num2str(first_i));
|
---|
935 | set(handles.num_first_j,'String',num2str(first_j));
|
---|
936 | set(handles.num_last_i,'String',num2str(last_i));
|
---|
937 | set(handles.num_last_j,'String',num2str(last_j));
|
---|
938 |
|
---|
939 | %% number of slices set by default
|
---|
940 | NbSlice=[]; % default
|
---|
941 | % read value set by the first series for the append mode (iwiew >1)
|
---|
942 | if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
|
---|
943 | NbSlice=str2double(get(handles.num_NbSlice,'String'));
|
---|
944 | end
|
---|
945 |
|
---|
946 | %% default time settings
|
---|
947 | TimeUnit='';
|
---|
948 | % read value set by the first series for the append mode (iwiew >1)
|
---|
949 | if iview>1
|
---|
950 | TimeUnit=get(handles.TimeUnit,'String');
|
---|
951 | end
|
---|
952 | TimeName='';
|
---|
953 | Time=[]; % default
|
---|
954 | TimeMin=[];
|
---|
955 | TimeFirst=[];
|
---|
956 | TimeLast=[];
|
---|
957 | TimeMax=[];
|
---|
958 |
|
---|
959 | %% read image documentation file if found
|
---|
960 | XmlData=[];
|
---|
961 | check_calib=0;
|
---|
962 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2});
|
---|
963 | if ~isempty(XmlFileName)
|
---|
964 | [XmlData,errormsg]=imadoc2struct(XmlFileName);
|
---|
965 | if ~isempty(errormsg)
|
---|
966 | msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
|
---|
967 | end
|
---|
968 | % read time if available
|
---|
969 | if isfield(XmlData,'Time')
|
---|
970 | Time=XmlData.Time;
|
---|
971 | TimeName='xml';
|
---|
972 | end
|
---|
973 | if isfield(XmlData,'Camera')
|
---|
974 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
975 | if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit)
|
---|
976 | msgbox_uvmat('WARNING','inconsistent time unit with the first field series');
|
---|
977 | end
|
---|
978 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
979 | end
|
---|
980 | end
|
---|
981 | % number of slices
|
---|
982 | if isfield(XmlData,'TranslationMotor')&& isfield(XmlData.TranslationMotor,'NbSlice')
|
---|
983 | NbSlice_motor=XmlData.TranslationMotor.NbSlice;
|
---|
984 | if ~isempty(NbSlice) && ~isequal(NbSlice_motor,NbSlice)
|
---|
985 | msgbox_uvmat('WARNING','inconsistent Z numbers of Z indices');
|
---|
986 | else
|
---|
987 | NbSlice=NbSlice_motor;
|
---|
988 | end
|
---|
989 | end
|
---|
990 | end
|
---|
991 | if ~isempty(NbSlice)
|
---|
992 | set(handles.num_NbSlice,'String',num2str(NbSlice))
|
---|
993 | set(handles.num_NbSlice,'Visible','on')
|
---|
994 | end
|
---|
995 |
|
---|
996 | %% read timing from the current file (prioritary)
|
---|
997 | if ~isempty(VideoObject)% case of movies
|
---|
998 | imainfo=get(VideoObject);
|
---|
999 | if isfield(imainfo,'NumFrames')
|
---|
1000 | imainfo.NumberOfFrames=imainfo.NumFrames;
|
---|
1001 | end
|
---|
1002 | if isempty(j1_series) % frame index along i
|
---|
1003 | Time=zeros(imainfo.NumberOfFrames+1,2);
|
---|
1004 | Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
|
---|
1005 | else
|
---|
1006 | Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
|
---|
1007 | end
|
---|
1008 | TimeName='video';
|
---|
1009 | end
|
---|
1010 |
|
---|
1011 |
|
---|
1012 | %% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback
|
---|
1013 | if ~isempty(TimeName)
|
---|
1014 | if size(Time)<[MaxIndex_i+1 MaxIndex_j+1]
|
---|
1015 | msgbox_uvmat('WARNING',['incomplete time info in ' XmlFileName]);
|
---|
1016 | end
|
---|
1017 | TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
|
---|
1018 | if size(Time)>=[first_i+1 first_j+1]
|
---|
1019 | TimeFirst=Time(first_i+1,first_j+1);
|
---|
1020 | end
|
---|
1021 | if size(Time)>=[last_i+1 last_j+1]
|
---|
1022 | TimeLast=Time(last_i+1,last_j+1);
|
---|
1023 | end
|
---|
1024 | if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]
|
---|
1025 | TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
|
---|
1026 | end
|
---|
1027 | end
|
---|
1028 |
|
---|
1029 | %% update the time table
|
---|
1030 | TimeTable=get(handles.TimeTable,'Data');
|
---|
1031 | TimeTable{iview,1}=TimeName;
|
---|
1032 | TimeTable{iview,2}=TimeMin;
|
---|
1033 | TimeTable{iview,3}=TimeFirst;
|
---|
1034 | TimeTable{iview,4}=TimeLast;
|
---|
1035 | TimeTable{iview,5}=TimeMax;
|
---|
1036 | set(handles.TimeTable,'Data',TimeTable)
|
---|
1037 |
|
---|
1038 | %% update the series info in 'UserData'
|
---|
1039 | SeriesData.i1_series{iview}=i1_series;
|
---|
1040 | SeriesData.i2_series{iview}=i2_series;
|
---|
1041 | SeriesData.j1_series{iview}=j1_series;
|
---|
1042 | SeriesData.j2_series{iview}=j2_series;
|
---|
1043 | SeriesData.FileType{iview}=FileInfo.FileType;
|
---|
1044 | SeriesData.FileInfo{iview}=FileInfo;
|
---|
1045 | SeriesData.Time{iview}=Time;
|
---|
1046 |
|
---|
1047 | SeriesData.TimeName=TimeName;
|
---|
1048 |
|
---|
1049 | if check_calib
|
---|
1050 | SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
|
---|
1051 | end
|
---|
1052 | set(handles.series,'UserData',SeriesData)
|
---|
1053 |
|
---|
1054 | %% update pair menus
|
---|
1055 | hset_pair=findobj(allchild(0),'Tag','set_pairs');
|
---|
1056 | if ~isempty(hset_pair), delete(hset_pair); end % delete the GUI set_pair if opened
|
---|
1057 | CheckPair= ~isempty(i2_series)||~isempty(j2_series); % check whether index pairs need to be defined
|
---|
1058 | PairString=get(handles.PairString,'Data');
|
---|
1059 | if CheckPair% if pairs need to be display for line iview
|
---|
1060 | [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series);
|
---|
1061 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j,TimeName,InputTable(iview,:),FileInfo);
|
---|
1062 | PairString{iview,1}=Menu{1};
|
---|
1063 | else
|
---|
1064 | PairString{iview,1}=''; % no pair for #iview
|
---|
1065 | end
|
---|
1066 | set(handles.PairString,'Data',PairString)
|
---|
1067 | if isempty(find(cellfun('isempty',get(handles.PairString,'Data'))==0, 1))% if all lines of pairs are empty
|
---|
1068 | set(handles.PairString,'Visible','off')
|
---|
1069 | set(handles.SetPairs,'Visible','off')
|
---|
1070 | else
|
---|
1071 | set(handles.PairString,'Visible','on')
|
---|
1072 | set(handles.SetPairs,'Visible','on')
|
---|
1073 | end
|
---|
1074 |
|
---|
1075 |
|
---|
1076 | %% display the set of existing files as an image with black bands for gaps showing gaps in the series
|
---|
1077 | set(handles.FileStatus,'Units','pixels')
|
---|
1078 | Position=get(handles.FileStatus,'Position');
|
---|
1079 | set(handles.FileStatus,'Units','normalized')
|
---|
1080 | %xI=0.5:Position(3)-0.5;
|
---|
1081 | nbview=numel(SeriesData.i1_series);
|
---|
1082 | j_max=cell(1,nbview);
|
---|
1083 | MaxIndex_i=ones(1,nbview); % default
|
---|
1084 | MinIndex_i=ones(1,nbview); % default
|
---|
1085 | for iline=1:nbview
|
---|
1086 | pair_max=squeeze(max(SeriesData.i1_series{iline},[],1)); % max on pair index
|
---|
1087 | j_max{iline}=max(pair_max,[],1); % max on j index
|
---|
1088 | if ~isempty(j_max{iline})
|
---|
1089 | MaxIndex_i(iline)=find(j_max{iline}, 1, 'last' )-1; % max ref index i
|
---|
1090 | MinIndex_i(iline)=find(j_max{iline}, 1 )-1; % min ref index i
|
---|
1091 | end
|
---|
1092 | end
|
---|
1093 | MinIndex_i=min(MinIndex_i);
|
---|
1094 | MaxIndex_i=max(MaxIndex_i);
|
---|
1095 | range_index=MaxIndex_i-MinIndex_i+1;
|
---|
1096 | range_y=max(1,floor(Position(4)/nbview));
|
---|
1097 | npx=floor(Position(3));
|
---|
1098 | file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1;
|
---|
1099 | CData=zeros(nbview*range_y,npx); % initiate the image representing the existing files
|
---|
1100 | for iline=1:nbview
|
---|
1101 | ind_y=1+(iline-1)*range_y:iline*range_y;
|
---|
1102 | LineData=zeros(size(file_indices));
|
---|
1103 | file_select=file_indices(file_indices<=numel(j_max{iline}));
|
---|
1104 | ind_select=file_indices<=numel(j_max{iline});
|
---|
1105 | LineData(ind_select)=j_max{iline}(file_select)~=0;
|
---|
1106 | CData(ind_y,:)=ones(size(ind_y'))*LineData;
|
---|
1107 | end
|
---|
1108 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData))); % make color images r=0,g,b=0
|
---|
1109 | set(handles.FileStatus,'CData',CData);
|
---|
1110 |
|
---|
1111 | %-----------------------------------------------------------guide -------------
|
---|
1112 | %------------------------------------------------------------------------
|
---|
1113 | % III - FUNCTIONS ASSOCIATED TO THE FRAME IndexRange
|
---|
1114 | %------------------------------------------------------------------------
|
---|
1115 |
|
---|
1116 |
|
---|
1117 | % ---- determine the menu to put in mode and advice a default choice
|
---|
1118 | %------------------------------------------------------------------------
|
---|
1119 | function [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series)
|
---|
1120 | %------------------------------------------------------------------------
|
---|
1121 | ModeMenu={''};
|
---|
1122 | if isempty(j2_series)% no j pair
|
---|
1123 | ModeValue=1;
|
---|
1124 | if ~isempty(i2_series)
|
---|
1125 | ModeMenu={'series(Di)'}; % pair menu with only option Di
|
---|
1126 | end
|
---|
1127 | else %existence of j pairs
|
---|
1128 | pair_max=squeeze(max(i1_series,[],1)); % max on pair index
|
---|
1129 | j_max=max(pair_max,[],1);
|
---|
1130 | MaxIndex_i=find(j_max, 1, 'last' )-1; % max ref index i
|
---|
1131 | MinIndex_i=find(j_max, 1 )-1; % min ref index i
|
---|
1132 | i_max=max(pair_max,[],2);
|
---|
1133 | MaxIndex_j=find(i_max, 1, 'last' )-1; % max ref index i
|
---|
1134 | MinIndex_j=find(i_max, 1 )-1; % min ref index i
|
---|
1135 | if MaxIndex_j==MinIndex_j
|
---|
1136 | ModeValue=1;
|
---|
1137 | ModeMenu={'bursts'};
|
---|
1138 | elseif MaxIndex_i==MinIndex_i
|
---|
1139 | ModeValue=1;
|
---|
1140 | ModeMenu={'series(Dj)'};
|
---|
1141 | else
|
---|
1142 | ModeMenu={'bursts';'series(Dj)'};
|
---|
1143 | if (MaxIndex_j-MinIndex_j)>10
|
---|
1144 | ModeValue=2; % set mode to series(Dj) if more than 10 j values
|
---|
1145 | else
|
---|
1146 | ModeValue=1;
|
---|
1147 | end
|
---|
1148 | end
|
---|
1149 | end
|
---|
1150 |
|
---|
1151 |
|
---|
1152 | %------------------------------------------------------------------------
|
---|
1153 | %fill the menu of possible pairs as input
|
---|
1154 | function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo)
|
---|
1155 | %------------------------------------------------------------------------
|
---|
1156 | displ_pair={};
|
---|
1157 | if isempty(TimeUnit)
|
---|
1158 | dtunit='e-03';
|
---|
1159 | else
|
---|
1160 | dtunit=['m' TimeUnit];
|
---|
1161 | end
|
---|
1162 | switch mode
|
---|
1163 | case 'series(Di)'
|
---|
1164 | diff_i=i2_series-i1_series;
|
---|
1165 | min_diff=min(diff_i(diff_i>0));
|
---|
1166 | max_diff=max(diff_i(diff_i>0));
|
---|
1167 | for ipair=min_diff:max_diff
|
---|
1168 | if ~isempty(find(diff_i==ipair,1))% if the considered difference exists as input
|
---|
1169 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
|
---|
1170 | if size(time,1)>=ref_i+ceil(ipair/2)
|
---|
1171 | if ref_i<=floor(ipair/2)
|
---|
1172 | ref_i=floor(ipair/2)+1; % shift ref_i to get the first pair
|
---|
1173 | end
|
---|
1174 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j);
|
---|
1175 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
|
---|
1176 | end
|
---|
1177 | displ_pair=[displ_pair;{pair_string}];
|
---|
1178 | end
|
---|
1179 | end
|
---|
1180 | if ~isempty(displ_pair)
|
---|
1181 | displ_pair=[displ_pair;{'Di=*|*'}];
|
---|
1182 | end
|
---|
1183 | case 'series(Dj)'
|
---|
1184 | if isempty(j2_series)
|
---|
1185 | msgbox_uvmat('ERROR','no j1-j2 pair available')
|
---|
1186 | return
|
---|
1187 | end
|
---|
1188 | diff_j=j2_series-j1_series;
|
---|
1189 | min_diff=min(diff_j(diff_j>0));
|
---|
1190 | max_diff=max(diff_j(diff_j>0));
|
---|
1191 | for ipair=min_diff:max_diff
|
---|
1192 | if numel(diff_j(diff_j==ipair))>0
|
---|
1193 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
|
---|
1194 | if ~isempty(time)
|
---|
1195 | if ref_j<=floor(ipair/2)
|
---|
1196 | ref_j=floor(ipair/2)+1; % shift ref_i to get the first pair
|
---|
1197 | end
|
---|
1198 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2));
|
---|
1199 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
|
---|
1200 | end
|
---|
1201 | displ_pair=[displ_pair;{pair_string}];
|
---|
1202 | end
|
---|
1203 | end
|
---|
1204 | if ~isempty(displ_pair)
|
---|
1205 | displ_pair=[displ_pair;{'Dj=*|*'}];
|
---|
1206 | end
|
---|
1207 | case 'bursts'
|
---|
1208 | if isempty(j2_series)
|
---|
1209 | msgbox_uvmat('ERROR','no j1-j2 pair available')
|
---|
1210 | return
|
---|
1211 | end
|
---|
1212 | %diff_j=j2_series-j1_series;
|
---|
1213 | min_j1=min(j1_series(j1_series>0));
|
---|
1214 | max_j1=max(j1_series(j1_series>0));
|
---|
1215 | min_j2=min(j2_series(j2_series>0));
|
---|
1216 | max_j2=max(j2_series(j2_series>0));
|
---|
1217 | for pair1=min_j1:min(max_j1,min_j1+20)
|
---|
1218 | for pair2=min_j2:min(max_j2,min_j2+20)
|
---|
1219 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0
|
---|
1220 | pair_string=['j= ' num2str(pair1) '-' num2str(pair2)];
|
---|
1221 | [TimeValue,DtValue]=get_time(ref_i,[],pair_string,InputTable,FileInfo,TimeName,'Dt');
|
---|
1222 | %Dt=time(ref_i,pair2+1)-time(ref_i,pair1+1);
|
---|
1223 | pair_string=[pair_string ', Dt=' num2str(DtValue) ' ' dtunit];
|
---|
1224 | displ_pair=[displ_pair;{pair_string}];
|
---|
1225 | end
|
---|
1226 | end
|
---|
1227 | end
|
---|
1228 | if ~isempty(displ_pair)
|
---|
1229 | displ_pair=[displ_pair;{'j=*-*'}];
|
---|
1230 | end
|
---|
1231 | end
|
---|
1232 |
|
---|
1233 | %------------------------------------------------------------------------
|
---|
1234 | function num_first_i_Callback(hObject, eventdata, handles)
|
---|
1235 | %------------------------------------------------------------------------
|
---|
1236 | num_last_i_Callback(hObject, eventdata, handles)
|
---|
1237 |
|
---|
1238 | %------------------------------------------------------------------------
|
---|
1239 | function num_last_i_Callback(hObject, eventdata, handles)
|
---|
1240 | %------------------------------------------------------------------------
|
---|
1241 | SeriesData=get(handles.series,'UserData');
|
---|
1242 | if ~isfield(SeriesData,'Time')
|
---|
1243 | SeriesData.Time{1}=[];
|
---|
1244 | end
|
---|
1245 | displ_time(handles);
|
---|
1246 |
|
---|
1247 | %------------------------------------------------------------------------
|
---|
1248 | function num_first_j_Callback(hObject, eventdata, handles)
|
---|
1249 | %------------------------------------------------------------------------
|
---|
1250 | num_last_j_Callback(hObject, eventdata, handles)
|
---|
1251 |
|
---|
1252 | %------------------------------------------------------------------------
|
---|
1253 | function num_last_j_Callback(hObject, eventdata, handles)
|
---|
1254 | %------------------------------------------------------------------------
|
---|
1255 | SeriesData=get(handles.series,'UserData');
|
---|
1256 | if ~isfield(SeriesData,'Time')
|
---|
1257 | SeriesData.Time{1}=[];
|
---|
1258 | end
|
---|
1259 | displ_time(handles);
|
---|
1260 |
|
---|
1261 | %------------------------------------------------------------------------
|
---|
1262 | % ---- find the times corresponding to the first and last indices of a series
|
---|
1263 | function displ_time(handles)
|
---|
1264 | %------------------------------------------------------------------------
|
---|
1265 | SeriesData=get(handles.series,'UserData'); %
|
---|
1266 | if ~isfield(SeriesData,'Time')
|
---|
1267 | return
|
---|
1268 | end
|
---|
1269 | PairString=get(handles.PairString,'Data');
|
---|
1270 | ref_i_1=str2num(get(handles.num_first_i,'String')); % first reference index
|
---|
1271 | ref_i_2=str2num(get(handles.num_last_i,'String')); % last reference index
|
---|
1272 | ref_j_1=[];ref_j_2=[];
|
---|
1273 | if strcmp(get(handles.num_first_j,'Visible'),'on')
|
---|
1274 | ref_j_1=str2num(get(handles.num_first_j,'String'));
|
---|
1275 | ref_j_2=str2num(get(handles.num_last_j,'String'));
|
---|
1276 | end
|
---|
1277 | [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString);
|
---|
1278 | [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString);
|
---|
1279 | TimeTable=get(handles.TimeTable,'Data');
|
---|
1280 | %%%%%%
|
---|
1281 | %TODO: read time in netcdf file, see ActionName_Callback
|
---|
1282 | %%%%%%%
|
---|
1283 | %Pairs=get(handles.PairString,'Data');
|
---|
1284 | for iview=1:size(TimeTable,1)
|
---|
1285 | if numel(SeriesData.Time)<iview
|
---|
1286 | break
|
---|
1287 | end
|
---|
1288 | TimeTable{iview,3}=[];
|
---|
1289 | TimeTable{iview,4}=[];
|
---|
1290 | if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1)
|
---|
1291 | if isempty(ref_j_1)
|
---|
1292 | time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2;
|
---|
1293 | time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2;
|
---|
1294 | else
|
---|
1295 | time_first=(SeriesData.Time{iview}(i1_1+1,j1_1+1)+SeriesData.Time{iview}(i2_1+1,j2_1+1))/2;
|
---|
1296 | time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2;
|
---|
1297 | end
|
---|
1298 | TimeTable{iview,3}=time_first; % TODO: take into account pairs
|
---|
1299 | TimeTable{iview,4}=time_last; % TODO: take into account pairs
|
---|
1300 | end
|
---|
1301 | end
|
---|
1302 | set(handles.TimeTable,'Data',TimeTable)
|
---|
1303 |
|
---|
1304 | %% set the waitbar position with respect to the min and max in the series
|
---|
1305 | MinIndex_i=min(get(handles.MinIndex_i,'Data'));
|
---|
1306 | MaxIndex_i=max(get(handles.MaxIndex_i,'Data'));
|
---|
1307 | pos_first=(ref_i_1-MinIndex_i)/(MaxIndex_i-MinIndex_i+1);
|
---|
1308 | pos_last=(ref_i_2-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1);
|
---|
1309 | if isempty(pos_first), pos_first=0; end
|
---|
1310 | if isempty(pos_last), pos_last=1; end
|
---|
1311 | Position=get(handles.Waitbar,'Position'); % position of the waitbar:= [ x,y, width, height]
|
---|
1312 | Position_status=get(handles.FileStatus,'Position');
|
---|
1313 | Position(1)=Position_status(1)+Position_status(3)*pos_first;
|
---|
1314 | Position(3)=max(Position_status(3)*(pos_last-pos_first),0.001); % width must remain positive
|
---|
1315 | set(handles.Waitbar,'Position',Position)
|
---|
1316 | update_waitbar(handles.Waitbar,0)
|
---|
1317 |
|
---|
1318 | %------------------------------------------------------------------------
|
---|
1319 | % --- Executes when selected cell(s) is changed in PairString.
|
---|
1320 | function PairString_CellSelectionCallback(hObject, eventdata, handles)
|
---|
1321 | %------------------------------------------------------------------------
|
---|
1322 | if numel(eventdata.Indices)>=1
|
---|
1323 | PairString=get(hObject,'Data');
|
---|
1324 | if ~isempty(PairString{eventdata.Indices(1)})
|
---|
1325 | SetPairs_Callback(hObject, eventdata.Indices(1), handles)
|
---|
1326 | end
|
---|
1327 | end
|
---|
1328 |
|
---|
1329 |
|
---|
1330 | %-----------------------------------
|
---|
1331 | function enable_j(handles,state)
|
---|
1332 | set(handles.j_txt,'Visible',state)
|
---|
1333 | set(handles.num_first_j,'Visible',state)
|
---|
1334 | set(handles.num_last_j,'Visible',state)
|
---|
1335 | set(handles.num_incr_j,'Visible',state)
|
---|
1336 | set(handles.MinIndex_j,'Visible',state)
|
---|
1337 | set(handles.MaxIndex_j,'Visible',state)
|
---|
1338 |
|
---|
1339 |
|
---|
1340 | %%%%%%%%%%%%%%%%%%%%
|
---|
1341 | %% MAIN ActionName FUNCTIONS
|
---|
1342 | %%%%%%%%%%%%%%%%%%%%
|
---|
1343 | %------------------------------------------------------------------------
|
---|
1344 | % --- Executes on button press in RUN.
|
---|
1345 | %------------------------------------------------------------------------
|
---|
1346 | function RUN_Callback(hObject, eventdata, handles)
|
---|
1347 |
|
---|
1348 | %% settings of the button RUN
|
---|
1349 | if ~isequal(get(handles.ActionInput,'BackgroundColor'),[1 0 0])
|
---|
1350 | msgbox_uvmat('ERROR','first activate the button ActionInput')
|
---|
1351 | return
|
---|
1352 | end
|
---|
1353 | set(handles.RUN,'BusyAction','queue'); % activation of STOP button will set BusyAction to 'cancel'
|
---|
1354 | set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished
|
---|
1355 | set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color
|
---|
1356 | drawnow
|
---|
1357 | set(handles.status,'Value',0)% desable status display if relevant
|
---|
1358 | status_Callback([], eventdata, handles)
|
---|
1359 |
|
---|
1360 | %% launch action
|
---|
1361 | errormsg=launch_action(handles);
|
---|
1362 | if ~isempty(errormsg)
|
---|
1363 | msgbox_uvmat('ERROR',errormsg)
|
---|
1364 | end
|
---|
1365 |
|
---|
1366 | %% reset the GUI series
|
---|
1367 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
|
---|
1368 | set(handles.RUN, 'Enable','On')
|
---|
1369 | set(handles.RUN,'BackgroundColor',[1 0 0])
|
---|
1370 | set(handles.RUN, 'Value',0)
|
---|
1371 |
|
---|
1372 | %------------------------------------------------------------------------
|
---|
1373 | % --- called by RUN_Callback
|
---|
1374 | %------------------------------------------------------------------------
|
---|
1375 | % The calculations are launched in three different ways:
|
---|
1376 | % RunMode='local': calculation on the local Matlab session, will prevent other actions during that time.
|
---|
1377 | % RunMode='background': calculation on the local computer, but in a new Matlab session (with no graphic output).
|
---|
1378 | % RunMode='cluster': calculations dispatched in a cluster, using a managing system, 'oar, 'sge, or 'sgb'.
|
---|
1379 | % In the latter case, the calculation is split in 'packets' of i index (all j indices are contained in a single packet).
|
---|
1380 | % This splitting is possible only if the different calculations in the series are independent. Otherwise the action
|
---|
1381 | % function imposes a number of processes NbSlice in input, for instance NbSlice=1 for a time series.
|
---|
1382 | % If NbSlice is not imposed, the splitting in packets (jobs) is determined
|
---|
1383 | % so that a job is optimum length AdvisedJobCPUTime), and the total job number in any case smaller
|
---|
1384 | % than MaxJobNumber (these parameters are defined in the file series.xml in
|
---|
1385 | % accordance with the management strategy for the cluster). The jobs are
|
---|
1386 | % dispatched in parallel into NbCore processors by the cluster managing system.
|
---|
1387 |
|
---|
1388 | function errormsg=launch_action(handles)
|
---|
1389 | errormsg=''; % default
|
---|
1390 |
|
---|
1391 | %% read the data on the GUI series
|
---|
1392 | Param=read_GUI_series(handles); % displayed parameters
|
---|
1393 | SeriesData=get(handles.series,'UserData'); % hidden parameters
|
---|
1394 | if isfield(SeriesData,'TransformInput')
|
---|
1395 | Param.TransformInput=SeriesData.TransformInput;
|
---|
1396 | end
|
---|
1397 | if isfield(SeriesData,'ProjObject')
|
---|
1398 | Param.ProjObject=SeriesData.ProjObject;
|
---|
1399 | end
|
---|
1400 | if ~isfield(SeriesData,'i1_series')
|
---|
1401 | errormsg='The input field series needs to be refreshed: press REFRESH';
|
---|
1402 | return
|
---|
1403 | end
|
---|
1404 | if isfield(Param,'InputFields')&& isfield(Param.InputFields,'FieldName')&& isequal(Param.InputFields.FieldName,'add_field...')
|
---|
1405 | errormsg='input field name(s) not defined, select add_field...';
|
---|
1406 | return
|
---|
1407 | end
|
---|
1408 | [status,result]=system(['svn info ' Param.Action.ActionPath]);
|
---|
1409 | if status==0
|
---|
1410 | t=regexp(result,'R.vision\s*:\s*(?<rev>\d+)','names');%detect 'revision' or 'Revision' in the text
|
---|
1411 | if ~isempty(t)
|
---|
1412 | Param.UvmatRevision=t.rev; %version nbre of the current package
|
---|
1413 | end
|
---|
1414 | end
|
---|
1415 |
|
---|
1416 | %% select the Action mode, 'local', 'background' or 'cluster' (if available)
|
---|
1417 | RunMode='local'; % default (needed for first opening of the GUI series)
|
---|
1418 | if isfield(Param.Action,'RunMode')
|
---|
1419 | RunMode=Param.Action.RunMode;
|
---|
1420 | Param.Action=rmfield(Param.Action,'RunMode'); % remove from the recorded xml file to avoid interference during ImportConfig
|
---|
1421 | Param.RunMode=RunMode; % keep track of the mode
|
---|
1422 | end
|
---|
1423 | ActionExt='.m'; % default
|
---|
1424 | if isfield(Param.Action,'ActionExt')
|
---|
1425 | ActionExt=Param.Action.ActionExt; % '.m', '.sh' (compiled) or 'fluidimage' (Python)
|
---|
1426 | Param.Action=rmfield(Param.Action,'ActionExt'); % remove from the recorded xml file to avoid interference during ImportConfig
|
---|
1427 | end
|
---|
1428 | ActionName=Param.Action.ActionName;
|
---|
1429 | ActionPath=Param.Action.ActionPath;
|
---|
1430 | path_series=fileparts(which('series'));
|
---|
1431 |
|
---|
1432 | %% create the Action fct handle if RunMode option = 'local'
|
---|
1433 | if strcmp(RunMode,'local')
|
---|
1434 | current_dir=pwd; % current working dir
|
---|
1435 | cd(ActionPath)
|
---|
1436 | h_fun=str2func(ActionName);% create the function handle for the function ActionName
|
---|
1437 | cd(current_dir)
|
---|
1438 | % if ~isequal(ActionPath,path_series)
|
---|
1439 | %
|
---|
1440 | % %eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
|
---|
1441 | % if ~exist(ActionPath,'dir')
|
---|
1442 | % errormsg=['The prescribed function path ' ActionPath ' does not exist'];
|
---|
1443 | % return
|
---|
1444 | % end
|
---|
1445 | % spath=fileparts(which(ActionName));
|
---|
1446 | % if ~strcmp(spath,ActionPath)
|
---|
1447 | % addpath(ActionPath)% add the prescribed path if not the current one
|
---|
1448 | % end
|
---|
1449 | % end
|
---|
1450 | % eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION
|
---|
1451 | % if ~isequal(ActionPath,path_series)
|
---|
1452 | % rmpath(ActionPath)% add the prescribed path if not the current one
|
---|
1453 | % end
|
---|
1454 | end
|
---|
1455 |
|
---|
1456 | %% Get parameters from series.xml
|
---|
1457 | errormsg=''; % default error message
|
---|
1458 | ActionFullName=fullfile(get(handles.ActionPath,'String'),ActionName);
|
---|
1459 |
|
---|
1460 | %% If a compiled version has been selected (ext .sh) check wether it needs to be recompiled
|
---|
1461 | if strcmp(ActionExt,'.sh')
|
---|
1462 | TransformPath='';
|
---|
1463 | if isfield(SeriesData,'TransformPath')
|
---|
1464 | TransformPath=SeriesData.TransformPath;
|
---|
1465 | if isfield(SeriesData,'TransformList')
|
---|
1466 | TransformList=get(handles.TransformName,'String');
|
---|
1467 | TransformIndex=get(handles.TransformName,'Value');
|
---|
1468 | TransformName=TransformList{TransformIndex};
|
---|
1469 | if ~ismember(TransformName,SeriesData.TransformList)
|
---|
1470 | TransformPath='';
|
---|
1471 | end
|
---|
1472 | end
|
---|
1473 | end
|
---|
1474 | if ~isempty(TransformPath)&&...
|
---|
1475 | ~strcmp(TransformPath,get(handles.TransformPath,'String'))% if the transform is not in paths set for compilation
|
---|
1476 | msgbox_uvmat('ERROR', 'compilation not available for this transform function, select .m')
|
---|
1477 | return
|
---|
1478 | end
|
---|
1479 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
|
---|
1480 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
1481 | [mcrmajor, mcrminor] = mcrversion;
|
---|
1482 | MCRROOT = ['MCRROOT',int2str(mcrmajor),int2str(mcrminor)];
|
---|
1483 | RunTime = getenv('MCRROOT'); % Just variable MCRROOT with no version in it's name
|
---|
1484 | if strcmp(RunTime,'')
|
---|
1485 | RunTime = getenv(MCRROOT); % Use specialize MCRROOT with version
|
---|
1486 | end
|
---|
1487 | ActionNameVersion=[ActionName '_' MCRROOT];
|
---|
1488 | ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionNameVersion '.sh']);
|
---|
1489 | % compile the .m file if the .sh file does not exist yet
|
---|
1490 | if ~exist(ActionFullName,'file')
|
---|
1491 | answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
|
---|
1492 | if strcmp(answer,'Yes')
|
---|
1493 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
1494 | path_uvmat=fileparts(which('series'));
|
---|
1495 | currentdir=pwd;
|
---|
1496 | cd(get(handles.ActionPath,'String'))% go to the directory of Action
|
---|
1497 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
|
---|
1498 | compile(ActionName,TransformPath)
|
---|
1499 | cd(currentdir)
|
---|
1500 | else
|
---|
1501 | errormsg='Action launch interrupted';
|
---|
1502 | return
|
---|
1503 | end
|
---|
1504 | else
|
---|
1505 | sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionNameVersion '.sh']));
|
---|
1506 | m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
|
---|
1507 | if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
|
---|
1508 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
1509 | drawnow
|
---|
1510 | answer=msgbox_uvmat('INPUT_Y-N',[ActionNameVersion '.sh needs to be updated: recompile now?']);
|
---|
1511 | if strcmp(answer,'Yes')
|
---|
1512 | path_uvmat=fileparts(which('series'));
|
---|
1513 | currentdir=pwd;
|
---|
1514 | cd(get(handles.ActionPath,'String'))% go to the directory of Action
|
---|
1515 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
|
---|
1516 | addpath(fullfile(path_uvmat,'transform_field'))% add the path to transform functions to run the fct 'compile'
|
---|
1517 | compile(ActionName,TransformPath)
|
---|
1518 | cd(currentdir)
|
---|
1519 | end
|
---|
1520 | end
|
---|
1521 | end
|
---|
1522 |
|
---|
1523 | set(handles.ActionExt,'BackgroundColor',[1 1 1])
|
---|
1524 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch
|
---|
1525 | end
|
---|
1526 |
|
---|
1527 | %% set nbre of cluster cores and processes:
|
---|
1528 | % NbCore is the number of computer processors used
|
---|
1529 | % NbProcess is the number of independent processes in which the required calculation is split.
|
---|
1530 | % switch RunMode
|
---|
1531 | % case {'local','background'}
|
---|
1532 | % NbCore=1; % no need to split the calculation
|
---|
1533 | % case 'cluster'
|
---|
1534 | % %proposed number of cores to reserve in the cluster
|
---|
1535 | % NbCoreAdvised=SeriesData.SeriesParam.ClusterParam.NbCoreAdvised;
|
---|
1536 | % NbCoreMax=min(NbProcess,SeriesData.SeriesParam.ClusterParam.NbCoreMax);
|
---|
1537 | % if NbCoreMax~=1
|
---|
1538 | % if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
|
---|
1539 | % warning_string=', preferably use .sh option to save Matlab licences';
|
---|
1540 | % else
|
---|
1541 | % warning_string=')';
|
---|
1542 | % end
|
---|
1543 | % answer=msgbox_uvmat('INPUT_TXT',['Number of cores (max ' num2str(NbCoreMax) ', ' warning_string],num2str(NbCoreAdvised));
|
---|
1544 | % if isempty(answer)
|
---|
1545 | % errormsg='Action launch interrupted by user';
|
---|
1546 | % return
|
---|
1547 | % end
|
---|
1548 | % NbCore=str2double(answer);
|
---|
1549 | % if NbCore > NbCoreMax
|
---|
1550 | % NbCore=NbCoreMax;
|
---|
1551 | % end
|
---|
1552 | % else
|
---|
1553 | % NbCore=1;
|
---|
1554 | % end
|
---|
1555 | % end
|
---|
1556 | if ~isfield(Param.IndexRange,'NbSlice')
|
---|
1557 | Param.IndexRange.NbSlice=[];
|
---|
1558 | end
|
---|
1559 | OutputPath=get(handles.OutputPath,'String');
|
---|
1560 |
|
---|
1561 | %% Look for processing on multiple experiments set by the GUI browse_data
|
---|
1562 | NbExp=1;% initiate the number of experiments set by the GUI browse_data, =1 otherwise
|
---|
1563 | if get(handles.Replicate,'Value')
|
---|
1564 | hh=findobj(allchild(0),'Tag','browse_data');
|
---|
1565 | if isempty(hh)
|
---|
1566 | set(handles.Replicate,'Value',0)
|
---|
1567 | else
|
---|
1568 | set(handles.Replicate,'BackgroundColor',[1 1 0])%paint Relicate button in yellow
|
---|
1569 | BrowseData=guidata(hh);
|
---|
1570 | SourceDir=get(BrowseData.SourceDir,'String');
|
---|
1571 | ListExp=get(BrowseData.ListExperiments,'String');
|
---|
1572 | ExpIndices=get(BrowseData.ListExperiments,'Value');
|
---|
1573 | ListExp=ListExp(ExpIndices);
|
---|
1574 | ListDevices=get(BrowseData.ListDevices,'String');
|
---|
1575 | DeviceIndices=get(BrowseData.ListDevices,'Value');
|
---|
1576 | ListDevices=ListDevices(DeviceIndices);
|
---|
1577 | ListDataSeries=get(BrowseData.DataSeries,'String');
|
---|
1578 | DataSeriesIndices=get(BrowseData.DataSeries,'Value');
|
---|
1579 | ListDataSeries=ListDataSeries(DataSeriesIndices);
|
---|
1580 | NbExp=0; % counter of the number of experiments set by the GUI browse_data
|
---|
1581 | for iexp=1:numel(ListExp)
|
---|
1582 | if ~isempty(regexp(ListExp{iexp},'^\+/'))% if it is a folder
|
---|
1583 | %if strcmp(get(BrowseData.DataSeries,'enable'),'off') %case of a multiple input line for series
|
---|
1584 | % NbExp=NbExp+1;
|
---|
1585 | % ExpIndex{NbExp}=iexp;
|
---|
1586 | % for idevice=1:numel(ListDevices)
|
---|
1587 | % lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
1588 | % regexprep(ListDevices{idevice},'^\+/',''));
|
---|
1589 | % lpathout=fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
1590 | % regexprep(ListDevices{idevice},'^\+/',''));
|
---|
1591 | % ldir=regexprep(ListDataSeries{idevice},'^\+/','');
|
---|
1592 | % ListPath{idevice,NbExp}=lpath;
|
---|
1593 | % ListPathOut{idevice,NbExp}=lpathout;
|
---|
1594 | % ListSubdir{idevice,NbExp}=ldir;
|
---|
1595 | % end
|
---|
1596 | %else
|
---|
1597 | for idevice=1:numel(ListDevices)
|
---|
1598 | if ~isempty(regexp(ListDevices{idevice},'^\+/'))% if it is a folder
|
---|
1599 | for isubdir=1:numel(ListDataSeries)
|
---|
1600 | if ~isempty(regexp(ListDataSeries{isubdir},'^\+/'))% if it is a folder
|
---|
1601 | lpath= fullfile(SourceDir,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
1602 | regexprep(ListDevices{idevice},'^\+/',''));
|
---|
1603 | lpathout= fullfile(OutputPath,regexprep(ListExp{iexp},'^\+/',''),...
|
---|
1604 | regexprep(ListDevices{idevice},'^\+/',''));
|
---|
1605 | ldir= regexprep(ListDataSeries{isubdir},'^\+/','');
|
---|
1606 | if exist(fullfile(lpath,ldir),'dir')
|
---|
1607 | NbExp=NbExp+1;
|
---|
1608 | ExpIndex(NbExp)=ExpIndices(iexp);
|
---|
1609 | DeviceIndex(NbExp)=DeviceIndices(idevice);
|
---|
1610 | ListPath{NbExp}=lpath;
|
---|
1611 | ListPathOut{NbExp}=lpathout;
|
---|
1612 | ListDeviceOut{NbExp}=regexprep(ListDevices{idevice},'^\+/','');
|
---|
1613 | ListExpOut{NbExp}=regexprep(ListExp{iexp},'^\+/','');
|
---|
1614 | ListSubdir{NbExp}=ldir;
|
---|
1615 | end
|
---|
1616 | end
|
---|
1617 | end
|
---|
1618 | end
|
---|
1619 | end
|
---|
1620 | % end
|
---|
1621 | end
|
---|
1622 | end
|
---|
1623 | answer=msgbox_uvmat('INPUT_Y-N-Cancel',['replicate the processing on ' num2str(NbExp) ' data series']);
|
---|
1624 | if strcmp(answer,'Cancel')||strcmp(answer,'No')
|
---|
1625 | return
|
---|
1626 | end
|
---|
1627 | end
|
---|
1628 | end
|
---|
1629 |
|
---|
1630 | %%%%%%%%%%%%%%%%%%% LOOP ON EXPERIMENTS POSSIBLY SET BY THE GUI browse_data, NbExp=1 otherwise %%%%%%%%%
|
---|
1631 |
|
---|
1632 | for iexp=1:NbExp
|
---|
1633 | if get(handles.Replicate,'Value')
|
---|
1634 | if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
|
---|
1635 | disp('program stopped by user')
|
---|
1636 | return
|
---|
1637 | end
|
---|
1638 | set(BrowseData.ListExperiments,'Value',ExpIndex(iexp))
|
---|
1639 | set(BrowseData.ListDevices,'Value',DeviceIndex(iexp))
|
---|
1640 | Param.InputTable(:,1)=ListPath(:,iexp);
|
---|
1641 | Param.InputTable(:,2)=ListSubdir(:,iexp);
|
---|
1642 | OutputSubDir=unique(ListSubdir(:,iexp));
|
---|
1643 | Param.OutputSubDir=OutputSubDir{1};
|
---|
1644 | if numel(OutputSubDir)>1% case
|
---|
1645 | for iout=2:numel(OutputSubDir)
|
---|
1646 | Param.OutputSubDir=[Param.OutputSubDir '-' OutputSubDir{iout}];
|
---|
1647 | end
|
---|
1648 | end
|
---|
1649 | end
|
---|
1650 | [xx,ExpName]=fileparts(Param.InputTable{1,1});
|
---|
1651 | Param.IndexRange.first_i=str2num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess
|
---|
1652 | Param.IndexRange.last_i=str2num(get(handles.num_last_i,'String'));
|
---|
1653 |
|
---|
1654 | %% create the output data directory if needed, after checking its existence
|
---|
1655 | OutputDir='';
|
---|
1656 | answer='';
|
---|
1657 | if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt')% possibly update the output dir if it already exists
|
---|
1658 | PathOut=get(handles.OutputPath,'String');
|
---|
1659 | if ~exist(PathOut,'dir') % test if the dir already exist
|
---|
1660 | PathOut=uigetdir(PathOut,'pick the output root path');
|
---|
1661 | set(handles.OutputPath,'String',PathOut);
|
---|
1662 | end
|
---|
1663 | if get(handles.Replicate,'Value')
|
---|
1664 | PathExpOut=fileparts(ListPath{iexp});
|
---|
1665 | PathExpDeviceOut=ListPath{iexp};
|
---|
1666 | else
|
---|
1667 | PathExpOut=fullfile(PathOut,get(handles.Experiment,'String'));
|
---|
1668 | PathExpDeviceOut=fullfile(PathExpOut,get(handles.Device,'String'))
|
---|
1669 | end
|
---|
1670 | if ~exist(PathExpOut,'dir')
|
---|
1671 | [tild,msg1]=mkdir(PathExpOut);
|
---|
1672 | if ~strcmp(msg1,'')
|
---|
1673 | errormsg=['cannot create ' PathExpOut ': ' msg1]; % error message for directory creation
|
---|
1674 | return
|
---|
1675 | end
|
---|
1676 | end
|
---|
1677 | if ~exist(PathExpDeviceOut,'dir')
|
---|
1678 | [tild,msg1]=mkdir(PathExpDeviceOut);
|
---|
1679 | if ~strcmp(msg1,'')
|
---|
1680 | errormsg=['cannot create ' PathExpDeviceOut ': ' msg1]; % error message for directory creation
|
---|
1681 | return
|
---|
1682 | end
|
---|
1683 | end
|
---|
1684 |
|
---|
1685 | SubDirOut=[Param.OutputSubDir Param.OutputDirExt];
|
---|
1686 | SubDirOutNew=SubDirOut;
|
---|
1687 | detect=exist(fullfile(PathExpDeviceOut,SubDirOutNew),'dir'); % test if the dir already exist
|
---|
1688 | check_create=1; % need to create the result directory by default
|
---|
1689 | CheckOverwrite=1;
|
---|
1690 | if isfield(Param,'CheckOverwrite')
|
---|
1691 | CheckOverwrite=Param.CheckOverwrite;% will overwrite previous data if it is equal to 1
|
---|
1692 | end
|
---|
1693 | while detect
|
---|
1694 | if CheckOverwrite
|
---|
1695 | comment=', possibly overwrite previous data';
|
---|
1696 | else
|
---|
1697 | comment=', will complement existing result files (no overwriting)';
|
---|
1698 | end
|
---|
1699 | answer=msgbox_uvmat('INPUT_Y-N-Cancel',['use existing ouput directory: ' fullfile(PathExpDeviceOut,SubDirOutNew) comment]);
|
---|
1700 | if strcmp(answer,'Cancel')
|
---|
1701 | break
|
---|
1702 | elseif strcmp(answer,'Yes')
|
---|
1703 | detect=0;
|
---|
1704 | check_create=0;
|
---|
1705 | else
|
---|
1706 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names'); % detect whether name ends by a number
|
---|
1707 | if isempty(r)
|
---|
1708 | r(1).root=[SubDirOutNew '_'];
|
---|
1709 | r(1).num1='0';
|
---|
1710 | end
|
---|
1711 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)]; % increment the index by 1 or put 1
|
---|
1712 | detect=exist(fullfile(PathExpDeviceOut,SubDirOutNew),'dir'); % test if the dir already exists
|
---|
1713 | check_create=1;
|
---|
1714 | end
|
---|
1715 | end
|
---|
1716 | if strcmp(answer,'Cancel')
|
---|
1717 | continue
|
---|
1718 | end
|
---|
1719 | Param.OutputDirExt=regexprep(SubDirOutNew,['^' Param.OutputSubDir],'');
|
---|
1720 | Param.OutputRootFile=Param.InputTable{1,3}; % the first sorted RootFile taken for output
|
---|
1721 | OutputDir=fullfile(PathExpDeviceOut,[Param.OutputSubDir Param.OutputDirExt]); % full name (with path) of output directory
|
---|
1722 | if check_create % create output directory if it does not exist
|
---|
1723 | [tild,msg1]=mkdir(OutputDir);
|
---|
1724 | if ~strcmp(msg1,'')
|
---|
1725 | errormsg=['cannot create ' OutputDir ': ' msg1]; % error message for directory creation
|
---|
1726 | return
|
---|
1727 | end
|
---|
1728 | end
|
---|
1729 |
|
---|
1730 | elseif isfield(Param,'ActionInput')&&isfield(Param.ActionInput,'LogPath')% custom definition of the output dir
|
---|
1731 | OutputDir=Param.ActionInput.LogPath;
|
---|
1732 | end
|
---|
1733 | if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt')
|
---|
1734 | set(handles.OutputSubDir,'String',Param.OutputSubDir)
|
---|
1735 | set(handles.OutputDirExt,'String',Param.OutputDirExt)
|
---|
1736 | drawnow
|
---|
1737 | end
|
---|
1738 | if get(handles.Replicate,'Value')
|
---|
1739 | set(handles.InputTable,'Data',Param.InputTable)
|
---|
1740 | set(handles.OutputPath,'String',OutputPath)
|
---|
1741 | set(handles.Experiment,'String',ListExpOut{iexp})
|
---|
1742 | set(handles.Device,'String',ListDeviceOut{iexp})
|
---|
1743 | Param.Experiment=ListExpOut{iexp};
|
---|
1744 | Param.Device=ListDeviceOut{iexp};
|
---|
1745 | check_input_file_series(handles)
|
---|
1746 | end
|
---|
1747 | DirXml=fullfile(OutputDir,'0_XML');
|
---|
1748 | if ~exist(DirXml,'dir')
|
---|
1749 | [~,msg1]=mkdir(DirXml);
|
---|
1750 | if ~strcmp(msg1,'')
|
---|
1751 | errormsg=['cannot create ' DirXml ': ' msg1]; % error message for directory creation
|
---|
1752 | return
|
---|
1753 | end
|
---|
1754 | [success,msg] = fileattrib(DirXml,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
1755 | if success==0
|
---|
1756 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg}); % error message for directory creation
|
---|
1757 | end
|
---|
1758 | end
|
---|
1759 | OutputNomType=nomtype2pair(Param.InputTable{1,4}); % nomenclature for output files
|
---|
1760 |
|
---|
1761 | %% get the set of reference input field indices
|
---|
1762 | first_i=1; % first i index to process
|
---|
1763 | last_i=1; % last i index to process
|
---|
1764 | incr_i=1; % increment step in i index
|
---|
1765 | first_j=1; % first j index to process
|
---|
1766 | last_j=1; % last j index to process
|
---|
1767 | incr_j=1; % increment step in j index
|
---|
1768 | if isfield(Param.IndexRange,'first_i')
|
---|
1769 | first_i=Param.IndexRange.first_i;
|
---|
1770 | incr_i=Param.IndexRange.incr_i;
|
---|
1771 | last_i=Param.IndexRange.last_i;
|
---|
1772 | end
|
---|
1773 | if isfield(Param.IndexRange,'incr_j')
|
---|
1774 | first_j=Param.IndexRange.first_j;
|
---|
1775 | last_j=Param.IndexRange.last_j;
|
---|
1776 | incr_j=Param.IndexRange.incr_j;
|
---|
1777 | end
|
---|
1778 | if last_i < first_i || last_j < first_j
|
---|
1779 | errormsg= 'series/Run_Callback:last field index must be larger or equal to the first one';
|
---|
1780 | return
|
---|
1781 | end
|
---|
1782 | %incr_i must be defined, =1 by default, if NbSlice is active
|
---|
1783 | if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice)
|
---|
1784 | incr_i=1;
|
---|
1785 | set(handles.num_incr_i,'String','1')
|
---|
1786 | end
|
---|
1787 | % case of no increment i defined: processing is done on the available files found in i1_series
|
---|
1788 | if isempty(incr_i)
|
---|
1789 | if isempty(incr_j)
|
---|
1790 | [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
1791 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
|
---|
1792 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
|
---|
1793 | ref_j=ref_j-1;
|
---|
1794 | ref_i=ref_i-1;
|
---|
1795 | else
|
---|
1796 | ref_j=first_j:incr_j:last_j;
|
---|
1797 | [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
1798 | ref_i=ref_i-1;
|
---|
1799 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
|
---|
1800 | end
|
---|
1801 | % increment i is defined: processing is done on first_i:incr_i:last_i;
|
---|
1802 | else
|
---|
1803 | ref_i=first_i:incr_i:last_i;
|
---|
1804 | if isempty(incr_j)% automatic finding of the existing j indices
|
---|
1805 | [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
1806 | ref_j=ref_j-1;
|
---|
1807 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
|
---|
1808 | else
|
---|
1809 | ref_j=first_j:incr_j:last_j;
|
---|
1810 | end
|
---|
1811 | end
|
---|
1812 | nbfield_j=numel(ref_j); % number of j indices
|
---|
1813 | BlockLength=numel(ref_i); % by default, job involves the full set of i field indicesNbProcess
|
---|
1814 | NbProcess=1;
|
---|
1815 | NbCore=1;
|
---|
1816 | switch RunMode
|
---|
1817 | case 'cluster'
|
---|
1818 | if (isfield(Param.Action, 'CPUTime') && ~isempty(Param.Action.CPUTime) && isnumeric(Param.Action.CPUTime))
|
---|
1819 | CPUTime=Param.Action.CPUTime; % Note: CpUTime for one iteration ref_i has to be multiplied by the number of j indices nbfield_j
|
---|
1820 | else
|
---|
1821 | answer=msgbox_uvmat('INPUT_TXT','estimate the CPU time(in minutes) for each value of index i:' ,'');
|
---|
1822 | CPUTime=str2num(answer);
|
---|
1823 | set(handles.num_CPUTime,'String',answer)
|
---|
1824 | Param.Action.CPUTime=CPUTime;
|
---|
1825 | end
|
---|
1826 | JobNumberMax=SeriesData.SeriesParam.ClusterParam.JobNumberMax;
|
---|
1827 | JobCPUTimeAdvised=SeriesData.SeriesParam.ClusterParam.JobCPUTimeAdvised;
|
---|
1828 | if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined
|
---|
1829 | BlockLength= ceil(JobCPUTimeAdvised/(CPUTime*nbfield_j)); % iterations are grouped in sets with length BlockLength such that the typical CPU time of a job is JobCPUTimeAdvised.
|
---|
1830 | BlockLength=max(BlockLength,ceil(numel(ref_i)*NbExp/JobNumberMax)); % possibly increase the BlockLength to have less than MaxJobNumber jobs
|
---|
1831 | NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
|
---|
1832 | else
|
---|
1833 | NbProcess=Param.IndexRange.NbSlice; % the parameter NbSlice sets the nbre of run processes
|
---|
1834 | end
|
---|
1835 |
|
---|
1836 | % %proposed number of cores to reserve in the cluster
|
---|
1837 | NbCoreAdvised=SeriesData.SeriesParam.ClusterParam.NbCoreAdvised;
|
---|
1838 | NbCoreMax=min(NbProcess,SeriesData.SeriesParam.ClusterParam.NbCoreMax);% reduces the number of cores if it exceeds the number of processes
|
---|
1839 | if NbCoreMax~=1
|
---|
1840 | if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
|
---|
1841 | warning_string=', preferably use .sh option to save Matlab licences';
|
---|
1842 | else
|
---|
1843 | warning_string=')';
|
---|
1844 | end
|
---|
1845 | answer=msgbox_uvmat('INPUT_TXT',['Number of cores (max ' num2str(NbCoreMax) ', ' warning_string],num2str(NbCoreAdvised));
|
---|
1846 | if isempty(answer)
|
---|
1847 | errormsg='Action launch interrupted by user';
|
---|
1848 | return
|
---|
1849 | end
|
---|
1850 | NbCore=str2double(answer);
|
---|
1851 | if NbCore > NbCoreMax
|
---|
1852 | NbCore=NbCoreMax;
|
---|
1853 | end
|
---|
1854 | end
|
---|
1855 | otherwise
|
---|
1856 | if ~isempty(Param.IndexRange.NbSlice)
|
---|
1857 | NbProcess=Param.IndexRange.NbSlice; % the parameter NbSlice sets the nbre of run processes
|
---|
1858 | end
|
---|
1859 | end
|
---|
1860 |
|
---|
1861 | %% record nbre of output files and starting time for computation for status
|
---|
1862 | StatusData=get(handles.status,'UserData');
|
---|
1863 | if isfield(StatusData,'OutputFileMode')
|
---|
1864 | switch StatusData.OutputFileMode
|
---|
1865 | case 'NbInput'
|
---|
1866 | StatusData.NbOutputFile=numel(ref_i)*nbfield_j;
|
---|
1867 | case 'NbInput_i'
|
---|
1868 | StatusData.NbOutputFile=numel(ref_i);
|
---|
1869 | case 'NbSlice'
|
---|
1870 | StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
|
---|
1871 | end
|
---|
1872 | end
|
---|
1873 | StatusData.TimeStart=now;
|
---|
1874 | set(handles.status,'UserData',StatusData)
|
---|
1875 |
|
---|
1876 | %% case of a function in Python
|
---|
1877 | if strcmp(ActionExt, 'fluidimage')
|
---|
1878 | fprintf([
|
---|
1879 | '\n' ...
|
---|
1880 | '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' ...
|
---|
1881 | 'The computation should be done by fluidimage (https://fluidimage.readthedocs.io).\n' ...
|
---|
1882 | 'Warning: Fluidimage parameters will be guessed from UVmat parameters but \n' ...
|
---|
1883 | 'there is no direct correspondance between UVMAT and fluidimage parameters.\n' ...
|
---|
1884 | 'Please report issues here https://foss.heptapod.net/fluiddyn/fluidimage/-/issues\n' ...
|
---|
1885 | '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'])
|
---|
1886 | RunMode = 'python';
|
---|
1887 | end
|
---|
1888 |
|
---|
1889 |
|
---|
1890 | %% direct processing on the current Matlab session or creation of command files
|
---|
1891 | filexml=cell(1,NbProcess); % initialisation of the names of the files containing the processing parameters
|
---|
1892 | extxml=cell(1,NbProcess); % initialisation of the set of labels used for the files documenting each process
|
---|
1893 | for iprocess=1:NbProcess
|
---|
1894 | extxml{iprocess}='.xml';
|
---|
1895 | end
|
---|
1896 | for iprocess=1:NbProcess
|
---|
1897 | if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
|
---|
1898 | disp('program stopped by user')
|
---|
1899 | return
|
---|
1900 | end
|
---|
1901 | Param.IndexRange.incr_slice=incr_i;
|
---|
1902 | if isempty(Param.IndexRange.NbSlice)
|
---|
1903 | Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
|
---|
1904 | if Param.IndexRange.first_i>last_i
|
---|
1905 | NbProcess=iprocess-1; % leave the loop, we are at the end of the calculation
|
---|
1906 | break
|
---|
1907 | end
|
---|
1908 | Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
|
---|
1909 | else %multislices (then incr_i is not empty)
|
---|
1910 | Param.IndexRange.first_i= first_i+iprocess-1;
|
---|
1911 | Param.IndexRange.incr_slice=incr_i*Param.IndexRange.NbSlice;
|
---|
1912 | end
|
---|
1913 | for ilist=1:size(Param.InputTable,1)
|
---|
1914 | Param.InputTable{ilist,1}=regexprep(Param.InputTable{ilist,1},'\','/'); % correct path name for PCWIN system
|
---|
1915 | end
|
---|
1916 |
|
---|
1917 | if isfield(Param,'OutputSubDir')
|
---|
1918 | t=struct2xml(Param);
|
---|
1919 | t=set(t,1,'name','Series');
|
---|
1920 | extxml{iprocess}=fullfile_uvmat('','',Param.InputTable{1,3},'.xml',OutputNomType,...
|
---|
1921 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
|
---|
1922 | filexml{iprocess}=fullfile(OutputDir,'0_XML',extxml{iprocess});
|
---|
1923 | try
|
---|
1924 | save(t, filexml{iprocess}); % save the xml file containing the processing parameters
|
---|
1925 | catch ME
|
---|
1926 | if ~strcmp (RunMode,'local')
|
---|
1927 | errormsg=['error writting ' filexml{iprocess} ': ' ME.message];
|
---|
1928 | return
|
---|
1929 | end
|
---|
1930 | end
|
---|
1931 | end
|
---|
1932 | if strcmp (RunMode,'local')
|
---|
1933 | switch ActionExt
|
---|
1934 | case '.m'
|
---|
1935 | h_fun(Param); % direct launching
|
---|
1936 |
|
---|
1937 | case '.sh'
|
---|
1938 | switch computer
|
---|
1939 | case {'PCWIN','PCWIN64'} %Windows system
|
---|
1940 | filexml=regexprep(filexml,'\\','\\\\'); % add '\' so that '\' are left as characters
|
---|
1941 | system([ActionFullName ' ' RunTime ' ' filexml{iprocess}]); % TODO: adapt to DOS system
|
---|
1942 | case {'GLNX86','GLNXA64','MACI64'}%Linux system
|
---|
1943 | system([ActionFullName ' ' RunTime ' ' filexml{iprocess}]);
|
---|
1944 | end
|
---|
1945 | end
|
---|
1946 | end
|
---|
1947 | end
|
---|
1948 |
|
---|
1949 | if ~strcmp (RunMode,'local') && ~strcmp(RunMode,'python')
|
---|
1950 | %% processing on a different session of the same computer (background) or cluster, create executable files
|
---|
1951 | batch_file_list=cell(NbProcess,1); % initiate the list of executable files
|
---|
1952 | DirExe=fullfile(OutputDir,'0_EXE'); % directory name for executable files
|
---|
1953 | switch computer
|
---|
1954 | case {'PCWIN','PCWIN64'} %Windows system
|
---|
1955 | ExeExt='.bat';
|
---|
1956 | case {'GLNX86','GLNXA64','MACI64'}%Linux system
|
---|
1957 | ExeExt='.sh';
|
---|
1958 | end
|
---|
1959 | %create subdirectory for executable files
|
---|
1960 | if ~exist(DirExe,'dir')
|
---|
1961 | [tild,msg1]=mkdir(DirExe);
|
---|
1962 | if ~strcmp(msg1,'')
|
---|
1963 | errormsg=['cannot create ' DirExe ': ' msg1]; % error message for directory creation
|
---|
1964 | return
|
---|
1965 | end
|
---|
1966 | [success,msg] = fileattrib(DirExe,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
1967 | if success==0
|
---|
1968 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirExe ':']; msg}); % error message for directory creation
|
---|
1969 | end
|
---|
1970 | end
|
---|
1971 | %create subdirectory for log files
|
---|
1972 | DirLog=fullfile(OutputDir,'0_LOG');
|
---|
1973 | if ~exist(DirLog,'dir')
|
---|
1974 | [tild,msg1]=mkdir(DirLog);
|
---|
1975 | if ~strcmp(msg1,'')
|
---|
1976 | errormsg=['cannot create ' DirLog ': ' msg1]; % error message for directory creation
|
---|
1977 | return
|
---|
1978 | end
|
---|
1979 | [success,msg] = fileattrib(DirLog,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
1980 | if success==0
|
---|
1981 | msgbox_uvmat('WARNING',{['unable to set group write access to ' DirLog ':']; msg}); % error message for directory creation
|
---|
1982 | end
|
---|
1983 | end
|
---|
1984 |
|
---|
1985 | %create the executable and log file names
|
---|
1986 | file_exe_global=fullfile_uvmat('','',Param.InputTable{1,3},ExeExt,OutputNomType,...
|
---|
1987 | first_i,last_i,first_j,last_j);
|
---|
1988 | file_exe_global=fullfile(OutputDir,'0_EXE',file_exe_global);
|
---|
1989 | filelog_global=fullfile_uvmat('','',Param.InputTable{1,3},'.log',OutputNomType,...
|
---|
1990 | first_i,last_i,first_j,last_j);
|
---|
1991 | filelog_global=fullfile(OutputDir,'0_LOG',filelog_global);
|
---|
1992 |
|
---|
1993 | for iprocess=1:NbProcess
|
---|
1994 | batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt)); % executable file names
|
---|
1995 | filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));% corresponding log file names
|
---|
1996 | end
|
---|
1997 | end
|
---|
1998 |
|
---|
1999 | %% launch the executable files for background or cluster processing
|
---|
2000 |
|
---|
2001 | switch RunMode
|
---|
2002 |
|
---|
2003 | case 'background'
|
---|
2004 | [fid,message]=fopen(file_exe_global,'w');
|
---|
2005 | if isequal(fid,-1)
|
---|
2006 | errormsg=['creation of ' file_exe_global ':' message];
|
---|
2007 | return
|
---|
2008 | end
|
---|
2009 | switch ActionExt
|
---|
2010 | case '.m'% Matlab function
|
---|
2011 | switch computer
|
---|
2012 | case {'GLNX86','GLNXA64','MACI64'}
|
---|
2013 | cmd=command_launch_matlab(filelog_global,path_series,Param.Action.ActionPath,Param.Action.ActionName,filexml,'background');
|
---|
2014 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
2015 | fclose(fid); % close the executable filefilelog_global
|
---|
2016 | system(['chmod +x ' file_exe_global]); % set the file to executable
|
---|
2017 | case {'PCWIN','PCWIN64'}
|
---|
2018 | cmd=['matlab -automation -logfile ' regexprep(filelog{iprocess},'\\','\\\\')...
|
---|
2019 | ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
|
---|
2020 | 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'];
|
---|
2021 | for iprocess=1:NbProcess
|
---|
2022 | cmd=[cmd '' Param.Action.ActionName '( ''' regexprep(filexml{iprocess},'\\','\\\\') ''');']
|
---|
2023 | end
|
---|
2024 | cmd=[cmd ';exit"'];
|
---|
2025 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
2026 | fclose(fid); % close the executable file
|
---|
2027 | end
|
---|
2028 | system([file_exe_global ' &'])% directly execute the command file
|
---|
2029 | case '.sh' % compiled Matlab function
|
---|
2030 | for iprocess=1:NbProcess
|
---|
2031 | switch computer
|
---|
2032 | case {'GLNX86','GLNXA64','MACI64'}
|
---|
2033 | [fid,message]=fopen(batch_file_list{iprocess},'w'); % create the executable file
|
---|
2034 | if isequal(fid,-1)
|
---|
2035 | errormsg=['creation of .bat file: ' message];
|
---|
2036 | return
|
---|
2037 | end
|
---|
2038 | cmd=['#!/bin/bash \n '...
|
---|
2039 | '#$ -cwd \n '...
|
---|
2040 | 'hostname && date \n '...
|
---|
2041 | 'umask 002 \n'...
|
---|
2042 | ActionFullName ' ' RunTime ' ' filexml{iprocess}]; % allow writting access to created files for user group
|
---|
2043 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
2044 | fclose(fid); % close the executable file
|
---|
2045 | system(['chmod +x ' batch_file_list{iprocess}]); % set the file to executable
|
---|
2046 | system([batch_file_list{iprocess} ' &'])% directly execute the command file
|
---|
2047 | case {'PCWIN','PCWIN64'}
|
---|
2048 | msgbox_uvmat('ERROR','option for compiled Matlab functions not implemented for Windows system')
|
---|
2049 | return
|
---|
2050 | end
|
---|
2051 | end
|
---|
2052 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched in background for ' ExpName ': press STATUS to see results'])
|
---|
2053 | end
|
---|
2054 |
|
---|
2055 | case 'cluster' % option 'oar-parexec' used
|
---|
2056 | %create subdirectory for oar commands
|
---|
2057 | for iprocess=1:NbProcess
|
---|
2058 | [fid,message]=fopen(batch_file_list{iprocess},'w'); % create the executable file
|
---|
2059 | if isequal(fid,-1)
|
---|
2060 | errormsg=['creation of .bat file: ' message];
|
---|
2061 | return
|
---|
2062 | end
|
---|
2063 | if strcmp(ActionExt,'.sh')
|
---|
2064 | cmd=['#!/bin/bash \n '...
|
---|
2065 | '#$ -cwd \n '...
|
---|
2066 | 'hostname && date \n '...
|
---|
2067 | 'umask 002 \n'...
|
---|
2068 | ActionFullName ' ' RunTime ' ' filexml{iprocess}]; % allow writting access to created files for user group
|
---|
2069 | else
|
---|
2070 | cmd=command_launch_matlab(filelog_global,path_series,Param.Action.ActionPath,Param.Action.ActionName,filexml{iprocess},'cluster');
|
---|
2071 |
|
---|
2072 | end
|
---|
2073 | fprintf(fid,cmd); % fill the executable file with the char string cmd
|
---|
2074 | fclose(fid); % close the executable file
|
---|
2075 | system(['chmod +x ' batch_file_list{iprocess}]); % set the file to executable
|
---|
2076 | end
|
---|
2077 | DIR_CLUSTER=fullfile(OutputDir,'0_CLUSTER');
|
---|
2078 | if exist(DIR_CLUSTER,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
2079 | curdir=pwd;
|
---|
2080 | cd(DIR_CLUSTER)
|
---|
2081 | delete('*')
|
---|
2082 | cd(curdir)
|
---|
2083 | else
|
---|
2084 | [tild,msg1]=mkdir(DIR_CLUSTER);
|
---|
2085 | if ~strcmp(msg1,'')
|
---|
2086 | errormsg=['cannot create ' DIR_CLUSTER ': ' msg1]; % error message for directory creation
|
---|
2087 | return
|
---|
2088 | end
|
---|
2089 | end
|
---|
2090 | % create file containing the list of jobs
|
---|
2091 | ListProcess=fullfile(DIR_CLUSTER,'job_list.txt'); % name of the file containing the list of executables
|
---|
2092 | [fid,errormsg]=fopen(ListProcess,'w'); % open it for writting
|
---|
2093 | if isempty(errormsg)
|
---|
2094 | for iprocess=1:length(batch_file_list)
|
---|
2095 | fprintf(fid,[batch_file_list{iprocess} '\n']); % write list of exe files
|
---|
2096 | end
|
---|
2097 | fclose(fid);
|
---|
2098 | system(['chmod +x ' ListProcess]); % set the file to executable
|
---|
2099 | else
|
---|
2100 | errormsg=['error for writting the executable file:' errormsg];
|
---|
2101 | end
|
---|
2102 | CPUTimeProcess=CPUTime*BlockLength*nbfield_j; % estimated CPU time for one individual process (in minutes)
|
---|
2103 | LaunchCmdFcn=SeriesData.SeriesParam.ClusterParam.LaunchCmdFcn;% command obtained from the function
|
---|
2104 | oar_command=feval(LaunchCmdFcn,ListProcess,ActionFullName,DirLog,NbProcess, NbCore,CPUTimeProcess)
|
---|
2105 | [status,result]=system(oar_command)% execute system command and show the result (ID number of the launched job) on the Matlab command window
|
---|
2106 | filename_oarcommand=fullfile(DIR_CLUSTER,'0_cluster_command'); % keep track of the command in file '0-OAR/0_cluster_command'
|
---|
2107 | [fid,errormsg]=fopen(filename_oarcommand,'w');
|
---|
2108 | if ~isempty(errormsg)
|
---|
2109 | msgbox_uvmat('ERROR',['cannot create ' filename_oarcommand ': ' errormsg])
|
---|
2110 | return
|
---|
2111 | end
|
---|
2112 | fprintf(fid,oar_command); % store the command
|
---|
2113 | fprintf(fid,result); % store the result (job ID number)
|
---|
2114 | fclose(fid);
|
---|
2115 | if status==0
|
---|
2116 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched for ' ExpName ' as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
|
---|
2117 | else
|
---|
2118 | msgbox_uvmat('ERROR',result)
|
---|
2119 | end
|
---|
2120 | % case 'cluster_pbs' % for LMFA Kepler machine: trqnsferred to fct
|
---|
2121 |
|
---|
2122 | % %create subdirectory for pbs command and log files
|
---|
2123 | % DirPBS=fullfile(OutputDir,'0_PBS'); % todo : common name OAR/PBS
|
---|
2124 | % if exist(DirPBS,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
2125 | % curdir=pwd;
|
---|
2126 | % cd(DirPBS)
|
---|
2127 | % delete('*')
|
---|
2128 | % cd(curdir)
|
---|
2129 | % else
|
---|
2130 | % [tild,msg1]=mkdir(DirPBS);
|
---|
2131 | % if ~strcmp(msg1,'')
|
---|
2132 | % errormsg=['cannot create ' DirPBS ': ' msg1]; % error message for directory creation
|
---|
2133 | % return
|
---|
2134 | % end
|
---|
2135 | % end
|
---|
2136 | % max_walltime=3600*20; % 20h max total calculation (cannot exceed 24 h)
|
---|
2137 | % walltime_onejob=1800; % seconds, max estimated time for asingle file index value
|
---|
2138 | % ListProcess=fullfile(DirPBS,'job_list.txt'); % create name of the global executable file
|
---|
2139 | % fid=fopen(ListProcess,'w');
|
---|
2140 | % for iprocess=1:length(batch_file_list)
|
---|
2141 | % fprintf(fid,[batch_file_list{iprocess} '\n']); % list of exe files
|
---|
2142 | % end
|
---|
2143 | % fclose(fid);
|
---|
2144 | % system(['chmod +x ' ListProcess]); % set the file to executable
|
---|
2145 | % pbs_command=['qsub -n CIVX '...
|
---|
2146 | % '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
|
---|
2147 | % '-l /core=' num2str(NbCore) ','...
|
---|
2148 | % 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '...
|
---|
2149 | % '-E ' regexprep(ListProcess,'\.txt\>','.stderr') ' '...
|
---|
2150 | % '-O ' regexprep(ListProcess,'\.txt\>','.log') ' '...
|
---|
2151 | % extra_qstat ' '...
|
---|
2152 | % '"oar-parexec -s -f ' ListProcess ' '...
|
---|
2153 | % '-l ' ListProcess '.log"'];
|
---|
2154 | % filename_oarcommand=fullfile(DirPBS,'pbs_command');
|
---|
2155 | % fid=fopen(filename_oarcommand,'w');
|
---|
2156 | % fprintf(fid,pbs_command);
|
---|
2157 | % fclose(fid);
|
---|
2158 | % fprintf(pbs_command); % display in command line
|
---|
2159 | % %system(pbs_command);
|
---|
2160 | % msgbox_uvmat('CONFIRMATION',[ActionFullName ' command ready to be launched in cluster'])
|
---|
2161 |
|
---|
2162 | case 'cluster_sge' % for PSMN % TODO: use the standard 'cluster' config with an external fct
|
---|
2163 | % Au PSMN, on ne cr??e pas 1 job avec plusieurs c??urs, mais N jobs de 1 c??urs
|
---|
2164 | % o?? N < 1000.
|
---|
2165 | %create subdirectory for pbs command and log files
|
---|
2166 |
|
---|
2167 | DirSGE=fullfile(OutputDir,'0_SGE');
|
---|
2168 | if exist(DirSGE,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
2169 | curdir=pwd;
|
---|
2170 | cd(DirSGE)
|
---|
2171 | delete('*')
|
---|
2172 | cd(curdir)
|
---|
2173 | else
|
---|
2174 | [tild,msg1]=mkdir(DirSGE);
|
---|
2175 | if ~strcmp(msg1,'')
|
---|
2176 | errormsg=['cannot create ' DirSGE ': ' msg1]; % error message for directory creation
|
---|
2177 | return
|
---|
2178 | end
|
---|
2179 | end
|
---|
2180 | maxImgsPerJob = ceil(length(batch_file_list)/NbCore);
|
---|
2181 | disp(['Max number of jobs: ' num2str(NbCore)])
|
---|
2182 | disp(['Images per job: ' num2str(maxImgsPerJob)])
|
---|
2183 |
|
---|
2184 | iprocess = 1;
|
---|
2185 | imgsInJob = [];
|
---|
2186 | currJobIndex = 1;
|
---|
2187 | done = 0;
|
---|
2188 | while(~done)
|
---|
2189 | if(iprocess <= length(batch_file_list))
|
---|
2190 | imgsInJob = [imgsInJob, iprocess];
|
---|
2191 | end
|
---|
2192 | if((numel(imgsInJob) >= maxImgsPerJob) || (iprocess == length(batch_file_list)))
|
---|
2193 | cmd=['#!/bin/sh \n'...
|
---|
2194 | '#$ -cwd \n'...
|
---|
2195 | 'hostname && date\n']
|
---|
2196 | for ii=1:numel(imgsInJob)
|
---|
2197 | cmd=[cmd ActionFullName ' /softs/matlab ' filexml{imgsInJob(ii)} '\n'];
|
---|
2198 | end
|
---|
2199 | [fid, message] = fopen([DirSGE '/job' num2str(currJobIndex) '.sh'], 'w');
|
---|
2200 | fprintf(fid, cmd);
|
---|
2201 | fclose(fid);
|
---|
2202 | system(['chmod +x ' DirSGE '/job' num2str(currJobIndex) '.sh'])
|
---|
2203 | sge_command=['qsub -N civ_' num2str(currJobIndex) ' '...
|
---|
2204 | '-q ' qstat_Queue ' '...
|
---|
2205 | '-e ' fullfile([DirSGE '/job' num2str(currJobIndex) '.out']) ' '...
|
---|
2206 | '-o ' fullfile([DirSGE '/job' num2str(currJobIndex) '.out']) ' '...
|
---|
2207 | fullfile([DirSGE '/job' num2str(currJobIndex) '.sh'])];
|
---|
2208 | fprintf(sge_command); % display in command line
|
---|
2209 | [status, result] = system(sge_command);
|
---|
2210 | fprintf(result);
|
---|
2211 | currJobIndex = currJobIndex + 1;
|
---|
2212 | imgsInJob = [];
|
---|
2213 | end
|
---|
2214 | if(iprocess == length(batch_file_list))
|
---|
2215 | done = 1;
|
---|
2216 | end
|
---|
2217 | iprocess = iprocess + 1;
|
---|
2218 | end
|
---|
2219 | msgbox_uvmat('CONFIRMATION',[num2str(currJobIndex-1) ' jobs launched on queue ' qstat_Queue '.'])
|
---|
2220 | case 'python'
|
---|
2221 | command = command_launch_python(filexml{iprocess});
|
---|
2222 | fprintf(['command:\n' command '\n\n'])
|
---|
2223 | [status, result] = call_command_clean(command);
|
---|
2224 | end
|
---|
2225 | if exist(OutputDir,'dir')
|
---|
2226 | [SUCCESS,MESSAGE,MESSAGEID] = fileattrib (OutputDir);
|
---|
2227 | if MESSAGE.GroupWrite~=1
|
---|
2228 | [success,msg] = fileattrib(OutputDir,'+w','g','s'); % allow writing access for the group of users, recursively in the folder
|
---|
2229 | if success==0
|
---|
2230 | msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg}); % error message for directory creation
|
---|
2231 | end
|
---|
2232 | end
|
---|
2233 | end
|
---|
2234 | end
|
---|
2235 | set(handles.Replicate,'BackgroundColor',[0 1 0])
|
---|
2236 |
|
---|
2237 | %------------------------------------------------------------------------
|
---|
2238 | function STOP_Callback(hObject, eventdata, handles)
|
---|
2239 | %------------------------------------------------------------------------
|
---|
2240 | set(handles.RUN, 'BusyAction','cancel')
|
---|
2241 | set(handles.RUN,'BackgroundColor',[1 0 0])
|
---|
2242 | set(handles.RUN,'enable','on')
|
---|
2243 | set(handles.RUN, 'Value',0)
|
---|
2244 |
|
---|
2245 | %------------------------------------------------------------------------
|
---|
2246 | % --- read parameters from the GUI series
|
---|
2247 | %------------------------------------------------------------------------
|
---|
2248 | function Param=read_GUI_series(handles)
|
---|
2249 |
|
---|
2250 | %% read raw parameters from the GUI series
|
---|
2251 | Param=read_GUI(handles.series);
|
---|
2252 |
|
---|
2253 | %% clean the output structure by removing unused information
|
---|
2254 | if isfield(Param,'Pairs')
|
---|
2255 | Param=rmfield(Param,'Pairs'); % info Pairs not needed for output
|
---|
2256 | end
|
---|
2257 | if isfield(Param,'InputLine')
|
---|
2258 | Param=rmfield(Param,'InputLine');
|
---|
2259 | end
|
---|
2260 | if isfield(Param,'EditObject')
|
---|
2261 | Param=rmfield(Param,'EditObject');
|
---|
2262 | end
|
---|
2263 | Param.IndexRange.TimeSource=Param.IndexRange.TimeTable{end,1};
|
---|
2264 | Param.IndexRange=rmfield(Param.IndexRange,'TimeTable');
|
---|
2265 | empty_line=false(size(Param.InputTable,1),1);
|
---|
2266 | for iline=1:size(Param.InputTable,1)
|
---|
2267 | empty_line(iline)=isempty(cell2mat(Param.InputTable(iline,1:3)));
|
---|
2268 | end
|
---|
2269 | Param.InputTable(empty_line,:)=[];
|
---|
2270 |
|
---|
2271 | %------------------------------------------------------------------------
|
---|
2272 | % --- Executes on selection change in ActionName.
|
---|
2273 | function ActionName_Callback(hObject, ActionPath, handles)
|
---|
2274 | %------------------------------------------------------------------------
|
---|
2275 |
|
---|
2276 | %% stop any ongoing series processing
|
---|
2277 | if isequal(get(handles.RUN,'Value'),1)
|
---|
2278 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
|
---|
2279 | if strcmp(answer,'Yes')
|
---|
2280 | STOP_Callback(hObject, [], handles)
|
---|
2281 | else
|
---|
2282 | return
|
---|
2283 | end
|
---|
2284 | end
|
---|
2285 | set(handles.ActionName,'BackgroundColor',[1 1 0])
|
---|
2286 | huigetfile=findobj(allchild(0),'tag','status_display');
|
---|
2287 | if ~isempty(huigetfile)
|
---|
2288 | delete(huigetfile)
|
---|
2289 | end
|
---|
2290 | drawnow
|
---|
2291 |
|
---|
2292 | %% get Action name and path
|
---|
2293 | NbBuiltinAction=get(handles.Action,'UserData'); % nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series)
|
---|
2294 | ActionList=get(handles.ActionName,'String'); % list menu fields
|
---|
2295 | ActionIndex=get(handles.ActionName,'Value');
|
---|
2296 | if ~isequal(ActionIndex,1)% if we are not just opening series
|
---|
2297 | InputTable=get(handles.InputTable,'Data');
|
---|
2298 | if isempty(InputTable{1,4})
|
---|
2299 | msgbox_uvmat('ERROR','no input file available: use Open in the menu bar')
|
---|
2300 | return
|
---|
2301 | end
|
---|
2302 | end
|
---|
2303 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name
|
---|
2304 | ActionPathList=get(handles.ActionName,'UserData'); % list of recorded paths to functions of the list ActionName
|
---|
2305 |
|
---|
2306 | %% add a new function to the menu if 'more...' has been selected in the menu ActionName
|
---|
2307 | if isequal(ActionName,'more...')
|
---|
2308 | if ~ischar(ActionPath)
|
---|
2309 | ActionPath=get(handles.ActionPath,'String');
|
---|
2310 | end
|
---|
2311 | [FileName, PathName] = uigetfile( ...
|
---|
2312 | {'*.m', ' (*.m)';
|
---|
2313 | '*.m', '.m files '; ...
|
---|
2314 | '*.*', 'All Files (*.*)'}, ...
|
---|
2315 | 'Pick a series processing function ',ActionPath);
|
---|
2316 | if length(FileName)<2
|
---|
2317 | return
|
---|
2318 | end
|
---|
2319 | [~,ActionName,ActionExt]=fileparts(FileName);
|
---|
2320 |
|
---|
2321 | % insert the choice in the menu ActionName
|
---|
2322 | ActionIndex=find(strcmp(ActionName,ActionList),1); % look for the selected function in the menu Action
|
---|
2323 | PathName=regexprep(PathName,'/$','');
|
---|
2324 | if ~isempty(ActionIndex) && ~strcmp(ActionPathList{ActionIndex},PathName)%compare the path to the existing fct
|
---|
2325 | ActionIndex=[]; % the selected path is different than the recorded one
|
---|
2326 | end
|
---|
2327 | if isempty(ActionIndex)%the qselected fct (with selected path) does not exist in the menu
|
---|
2328 | ActionIndex= length(ActionList);
|
---|
2329 | ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)]; % the selected function is appended in the menu, before the last item 'more...'
|
---|
2330 | ActionPathList=[ActionPathList; PathName];
|
---|
2331 | end
|
---|
2332 |
|
---|
2333 | % record the file extension and extend the path list if it is a new extension
|
---|
2334 | ActionExtList=get(handles.ActionExt,'String');
|
---|
2335 | ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1);
|
---|
2336 | if isempty(ActionExtIndex)
|
---|
2337 | set(handles.ActionExt,'String',[ActionExtList;{ActionExt}])
|
---|
2338 | end
|
---|
2339 |
|
---|
2340 | % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5)
|
---|
2341 | if length(ActionList)>NbBuiltinAction+5% nb_builtin_ACTION=nbre of functions always remaining in the initial menu
|
---|
2342 | nbremove=length(ActionList)-NbBuiltinAction-5;
|
---|
2343 | ActionList(NbBuiltinAction+1:end-5)=[];
|
---|
2344 | ActionPathList(NbBuiltinAction+1:end-4,:)=[];
|
---|
2345 | ActionIndex=ActionIndex-nbremove;
|
---|
2346 | end
|
---|
2347 |
|
---|
2348 | % record action menu, choice and path
|
---|
2349 | set(handles.ActionName,'Value',ActionIndex)
|
---|
2350 | set(handles.ActionName,'String',ActionList)
|
---|
2351 | set(handles.ActionName,'UserData',ActionPathList);
|
---|
2352 | set(handles.ActionExt,'Value',ActionExtIndex)
|
---|
2353 |
|
---|
2354 | %record the user defined menu additions in personal file profil_perso
|
---|
2355 | dir_perso=prefdir;
|
---|
2356 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
2357 | if NbBuiltinAction+1<=numel(ActionList)-1
|
---|
2358 | ActionListUser=ActionList(NbBuiltinAction+1:numel(ActionList)-1);
|
---|
2359 | ActionPathListUser=ActionPathList(NbBuiltinAction+1:numel(ActionList)-1);
|
---|
2360 | ActionExtListUser={};
|
---|
2361 | if numel(ActionExtList)>2
|
---|
2362 | ActionExtListUser=ActionExtList(3:end);
|
---|
2363 | end
|
---|
2364 | if exist(profil_perso,'file')
|
---|
2365 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append')
|
---|
2366 | else
|
---|
2367 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6')
|
---|
2368 | end
|
---|
2369 | end
|
---|
2370 | end
|
---|
2371 |
|
---|
2372 | %% check the current ActionPath to the selected function
|
---|
2373 | ActionPath=ActionPathList{ActionIndex}; % current recorded path
|
---|
2374 | set(handles.ActionPath,'String',ActionPath); % show the path to the selected function
|
---|
2375 |
|
---|
2376 | %% reinitialise the waitbar
|
---|
2377 | update_waitbar(handles.Waitbar,0)
|
---|
2378 |
|
---|
2379 | %% Put the first line of the selected Action fct as tooltip help
|
---|
2380 | try
|
---|
2381 | [fid,errormsg] =fopen([fullfile(ActionPath,ActionName) '.m']);
|
---|
2382 | InputText=textscan(fid,'%s',1,'delimiter','\n');
|
---|
2383 | fclose(fid);
|
---|
2384 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help
|
---|
2385 | end
|
---|
2386 | set(handles.ActionName,'BackgroundColor',[1 1 1])
|
---|
2387 | set(handles.ActionInput,'BackgroundColor',[1 0 1])% set ActionInput button to magenta color to indicate that input refr
|
---|
2388 | set(handles.num_CPUTime,'String','')
|
---|
2389 |
|
---|
2390 | % --- Executes on button press in ActionInput.
|
---|
2391 | function ActionInput_Callback(hObject, eventdata, handles)
|
---|
2392 |
|
---|
2393 | set(handles.ActionInput,'BackgroundColor',[1 1 0])
|
---|
2394 | SeriesData=get(handles.series,'UserData'); % info on the input file series
|
---|
2395 |
|
---|
2396 | %% create the function handle for Action
|
---|
2397 | ActionPath=get(handles.ActionPath,'String');
|
---|
2398 | ActionList=get(handles.ActionName,'String');
|
---|
2399 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name
|
---|
2400 | if ~exist(ActionPath,'dir')
|
---|
2401 | ActionName_Callback(handles.ActionName, ActionPath, handles)% update the function
|
---|
2402 | return
|
---|
2403 | end
|
---|
2404 | current_dir=pwd; % current working dir
|
---|
2405 | cd(ActionPath)
|
---|
2406 | h_fun=str2func(ActionName);% create the function handle for the function ActionName
|
---|
2407 | cd(current_dir)
|
---|
2408 |
|
---|
2409 | %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData
|
---|
2410 | Param=read_GUI_series(handles); % read the parameters from the GUI series
|
---|
2411 | Param.Action.RUN=0;% indicate that we are in the mode of parameter input, not program run
|
---|
2412 | Param.SeriesData=SeriesData;% info stored in 'UserData' of the fig 'series'
|
---|
2413 | ParamOut=h_fun(Param); % run the selected Action function to get the relevant input
|
---|
2414 |
|
---|
2415 |
|
---|
2416 | %% Visibility of VelType and VelType_1 menus asked by ActionName
|
---|
2417 | VelTypeRequest=1; % VelType requested by default
|
---|
2418 | VelTypeRequest_1=1; % VelType requested by default
|
---|
2419 | if isfield(ParamOut,'VelType')
|
---|
2420 | VelTypeRequest=ismember(ParamOut.VelType,{'on','one','two'});
|
---|
2421 | VelTypeRequest_1=strcmp( ParamOut.VelType,'two');
|
---|
2422 | end
|
---|
2423 | FieldNameRequest=0; %hidden by default
|
---|
2424 | FieldNameRequest_1=0; %hidden by default
|
---|
2425 | if isfield(ParamOut,'FieldName')
|
---|
2426 | FieldNameRequest=ismember(ParamOut.FieldName,{'on','one','two'});
|
---|
2427 | FieldNameRequest_1=strcmp( ParamOut.FieldName,'two');
|
---|
2428 | end
|
---|
2429 |
|
---|
2430 | %% Detect the types of input files and set menus and default options in 'VelType'
|
---|
2431 | if ~isfield(SeriesData,'FileType')
|
---|
2432 | SeriesData.FileType={'none'};
|
---|
2433 | end
|
---|
2434 | iview_civ=find( strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));
|
---|
2435 | iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)); % all nc files, icluding civ
|
---|
2436 | FieldList=get(handles.FieldName,'String'); % previous list as default
|
---|
2437 | if ~iscell(FieldList),FieldList={FieldList};end
|
---|
2438 | FieldList_1=get(handles.FieldName_1,'String'); % previous list as default
|
---|
2439 | if ~iscell(FieldList_1),FieldList_1={FieldList_1};end
|
---|
2440 | CheckPivData_1=0; % indicate whether FieldName_1 has been updated with civ data, 0 by default
|
---|
2441 | handles_coord=[handles.Coord_x handles.Coord_y handles.Coord_z handles.Coord_x_title handles.Coord_y_title handles.Coord_z_title];
|
---|
2442 | if VelTypeRequest && numel(iview_civ)>=1
|
---|
2443 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(1)}.CivStage,SeriesData.FileType{iview_civ(1)});
|
---|
2444 | set(handles.VelType,'Value',1)% set first choice by default
|
---|
2445 | set(handles.VelType,'String',[{'*'};menu])
|
---|
2446 | set(handles.VelType,'Visible','on')
|
---|
2447 | set(handles.VelType_title,'Visible','on')
|
---|
2448 | FieldList=set_field_list('U','V'); % standard menu for civx data
|
---|
2449 | if max(get(handles.FieldName,'Value'))>numel(FieldList)
|
---|
2450 | set(handles.FieldName,'Value',1); % velocity vector choice by default
|
---|
2451 | end
|
---|
2452 | if VelTypeRequest_1 && numel(iview_civ)>=2
|
---|
2453 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)});
|
---|
2454 | set(handles.VelType_1,'Value',1)% set first choice by default
|
---|
2455 | set(handles.VelType_1,'String',[{'*'};menu])
|
---|
2456 | set(handles.VelType_1,'Visible','on')
|
---|
2457 | set(handles.VelType_title_1,'Visible','on')
|
---|
2458 | FieldList_1=[set_field_list('U','V');{'C'};{'add_field...'}]; % standard menu for civx data
|
---|
2459 | CheckPivData_1=1;
|
---|
2460 | set(handles.FieldName_1,'Value',1); % velocity vector choice by default
|
---|
2461 | else
|
---|
2462 | set(handles.VelType_1,'Visible','off')
|
---|
2463 | set(handles.VelType_title_1,'Visible','off')
|
---|
2464 | end
|
---|
2465 | else
|
---|
2466 | set(handles.VelType,'Visible','off')
|
---|
2467 | set(handles.VelType_title,'Visible','off')
|
---|
2468 | end
|
---|
2469 |
|
---|
2470 | %% Detect the types of input files and set menus and default options in 'FieldName'
|
---|
2471 | if (FieldNameRequest || VelTypeRequest) && numel(iview_netcdf)>=1
|
---|
2472 | set(handles.InputFields,'Visible','on')% set the frame InputFields visible
|
---|
2473 | if FieldNameRequest && isfield(SeriesData.FileInfo{iview_netcdf(1)},'ListVarName')
|
---|
2474 | set(handles.FieldName,'Visible','on')
|
---|
2475 | set(handles.Field_text,'Visible','on')
|
---|
2476 | ListVarName=SeriesData.FileInfo{iview_netcdf(1)}.ListVarName;
|
---|
2477 | ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables
|
---|
2478 | for ilist=1:numel(ind_var)
|
---|
2479 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName), 1))
|
---|
2480 | FieldList={}; % previous choice not consistent with new input field
|
---|
2481 | set(handles.FieldName,'Value',1)
|
---|
2482 | break
|
---|
2483 | end
|
---|
2484 | end
|
---|
2485 | if ~isempty(FieldList)
|
---|
2486 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName), 1))||...
|
---|
2487 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName), 1))
|
---|
2488 | FieldList={};
|
---|
2489 | set(handles.Coord_x,'String','')
|
---|
2490 | set(handles.Coord_y,'String','')
|
---|
2491 | end
|
---|
2492 | Coord_z=get(handles.Coord_z,'String');
|
---|
2493 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName), 1))
|
---|
2494 | FieldList={};
|
---|
2495 | set(handles.Coord_z,'String','')
|
---|
2496 | end
|
---|
2497 | end
|
---|
2498 | else
|
---|
2499 | set(handles.FieldName,'Visible','off')
|
---|
2500 | set(handles.Field_text,'Visible','off')
|
---|
2501 | end
|
---|
2502 | set(handles_coord,'Visible','on')
|
---|
2503 | if isempty(find(strcmp('add_field...',FieldList), 1))
|
---|
2504 | FieldList=[FieldList;{'add_field...'}];%add 'add_field...' to the menu FieldName if it is not already
|
---|
2505 | end
|
---|
2506 | if FieldNameRequest_1 && numel(iview_netcdf)>=2
|
---|
2507 | set(handles.FieldName_1,'Visible','on')
|
---|
2508 | set(handles.Field_text_1,'Visible','on')
|
---|
2509 | if CheckPivData_1==0 % not civ input made
|
---|
2510 | FieldList_1={'add_field...'};
|
---|
2511 | ListVarName=SeriesData.FileInfo{iview_netcdf(2)}.ListVarName;
|
---|
2512 | ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables
|
---|
2513 | for ilist=1:numel(ind_var)
|
---|
2514 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName), 1))
|
---|
2515 | %FieldList_1={}; % previous choice not consistent with new input field
|
---|
2516 | set(handles.FieldName_1,'Value',1)
|
---|
2517 | break
|
---|
2518 | end
|
---|
2519 | end
|
---|
2520 | warn_coord=0;
|
---|
2521 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName), 1))||...
|
---|
2522 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName), 1))
|
---|
2523 | warn_coord=1;
|
---|
2524 | end
|
---|
2525 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName), 1))
|
---|
2526 | FieldList_1={'add_field...'};
|
---|
2527 | warn_coord=1;
|
---|
2528 | end
|
---|
2529 | if warn_coord
|
---|
2530 | msgbox_uvmat('WARNING','coordinate names do not exist in the second netcdf input file')
|
---|
2531 | end
|
---|
2532 |
|
---|
2533 | set(handles.FieldName_1,'Visible','on')
|
---|
2534 | set(handles.FieldName_1,'Value',1)
|
---|
2535 | set(handles.FieldName_1,'String',FieldList_1)
|
---|
2536 | end
|
---|
2537 | else
|
---|
2538 | set(handles.FieldName_1,'Visible','off')
|
---|
2539 | end
|
---|
2540 | if isempty(FieldList)
|
---|
2541 | set(handles.Field_text,'Visible','off')
|
---|
2542 | set(handles.FieldName,'Visible','off')
|
---|
2543 | else
|
---|
2544 | set(handles.Field_text,'Visible','on')
|
---|
2545 | set(handles.FieldName,'Visible','on')
|
---|
2546 | set(handles.FieldName,'String',FieldList)
|
---|
2547 | end
|
---|
2548 | else
|
---|
2549 | set(handles.InputFields,'Visible','off')
|
---|
2550 | end
|
---|
2551 |
|
---|
2552 | %% Introduce visibility of file overwrite option
|
---|
2553 | if isfield(ParamOut,'CheckOverwriteVisible')&& strcmp(ParamOut.CheckOverwriteVisible,'on')
|
---|
2554 | set(handles.CheckOverwrite,'Visible','on')
|
---|
2555 | else
|
---|
2556 | set(handles.CheckOverwrite,'Visible','off')
|
---|
2557 | end
|
---|
2558 |
|
---|
2559 | %% Check whether alphabetical sorting of input Subdir is allowed by the Action fct (for multiples series entries)
|
---|
2560 | if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1
|
---|
2561 | [~,iview]=sort(Param.InputTable(:,2)); % subdirectories sorted in alphabetical order
|
---|
2562 | set(handles.InputTable,'Data',Param.InputTable(iview,:));
|
---|
2563 | MinIndex_i=get(handles.MinIndex_i,'Data');
|
---|
2564 | MinIndex_j=get(handles.MinIndex_j,'Data');
|
---|
2565 | MaxIndex_i=get(handles.MaxIndex_i,'Data');
|
---|
2566 | MaxIndex_j=get(handles.MaxIndex_j,'Data');
|
---|
2567 | set(handles.MinIndex_i,'Data',MinIndex_i(iview,:));
|
---|
2568 | set(handles.MinIndex_j,'Data',MinIndex_j(iview,:));
|
---|
2569 | set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:));
|
---|
2570 | set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));
|
---|
2571 | TimeTable=get(handles.TimeTable,'Data');
|
---|
2572 | if size(TimeTable,1)<size(Param.InputTable,1)%if the time table is not complete, copy the missing lines from the previous ones
|
---|
2573 | for iline=size(TimeTable,1)+1:size(Param.InputTable,1)
|
---|
2574 | TimeTable(iline,:)=TimeTable(iline-1,:);
|
---|
2575 | end
|
---|
2576 | end
|
---|
2577 | set(handles.TimeTable,'Data',TimeTable(iview,:));% sort the time tables
|
---|
2578 | PairString=get(handles.PairString,'Data');
|
---|
2579 | set(handles.PairString,'Data',PairString(iview,:));
|
---|
2580 | end
|
---|
2581 |
|
---|
2582 | %% Impose the whole input file index range if requested
|
---|
2583 | if ~isfield(ParamOut,'WholeIndexRange')
|
---|
2584 | ParamOut.WholeIndexRange='off';
|
---|
2585 | end
|
---|
2586 | if ~isfield(ParamOut,'IndexRange_j')
|
---|
2587 | ParamOut.IndexRange_j='on';% accept Index_j as input by default
|
---|
2588 | end
|
---|
2589 | if strcmp(ParamOut.WholeIndexRange,'on')
|
---|
2590 | MinIndex_i=get(handles.MinIndex_i,'Data');
|
---|
2591 | MaxIndex_i=get(handles.MaxIndex_i,'Data');
|
---|
2592 | set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line)
|
---|
2593 | set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line)
|
---|
2594 | set(handles.num_incr_i,'String','1')
|
---|
2595 | else
|
---|
2596 | first_i=1;last_i=1;
|
---|
2597 | if isfield(Param.IndexRange,'first_i')
|
---|
2598 | first_i=Param.IndexRange.first_i;
|
---|
2599 | last_i=Param.IndexRange.last_i;
|
---|
2600 | end
|
---|
2601 | end
|
---|
2602 | if strcmp(ParamOut.WholeIndexRange,'on')||strcmp(ParamOut.IndexRange_j,'whole')
|
---|
2603 | MinIndex_j=get(handles.MinIndex_j,'Data');
|
---|
2604 | MaxIndex_j=get(handles.MaxIndex_j,'Data');
|
---|
2605 | set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line)
|
---|
2606 | set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line)
|
---|
2607 | set(handles.num_incr_j,'String','1')
|
---|
2608 | else % check index ranges
|
---|
2609 | first_j=1;last_j=1;
|
---|
2610 | if isfield(Param.IndexRange,'first_j')
|
---|
2611 | first_j=Param.IndexRange.first_j;
|
---|
2612 | last_j=Param.IndexRange.last_j;
|
---|
2613 | end
|
---|
2614 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
|
---|
2615 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end
|
---|
2616 | end
|
---|
2617 |
|
---|
2618 | %% enable or desable j index visibility
|
---|
2619 | if strcmp(ParamOut.IndexRange_j,'off')%do not show the j index
|
---|
2620 | enable_j(handles,'off')
|
---|
2621 | else% show j index if relevant in the input series
|
---|
2622 | j1_series=SeriesData.j1_series;
|
---|
2623 | for iview=1:size(j1_series,1)
|
---|
2624 | if ~isempty(j1_series{iview})
|
---|
2625 | enable_j(handles,'on')
|
---|
2626 | break
|
---|
2627 | end
|
---|
2628 | end
|
---|
2629 | end
|
---|
2630 |
|
---|
2631 | % status_j='on'; % default
|
---|
2632 | % if isfield(SeriesData,'j1_series') && isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)) % case of empty j indices
|
---|
2633 | % status_j='off'; % no j index needed
|
---|
2634 | % elseif strcmp(get(handles.PairString,'Visible'),'on')
|
---|
2635 | % check_burst=cellfun(@isempty,regexp(get(handles.PairString,'Data'),'^j')); % =0 for burst case, 1 otherwise
|
---|
2636 | % if isempty(find(check_burst, 1))% if all pair string begins by j (burst)
|
---|
2637 | % status_j='off'; % no j index needed for bust case
|
---|
2638 | % end
|
---|
2639 | % end
|
---|
2640 | % enable_j(handles,status_j) % no j index needed
|
---|
2641 | % if isfield(ParamOut,'j_index_1')&& isfield(ParamOut,'j_index_2')%strcmp(ParamOut.Desable_j_index,'on')
|
---|
2642 | % %status_j='off';
|
---|
2643 | % set(handles.num_first_j,'String',num2str(ParamOut.j_index_1))
|
---|
2644 | % set(handles.num_last_j,'String',num2str(ParamOut.j_index_2))
|
---|
2645 | % % set(handles.num_first_j,'enable','off')
|
---|
2646 | % % set(handles.num_last_j,'enable','off')
|
---|
2647 | % set(handles.num_first_j,'visible','off')
|
---|
2648 | % set(handles.num_last_j,'visible','off')
|
---|
2649 | % set(handles.num_incr_j,'visible','off')
|
---|
2650 | % else
|
---|
2651 | % set(handles.num_first_j,'visible','on')
|
---|
2652 | % set(handles.num_last_j,'visible','on')
|
---|
2653 | % set(handles.num_incr_j,'visible',status_j)
|
---|
2654 | % end
|
---|
2655 |
|
---|
2656 | %% NbSlice visibility
|
---|
2657 | if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice))
|
---|
2658 | set(handles.num_NbSlice,'Visible','on')
|
---|
2659 | set(handles.NbSlice_title,'Visible','on')
|
---|
2660 | if isnumeric(ParamOut.NbSlice)
|
---|
2661 | set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
|
---|
2662 | end
|
---|
2663 | else
|
---|
2664 | set(handles.num_NbSlice,'Visible','off')
|
---|
2665 | set(handles.NbSlice_title,'Visible','off')
|
---|
2666 | end
|
---|
2667 | if isfield(ParamOut,'NbSlice') && isnumeric(ParamOut.NbSlice)
|
---|
2668 | set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
|
---|
2669 | set(handles.num_NbSlice,'Enable','off'); % NbSlice set by the activation of the Action function
|
---|
2670 | else
|
---|
2671 | set(handles.num_NbSlice,'Enable','on'); % NbSlice can be modified on the GUI series
|
---|
2672 | end
|
---|
2673 |
|
---|
2674 | %% Visibility of FieldTransform menu
|
---|
2675 | FieldTransformVisible='off'; %hidden by default
|
---|
2676 | if isfield(ParamOut,'FieldTransform')
|
---|
2677 | if ~strcmp(ParamOut.FieldTransform,'off')
|
---|
2678 | FieldTransformVisible='on';
|
---|
2679 | end
|
---|
2680 | if iscell(ParamOut.FieldTransform)
|
---|
2681 | SeriesData.TransformList=ParamOut.FieldTransform;
|
---|
2682 | end
|
---|
2683 | TransformName_Callback([],[], handles)
|
---|
2684 | end
|
---|
2685 | set(handles.FieldTransform,'Visible',FieldTransformVisible)
|
---|
2686 | if isfield(ParamOut,'TransformPath')% record the path of transform function requested for compilation
|
---|
2687 | set(handles.TransformPath,'UserData',ParamOut.TransformPath)
|
---|
2688 | else
|
---|
2689 | set(handles.TransformPath,'UserData',[])
|
---|
2690 | end
|
---|
2691 |
|
---|
2692 | %% Visibility of projection object
|
---|
2693 | ProjObjectVisible='off'; %hidden by default
|
---|
2694 | if isfield(ParamOut,'ProjObject')
|
---|
2695 | ProjObjectVisible=ParamOut.ProjObject;
|
---|
2696 | end
|
---|
2697 | set(handles.CheckObject,'Visible',ProjObjectVisible)
|
---|
2698 | if ~get(handles.CheckObject,'Value')
|
---|
2699 | ProjObjectVisible='off';
|
---|
2700 | end
|
---|
2701 | set(handles.ProjObjectName,'Visible',ProjObjectVisible)
|
---|
2702 | set(handles.DeleteObject,'Visible',ProjObjectVisible)
|
---|
2703 | set(handles.ViewObject,'Visible',ProjObjectVisible)
|
---|
2704 | set(handles.EditObject,'Visible',ProjObjectVisible)
|
---|
2705 |
|
---|
2706 | %% Visibility of mask input
|
---|
2707 | MaskVisible='off'; %hidden by default
|
---|
2708 | if isfield(ParamOut,'Mask')
|
---|
2709 | MaskVisible=ParamOut.Mask;
|
---|
2710 | end
|
---|
2711 | set(handles.CheckMask,'Visible',MaskVisible);
|
---|
2712 | set(handles.MaskTable,'Visible',MaskVisible);
|
---|
2713 |
|
---|
2714 | %% Setting of expected iteration time
|
---|
2715 | if isfield(ParamOut,'CPUTime')
|
---|
2716 | set(handles.num_CPUTime,'String',num2str(ParamOut.CPUTime));
|
---|
2717 | end
|
---|
2718 |
|
---|
2719 | %% definition of the path for the output files
|
---|
2720 | InputTable=get(handles.InputTable,'Data');
|
---|
2721 | [OutputPath,Device,DeviceExt]=fileparts(InputTable{1,1});
|
---|
2722 | [~,Experiment,ExperimentExt]=fileparts(OutputPath);
|
---|
2723 | set(handles.Device,'String',[Device DeviceExt])
|
---|
2724 | set(handles.Device,'Visible','on')
|
---|
2725 | set(handles.Device_title,'Visible','on')
|
---|
2726 | set(handles.Experiment,'String',[Experiment ExperimentExt])
|
---|
2727 | set(handles.Experiment,'Visible','on')
|
---|
2728 | set(handles.Experiment_title,'Visible','on')
|
---|
2729 | set(handles.Experiment_title,'Visible','on')
|
---|
2730 | set(handles.OutputPath,'Visible','on')
|
---|
2731 | set(handles.OutputPathBrowse,'Visible','on')
|
---|
2732 |
|
---|
2733 | %% definition of the subdirectory containing the output files
|
---|
2734 | if ~(isfield(SeriesData,'ActionName') && strcmp(ActionName,SeriesData.ActionName))
|
---|
2735 | OutputDirExt='.series'; % default
|
---|
2736 | if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt)
|
---|
2737 | OutputDirExt=ParamOut.OutputDirExt;
|
---|
2738 | end
|
---|
2739 | set(handles.OutputDirExt,'String',OutputDirExt)
|
---|
2740 | end
|
---|
2741 | OutputDirVisible='off';
|
---|
2742 | OutputSubDirMode='auto'; % default
|
---|
2743 | SubDirOut='';
|
---|
2744 | if isfield(ParamOut,'OutputSubDirMode')
|
---|
2745 | OutputSubDirMode=ParamOut.OutputSubDirMode;
|
---|
2746 | end
|
---|
2747 | switch OutputSubDirMode
|
---|
2748 | case 'auto' % default
|
---|
2749 | OutputDirVisible='on';
|
---|
2750 | SubDir=InputTable(1:end,2); % set of subdirectories
|
---|
2751 | SubDirOut=SubDir{1};
|
---|
2752 | if numel(SubDir)>1
|
---|
2753 | for ilist=2:numel(SubDir)
|
---|
2754 | SubDirOut=[SubDirOut '-' regexprep(SubDir{ilist},'^/','')];
|
---|
2755 | end
|
---|
2756 | end
|
---|
2757 | case 'one'
|
---|
2758 | OutputDirVisible='on';
|
---|
2759 | SubDirOut=InputTable{1,2}; % use the first subdir name (+OutputDirExt) as output subdirectory
|
---|
2760 | case 'two'
|
---|
2761 | OutputDirVisible='on';
|
---|
2762 | SubDir=InputTable(1:2,2); % set of subdirectories
|
---|
2763 | SubDirOut=SubDir{1};
|
---|
2764 | if numel(SubDir)>1
|
---|
2765 | SubDirOut=[SubDirOut '-' regexprep(SubDir{2},'^/','')];
|
---|
2766 | end
|
---|
2767 | case 'last'
|
---|
2768 | OutputDirVisible='on';
|
---|
2769 | SubDirOut=InputTable{end,2}; % use the last subdir name (+OutputDirExt) as output subdirectory
|
---|
2770 | end
|
---|
2771 | set(handles.OutputSubDir,'String',SubDirOut)
|
---|
2772 | set(handles.OutputSubDir,'BackgroundColor',[1 1 1])% set edit box to white color to indicate refreshment
|
---|
2773 | set(handles.OutputDirExt,'Visible',OutputDirVisible)
|
---|
2774 | set(handles.OutputSubDir,'Visible',OutputDirVisible)
|
---|
2775 | SeriesData.ActionName=ActionName; % record ActionName for next use
|
---|
2776 |
|
---|
2777 |
|
---|
2778 | %% visibility of the run mode (local or background or cluster)
|
---|
2779 | if strcmp(OutputSubDirMode,'none')
|
---|
2780 | RunModeVisible='off'; % only local mode available if no output file is produced
|
---|
2781 | else
|
---|
2782 | RunModeVisible='on';
|
---|
2783 | end
|
---|
2784 | set(handles.RunMode,'Visible',RunModeVisible)
|
---|
2785 | set(handles.ActionExt,'Visible',RunModeVisible)
|
---|
2786 | set(handles.RunMode_title,'Visible',RunModeVisible)
|
---|
2787 | set(handles.ActionExt_title,'Visible',RunModeVisible)
|
---|
2788 |
|
---|
2789 |
|
---|
2790 | %% Expected nbre of output files
|
---|
2791 | if isfield(ParamOut,'OutputFileMode')
|
---|
2792 | StatusData.OutputFileMode=ParamOut.OutputFileMode;
|
---|
2793 | set(handles.status,'UserData',StatusData)
|
---|
2794 | end
|
---|
2795 |
|
---|
2796 | %% definition of an additional parameter set, determined by an ancillary GUI
|
---|
2797 | if isfield(ParamOut,'ActionInput')
|
---|
2798 | ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput
|
---|
2799 | SeriesData.ActionInput=ParamOut.ActionInput;
|
---|
2800 | else
|
---|
2801 | if isfield(SeriesData,'ActionInput')
|
---|
2802 | SeriesData=rmfield(SeriesData,'ActionInput');
|
---|
2803 | end
|
---|
2804 | end
|
---|
2805 | set(handles.series,'UserData',SeriesData)
|
---|
2806 | set(handles.ActionInput,'BackgroundColor',[1 0 0])
|
---|
2807 |
|
---|
2808 |
|
---|
2809 | %------------------------------------------------------------------------
|
---|
2810 | % --- Executes on button press in RefreshField.
|
---|
2811 | function RefreshField_Callback(hObject, eventdata, handles)
|
---|
2812 | %------------------------------------------------------------------------
|
---|
2813 | set(handles.FieldName,'String',{'add_field...'});
|
---|
2814 | set(handles.FieldName,'Value',1);
|
---|
2815 | FieldName_Callback(hObject, eventdata, handles)
|
---|
2816 |
|
---|
2817 |
|
---|
2818 | %------------------------------------------------------------------------
|
---|
2819 | % --- Executes on selection change in FieldName.
|
---|
2820 | function FieldName_Callback(hObject, eventdata, handles)
|
---|
2821 | %------------------------------------------------------------------------
|
---|
2822 | FieldListInit=get(handles.FieldName,'String');
|
---|
2823 | field_index=get(handles.FieldName,'Value');
|
---|
2824 | field=FieldListInit{field_index(1)};
|
---|
2825 | if isequal(field,'add_field...')
|
---|
2826 | FieldListInit(field_index(1))=[];
|
---|
2827 | SeriesData=get(handles.series,'UserData');
|
---|
2828 | % input line for which the field choice is relevant
|
---|
2829 | iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'})); % all nc files, icluding civ
|
---|
2830 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2831 | if ~isempty(hget_field)
|
---|
2832 | delete(hget_field)%delete opened versions of get_field
|
---|
2833 | end
|
---|
2834 | Param=read_GUI(handles.series);
|
---|
2835 | InputTable=Param.InputTable(iview,:);
|
---|
2836 | % check the existence of the first file in the series
|
---|
2837 | first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1; % default setting for index j
|
---|
2838 | if isfield(Param.IndexRange,'first_j') % if index j is used
|
---|
2839 | first_j=Param.IndexRange.first_j;
|
---|
2840 | last_j=Param.IndexRange.last_j;
|
---|
2841 | MinIndex_j=Param.IndexRange.MinIndex_j(iview);
|
---|
2842 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview);
|
---|
2843 | end
|
---|
2844 | PairString='';
|
---|
2845 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end
|
---|
2846 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
2847 | LineIndex=iview(1);
|
---|
2848 | if numel(iview)>1
|
---|
2849 | answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1)));
|
---|
2850 | LineIndex=str2num(answer);
|
---|
2851 | end
|
---|
2852 | FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},...
|
---|
2853 | InputTable{LineIndex,5},InputTable{LineIndex,4},i1,i2,j1,j2);
|
---|
2854 | if exist(FirstFileName,'file') || ~isempty(regexp(InputTable{LineIndex,1},'^http'))
|
---|
2855 | ParamIn.Title='get_field: pick input variables and coordinates for series processing';
|
---|
2856 | ParamIn.SeriesInput=1;
|
---|
2857 | GetFieldData=get_field(FirstFileName,ParamIn);
|
---|
2858 | FieldList={};
|
---|
2859 | if isfield(GetFieldData,'FieldOption')% if a field has been selected
|
---|
2860 | switch GetFieldData.FieldOption
|
---|
2861 | case 'vectors'
|
---|
2862 | UName=GetFieldData.PanelVectors.vector_x;
|
---|
2863 | VName=GetFieldData.PanelVectors.vector_y;
|
---|
2864 | YName={GetFieldData.Coordinates.Coord_y};
|
---|
2865 | FieldList={['vec(' UName ',' VName ')'];...
|
---|
2866 | ['norm(' UName ',' VName ')'];...
|
---|
2867 | UName;VName};
|
---|
2868 | set(handles.VelType,'Visible','off')
|
---|
2869 | case {'scalar'}
|
---|
2870 | FieldList=GetFieldData.PanelScalar.scalar;
|
---|
2871 | YName={GetFieldData.Coordinates.Coord_y};
|
---|
2872 | if ischar(FieldList)
|
---|
2873 | FieldList={FieldList};
|
---|
2874 | end
|
---|
2875 | set(handles.VelType,'Visible','off')
|
---|
2876 | case 'civdata...'
|
---|
2877 | FieldList=[set_field_list('U','V') ;{'C'}];
|
---|
2878 | set(handles.FieldName,'Value',1) % set menu to 'velocity
|
---|
2879 | XName='X';
|
---|
2880 | YName='y';
|
---|
2881 | set(handles.VelType,'Visible','on')
|
---|
2882 | end
|
---|
2883 | set(handles.FieldName,'Value',1)
|
---|
2884 | set(handles.FieldName,'String',[FieldListInit; FieldList; {'add_field...'}]);
|
---|
2885 | if ~strcmp(GetFieldData.FieldOption,'civdata...')
|
---|
2886 | if ~isempty(regexp(FieldList{1},'^vec'))
|
---|
2887 | set(handles.FieldName,'Value',1)
|
---|
2888 | else
|
---|
2889 | set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
|
---|
2890 | end
|
---|
2891 | XName=GetFieldData.Coordinates.Coord_x;
|
---|
2892 | YName=GetFieldData.Coordinates.Coord_y;
|
---|
2893 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
|
---|
2894 | % get the time info
|
---|
2895 | TimeTable=get(handles.TimeTable,'Data');
|
---|
2896 | switch TimeNameStr
|
---|
2897 | case 'file index'
|
---|
2898 | TimeName='';
|
---|
2899 | case 'attribute'
|
---|
2900 | TimeName=['att:' GetFieldData.Time.TimeName];
|
---|
2901 | % update the time table
|
---|
2902 | TimeTable{LineIndex,2}=get_time(Param.IndexRange.MinIndex_i(LineIndex),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % Min time
|
---|
2903 | TimeTable{LineIndex,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % first time
|
---|
2904 | TimeTable{LineIndex,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % last time
|
---|
2905 | TimeTable{LineIndex,5}=get_time(Param.IndexRange.MaxIndex_i(LineIndex),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % Max time
|
---|
2906 | case 'variable'
|
---|
2907 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
|
---|
2908 | set(handles.NomType,'String','*')
|
---|
2909 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
|
---|
2910 | set(handles.FileIndex,'String','')
|
---|
2911 | ParamIn.TimeVarName=GetFieldData.Time.TimeName;
|
---|
2912 | case 'matrix_index'
|
---|
2913 | TimeName=['dim:' GetFieldData.Time.TimeName];
|
---|
2914 | set(handles.NomType,'String','*')
|
---|
2915 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
|
---|
2916 | set(handles.FileIndex,'String','')
|
---|
2917 | ParamIn.TimeDimName=GetFieldData.Time.TimeName;
|
---|
2918 | end
|
---|
2919 | TimeTable{LineIndex,1}=TimeName;
|
---|
2920 | set(handles.TimeTable,'Data',TimeTable);
|
---|
2921 | end
|
---|
2922 | set(handles.Coord_x,'String',XName)
|
---|
2923 | set(handles.Coord_y,'String',YName)
|
---|
2924 | set(handles.Coord_x,'Visible','on')
|
---|
2925 | set(handles.Coord_y,'Visible','on')
|
---|
2926 | end
|
---|
2927 | else
|
---|
2928 | msgbox_uvmat('ERROR',[FirstFileName ' does not exist'])
|
---|
2929 | end
|
---|
2930 | end
|
---|
2931 |
|
---|
2932 |
|
---|
2933 | function [TimeValue,DtValue]=get_time(ref_i,ref_j,PairString,InputTable,FileInfo,TimeName,DtName)
|
---|
2934 | [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString);
|
---|
2935 | FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2);
|
---|
2936 | %Data=nc2struct(FileName,[]);
|
---|
2937 | TimeValue=[];
|
---|
2938 | DtValue=[];
|
---|
2939 | switch FileInfo.FileType
|
---|
2940 | case 'civdata'
|
---|
2941 | Data=nc2struct(FileName,[]);
|
---|
2942 | if ismember(TimeName,{'civ1','filter1'})
|
---|
2943 | if isfield(Data,'Civ1_Time')
|
---|
2944 | TimeValue=Data.Civ1_Time;
|
---|
2945 | end
|
---|
2946 | if isfield(Data,'Civ1_Dt')
|
---|
2947 | DtValue=Data.Civ1_Dt;
|
---|
2948 | end
|
---|
2949 | else
|
---|
2950 | if isfield(Data,'Civ2_Time')
|
---|
2951 | TimeValue=Data.Civ2_Time;
|
---|
2952 | end
|
---|
2953 | if isfield(Data,'Civ2_Dt')
|
---|
2954 | DtValue=Data.Civ2_Dt;
|
---|
2955 | end
|
---|
2956 | end
|
---|
2957 | case 'pivdata_fluidimage'
|
---|
2958 | TimeValue=ref_i;%default
|
---|
2959 | DtValue=1;%default
|
---|
2960 | case 'netcdf'
|
---|
2961 | Data=nc2struct(FileName,[]);
|
---|
2962 | if ~isempty(TimeName)&& isfield(Data,TimeName)
|
---|
2963 | TimeValue=Data.(TimeName);
|
---|
2964 | end
|
---|
2965 | if exist('DtName','var') && isfield(Data,DtName)
|
---|
2966 | DtValue=Data.(DtName);
|
---|
2967 | end
|
---|
2968 | end
|
---|
2969 |
|
---|
2970 | %------------------------------------------------------------------------
|
---|
2971 | % --- Executes on selection change in FieldName_1.
|
---|
2972 | function FieldName_1_Callback(hObject, eventdata, handles)
|
---|
2973 | %------------------------------------------------------------------------
|
---|
2974 | field_str=get(handles.FieldName_1,'String');
|
---|
2975 | field_index=get(handles.FieldName_1,'Value');
|
---|
2976 | field=field_str{field_index(1)};
|
---|
2977 | if strcmp(field,'add_field...')
|
---|
2978 | %iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'})); % all nc files, icluding civ
|
---|
2979 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2980 | if ~isempty(hget_field)
|
---|
2981 | delete(hget_field)%delete opened versions of get_field
|
---|
2982 | end
|
---|
2983 | Param=read_GUI(handles.series);
|
---|
2984 | InputTable=Param.InputTable(2,:);
|
---|
2985 | % check the existence of the first file in the series
|
---|
2986 | first_j=[];
|
---|
2987 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
2988 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
2989 | PairString='';
|
---|
2990 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
2991 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
2992 | FirstFileName=fullfile_uvmat(Param.InputTable{2,1},Param.InputTable{2,2},Param.InputTable{2,3},...
|
---|
2993 | Param.InputTable{2,5},Param.InputTable{2,4},i1,i2,j1,j2);
|
---|
2994 | if exist(FirstFileName,'file')
|
---|
2995 | ParamIn.SeriesInput=1;
|
---|
2996 | GetFieldData=get_field(FirstFileName,ParamIn);
|
---|
2997 | FieldList={};
|
---|
2998 | switch GetFieldData.FieldOption
|
---|
2999 | case 'vectors'
|
---|
3000 | UName=GetFieldData.PanelVectors.vector_x;
|
---|
3001 | VName=GetFieldData.PanelVectors.vector_y;
|
---|
3002 | FieldList={['vec(' UName ',' VName ')'];...
|
---|
3003 | ['norm(' UName ',' VName ')'];...
|
---|
3004 | UName;VName};
|
---|
3005 | case {'scalar','pick variables'}
|
---|
3006 | FieldList=GetFieldData.PanelScalar.scalar;
|
---|
3007 | if ischar(FieldList)
|
---|
3008 | FieldList={FieldList};
|
---|
3009 | end
|
---|
3010 | case '1D plot'
|
---|
3011 |
|
---|
3012 | case 'civdata...'
|
---|
3013 | FieldList=set_field_list('U','V','C');
|
---|
3014 | set(handles.FieldName,'Value',2) % set menu to 'velocity
|
---|
3015 | end
|
---|
3016 | set(handles.FieldName_1,'Value',1)
|
---|
3017 | set(handles.FieldName_1,'String',[FieldList; {'add_field...'}]);
|
---|
3018 | end
|
---|
3019 | end
|
---|
3020 |
|
---|
3021 |
|
---|
3022 | %%%%%%%%%%%%%
|
---|
3023 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i)
|
---|
3024 | indsel=ind_i;
|
---|
3025 | indiff=diff(ind_i); % test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series
|
---|
3026 | indiff=[1 indiff last_i-ind_i(end)+1]; % for testing gaps with the imposed bounds
|
---|
3027 | if ~isempty(indiff)
|
---|
3028 | indiff2=diff(indiff);
|
---|
3029 | indiffp=[indiff2 1];
|
---|
3030 | indiffm=[1 indiff2];
|
---|
3031 | ind_multi_m=find((indiff==0)&(indiffm<0))-1; % indices of first members of multiplets
|
---|
3032 | ind_multi_p=find((indiff==0)&(indiffp>0)); % indices of last members of multiplets
|
---|
3033 | %for each multiplet, select the most recent file
|
---|
3034 | ind_remove=[];
|
---|
3035 | for i=1:length(ind_multi_m)
|
---|
3036 | ind_pairs=ind_multi_m(i):ind_multi_p(i);
|
---|
3037 | for imulti=1:length(ind_pairs)
|
---|
3038 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date); % dates of creation
|
---|
3039 | end
|
---|
3040 | [datenew,indsort2]=sort(datepair); % sort the multiplet by creation date
|
---|
3041 | ind_s=indsort2(1:end-1); %
|
---|
3042 | ind_remove=[ind_remove ind_pairs(ind_s)]; % remove these indices, leave the last one
|
---|
3043 | end
|
---|
3044 | end
|
---|
3045 |
|
---|
3046 | %------------------------------------------------------------------------
|
---|
3047 | % --- determine the list of index pairstring of processing file
|
---|
3048 | 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)
|
---|
3049 | %------------------------------------------------------------------------
|
---|
3050 | num_i1=num_i; % set of first image numbers by default
|
---|
3051 | num_i2=num_i;
|
---|
3052 | num_j1=num_j;
|
---|
3053 | num_j2=num_j;
|
---|
3054 | num_i_out=num_i;
|
---|
3055 | num_j_out=num_j;
|
---|
3056 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2')
|
---|
3057 | if isequal(mode,'series(Di)')
|
---|
3058 | num_i1_line=num_i+ind_shift(3); % set of first image numbers
|
---|
3059 | num_i2_line=num_i+ind_shift(4);
|
---|
3060 | % adjust the first and last field number
|
---|
3061 | indsel=find(num_i1_line >= 1);
|
---|
3062 | num_i_out=num_i(indsel);
|
---|
3063 | num_i1_line=num_i1_line(indsel);
|
---|
3064 | num_i2_line=num_i2_line(indsel);
|
---|
3065 | num_j1=meshgrid(num_j,ones(size(num_i1_line)));
|
---|
3066 | num_j2=meshgrid(num_j,ones(size(num_i1_line)));
|
---|
3067 | [xx,num_i1]=meshgrid(num_j,num_i1_line);
|
---|
3068 | [xx,num_i2]=meshgrid(num_j,num_i2_line);
|
---|
3069 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts')
|
---|
3070 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
|
---|
3071 | num_j1=ind_shift(1)*ones(size(num_i));
|
---|
3072 | num_j2=ind_shift(2)*ones(size(num_i));
|
---|
3073 | else
|
---|
3074 | num_j1_col=num_j+ind_shift(1); % set of first image numbers
|
---|
3075 | num_j2_col=num_j+ind_shift(2);
|
---|
3076 | % adjust the first field number
|
---|
3077 | indsel=find((num_j1_col >= 1));
|
---|
3078 | num_j_out=num_j(indsel);
|
---|
3079 | num_j1_col=num_j1_col(indsel);
|
---|
3080 | num_j2_col=num_j2_col(indsel);
|
---|
3081 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
|
---|
3082 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
|
---|
3083 | end
|
---|
3084 | end
|
---|
3085 |
|
---|
3086 | %------------------------------------------------------------------------
|
---|
3087 | % --- Executes on button press in CheckObject.
|
---|
3088 | function CheckObject_Callback(hObject, eventdata, handles)
|
---|
3089 | %------------------------------------------------------------------------
|
---|
3090 | hset_object=findobj(allchild(0),'tag','set_object'); % find the set_object interface handle
|
---|
3091 | if get(handles.CheckObject,'Value')
|
---|
3092 | SeriesData=get(handles.series,'UserData');
|
---|
3093 | if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)% a projection object is already loaded in the GUI series
|
---|
3094 | set(handles.ViewObject,'Value',1)
|
---|
3095 | ViewObject_Callback(hObject, eventdata, handles)
|
---|
3096 | else
|
---|
3097 | if ishandle(hset_object)% a projection object is already displayed in a GUI set_object
|
---|
3098 | uistack(hset_object,'top')% show the GUI set_object if opened
|
---|
3099 | else
|
---|
3100 | %get the object file
|
---|
3101 | InputTable=get(handles.InputTable,'Data');
|
---|
3102 | defaultname=InputTable{1,1};
|
---|
3103 | if isempty(defaultname)
|
---|
3104 | defaultname={''};
|
---|
3105 | end
|
---|
3106 | fileinput=uigetfile_uvmat('pick a xml object file (or use uvmat to create it)',defaultname,'.xml');
|
---|
3107 | if isempty(fileinput)% exit if no object file is selected
|
---|
3108 | set(handles.CheckObject,'Value',0)
|
---|
3109 | return
|
---|
3110 | end
|
---|
3111 | %read the file
|
---|
3112 | data=xml2struct(fileinput);
|
---|
3113 | if ~isfield(data,'Type')
|
---|
3114 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file'])
|
---|
3115 | set(handles.CheckObject,'Value',0)
|
---|
3116 | return
|
---|
3117 | end
|
---|
3118 | if ~isfield(data,'ProjMode')
|
---|
3119 | data.ProjMode='none';
|
---|
3120 | end
|
---|
3121 | hset_object=set_object(data); % call the set_object interface
|
---|
3122 | set(hset_object,'Name','set_object_series')% name to distinguish from set_object used with uvmat
|
---|
3123 | end
|
---|
3124 | ProjObject=read_GUI(hset_object);
|
---|
3125 | set(handles.ProjObjectName,'String',ProjObject.Name); % display the object name
|
---|
3126 | SeriesData=get(handles.series,'UserData');
|
---|
3127 | SeriesData.ProjObject=ProjObject;
|
---|
3128 | set(handles.series,'UserData',SeriesData);
|
---|
3129 | end
|
---|
3130 | set(handles.EditObject,'Visible','on');
|
---|
3131 | set(handles.DeleteObject,'Visible','on');
|
---|
3132 | set(handles.ViewObject,'Visible','on');
|
---|
3133 | set(handles.ProjObjectName,'Visible','on');
|
---|
3134 | else
|
---|
3135 | set(handles.EditObject,'Visible','off');
|
---|
3136 | set(handles.DeleteObject,'Visible','off');
|
---|
3137 | set(handles.ViewObject,'Visible','off');
|
---|
3138 | if ~ishandle(hset_object)
|
---|
3139 | set(handles.ViewObject,'Value',0);
|
---|
3140 | end
|
---|
3141 | set(handles.ProjObjectName,'Visible','off');
|
---|
3142 | end
|
---|
3143 |
|
---|
3144 | %------------------------------------------------------------------------
|
---|
3145 | % --- Executes on button press in ViewObject.
|
---|
3146 | %------------------------------------------------------------------------
|
---|
3147 | function ViewObject_Callback(hObject, eventdata, handles)
|
---|
3148 |
|
---|
3149 | UserData=get(handles.series,'UserData');
|
---|
3150 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
3151 | if ~isempty(hset_object)
|
---|
3152 | delete(hset_object)% refresh set_object if already opened
|
---|
3153 | end
|
---|
3154 | hset_object=set_object(UserData.ProjObject);
|
---|
3155 | set(hset_object,'Name','view_object_series')
|
---|
3156 |
|
---|
3157 |
|
---|
3158 | %------------------------------------------------------------------------
|
---|
3159 | % --- Executes on button press in EditObject.
|
---|
3160 | function EditObject_Callback(hObject, eventdata, handles)
|
---|
3161 | %------------------------------------------------------------------------
|
---|
3162 | if get(handles.EditObject,'Value')
|
---|
3163 | set(handles.ViewObject,'Value',0)
|
---|
3164 | UserData=get(handles.series,'UserData');
|
---|
3165 | if isfield(UserData,'ProjObject')
|
---|
3166 | hset_object=set_object(UserData.ProjObject);
|
---|
3167 | set(hset_object,'Name','edit_object_series')
|
---|
3168 | set(get(hset_object,'Children'),'Enable','on')
|
---|
3169 | else
|
---|
3170 | msgbox_uvmat('ERROR','no projection object available');
|
---|
3171 | end
|
---|
3172 | else
|
---|
3173 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
3174 | if ~isempty(hset_object)
|
---|
3175 | set(get(hset_object,'Children'),'Enable','off')
|
---|
3176 | end
|
---|
3177 | end
|
---|
3178 |
|
---|
3179 | %------------------------------------------------------------------------
|
---|
3180 | % --- Executes on button press in DeleteObject.
|
---|
3181 | function DeleteObject_Callback(hObject, eventdata, handles)
|
---|
3182 | %------------------------------------------------------------------------
|
---|
3183 | SeriesData=get(handles.series,'UserData');
|
---|
3184 | SeriesData.ProjObject=[];
|
---|
3185 | set(handles.series,'UserData',SeriesData)
|
---|
3186 | set(handles.ProjObjectName,'String','')
|
---|
3187 | set(handles.ProjObjectName,'Visible','off')
|
---|
3188 | set(handles.CheckObject,'Value',0)
|
---|
3189 | set(handles.ViewObject,'Visible','off')
|
---|
3190 | set(handles.EditObject,'Visible','off')
|
---|
3191 | hset_object=findobj(allchild(0),'name','set_object_series');
|
---|
3192 | if ~isempty(hset_object)
|
---|
3193 | delete(hset_object)
|
---|
3194 | end
|
---|
3195 | set(handles.DeleteObject,'Visible','off')
|
---|
3196 |
|
---|
3197 | %------------------------------------------------------------------------
|
---|
3198 | % --- Executed when CheckMask is activated
|
---|
3199 | %------------------------------------------------------------------------
|
---|
3200 | function CheckMask_Callback(hObject, eventdata, handles)
|
---|
3201 |
|
---|
3202 |
|
---|
3203 | if get(handles.CheckMask,'Value')
|
---|
3204 | set(handles.DeleteMask,'Visible','on')
|
---|
3205 | Param=read_GUI_series(handles); % displayed parameters
|
---|
3206 | NbView=size(Param.InputTable,1);
|
---|
3207 | MaskTable=cell(NbView,2);
|
---|
3208 |
|
---|
3209 | RootPath=Param.InputTable{1,1};
|
---|
3210 | first_j=[];% note that the function will propose to cover the whole range of indices
|
---|
3211 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
3212 | last_j=[];
|
---|
3213 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
3214 | PairString='';
|
---|
3215 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
3216 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
3217 | %checkmask=zeros(NbView,1);
|
---|
3218 | for iview=1:NbView
|
---|
3219 | checkmask=0;
|
---|
3220 | FirstFileName=fullfile_uvmat(Param.InputTable{iview,1},Param.InputTable{iview,2},Param.InputTable{iview,3},...
|
---|
3221 | Param.InputTable{iview,5},Param.InputTable{iview,4},i1,i2,j1,j2);
|
---|
3222 | Data=nc2struct(FirstFileName);
|
---|
3223 | if isfield(Data,'Civ2_Mask')
|
---|
3224 | MaskTable{iview,1}=Data.Civ2_Mask;
|
---|
3225 | checkmask=1;
|
---|
3226 | end
|
---|
3227 | if ~checkmask
|
---|
3228 | MaskTable{iview,1}=uigetfile_uvmat('select a mask file:',Param.InputTable{iview,1},'image');
|
---|
3229 | end
|
---|
3230 | end
|
---|
3231 | for iview=1:NbView
|
---|
3232 | [Path,Name]=fileparts(MaskTable{iview,1});
|
---|
3233 | Name=regexprep(Name,'_\d+','');
|
---|
3234 | maskfiles=dir(fullfile(Path,[Name '_*.png']));%look for mask files
|
---|
3235 | if ~isempty(maskfiles)
|
---|
3236 | for ilist=1:numel(maskfiles)
|
---|
3237 | r=regexp(maskfiles(ilist).name,'_(?<num1>\d+)','names');%look for burst pairs
|
---|
3238 | index(ilist)=str2double(r.num1);
|
---|
3239 | end
|
---|
3240 | MaskTable{iview,2}=max(index);
|
---|
3241 | end
|
---|
3242 | end
|
---|
3243 | set(handles.MaskTable,'Data',MaskTable)
|
---|
3244 | set(handles.CheckMask,'Value',0)
|
---|
3245 | end
|
---|
3246 | %
|
---|
3247 | % if ~isempty(NewMask)
|
---|
3248 | % if isempty(MaskList)
|
---|
3249 | % MaskList={NewMask};
|
---|
3250 | % else
|
---|
3251 | % MaskList={MaskList;NewMask};
|
---|
3252 | % end
|
---|
3253 | % set(handles.Mask,'String',MaskList)
|
---|
3254 | % end
|
---|
3255 | % end
|
---|
3256 | % % MaskTable=cell(nbview,1); % default
|
---|
3257 | % % ListMask=cell(nbview,1); % default
|
---|
3258 | % % MaskData=get(handles.MaskTable,'Data');
|
---|
3259 | % % MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1); % complement if undefined lines
|
---|
3260 | % for iview=1:nbview
|
---|
3261 | % ListMask{iview,1}=num2str(iview);
|
---|
3262 | % RootPath=InputTable{iview,1};
|
---|
3263 | % if ~isempty(RootPath)
|
---|
3264 | % if isempty(MaskData{iview})
|
---|
3265 | % SubDir=InputTable{iview,2};
|
---|
3266 | % MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']); % take the root part of SubDir, before the first dot '.'
|
---|
3267 | % if exist(MaskPath,'dir')
|
---|
3268 | % ListStruct=dir(MaskPath); % look for a mask file
|
---|
3269 | % ListCells=struct2cell(ListStruct); % transform dir struct to a cell arrray
|
---|
3270 | % check_dir=cell2mat(ListCells(4,:)); % =1 for directories, =0 for files
|
---|
3271 | % ListFiles=ListCells(1,:); % list of file and dri names
|
---|
3272 | % ListFiles=ListFiles(~check_dir); % list of file names (excluding dir)
|
---|
3273 | % mdetect=0;
|
---|
3274 | % if ~isempty(ListFiles)
|
---|
3275 | % for ifile=1:numel(ListFiles)
|
---|
3276 | % [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0);
|
---|
3277 | % if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
|
---|
3278 | % mdetect=1;
|
---|
3279 | % MaskName=ListFiles{ifile};
|
---|
3280 | % end
|
---|
3281 | % if ~strcmp(MaskFile{ifile},MaskFile{1})
|
---|
3282 | % mdetect=0; % cancel detection test in case of multiple masks, use the brower for selection
|
---|
3283 | % break
|
---|
3284 | % end
|
---|
3285 | % end
|
---|
3286 | % end
|
---|
3287 | % if mdetect==1
|
---|
3288 | % MaskName=fullfile(MaskPath,'mask_1.png');
|
---|
3289 | % else
|
---|
3290 | % MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image');
|
---|
3291 | % end
|
---|
3292 | % else
|
---|
3293 | % MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
|
---|
3294 | % end
|
---|
3295 | % MaskTable{iview,1}=MaskName ;
|
---|
3296 | % ListMask{iview,1}=num2str(iview);
|
---|
3297 | % end
|
---|
3298 | % end
|
---|
3299 | % end
|
---|
3300 | % set(handles.MaskTable,'Data',MaskTable)
|
---|
3301 | % set(handles.MaskTable,'Visible','on')
|
---|
3302 | % set(handles.MaskBrowse,'Visible','on')
|
---|
3303 | % set(handles.ListMask,'Visible','on')
|
---|
3304 | % set(handles.ListMask,'String',ListMask)
|
---|
3305 | % set(handles.ListMask,'Value',1)
|
---|
3306 |
|
---|
3307 |
|
---|
3308 |
|
---|
3309 | %------------------------------------------------------------------------
|
---|
3310 | % --- Executes when selected cell(s) is changed in MaskTable.
|
---|
3311 | %------------------------------------------------------------------------
|
---|
3312 | function MaskTable_CellSelectionCallback(hObject, eventdata, handles)
|
---|
3313 |
|
---|
3314 | if numel(eventdata.Indices)>=1
|
---|
3315 | set(handles.ListMask,'Value',eventdata.Indices(1))
|
---|
3316 | end
|
---|
3317 |
|
---|
3318 | %-------------------------------------------------------------------
|
---|
3319 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
3320 | %-------------------------------------------------------------------
|
---|
3321 |
|
---|
3322 |
|
---|
3323 | % path_to_uvmat=which ('uvmat'); % check the path of uvmat
|
---|
3324 | % pathelp=fileparts(path_to_uvmat);
|
---|
3325 | % helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
3326 | % 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')
|
---|
3327 | % else
|
---|
3328 | % addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
3329 | % web([helpfile '#series'])
|
---|
3330 | % end
|
---|
3331 |
|
---|
3332 | %-------------------------------------------------------------------
|
---|
3333 | % --- Executes on selection change in TransformName.
|
---|
3334 | function TransformName_Callback(hObject, eventdata, handles)
|
---|
3335 | %----------------------------------------------------------------------
|
---|
3336 | TransformList=get(handles.TransformName,'String');
|
---|
3337 | TransformIndex=get(handles.TransformName,'Value');
|
---|
3338 | TransformName=TransformList{TransformIndex};
|
---|
3339 | TransformPathList=get(handles.TransformName,'UserData');
|
---|
3340 | nb_builtin_transform=4;
|
---|
3341 |
|
---|
3342 | %% browse transform functions with the input menu option more...
|
---|
3343 | if isequal(TransformName,'more...')% browse transform functions
|
---|
3344 | FileName=uigetfile_uvmat('Pick a transform function',get(handles.TransformPath,'String'),'.m');
|
---|
3345 | if isempty(FileName)
|
---|
3346 | return %browser closed without choice
|
---|
3347 | end
|
---|
3348 | [TransformPath,TransformName,TransformExt]=fileparts(FileName); % removes extension .m
|
---|
3349 | if ~strcmp(TransformExt,'.m')
|
---|
3350 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
3351 | return
|
---|
3352 | end
|
---|
3353 | % insert the choice in the menu
|
---|
3354 | TransformIndex=find(strcmp(TransformName,TransformList),1); % look for the selected function in the menu Action
|
---|
3355 | if isempty(TransformIndex)%the input string does not exist in the menu
|
---|
3356 | TransformIndex= length(TransformList);
|
---|
3357 | TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)]; % the selected function is appended in the menu, before the last item 'more...'
|
---|
3358 | set(handles.TransformName,'String',TransformList)
|
---|
3359 | TransformPathList=[TransformPathList;{TransformPath}];
|
---|
3360 | else% the input function already exist, we update its path (possibly new)
|
---|
3361 | TransformPathList{TransformIndex}=TransformPath; %
|
---|
3362 | set(handles.TransformName,'Value',TransformIndex)
|
---|
3363 | end
|
---|
3364 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
3365 | dir_perso=prefdir; % personal Matalb directory
|
---|
3366 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
3367 | if exist(profil_perso,'file')
|
---|
3368 | for ilist=nb_builtin_transform+1:numel(TransformPathList)
|
---|
3369 | TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist};
|
---|
3370 | TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist};
|
---|
3371 | end
|
---|
3372 | TransformPathListUser=TransformPathListUser';
|
---|
3373 | TransformListUser=TransformListUser';
|
---|
3374 | save (profil_perso,'TransformPathListUser','TransformListUser','-append'); % store the root name for future opening of uvmat
|
---|
3375 | end
|
---|
3376 | end
|
---|
3377 |
|
---|
3378 | %% display the current function path
|
---|
3379 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}); % show the path to the senlected function
|
---|
3380 | set(handles.TransformName,'UserData',TransformPathList);
|
---|
3381 |
|
---|
3382 | %% create the function handle of the selected fct
|
---|
3383 | if ~isempty(TransformName)
|
---|
3384 | if ~exist(TransformPathList{TransformIndex},'dir')
|
---|
3385 | msgbox_uvmat('ERROR',['The prescribed transform function path ' TransformPathList{TransformIndex} ' does not exist']);
|
---|
3386 | return
|
---|
3387 | end
|
---|
3388 | current_dir=pwd; % current working dir
|
---|
3389 | cd(TransformPathList{TransformIndex})
|
---|
3390 | transform_handle=str2func(TransformName);
|
---|
3391 | cd(current_dir)
|
---|
3392 | Field.Action.RUN=0;% indicate that the transform fct is called only to get input param
|
---|
3393 | SeriesData=get(handles.series,'UserData');
|
---|
3394 | ParamIn=[];
|
---|
3395 | if isfield(SeriesData,'TransformInput')
|
---|
3396 | ParamIn.TransformInput=SeriesData.TransformInput;
|
---|
3397 | end
|
---|
3398 | DataOut=feval(transform_handle,Field,ParamIn);% execute the transform fct to get its input parameters
|
---|
3399 | if isfield(DataOut,'TransformInput')% used to add transform parameters at selection of the transform fct
|
---|
3400 | SeriesData.TransformInput=DataOut.TransformInput;
|
---|
3401 | set(handles.series,'UserData',SeriesData)
|
---|
3402 | end
|
---|
3403 | end
|
---|
3404 |
|
---|
3405 | %------------------------------------------------------------------------
|
---|
3406 | % --- fct activated by the upper bar menu ExportConfig
|
---|
3407 | %------------------------------------------------------------------------
|
---|
3408 | function MenuDisplayConfig_Callback(hObject, eventdata, handles)
|
---|
3409 |
|
---|
3410 | global Param
|
---|
3411 | Param=read_GUI_series(handles);
|
---|
3412 | evalin('base','global Param')%make CurData global in the workspace
|
---|
3413 | display('current series config :')
|
---|
3414 | evalin('base','Param') %display CurData in the workspace
|
---|
3415 | commandwindow; % brings the Matlab command window to the front
|
---|
3416 |
|
---|
3417 | %------------------------------------------------------------------------
|
---|
3418 | % --- fct activated by the upper bar menu InportConfig: import
|
---|
3419 | % menu settings from an xml file (stored in /0_XML for each run)
|
---|
3420 | %------------------------------------------------------------------------
|
---|
3421 | function MenuImportConfig_Callback(hObject, eventdata, handles)
|
---|
3422 |
|
---|
3423 | %% use a browser to choose the xml file containing the processing config
|
---|
3424 | InputTable=get(handles.InputTable,'Data');
|
---|
3425 | oldfile=InputTable{1,1}; % current path in InputTable
|
---|
3426 | if isempty(oldfile)
|
---|
3427 | % use a file name stored in prefdir
|
---|
3428 | dir_perso=prefdir;
|
---|
3429 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
3430 | if exist(profil_perso,'file')
|
---|
3431 | h=load (profil_perso);
|
---|
3432 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
3433 | oldfile=h.RootPath;
|
---|
3434 | end
|
---|
3435 | end
|
---|
3436 | end
|
---|
3437 | filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml'); % get the xml file containing processing parameters
|
---|
3438 | if isempty(filexml), return, end % quit function if an xml file has not been opened
|
---|
3439 |
|
---|
3440 | %% fill the GUI series with the content of the xml file
|
---|
3441 | [Param,RootTag,errormsg]=xml2struct(filexml); % read the input xml file as a Matlab structure
|
---|
3442 | if ~isempty(errormsg)
|
---|
3443 | msgbox_uvmat('ERROR',errormsg);
|
---|
3444 | return
|
---|
3445 | end
|
---|
3446 | % ask to stop current Action if button RUN is in action (another process is already running)
|
---|
3447 | if isequal(get(handles.RUN,'Value'),1)
|
---|
3448 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
|
---|
3449 | if strcmp(answer,'Yes')
|
---|
3450 | STOP_Callback(hObject, eventdata, handles)
|
---|
3451 | else
|
---|
3452 | return
|
---|
3453 | end
|
---|
3454 | end
|
---|
3455 | Param.Action.RUN=0; % desactivate the input RUN=1
|
---|
3456 |
|
---|
3457 | fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters
|
---|
3458 | SeriesData=get(handles.series,'UserData');
|
---|
3459 | if isfield(Param,'InputFields')
|
---|
3460 | ListField=Param.InputFields.FieldName;
|
---|
3461 | if ischar(ListField),ListField={ListField}; end
|
---|
3462 | set(handles.FieldName,'String',[ListField;{'add_field...'}])
|
---|
3463 | set(handles.FieldName,'Value',1:numel(ListField))
|
---|
3464 | set(handles.FieldName,'Visible','on')
|
---|
3465 | end
|
---|
3466 | if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters
|
---|
3467 | % set(handles.ActionInput,'Visible','on')
|
---|
3468 | % set(handles.ActionInput,'Value',0)
|
---|
3469 | Param.ActionInput.ConfigSource=filexml; % record the source of config for future info
|
---|
3470 | SeriesData.ActionInput=Param.ActionInput;
|
---|
3471 | end
|
---|
3472 | if isfield(Param,'TransformInput')% introduce parameters specific to a transform fct
|
---|
3473 | SeriesData.TransformInput=Param.TransformInput;
|
---|
3474 | end
|
---|
3475 | if isfield(Param,'ProjObject') %introduce projection object if relevant
|
---|
3476 | SeriesData.ProjObject=Param.ProjObject;
|
---|
3477 | end
|
---|
3478 | set(handles.series,'UserData',SeriesData)
|
---|
3479 | if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1)
|
---|
3480 | set(handles.ProjObjectName,'String',Param.ProjObject.Name)
|
---|
3481 | set(handles.ViewObject,'Visible','on')
|
---|
3482 | set(handles.EditObject,'Visible','on')
|
---|
3483 | set(handles.DeleteObject,'Visible','on')
|
---|
3484 | else
|
---|
3485 | set(handles.ProjObjectName,'String','')
|
---|
3486 | set(handles.ProjObjectName,'Visible','off')
|
---|
3487 | set(handles.ViewObject,'Visible','off')
|
---|
3488 | set(handles.EditObject,'Visible','off')
|
---|
3489 | set(handles.DeleteObject,'Visible','off')
|
---|
3490 | end
|
---|
3491 | set(handles.REFRESH,'BackgroundColor',[1 0 1]); % paint REFRESH button in magenta to indicate that it should be activated
|
---|
3492 |
|
---|
3493 |
|
---|
3494 | %------------------------------------------------------------------------
|
---|
3495 | % --- Executes when the GUI series is resized.
|
---|
3496 | %------------------------------------------------------------------------
|
---|
3497 | function series_ResizeFcn(hObject, eventdata, handles)
|
---|
3498 |
|
---|
3499 | %% input table
|
---|
3500 | set(handles.InputTable,'Unit','pixel')
|
---|
3501 | Pos=get(handles.InputTable,'Position');
|
---|
3502 | set(handles.InputTable,'Unit','normalized')
|
---|
3503 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52));
|
---|
3504 | ColumnWidth=num2cell(ColumnWidth);
|
---|
3505 | set(handles.InputTable,'ColumnWidth',ColumnWidth)
|
---|
3506 |
|
---|
3507 | %% MaskTable
|
---|
3508 | set(handles.MaskTable,'Unit','pixel')
|
---|
3509 | Pos=get(handles.MaskTable,'Position');
|
---|
3510 | set(handles.MaskTable,'Unit','normalized')
|
---|
3511 | ColumnWidth=round([0.9 0.1]*(Pos(3)-52));
|
---|
3512 | ColumnWidth=num2cell(ColumnWidth);
|
---|
3513 | set(handles.MaskTable,'ColumnWidth',ColumnWidth)
|
---|
3514 |
|
---|
3515 | %% MinIndex_j and MaxIndex_i
|
---|
3516 | unit=get(handles.MinIndex_i,'Unit');
|
---|
3517 | set(handles.MinIndex_i,'Unit','pixel')
|
---|
3518 | Pos=get(handles.MinIndex_i,'Position');
|
---|
3519 | set(handles.MinIndex_i,'Unit',unit)
|
---|
3520 | set(handles.MinIndex_i,'ColumnWidth',{Pos(3)-18})
|
---|
3521 | set(handles.MaxIndex_i,'ColumnWidth',{Pos(3)-18})
|
---|
3522 | set(handles.MinIndex_j,'ColumnWidth',{Pos(3)-18})
|
---|
3523 | set(handles.MaxIndex_j,'ColumnWidth',{Pos(3)-18})
|
---|
3524 |
|
---|
3525 | %% TimeTable
|
---|
3526 | set(handles.TimeTable,'Unit','pixel')
|
---|
3527 | Pos=get(handles.TimeTable,'Position');
|
---|
3528 | set(handles.TimeTable,'Unit','normalized')
|
---|
3529 | % ColumnWidth=get(handles.TimeTable,'ColumnWidth');
|
---|
3530 | ColumnWidth=num2cell(floor([0.2 0.2 0.2 0.2 0.2]*(Pos(3)-20)));
|
---|
3531 | set(handles.TimeTable,'ColumnWidth',ColumnWidth)
|
---|
3532 |
|
---|
3533 |
|
---|
3534 | %% PairString
|
---|
3535 | set(handles.PairString,'Unit','pixel')
|
---|
3536 | Pos=get(handles.PairString,'Position');
|
---|
3537 | set(handles.PairString,'Unit','normalized')
|
---|
3538 | set(handles.PairString,'ColumnWidth',{Pos(3)-5})
|
---|
3539 |
|
---|
3540 | %% MaskTable
|
---|
3541 | % % set(handles.MaskTable,'Unit','pixel')
|
---|
3542 | % % Pos=get(handles.MaskTable,'Position');
|
---|
3543 | % % set(handles.MaskTable,'Unit','normalized')
|
---|
3544 | % % set(handles.MaskTable,'ColumnWidth',{Pos(3)-5})
|
---|
3545 |
|
---|
3546 | %------------------------------------------------------------------------
|
---|
3547 | % --- Executes on button press in status.
|
---|
3548 | %------------------------------------------------------------------------
|
---|
3549 | function status_Callback(hObject, eventdata, handles)
|
---|
3550 |
|
---|
3551 | if get(handles.status,'Value')
|
---|
3552 | set(handles.status,'BackgroundColor',[1 1 0])
|
---|
3553 | drawnow
|
---|
3554 | Param=read_GUI(handles.series);
|
---|
3555 | RootPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
|
---|
3556 | if ~isfield(Param,'OutputSubDir')
|
---|
3557 | msgbox_uvmat('ERROR','no standard sub-directory definition for output files, use a browser to check the output')
|
---|
3558 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
3559 | return
|
---|
3560 | end
|
---|
3561 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt]; % subdirectory for output files
|
---|
3562 | OutputDir=fullfile(RootPath,OutputSubDir);
|
---|
3563 | if exist(OutputDir,'dir')
|
---|
3564 | uigetfile_uvmat('status_display',OutputDir)
|
---|
3565 | else
|
---|
3566 | msgbox_uvmat('ERROR','output folder not created yet: calculation did not start')
|
---|
3567 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
3568 | end
|
---|
3569 | else
|
---|
3570 | %% delete current display fig if selection is off
|
---|
3571 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
3572 | hfig=findobj(allchild(0),'name','status_display');
|
---|
3573 | if ~isempty(hfig)
|
---|
3574 | delete(hfig)
|
---|
3575 | end
|
---|
3576 | return
|
---|
3577 | end
|
---|
3578 |
|
---|
3579 |
|
---|
3580 | %------------------------------------------------------------------------
|
---|
3581 | % launched by selecting a file on the list
|
---|
3582 | %------------------------------------------------------------------------
|
---|
3583 | function view_file(hObject, eventdata)
|
---|
3584 |
|
---|
3585 | list=get(hObject,'String');
|
---|
3586 | index=get(hObject,'Value');
|
---|
3587 | rootroot=get(hObject,'UserData');
|
---|
3588 | selectname=list{index};
|
---|
3589 | ind_dot=regexp(selectname,'\.\.\.');
|
---|
3590 | if ~isempty(ind_dot)
|
---|
3591 | selectname=selectname(1:ind_dot-1);
|
---|
3592 | end
|
---|
3593 | FullSelectName=fullfile(rootroot,selectname);
|
---|
3594 | if exist(FullSelectName,'dir')% a directory has been selected
|
---|
3595 | ListFiles=dir(FullSelectName);
|
---|
3596 | ListDisplay=cell(numel(ListFiles),1);
|
---|
3597 | for ilist=2:numel(ListDisplay)% suppress the first line '.'
|
---|
3598 | ListDisplay{ilist-1}=ListFiles(ilist).name;
|
---|
3599 | end
|
---|
3600 | set(hObject,'Value',1)
|
---|
3601 | set(hObject,'String',ListDisplay)
|
---|
3602 | if strcmp(selectname,'..')
|
---|
3603 | FullSelectName=fileparts(fileparts(FullSelectName));
|
---|
3604 | end
|
---|
3605 | set(hObject,'UserData',FullSelectName)
|
---|
3606 | hfig=get(hObject,'parent');
|
---|
3607 | htitlebox=findobj(hfig,'tag','titlebox');
|
---|
3608 | set(htitlebox,'String',FullSelectName)
|
---|
3609 | elseif exist(FullSelectName,'file')%visualise the vel field if it exists
|
---|
3610 | FileInfo=get_file_info(FullSelectName);
|
---|
3611 | if strcmp(FileInfo.FileType,'txt')
|
---|
3612 | edit(FullSelectName)
|
---|
3613 | elseif strcmp(FileInfo.FileType,'xml')
|
---|
3614 | editxml(FullSelectName)
|
---|
3615 | else
|
---|
3616 | uvmat(FullSelectName)
|
---|
3617 | end
|
---|
3618 | set(gcbo,'Value',1)
|
---|
3619 | end
|
---|
3620 |
|
---|
3621 |
|
---|
3622 | %------------------------------------------------------------------------
|
---|
3623 | % launched by refreshing the status figure
|
---|
3624 | %------------------------------------------------------------------------
|
---|
3625 | function refresh_GUI(hfig)
|
---|
3626 |
|
---|
3627 | htitlebox=findobj(hfig,'tag','titlebox');
|
---|
3628 | hlist=findobj(hfig,'tag','list');
|
---|
3629 | hseries=findobj(allchild(0),'tag','series');
|
---|
3630 | hstatus=findobj(hseries,'tag','status');
|
---|
3631 | StatusData=get(hstatus,'UserData');
|
---|
3632 | OutputDir=get(htitlebox,'String');
|
---|
3633 | if ischar(OutputDir),OutputDir={OutputDir};end
|
---|
3634 | ListFiles=dir(OutputDir{1});
|
---|
3635 | if numel(ListFiles)<1
|
---|
3636 | return
|
---|
3637 | end
|
---|
3638 | ListFiles(1)=[]; % removes the first line ='.'
|
---|
3639 | ListDisplay=cell(numel(ListFiles),1);
|
---|
3640 | testrecent=0;
|
---|
3641 | datnum=zeros(numel(ListDisplay),1);
|
---|
3642 | for ilist=1:numel(ListDisplay)
|
---|
3643 | ListDisplay{ilist}=ListFiles(ilist).name;
|
---|
3644 | if ~ListFiles(ilist).isdir && isfield(ListFiles(ilist),'datenum')
|
---|
3645 | datnum(ilist)=ListFiles(ilist).datenum; % only available in recent matlab versions
|
---|
3646 | testrecent=1;
|
---|
3647 | end
|
---|
3648 | end
|
---|
3649 | set(hlist,'String',ListDisplay)
|
---|
3650 |
|
---|
3651 | %% Look at date of creation
|
---|
3652 | ListDisplay=ListDisplay(datnum~=0);
|
---|
3653 | datnum=datnum(datnum~=0); % keep the non zero values corresponding to existing files
|
---|
3654 | NbOutputFile=[];
|
---|
3655 | if isempty(datnum)
|
---|
3656 | if testrecent
|
---|
3657 | message='no civ result created yet';
|
---|
3658 | else
|
---|
3659 | message='';
|
---|
3660 | end
|
---|
3661 | else
|
---|
3662 | [first,indfirst]=min(datnum);
|
---|
3663 | [last,indlast]=max(datnum);
|
---|
3664 | NbOutputFile_str='?';
|
---|
3665 | NbOutputFile=[];
|
---|
3666 | if isfield(StatusData,'NbOutputFile')
|
---|
3667 | NbOutputFile=StatusData.NbOutputFile;
|
---|
3668 | NbOutputFile_str=num2str(NbOutputFile);
|
---|
3669 | end
|
---|
3670 | message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];...
|
---|
3671 | ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]};
|
---|
3672 | end
|
---|
3673 | set(htitlebox,'String', [OutputDir{1};message])
|
---|
3674 |
|
---|
3675 | %% update the waitbar
|
---|
3676 | hwaitbar=findobj(hfig,'tag','waitbar');
|
---|
3677 | if ~isempty(NbOutputFile)
|
---|
3678 | BarPosition=get(hwaitbar,'Position');
|
---|
3679 | BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
|
---|
3680 | set(hwaitbar,'Position',BarPosition)
|
---|
3681 | end
|
---|
3682 |
|
---|
3683 | %------------------------------------------------------------------------
|
---|
3684 | % --- Executes on selection change in ActionExt.
|
---|
3685 | %------------------------------------------------------------------------
|
---|
3686 | function ActionExt_Callback(hObject, eventdata, handles)
|
---|
3687 |
|
---|
3688 | ActionExtList=get(handles.ActionExt,'String');
|
---|
3689 | ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
|
---|
3690 | if strcmp(ActionExt,'fluidimage')
|
---|
3691 | set(handles.RunMode,'Value',2)
|
---|
3692 | end
|
---|
3693 |
|
---|
3694 |
|
---|
3695 | function num_NbSlice_Callback(hObject, eventdata, handles)
|
---|
3696 | NbSlice=str2num(get(handles.num_NbSlice,'String'));
|
---|
3697 |
|
---|
3698 | %------------------------------------------------------------------------
|
---|
3699 | % --- set the visibility of relevant velocity type menus:
|
---|
3700 | function menu=set_veltype_display(Civ,FileType)
|
---|
3701 | %------------------------------------------------------------------------
|
---|
3702 | if ~exist('FileType','var')
|
---|
3703 | FileType='civx';
|
---|
3704 | end
|
---|
3705 | switch FileType
|
---|
3706 | case 'civx'
|
---|
3707 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
|
---|
3708 | if isequal(Civ,0)
|
---|
3709 | imax=0;
|
---|
3710 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
3711 | imax=1;
|
---|
3712 | elseif isequal(Civ,3)
|
---|
3713 | imax=3;
|
---|
3714 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
3715 | imax=4;
|
---|
3716 | elseif isequal(Civ,6) %patch2
|
---|
3717 | imax=6;
|
---|
3718 | end
|
---|
3719 | case 'civdata'
|
---|
3720 | menu={'civ1';'filter1';'civ2';'filter2'};
|
---|
3721 | if isequal(Civ,0)
|
---|
3722 | imax=0;
|
---|
3723 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
3724 | imax=1;
|
---|
3725 | elseif isequal(Civ,3)
|
---|
3726 | imax=2;
|
---|
3727 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
3728 | imax=3;
|
---|
3729 | else%if isequal(Civ,6) %patch2
|
---|
3730 | imax=4;
|
---|
3731 | end
|
---|
3732 | end
|
---|
3733 | menu=menu(1:imax);
|
---|
3734 |
|
---|
3735 |
|
---|
3736 | % --- Executes on mouse motion over figure - except title and menu.
|
---|
3737 | % function series_WindowButtonMotionFcn(hObject, eventdata, handles)
|
---|
3738 | % set(hObject,'Pointer','arrow');
|
---|
3739 |
|
---|
3740 |
|
---|
3741 | % --- Executes on button press in SetPairs.
|
---|
3742 | function SetPairs_Callback(hObject, eventdata, handles)
|
---|
3743 |
|
---|
3744 | %% delete previous occurrence of 'set_pairs'
|
---|
3745 | hfig=findobj(allchild(0),'Tag','set_pairs');
|
---|
3746 | if ~isempty(hfig)
|
---|
3747 | delete(hfig)
|
---|
3748 | end
|
---|
3749 |
|
---|
3750 | %% create the GUI set_pairs
|
---|
3751 | set(0,'Unit','points')
|
---|
3752 | ScreenSize=get(0,'ScreenSize'); % get the size of the screen, to put the fig on the upper right
|
---|
3753 | Width=220; % fig width in points (1/72 inch)
|
---|
3754 | Height=min(0.8*ScreenSize(4),300);
|
---|
3755 | Left=ScreenSize(3)- Width-40; % right edge close to the right, with margin=40
|
---|
3756 | Bottom=ScreenSize(4)-Height-40; % put fig at top right
|
---|
3757 | hfig=findobj(allchild(0),'Tag','set_slice');
|
---|
3758 | if ~isempty(hfig),delete(hfig), end; % delete existing version of the GUI
|
---|
3759 | hfig=figure('name','set_pairs','tag','set_pairs','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height]);
|
---|
3760 | BackgroundColor=get(hfig,'Color');
|
---|
3761 | SeriesData=get(handles.series,'UserData');
|
---|
3762 | TimeUnit=get(handles.TimeUnit,'String');
|
---|
3763 | PairString=get(handles.PairString,'Data');
|
---|
3764 | ListViewLines=find(cellfun('isempty',PairString)==0); % find list of non empty pairs
|
---|
3765 | ListViewMenu=cell(numel(ListViewLines),1);
|
---|
3766 | %iview=get(handles.PairString,'Value');
|
---|
3767 | iview=[];
|
---|
3768 | for ilist=1:numel(ListViewLines)
|
---|
3769 | ListViewMenu{ilist}=num2str(ListViewLines(ilist));
|
---|
3770 | end
|
---|
3771 | if isempty(iview)
|
---|
3772 | ListViewValue=numel(ListViewLines); % we work by default on the pair option for the last line which requires pairs
|
---|
3773 | iview=ListViewLines(end);
|
---|
3774 | else
|
---|
3775 | ListViewValue=find(ListViewLines==iview);
|
---|
3776 | end
|
---|
3777 | ref_i=str2num(get(handles.num_first_i,'String'));
|
---|
3778 | ref_j=1; % default
|
---|
3779 | if strcmp(get(handles.num_first_j,'String'),'Visible')
|
---|
3780 | ref_j=str2num(get(handles.num_first_j,'String'));
|
---|
3781 | end
|
---|
3782 | [ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{1},SeriesData.i2_series{1},SeriesData.j2_series{1});
|
---|
3783 | InputTable=get(handles.InputTable,'Data');
|
---|
3784 | displ_pair=update_listpair(SeriesData.i1_series{1},SeriesData.i2_series{1},SeriesData.j1_series{1},SeriesData.j2_series{1},ModeMenu{ModeValue},...
|
---|
3785 | SeriesData.Time{1},TimeUnit,ref_i,ref_j,SeriesData.TimeName,InputTable,SeriesData.FileInfo{1});
|
---|
3786 | for iline=1:size(InputTable,1)
|
---|
3787 | viewcell{iline}=num2str(iline);
|
---|
3788 | end
|
---|
3789 | viewcell=viewcell';
|
---|
3790 | ModeMenu={'bursts';'series(Dj)'};
|
---|
3791 | ModeValue=1;
|
---|
3792 | %i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo
|
---|
3793 | % first raw of the GUI
|
---|
3794 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.88 0.5 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3795 | 'String','row to edit #','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right'); % title
|
---|
3796 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.54 0.8 0.3 0.2],'BackgroundColor',[1 1 1],...
|
---|
3797 | 'Callback',@(hObject,eventdata)ListView_Callback(hObject,eventdata),'String',viewcell,'Value',1,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3798 | 'Tag','ListView','TooltipString','''ListView'':choice of the file series w for pair display');
|
---|
3799 | % second raw of the GUI
|
---|
3800 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.79 0.7 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3801 | 'String','mode of index pairing:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); % title
|
---|
3802 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.05 0.62 0.9 0.2],'BackgroundColor',[1 1 1],...
|
---|
3803 | 'Callback',@(hObject,eventdata)Mode_Callback(hObject,eventdata),'String',ModeMenu,'Value',ModeValue,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3804 | 'Tag','Mode','TooltipString','''Mode'': choice of the image pair mode');
|
---|
3805 | % third raw
|
---|
3806 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.6 0.7 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3807 | 'String','pair choice:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); % title
|
---|
3808 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.42 0.9 0.2],'BackgroundColor',[1 1 1],...
|
---|
3809 | 'Callback',@(hObject,eventdata)ListPair_Callback(hObject,eventdata),'String',displ_pair,'Value',1,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3810 | 'Tag','ListPair','TooltipString','''ListPair'': menu for selecting the image pair');
|
---|
3811 | uicontrol('Style','text','Units','normalized', 'Position', [0.1 0.22 0.8 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3812 | 'String','ref_i ref_j','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center'); % title
|
---|
3813 | uicontrol('Style','edit','Units','normalized', 'Position', [0.15 0.17 0.3 0.08],'BackgroundColor',[1 1 1],...
|
---|
3814 | 'Callback',@(hObject,eventdata)num_ref_i_Callback(hObject,eventdata),'String',num2str(ref_i),'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3815 | 'Tag','num_ref_i','TooltipString','''num_ref_i'': reference field index i used to display dt in ''list_pair_civ''');
|
---|
3816 | uicontrol('Style','edit','Units','normalized', 'Position', [0.55 0.17 0.3 0.08],'BackgroundColor',[1 1 1],...
|
---|
3817 | 'Callback',@(hObject,eventdata)num_ref_j_Callback(hObject,eventdata),'String',num2str(ref_j),'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3818 | 'Tag','num_ref_j','TooltipString','''num_ref_j'': reference field index i used to display dt in ''list_pair_civ''');
|
---|
3819 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.01 0.01 0.3 0.12],'BackgroundColor',[0 1 0],...
|
---|
3820 | 'Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),'String','OK','FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3821 | 'Tag','OK','TooltipString','''OK'': validate the choice');
|
---|
3822 | % last raw of the GUI: pushbuttons
|
---|
3823 | % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.35 0.01 0.3 0.15],'BackgroundColor',[0 1 0],'String','OK','Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),...
|
---|
3824 | % 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''OK'': apply the output to the current field series in uvmat');
|
---|
3825 | drawnow
|
---|
3826 |
|
---|
3827 | %------------------------------------------------------------------------
|
---|
3828 | function ListView_Callback(hObject,eventdata)
|
---|
3829 | Mode_Callback(hObject,eventdata)
|
---|
3830 |
|
---|
3831 | %------------------------------------------------------------------------
|
---|
3832 | function Mode_Callback(hObject,eventdata)
|
---|
3833 | %% get input info
|
---|
3834 | hseries=findobj(allchild(0),'tag','series'); % handles of the GUI series
|
---|
3835 | hhseries=guidata(hseries); % handles of the elements in the GUI series
|
---|
3836 | TimeUnit=get(hhseries.TimeUnit,'String');
|
---|
3837 | SeriesData=get(hseries,'UserData');
|
---|
3838 | mode_list=get(hObject,'String');
|
---|
3839 | mode=mode_list{get(hObject,'Value')};
|
---|
3840 | hListView=findobj(get(hObject,'parent'),'Tag','ListView');
|
---|
3841 | iview=get(hListView,'Value');
|
---|
3842 | i1_series=SeriesData.i1_series{iview};
|
---|
3843 | i2_series=SeriesData.i2_series{iview};
|
---|
3844 | j1_series=SeriesData.j1_series{iview};
|
---|
3845 | j2_series=SeriesData.j2_series{iview};
|
---|
3846 |
|
---|
3847 | %% enable j index visibility after the new choice
|
---|
3848 |
|
---|
3849 | if strcmp(mode,'series(Dj)')
|
---|
3850 | status_j='on'; % default
|
---|
3851 | else
|
---|
3852 | status_j='off'; % no j index needed for bust case
|
---|
3853 | end
|
---|
3854 | enable_j(hhseries,status_j) % no j index needed
|
---|
3855 |
|
---|
3856 | %% get the reference indices for the time interval Dt
|
---|
3857 | href_i=findobj(get(hObject,'parent'),'Tag','ref_i');
|
---|
3858 | ref_i=[];ref_j=[];
|
---|
3859 | if strcmp(get(href_i,'Visible'),'on')
|
---|
3860 | ref_i=str2num(get(href_i,'String'));
|
---|
3861 | end
|
---|
3862 | if isempty(ref_i)
|
---|
3863 | ref_i=1;
|
---|
3864 | end
|
---|
3865 | if isempty(ref_j)
|
---|
3866 | ref_j=1;
|
---|
3867 | end
|
---|
3868 |
|
---|
3869 | %% update the menu ListPair
|
---|
3870 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j,SeriesData.FileInfo);
|
---|
3871 | hlist_pairs=findobj(get(hObject,'parent'),'Tag','ListPair');
|
---|
3872 | set(hlist_pairs,'Value',1)% set the first choice by default in ListPair
|
---|
3873 | set(hlist_pairs,'String',Menu)% set the menu in ListPair
|
---|
3874 | ListPair_Callback(hlist_pairs,[])% apply the default choice in ListPair
|
---|
3875 |
|
---|
3876 | %-------------------------------------------------------------
|
---|
3877 | % --- Executes on selection in ListPair.
|
---|
3878 | function ListPair_Callback(hObject,eventdata)
|
---|
3879 | %------------------------------------------------------------
|
---|
3880 | list_pair=get(hObject,'String'); % get the menu of image pairs
|
---|
3881 | if isempty(list_pair)
|
---|
3882 | string='';
|
---|
3883 | else
|
---|
3884 | string=list_pair{get(hObject,'Value')};
|
---|
3885 | % string=regexprep(string,',.*',''); % removes time indication (after ',')
|
---|
3886 | end
|
---|
3887 | hseries=findobj(allchild(0),'tag','series');
|
---|
3888 | hPairString=findobj(hseries,'tag','PairString');
|
---|
3889 | PairString=get(hPairString,'Data');
|
---|
3890 | hListView=findobj(get(hObject,'parent'),'Tag','ListView');
|
---|
3891 | iview=get(hListView,'Value');
|
---|
3892 | PairString{iview,1}=string;
|
---|
3893 | % report the selected pair string to the table PairString
|
---|
3894 | set(hPairString,'Data',PairString)
|
---|
3895 |
|
---|
3896 |
|
---|
3897 | %------------------------------------------------------------------------
|
---|
3898 | function num_ref_i_Callback(hObject, eventdata)
|
---|
3899 | %------------------------------------------------------------------------
|
---|
3900 | Mode_Callback([],[])
|
---|
3901 |
|
---|
3902 | %------------------------------------------------------------------------
|
---|
3903 | function num_ref_j_Callback(hObject, eventdata)
|
---|
3904 | %------------------------------------------------------------------------
|
---|
3905 | Mode_Callback([],[])
|
---|
3906 |
|
---|
3907 | %------------------------------------------------------------------------
|
---|
3908 | function OK_Callback(hObject, eventdata)
|
---|
3909 | %------------------------------------------------------------------------
|
---|
3910 | delete(get(hObject,'parent'))
|
---|
3911 |
|
---|
3912 |
|
---|
3913 | %------------------------------------------------------------------------
|
---|
3914 | % --- Executes on button press in ClearLine.
|
---|
3915 | %------------------------------------------------------------------------
|
---|
3916 | function ClearLine_Callback(hObject, eventdata, handles)
|
---|
3917 | InputTable=get(handles.InputTable,'Data');
|
---|
3918 | iline=str2double(get(handles.InputLine,'String'));
|
---|
3919 | if size(InputTable,1)>1
|
---|
3920 | InputTable(iline,:)=[]; % suppress the current line if not the first
|
---|
3921 | set(handles.InputTable,'Data',InputTable);
|
---|
3922 | end
|
---|
3923 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refr
|
---|
3924 |
|
---|
3925 |
|
---|
3926 | % --- Executes on button press in MonitorCluster.
|
---|
3927 | function MonitorCluster_Callback(hObject, eventdata, handles)
|
---|
3928 |
|
---|
3929 | [rr,ss]=system('oarstat |grep N=UVmat');% check the list of jobs launched with uvmat
|
---|
3930 | if isempty(ss)
|
---|
3931 | disp( 'no job presently submitted with uvmat')
|
---|
3932 | else
|
---|
3933 | disp('format: R/W=run/wait, time lapsed, R=nbre of cores,W=walltime')
|
---|
3934 | disp(ss)
|
---|
3935 | end
|
---|
3936 |
|
---|
3937 |
|
---|
3938 | function OutputSubDir_Callback(hObject, eventdata, handles)
|
---|
3939 | set(handles.OutputSubDir,'BackgroundColor',[1 1 1])
|
---|
3940 |
|
---|
3941 |
|
---|
3942 | % --- Executes on button press in CheckOverwrite.
|
---|
3943 | function CheckOverwrite_Callback(hObject, eventdata, handles)
|
---|
3944 |
|
---|
3945 | % --- Executes on button press in TestCPUTime.
|
---|
3946 | function TestCPUTime_Callback(hObject, eventdata, handles)
|
---|
3947 | % hObject handle to TestCPUTime (see GCBO)
|
---|
3948 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
3949 | % handles structure with handles and user data (see GUIDATA)
|
---|
3950 |
|
---|
3951 |
|
---|
3952 | % --- Executes on button press in DiskQuota.
|
---|
3953 | function DiskQuota_Callback(hObject, eventdata, handles)
|
---|
3954 | SeriesData=get(handles.series,'UserData');
|
---|
3955 | system(SeriesData.SeriesParam.DiskQuotaCmd)
|
---|
3956 |
|
---|
3957 |
|
---|
3958 | % --- Executes on button press in Replicate.
|
---|
3959 | function Replicate_Callback(hObject, eventdata, handles)
|
---|
3960 | if get(handles.Replicate,'Value')
|
---|
3961 | InputTable=get(handles.InputTable,'Data');
|
---|
3962 | for ilist=1:size(InputTable,1)
|
---|
3963 | InputDir{ilist}=fullfile(InputTable{ilist,1},InputTable{ilist,2});
|
---|
3964 | end
|
---|
3965 | browse_data(InputDir)
|
---|
3966 | else
|
---|
3967 | hh=findobj(allchild(0),'Tag','browse_data');
|
---|
3968 | if ~isempty(hh)
|
---|
3969 | delete(hh)
|
---|
3970 | end
|
---|
3971 | end
|
---|
3972 |
|
---|
3973 |
|
---|
3974 |
|
---|
3975 |
|
---|
3976 | function OutputPath_Callback(hObject, eventdata, handles)
|
---|
3977 |
|
---|
3978 |
|
---|
3979 | function Experiment_Callback(hObject, eventdata, handles)
|
---|
3980 |
|
---|
3981 |
|
---|
3982 | function Device_Callback(hObject, eventdata, handles)
|
---|
3983 |
|
---|
3984 |
|
---|
3985 | % --- Executes on button press in OutputPathBrowse.
|
---|
3986 | function OutputPathBrowse_Callback(hObject, eventdata, handles)
|
---|
3987 | CheckValue=get(handles.OutputPathBrowse,'Value');
|
---|
3988 | if CheckValue
|
---|
3989 | OutputPath=uigetdir(get(handles.OutputPath,'String'));
|
---|
3990 | set(handles.OutputPath,'String',OutputPath)
|
---|
3991 | else
|
---|
3992 | InputTable=get(handles.InputTable,'Data');
|
---|
3993 | set(handles.OutputPath,'String',InputTable{1,1})
|
---|
3994 | end
|
---|
3995 |
|
---|
3996 |
|
---|
3997 |
|
---|
3998 | % --- Executes on button press in DeleteMask.
|
---|
3999 | function DeleteMask_Callback(hObject, eventdata, handles)
|
---|
4000 | set(handles.MaskTable,'Data',{})
|
---|