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