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