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