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