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