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