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