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