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