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