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