[2] | 1 | %'series': master function associated to the GUI series.m for analysis field series |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function varargout = series(varargin) |
---|
| 4 | % associated with the GUI series.fig |
---|
| 5 | % |
---|
| 6 | %INPUT |
---|
| 7 | % param: structure with input parameters (link with the GUI uvmat) |
---|
[446] | 8 | % .menu_coord_str: string for the TransformName (menu for coordinate transforms) |
---|
| 9 | % .menu_coord_val: value for TransformName (menu for coordinate transforms) |
---|
[2] | 10 | % .FileName: input file name |
---|
| 11 | % .FileName_1: second input file name |
---|
| 12 | % .list_field: menu of input fields |
---|
| 13 | % .index_fields: chosen index |
---|
| 14 | % .civ1=0 or 1, .interp1, ... : input civ field type |
---|
| 15 | % |
---|
| 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 17 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 18 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 19 | % This file is part of the toolbox UVMAT. |
---|
| 20 | % |
---|
| 21 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 22 | % it under the terms of the GNU General Public License as published by |
---|
| 23 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 24 | % (at your option) any later version. |
---|
| 25 | % |
---|
| 26 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 29 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 30 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 31 | |
---|
[408] | 32 | %------------------------------------------------------------------------ |
---|
| 33 | %------------------------------------------------------------------------ |
---|
| 34 | % I - MAIN FUNCTION series |
---|
| 35 | %------------------------------------------------------------------------ |
---|
| 36 | %------------------------------------------------------------------------ |
---|
[2] | 37 | function varargout = series(varargin) |
---|
| 38 | |
---|
| 39 | % Begin initialization code - DO NOT EDIT |
---|
| 40 | gui_Singleton = 1; |
---|
| 41 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 42 | 'gui_Singleton', gui_Singleton, ... |
---|
| 43 | 'gui_OpeningFcn', @series_OpeningFcn, ... |
---|
| 44 | 'gui_OutputFcn', @series_OutputFcn, ... |
---|
| 45 | 'gui_LayoutFcn', [] , ... |
---|
| 46 | 'gui_Callback', []); |
---|
| 47 | if nargin && ischar(varargin{1}) |
---|
| 48 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 49 | end |
---|
| 50 | |
---|
| 51 | if nargout |
---|
| 52 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 53 | else |
---|
| 54 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 55 | end |
---|
| 56 | % End initialization code - DO NOT EDIT |
---|
| 57 | |
---|
| 58 | %-------------------------------------------------------------------------- |
---|
| 59 | % --- Executes just before series is made visible. |
---|
| 60 | %-------------------------------------------------------------------------- |
---|
| 61 | function series_OpeningFcn(hObject, eventdata, handles,param) |
---|
[205] | 62 | global nb_builtin_ACTION nb_builtin_transform |
---|
[2] | 63 | % Choose default command line output for series |
---|
| 64 | handles.output = hObject; |
---|
| 65 | % Update handles structure |
---|
| 66 | guidata(hObject, handles); |
---|
| 67 | %default initial parameters |
---|
[156] | 68 | drawnow |
---|
[244] | 69 | set(hObject,'Units','pixels') |
---|
[408] | 70 | set(handles.PairString,'ColumnEditable',logical(0)) |
---|
| 71 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
| 72 | set(handles.PairString,'ColumnWidth',{60}) |
---|
| 73 | set(handles.PairString,'Data',{''}) |
---|
[332] | 74 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
[2] | 75 | dir_perso=prefdir; |
---|
[205] | 76 | test_profil_perso=0; |
---|
[2] | 77 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 78 | if exist(profil_perso,'file') |
---|
| 79 | h=load (profil_perso); |
---|
[460] | 80 | if isfield(h,'MenuFile') |
---|
| 81 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 82 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 83 | % eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
| 84 | end |
---|
| 85 | end |
---|
| 86 | % if isfield(h,'MenuFile') |
---|
| 87 | % for ifile=1:min(length(h.MenuFile),5) |
---|
| 88 | % eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 89 | % eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
| 90 | % end |
---|
| 91 | % end |
---|
| 92 | |
---|
[205] | 93 | test_profil_perso=1; |
---|
[460] | 94 | % if isfield(h,'MenuFile_1') && exist(h.MenuFile_1,'file') |
---|
| 95 | % set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
| 96 | % set(handles.MenuFile_insert_1,'Label',h.MenuFile_1); |
---|
| 97 | % end |
---|
| 98 | % if isfield(h,'MenuFile_2')&& exist(h.MenuFile_2,'file') |
---|
| 99 | % set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
| 100 | % set(handles.MenuFile_insert_2,'Label',h.MenuFile_2); |
---|
| 101 | % end |
---|
| 102 | % if isfield(h,'MenuFile_3')&& exist(h.MenuFile_3,'file') |
---|
| 103 | % set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
| 104 | % set(handles.MenuFile_insert_3,'Label',h.MenuFile_3); |
---|
| 105 | % end |
---|
| 106 | % if isfield(h,'MenuFile_4')&& exist(h.MenuFile_4,'file') |
---|
| 107 | % set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
| 108 | % set(handles.MenuFile_insert_4,'Label',h.MenuFile_4); |
---|
| 109 | % end |
---|
| 110 | % if isfield(h,'MenuFile_5')&& exist(h.MenuFile_5,'file') |
---|
| 111 | % set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
| 112 | % set(handles.MenuFile_insert_5,'Label',h.MenuFile_5); |
---|
| 113 | % end |
---|
[2] | 114 | end |
---|
| 115 | |
---|
| 116 | %check default input data |
---|
| 117 | if ~exist('param','var') |
---|
| 118 | param=[]; %default |
---|
| 119 | end |
---|
| 120 | |
---|
[376] | 121 | %% file name and browser initialisation |
---|
[2] | 122 | if isfield(param,'menu_coord_str') |
---|
[446] | 123 | set(handles.TransformName,'String',param.menu_coord_str) |
---|
[2] | 124 | end |
---|
| 125 | if isfield(param,'menu_coord_val') |
---|
[446] | 126 | set(handles.TransformName,'Value',param.menu_coord_val); |
---|
[2] | 127 | else |
---|
[446] | 128 | set(handles.TransformName,'Value',1);%default |
---|
[2] | 129 | end |
---|
| 130 | if isfield(param,'FileName') |
---|
| 131 | if isfield(param,'FileName_1') |
---|
[408] | 132 | display_file_name(handles,param.FileName_1,0) |
---|
| 133 | display_file_name(handles,param.FileName,1) |
---|
[2] | 134 | else |
---|
[408] | 135 | display_file_name(handles,param.FileName,0) |
---|
[2] | 136 | end |
---|
| 137 | end |
---|
| 138 | |
---|
[376] | 139 | %% fields input initialisation |
---|
[2] | 140 | if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields) |
---|
[446] | 141 | set(handles.FieldName,'String',param.list_fields);% list menu fields |
---|
| 142 | set(handles.FieldName,'Value',param.index_fields);% selected string index |
---|
[2] | 143 | FieldCell{1}=param.list_fields{param.index_fields}; |
---|
| 144 | end |
---|
[376] | 145 | |
---|
[446] | 146 | %loads the information stored in prefdir to initiate the list of ActionName functions |
---|
[329] | 147 | fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
[38] | 148 | transform_menu={'';'phys';'px';'phys_polar'}; |
---|
[205] | 149 | nb_builtin_ACTION=numel(fct_menu); %number of functions |
---|
[38] | 150 | nb_transform=numel(transform_menu); |
---|
[26] | 151 | [path_series,name,ext]=fileparts(which('series')); |
---|
[34] | 152 | path_series=fullfile(path_series,'series');%path of the function 'series' |
---|
[332] | 153 | addpath (path_series) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
[276] | 154 | path_transform=fullfile(path_series,'transform_field');%path to the field transform functions |
---|
[38] | 155 | for ilist=1:length(fct_menu) |
---|
[2] | 156 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
| 157 | end |
---|
[39] | 158 | |
---|
[376] | 159 | %% TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions |
---|
[39] | 160 | menu_str={'';'phys';'px';'phys_polar'}; |
---|
[205] | 161 | nb_builtin_transform=numel(menu_str); %number of functions |
---|
[39] | 162 | [path_uvmat,name,ext]=fileparts(which('uvmat')); |
---|
| 163 | addpath(fullfile(path_uvmat,'transform_field')) |
---|
| 164 | fct_handle{1,1}=[]; |
---|
| 165 | testexist(1)=1; |
---|
| 166 | for ilist=2:length(menu_str) |
---|
| 167 | if exist(menu_str{ilist},'file') |
---|
| 168 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
| 169 | testexist(ilist)=1; |
---|
| 170 | else |
---|
| 171 | testexist(ilist)=0; |
---|
| 172 | end |
---|
[38] | 173 | end |
---|
[39] | 174 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
| 175 | |
---|
[376] | 176 | %% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir |
---|
[205] | 177 | if test_profil_perso |
---|
[2] | 178 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
| 179 | for ilist=1:length(h.series_fct) |
---|
| 180 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
| 181 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
[205] | 182 | fct_menu=[fct_menu; {file}]; |
---|
[2] | 183 | end |
---|
| 184 | end |
---|
[38] | 185 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
[39] | 186 | for ilist=1:length(h.transform_fct); |
---|
[38] | 187 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
[39] | 188 | addpath(path) |
---|
| 189 | if exist(file,'file') |
---|
| 190 | h_func=str2func(file); |
---|
| 191 | testexist=[testexist 1]; |
---|
| 192 | else |
---|
| 193 | h_func=[]; |
---|
| 194 | testexist=[testexist 0]; |
---|
| 195 | end |
---|
| 196 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths |
---|
| 197 | rmpath(path) |
---|
| 198 | menu_str=[menu_str; {file}]; |
---|
| 199 | end |
---|
[38] | 200 | end |
---|
[2] | 201 | end |
---|
[38] | 202 | fct_menu=[fct_menu;{'more...'}]; |
---|
[446] | 203 | set(handles.ActionName,'String',fct_menu) |
---|
| 204 | set(handles.ActionName,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
[39] | 205 | menu_str=menu_str(find(testexist)); |
---|
| 206 | fct_handle=fct_handle(find(testexist)); |
---|
| 207 | menu_str=[menu_str;{'more...'}]; |
---|
[446] | 208 | set(handles.TransformName,'String',menu_str) |
---|
| 209 | set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
[39] | 210 | |
---|
[446] | 211 | % display the GUI for the default actionname 'check_data_files' |
---|
| 212 | ActionName_Callback(hObject, eventdata, handles) |
---|
[2] | 213 | |
---|
[408] | 214 | %------------------------------------------------------------------------ |
---|
[2] | 215 | % --- Outputs from this function are returned to the command line. |
---|
| 216 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
[408] | 217 | %------------------------------------------------------------------------ |
---|
[2] | 218 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 219 | % hObject handle to figure |
---|
| 220 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 221 | % handles structure with handles and user data (see GUIDATA) |
---|
| 222 | % Get default command line output from handles structure |
---|
| 223 | varargout{1} = handles.output; |
---|
| 224 | |
---|
[408] | 225 | %------------------------------------------------------------------------ |
---|
| 226 | %------------------------------------------------------------------------ |
---|
| 227 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 228 | % automatically sets the global properties when the rootfile name is introduced |
---|
[446] | 229 | % then activate the view-field actionname if selected |
---|
[408] | 230 | % it is activated either by clicking on the RootPath window or by the |
---|
| 231 | % browser |
---|
| 232 | %------------------------------------------------------------------------ |
---|
| 233 | %------------------------------------------------------------------------ |
---|
[2] | 234 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
[408] | 235 | %------------------------------------------------------------------------ |
---|
[350] | 236 | InputTable=get(handles.InputTable,'Data'); |
---|
| 237 | RootPathCell=InputTable(:,1); |
---|
[358] | 238 | SubDirCell=InputTable(:,2); |
---|
| 239 | RootFileCell=InputTable(:,3); |
---|
[2] | 240 | oldfile=''; %default |
---|
[329] | 241 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 242 | dir_perso=prefdir; |
---|
| 243 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 244 | if exist(profil_perso,'file') |
---|
| 245 | h=load (profil_perso); |
---|
[329] | 246 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
[2] | 247 | oldfile=h.filebase; |
---|
| 248 | end |
---|
[329] | 249 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
[2] | 250 | oldfile=h.RootPath; |
---|
| 251 | end |
---|
| 252 | end |
---|
| 253 | else |
---|
| 254 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
| 255 | end |
---|
| 256 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 257 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 258 | '*.xml', '.xml files '; ... |
---|
| 259 | '*.xls', '.xls files '; ... |
---|
| 260 | '*.png','.png image files'; ... |
---|
| 261 | '*.tif','.tif image files'; ... |
---|
| 262 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 263 | '*.nc','.netcdf files'; ... |
---|
| 264 | '*.*', 'All Files (*.*)'}, ... |
---|
| 265 | 'Pick a file',oldfile); |
---|
| 266 | fileinput=[PathName FileName];%complete file name |
---|
| 267 | sizf=size(fileinput); |
---|
| 268 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 269 | [path,name,ext]=fileparts(fileinput); |
---|
| 270 | SeriesData=[];%dfault |
---|
| 271 | if isequal(ext,'.xml') |
---|
[460] | 272 | Param=xml2struct(fileinput); |
---|
| 273 | fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file |
---|
| 274 | return |
---|
[2] | 275 | elseif isequal(ext,'.xls') |
---|
[408] | 276 | msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 277 | else |
---|
[408] | 278 | display_file_name(handles,fileinput,0) |
---|
[2] | 279 | %update list of recent files in the menubar |
---|
[446] | 280 | % MenuFile_1=fileinput; |
---|
| 281 | % MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 282 | % MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 283 | % MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 284 | % MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 285 | % set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 286 | % set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 287 | % set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 288 | % set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 289 | % set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 290 | % set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
| 291 | % set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
| 292 | % set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
| 293 | % set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
| 294 | % set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
| 295 | % dir_perso=prefdir; |
---|
| 296 | % profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 297 | % if exist(profil_perso,'file') |
---|
| 298 | % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 299 | % else |
---|
| 300 | % txt=ver('MATLAB'); |
---|
| 301 | % Release=txt.Release; |
---|
| 302 | % relnumb=str2num(Release(3:4)); |
---|
| 303 | % if relnumb >= 14 |
---|
| 304 | % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 305 | % else |
---|
| 306 | % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 307 | % end |
---|
| 308 | % end |
---|
[2] | 309 | end |
---|
| 310 | |
---|
| 311 | % -------------------------------------------------------------------- |
---|
| 312 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 313 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[408] | 314 | display_file_name(handles,fileinput,0) |
---|
[2] | 315 | |
---|
| 316 | % -------------------------------------------------------------------- |
---|
| 317 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 318 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[408] | 319 | display_file_name(handles,fileinput,0) |
---|
[2] | 320 | |
---|
| 321 | % -------------------------------------------------------------------- |
---|
| 322 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 323 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[408] | 324 | display_file_name( handles,fileinput,0) |
---|
[2] | 325 | |
---|
| 326 | % -------------------------------------------------------------------- |
---|
| 327 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 328 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[408] | 329 | display_file_name(handles,fileinput,0) |
---|
[2] | 330 | |
---|
| 331 | % -------------------------------------------------------------------- |
---|
| 332 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 333 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[408] | 334 | display_file_name(handles,fileinput,0) |
---|
[2] | 335 | |
---|
| 336 | % -------------------------------------------------------------------- |
---|
| 337 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
[350] | 338 | InputTable=get(handles.InputTable,'Data'); |
---|
| 339 | RootPathCell=InputTable(:,1); |
---|
| 340 | SubDirCell=InputTable(:,3); |
---|
| 341 | RootFileCell=InputTable(:,2); |
---|
[2] | 342 | oldfile=''; %default |
---|
[206] | 343 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 344 | dir_perso=prefdir; |
---|
| 345 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 346 | if exist(profil_perso,'file') |
---|
| 347 | h=load (profil_perso); |
---|
| 348 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 349 | oldfile=h.filebase; |
---|
| 350 | end |
---|
| 351 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 352 | oldfile=h.RootPath; |
---|
| 353 | end |
---|
| 354 | end |
---|
| 355 | else |
---|
| 356 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
| 357 | end |
---|
| 358 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 359 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
| 360 | '*.xml', '.xml files '; ... |
---|
| 361 | '*.xls', '.xls files '; ... |
---|
| 362 | '*.png','.png image files'; ... |
---|
| 363 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 364 | '*.nc','.netcdf files'; ... |
---|
| 365 | '*.*', 'All Files (*.*)'}, ... |
---|
| 366 | 'Pick a file',oldfile); |
---|
| 367 | fileinput=[PathName FileName];%complete file name |
---|
| 368 | sizf=size(fileinput); |
---|
| 369 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 370 | [path,name,ext]=fileparts(fileinput); |
---|
| 371 | if isequal(ext,'.xml') |
---|
[206] | 372 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 373 | elseif isequal(ext,'.xls') |
---|
[206] | 374 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 375 | else |
---|
[408] | 376 | display_file_name(handles,fileinput,1) |
---|
[2] | 377 | end |
---|
| 378 | |
---|
| 379 | % -------------------------------------------------------------------- |
---|
| 380 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
[408] | 381 | % -------------------------------------------------------------------- |
---|
[2] | 382 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
[408] | 383 | display_file_name(handles,fileinput,1) |
---|
[2] | 384 | |
---|
| 385 | % -------------------------------------------------------------------- |
---|
| 386 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
[408] | 387 | % -------------------------------------------------------------------- |
---|
[2] | 388 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
[408] | 389 | display_file_name(handles,fileinput,1) |
---|
[2] | 390 | |
---|
| 391 | % -------------------------------------------------------------------- |
---|
| 392 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
[408] | 393 | % -------------------------------------------------------------------- |
---|
[2] | 394 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
[408] | 395 | display_file_name( handles,fileinput,1) |
---|
[2] | 396 | |
---|
| 397 | % -------------------------------------------------------------------- |
---|
| 398 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
[408] | 399 | % -------------------------------------------------------------------- |
---|
[2] | 400 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
[408] | 401 | display_file_name( handles,fileinput,1) |
---|
[2] | 402 | |
---|
| 403 | % -------------------------------------------------------------------- |
---|
| 404 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
[408] | 405 | % -------------------------------------------------------------------- |
---|
[2] | 406 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
[408] | 407 | display_file_name(handles,fileinput,1) |
---|
[2] | 408 | |
---|
[89] | 409 | %------------------------------------------------------------------------ |
---|
[408] | 410 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
| 411 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
| 412 | %------------------------------------------------------------------------ |
---|
| 413 | iview=eventdata.Indices(1); |
---|
| 414 | InputTable=get(handles.InputTable,'Data'); |
---|
[446] | 415 | fileinput=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); |
---|
[408] | 416 | display_file_name(handles,fileinput,0) |
---|
[446] | 417 | %update the output dir |
---|
| 418 | SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
| 419 | SubDirOut=SubDir{1}; |
---|
| 420 | if numel(SubDir)>1 |
---|
| 421 | for ilist=2:numel(SubDir) |
---|
| 422 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
| 423 | end |
---|
| 424 | end |
---|
| 425 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
[408] | 426 | |
---|
| 427 | %------------------------------------------------------------------------ |
---|
| 428 | % --- refresh the GUI data after introduction of a new file |
---|
[332] | 429 | % INPUT: |
---|
[408] | 430 | % handles: handles of the elements in the GUI series |
---|
[332] | 431 | % fileinput: name of the input file |
---|
[408] | 432 | % append: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert') |
---|
| 433 | function display_file_name(handles,fileinput,append) |
---|
[89] | 434 | %------------------------------------------------------------------------ |
---|
[332] | 435 | |
---|
[408] | 436 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
| 437 | if ~exist(fileinput,'file') |
---|
| 438 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 439 | return |
---|
| 440 | end |
---|
| 441 | |
---|
[332] | 442 | %% enable other menus and uicontrols |
---|
| 443 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 444 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 445 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 446 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 447 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 448 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 449 | set(handles.RUN, 'Enable','On') |
---|
| 450 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
[350] | 451 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
[332] | 452 | drawnow |
---|
| 453 | |
---|
[408] | 454 | %% detect root name, nomenclature and indices in the input file name: |
---|
| 455 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
| 456 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 457 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 458 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
| 459 | if isempty(RootFile)&&isempty(i1_series) |
---|
| 460 | errormsg='no input file in the series'; |
---|
[29] | 461 | return |
---|
| 462 | end |
---|
[89] | 463 | |
---|
[376] | 464 | %% fill the list of file series |
---|
| 465 | InputTable=get(handles.InputTable,'Data'); |
---|
[408] | 466 | if append % display the input data as a new line in the table |
---|
| 467 | lastview=size(InputTable,1)+1; |
---|
| 468 | InputTable(lastview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
| 469 | set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}]) |
---|
| 470 | set(handles.ListView,'Value',lastview) |
---|
[446] | 471 | |
---|
[376] | 472 | else % or re-initialise the list of input file series |
---|
[408] | 473 | lastview=1; |
---|
[376] | 474 | InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
| 475 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
| 476 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
| 477 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
[408] | 478 | set(handles.ListView,'Value',1) |
---|
| 479 | set(handles.ListView,'String',{'1'}) |
---|
[376] | 480 | end |
---|
| 481 | set(handles.InputTable,'Data',InputTable) |
---|
| 482 | |
---|
[460] | 483 | %% display the min and max indices for all the file series |
---|
| 484 | i_sum=sum(sum(i1_series,2),3);%sum of i1_series on the last index |
---|
| 485 | MaxIndex_i=max(find(i_sum>0))-1; |
---|
| 486 | MinIndex_i=min(find(i_sum>0))-1; |
---|
| 487 | if isequal(MinIndex_i,1) && exist (fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,0,i2_series(2,2),j1_series(2,2),j2_series(2,2)),'file') |
---|
| 488 | MinIndex_i=0; |
---|
| 489 | end |
---|
| 490 | j_sum=sum(sum(j1_series,1),3); |
---|
| 491 | MaxIndex_j=max(find(j_sum>0))-1; |
---|
| 492 | MinIndex_j=min(find(j_sum>0))-1; |
---|
| 493 | MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex |
---|
| 494 | MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex |
---|
| 495 | MinIndex{lastview,1}=MinIndex_i; |
---|
| 496 | MinIndex{lastview,2}=MinIndex_j; |
---|
| 497 | MaxIndex{lastview,1}=MaxIndex_i; |
---|
| 498 | MaxIndex{lastview,2}=MaxIndex_j; |
---|
| 499 | |
---|
| 500 | set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex |
---|
| 501 | set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex |
---|
| 502 | |
---|
| 503 | %% adjust the first and last indices if requested by the bounds |
---|
| 504 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 505 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
| 506 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
| 507 | if isempty(first_i) |
---|
| 508 | first_i=ref_i; |
---|
| 509 | elseif first_i < MinIndex_i |
---|
| 510 | first_i=MinIndex_i; |
---|
| 511 | end |
---|
| 512 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 513 | if isempty(first_j) |
---|
| 514 | first_j=ref_j; |
---|
| 515 | elseif first_j<MinIndex_j |
---|
| 516 | first_j=MinIndex_j; |
---|
| 517 | end |
---|
| 518 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 519 | if isempty(last_i) |
---|
| 520 | last_i=ref_i; |
---|
| 521 | elseif last_i > MaxIndex_i |
---|
| 522 | last_i=MaxIndex_i; |
---|
| 523 | end |
---|
| 524 | last_j=str2num(get(handles.num_first_j,'String')); |
---|
| 525 | if isempty(last_j) |
---|
| 526 | last_j=ref_j; |
---|
| 527 | elseif last_j>MaxIndex_j |
---|
| 528 | last_j=MaxIndex_j; |
---|
| 529 | end |
---|
| 530 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
| 531 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
| 532 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
| 533 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
| 534 | |
---|
| 535 | |
---|
| 536 | %% update the output dir |
---|
[446] | 537 | SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
| 538 | SubDirOut=SubDir{1}; |
---|
| 539 | if numel(SubDir)>1 |
---|
| 540 | for ilist=2:numel(SubDir) |
---|
| 541 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
| 542 | end |
---|
| 543 | end |
---|
| 544 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
[376] | 545 | |
---|
[408] | 546 | %% determine the selected reference field indices for pair display |
---|
[2] | 547 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
[339] | 548 | if ~isempty(i1) |
---|
| 549 | ref_i=i1; |
---|
| 550 | if ~isempty(i2) |
---|
| 551 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
[2] | 552 | end |
---|
| 553 | end |
---|
[408] | 554 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
[2] | 555 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
[339] | 556 | if ~isempty(j1) |
---|
| 557 | ref_j=j1; |
---|
| 558 | if ~isempty(j2) |
---|
| 559 | ref_j=floor((j1+j2)/2); |
---|
[2] | 560 | end |
---|
| 561 | end |
---|
[408] | 562 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
[372] | 563 | |
---|
[446] | 564 | %% update the list of recent files in the menubar and save it for future opening |
---|
[408] | 565 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 566 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
[446] | 567 | str_find=strcmp(fileinput,MenuFile); |
---|
[408] | 568 | if isempty(find(str_find,1)) |
---|
[446] | 569 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
[372] | 570 | end |
---|
[408] | 571 | for ifile=1:min(length(MenuFile),5) |
---|
| 572 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 573 | eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 574 | end |
---|
[2] | 575 | dir_perso=prefdir; |
---|
| 576 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 577 | if exist(profil_perso,'file') |
---|
[408] | 578 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
[2] | 579 | else |
---|
[408] | 580 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
[2] | 581 | end |
---|
[408] | 582 | |
---|
[350] | 583 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
[2] | 584 | |
---|
[408] | 585 | %% initiate input file series and refresh the current field view: |
---|
| 586 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,lastview); |
---|
[2] | 587 | |
---|
[408] | 588 | %------------------------------------------------------------------------ |
---|
| 589 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 590 | % calibration from an xml file, then refresh current plots |
---|
| 591 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) |
---|
| 592 | %------------------------------------------------------------------------ |
---|
| 593 | |
---|
| 594 | %% enable j index visibility |
---|
| 595 | if isempty(j1_series) |
---|
| 596 | state='off'; |
---|
| 597 | else |
---|
| 598 | state='on'; |
---|
| 599 | end |
---|
| 600 | enable_j(handles,state) |
---|
| 601 | |
---|
| 602 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 603 | InputTable=get(handles.InputTable,'Data'); |
---|
| 604 | FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); |
---|
| 605 | time=[];%default |
---|
| 606 | % case of movies |
---|
| 607 | if strcmp(InputTable{iview,4},'*') |
---|
| 608 | if ~isempty(VideoObject) |
---|
| 609 | imainfo=get(VideoObject); |
---|
| 610 | time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
| 611 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 612 | ColorType='truecolor'; |
---|
| 613 | elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image |
---|
| 614 | if ~isempty(InputTable{iview,2}) |
---|
| 615 | imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); |
---|
| 616 | else |
---|
| 617 | imainfo=imfinfo([FileBase InputTable{iview,5}]); |
---|
| 618 | end |
---|
| 619 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 620 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 621 | nbfield=length(imainfo); |
---|
| 622 | nbfield_j=1; |
---|
| 623 | end |
---|
| 624 | end |
---|
| 625 | end |
---|
| 626 | |
---|
| 627 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 628 | ext_imadoc=''; |
---|
| 629 | if exist([FileBase '.xml'],'file') |
---|
| 630 | ext_imadoc='.xml'; |
---|
| 631 | elseif exist([FileBase '.civ'],'file') |
---|
| 632 | ext_imadoc='.civ'; |
---|
| 633 | end |
---|
| 634 | %read the ImaDoc file |
---|
| 635 | XmlData=[]; |
---|
| 636 | NbSlice_calib={}; |
---|
| 637 | if isequal(ext_imadoc,'.xml') |
---|
| 638 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
| 639 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
| 640 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
| 641 | end |
---|
| 642 | if isfield(XmlData,'Time') |
---|
| 643 | time=XmlData.Time; |
---|
| 644 | end |
---|
| 645 | if isfield(XmlData,'Camera') |
---|
| 646 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
| 647 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
| 648 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 649 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 650 | end |
---|
| 651 | end |
---|
| 652 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
| 653 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 654 | end |
---|
| 655 | end |
---|
| 656 | if ~isempty(warntext) |
---|
| 657 | msgbox_uvmat('WARNING',warntext) |
---|
| 658 | end |
---|
| 659 | elseif isequal(ext_imadoc,'.civ') |
---|
| 660 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
| 661 | time=XmlData.Time; |
---|
| 662 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
| 663 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
| 664 | end |
---|
| 665 | end |
---|
| 666 | |
---|
| 667 | %% update time table |
---|
[456] | 668 | if ~isempty(time) |
---|
[408] | 669 | TimeTable=get(handles.TimeTable,'Data'); |
---|
| 670 | if isempty(MinIndex_j) |
---|
[456] | 671 | if MinIndex_i>0 |
---|
[408] | 672 | TimeTable{iview,1}=time(MinIndex_i); |
---|
[456] | 673 | end |
---|
[408] | 674 | TimeTable{iview,2}=time(first_i); |
---|
| 675 | TimeTable{iview,3}=time(last_i); |
---|
| 676 | TimeTable{iview,4}=time(MaxIndex_i); |
---|
[419] | 677 | elseif ~isempty(time) |
---|
[456] | 678 | if MinIndex_i>0 |
---|
[408] | 679 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
[456] | 680 | end |
---|
[408] | 681 | TimeTable{iview,2}=time(first_i,first_j); |
---|
| 682 | TimeTable{iview,3}=time(last_i,last_j); |
---|
| 683 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
| 684 | end |
---|
| 685 | set(handles.TimeTable,'Data',TimeTable) |
---|
[456] | 686 | end |
---|
[408] | 687 | |
---|
| 688 | %% number of slices |
---|
[460] | 689 | NbSlice=1;%default |
---|
[408] | 690 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
| 691 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
| 692 | if siz(1)>1 |
---|
| 693 | NbSlice=siz(1); |
---|
| 694 | end |
---|
| 695 | end |
---|
[450] | 696 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
| 697 | |
---|
[408] | 698 | %% update pair menus |
---|
[441] | 699 | set(handles.Pairs,'Visible','on') |
---|
| 700 | set(handles.PairString,'Visible','on') |
---|
[408] | 701 | ListView=get(handles.ListView,'String'); |
---|
| 702 | ListView{iview}=num2str(iview); |
---|
| 703 | set(handles.ListView,'String'); |
---|
| 704 | set(handles.ListView,'Value',iview) |
---|
| 705 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 706 | |
---|
[441] | 707 | |
---|
[408] | 708 | %% display the set of existing files as an image |
---|
| 709 | set(handles.waitbar_frame,'Units','pixels') |
---|
| 710 | pos=get(handles.waitbar_frame,'Position'); |
---|
| 711 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
| 712 | yima=0.5:pos(4)-0.5; |
---|
| 713 | [XIma,YIma]=meshgrid(xima,yima); |
---|
| 714 | nb_i=size(i1_series,1); |
---|
| 715 | nb_j=size(i1_series,2); |
---|
| 716 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
| 717 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
| 718 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
| 719 | CData=zeros([size(XIma) 3]); |
---|
| 720 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
| 721 | if numel(file_ima)>=2 |
---|
| 722 | if size(file_ima,1)==1 |
---|
| 723 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
| 724 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
| 725 | else |
---|
| 726 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
| 727 | end |
---|
| 728 | set(handles.waitbar_frame,'CData',CData) |
---|
| 729 | end |
---|
| 730 | set(handles.waitbar_frame,'Units','normalized') |
---|
| 731 | |
---|
| 732 | %% enable field and veltype menus |
---|
| 733 | SeriesData=get(handles.series,'UserData'); |
---|
| 734 | SeriesData.FileType{iview}=FileType; |
---|
| 735 | check_civ=0; |
---|
| 736 | check_netcdf=0; |
---|
| 737 | for iview=1:length(SeriesData.FileType) |
---|
| 738 | switch SeriesData.FileType{iview} |
---|
| 739 | case {'civx','civdata'} |
---|
| 740 | check_civ=check_civ+1; |
---|
| 741 | case 'netcdf' |
---|
| 742 | check_netcdf=check_netcdf+1; |
---|
| 743 | end |
---|
| 744 | end |
---|
| 745 | if check_civ |
---|
| 746 | enable='on'; |
---|
| 747 | else |
---|
| 748 | enable='off'; |
---|
| 749 | end |
---|
[446] | 750 | set(handles.VelType,'Visible',enable) |
---|
[408] | 751 | set(handles.VelType_text,'Visible',enable) |
---|
| 752 | if check_civ>=2 |
---|
| 753 | enable='on'; |
---|
| 754 | else |
---|
| 755 | enable='off'; |
---|
| 756 | end |
---|
[446] | 757 | set(handles.VelType_1,'Visible',enable) |
---|
[408] | 758 | set(handles.VelType_text_1,'Visible',enable) |
---|
| 759 | if check_civ || check_netcdf |
---|
| 760 | enable='on'; |
---|
| 761 | else |
---|
| 762 | enable='off'; |
---|
| 763 | end |
---|
[446] | 764 | set(handles.FieldName,'Visible',enable) |
---|
[408] | 765 | set(handles.Field_text,'Visible',enable) |
---|
| 766 | if check_civ+ check_netcdf>=2 |
---|
| 767 | enable='on'; |
---|
| 768 | else |
---|
| 769 | enable='off'; |
---|
| 770 | end |
---|
[446] | 771 | set(handles.FieldName_1,'Visible',enable) |
---|
[408] | 772 | set(handles.Field_text_1,'Visible',enable) |
---|
| 773 | FieldString={''}; |
---|
| 774 | if check_civ |
---|
| 775 | FieldString=[calc_field;{'get_field...'}]; |
---|
| 776 | elseif check_netcdf |
---|
| 777 | FieldString={'get_field...'}; |
---|
| 778 | end |
---|
[446] | 779 | set(handles.FieldName,'String',FieldString) |
---|
[408] | 780 | FieldString={''}; |
---|
| 781 | if check_civ>=2 |
---|
| 782 | FieldString=[calc_field;{'get_field...'}]; |
---|
| 783 | elseif check_civ+check_netcdf>=2 |
---|
| 784 | FieldString={'get_field...'}; |
---|
| 785 | end |
---|
[446] | 786 | set(handles.FieldName_1,'String',{'get_field...'}) |
---|
[408] | 787 | |
---|
| 788 | |
---|
| 789 | %% store the series info in 'UserData' |
---|
| 790 | SeriesData.i1_series{iview}=i1_series; |
---|
| 791 | SeriesData.i2_series{iview}=i2_series; |
---|
| 792 | SeriesData.j1_series{iview}=j1_series; |
---|
| 793 | SeriesData.j2_series{iview}=j2_series; |
---|
| 794 | SeriesData.FileType{iview}=FileType; |
---|
| 795 | SeriesData.Time{iview}=time; |
---|
| 796 | set(handles.series,'UserData',SeriesData) |
---|
| 797 | |
---|
[441] | 798 | %% check for pair display |
---|
| 799 | check_pairs=0; |
---|
| 800 | for iview=1:numel(SeriesData.i2_series) |
---|
| 801 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
| 802 | check_pairs=1; |
---|
| 803 | end |
---|
| 804 | end |
---|
| 805 | if check_pairs |
---|
| 806 | set(handles.Pairs,'Visible','on') |
---|
| 807 | set(handles.PairString,'Visible','on') |
---|
| 808 | else |
---|
| 809 | set(handles.Pairs,'Visible','off') |
---|
| 810 | set(handles.PairString,'Visible','off') |
---|
| 811 | end |
---|
[408] | 812 | |
---|
[460] | 813 | % %% set default options in menu 'Fields'%% TODO: check VelType |
---|
| 814 | % if ~testima |
---|
| 815 | % testcivx=0; |
---|
| 816 | % if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field) |
---|
| 817 | % set(handles_Fields,'Value',1) |
---|
| 818 | % set(handles_Fields,'String',{'get_field...'}) |
---|
| 819 | % UvData=rmfield(UvData,'FieldsString'); |
---|
| 820 | % else |
---|
| 821 | % Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); |
---|
| 822 | % if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx |
---|
| 823 | % FieldList=calc_field; |
---|
| 824 | % set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 825 | % set(handles_Fields,'Value',2) % set menu to 'velocity' |
---|
| 826 | % col_vec=FieldList; |
---|
| 827 | % col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar) |
---|
| 828 | % testcivx=1; |
---|
| 829 | % end |
---|
| 830 | % if ~testcivx |
---|
| 831 | % set(handles_Fields,'Value',1) % set menu to 'get_field... |
---|
| 832 | % set(handles_Fields,'String',{'get_field...'}) |
---|
| 833 | % col_vec={'get_field...'}; |
---|
| 834 | % end |
---|
| 835 | % set(handles.ColorScalar,'String',col_vec) |
---|
| 836 | % end |
---|
| 837 | % end |
---|
| 838 | % set(handles.uvmat,'UserData',UvData) |
---|
| 839 | % |
---|
| 840 | % %% set index navigation options and refresh plots |
---|
| 841 | % scan_option='i';%default |
---|
| 842 | % state_j='off'; %default |
---|
| 843 | % if index==2 |
---|
| 844 | % if get(handles.scan_j,'Value') |
---|
| 845 | % scan_option='j'; %keep the scan option for the second fiel series |
---|
| 846 | % end |
---|
| 847 | % if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 848 | % state_j='on'; |
---|
| 849 | % end |
---|
| 850 | % end |
---|
| 851 | % if ~isempty(j1_series) |
---|
| 852 | % state_j='on'; |
---|
| 853 | % if isequal(nbfield,1) &&index==1 |
---|
| 854 | % scan_option='j'; %scan j index by default if nbfield=1 |
---|
| 855 | % end |
---|
| 856 | % end |
---|
| 857 | % if isequal(scan_option,'i') |
---|
| 858 | % set(handles.scan_i,'Value',1) |
---|
| 859 | % scan_i_Callback([],[], handles); |
---|
| 860 | % else |
---|
| 861 | % set(handles.scan_j,'Value',1) |
---|
| 862 | % scan_j_Callback([],[], handles); |
---|
| 863 | % end |
---|
| 864 | % set(handles.scan_j,'Visible',state_j) |
---|
| 865 | % set(handles.j1,'Visible',state_j) |
---|
| 866 | % set(handles.j2,'Visible',state_j) |
---|
| 867 | % set(handles.last_j,'Visible',state_j); |
---|
| 868 | % set(handles.frame_j,'Visible',state_j); |
---|
| 869 | % set(handles.j_text,'Visible',state_j); |
---|
| 870 | % if ~isempty(i2_series)||~isempty(j2_series) |
---|
| 871 | % set(handles.CheckFixPair,'Visible','on') |
---|
| 872 | % elseif index==1 |
---|
| 873 | % set(handles.CheckFixPair,'Visible','off') |
---|
| 874 | % end |
---|
| 875 | % |
---|
| 876 | % |
---|
| 877 | % mode_Callback(hObject, eventdata, handles) |
---|
| 878 | % |
---|
| 879 | % set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 880 | % InputTable=get(handles.InputTable,'Data'); |
---|
| 881 | % check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
| 882 | % |
---|
| 883 | % %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
| 884 | % for ind_list=1:length(check_lines) |
---|
| 885 | % if check_lines(ind_list) |
---|
| 886 | % InputLine=InputTable(ind_list,:); |
---|
| 887 | % detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
| 888 | % detect_idem=detect_idem(detect_idem>0); |
---|
| 889 | % if ~isempty (detect_idem) |
---|
| 890 | % InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
| 891 | % set(handles.InputTable,'Data',InputTable) |
---|
| 892 | % end |
---|
| 893 | % fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
| 894 | % %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
| 895 | % %update file series defined by the selected line |
---|
| 896 | % [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
| 897 | % if ~isempty(errormsg) |
---|
| 898 | % msgbox_uvmat('ERROR',errormsg) |
---|
| 899 | % return |
---|
| 900 | % end |
---|
| 901 | % end |
---|
| 902 | % end |
---|
| 903 | % set(handles.InputTable,'Data',InputTable) |
---|
| 904 | % SeriesData=get(handles.series,'UserData'); |
---|
| 905 | % |
---|
| 906 | % state_j='off'; |
---|
| 907 | % state_Pairs='off'; |
---|
| 908 | % state_InputFields='off'; |
---|
| 909 | % val=get(handles.ListView,'Value'); |
---|
| 910 | % ListViewString={''}; |
---|
| 911 | % if ~isempty(SeriesData) |
---|
| 912 | % % ListViewString={}; |
---|
| 913 | % for iview=1:size(InputTable,1) |
---|
| 914 | % if ~isempty(SeriesData.j1_series{iview}) |
---|
| 915 | % state_j='on'; |
---|
| 916 | % end |
---|
| 917 | % if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
| 918 | % state_Pairs='on'; |
---|
| 919 | % ListViewString{iview}=num2str(iview); |
---|
| 920 | % if check_lines(iview) |
---|
| 921 | % val=iview;%select the last pair if it is a new entry |
---|
| 922 | % end |
---|
| 923 | % end |
---|
| 924 | % if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
| 925 | % state_InputFields='on'; |
---|
| 926 | % end |
---|
| 927 | % end |
---|
| 928 | % end |
---|
| 929 | % set(handles.ListView,'Value',val) |
---|
| 930 | % set(handles.ListView,'String',ListViewString) |
---|
| 931 | % if strcmp(state_Pairs,'on') |
---|
| 932 | % ListView_Callback(hObject,eventdata,handles) |
---|
| 933 | % end |
---|
| 934 | % set(handles.PairString,'Visible',state_Pairs) |
---|
| 935 | % enable_j(handles,state_j) |
---|
[408] | 936 | |
---|
[446] | 937 | %------------------------------------------------------------------------ |
---|
| 938 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
| 939 | %------------------------------------------------------------------------ |
---|
| 940 | num_last_i_Callback(hObject, eventdata, handles) |
---|
[408] | 941 | |
---|
| 942 | %------------------------------------------------------------------------ |
---|
[446] | 943 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
| 944 | %------------------------------------------------------------------------ |
---|
| 945 | SeriesData=get(handles.series,'UserData'); |
---|
| 946 | if ~isfield(SeriesData,'Time') |
---|
| 947 | SeriesData.Time{1}=[]; |
---|
| 948 | end |
---|
| 949 | displ_time(handles); |
---|
| 950 | |
---|
| 951 | %------------------------------------------------------------------------ |
---|
| 952 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
| 953 | %------------------------------------------------------------------------ |
---|
| 954 | num_last_j_Callback(hObject, eventdata, handles) |
---|
| 955 | |
---|
| 956 | %------------------------------------------------------------------------ |
---|
| 957 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
| 958 | %------------------------------------------------------------------------ |
---|
| 959 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 960 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 961 | ref_j=ceil((first_j+last_j)/2); |
---|
| 962 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
| 963 | num_ref_j_Callback(hObject, eventdata, handles) |
---|
| 964 | SeriesData=get(handles.series,'UserData'); |
---|
| 965 | if ~isfield(SeriesData,'Time') |
---|
| 966 | SeriesData.Time{1}=[]; |
---|
| 967 | end |
---|
| 968 | displ_time(handles); |
---|
| 969 | |
---|
| 970 | %------------------------------------------------------------------------ |
---|
| 971 | % ---- find the times corresponding to the first and last indices of a series |
---|
| 972 | function displ_time(handles) |
---|
| 973 | %------------------------------------------------------------------------ |
---|
| 974 | SeriesData=get(handles.series,'UserData');% |
---|
| 975 | ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; |
---|
| 976 | ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; |
---|
| 977 | % last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 978 | % last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 979 | TimeTable=get(handles.TimeTable,'Data'); |
---|
| 980 | Pairs=get(handles.PairString,'Data'); |
---|
| 981 | for iview=1:size(TimeTable,1) |
---|
| 982 | if size(SeriesData.Time,1)<iview |
---|
| 983 | break |
---|
| 984 | end |
---|
| 985 | i1=ref_i; |
---|
| 986 | j1=ref_j; |
---|
| 987 | i2=ref_i; |
---|
| 988 | j2=ref_j; |
---|
| 989 | % case of pairs |
---|
| 990 | if ~isempty(Pairs{iview,1}) |
---|
| 991 | r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 992 | if isempty(r) |
---|
| 993 | r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
| 994 | end |
---|
| 995 | switch r.mode |
---|
| 996 | case 'Di=' % case 'series(Di)') |
---|
| 997 | i1=ref_i-str2num(r.num1); |
---|
| 998 | i2=ref_i+str2num(r.num2); |
---|
| 999 | case 'Dj=' % case 'series(Dj)' |
---|
| 1000 | j1=ref_j-str2num(r.num1); |
---|
| 1001 | j2=ref_j+str2num(r.num2); |
---|
| 1002 | case '-' % case 'bursts' |
---|
| 1003 | j1=str2num(r.num1)*ones(size(ref_i)); |
---|
| 1004 | j2=str2num(r.num2)*ones(size(ref_i)); |
---|
| 1005 | end |
---|
| 1006 | end |
---|
| 1007 | TimeTable{iview,2}=[]; |
---|
| 1008 | TimeTable{iview,3}=[]; |
---|
| 1009 | if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) |
---|
| 1010 | if isempty(ref_j) |
---|
| 1011 | time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2; |
---|
| 1012 | time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2; |
---|
| 1013 | else |
---|
| 1014 | time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2; |
---|
| 1015 | time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2; |
---|
| 1016 | end |
---|
| 1017 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
| 1018 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
| 1019 | end |
---|
| 1020 | end |
---|
| 1021 | set(handles.TimeTable,'Data',TimeTable) |
---|
| 1022 | |
---|
| 1023 | %------------------------------------------------------------------------ |
---|
[408] | 1024 | % --- Executes when selected cell(s) is changed in PairString. |
---|
| 1025 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
| 1026 | %------------------------------------------------------------------------ |
---|
| 1027 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
| 1028 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
| 1029 | |
---|
| 1030 | %------------------------------------------------------------------------ |
---|
| 1031 | %------------------------------------------------------------------------ |
---|
| 1032 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
| 1033 | %------------------------------------------------------------------------ |
---|
| 1034 | %------------------------------------------------------------------------ |
---|
| 1035 | % --- Executes on selection change in ListView. |
---|
| 1036 | function ListView_Callback(hObject, eventdata, handles) |
---|
| 1037 | %------------------------------------------------------------------------ |
---|
| 1038 | SeriesData=get(handles.series,'UserData'); |
---|
| 1039 | i2_series=[]; |
---|
| 1040 | j2_series=[]; |
---|
| 1041 | iview=get(handles.ListView,'Value'); |
---|
| 1042 | if ~isempty(SeriesData.i2_series{iview}) |
---|
| 1043 | i2_series=SeriesData.i2_series{iview}; |
---|
| 1044 | end |
---|
| 1045 | if ~isempty(SeriesData.j2_series{iview}) |
---|
| 1046 | j2_series=SeriesData.j2_series{iview}; |
---|
| 1047 | end |
---|
| 1048 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
| 1049 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
| 1050 | |
---|
| 1051 | %------------------------------------------------------------------------ |
---|
[2] | 1052 | % --- Executes on button press in mode. |
---|
[376] | 1053 | function mode_Callback(hObject, eventdata, handles) |
---|
[408] | 1054 | %------------------------------------------------------------------------ |
---|
[376] | 1055 | SeriesData=get(handles.series,'UserData'); |
---|
[408] | 1056 | iview=get(handles.ListView,'Value'); |
---|
[376] | 1057 | mode_list=get(handles.mode,'String'); |
---|
[408] | 1058 | mode=mode_list{get(handles.mode,'Value')}; |
---|
[376] | 1059 | if isequal(mode,'bursts') |
---|
| 1060 | enable_i(handles,'On') |
---|
| 1061 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 1062 | else |
---|
| 1063 | enable_i(handles,'On') |
---|
| 1064 | enable_j(handles,'Off') |
---|
| 1065 | end |
---|
[408] | 1066 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
| 1067 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
| 1068 | ListPairs_Callback([],[],handles) |
---|
[339] | 1069 | |
---|
[408] | 1070 | %------------------------------------------------------------- |
---|
| 1071 | % --- Executes on selection in ListPairs. |
---|
| 1072 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
| 1073 | %------------------------------------------------------------ |
---|
| 1074 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
[441] | 1075 | if isempty(list_pair) |
---|
| 1076 | string=''; |
---|
| 1077 | else |
---|
| 1078 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
| 1079 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
| 1080 | end |
---|
[408] | 1081 | PairString=get(handles.PairString,'Data'); |
---|
| 1082 | iview=get(handles.ListView,'Value'); |
---|
| 1083 | PairString{iview,1}=string; |
---|
| 1084 | % report the selected pair string to the table PairString |
---|
| 1085 | set(handles.PairString,'Data',PairString) |
---|
[2] | 1086 | |
---|
[408] | 1087 | %------------------------------------------------------------------------ |
---|
| 1088 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
| 1089 | %------------------------------------------------------------------------ |
---|
| 1090 | mode_list=get(handles.mode,'String'); |
---|
| 1091 | mode=mode_list{get(handles.mode,'Value')}; |
---|
| 1092 | SeriesData=get(handles.series,'UserData'); |
---|
| 1093 | iview=get(handles.ListView,'Value'); |
---|
| 1094 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
[446] | 1095 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files |
---|
[408] | 1096 | ListPairs_Callback([],[],handles) |
---|
[2] | 1097 | |
---|
[408] | 1098 | %------------------------------------------------------------------------ |
---|
| 1099 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
| 1100 | %------------------------------------------------------------------------ |
---|
| 1101 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
[2] | 1102 | |
---|
[408] | 1103 | %------------------------------------------------------------------------ |
---|
| 1104 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1105 | %------------------------------------------------------------------------ |
---|
[440] | 1106 | check_burst=0; |
---|
[408] | 1107 | if isempty(j2_series)% no pair menu to display |
---|
| 1108 | if isempty(i2_series) |
---|
| 1109 | set(handles.mode,'String',{''}) |
---|
| 1110 | else |
---|
| 1111 | set(handles.mode,'Value',1) |
---|
| 1112 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 1113 | end |
---|
| 1114 | else |
---|
[419] | 1115 | nbfield=size(j2_series,1); |
---|
| 1116 | nbfield2=size(j2_series,2); |
---|
[408] | 1117 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
| 1118 | if nbfield2>10 || nbfield==1 |
---|
[440] | 1119 | set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values |
---|
[408] | 1120 | else |
---|
| 1121 | set(handles.mode,'Value',1); |
---|
| 1122 | check_burst=1; |
---|
| 1123 | end |
---|
| 1124 | end |
---|
| 1125 | if check_burst |
---|
| 1126 | enable_i(handles,'On') |
---|
| 1127 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 1128 | else |
---|
| 1129 | enable_i(handles,'On') |
---|
[456] | 1130 | if isempty(j1_series) |
---|
| 1131 | enable_j(handles,'Off') |
---|
| 1132 | else |
---|
| 1133 | enable_j(handles,'On') |
---|
| 1134 | end |
---|
[408] | 1135 | end |
---|
| 1136 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1137 | ListPairs_Callback([],[],handles) |
---|
[2] | 1138 | |
---|
| 1139 | %-------------------------------------------------------------- |
---|
[408] | 1140 | % determine the menu for civ1 pairstring depending on existing netcdf files |
---|
| 1141 | % with the reference indices num_ref_i and num_ref_j |
---|
[2] | 1142 | %---------------------------------------------------------------- |
---|
[408] | 1143 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1144 | |
---|
[2] | 1145 | mode_list=get(handles.mode,'String'); |
---|
[408] | 1146 | mode=mode_list{get(handles.mode,'Value')}; |
---|
| 1147 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
| 1148 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
| 1149 | if isempty(ref_i) |
---|
| 1150 | ref_i=1; |
---|
| 1151 | end |
---|
| 1152 | if isempty(ref_j) |
---|
| 1153 | ref_j=1; |
---|
| 1154 | end |
---|
[2] | 1155 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1156 | if length(TimeUnit)>=1 |
---|
| 1157 | dtunit=['m' TimeUnit]; |
---|
| 1158 | else |
---|
| 1159 | dtunit='e-03'; |
---|
| 1160 | end |
---|
[339] | 1161 | |
---|
| 1162 | displ_pair={}; |
---|
[118] | 1163 | if strcmp(mode,'series(Di)') |
---|
[339] | 1164 | if isempty(i2_series) |
---|
| 1165 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
| 1166 | return |
---|
| 1167 | end |
---|
| 1168 | diff_i=i2_series-i1_series; |
---|
| 1169 | min_diff=min(diff_i(diff_i>0)); |
---|
| 1170 | max_diff=max(diff_i(diff_i>0)); |
---|
| 1171 | for ipair=min_diff:max_diff |
---|
| 1172 | if numel(diff_i(diff_i==ipair))>0 |
---|
[408] | 1173 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
| 1174 | if ~isempty(time) |
---|
| 1175 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
| 1176 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
| 1177 | end |
---|
| 1178 | displ_pair=[displ_pair;{pair_string}]; |
---|
[339] | 1179 | end |
---|
| 1180 | end |
---|
| 1181 | if ~isempty(displ_pair) |
---|
| 1182 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
| 1183 | end |
---|
| 1184 | elseif strcmp(mode,'series(Dj)') |
---|
| 1185 | if isempty(j2_series) |
---|
| 1186 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 1187 | return |
---|
| 1188 | end |
---|
| 1189 | diff_j=j2_series-j1_series; |
---|
| 1190 | min_diff=min(diff_j(diff_j>0)); |
---|
| 1191 | max_diff=max(diff_j(diff_j>0)); |
---|
| 1192 | for ipair=min_diff:max_diff |
---|
| 1193 | if numel(diff_j(diff_j==ipair))>0 |
---|
[408] | 1194 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
| 1195 | if ~isempty(time) |
---|
| 1196 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
| 1197 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
| 1198 | end |
---|
| 1199 | displ_pair=[displ_pair;{pair_string}]; |
---|
[339] | 1200 | end |
---|
| 1201 | end |
---|
| 1202 | if ~isempty(displ_pair) |
---|
| 1203 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
| 1204 | end |
---|
| 1205 | elseif strcmp(mode,'bursts') |
---|
| 1206 | if isempty(j2_series) |
---|
| 1207 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 1208 | return |
---|
| 1209 | end |
---|
| 1210 | diff_j=j2_series-j1_series; |
---|
| 1211 | min_j1=min(j1_series(j1_series>0)); |
---|
| 1212 | max_j1=max(j1_series(j1_series>0)); |
---|
| 1213 | min_j2=min(j2_series(j2_series>0)); |
---|
| 1214 | max_j2=max(j2_series(j2_series>0)); |
---|
| 1215 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
| 1216 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
| 1217 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
| 1218 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
| 1219 | end |
---|
| 1220 | end |
---|
| 1221 | end |
---|
| 1222 | if ~isempty(displ_pair) |
---|
| 1223 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
| 1224 | end |
---|
| 1225 | end |
---|
[408] | 1226 | |
---|
| 1227 | %% display list of pairstring |
---|
| 1228 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
[339] | 1229 | NewVal=[]; |
---|
| 1230 | if ~isempty(displ_pair_list) |
---|
[408] | 1231 | Val=get(handles.ListPairs,'Value'); |
---|
[419] | 1232 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pï¿œir |
---|
[339] | 1233 | end |
---|
| 1234 | if ~isempty(NewVal) |
---|
[408] | 1235 | set(handles.ListPairs,'Value',NewVal) |
---|
[339] | 1236 | else |
---|
[408] | 1237 | set(handles.ListPairs,'Value',1) |
---|
[339] | 1238 | end |
---|
[408] | 1239 | set(handles.ListPairs,'String',displ_pair) |
---|
[339] | 1240 | |
---|
[408] | 1241 | %------------------------------------- |
---|
| 1242 | function enable_i(handles,state) |
---|
| 1243 | set(handles.i_txt,'Visible',state) |
---|
| 1244 | set(handles.num_first_i,'Visible',state) |
---|
| 1245 | set(handles.num_last_i,'Visible',state) |
---|
| 1246 | set(handles.num_incr_i,'Visible',state) |
---|
| 1247 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
| 1248 | set(handles.num_ref_i,'Visible',state) |
---|
| 1249 | set(handles.ref_i_text,'Visible',state) |
---|
[2] | 1250 | |
---|
[408] | 1251 | %----------------------------------- |
---|
| 1252 | function enable_j(handles,state) |
---|
| 1253 | set(handles.j_txt,'Visible',state) |
---|
| 1254 | % set(handles.num_MinIndex_j,'Visible',state) |
---|
| 1255 | set(handles.num_first_j,'Visible',state) |
---|
| 1256 | set(handles.num_last_j,'Visible',state) |
---|
| 1257 | set(handles.num_incr_j,'Visible',state) |
---|
| 1258 | % set(handles.num_MaxIndex_j,'Visible',state) |
---|
| 1259 | set(handles.num_ref_j,'Visible',state) |
---|
| 1260 | set(handles.ref_j_text,'Visible',state) |
---|
[41] | 1261 | |
---|
[408] | 1262 | %----------------------------------- |
---|
| 1263 | function view_FieldMenu(handles,state) |
---|
[446] | 1264 | % set(handles.FieldName,'Visible',state) |
---|
[408] | 1265 | % set(handles.Field_text,'Visible',state) |
---|
| 1266 | set(handles.InputFields,'Visible',state) |
---|
| 1267 | |
---|
| 1268 | %----------------------------------- |
---|
| 1269 | function view_FieldMenu_1(handles,state) |
---|
[446] | 1270 | set(handles.FieldName_1,'Visible',state) |
---|
[408] | 1271 | set(handles.Field_text_1,'Visible',state) |
---|
| 1272 | |
---|
| 1273 | |
---|
[446] | 1274 | %%%%%%%%%%%%%%%%%%%% |
---|
| 1275 | %% MAIN ActionName FUNCTIONS |
---|
| 1276 | %%%%%%%%%%%%%%%%%%%% |
---|
[41] | 1277 | %------------------------------------------------------------------------ |
---|
[2] | 1278 | % --- Executes on button press in RUN. |
---|
| 1279 | function RUN_Callback(hObject, eventdata, handles) |
---|
[41] | 1280 | %------------------------------------------------------------------------ |
---|
[2] | 1281 | set(handles.RUN,'BusyAction','queue'); |
---|
[332] | 1282 | set(0,'CurrentFigure',handles.series) |
---|
[446] | 1283 | set(handles.RUN, 'Enable','Off') |
---|
| 1284 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[456] | 1285 | drawnow |
---|
[453] | 1286 | [h_fun,Series,filexml,errormsg]=prepare_jobs(handles); |
---|
[446] | 1287 | if ~isempty(errormsg) |
---|
| 1288 | msgbox_uvmat('ERROR',errormsg) |
---|
[2] | 1289 | else |
---|
[456] | 1290 | %Series.Specific=h_fun(Series); |
---|
| 1291 | Series=h_fun(Series); |
---|
[460] | 1292 | if ~isempty(filexml) |
---|
[453] | 1293 | t=struct2xml(Series); |
---|
| 1294 | t=set(t,1,'name','Series'); |
---|
| 1295 | save(t,filexml); |
---|
[460] | 1296 | end |
---|
[456] | 1297 | % h_fun(Series); |
---|
[2] | 1298 | end |
---|
[446] | 1299 | set(handles.RUN, 'Enable','On') |
---|
| 1300 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[2] | 1301 | |
---|
[446] | 1302 | %------------------------------------------------------------------------ |
---|
| 1303 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1304 | %------------------------------------------------------------------------ |
---|
| 1305 | set(handles.RUN, 'BusyAction','cancel') |
---|
| 1306 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1307 | set(handles.RUN,'enable','on') |
---|
[448] | 1308 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1309 | set(handles.BATCH,'enable','on') |
---|
[446] | 1310 | |
---|
| 1311 | %------------------------------------------------------------------------ |
---|
| 1312 | % --- Executes on button press in BATCH. |
---|
| 1313 | function BATCH_Callback(hObject, eventdata, handles) |
---|
| 1314 | %------------------------------------------------------------------------ |
---|
| 1315 | set(handles.BATCH, 'Enable','Off') |
---|
| 1316 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[453] | 1317 | [h_fun,Series,filexml,errormsg]=prepare_jobs(handles); |
---|
[448] | 1318 | if ~isempty(errormsg) |
---|
| 1319 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1320 | return |
---|
| 1321 | end |
---|
[453] | 1322 | % update the xml file after interactive input with the function |
---|
[460] | 1323 | Series.Specific='?'; |
---|
| 1324 | Series=h_fun(Series); |
---|
[453] | 1325 | t=struct2xml(Series); |
---|
| 1326 | t=set(t,1,'name','Series'); |
---|
| 1327 | save(t,filexml); |
---|
[448] | 1328 | path_series=fileparts(which('series')); |
---|
| 1329 | filename_xml=fullfile(Series.OutputDir,[Series.OutputRootFile '.xml']); |
---|
| 1330 | filename_bat=fullfile(Series.OutputDir,[Series.OutputRootFile '.bat']); |
---|
[446] | 1331 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1332 | if isequal(fid,-1) |
---|
[448] | 1333 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); |
---|
[446] | 1334 | return |
---|
| 1335 | end |
---|
[456] | 1336 | path_fct=get(handles.ActionPath,'String'); |
---|
[446] | 1337 | text_matlabscript=[... |
---|
| 1338 | '#!/bin/bash \n'... |
---|
| 1339 | '. /etc/sysprofile \n'... |
---|
| 1340 | 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'... |
---|
[448] | 1341 | 'cd(''' path_series '''); \n'... |
---|
[456] | 1342 | 'addpath(''' path_fct '''); \n'... |
---|
[448] | 1343 | '' Series.Action '( ''' filename_xml '''); \n'... |
---|
[446] | 1344 | 'exit \n'... |
---|
| 1345 | 'END_MATLAB \n']; |
---|
| 1346 | fprintf(fid,text_matlabscript); |
---|
| 1347 | fclose(fid); |
---|
| 1348 | if isunix |
---|
[456] | 1349 | system(['chmod +x ' filename_bat]);% set the file to executable |
---|
[460] | 1350 | system(['. ' filename_bat ' &']);%execute fct |
---|
| 1351 | else |
---|
| 1352 | system(filename_bat); |
---|
[446] | 1353 | end |
---|
[448] | 1354 | set(handles.BATCH, 'Enable','On') |
---|
| 1355 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[456] | 1356 | |
---|
[446] | 1357 | %------------------------------------------------------------------------ |
---|
| 1358 | % --- Executes on button press in BIN. |
---|
| 1359 | function BIN_Callback(hObject, eventdata, handles) |
---|
| 1360 | %------------------------------------------------------------------------ |
---|
| 1361 | cmd=['#!/bin/bash \n '... |
---|
| 1362 | '#$ -cwd \n '... |
---|
| 1363 | 'hostname && date \n '... |
---|
| 1364 | 'umask 002 \n'... |
---|
| 1365 | Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; |
---|
| 1366 | |
---|
| 1367 | %------------------------------------------------------------------------ |
---|
[456] | 1368 | % --- Main launch command, called by RUN and BATCH |
---|
[453] | 1369 | function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles) |
---|
[446] | 1370 | %------------------------------------------------------------------------ |
---|
[456] | 1371 | filexml=''; |
---|
[446] | 1372 | errormsg=''; |
---|
| 1373 | %% Read parameters from series |
---|
| 1374 | Series=read_GUI(handles.series); |
---|
| 1375 | if isfield(Series,'Pairs') |
---|
| 1376 | Series=rmfield(Series,'Pairs'); %info Pairs not needed for output |
---|
| 1377 | end |
---|
| 1378 | |
---|
[456] | 1379 | %% read index ranges |
---|
[446] | 1380 | first_i=1; |
---|
| 1381 | last_i=1; |
---|
| 1382 | incr_i=1; |
---|
| 1383 | first_j=1; |
---|
| 1384 | last_j=1; |
---|
| 1385 | incr_j=1; |
---|
[339] | 1386 | if isfield(Series.IndexRange,'first_i') |
---|
| 1387 | first_i=Series.IndexRange.first_i; |
---|
| 1388 | incr_i=Series.IndexRange.incr_i; |
---|
| 1389 | last_i=Series.IndexRange.last_i; |
---|
| 1390 | end |
---|
| 1391 | if isfield(Series.IndexRange,'first_j') |
---|
| 1392 | first_j=Series.IndexRange.first_j; |
---|
| 1393 | incr_j=Series.IndexRange.incr_j; |
---|
| 1394 | last_j=Series.IndexRange.last_j; |
---|
| 1395 | end |
---|
| 1396 | |
---|
| 1397 | %% read input file parameters and set menus |
---|
[446] | 1398 | menu_coord_state=get(handles.TransformName,'Visible'); |
---|
[2] | 1399 | if isequal(menu_coord_state,'on') |
---|
[446] | 1400 | menu_index=get(handles.TransformName,'Value'); |
---|
| 1401 | transform_list=get(handles.TransformName,'UserData'); |
---|
| 1402 | Series.FieldTransform.TransformHandle=transform_list{menu_index};% transform function handles |
---|
[2] | 1403 | end |
---|
| 1404 | |
---|
| 1405 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
| 1406 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1407 | |
---|
[446] | 1408 | %% projection object |
---|
| 1409 | if isfield(Series,'CheckObject') |
---|
| 1410 | if Series.CheckObject |
---|
| 1411 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 1412 | Series.ProjObject=read_GUI(hset_object); |
---|
[458] | 1413 | CheckObject_Callback([], [], handles) |
---|
[446] | 1414 | end |
---|
| 1415 | else |
---|
| 1416 | Series.CheckObject=0; |
---|
| 1417 | end |
---|
[2] | 1418 | |
---|
[446] | 1419 | %% get_field GUI |
---|
| 1420 | if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field') |
---|
| 1421 | if strcmp(Series.InputFields.Field,'get_field...') |
---|
| 1422 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1423 | Series.GetField=read_GUI(hget_field); |
---|
| 1424 | end |
---|
| 1425 | end |
---|
[2] | 1426 | |
---|
[446] | 1427 | %% defining the ActionName function handle |
---|
| 1428 | list_action=get(handles.ActionName,'String');% list menu action |
---|
| 1429 | index=get(handles.ActionName,'Value'); |
---|
| 1430 | action= list_action{index}; % selected string |
---|
| 1431 | Series.Action=action;%name of the processing programme |
---|
| 1432 | Series.hseries=handles.series; % handles to the series GUI |
---|
[2] | 1433 | path_series=which('series'); |
---|
[446] | 1434 | list_path=get(handles.ActionName,'UserData'); |
---|
[2] | 1435 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
| 1436 | if ~isequal(fct_path,path_series) |
---|
| 1437 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
[41] | 1438 | if ~exist(fct_path,'dir') |
---|
[446] | 1439 | errormsg=['The prescibed function path ' fct_path ' does not exist']; |
---|
[41] | 1440 | return |
---|
| 1441 | end |
---|
| 1442 | if ~isequal(spath,fct_path) |
---|
[2] | 1443 | addpath(fct_path)% add the prescribed path if not the current one |
---|
| 1444 | end |
---|
| 1445 | end |
---|
[41] | 1446 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
[26] | 1447 | if ~isequal(fct_path,path_series) |
---|
| 1448 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
| 1449 | end |
---|
| 1450 | |
---|
[446] | 1451 | %% create the output data directory and write in it the xml file from the GUI config |
---|
| 1452 | %determine the root file corresponding to the first sub dir |
---|
| 1453 | if isfield(Series,'OutputSubDir') |
---|
| 1454 | SubDirOut=[Series.OutputSubDir Series.OutputDirExt]; |
---|
| 1455 | SubDirOutNew=SubDirOut; |
---|
| 1456 | iview=1; |
---|
| 1457 | SeriesData=get(handles.series,'UserData'); |
---|
| 1458 | if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && isfield(SeriesData.AllowInputSort) |
---|
| 1459 | [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
| 1460 | Series.InputTable=Series.InputTable(iview,:); |
---|
[421] | 1461 | end |
---|
[448] | 1462 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist |
---|
[450] | 1463 | check_create=1; %need to create the result directory by default |
---|
[446] | 1464 | while detect |
---|
[448] | 1465 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); |
---|
| 1466 | if isequal(answer,'Yes') |
---|
| 1467 | detect=0; |
---|
| 1468 | check_create=0; |
---|
| 1469 | else |
---|
| 1470 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
| 1471 | if isempty(r) |
---|
| 1472 | r(1).root=[SubDirOutNew '_']; |
---|
| 1473 | r(1).num1='0'; |
---|
| 1474 | end |
---|
| 1475 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
| 1476 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists |
---|
| 1477 | check_create=1; |
---|
[408] | 1478 | end |
---|
| 1479 | end |
---|
[448] | 1480 | Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,''); |
---|
[446] | 1481 | Series.OutputSubDir=SubDirOutNew; |
---|
| 1482 | Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results |
---|
| 1483 | Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output |
---|
[448] | 1484 | set(handles.OutputDirExt,'String',Series.OutputDirExt) |
---|
[450] | 1485 | %removes redondant information |
---|
| 1486 | Series=rmfield(Series,'OutputDirExt'); |
---|
| 1487 | Series.IndexRange=rmfield(Series.IndexRange,'TimeTable'); |
---|
| 1488 | Series.IndexRange=rmfield(Series.IndexRange,'MinIndex'); |
---|
| 1489 | Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex'); |
---|
[446] | 1490 | % create output directory |
---|
[448] | 1491 | if check_create |
---|
[446] | 1492 | [tild,msg1]=mkdir(Series.OutputDir); |
---|
| 1493 | if ~strcmp(msg1,'') |
---|
| 1494 | errormsg=['cannot create ' Series.OutputDir ': ' msg1];%error message for directory creation |
---|
| 1495 | return |
---|
[421] | 1496 | end |
---|
[408] | 1497 | end |
---|
[446] | 1498 | filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory |
---|
[456] | 1499 | % t=struct2xml(Series); |
---|
| 1500 | % t=set(t,1,'name','Series'); |
---|
| 1501 | % save(t,filexml); |
---|
[408] | 1502 | end |
---|
| 1503 | |
---|
[41] | 1504 | %------------------------------------------------------------------------ |
---|
[446] | 1505 | % --- Executes on selection change in ActionName. |
---|
| 1506 | function ActionName_Callback(hObject, eventdata, handles) |
---|
[41] | 1507 | %------------------------------------------------------------------------ |
---|
[205] | 1508 | global nb_builtin_ACTION |
---|
[446] | 1509 | list_ACTION=get(handles.ActionName,'String');% list menu fields |
---|
| 1510 | index_ACTION=get(handles.ActionName,'Value');% selected string index |
---|
[2] | 1511 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
| 1512 | path_series=which('series');%path to series.m |
---|
[446] | 1513 | list_path=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ACTION |
---|
[39] | 1514 | default_file=fullfile(list_path{end},ACTION); |
---|
[29] | 1515 | % add a new function to the menu if the selected item is 'more...' |
---|
[2] | 1516 | if isequal(ACTION,'more...') |
---|
| 1517 | pathfct=fileparts(path_series); |
---|
| 1518 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1519 | {'*.m', ' (*.m)'; |
---|
| 1520 | '*.m', '.m files '; ... |
---|
| 1521 | '*.*', 'All Files (*.*)'}, ... |
---|
[39] | 1522 | 'Pick a file',default_file); |
---|
[2] | 1523 | if length(FileName)<2 |
---|
| 1524 | return |
---|
[29] | 1525 | end |
---|
| 1526 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
[2] | 1527 | if ~isequal(ext_fct,'.m') |
---|
| 1528 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1529 | return |
---|
| 1530 | end |
---|
| 1531 | |
---|
[446] | 1532 | % insert the choice in the actionname menu |
---|
| 1533 | menu_str=update_menu(handles.ActionName,ACTION);%new action menu in which the new item has been appended if needed |
---|
| 1534 | index_ACTION=get(handles.ActionName,'Value');% currently selected index in the list |
---|
[2] | 1535 | list_path{index_ACTION}=PathName; |
---|
[205] | 1536 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
| 1537 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
| 1538 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
| 1539 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
[2] | 1540 | index_ACTION=index_ACTION-nbremove; |
---|
[446] | 1541 | set(handles.ActionName,'Value',index_ACTION) |
---|
| 1542 | set(handles.ActionName,'String',menu_str) |
---|
[2] | 1543 | end |
---|
| 1544 | list_path{index_ACTION}=PathName; |
---|
[446] | 1545 | set(handles.ActionName,'UserData',list_path); |
---|
| 1546 | set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
[2] | 1547 | |
---|
| 1548 | %record the current menu in personal file profil_perso |
---|
| 1549 | dir_perso=prefdir; |
---|
| 1550 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
[205] | 1551 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
| 1552 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
[2] | 1553 | end |
---|
[206] | 1554 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
| 1555 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
| 1556 | save(profil_perso,'series_fct','-append') |
---|
| 1557 | else |
---|
| 1558 | txt=ver('MATLAB'); |
---|
| 1559 | Release=txt.Release; |
---|
| 1560 | relnumb=str2num(Release(3:4)); |
---|
| 1561 | if relnumb >= 14%recent relaese of Matlab |
---|
| 1562 | save(profil_perso,'series_fct','-V6') |
---|
| 1563 | else |
---|
| 1564 | save(profil_perso, 'series_fct') |
---|
| 1565 | end |
---|
| 1566 | end |
---|
[2] | 1567 | end |
---|
| 1568 | end |
---|
| 1569 | |
---|
[446] | 1570 | %check the current ActionPath to the selected function |
---|
[2] | 1571 | PathName=list_path{index_ACTION};%current recorded path |
---|
[446] | 1572 | set(handles.ActionPath,'String',PathName); %show the path to the senlected function |
---|
[2] | 1573 | |
---|
| 1574 | %default setting for the visibility of the GUI elements |
---|
[339] | 1575 | set(handles.num_NbSlice,'Visible','off') |
---|
[2] | 1576 | set(handles.NbSlice_title,'Visible','off') |
---|
[446] | 1577 | set(handles.VelType,'Visible','off'); |
---|
[2] | 1578 | set(handles.VelType_text,'Visible','off'); |
---|
[446] | 1579 | set(handles.VelType_1,'Visible','off'); |
---|
[2] | 1580 | set(handles.VelType_text_1,'Visible','off'); |
---|
| 1581 | view_FieldMenu(handles,'off') |
---|
| 1582 | view_FieldMenu_1(handles,'off') |
---|
[339] | 1583 | set(handles.FieldTransform,'Visible','off') |
---|
[446] | 1584 | set(handles.CheckObject,'Visible','off'); |
---|
| 1585 | set(handles.ProjObject,'Visible','off'); |
---|
| 1586 | set(handles.CheckMask,'Visible','off') |
---|
[2] | 1587 | set(handles.Mask,'Visible','off') |
---|
[446] | 1588 | % set(handles.OutputDirExt,'Visible','off'); |
---|
[2] | 1589 | set(handles.ParamKey,'Visible','off') |
---|
| 1590 | set(handles.ParamVal,'Visible','off') |
---|
| 1591 | ParamKey={}; |
---|
[446] | 1592 | set(handles.FieldName,'Enable','off') |
---|
| 1593 | set(handles.VelType,'Enable','off') |
---|
| 1594 | set(handles.FieldName_1,'Enable','off') |
---|
| 1595 | set(handles.VelType_1,'Enable','off') |
---|
| 1596 | set(handles.TransformName,'Enable','off') |
---|
| 1597 | set(handles.OutputDirExt,'Visible','off') |
---|
| 1598 | set(handles.OutputSubDir,'Visible','off') |
---|
| 1599 | set(handles.OutputDir_title,'Visible','off') |
---|
[2] | 1600 | %set the displayed GUI item needed for input parameters |
---|
[29] | 1601 | if ~isequal(path_series,PathName) |
---|
| 1602 | addpath(PathName) |
---|
| 1603 | end |
---|
| 1604 | eval(['h_function=@' ACTION ';']); |
---|
[244] | 1605 | try |
---|
| 1606 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
| 1607 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
| 1608 | fclose(fid) |
---|
[456] | 1609 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help |
---|
[244] | 1610 | end |
---|
[29] | 1611 | if ~isequal(path_series,PathName) |
---|
| 1612 | rmpath(PathName) |
---|
| 1613 | end |
---|
| 1614 | varargout=h_function(); |
---|
[2] | 1615 | Param_list={}; |
---|
| 1616 | |
---|
[372] | 1617 | InputTable=get(handles.InputTable,'Data'); |
---|
| 1618 | nb_series=size(InputTable,1); |
---|
[2] | 1619 | testima_series=1; %test for a list of images only |
---|
| 1620 | testima=1; |
---|
| 1621 | testima_1=1; |
---|
| 1622 | testciv_series=1; |
---|
| 1623 | for iview=1:nb_series |
---|
[372] | 1624 | ext=InputTable{iview,5}; |
---|
[2] | 1625 | if length(ext)<2 |
---|
| 1626 | ext='.none'; |
---|
| 1627 | end |
---|
| 1628 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
| 1629 | if ~testimaview |
---|
| 1630 | if iview==1 |
---|
| 1631 | testima=0; |
---|
| 1632 | end |
---|
| 1633 | if iview==2 |
---|
| 1634 | testima_1=0; |
---|
| 1635 | end |
---|
| 1636 | testima_series=0; |
---|
| 1637 | end |
---|
| 1638 | end |
---|
| 1639 | for ilist=1:length(varargout)-1 |
---|
| 1640 | switch varargout{ilist} |
---|
[446] | 1641 | case 'NbViewMax' |
---|
| 1642 | if ~isempty (varargout{ilist+1}) |
---|
| 1643 | if size(InputTable,1)>varargout{ilist+1} |
---|
| 1644 | InputTable=InputTable(1:varargout{ilist+1},:); |
---|
| 1645 | set(handles.InputTable,'Data',InputTable) |
---|
| 1646 | end |
---|
| 1647 | end |
---|
| 1648 | case 'AllowInputSort' |
---|
| 1649 | if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir |
---|
| 1650 | SeriesData=get(handles.series,'UserData'); |
---|
| 1651 | SeriesData.AllowInputSort=1; |
---|
| 1652 | set(handles.series,'UserData',SeriesData) |
---|
[456] | 1653 | end |
---|
| 1654 | case 'WholeIndexRange' |
---|
| 1655 | if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir |
---|
| 1656 | MinIndex=get(handles.MinIndex,'Data'); |
---|
| 1657 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
| 1658 | if ~isempty(MinIndex) |
---|
| 1659 | set(handles.num_first_i,'String',num2str(MinIndex{1})) |
---|
| 1660 | set(handles.num_last_i,'String',num2str(MaxIndex{1})) |
---|
| 1661 | set(handles.num_incr_i,'String','1') |
---|
| 1662 | if size(MinIndex,2)>=2 |
---|
| 1663 | set(handles.num_first_j,'String',num2str(MinIndex{1,2})) |
---|
| 1664 | set(handles.num_last_j,'String',num2str(MaxIndex{1,2})) |
---|
| 1665 | set(handles.num_incr_j,'String','1') |
---|
| 1666 | end |
---|
| 1667 | end |
---|
| 1668 | end |
---|
[2] | 1669 | case 'NbSlice' %hidden by default |
---|
| 1670 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[339] | 1671 | set(handles.num_NbSlice,'Visible','on') |
---|
[2] | 1672 | set(handles.NbSlice_title,'Visible','on') |
---|
| 1673 | end |
---|
[446] | 1674 | case 'VelType' %hidden by default |
---|
[372] | 1675 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
[446] | 1676 | set(handles.VelType,'Enable','on') |
---|
[2] | 1677 | if nb_series >=1 && ~testima_series |
---|
[446] | 1678 | set(handles.VelType,'Visible','on') |
---|
[2] | 1679 | set(handles.VelType_text,'Visible','on'); |
---|
| 1680 | end |
---|
[372] | 1681 | end |
---|
[2] | 1682 | if isequal(lower(varargout{ilist+1}),'two') |
---|
[446] | 1683 | set(handles.VelType_1,'Enable','on') |
---|
[2] | 1684 | if nb_series >=2 && ~testima_series |
---|
[446] | 1685 | set(handles.VelType_1,'Visible','on') |
---|
[2] | 1686 | set(handles.VelType_text_1,'Visible','on'); |
---|
| 1687 | end |
---|
| 1688 | end |
---|
[446] | 1689 | case 'FieldName' %hidden by default |
---|
[2] | 1690 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
[446] | 1691 | set(handles.FieldName,'Enable','on') % test for MenuBorser |
---|
[2] | 1692 | if nb_series >=1 && ~testima_series |
---|
| 1693 | view_FieldMenu(handles,'on') |
---|
| 1694 | end |
---|
| 1695 | end |
---|
| 1696 | if isequal(lower(varargout{ilist+1}),'two') |
---|
[446] | 1697 | set(handles.FieldName_1,'Enable','on') |
---|
[2] | 1698 | if nb_series >=2 && ~testima_1 |
---|
| 1699 | view_FieldMenu_1(handles,'on') |
---|
| 1700 | end |
---|
| 1701 | end |
---|
[446] | 1702 | case 'FieldTransform' %hidden by default |
---|
[2] | 1703 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[446] | 1704 | set(handles.TransformName,'Enable','on') |
---|
[339] | 1705 | set(handles.FieldTransform,'Visible','on') |
---|
[2] | 1706 | end |
---|
[446] | 1707 | case 'ProjObject' %hidden by default |
---|
[2] | 1708 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[446] | 1709 | set(handles.CheckObject,'Visible','on') |
---|
| 1710 | set(handles.ProjObject,'Visible','on') |
---|
[2] | 1711 | end |
---|
| 1712 | case 'Mask' %hidden by default |
---|
| 1713 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[446] | 1714 | set(handles.Mask,'Visible','on') |
---|
| 1715 | set(handles.CheckMask,'Visible','on'); |
---|
[2] | 1716 | end |
---|
[446] | 1717 | case 'PARAMETER' % NOT USED |
---|
[2] | 1718 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
| 1719 | set(handles.PARAMETERS_title,'Visible','on') |
---|
| 1720 | set(handles.ParamKey,'Visible','on') |
---|
| 1721 | %set(handles.ParamVal,'Visible','on') |
---|
| 1722 | Param_str=varargout{ilist+1}; |
---|
[446] | 1723 | Param_list=[Param_list; {Param_str}]; |
---|
| 1724 | case 'OutputDirExt' |
---|
| 1725 | if ~isempty(varargout{ilist+1}) |
---|
| 1726 | set(handles.OutputDirExt,'String',varargout{ilist+1}) |
---|
| 1727 | set(handles.OutputDirExt,'Visible','on') |
---|
| 1728 | set(handles.OutputSubDir,'Visible','on') |
---|
| 1729 | set(handles.OutputDir_title,'Visible','on') |
---|
| 1730 | end |
---|
[2] | 1731 | end |
---|
| 1732 | end |
---|
| 1733 | if ~isempty(Param_list) |
---|
| 1734 | set(handles.ParamKey,'String',Param_list) |
---|
| 1735 | set(handles.ParamVal,'Visible','on') |
---|
| 1736 | end |
---|
| 1737 | |
---|
[41] | 1738 | %------------------------------------------------------------------------ |
---|
[446] | 1739 | % --- Executes on selection change in FieldName. |
---|
| 1740 | function FieldName_Callback(hObject, eventdata, handles) |
---|
[41] | 1741 | %------------------------------------------------------------------------ |
---|
[446] | 1742 | field_str=get(handles.FieldName,'String'); |
---|
| 1743 | field_index=get(handles.FieldName,'Value'); |
---|
[2] | 1744 | field=field_str{field_index(1)}; |
---|
| 1745 | if isequal(field,'get_field...') |
---|
| 1746 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1747 | if ~isempty(hget_field) |
---|
| 1748 | delete(hget_field)%delete opened versions of get_field |
---|
| 1749 | end |
---|
[453] | 1750 | filecell=get_file_series(read_GUI(handles.series)); |
---|
[428] | 1751 | if exist(filecell{1,1},'file') |
---|
| 1752 | get_field(filecell{1,1}) |
---|
[2] | 1753 | end |
---|
| 1754 | elseif isequal(field,'more...') |
---|
| 1755 | str=calc_field; |
---|
| 1756 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1757 | 'SelectionMode','single',... |
---|
| 1758 | 'ListString',str); |
---|
[446] | 1759 | % edit the choice in the fields and actionname menu |
---|
[2] | 1760 | scalar=cell2mat(str(ind_answer)); |
---|
[446] | 1761 | update_menu(handles.FieldName,scalar) |
---|
[2] | 1762 | end |
---|
| 1763 | |
---|
[41] | 1764 | %------------------------------------------------------------------------ |
---|
[446] | 1765 | % --- Executes on selection change in FieldName_1. |
---|
| 1766 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
[41] | 1767 | %------------------------------------------------------------------------ |
---|
[446] | 1768 | field_str=get(handles.FieldName_1,'String'); |
---|
| 1769 | field_index=get(handles.FieldName_1,'Value'); |
---|
[2] | 1770 | field=field_str{field_index}; |
---|
| 1771 | if isequal(field,'get_field...') |
---|
| 1772 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 1773 | if ~isempty(hget_field) |
---|
| 1774 | delete(hget_field) |
---|
| 1775 | end |
---|
[332] | 1776 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1777 | filename=SeriesData.CurrentInputFile_1; |
---|
| 1778 | if exist(filename,'file') |
---|
| 1779 | hget_field=get_field(filename); |
---|
| 1780 | set(hget_field,'name','get_field_1') |
---|
| 1781 | end |
---|
| 1782 | elseif isequal(field,'more...') |
---|
| 1783 | str=calc_field; |
---|
| 1784 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1785 | 'SelectionMode','single',... |
---|
| 1786 | 'ListString',str); |
---|
[446] | 1787 | % edit the choice in the fields and actionname menu |
---|
[2] | 1788 | scalar=cell2mat(str(ind_answer)); |
---|
[446] | 1789 | update_menu(handles.FieldName_1,scalar) |
---|
[2] | 1790 | end |
---|
[29] | 1791 | |
---|
[244] | 1792 | |
---|
[2] | 1793 | %%%%%%%%%%%%% |
---|
| 1794 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
[339] | 1795 | indsel=ind_i; |
---|
| 1796 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
| 1797 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
| 1798 | if ~isempty(indiff) |
---|
| 1799 | indiff2=diff(indiff); |
---|
| 1800 | indiffp=[indiff2 1]; |
---|
| 1801 | indiffm=[1 indiff2]; |
---|
| 1802 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
| 1803 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
| 1804 | %for each multiplet, select the most recent file |
---|
| 1805 | ind_remove=[]; |
---|
| 1806 | for i=1:length(ind_multi_m) |
---|
| 1807 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
| 1808 | for imulti=1:length(ind_pairs) |
---|
| 1809 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
[2] | 1810 | end |
---|
[339] | 1811 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
| 1812 | ind_s=indsort2(1:end-1);% |
---|
| 1813 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
| 1814 | end |
---|
| 1815 | end |
---|
[2] | 1816 | |
---|
[89] | 1817 | %------------------------------------------------------------------------ |
---|
[408] | 1818 | % --- determine the list of index pairstring of processing file |
---|
[32] | 1819 | 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] | 1820 | %------------------------------------------------------------------------ |
---|
[32] | 1821 | num_i1=num_i;% set of first image numbers by default |
---|
| 1822 | num_i2=num_i; |
---|
| 1823 | num_j1=num_j; |
---|
| 1824 | num_j2=num_j; |
---|
| 1825 | num_i_out=num_i; |
---|
| 1826 | num_j_out=num_j; |
---|
[339] | 1827 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
| 1828 | if isequal(mode,'series(Di)') |
---|
[32] | 1829 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
| 1830 | num_i2_line=num_i+ind_shift(4); |
---|
| 1831 | % adjust the first and last field number |
---|
| 1832 | indsel=find(num_i1_line >= 1); |
---|
| 1833 | num_i_out=num_i(indsel); |
---|
| 1834 | num_i1_line=num_i1_line(indsel); |
---|
| 1835 | num_i2_line=num_i2_line(indsel); |
---|
| 1836 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 1837 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 1838 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
| 1839 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
[339] | 1840 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
[32] | 1841 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
| 1842 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
| 1843 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
| 1844 | else |
---|
| 1845 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
| 1846 | num_j2_col=num_j+ind_shift(2); |
---|
| 1847 | % adjust the first field number |
---|
| 1848 | indsel=find((num_j1_col >= 1)); |
---|
| 1849 | num_j_out=num_j(indsel); |
---|
| 1850 | num_j1_col=num_j1_col(indsel); |
---|
| 1851 | num_j2_col=num_j2_col(indsel); |
---|
| 1852 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
| 1853 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
| 1854 | end |
---|
| 1855 | end |
---|
[2] | 1856 | |
---|
[41] | 1857 | %------------------------------------------------------------------------ |
---|
[446] | 1858 | % --- Executes on button press in CheckObject. |
---|
| 1859 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
[41] | 1860 | %------------------------------------------------------------------------ |
---|
[446] | 1861 | % SeriesData=get(handles.series,'UserData'); |
---|
| 1862 | value=get(handles.CheckObject,'Value'); |
---|
[2] | 1863 | if value |
---|
[446] | 1864 | set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
[76] | 1865 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
[2] | 1866 | if ishandle(hset_object) |
---|
[421] | 1867 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
[2] | 1868 | else |
---|
[41] | 1869 | %get the object file |
---|
[376] | 1870 | InputTable=get(handles.InputTable,'Data'); |
---|
| 1871 | defaultname=InputTable{1,1}; |
---|
[106] | 1872 | if isempty(defaultname) |
---|
| 1873 | defaultname={''}; |
---|
| 1874 | end |
---|
[41] | 1875 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1876 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 1877 | '*.xml', '.xml files '; ... |
---|
| 1878 | '*.mat', '.mat matlab files '}, ... |
---|
[427] | 1879 | 'Pick an xml object file (or use uvmat to create it)',defaultname); |
---|
[41] | 1880 | fileinput=[PathName FileName];%complete file name |
---|
| 1881 | sizf=size(fileinput); |
---|
| 1882 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 1883 | %read the file |
---|
[427] | 1884 | data=xml2struct(fileinput); |
---|
[446] | 1885 | if ~isfield(data,'Type') |
---|
| 1886 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
| 1887 | return |
---|
[41] | 1888 | end |
---|
| 1889 | if ~isfield(data,'ProjMode') |
---|
[446] | 1890 | data.ProjMode='none'; |
---|
[41] | 1891 | end |
---|
[446] | 1892 | hset_object=set_object(data);% call the set_object interface |
---|
[2] | 1893 | end |
---|
[446] | 1894 | Object=read_GUI(hset_object); |
---|
| 1895 | set(handles.ProjObject,'String',Object.Name);%display the object name |
---|
[2] | 1896 | else |
---|
[446] | 1897 | set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
[2] | 1898 | end |
---|
[446] | 1899 | %set(handles.series,'UserData',SeriesData) |
---|
[2] | 1900 | |
---|
| 1901 | %-------------------------------------------------------------- |
---|
[446] | 1902 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1903 | value=get(handles.CheckMask,'Value'); |
---|
[2] | 1904 | if value |
---|
[41] | 1905 | msgbox_uvmat('ERROR','not implemented yet') |
---|
[2] | 1906 | end |
---|
| 1907 | %-------------------------------------------------------------- |
---|
| 1908 | |
---|
[41] | 1909 | %------------------------------------------------------------------- |
---|
[2] | 1910 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
| 1911 | function ncbrowser_uvmat(hObject, eventdata) |
---|
[41] | 1912 | %------------------------------------------------------------------- |
---|
[2] | 1913 | bla=get(gcbo,'String'); |
---|
| 1914 | ind=get(gcbo,'Value'); |
---|
| 1915 | filename=cell2mat(bla(ind)); |
---|
| 1916 | blank=find(filename==' '); |
---|
| 1917 | filename=filename(1:blank-1); |
---|
| 1918 | get_field(filename) |
---|
| 1919 | |
---|
[41] | 1920 | % ------------------------------------------------------------------ |
---|
[2] | 1921 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[41] | 1922 | %------------------------------------------------------------------- |
---|
[2] | 1923 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 1924 | pathelp=fileparts(path_to_uvmat); |
---|
[36] | 1925 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 1926 | 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') |
---|
[2] | 1927 | else |
---|
[36] | 1928 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 1929 | web([helpfile '#series']) |
---|
[2] | 1930 | end |
---|
| 1931 | |
---|
[41] | 1932 | %------------------------------------------------------------------- |
---|
[446] | 1933 | % --- Executes on selection change in TransformName. |
---|
| 1934 | function TransformName_Callback(hObject, eventdata, handles) |
---|
[41] | 1935 | %------------------------------------------------------------------- |
---|
[39] | 1936 | global nb_transform |
---|
[2] | 1937 | |
---|
[446] | 1938 | menu=get(handles.TransformName,'String'); |
---|
| 1939 | ind_coord=get(handles.TransformName,'Value'); |
---|
[39] | 1940 | coord_option=menu{ind_coord}; |
---|
[446] | 1941 | list_transform=get(handles.TransformName,'UserData'); |
---|
[39] | 1942 | ff=functions(list_transform{end}); |
---|
| 1943 | if isequal(coord_option,'more...'); |
---|
| 1944 | coord_fct=''; |
---|
| 1945 | prompt = {'Enter the name of the transform function'}; |
---|
| 1946 | dlg_title = 'user defined transform'; |
---|
| 1947 | num_lines= 1; |
---|
| 1948 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1949 | {'*.m', ' (*.m)'; |
---|
| 1950 | '*.m', '.m files '; ... |
---|
| 1951 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1952 | 'Pick a file', ff.file); |
---|
| 1953 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
| 1954 | PathName(end)=[]; |
---|
| 1955 | end |
---|
| 1956 | transform_selected =fullfile(PathName,FileName); |
---|
| 1957 | if ~exist(transform_selected,'file') |
---|
| 1958 | return |
---|
| 1959 | end |
---|
| 1960 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
| 1961 | if ~isequal(ext_fct,'.m') |
---|
| 1962 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1963 | return |
---|
| 1964 | end |
---|
[446] | 1965 | menu=update_menu(handles.TransformName,transform);%add the selected fct to the menu |
---|
| 1966 | ind_coord=get(handles.TransformName,'Value'); |
---|
[39] | 1967 | addpath(PathName) |
---|
| 1968 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
[446] | 1969 | set(handles.TransformName,'UserData',list_transform) |
---|
[39] | 1970 | rmpath(PathName) |
---|
| 1971 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 1972 | dir_perso=prefdir;%personal Matalb directory |
---|
| 1973 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1974 | if exist(profil_perso,'file') |
---|
| 1975 | for ilist=nb_transform+1:numel(list_transform) |
---|
[55] | 1976 | ff=functions(list_transform{ilist}); |
---|
[39] | 1977 | transform_fct{ilist-nb_transform}=ff.file; |
---|
| 1978 | end |
---|
| 1979 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
| 1980 | end |
---|
| 1981 | end |
---|
[2] | 1982 | |
---|
[446] | 1983 | %check the current ActionPath to the selected function |
---|
[248] | 1984 | if ~isempty(list_transform{ind_coord}) |
---|
[39] | 1985 | func=functions(list_transform{ind_coord}); |
---|
[446] | 1986 | set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function |
---|
[248] | 1987 | else |
---|
[446] | 1988 | set(handles.TransformPath,'String',''); %show the path to the senlected function |
---|
[248] | 1989 | end |
---|
[350] | 1990 | |
---|
[446] | 1991 | % %------------------------------------------------------------------------ |
---|
| 1992 | % % --- Executes on button press in REFRESH_INDICES. |
---|
| 1993 | % function REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
| 1994 | % %------------------------------------------------------------------------ |
---|
| 1995 | % % hObject handle to REFRESH_INDICES (see GCBO) |
---|
| 1996 | % % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1997 | % % handles structure with handles and user data (see GUIDATA) |
---|
| 1998 | % set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1999 | % InputTable=get(handles.InputTable,'Data'); |
---|
| 2000 | % check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
| 2001 | % |
---|
| 2002 | % %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
| 2003 | % for ind_list=1:length(check_lines) |
---|
| 2004 | % if check_lines(ind_list) |
---|
| 2005 | % InputLine=InputTable(ind_list,:); |
---|
| 2006 | % detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
| 2007 | % detect_idem=detect_idem(detect_idem>0); |
---|
| 2008 | % if ~isempty (detect_idem) |
---|
| 2009 | % InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
| 2010 | % set(handles.InputTable,'Data',InputTable) |
---|
| 2011 | % end |
---|
| 2012 | % fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
| 2013 | % %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
| 2014 | % %update file series defined by the selected line |
---|
| 2015 | % [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
| 2016 | % if ~isempty(errormsg) |
---|
| 2017 | % msgbox_uvmat('ERROR',errormsg) |
---|
| 2018 | % return |
---|
| 2019 | % end |
---|
| 2020 | % end |
---|
| 2021 | % end |
---|
| 2022 | % set(handles.InputTable,'Data',InputTable) |
---|
| 2023 | % SeriesData=get(handles.series,'UserData'); |
---|
| 2024 | % |
---|
| 2025 | % state_j='off'; |
---|
| 2026 | % state_Pairs='off'; |
---|
| 2027 | % state_InputFields='off'; |
---|
| 2028 | % val=get(handles.ListView,'Value'); |
---|
| 2029 | % ListViewString={''}; |
---|
| 2030 | % if ~isempty(SeriesData) |
---|
| 2031 | % % ListViewString={}; |
---|
| 2032 | % for iview=1:size(InputTable,1) |
---|
| 2033 | % if ~isempty(SeriesData.j1_series{iview}) |
---|
| 2034 | % state_j='on'; |
---|
| 2035 | % end |
---|
| 2036 | % if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
| 2037 | % state_Pairs='on'; |
---|
| 2038 | % ListViewString{iview}=num2str(iview); |
---|
| 2039 | % if check_lines(iview) |
---|
| 2040 | % val=iview;%select the last pair if it is a new entry |
---|
| 2041 | % end |
---|
| 2042 | % end |
---|
| 2043 | % if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
| 2044 | % state_InputFields='on'; |
---|
| 2045 | % end |
---|
| 2046 | % end |
---|
| 2047 | % end |
---|
| 2048 | % set(handles.ListView,'Value',val) |
---|
| 2049 | % set(handles.ListView,'String',ListViewString) |
---|
| 2050 | % if strcmp(state_Pairs,'on') |
---|
| 2051 | % ListView_Callback(hObject,eventdata,handles) |
---|
| 2052 | % end |
---|
| 2053 | % set(handles.PairString,'Visible',state_Pairs) |
---|
| 2054 | % enable_j(handles,state_j) |
---|
| 2055 | % set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0]) |
---|
| 2056 | % set(handles.REFRESH_INDICES,'visible','off') |
---|
[350] | 2057 | |
---|
[372] | 2058 | % ----------------------------------------------------------------------- |
---|
| 2059 | % --- Update min and max indices of a file series by scanning with find_file_series |
---|
| 2060 | % --- which also changes the root file and NomType in case of movie. Also adjust the string representation of indices (e.g; |
---|
| 2061 | % --- 1 or 001 by the function find_file_series |
---|
| 2062 | % --- This function also dispaly the set of availbale files in the series |
---|
| 2063 | % --- and the menus appropriate to the file type as well as timing possibly set |
---|
| 2064 | % --- by an xml image documentation file |
---|
| 2065 | function [RootFile,NomType,errormsg]=update_indices(handles,fileinput,iview) |
---|
| 2066 | % ----------------------------------------------------------------------- |
---|
[350] | 2067 | %% look for min and max indices existing in the file series and update SeriesData |
---|
| 2068 | errormsg=''; |
---|
[398] | 2069 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
| 2070 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 2071 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 2072 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
[350] | 2073 | if isempty(RootFile)&&isempty(i1_series) |
---|
[358] | 2074 | errormsg='no input file in the series'; |
---|
[350] | 2075 | return |
---|
| 2076 | end |
---|
| 2077 | |
---|
[408] | 2078 | %% adjust the min and max indices common to all the file series |
---|
[350] | 2079 | MinIndex=get(handles.MinIndex,'Data'); |
---|
| 2080 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
| 2081 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
| 2082 | if ~isempty(i2_series) |
---|
| 2083 | MaxIndex_i=max(i2_series(i2_series>0)); |
---|
| 2084 | else |
---|
| 2085 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
| 2086 | end |
---|
| 2087 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
| 2088 | if ~isempty(j2_series) |
---|
| 2089 | MaxIndex_j=max(j2_series(j2_series>0)); |
---|
| 2090 | else |
---|
| 2091 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
| 2092 | end |
---|
[358] | 2093 | MinIndex{iview,1}=MinIndex_i; |
---|
| 2094 | MinIndex{iview,2}=MinIndex_j; |
---|
| 2095 | MaxIndex{iview,1}=MaxIndex_i; |
---|
| 2096 | MaxIndex{iview,2}=MaxIndex_j; |
---|
[350] | 2097 | set(handles.MinIndex,'Data',MinIndex) |
---|
| 2098 | set(handles.MaxIndex,'Data',MaxIndex) |
---|
| 2099 | SeriesData=get(handles.series,'UserData'); |
---|
[358] | 2100 | SeriesData.i1_series{iview}=i1_series; |
---|
| 2101 | SeriesData.i2_series{iview}=i2_series; |
---|
| 2102 | SeriesData.j1_series{iview}=j1_series; |
---|
| 2103 | SeriesData.j2_series{iview}=j2_series; |
---|
| 2104 | SeriesData.FileType{iview}=FileType; |
---|
[350] | 2105 | |
---|
[372] | 2106 | %% display the set of existing files as an image |
---|
[350] | 2107 | set(handles.waitbar_frame,'Units','pixels') |
---|
| 2108 | pos=get(handles.waitbar_frame,'Position'); |
---|
| 2109 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
| 2110 | yima=0.5:pos(4)-0.5; |
---|
| 2111 | [XIma,YIma]=meshgrid(xima,yima); |
---|
| 2112 | nb_i=size(i1_series,1); |
---|
| 2113 | nb_j=size(i1_series,2); |
---|
| 2114 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
| 2115 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
| 2116 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
| 2117 | CData=zeros([size(XIma) 3]); |
---|
| 2118 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
| 2119 | if numel(file_ima)>=2 |
---|
| 2120 | if size(file_ima,1)==1 |
---|
| 2121 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
| 2122 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
| 2123 | else |
---|
| 2124 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
| 2125 | end |
---|
| 2126 | set(handles.waitbar_frame,'CData',CData) |
---|
| 2127 | end |
---|
| 2128 | set(handles.waitbar_frame,'Units','normalized') |
---|
| 2129 | |
---|
| 2130 | %% enable field and veltype menus |
---|
[446] | 2131 | testfield=isequal(get(handles.FieldName,'enable'),'on'); |
---|
| 2132 | testfield_1=isequal(get(handles.FieldName_1,'enable'),'on'); |
---|
| 2133 | testveltype=isequal(get(handles.VelType,'enable'),'on'); |
---|
| 2134 | testveltype_1=isequal(get(handles.VelType_1,'enable'),'on'); |
---|
| 2135 | testtransform=isequal(get(handles.TransformName,'Enable'),'on'); |
---|
[372] | 2136 | % testnc=0; |
---|
| 2137 | % testnc_1=0; |
---|
| 2138 | % testcivx=0; |
---|
| 2139 | % testcivx_1=0; |
---|
| 2140 | % testima=0; %test for image input |
---|
| 2141 | % if isequal(lower(FileExt),'.avi') %.avi file |
---|
| 2142 | % testima=1; |
---|
| 2143 | % elseif ~isempty(imformats(FileExt(2:end))) |
---|
| 2144 | % testima=1; |
---|
| 2145 | % elseif isequal(FileExt,'.vol') |
---|
| 2146 | % testima=1; |
---|
| 2147 | % end |
---|
[350] | 2148 | %TODO: update |
---|
| 2149 | % if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
| 2150 | % for iview=1:length(FileExtCell) |
---|
| 2151 | % if isequal(FileExtCell{iview},'.nc') |
---|
| 2152 | % testnc=1; |
---|
| 2153 | % end |
---|
| 2154 | % if isequal(FileTypeCell{iview},'civx') |
---|
| 2155 | % testcivx=1; |
---|
| 2156 | % end |
---|
| 2157 | % end |
---|
| 2158 | % elseif length(FileExtCell)==2 |
---|
| 2159 | % testnc=isequal(FileExtCell{1},'.nc'); |
---|
| 2160 | % testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
| 2161 | % testcivx=isequal(FileTypeCell{1},'civx'); |
---|
| 2162 | % testcivx_1=isequal(FileTypeCell{2},'civx'); |
---|
| 2163 | % end |
---|
[372] | 2164 | switch FileType |
---|
| 2165 | case {'civx','civdata'} |
---|
[350] | 2166 | view_FieldMenu(handles,'on') |
---|
[446] | 2167 | menustr=get(handles.FieldName,'String'); |
---|
[372] | 2168 | if isequal(menustr,{'get_field...'}) |
---|
[446] | 2169 | set(handles.FieldName,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
[350] | 2170 | end |
---|
[446] | 2171 | set(handles.VelType,'Visible','on') |
---|
[372] | 2172 | set(handles.FieldTransform,'Visible','on') |
---|
| 2173 | % view_TRANSFORM(handles,'on') |
---|
| 2174 | % TODO: second menu |
---|
| 2175 | % view_FieldMenu_1(handles,'on') |
---|
| 2176 | % if testcivx_1 |
---|
[446] | 2177 | % menustr=get(handles.FieldName_1,'String'); |
---|
[372] | 2178 | % if isequal(menustr,{'get_field...'}) |
---|
[446] | 2179 | % set(handles.FieldName_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
[372] | 2180 | % end |
---|
| 2181 | % else |
---|
[446] | 2182 | % set(handles.FieldName_1,'Value',1) |
---|
| 2183 | % set(handles.FieldName_1,'String',{'get_field...'}) |
---|
| 2184 | % set(handles.VelType_1,'Visible','on') |
---|
[372] | 2185 | % set(handles.VelType_text_1,'Visible','on'); |
---|
| 2186 | % end |
---|
| 2187 | % view_FieldMenu_1(handles,'off') |
---|
| 2188 | case 'netcdf' |
---|
| 2189 | view_FieldMenu(handles,'on') |
---|
[446] | 2190 | set(handles.FieldName,'Value',1) |
---|
| 2191 | set(handles.FieldName,'String',{'get_field...'}) |
---|
[372] | 2192 | set(handles.FieldTransform,'Visible','off') |
---|
| 2193 | % view_TRANSFORM(handles,'off') |
---|
| 2194 | case {'image','multimage','video'} |
---|
[350] | 2195 | view_FieldMenu(handles,'off') |
---|
| 2196 | view_FieldMenu_1(handles,'off') |
---|
[446] | 2197 | set(handles.VelType,'Visible','off') |
---|
[350] | 2198 | set(handles.VelType_text,'Visible','off'); |
---|
| 2199 | end |
---|
[372] | 2200 | |
---|
| 2201 | |
---|
[350] | 2202 | %TODO:update |
---|
| 2203 | % if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima |
---|
| 2204 | % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt]) |
---|
| 2205 | % return |
---|
| 2206 | % end |
---|
| 2207 | |
---|
| 2208 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2209 | ext_imadoc=''; |
---|
[398] | 2210 | FileBase=fullfile(RootPath,RootFile); |
---|
[350] | 2211 | if isequal(FileExt,'.xml')||isequal(FileExt,'.civ') |
---|
| 2212 | ext_imadoc=FileExt; |
---|
| 2213 | elseif exist([FileBase '.xml'],'file') |
---|
| 2214 | ext_imadoc='.xml'; |
---|
| 2215 | elseif exist([FileBase '.civ'],'file') |
---|
| 2216 | ext_imadoc='.civ'; |
---|
| 2217 | end |
---|
| 2218 | %read the ImaDoc file |
---|
| 2219 | XmlData=[]; |
---|
| 2220 | NbSlice_calib={}; |
---|
| 2221 | if isequal(ext_imadoc,'.xml') |
---|
| 2222 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
| 2223 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
| 2224 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
| 2225 | end |
---|
| 2226 | if isfield(XmlData,'Time') |
---|
[408] | 2227 | time{iview}=XmlData.Time; |
---|
[350] | 2228 | end |
---|
| 2229 | if isfield(XmlData,'Camera') |
---|
| 2230 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
| 2231 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
| 2232 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 2233 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 2234 | end |
---|
| 2235 | end |
---|
| 2236 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
| 2237 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 2238 | end |
---|
| 2239 | end |
---|
| 2240 | if ~isempty(warntext) |
---|
| 2241 | msgbox_uvmat('WARNING',warntext) |
---|
| 2242 | end |
---|
| 2243 | elseif isequal(ext_imadoc,'.civ') |
---|
| 2244 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
[408] | 2245 | time{iview}=XmlData.Time; |
---|
[350] | 2246 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
| 2247 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
| 2248 | end |
---|
[408] | 2249 | end |
---|
[350] | 2250 | |
---|
[408] | 2251 | %% update time table |
---|
[446] | 2252 | TimeTable=get(handles.TimeTable,'Data'); |
---|
[408] | 2253 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
| 2254 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
| 2255 | set(handles.TimeTable,'Data',TimeTable) |
---|
[350] | 2256 | |
---|
| 2257 | %% number of slices |
---|
| 2258 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
| 2259 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
| 2260 | if siz(1)>1 |
---|
| 2261 | NbSlice=siz(1); |
---|
| 2262 | else |
---|
| 2263 | NbSlice=1; |
---|
| 2264 | end |
---|
| 2265 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
| 2266 | end |
---|
[408] | 2267 | % set(handles.mode,'Visible','off') % do not show index pairstring by default |
---|
| 2268 | set(handles.PairString,'Visible','off') |
---|
| 2269 | % set(handles.num_ref_i,'Visible','off') |
---|
[350] | 2270 | % set(handles.ref_i_text,'Visible','off') |
---|
| 2271 | testpair=0; |
---|
[408] | 2272 | %set the menus of image pairstring and default selection for series |
---|
| 2273 | %list pairstring if relevant |
---|
[350] | 2274 | % Val=get(handles.NomType,'Value'); |
---|
| 2275 | % synchronise_view(handles,Val) |
---|
| 2276 | |
---|
| 2277 | % if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{index}) |
---|
| 2278 | % state_j='off'; %no need for j index |
---|
| 2279 | % else |
---|
| 2280 | % state_j='on'; %case of j index |
---|
| 2281 | % end |
---|
[408] | 2282 | % show index pairstring if files exist |
---|
[350] | 2283 | set(handles.series,'UserData',SeriesData) |
---|
| 2284 | |
---|
[351] | 2285 | |
---|
[446] | 2286 | % -------------------------------------------------------------------- |
---|
| 2287 | function MenuExportConfig_Callback(hObject, eventdata, handles) |
---|
| 2288 | global Series |
---|
| 2289 | [tild,Series,errormsg]=prepare_jobs(handles); |
---|
| 2290 | % Series=read_GUI(handles.series); |
---|
[358] | 2291 | |
---|
[446] | 2292 | evalin('base','global Series')%make CurData global in the workspace |
---|
| 2293 | display('current series config :') |
---|
| 2294 | evalin('base','Series') %display CurData in the workspace |
---|
| 2295 | commandwindow; %brings the Matlab command window to the front |
---|