[2] | 1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % provides an interface for the software CIVx |
---|
| 4 | % function varargout = civ(varargin) |
---|
| 5 | % provides an interface for the software CIVx |
---|
| 6 | % |
---|
| 7 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 8 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 9 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 10 | % This file is part of the toolbox UVMAT. |
---|
| 11 | % |
---|
| 12 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 13 | % it under the terms of the GNU General Public License as published by |
---|
| 14 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 15 | % (at your option) any later version. |
---|
| 16 | % |
---|
| 17 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 20 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 21 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 22 | function varargout = civ(varargin) |
---|
| 23 | |
---|
[12] | 24 | % Last Modified by GUIDE v2.5 10-Jan-2010 22:04:45 |
---|
[2] | 25 | % Begin initialization code - DO NOT EDIT |
---|
| 26 | gui_Singleton = 1; |
---|
| 27 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 28 | 'gui_Singleton', gui_Singleton, ... |
---|
| 29 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 30 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 31 | 'gui_LayoutFcn', [] , ... |
---|
| 32 | 'gui_Callback', []); |
---|
| 33 | if nargin && ischar(varargin{1}) |
---|
| 34 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 35 | end |
---|
| 36 | |
---|
| 37 | if nargout |
---|
| 38 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 39 | else |
---|
| 40 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 41 | end |
---|
| 42 | % End initialization code - DO NOT EDIT |
---|
| 43 | |
---|
[12] | 44 | %------------------------------------------------------------------------ |
---|
[2] | 45 | % --- Executes just before civ is made visible. |
---|
| 46 | function civ_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
[12] | 47 | %------------------------------------------------------------------------ |
---|
[2] | 48 | % This function has no output args, see OutputFcn. |
---|
| 49 | % hObject handle to figure |
---|
| 50 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 51 | % handles structure with handles and user data (see GUIDATA) |
---|
| 52 | % varargin command line arguments to civ (see VARARGIN) |
---|
| 53 | global test_batch patch_new_exe%=1 if patch processing available |
---|
| 54 | %filebase: root name |
---|
| 55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
| 56 | %list of field numbers to process |
---|
| 57 | %subdir: subdirectory of the opened netcdf file |
---|
| 58 | %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), |
---|
| 59 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
| 60 | % Choose default command line output for civ |
---|
| 61 | handles.output = hObject; |
---|
| 62 | % Update handles structure |
---|
| 63 | guidata(hObject, handles); |
---|
| 64 | |
---|
| 65 | %default initial parameters |
---|
| 66 | filebase=''; % root file name ('filebase'.civ) |
---|
[45] | 67 | %nom_type=[]; % nomenclature type |
---|
[2] | 68 | ext=[]; |
---|
| 69 | testall=0; |
---|
| 70 | browse=[]; |
---|
| 71 | |
---|
| 72 | %load the initial parameters if the interface is started from uvmat |
---|
| 73 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 74 | varcell=varargin{1}; |
---|
| 75 | filebase=varcell{1}; |
---|
| 76 | nom_type_read=varcell{2}; |
---|
| 77 | num1=varcell{3}; |
---|
| 78 | num2=varcell{4}; |
---|
| 79 | num_a=varcell{5}; |
---|
| 80 | num_b=varcell{6}; |
---|
| 81 | subdir=varcell{7}; |
---|
| 82 | ind_opening=varcell{8}; |
---|
| 83 | ext=varcell{11}; |
---|
| 84 | else |
---|
| 85 | num1=1; % set of field i numbers |
---|
| 86 | num2=2; % set of field i numbers |
---|
| 87 | num_a=1; % set of field j numbers (fields a) |
---|
| 88 | num_b=1; % second set of field j numbers (fields b) |
---|
| 89 | subdir='A'; % subdir for the netcdf result files |
---|
| 90 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 91 | end |
---|
| 92 | |
---|
[39] | 93 | if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext(2:end)))||... |
---|
| 94 | isequal(lower(ext),'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 95 | set(handles.ext_ima,'String',ext) |
---|
| 96 | if exist('nom_type_read','var') |
---|
| 97 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 98 | end |
---|
| 99 | elseif isequal(ext,'.nc') |
---|
| 100 | if exist('nom_type_read','var') |
---|
| 101 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 102 | end |
---|
| 103 | end |
---|
| 104 | set(handles.displ_filebase,'String',filebase); |
---|
| 105 | set(handles.ImaDoc,'UserData',testall); |
---|
| 106 | set(handles.ImaDoc,'String',ext) |
---|
| 107 | |
---|
| 108 | %read names of the .exe file to adjust the interface according to |
---|
| 109 | %available prog |
---|
| 110 | %read names of the .exe file |
---|
| 111 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 112 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 113 | errormsg=[];%default error message |
---|
[2] | 114 | if isunix |
---|
| 115 | syst='LINUX'; |
---|
| 116 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 117 | if exist(xmlfile,'file') |
---|
[45] | 118 | try |
---|
[2] | 119 | t=xmltree(xmlfile); |
---|
| 120 | sparam=convert(t); |
---|
[45] | 121 | catch |
---|
| 122 | errormsg={[' Problem for reading ' xmlfile]; lasterr}; |
---|
| 123 | end |
---|
| 124 | else |
---|
| 125 | erromsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[2] | 126 | end |
---|
| 127 | else |
---|
| 128 | syst='WIN'; |
---|
| 129 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 130 | if exist(xmlfile,'file') |
---|
[45] | 131 | try |
---|
[2] | 132 | t=xmltree(xmlfile); |
---|
| 133 | sparam=convert(t); |
---|
[45] | 134 | catch |
---|
| 135 | errormsg={[' Problem for reading ' xmlfile]; lasterr}; |
---|
| 136 | end |
---|
| 137 | else |
---|
| 138 | erromsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[2] | 139 | end |
---|
| 140 | end |
---|
[45] | 141 | display(syst) |
---|
| 142 | if ~isempty(errormsg) |
---|
| 143 | msgbox_uvmat('ERROR',errormsg); |
---|
| 144 | end |
---|
[2] | 145 | patch_new_exe=''; |
---|
| 146 | % todo_patch=''; |
---|
| 147 | sge=0; |
---|
| 148 | |
---|
| 149 | if isfield(sparam,'PatchNew_exe') |
---|
| 150 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 151 | end |
---|
| 152 | if isfield(sparam,'Todo_path') |
---|
| 153 | todo_path=sparam.Todo_path; |
---|
| 154 | end |
---|
| 155 | if isfield(sparam,'SGE') |
---|
| 156 | sge=str2num(sparam.SGE); |
---|
| 157 | end |
---|
| 158 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 159 | test_batch=1; |
---|
| 160 | if ~sge |
---|
[12] | 161 | if isequal(todo_path,'') || isequal(todo_path,[]) |
---|
| 162 | display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst]) |
---|
| 163 | test_batch=0; |
---|
| 164 | end |
---|
| 165 | if exist(name_todo,'file')~=2 |
---|
| 166 | msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']); |
---|
| 167 | % test_batch=0; % Problems to detect file on linux/nfs filesystems |
---|
| 168 | end |
---|
[2] | 169 | end |
---|
| 170 | if test_batch==0 |
---|
| 171 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 172 | end |
---|
| 173 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 174 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 175 | |
---|
| 176 | %initiate advised operations |
---|
| 177 | if isequal(ind_opening,[]) |
---|
| 178 | ind_opening=1; % default |
---|
| 179 | end |
---|
| 180 | % set default operation options |
---|
| 181 | enable_civ1(handles,'off') |
---|
| 182 | enable_civ2(handles,'off') |
---|
| 183 | enable_pair1(handles,'on') |
---|
| 184 | enable_fix1(handles,'off') |
---|
| 185 | desable_patch1(handles) |
---|
| 186 | desable_fix2(handles) |
---|
| 187 | desable_patch2(handles) |
---|
| 188 | set(handles.CIV1,'Value',0) |
---|
| 189 | set(handles.FIX1,'Value',0) |
---|
| 190 | set(handles.PATCH1,'Value',0) |
---|
| 191 | set(handles.CIV2,'Value',0) |
---|
| 192 | set(handles.FIX2,'Value',0) |
---|
| 193 | set(handles.PATCH2,'Value',0) |
---|
| 194 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 195 | if isequal(ind_opening,1) |
---|
| 196 | set(handles.CIV1,'Value',1) |
---|
| 197 | enable_civ1(handles,'on') |
---|
| 198 | elseif isequal(ind_opening,2) |
---|
| 199 | set(handles.FIX1,'Value',1) |
---|
| 200 | enable_fix1(handles,'on') |
---|
| 201 | elseif isequal(ind_opening,3) |
---|
| 202 | set(handles.PATCH1,'Value',1) |
---|
| 203 | enable_patch1(handles) |
---|
| 204 | elseif isequal(ind_opening,4) |
---|
| 205 | set(handles.CIV2,'Value',1) |
---|
| 206 | enable_civ2(handles,1) |
---|
| 207 | elseif isequal(ind_opening,5) |
---|
| 208 | set(handles.FIX2,'Value',1) |
---|
| 209 | enable_fix2(handles) |
---|
| 210 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 211 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 212 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 213 | enable_pair1(handles,'off') |
---|
| 214 | elseif isequal(ind_opening,6) |
---|
| 215 | set(handles.PATCH2,'Value',1) |
---|
| 216 | enable_patch2(handles) |
---|
| 217 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 218 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 219 | enable_pair1(handles,'off') |
---|
| 220 | end |
---|
| 221 | |
---|
| 222 | % set the range of fields (1:1 by default) and selected pair |
---|
[12] | 223 | if isempty(num2)||isequal(num2,num1) |
---|
[2] | 224 | num_ref_i=num1; |
---|
| 225 | else |
---|
| 226 | num_ref_i=floor((num1+num2)/2); |
---|
| 227 | browse.incr_pair(1)=num2-num1; |
---|
| 228 | browse.incr_pair(2)=0; |
---|
| 229 | end |
---|
[12] | 230 | if isempty(num_b)||isequal(num_a,num_b) |
---|
[2] | 231 | if isempty(num_a) |
---|
| 232 | num_ref_j=1; |
---|
| 233 | else |
---|
| 234 | num_ref_j=num_a; |
---|
| 235 | end |
---|
| 236 | else |
---|
| 237 | num_ref_j=floor((num_a+num_b)/2); |
---|
| 238 | browse.incr_pair(2)=num_b-num_a; |
---|
| 239 | end |
---|
| 240 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 241 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 242 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 243 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 244 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 245 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
| 246 | set(handles.browse_root,'UserData',browse); |
---|
| 247 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 248 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 249 | end |
---|
| 250 | |
---|
| 251 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 252 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 253 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 254 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 255 | |
---|
[12] | 256 | %------------------------------------------------------------------------ |
---|
[2] | 257 | % --- Outputs from this function are returned to the command line. |
---|
| 258 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 259 | %------------------------------------------------------------------------ |
---|
[2] | 260 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 261 | % hObject handle to figure |
---|
| 262 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 263 | % handles structure with handles and user data (see GUIDATA) |
---|
| 264 | % Get default command line output from handles structure |
---|
| 265 | varargout{1} = handles.output; |
---|
| 266 | |
---|
[12] | 267 | %------------------------------------------------------------------------ |
---|
[2] | 268 | % --- Executes on button press in browse_root. |
---|
| 269 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 270 | %------------------------------------------------------------------------ |
---|
[2] | 271 | %get the input file properties |
---|
| 272 | filebase=get(handles.displ_filebase,'String'); |
---|
| 273 | oldfile=''; %default |
---|
[39] | 274 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 275 | dir_perso=prefdir; |
---|
| 276 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 277 | display(profil_perso) |
---|
| 278 | if exist(profil_perso,'file') |
---|
| 279 | h=load (profil_perso); |
---|
| 280 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 281 | oldfile=h.filebase; |
---|
| 282 | end |
---|
| 283 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 284 | oldfile=h.RootPath; |
---|
| 285 | end |
---|
| 286 | end |
---|
| 287 | else |
---|
| 288 | oldfile=filebase; |
---|
| 289 | end |
---|
| 290 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 291 | ind_opening=1;%default |
---|
| 292 | browse.incr_pair=[0 0]; %default |
---|
| 293 | if testall |
---|
| 294 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 295 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 296 | else % menu selecting only .civ or .avi files |
---|
| 297 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 298 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 299 | '*.*', 'All Files (*.*)'}; |
---|
| 300 | end |
---|
| 301 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 302 | fileinput=[PathName FileName];%complete file name |
---|
| 303 | sizf=size(fileinput); |
---|
| 304 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 305 | [path,name,ext]=fileparts(fileinput); |
---|
| 306 | testeditxml=0; |
---|
| 307 | if isequal(ext,'.xml') |
---|
| 308 | testeditxml=1; |
---|
| 309 | t_browse=xmltree(fileinput); |
---|
| 310 | head_element=get(t_browse,1); |
---|
[45] | 311 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 312 | testeditxml=0; |
---|
| 313 | end |
---|
| 314 | end |
---|
[45] | 315 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[2] | 316 | heditxml=editxml({fileinput}); |
---|
| 317 | set(heditxml,'Tag','browser') |
---|
| 318 | waitfor(heditxml,'Tag','idle') |
---|
| 319 | if ~ishandle(heditxml) |
---|
| 320 | return |
---|
| 321 | end |
---|
| 322 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 323 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 324 | fileinput=get(attr,'UserData'); |
---|
| 325 | if ~exist(fileinput,'file') |
---|
| 326 | return |
---|
| 327 | end |
---|
| 328 | end |
---|
[45] | 329 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput) |
---|
[2] | 330 | filebase=fullfile(RootPath,RootFile); |
---|
[45] | 331 | if isequal(nom_type,'*')% all fields in a single file ( movie files) |
---|
| 332 | num_i1=1;num_i2=1;num_j1=1;num_j2=1; |
---|
| 333 | else |
---|
| 334 | num_i1=str2double(str1); |
---|
| 335 | num_i2=str2double(str2); |
---|
| 336 | num_j1=str2double(str_a); |
---|
| 337 | num_j2=str2double(str_b); |
---|
| 338 | end |
---|
[2] | 339 | if isequal(get(handles.compare,'Value'),1) |
---|
| 340 | browse=[];%initialisation |
---|
| 341 | else |
---|
| 342 | browse=get(handles.browse_root,'UserData'); |
---|
| 343 | end |
---|
[45] | 344 | if length(ext)>1 && (~isempty(imformats(ext([2:end])))||... |
---|
| 345 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
[2] | 346 | set(handles.ext_ima,'String',ext) |
---|
| 347 | browse.nom_type_ima=nom_type; |
---|
[45] | 348 | browse.field_count=num_i1; |
---|
| 349 | % A=imread(fileinput); |
---|
| 350 | % npxy=size(A); |
---|
| 351 | % set(handles.ext_ima,'UserData',npxy) |
---|
[2] | 352 | end |
---|
| 353 | set(handles.ImaDoc,'String',ext); |
---|
| 354 | |
---|
| 355 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 356 | if isequal(ext,'.nc') |
---|
| 357 | browse.nom_type_nc=nom_type; |
---|
| 358 | ind_opening=2;% propose 'fix' as the default option |
---|
| 359 | Data=nc2struct(fileinput,[]); |
---|
| 360 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
| 361 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 362 | ind_opening=3; |
---|
| 363 | end |
---|
| 364 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 365 | ind_opening=4; |
---|
| 366 | end |
---|
| 367 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 368 | ind_opening=5; |
---|
| 369 | end |
---|
| 370 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 371 | ind_opening=6; |
---|
| 372 | end |
---|
| 373 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 374 | else |
---|
| 375 | ind_opening=3; %GUI used only for patch |
---|
| 376 | testciv=0; |
---|
| 377 | end |
---|
| 378 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 379 | set(handles.subdir_civ2,'String',subdir); |
---|
| 380 | browse.testciv=testciv; |
---|
| 381 | browse.ind_opening=ind_opening; |
---|
| 382 | end |
---|
| 383 | set(handles.displ_filebase,'String',filebase); |
---|
| 384 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 385 | if ~isempty(num_i1) |
---|
| 386 | ref_i=num_i1; |
---|
| 387 | if ~isempty(num_i2) |
---|
| 388 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 389 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 390 | browse.incr_pair(2)=0; |
---|
| 391 | end |
---|
| 392 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 393 | set(handles.last_i,'String',num2str(ref_i)); |
---|
| 394 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 395 | end |
---|
[45] | 396 | if isempty(num_j1) |
---|
[2] | 397 | set(handles.ref_j,'String','1'); |
---|
| 398 | else |
---|
[45] | 399 | ref_j=num_j1; |
---|
| 400 | if ~isempty(num_j2) |
---|
| 401 | ref_j=floor((num_j1+num_j2)/2); |
---|
| 402 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 403 | end |
---|
| 404 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 405 | set(handles.last_j,'String',num2str(ref_j)); |
---|
| 406 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
| 407 | end |
---|
| 408 | |
---|
| 409 | % set default operation options |
---|
| 410 | enable_civ1(handles,'off') |
---|
| 411 | enable_civ2(handles,'off') |
---|
| 412 | enable_pair1(handles,'on') |
---|
| 413 | enable_fix1(handles,'off') |
---|
| 414 | desable_patch1(handles) |
---|
| 415 | desable_fix2(handles) |
---|
| 416 | desable_patch2(handles) |
---|
| 417 | set(handles.CIV1,'Value',0) |
---|
| 418 | set(handles.FIX1,'Value',0) |
---|
| 419 | set(handles.PATCH1,'Value',0) |
---|
| 420 | set(handles.CIV2,'Value',0) |
---|
| 421 | set(handles.FIX2,'Value',0) |
---|
| 422 | set(handles.PATCH2,'Value',0) |
---|
| 423 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 424 | if isequal(ind_opening,1) |
---|
| 425 | set(handles.CIV1,'Value',1) |
---|
| 426 | enable_civ1(handles,'on') |
---|
| 427 | elseif isequal(ind_opening,2) |
---|
| 428 | set(handles.FIX1,'Value',1) |
---|
| 429 | enable_fix1(handles,'on') |
---|
| 430 | elseif isequal(ind_opening,3) |
---|
| 431 | set(handles.PATCH1,'Value',1) |
---|
| 432 | enable_patch1(handles) |
---|
| 433 | elseif isequal(ind_opening,4) |
---|
| 434 | set(handles.CIV2,'Value',1) |
---|
| 435 | enable_civ2(handles,1) |
---|
| 436 | elseif isequal(ind_opening,5) |
---|
| 437 | enable_pair1(handles,'off') |
---|
| 438 | set(handles.FIX2,'Value',1) |
---|
| 439 | enable_fix2(handles) |
---|
| 440 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 441 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 442 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 443 | elseif isequal(ind_opening,6) |
---|
| 444 | enable_pair1(handles,'off') |
---|
| 445 | set(handles.PATCH2,'Value',1) |
---|
| 446 | enable_patch2(handles) |
---|
| 447 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 448 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 449 | end |
---|
| 450 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 451 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 452 | set(handles.ImaDoc,'UserData',testall); |
---|
| 453 | |
---|
| 454 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 455 | |
---|
[12] | 456 | %------------------------------------------------------------------------ |
---|
[2] | 457 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 458 | %------------------------------------------------------------------------ |
---|
[2] | 459 | displ_filebase_Callback(hObject, eventdata, handles) |
---|
| 460 | |
---|
[12] | 461 | %------------------------------------------------------------------------ |
---|
[2] | 462 | %function activated when a new filebase (image series) is introduced |
---|
| 463 | function displ_filebase_Callback(hObject, eventdata, handles) |
---|
[12] | 464 | %------------------------------------------------------------------------ |
---|
[2] | 465 | global test_batch |
---|
| 466 | set(handles.compare,'Visible','on') |
---|
| 467 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 468 | nom_type_ima=[];%default |
---|
| 469 | field_count=1;%default |
---|
| 470 | nom_type_nc=[]; |
---|
| 471 | time=[]; |
---|
| 472 | TimeUnit=[]; %default |
---|
| 473 | CoordUnit=[];%default |
---|
| 474 | pxcmx_search=[];%default |
---|
| 475 | pxcmy_search=[];%default |
---|
| 476 | filebase=get(handles.displ_filebase,'String'); |
---|
| 477 | |
---|
| 478 | ext=get(handles.ImaDoc,'String'); |
---|
| 479 | browse=get(handles.browse_root,'UserData');%default |
---|
| 480 | if ~isempty(browse) |
---|
| 481 | if isfield(browse,'nom_type_ima') |
---|
[12] | 482 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[2] | 483 | end |
---|
| 484 | if isfield(browse,'field_count') |
---|
[12] | 485 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
[2] | 486 | end |
---|
| 487 | end |
---|
| 488 | |
---|
| 489 | %default first_i and j and increments |
---|
| 490 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
[12] | 491 | if isempty(first_i)|| first_i < 1 |
---|
[2] | 492 | first_i=1; %default first_i |
---|
| 493 | end |
---|
| 494 | last_i=str2num(get(handles.last_i,'String')); |
---|
[12] | 495 | if isempty(last_i)|| last_i < first_i |
---|
[2] | 496 | last_i=first_i; %default last_i |
---|
| 497 | end |
---|
| 498 | first_j=str2num(get(handles.first_j,'String')); |
---|
[39] | 499 | if isempty(first_j)|| first_j < 1 |
---|
[2] | 500 | first_j=1; %default first_j |
---|
| 501 | end |
---|
| 502 | last_j=str2num(get(handles.last_j,'String')); |
---|
[39] | 503 | if isempty(last_j)|| last_j < first_j |
---|
[2] | 504 | last_j=first_j; %default last_j |
---|
| 505 | end |
---|
| 506 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
[39] | 507 | if isempty(incr_i) || incr_i < 1; |
---|
[2] | 508 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 509 | end |
---|
| 510 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
[39] | 511 | if isempty(incr_j) || incr_j < 1; |
---|
[2] | 512 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 513 | end |
---|
| 514 | dt=[];%default |
---|
| 515 | testmode=0;%default |
---|
| 516 | nbfield=[]; %default |
---|
| 517 | nburst=[];%default |
---|
| 518 | pxcmx=1; |
---|
| 519 | pxcmy=1; |
---|
| 520 | |
---|
| 521 | %look for an image documentation file |
---|
| 522 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
| 523 | if exist([filebase '.xml'],'file') |
---|
| 524 | ext='.xml'; |
---|
| 525 | elseif exist([filebase '.civxml'],'file') |
---|
| 526 | ext='.civxml'; |
---|
| 527 | elseif exist([filebase '.civ'],'file') |
---|
| 528 | ext='.civ'; |
---|
| 529 | elseif exist([filebase '.avi'],'file') |
---|
| 530 | ext='.avi'; |
---|
| 531 | elseif exist([filebase '.AVI'],'file') |
---|
| 532 | ext='.AVI'; |
---|
| 533 | end |
---|
| 534 | set(handles.ImaDoc,'String',ext) |
---|
| 535 | end |
---|
| 536 | |
---|
| 537 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 538 | mode=''; %default |
---|
| 539 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 540 | drawnow |
---|
| 541 | %read the image documentation file if found |
---|
[12] | 542 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
[2] | 543 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 544 | set(handles.ref_j,'Visible','On') |
---|
| 545 | set(handles.dt,'Visible','Off') |
---|
[12] | 546 | set(handles.dt_text,'String','') |
---|
| 547 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
[2] | 548 | set(handles.ref_j,'Visible','Off') |
---|
| 549 | set(handles.dt,'Visible','Off') |
---|
| 550 | set(handles.dt_text,'String','ref. ind.') |
---|
| 551 | else |
---|
| 552 | set(handles.ref_i,'Visible','Off') |
---|
| 553 | set(handles.ref_j,'Visible','Off') |
---|
| 554 | set(handles.dt,'Visible','On') |
---|
| 555 | set(handles.dt_text,'String','dt(ms)=') |
---|
| 556 | end |
---|
[12] | 557 | testima_xml=0; |
---|
[2] | 558 | if isequal(ext,'.civxml')%TO ABANDON |
---|
| 559 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
| 560 | mode='pair j1-j2'; |
---|
| 561 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
| 562 | nom_type_ima='_i_j'; |
---|
| 563 | end |
---|
| 564 | elseif isequal(ext,'.xml') |
---|
| 565 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
| 566 | if isfield(XmlData,'Time') |
---|
| 567 | time=XmlData.Time; |
---|
| 568 | nbfield=size(XmlData.Time,1); |
---|
| 569 | nburst=size(XmlData.Time,2); |
---|
| 570 | end |
---|
| 571 | ext_ima_read=[]; |
---|
| 572 | nom_type_read=[]; |
---|
[12] | 573 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 574 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[39] | 575 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 576 | if ~exist(fullname,'file') |
---|
| 577 | % testima_xml=1; |
---|
| 578 | % else |
---|
[12] | 579 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 580 | end |
---|
[2] | 581 | end |
---|
| 582 | if isfield(XmlData,'Camera') |
---|
| 583 | if isfield(XmlData.Camera,'TimeUnit') |
---|
| 584 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 585 | end |
---|
| 586 | if isfield(XmlData.Camera,'ImageSize') |
---|
| 587 | ImageSize=XmlData.Camera.ImageSize; |
---|
| 588 | if ~isempty(ImageSize)&& ~isempty(ImageSize) |
---|
| 589 | xindex=findstr(ImageSize,'x'); |
---|
[45] | 590 | % if length(xindex)>=2 |
---|
| 591 | % npx=str2num(ImageSize(1:xindex(1)-1)); |
---|
| 592 | % npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1)); |
---|
| 593 | % end |
---|
[2] | 594 | end |
---|
| 595 | end |
---|
| 596 | end |
---|
| 597 | pxcmx_search=1; |
---|
| 598 | pxcmy_search=1; |
---|
| 599 | if isfield(XmlData,'GeometryCalib') |
---|
| 600 | tsai=XmlData.GeometryCalib; |
---|
| 601 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
| 602 | rot2D=tsai.R([1:2],[1,2]); |
---|
| 603 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 604 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
| 605 | end |
---|
| 606 | if isfield(tsai,'CoordUnit') |
---|
| 607 | CoordUnit=tsai.CoordUnit; |
---|
| 608 | end |
---|
| 609 | end |
---|
| 610 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
| 611 | if isempty(ext_ima) |
---|
| 612 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
| 613 | else %keep the image extension |
---|
| 614 | if ~strcmp(ext_ima_read,ext_ima) |
---|
| 615 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
| 616 | end |
---|
| 617 | end |
---|
| 618 | nom_type_ima=nom_type_read; |
---|
| 619 | end |
---|
| 620 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
| 621 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
[12] | 622 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 623 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
[2] | 624 | end |
---|
| 625 | % ext_ima='.png'; |
---|
| 626 | nom_type_ima='png_old'; |
---|
| 627 | elseif isequal(lower(ext),'.avi') |
---|
| 628 | nom_type_ima='*'; |
---|
| 629 | ext_ima=ext; |
---|
| 630 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 631 | dt=0.04;%default |
---|
| 632 | if exist([filebase ext],'file')==2 |
---|
| 633 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
| 634 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 635 | nbfield=info.NumFrames;%number of frames |
---|
| 636 | end |
---|
| 637 | time=(dt*[0:nbfield-1])';%list of image times |
---|
| 638 | set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
| 639 | end |
---|
| 640 | if isempty(time) |
---|
| 641 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 642 | end |
---|
| 643 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 644 | |
---|
[12] | 645 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
| 646 | if isempty(nom_type_ima) |
---|
| 647 | %look for double image series '_i_j' |
---|
| 648 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 649 | if isempty(dirima) |
---|
| 650 | % look for images series with sub marker '_' |
---|
| 651 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 652 | if isempty(dirima) |
---|
| 653 | % look for other images series |
---|
| 654 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
| 655 | if ~isempty(dirima) |
---|
| 656 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 657 | end |
---|
| 658 | else |
---|
| 659 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 660 | end |
---|
| 661 | else |
---|
| 662 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 663 | end |
---|
| 664 | end |
---|
| 665 | |
---|
[2] | 666 | % no image documentation file found: look for a series of existing images or .nc files |
---|
| 667 | if isempty(time) && ~isequal(ext,'.nc') |
---|
[12] | 668 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 669 | incr_pair=[0 0];%default |
---|
| 670 | if isfield(browse,'incr_pair') |
---|
| 671 | incr_pair=browse.incr_pair; |
---|
| 672 | end |
---|
| 673 | nbdetect=0;%test of detected images |
---|
| 674 | field_i=field_count; |
---|
| 675 | idetect=1; |
---|
| 676 | while idetect==1 %look for the maximum file number in the series |
---|
| 677 | field_i=field_i+1; |
---|
| 678 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
| 679 | if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 680 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 681 | nbdetect=1; |
---|
| 682 | else |
---|
| 683 | idetect=(exist(imagename,'file')==2); |
---|
| 684 | end |
---|
| 685 | %SEE CASE OF NETCDF FILES |
---|
| 686 | nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 687 | end |
---|
| 688 | nb_field=field_i;% last detected field number |
---|
| 689 | field_i=field_count;%look for the minimum file number in the series |
---|
| 690 | idetect=1; |
---|
| 691 | while idetect==1 |
---|
| 692 | field_i=field_i-1; |
---|
[2] | 693 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
[12] | 694 | if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 695 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 696 | nbdetect=1; |
---|
[2] | 697 | else |
---|
| 698 | idetect=(exist(imagename,'file')==2); |
---|
| 699 | end |
---|
[12] | 700 | nbdetect=nbdetect+idetect; |
---|
| 701 | end |
---|
| 702 | first_i=max(field_i+1,1); |
---|
| 703 | %determine the set of times and possible intervals for CIV |
---|
| 704 | dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 705 | time=(dt*[0:nb_field-1])'; |
---|
| 706 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 707 | end |
---|
| 708 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
| 709 | first_i=1; |
---|
| 710 | last_i=1; |
---|
| 711 | first_j=1; |
---|
| 712 | last_j=1; |
---|
| 713 | end |
---|
| 714 | if exist('time','var') |
---|
| 715 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 716 | nbfield=size(time,1); |
---|
| 717 | nbfield2=size(time,2); |
---|
| 718 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 719 | if isempty(TimeUnit) |
---|
[12] | 720 | set(handles.dt_unit,'String','dt in e-03'); |
---|
[2] | 721 | set(handles.TimeUnit,'String',''); |
---|
| 722 | else |
---|
[12] | 723 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
[2] | 724 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 725 | end |
---|
| 726 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 727 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 728 | end |
---|
| 729 | end |
---|
| 730 | set(handles.CoordUnit,'String',[CoordUnit '/']) |
---|
| 731 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 732 | % npxy=[npy npx]; |
---|
| 733 | set(handles.ext_ima,'String',ext_ima) |
---|
| 734 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 735 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 736 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 737 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 738 | browse.nom_type_ima=nom_type_ima; |
---|
| 739 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 740 | |
---|
| 741 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[41] | 742 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 743 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 744 | set(handles.mode,'Value',1) |
---|
[41] | 745 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
[2] | 746 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
| 747 | set(handles.mode,'Value',1) |
---|
| 748 | elseif (nbfield==1)% simple series in j |
---|
| 749 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 750 | set(handles.mode,'Value',1) |
---|
| 751 | else |
---|
| 752 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[41] | 753 | if nbfield2 <= 5 |
---|
| 754 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 755 | end |
---|
[41] | 756 | % else |
---|
| 757 | % if isequal(mode,'volume') |
---|
| 758 | % set(handles.mode,'Value',3) |
---|
| 759 | % elseif nbfield2 <= 5 |
---|
| 760 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 761 | % else |
---|
| 762 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 763 | % end |
---|
[2] | 764 | end |
---|
| 765 | |
---|
| 766 | %update the subdir |
---|
| 767 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 768 | listot=dir(pathdir); |
---|
| 769 | idir=0; |
---|
| 770 | listdir={''};%default |
---|
| 771 | for ilist=1:length(listot) |
---|
| 772 | if listot(ilist).isdir |
---|
| 773 | name=listot(ilist).name; |
---|
| 774 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 775 | idir=idir+1; |
---|
| 776 | listdir{idir,1}=listot(ilist).name; |
---|
| 777 | end |
---|
| 778 | end |
---|
| 779 | end |
---|
| 780 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 781 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 782 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
| 783 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
| 784 | %check wether the current subdir exists: |
---|
| 785 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 786 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 787 | |
---|
| 788 | mode_Callback(hObject, eventdata, handles) |
---|
| 789 | |
---|
| 790 | %%%%%% initialize waitbars and RUN button |
---|
| 791 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 792 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 793 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 794 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 795 | set(handles.RUN, 'Enable','On') |
---|
| 796 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 797 | if isequal(test_batch,1)%if batch installation is available |
---|
| 798 | set(handles.BATCH, 'Enable','On') |
---|
| 799 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 800 | end |
---|
| 801 | |
---|
| 802 | %%%%% store the root input filename for future opening |
---|
| 803 | dir_perso=prefdir; |
---|
| 804 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 805 | RootPath=fileparts(filebase); |
---|
| 806 | if exist(profil_perso,'file') |
---|
| 807 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 808 | else |
---|
| 809 | txt=ver; |
---|
| 810 | Release=txt(1).Release; |
---|
| 811 | relnumb=str2num(Release(3:4)); |
---|
| 812 | if relnumb >= 14 |
---|
| 813 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 814 | else |
---|
| 815 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 816 | end |
---|
| 817 | end |
---|
| 818 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 819 | set(gcf,'Pointer','arrow') |
---|
| 820 | |
---|
[12] | 821 | %------------------------------------------------------------------------ |
---|
[2] | 822 | % --- Executes on button press in mode. |
---|
| 823 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 824 | %------------------------------------------------------------------------ |
---|
[2] | 825 | browse=get(handles.browse_root,'UserData'); |
---|
| 826 | compare_list=get(handles.compare,'String'); |
---|
| 827 | val=get(handles.compare,'Value'); |
---|
| 828 | compare=compare_list{val}; |
---|
| 829 | if strcmp(compare,'displacement') |
---|
| 830 | mode='displacement'; |
---|
| 831 | else |
---|
| 832 | mode_list=get(handles.mode,'String'); |
---|
| 833 | mode_value=get(handles.mode,'Value'); |
---|
| 834 | mode=mode_list{mode_value}; |
---|
| 835 | end |
---|
| 836 | displ_num=[];%default |
---|
| 837 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 838 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 839 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 840 | siztime=size(time); |
---|
| 841 | nbfield=siztime(1); |
---|
| 842 | nbfield2=siztime(2); |
---|
| 843 | indchosen=1; %%first pair selected by default |
---|
| 844 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 845 | dt=1; |
---|
| 846 | displ=''; |
---|
| 847 | index=0; |
---|
| 848 | numlist_a=[]; |
---|
| 849 | numlist_B=[]; |
---|
| 850 | %get all the time intervals in bursts |
---|
| 851 | displ_dt=1;%default |
---|
| 852 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 853 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 854 | for numod_b=(numod_a+1):nbfield2 |
---|
| 855 | index=index+1; |
---|
| 856 | numlist_a(index)=numod_a; |
---|
| 857 | numlist_b(index)=numod_b; |
---|
| 858 | if ~isempty(time) |
---|
| 859 | dt(numod_a,numod_b)=time(first_i,numod_b)-time(first_i,numod_a);%first time interval dt |
---|
| 860 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 861 | else |
---|
| 862 | displ_dt(index)=1; |
---|
| 863 | end |
---|
| 864 | end |
---|
| 865 | end |
---|
| 866 | [dtsort,indsort]=sort(displ_dt); |
---|
| 867 | if ~isempty(numlist_a) |
---|
| 868 | displ_num(1,:)=numlist_a(indsort); |
---|
| 869 | displ_num(2,:)=numlist_b(indsort); |
---|
| 870 | end |
---|
| 871 | displ_num(3,:)=0; |
---|
| 872 | displ_num(4,:)=0; |
---|
| 873 | set(handles.jtext,'Visible','Off') |
---|
| 874 | set(handles.first_j,'Visible','Off') |
---|
| 875 | set(handles.last_j,'Visible','Off') |
---|
| 876 | set(handles.incr_j,'Visible','Off') |
---|
| 877 | set(handles.nb_field2,'Visible','Off') |
---|
| 878 | set(handles.ref_j,'Visible','Off') |
---|
| 879 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 880 | for index=1:min(nbfield2-1,200) |
---|
| 881 | displ_num(1,index)=-floor(index/2); |
---|
| 882 | displ_num(2,index)=ceil(index/2); |
---|
| 883 | displ_num(3,index)=0; |
---|
| 884 | displ_num(4,index)=0; |
---|
| 885 | end |
---|
| 886 | set(handles.jtext,'Visible','On') |
---|
| 887 | set(handles.first_j,'Visible','On') |
---|
| 888 | set(handles.last_j,'Visible','On') |
---|
| 889 | set(handles.incr_j,'Visible','On') |
---|
| 890 | set(handles.nb_field2,'Visible','On') |
---|
| 891 | set(handles.ref_j,'Visible','On') |
---|
| 892 | if nbfield > 1 |
---|
| 893 | set(handles.itext,'Visible','On') |
---|
| 894 | set(handles.first_i,'Visible','On') |
---|
| 895 | set(handles.last_i,'Visible','On') |
---|
| 896 | set(handles.incr_i,'Visible','On') |
---|
| 897 | set(handles.nb_field,'Visible','On') |
---|
| 898 | set(handles.ref_i,'Visible','On') |
---|
| 899 | else |
---|
| 900 | set(handles.itext,'Visible','Off') |
---|
| 901 | set(handles.first_i,'Visible','Off') |
---|
| 902 | set(handles.last_i,'Visible','Off') |
---|
| 903 | set(handles.incr_i,'Visible','Off') |
---|
| 904 | set(handles.nb_field,'Visible','Off') |
---|
| 905 | set(handles.ref_i,'Visible','Off') |
---|
| 906 | end |
---|
| 907 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 908 | for index=1:200%min(nbfield-1,200) |
---|
| 909 | displ_num(1,index)=0; |
---|
| 910 | displ_num(2,index)=0; |
---|
| 911 | displ_num(3,index)=-floor(index/2); |
---|
| 912 | displ_num(4,index)=ceil(index/2); |
---|
| 913 | end |
---|
| 914 | set(handles.itext,'Visible','On') |
---|
| 915 | set(handles.first_i,'Visible','On') |
---|
| 916 | set(handles.last_i,'Visible','On') |
---|
| 917 | set(handles.incr_i,'Visible','On') |
---|
| 918 | set(handles.nb_field,'Visible','On') |
---|
| 919 | set(handles.ref_i,'Visible','On') |
---|
| 920 | if nbfield2 > 1 |
---|
| 921 | set(handles.jtext,'Visible','On') |
---|
| 922 | set(handles.first_j,'Visible','On') |
---|
| 923 | set(handles.last_j,'Visible','On') |
---|
| 924 | set(handles.incr_j,'Visible','On') |
---|
| 925 | set(handles.nb_field2,'Visible','On') |
---|
| 926 | set(handles.ref_j,'Visible','On') |
---|
| 927 | else |
---|
| 928 | set(handles.jtext,'Visible','Off') |
---|
| 929 | set(handles.first_j,'Visible','Off') |
---|
| 930 | set(handles.last_j,'Visible','Off') |
---|
| 931 | set(handles.incr_j,'Visible','Off') |
---|
| 932 | set(handles.nb_field2,'Visible','Off') |
---|
| 933 | set(handles.ref_j,'Visible','Off') |
---|
| 934 | end |
---|
| 935 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 936 | displ_num(1,1)=0; |
---|
| 937 | displ_num(2,1)=0; |
---|
| 938 | displ_num(3,1)=0; |
---|
| 939 | displ_num(4,1)=0; |
---|
| 940 | if nbfield > 1 |
---|
| 941 | set(handles.itext,'Visible','On') |
---|
| 942 | set(handles.first_i,'Visible','On') |
---|
| 943 | set(handles.last_i,'Visible','On') |
---|
| 944 | set(handles.incr_i,'Visible','On') |
---|
| 945 | set(handles.nb_field,'Visible','On') |
---|
| 946 | set(handles.ref_i,'Visible','On') |
---|
| 947 | else |
---|
| 948 | set(handles.itext,'Visible','Off') |
---|
| 949 | set(handles.first_i,'Visible','Off') |
---|
| 950 | set(handles.last_i,'Visible','Off') |
---|
| 951 | set(handles.incr_i,'Visible','Off') |
---|
| 952 | set(handles.nb_field,'Visible','Off') |
---|
| 953 | set(handles.ref_i,'Visible','Off') |
---|
| 954 | end |
---|
| 955 | if nbfield2 > 1 |
---|
| 956 | set(handles.jtext,'Visible','On') |
---|
| 957 | set(handles.first_j,'Visible','On') |
---|
| 958 | set(handles.last_j,'Visible','On') |
---|
| 959 | set(handles.incr_j,'Visible','On') |
---|
| 960 | set(handles.nb_field2,'Visible','On') |
---|
| 961 | set(handles.ref_j,'Visible','On') |
---|
| 962 | else |
---|
| 963 | set(handles.jtext,'Visible','Off') |
---|
| 964 | set(handles.first_j,'Visible','Off') |
---|
| 965 | set(handles.last_j,'Visible','Off') |
---|
| 966 | set(handles.incr_j,'Visible','Off') |
---|
| 967 | set(handles.nb_field2,'Visible','Off') |
---|
| 968 | set(handles.ref_j,'Visible','Off') |
---|
| 969 | end |
---|
| 970 | end |
---|
| 971 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 972 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 973 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 974 | |
---|
[12] | 975 | %------------------------------------------------------------------------ |
---|
[2] | 976 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 977 | % the field series set by first_i, incr, last_i |
---|
| 978 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 979 | %------------------------------------------------------------------------ |
---|
[2] | 980 | set(gcf,'Pointer','watch') |
---|
| 981 | %nomenclature types |
---|
| 982 | filebase=get(handles.displ_filebase,'String'); |
---|
| 983 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 984 | browse=get(handles.browse_root,'UserData'); |
---|
| 985 | compare_list=get(handles.compare,'String'); |
---|
| 986 | val=get(handles.compare,'Value'); |
---|
| 987 | compare=compare_list{val}; |
---|
| 988 | if strcmp(compare,'displacement') |
---|
| 989 | mode='displacement'; |
---|
| 990 | else |
---|
| 991 | mode_list=get(handles.mode,'String'); |
---|
| 992 | mode_value=get(handles.mode,'Value'); |
---|
| 993 | mode=mode_list{mode_value}; |
---|
| 994 | end |
---|
| 995 | |
---|
| 996 | % nomenclature type of the .nc files |
---|
| 997 | nom_type_ima=[];%default |
---|
| 998 | if isfield(browse,'nom_type_ima') |
---|
| 999 | nom_type_ima=browse.nom_type_ima; |
---|
| 1000 | end |
---|
| 1001 | |
---|
| 1002 | %determine nom_type_nc: |
---|
| 1003 | nom_type_nc=[];%default |
---|
| 1004 | if isfield(browse,'nom_type_nc') |
---|
| 1005 | nom_type_nc=browse.nom_type_nc; |
---|
| 1006 | end |
---|
| 1007 | if isempty(nom_type_nc) |
---|
| 1008 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
| 1009 | end |
---|
| 1010 | browse.nom_type_nc=nom_type_nc; |
---|
| 1011 | set(handles.browse_root,'UserData',browse) |
---|
| 1012 | |
---|
| 1013 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 1014 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 1015 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1016 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1017 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1018 | % num1=first_i:incr:last_i; |
---|
| 1019 | % if isempty(num1) |
---|
| 1020 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1021 | % return |
---|
| 1022 | % end |
---|
| 1023 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1024 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1025 | ref_j=0; |
---|
| 1026 | else |
---|
[45] | 1027 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1028 | end |
---|
| 1029 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
| 1030 | if isempty(time) |
---|
| 1031 | time=[0 1]; |
---|
| 1032 | end |
---|
[45] | 1033 | dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[2] | 1034 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1035 | |
---|
| 1036 | %eliminate the first pairs inconsistent with the position |
---|
| 1037 | if isempty(displ_num) |
---|
| 1038 | nbpair=0; |
---|
| 1039 | else |
---|
| 1040 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1041 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1042 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1043 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1044 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1045 | end |
---|
| 1046 | end |
---|
| 1047 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1048 | |
---|
| 1049 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1050 | % be performed, while the result is needed for next steps. |
---|
| 1051 | displ_pair={''}; |
---|
| 1052 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1053 | testpair=0; |
---|
| 1054 | if get(handles.CIV1,'Value')==0 % |
---|
| 1055 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1056 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1057 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1058 | return |
---|
| 1059 | end |
---|
| 1060 | for ipair=1:nbpair |
---|
| 1061 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1062 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1063 | select(ipair)=exist(filename,'file')==2; |
---|
| 1064 | end |
---|
| 1065 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
| 1066 | if isfield(browse,'incr_pair') |
---|
| 1067 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1068 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1069 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1070 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1071 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1072 | select(1)=exist(filename,'file')==2; |
---|
| 1073 | testpair=1; |
---|
| 1074 | else |
---|
| 1075 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1076 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1077 | else |
---|
| 1078 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1079 | end |
---|
| 1080 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1081 | %COMPLETER CAS STEREO |
---|
| 1082 | return |
---|
| 1083 | end |
---|
| 1084 | end |
---|
| 1085 | end |
---|
| 1086 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1087 | if testpair |
---|
| 1088 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1089 | elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1090 | for ipair=1:nbpair |
---|
| 1091 | if select(ipair) |
---|
| 1092 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1093 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1094 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1095 | end |
---|
| 1096 | else |
---|
| 1097 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1098 | end |
---|
| 1099 | end |
---|
| 1100 | else |
---|
| 1101 | for ipair=1:nbpair |
---|
| 1102 | if select(ipair) |
---|
| 1103 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
| 1104 | else |
---|
| 1105 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1106 | end |
---|
| 1107 | end |
---|
| 1108 | end |
---|
| 1109 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1110 | if testpair |
---|
| 1111 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1112 | else |
---|
| 1113 | for ipair=1:nbpair |
---|
| 1114 | if select(ipair) |
---|
| 1115 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1116 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1117 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1118 | end |
---|
| 1119 | elseif testpair |
---|
| 1120 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1121 | else |
---|
| 1122 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1123 | end |
---|
| 1124 | end |
---|
| 1125 | end |
---|
| 1126 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1127 | for ipair=1:nbpair |
---|
| 1128 | if select(ipair) |
---|
| 1129 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
| 1130 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1131 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1132 | else |
---|
| 1133 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1134 | end |
---|
| 1135 | end |
---|
| 1136 | elseif isequal(mode,'displacement') |
---|
| 1137 | displ_pair={'Di=Dj=0'}; |
---|
| 1138 | end |
---|
| 1139 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1140 | ichoice=min(find(select)); |
---|
[45] | 1141 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1142 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
| 1143 | if initial>nbpair |
---|
| 1144 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1145 | end |
---|
| 1146 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1147 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1148 | end |
---|
[45] | 1149 | |
---|
[2] | 1150 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1151 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1152 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1153 | if ichoice <= length(displ_pair') |
---|
| 1154 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1155 | else |
---|
| 1156 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1157 | end |
---|
| 1158 | end |
---|
| 1159 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1160 | set(gcf,'Pointer','arrow') |
---|
[12] | 1161 | |
---|
| 1162 | %------------------------------------------------------------------------ |
---|
[2] | 1163 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1164 | %middle of the series set by first_i, incr, last_i |
---|
| 1165 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1166 | %------------------------------------------------------------------------ |
---|
[2] | 1167 | set(gcf,'Pointer','watch') |
---|
| 1168 | %nomenclature types |
---|
| 1169 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1170 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1171 | browse=get(handles.browse_root,'UserData'); |
---|
| 1172 | compare_list=get(handles.compare,'String'); |
---|
| 1173 | val=get(handles.compare,'Value'); |
---|
| 1174 | compare=compare_list{val}; |
---|
| 1175 | if strcmp(compare,'displacement') |
---|
| 1176 | mode='displacement'; |
---|
| 1177 | else |
---|
| 1178 | mode_list=get(handles.mode,'String'); |
---|
| 1179 | mode_value=get(handles.mode,'Value'); |
---|
| 1180 | mode=mode_list{mode_value}; |
---|
| 1181 | end |
---|
| 1182 | |
---|
| 1183 | % nomenclature type of the .nc files |
---|
| 1184 | nom_type_ima='ima_num';%default |
---|
| 1185 | if isfield(browse,'nom_type_ima') |
---|
| 1186 | nom_type_ima=browse.nom_type_ima; |
---|
| 1187 | end |
---|
| 1188 | nom_type_nc='_i1-i2';%default |
---|
| 1189 | if isfield(browse,'nom_type_nc') |
---|
| 1190 | nom_type_nc=browse.nom_type_nc; |
---|
| 1191 | end |
---|
| 1192 | if isequal(nom_type_ima,'png_old') | isequal(nom_type_ima,'netc_old')| isequal(nom_type_ima,'raw_SMD')| isequal(nom_type_nc,'netc_old') |
---|
| 1193 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 1194 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 1195 | nom_type_nc='none'; |
---|
| 1196 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
| 1197 | nom_type_nc='_i1-i2'; |
---|
| 1198 | else |
---|
| 1199 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1200 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1201 | else |
---|
| 1202 | nom_type_nc='_i_j1-j2'; |
---|
| 1203 | end |
---|
| 1204 | end |
---|
| 1205 | browse.nom_type_nc=nom_type_nc; |
---|
| 1206 | set(handles.browse_root,'UserData',browse) |
---|
| 1207 | |
---|
| 1208 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1209 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1210 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1211 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1212 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1213 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1214 | % num1=first_i:incr:last_i; |
---|
| 1215 | % if isempty(num1) |
---|
| 1216 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1217 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1218 | % return |
---|
| 1219 | % end |
---|
[2] | 1220 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1221 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1222 | ref_j=0; |
---|
| 1223 | else |
---|
| 1224 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1225 | end |
---|
| 1226 | if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval |
---|
| 1227 | ref_i=ceil((first_i+last_i)/2); |
---|
| 1228 | ref_j=1; |
---|
| 1229 | end |
---|
| 1230 | % ref_i=browse.num_ref;%field number initially selected by the browser |
---|
| 1231 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1232 | if isempty(time) |
---|
| 1233 | time=[0 1];%default |
---|
| 1234 | end |
---|
| 1235 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1236 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1237 | |
---|
| 1238 | |
---|
| 1239 | %eliminate the first pairs inconsistent with the position |
---|
| 1240 | if isempty(displ_num) |
---|
| 1241 | nbpair=0; |
---|
| 1242 | else |
---|
| 1243 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1244 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
| 1245 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1246 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1247 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1248 | end |
---|
| 1249 | end |
---|
| 1250 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1251 | |
---|
| 1252 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1253 | % be performed, while the result is needed for next steps. |
---|
| 1254 | displ_pair={''}; %default |
---|
| 1255 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1256 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1257 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1258 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1259 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1260 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1261 | return |
---|
| 1262 | end |
---|
| 1263 | for ipair=1:nbpair |
---|
| 1264 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1265 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1266 | select(ipair)=exist(filename,'file')==2; |
---|
| 1267 | end |
---|
| 1268 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1269 | if isfield(browse,'incr_pair') |
---|
| 1270 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1271 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1272 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1273 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1274 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1275 | select(1)=exist(filename,'file')==2; |
---|
| 1276 | else |
---|
| 1277 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1278 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1279 | else |
---|
| 1280 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1281 | end |
---|
| 1282 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1283 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1284 | return |
---|
| 1285 | end |
---|
| 1286 | end |
---|
| 1287 | end |
---|
| 1288 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1289 | % if ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1290 | for ipair=1:nbpair |
---|
| 1291 | if select(ipair) |
---|
| 1292 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1293 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1294 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1295 | end |
---|
| 1296 | else |
---|
| 1297 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1298 | end |
---|
| 1299 | end |
---|
| 1300 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1301 | for ipair=1:nbpair |
---|
| 1302 | if select(ipair) |
---|
| 1303 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1304 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1305 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1306 | end |
---|
| 1307 | else |
---|
| 1308 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1309 | end |
---|
| 1310 | end |
---|
| 1311 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1312 | for ipair=1:nbpair |
---|
| 1313 | if select(ipair) |
---|
| 1314 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
| 1315 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1316 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1317 | else |
---|
| 1318 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1319 | end |
---|
| 1320 | end |
---|
| 1321 | elseif isequal(mode,'displacement') |
---|
| 1322 | displ_pair={'Di=Dj=0'}; |
---|
| 1323 | end |
---|
| 1324 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1325 | ichoice=min(find(select)); |
---|
| 1326 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1327 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1328 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1329 | end |
---|
| 1330 | if val>length(displ_pair') |
---|
| 1331 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1332 | else |
---|
| 1333 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1334 | end |
---|
| 1335 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1336 | set(gcf,'Pointer','arrow') |
---|
[2] | 1337 | |
---|
[12] | 1338 | %------------------------------------------------------------------------ |
---|
[2] | 1339 | % determine the list of index pairs of processing file |
---|
| 1340 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1341 | find_pair_indices(handles,mode) |
---|
[12] | 1342 | %------------------------------------------------------------------------ |
---|
[45] | 1343 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1344 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1345 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
[39] | 1346 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
[2] | 1347 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
[45] | 1348 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1349 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1350 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
[2] | 1351 | else |
---|
| 1352 | first_j=1; |
---|
| 1353 | last_j=1; |
---|
| 1354 | incr_j=1; |
---|
| 1355 | end |
---|
[36] | 1356 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
[2] | 1357 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1358 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
[36] | 1359 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
[2] | 1360 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1361 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1362 | return |
---|
| 1363 | end |
---|
| 1364 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1365 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1366 | if index_civ2>length(list_civ2) |
---|
| 1367 | list_civ2=list_civ1; |
---|
| 1368 | index_civ2=index_civ1; |
---|
| 1369 | end |
---|
[36] | 1370 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 1371 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
| 1372 | return,end; |
---|
[39] | 1373 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[36] | 1374 | return,end; |
---|
[39] | 1375 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[36] | 1376 | return,end; |
---|
[39] | 1377 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[36] | 1378 | return,end; |
---|
| 1379 | if isequal (mode,'series(Di)') |
---|
[2] | 1380 | %recognize the pair civ1 from the display |
---|
| 1381 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1382 | str_raw=str_civ1(indsel); |
---|
| 1383 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
[45] | 1384 | d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
[2] | 1385 | if indsepar==length(str_raw) |
---|
[45] | 1386 | d2=str2double(str_civ1([indsel(indsepar)+1:end])); |
---|
[2] | 1387 | else |
---|
[45] | 1388 | d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
[2] | 1389 | end |
---|
[39] | 1390 | num1_civ1=num_i-d1;% set of first image numbers |
---|
| 1391 | num2_civ1=num_i+d2; |
---|
[2] | 1392 | num_a_civ1=num_j; |
---|
| 1393 | num_b_civ1=num_j; |
---|
| 1394 | |
---|
| 1395 | %recognize the pair civ2 from the display |
---|
| 1396 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1397 | str_raw=str_civ2(indsel); |
---|
| 1398 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1399 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1400 | if indsepar==length(str_raw) |
---|
| 1401 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
| 1402 | else |
---|
| 1403 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1404 | end |
---|
| 1405 | if isempty(d1) |
---|
[39] | 1406 | num1_civ2=num_i; |
---|
[2] | 1407 | else |
---|
[39] | 1408 | num1_civ2=num_i-d1;% set of first image numbers |
---|
[2] | 1409 | end |
---|
| 1410 | if isempty(d2) |
---|
[39] | 1411 | num2_civ2=num_i; |
---|
[2] | 1412 | else |
---|
[39] | 1413 | num2_civ2=num_i+d2; |
---|
[2] | 1414 | end |
---|
| 1415 | num_a_civ2=num_j; |
---|
| 1416 | num_b_civ2=num_j; |
---|
| 1417 | |
---|
| 1418 | % adjust the first and last field number |
---|
| 1419 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1420 | if isequal(lastfield,[]) |
---|
| 1421 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1422 | else |
---|
| 1423 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1424 | end |
---|
| 1425 | if length(indsel)>=1 |
---|
| 1426 | firstind=indsel(1); |
---|
| 1427 | lastind=indsel(end); |
---|
[39] | 1428 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
| 1429 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
| 1430 | num_i=num_i(indsel); |
---|
[2] | 1431 | num1_civ1=num1_civ1(indsel); |
---|
| 1432 | num1_civ2=num1_civ2(indsel); |
---|
| 1433 | num2_civ1=num2_civ1(indsel); |
---|
| 1434 | num2_civ2=num2_civ2(indsel); |
---|
| 1435 | end |
---|
[36] | 1436 | elseif isequal (mode,'series(Dj)') |
---|
[2] | 1437 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
[39] | 1438 | num1_civ1=num_i;% set of first image numbers |
---|
| 1439 | num2_civ1=num_i; |
---|
[2] | 1440 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1441 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
[39] | 1442 | num1_civ2=num_i; |
---|
| 1443 | num2_civ2=num_i; |
---|
[2] | 1444 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1445 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1446 | % adjust the first and last field number |
---|
| 1447 | if isequal(lastfield_j,[]) |
---|
| 1448 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1449 | else |
---|
| 1450 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1451 | end |
---|
| 1452 | if length(indsel)>=1 |
---|
| 1453 | firstind=indsel(1); |
---|
| 1454 | lastind=indsel(end); |
---|
| 1455 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1456 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1457 | num_j=num_j(indsel); |
---|
| 1458 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1459 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1460 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1461 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1462 | end |
---|
[36] | 1463 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[39] | 1464 | num1_civ1=num_i; |
---|
| 1465 | num1_civ2=num_i; |
---|
[2] | 1466 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[39] | 1467 | num2_civ1=num_i; |
---|
[2] | 1468 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1469 | num_b_civ1=displ_num(2,index_civ1); |
---|
[39] | 1470 | num2_civ2=num_i; |
---|
[2] | 1471 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1472 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1473 | elseif isequal(mode,'displacement') |
---|
[39] | 1474 | num1_civ1=num_i; |
---|
| 1475 | num2_civ1=num_i; |
---|
[2] | 1476 | num_a_civ1=num_j; |
---|
| 1477 | num_b_civ1=num_j; |
---|
[39] | 1478 | num1_civ2=num_i; |
---|
| 1479 | num2_civ2=num_i; |
---|
[2] | 1480 | num_a_civ2=num_j; |
---|
| 1481 | num_b_civ2=num_j; |
---|
| 1482 | end |
---|
| 1483 | |
---|
[41] | 1484 | |
---|
[12] | 1485 | %------------------------------------------------------------------------ |
---|
[2] | 1486 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1487 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1488 | %------------------------------------------------------------------------ |
---|
[2] | 1489 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1490 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1491 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1492 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1493 | num_a=displ_num(1,index_pair); |
---|
| 1494 | num_b=displ_num(2,index_pair); |
---|
| 1495 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1496 | if index_pair<=length(list_pair2) |
---|
| 1497 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1498 | end |
---|
| 1499 | |
---|
| 1500 | %update first_i and last_i according to the chosen image pairs |
---|
| 1501 | mode_list=get(handles.mode,'String'); |
---|
| 1502 | mode_value=get(handles.mode,'Value'); |
---|
| 1503 | mode=mode_list{mode_value}; |
---|
| 1504 | if isequal(mode,'series(Di)') |
---|
| 1505 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1506 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1507 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1508 | num1=first_i:incr_i:last_i; |
---|
| 1509 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1510 | if ~isequal(lastfield,[]) |
---|
| 1511 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1512 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1513 | num1=num1(ind); |
---|
| 1514 | end |
---|
| 1515 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1516 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1517 | elseif isequal(mode,'series(Dj)') |
---|
| 1518 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1519 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1520 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1521 | num_j=first_j:incr_j:last_j; |
---|
| 1522 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1523 | if ~isequal(lastfield2,[]) |
---|
| 1524 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1525 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1526 | num1=num_j(ind); |
---|
| 1527 | end |
---|
| 1528 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1529 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1530 | end |
---|
| 1531 | |
---|
[12] | 1532 | %------------------------------------------------------------------------ |
---|
[2] | 1533 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1534 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1535 | %------------------------------------------------------------------------ |
---|
[2] | 1536 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1537 | |
---|
| 1538 | %update first_i and last_i according to the chosen image pairs |
---|
| 1539 | mode_list=get(handles.mode,'String'); |
---|
| 1540 | mode_value=get(handles.mode,'Value'); |
---|
| 1541 | mode=mode_list{mode_value}; |
---|
| 1542 | if isequal(mode,'series(Di)') |
---|
| 1543 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1544 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1545 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1546 | num1=first_i:incr_i:last_i; |
---|
| 1547 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1548 | if ~isequal(lastfield,[]) |
---|
| 1549 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1550 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1551 | num1=num1(ind); |
---|
| 1552 | end |
---|
| 1553 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1554 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1555 | elseif isequal(mode,'series(Dj)') |
---|
| 1556 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1557 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1558 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1559 | num_j=first_j:incr_j:last_j; |
---|
| 1560 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1561 | if ~isequal(lastfield2,[]) |
---|
| 1562 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1563 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1564 | num1=num_j(ind); |
---|
| 1565 | end |
---|
| 1566 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1567 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1568 | end |
---|
| 1569 | |
---|
[12] | 1570 | %------------------------------------------------------------------------ |
---|
[2] | 1571 | % --- Executes on button press in RUN. |
---|
| 1572 | function RUN_Callback(hObject, eventdata, handles) |
---|
[12] | 1573 | %------------------------------------------------------------------------ |
---|
[2] | 1574 | global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
| 1575 | |
---|
| 1576 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1577 | %check the list of operations: |
---|
| 1578 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1579 | run_flag=1; |
---|
| 1580 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1581 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1582 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1583 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1584 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1585 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1586 | index=find(box_test==1); |
---|
| 1587 | if isempty(index) |
---|
| 1588 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 1589 | return |
---|
| 1590 | end |
---|
| 1591 | index_first=min(index); |
---|
| 1592 | index_last=max(index); |
---|
| 1593 | box_used=box_test([index_first : index_last]); |
---|
| 1594 | [box_missing,ind_missing]=min(box_used); |
---|
| 1595 | if isequal(box_missing,0) |
---|
| 1596 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1597 | return |
---|
| 1598 | end |
---|
| 1599 | |
---|
| 1600 | %root name |
---|
| 1601 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1602 | if isempty(filebase)||isequal(filebase,'') |
---|
| 1603 | msgbox_uvmat('ERROR','no input files') |
---|
| 1604 | return |
---|
| 1605 | end |
---|
| 1606 | %check mask if selecetd |
---|
| 1607 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1608 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1609 | if ~exist(maskname,'file') |
---|
| 1610 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1611 | end |
---|
[2] | 1612 | end |
---|
| 1613 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1614 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1615 | if ~exist(maskname,'file') |
---|
[2] | 1616 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
[12] | 1617 | end |
---|
[2] | 1618 | end |
---|
| 1619 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1620 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1621 | if ~exist(maskname,'file') |
---|
[2] | 1622 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1623 | end |
---|
[2] | 1624 | end |
---|
| 1625 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1626 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1627 | if ~exist(maskname,'file') |
---|
[2] | 1628 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1629 | end |
---|
[2] | 1630 | end |
---|
| 1631 | |
---|
| 1632 | %read names of the .exe file |
---|
[45] | 1633 | if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 |
---|
[2] | 1634 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1635 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 1636 | if isunix |
---|
| 1637 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 1638 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 1639 | if exist(xmlfile,'file') |
---|
| 1640 | t=xmltree(xmlfile); |
---|
| 1641 | sparam=convert(t); |
---|
| 1642 | end |
---|
| 1643 | else |
---|
| 1644 | %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names |
---|
| 1645 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 1646 | if exist(xmlfile,'file') |
---|
| 1647 | t=xmltree(xmlfile); |
---|
| 1648 | sparam=convert(t); |
---|
| 1649 | end |
---|
| 1650 | end |
---|
| 1651 | if isfield(sparam,'Civ1_exe') |
---|
| 1652 | civ1_exe=sparam.Civ1_exe; |
---|
[45] | 1653 | if isequal(civ1_exe(1:4),'civx')%the binary is defined in /civx, default setting |
---|
| 1654 | civ1_exe=fullfile(path_UVMAT,civ1_exe); |
---|
| 1655 | end |
---|
[2] | 1656 | end |
---|
| 1657 | if isfield(sparam,'Civ2_exe') |
---|
| 1658 | civ2_exe=sparam.Civ2_exe; |
---|
[45] | 1659 | if isequal(civ2_exe(1:4),'civx')%the binary is defined in /civx, default setting |
---|
| 1660 | civ2_exe=fullfile(path_UVMAT,civ2_exe); |
---|
| 1661 | end |
---|
[2] | 1662 | end |
---|
| 1663 | if isfield(sparam,'Patch_exe') |
---|
| 1664 | patch_exe=sparam.Patch_exe; |
---|
[45] | 1665 | if isequal(patch_exe(1:4),'civx')%the binary is defined in /civx, default setting |
---|
| 1666 | patch_exe=fullfile(path_UVMAT,patch_exe); |
---|
| 1667 | end |
---|
[2] | 1668 | end |
---|
| 1669 | if isfield(sparam,'Stinterp_exe') |
---|
| 1670 | stinterp_exe=sparam.Stinterp_exe; |
---|
| 1671 | end |
---|
| 1672 | if isfield(sparam,'SGE') |
---|
[45] | 1673 | sge=str2double(sparam.SGE); |
---|
[2] | 1674 | end |
---|
| 1675 | if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
| 1676 | dircur=pwd; |
---|
| 1677 | if ~isequal(dircur([2 3]),':\') |
---|
| 1678 | msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
| 1679 | return; |
---|
| 1680 | end |
---|
| 1681 | end |
---|
| 1682 | end |
---|
| 1683 | |
---|
| 1684 | %initialize the waitbars |
---|
| 1685 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 1686 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 1687 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 1688 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 1689 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1690 | set(handles.RUN, 'Enable','Off') |
---|
| 1691 | drawnow |
---|
| 1692 | |
---|
| 1693 | % get the list of file names and check the files |
---|
| 1694 | display('checking the files...') |
---|
| 1695 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... |
---|
| 1696 | set_civ_filenames(handles,compare,box_test); |
---|
[41] | 1697 | nbfield=numel(num1_civ1); |
---|
| 1698 | nbslice=size(num_a_civ1); |
---|
[36] | 1699 | |
---|
[12] | 1700 | if isempty(filecell) |
---|
| 1701 | set(handles.RUN, 'Enable','On') |
---|
| 1702 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1703 | set(handles.BATCH, 'Enable','On') |
---|
| 1704 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1705 | return |
---|
| 1706 | end |
---|
[2] | 1707 | display('files OK, processing...') |
---|
| 1708 | nbfield=size(num1_civ1,2); |
---|
| 1709 | nbslice=size(num1_civ1,1); |
---|
| 1710 | |
---|
| 1711 | %RUN CIV1 |
---|
| 1712 | if box_test(1)==1 |
---|
| 1713 | RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) |
---|
| 1714 | if compare==3 |
---|
| 1715 | RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) |
---|
| 1716 | end |
---|
| 1717 | end |
---|
| 1718 | |
---|
| 1719 | %RUN FIX1 |
---|
| 1720 | if box_test(2)==1 |
---|
| 1721 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1722 | %names of the civ1 fields |
---|
| 1723 | field1.vel_type='civ1'; |
---|
| 1724 | field1.nb='nb_vectors'; |
---|
[45] | 1725 | % field1.X='vec_X'; |
---|
| 1726 | % field1.Y='vec_Y'; |
---|
| 1727 | % field1.U='vec_U'; |
---|
| 1728 | % field1.V='vec_V'; |
---|
[2] | 1729 | field1.fixflag='vec_FixFlag'; |
---|
| 1730 | flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1731 | flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
| 1732 | flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
[45] | 1733 | thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1734 | thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1735 | inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 1736 | menu=get(handles.field_ref1,'String'); |
---|
| 1737 | index=get(handles.field_ref1,'Value'); |
---|
| 1738 | if isempty(menu) |
---|
| 1739 | fieldchoice=''; |
---|
| 1740 | else |
---|
| 1741 | fieldchoice=menu{index}; |
---|
| 1742 | end |
---|
[45] | 1743 | h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar |
---|
[12] | 1744 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1745 | if test_mask |
---|
| 1746 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 1747 | if exist(maskdispl,'file') |
---|
| 1748 | test_mask=2; |
---|
| 1749 | maskname=maskdispl; |
---|
| 1750 | else |
---|
| 1751 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1752 | end |
---|
| 1753 | end |
---|
[2] | 1754 | for ifile=1:nbfield |
---|
| 1755 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1756 | for j=1:nbslice |
---|
| 1757 | if test_mask==0 |
---|
| 1758 | maskname='noFile use default'; |
---|
| 1759 | maskflag=0; |
---|
[12] | 1760 | elseif test_mask==1 |
---|
[45] | 1761 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1762 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1763 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
| 1764 | maskflag= exist(maskname,'file')==2; |
---|
| 1765 | if ~maskflag; |
---|
| 1766 | maskname='noFile use default'; |
---|
| 1767 | end |
---|
| 1768 | end |
---|
| 1769 | if ~isempty(file_ref_fix1) |
---|
| 1770 | file_ref=file_ref_fix1{ifile,j}; |
---|
| 1771 | else |
---|
| 1772 | file_ref=''; |
---|
| 1773 | end |
---|
| 1774 | error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1775 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1776 | |
---|
| 1777 | if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
| 1778 | if test_mask==0 |
---|
| 1779 | maskname='noFile use default'; |
---|
| 1780 | maskflag=0; |
---|
| 1781 | else |
---|
| 1782 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1783 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1784 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1785 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1786 | maskflag= exist(maskname,'file')==2; |
---|
| 1787 | if ~maskflag; |
---|
| 1788 | maskname='noFile use default'; |
---|
| 1789 | end |
---|
| 1790 | end |
---|
| 1791 | error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1792 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1793 | if ~isempty(error) |
---|
| 1794 | msgbox_uvmat('ERROR',error) |
---|
| 1795 | return |
---|
| 1796 | end |
---|
| 1797 | end |
---|
| 1798 | end |
---|
| 1799 | end |
---|
| 1800 | close(h) |
---|
| 1801 | end |
---|
| 1802 | |
---|
| 1803 | % RUN PATCH1 |
---|
| 1804 | if box_test(3)==1 |
---|
| 1805 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 1806 | if isempty(rho_patch1) |
---|
| 1807 | rho_patch1='1000'; |
---|
| 1808 | set(handles.rho_patch1,'String','1') |
---|
| 1809 | else |
---|
| 1810 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1811 | end |
---|
| 1812 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1813 | if isequal(str2num(nx_patch1),[]) |
---|
| 1814 | nx_patch1='50' ;%default |
---|
| 1815 | set(handles.nx_patch1,'String','50'); |
---|
| 1816 | end |
---|
| 1817 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 1818 | if isequal(str2num(ny_patch1),[]) |
---|
| 1819 | ny_patch1='50' ;%default |
---|
| 1820 | set(handles.ny_patch1,'String','50'); |
---|
| 1821 | end |
---|
| 1822 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1823 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1824 | test_interp=get(handles.test_interp,'Value'); |
---|
| 1825 | icount=0; |
---|
| 1826 | for ifile=1:nbfield |
---|
| 1827 | for j=1:nbslice |
---|
| 1828 | icount=icount+1; |
---|
| 1829 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1830 | set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
| 1831 | drawnow |
---|
| 1832 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1833 | cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1834 | s=-1; |
---|
| 1835 | if sge |
---|
| 1836 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1837 | end |
---|
| 1838 | if s~=0 |
---|
| 1839 | display(['!' cmd]) |
---|
| 1840 | eval(['!' cmd]); |
---|
| 1841 | end |
---|
| 1842 | |
---|
| 1843 | %stereo case: |
---|
| 1844 | elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 1845 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1846 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
| 1847 | nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1848 | display(['!' cmd]) |
---|
| 1849 | eval(['!' cmd]); |
---|
| 1850 | else |
---|
| 1851 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1852 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1853 | end |
---|
| 1854 | end |
---|
| 1855 | if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1856 | cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1857 | s=-1; |
---|
| 1858 | if sge |
---|
| 1859 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1860 | end |
---|
| 1861 | if s~=0 |
---|
| 1862 | display(['!' cmd]) |
---|
| 1863 | eval(['!' cmd]); |
---|
| 1864 | end |
---|
| 1865 | end |
---|
| 1866 | end |
---|
| 1867 | end |
---|
| 1868 | end |
---|
| 1869 | |
---|
| 1870 | % CIV2 |
---|
| 1871 | if box_test(4)==1 |
---|
| 1872 | RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
| 1873 | num_a_civ2,num_b_civ2,nom_type_nc) |
---|
| 1874 | end |
---|
| 1875 | |
---|
| 1876 | % FIX2 |
---|
| 1877 | if box_test(5)==1 |
---|
| 1878 | %names of the civ2 fields |
---|
| 1879 | field2.vel_type='civ2'; |
---|
| 1880 | field2.nb='nb_vectors2'; |
---|
| 1881 | field2.X='vec2_X'; |
---|
| 1882 | field2.Y='vec2_Y'; |
---|
| 1883 | field2.U='vec2_U'; |
---|
| 1884 | field2.V='vec2_V'; |
---|
| 1885 | field2.fixflag='vec2_FixFlag'; |
---|
| 1886 | flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1887 | flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1888 | flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
| 1889 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1890 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 1891 | inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1892 | menu=get(handles.field_ref2,'String'); |
---|
| 1893 | index=get(handles.field_ref2,'Value'); |
---|
| 1894 | if isempty(menu) |
---|
| 1895 | fieldchoice=''; |
---|
| 1896 | else |
---|
| 1897 | fieldchoice=menu{index}; |
---|
| 1898 | end |
---|
| 1899 | h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
| 1900 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
[12] | 1901 | if test_mask |
---|
| 1902 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 1903 | if exist(maskdispl,'file') |
---|
| 1904 | test_mask=2; |
---|
| 1905 | maskname=maskdispl; |
---|
| 1906 | else |
---|
| 1907 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1908 | end |
---|
| 1909 | end |
---|
[2] | 1910 | for ifile=1:nbfield |
---|
| 1911 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1912 | for j=1:nbslice |
---|
| 1913 | if test_mask==0 |
---|
| 1914 | maskname='noFile use default'; |
---|
| 1915 | maskflag=0; |
---|
[12] | 1916 | elseif test_mask==1 |
---|
[2] | 1917 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1918 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1919 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1920 | maskflag= exist(maskname,'file')==2; |
---|
| 1921 | if ~maskflag; |
---|
| 1922 | maskname='noFile use default'; |
---|
| 1923 | end |
---|
| 1924 | end |
---|
| 1925 | if ~isempty(file_ref_fix2) |
---|
| 1926 | file_ref=file_ref_fix2{ifile,j}; |
---|
| 1927 | else |
---|
| 1928 | file_ref=''; |
---|
| 1929 | end |
---|
| 1930 | error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
| 1931 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1932 | if ~isempty(error) |
---|
| 1933 | msgbox_uvmat('ERROR',error) |
---|
| 1934 | return |
---|
| 1935 | end |
---|
| 1936 | if compare==3 |
---|
| 1937 | if test_mask==0 |
---|
| 1938 | maskname='noFile use default'; |
---|
| 1939 | maskflag=0; |
---|
| 1940 | else |
---|
| 1941 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1942 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1943 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1944 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1945 | maskflag= exist(maskname,'file')==2; |
---|
| 1946 | if ~maskflag; |
---|
| 1947 | maskname='noFile use default'; |
---|
| 1948 | end |
---|
| 1949 | end |
---|
| 1950 | error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
| 1951 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1952 | if ~isempty(error) |
---|
| 1953 | msgbox_uvmat('ERROR',error) |
---|
| 1954 | return |
---|
| 1955 | end |
---|
| 1956 | end |
---|
| 1957 | end |
---|
| 1958 | end |
---|
| 1959 | close(h) |
---|
| 1960 | end |
---|
| 1961 | |
---|
| 1962 | %PATCH 2 |
---|
| 1963 | if box_test(6)==1 |
---|
| 1964 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 1965 | if isempty(rho_patch2) |
---|
| 1966 | rho_patch2='1000'; |
---|
| 1967 | set(handles.rho_patch2,'String','1') |
---|
| 1968 | else |
---|
| 1969 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1970 | end |
---|
| 1971 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1972 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 1973 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1974 | if isequal(str2num(nx_patch2),[]) |
---|
| 1975 | nx_patch2='50' ;%default |
---|
| 1976 | set(handles.nx_patch2,'String','50'); |
---|
| 1977 | end |
---|
| 1978 | if isequal(str2num(ny_patch2),[]) |
---|
| 1979 | ny_patch2='50' ;%default |
---|
| 1980 | set(handles.ny_patch2,'String','50'); |
---|
| 1981 | end |
---|
| 1982 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1983 | icount=0; |
---|
| 1984 | for ifile=1:nbfield |
---|
| 1985 | for j=1:nbslice |
---|
| 1986 | icount=icount+1; |
---|
| 1987 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1988 | set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
| 1989 | drawnow |
---|
| 1990 | if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1991 | cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1992 | s=-1; |
---|
| 1993 | if sge |
---|
| 1994 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1995 | end |
---|
| 1996 | if s~=0 |
---|
| 1997 | display(['!' cmd]) |
---|
| 1998 | eval(['!' cmd]); |
---|
| 1999 | end |
---|
| 2000 | elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 2001 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 2002 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
| 2003 | nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 2004 | display(['!' cmd]) |
---|
| 2005 | eval(['!' cmd]) |
---|
| 2006 | else |
---|
| 2007 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 2008 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 2009 | end |
---|
| 2010 | end |
---|
| 2011 | if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 2012 | cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 2013 | s=-1; |
---|
| 2014 | if sge |
---|
| 2015 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 2016 | end |
---|
| 2017 | if s~=0 |
---|
| 2018 | display(['!' cmd]) |
---|
| 2019 | eval(['!' cmd]); |
---|
| 2020 | end |
---|
| 2021 | end |
---|
| 2022 | end |
---|
| 2023 | end |
---|
| 2024 | end |
---|
| 2025 | |
---|
| 2026 | set(handles.RUN, 'Enable','On') |
---|
| 2027 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2028 | |
---|
| 2029 | %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 2030 | if isfield(filecell,'st') |
---|
| 2031 | fileresu=filecell.st{1,1}; |
---|
| 2032 | elseif isfield(filecell,'nc') |
---|
| 2033 | if isfield(filecell.nc,'civ2') |
---|
| 2034 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2035 | else |
---|
| 2036 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2037 | end |
---|
| 2038 | end |
---|
| 2039 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2040 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2041 | detect=1; |
---|
| 2042 | while detect==1 |
---|
| 2043 | namefigfull=[namedoc '.fig']; |
---|
| 2044 | hh=dir(namefigfull); |
---|
| 2045 | if ~isempty(hh) |
---|
| 2046 | detect=1; |
---|
| 2047 | namedoc=[namedoc '.0']; |
---|
| 2048 | else |
---|
| 2049 | detect=0; |
---|
| 2050 | end |
---|
| 2051 | end |
---|
| 2052 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2053 | |
---|
[12] | 2054 | %------------------------------------------------------------------------ |
---|
[2] | 2055 | % --- Executes on button press in BATCH: remote processing |
---|
| 2056 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[12] | 2057 | %------------------------------------------------------------------------ |
---|
[2] | 2058 | global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe |
---|
| 2059 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 2060 | |
---|
| 2061 | %check the list of operations: |
---|
| 2062 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 2063 | run_flag=1; |
---|
| 2064 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 2065 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 2066 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 2067 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 2068 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 2069 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 2070 | index=find(box_test==1); |
---|
| 2071 | if isempty(index) |
---|
| 2072 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 2073 | return |
---|
| 2074 | end |
---|
| 2075 | index_first=min(index); |
---|
| 2076 | index_last=max(index); |
---|
| 2077 | box_used=box_test([index_first : index_last]); |
---|
| 2078 | [box_missing,ind_missing]=min(box_used); |
---|
| 2079 | if isequal(box_missing,0) |
---|
| 2080 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 2081 | return |
---|
| 2082 | end |
---|
| 2083 | |
---|
| 2084 | %root name |
---|
| 2085 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2086 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2087 | msgbox_uvmat('ERROR','no input files') |
---|
| 2088 | return |
---|
| 2089 | end |
---|
| 2090 | |
---|
| 2091 | %check mask if selecetd |
---|
| 2092 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 2093 | maskname=get(handles.mask_civ1,'String'); |
---|
| 2094 | if ~exist(maskname,'file') |
---|
| 2095 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 2096 | end |
---|
[2] | 2097 | end |
---|
| 2098 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 2099 | maskname=get(handles.mask_fix1,'String'); |
---|
| 2100 | if ~exist(maskname,'file') |
---|
| 2101 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 2102 | end |
---|
[2] | 2103 | end |
---|
| 2104 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 2105 | maskname=get(handles.mask_civ2,'String'); |
---|
| 2106 | if ~exist(maskname,'file') |
---|
[2] | 2107 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 2108 | end |
---|
[2] | 2109 | end |
---|
| 2110 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 2111 | maskname=get(handles.mask_fix2,'String'); |
---|
| 2112 | if ~exist(maskname,'file') |
---|
[2] | 2113 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 2114 | end |
---|
[2] | 2115 | end |
---|
| 2116 | |
---|
| 2117 | %read names of the .exe file |
---|
| 2118 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 2119 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 2120 | if isunix |
---|
| 2121 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 2122 | if exist(xmlfile,'file') |
---|
| 2123 | t=xmltree(xmlfile); |
---|
| 2124 | sparam=convert(t); |
---|
| 2125 | end |
---|
| 2126 | else |
---|
| 2127 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 2128 | if exist(xmlfile,'file') |
---|
| 2129 | t=xmltree(xmlfile); |
---|
| 2130 | sparam=convert(t); |
---|
| 2131 | end |
---|
| 2132 | end |
---|
| 2133 | sge=0; |
---|
| 2134 | if isfield(sparam,'Civ_exe') |
---|
| 2135 | Civ_exe=sparam.Civ_exe; |
---|
| 2136 | end |
---|
| 2137 | if isfield(sparam,'Civ1_exe') |
---|
| 2138 | civ1_exe=sparam.Civ1_exe; |
---|
| 2139 | end |
---|
| 2140 | if isfield(sparam,'Civ2_exe') |
---|
| 2141 | civ2_exe=sparam.Civ2_exe; |
---|
| 2142 | end |
---|
| 2143 | if isfield(sparam,'Patch_exe') |
---|
| 2144 | patch_exe=sparam.Patch_exe; |
---|
| 2145 | end |
---|
| 2146 | if isfield(sparam,'PatchNew_exe') |
---|
| 2147 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 2148 | end |
---|
| 2149 | if isfield(sparam,'Fix_exe') |
---|
| 2150 | fix_exe=sparam.Fix_exe; |
---|
| 2151 | end |
---|
| 2152 | if isfield(sparam,'Todo_path') |
---|
| 2153 | todo_path=sparam.Todo_path; |
---|
| 2154 | end |
---|
| 2155 | if isfield(sparam,'SGE') |
---|
| 2156 | sge=str2num(sparam.SGE); |
---|
| 2157 | end |
---|
| 2158 | |
---|
| 2159 | %choice of batch priority |
---|
| 2160 | ind_answer=2; |
---|
| 2161 | if sge |
---|
| 2162 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2163 | if isequal(s,0) |
---|
| 2164 | w(end)=[]; |
---|
| 2165 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 2166 | str={'urgent';'normal';'low'}; |
---|
| 2167 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2168 | 'SelectionMode','single',... |
---|
| 2169 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 2170 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 2171 | return % a better way should be create |
---|
| 2172 | end |
---|
| 2173 | else |
---|
| 2174 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 2175 | return |
---|
| 2176 | end |
---|
| 2177 | end |
---|
| 2178 | |
---|
| 2179 | %initialize the waitbars |
---|
| 2180 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 2181 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 2182 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 2183 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 2184 | set(handles.BATCH, 'Enable','Off') |
---|
| 2185 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2186 | drawnow |
---|
| 2187 | %get the filename root, nomenclature and numbers |
---|
| 2188 | |
---|
| 2189 | % for Windows system find the UBC path name if needed |
---|
| 2190 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 2191 | cur_dir=pwd; |
---|
| 2192 | if ~isequal(cur_dir(2:3),':\') |
---|
| 2193 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 2194 | end |
---|
| 2195 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 2196 | if isequal(ss,0) |
---|
| 2197 | rankpath=findstr(ww,'\\'); |
---|
| 2198 | if ~isempty(rankpath) |
---|
| 2199 | wwrest=ww(rankpath:end); |
---|
| 2200 | rankend=min(find(double(wwrest)==10))-1; |
---|
| 2201 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 2202 | set(handles.displ_filebase,'String',filebase); |
---|
| 2203 | end |
---|
| 2204 | else |
---|
| 2205 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
| 2206 | set(handles.BATCH, 'Enable','On') |
---|
| 2207 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2208 | return |
---|
| 2209 | end |
---|
| 2210 | end |
---|
| 2211 | |
---|
| 2212 | % set the list of files and check them |
---|
| 2213 | display('checking the files...') |
---|
| 2214 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... |
---|
| 2215 | set_civ_filenames(handles,compare,box_test); |
---|
[41] | 2216 | |
---|
[2] | 2217 | display('files OK, processing...') |
---|
[41] | 2218 | nbfield=numel(num1_civ1); |
---|
| 2219 | nbslice=numel(num_a_civ1); |
---|
[2] | 2220 | |
---|
| 2221 | %GET PARAMETERS: |
---|
| 2222 | %get civ parameters |
---|
| 2223 | if box_test(1)==1 |
---|
| 2224 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
| 2225 | end |
---|
| 2226 | |
---|
| 2227 | %get fix1 parameters |
---|
| 2228 | if box_test(2)==1 |
---|
| 2229 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 2230 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 2231 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 2232 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 2233 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 2234 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2235 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 2236 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
| 2237 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 2238 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 2239 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 2240 | % fileref=fullfile(refpath,fileref); |
---|
| 2241 | menu=get(handles.field_ref1,'String'); |
---|
| 2242 | index=get(handles.field_ref1,'Value'); |
---|
| 2243 | if isempty(menu) |
---|
| 2244 | fieldchoice=''; |
---|
| 2245 | else |
---|
| 2246 | fieldchoice=menu{index}; |
---|
| 2247 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 2248 | end |
---|
| 2249 | end |
---|
| 2250 | |
---|
| 2251 | %get patch1 parameters |
---|
| 2252 | if box_test(3)==1 |
---|
| 2253 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 2254 | if isempty(rho_patch1) |
---|
| 2255 | rho_patch1='1000'; |
---|
| 2256 | set(handles.rho_patch1,'String','1') |
---|
| 2257 | else |
---|
| 2258 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 2259 | end |
---|
| 2260 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 2261 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 2262 | if isequal(str2num(nx_patch1),[]) |
---|
| 2263 | nx_patch1='50' ;%default |
---|
| 2264 | set(handles.nx_patch1,'String','50'); |
---|
| 2265 | end |
---|
| 2266 | if isequal(str2num(ny_patch1),[]) |
---|
| 2267 | ny_patch1='50' ;%default |
---|
| 2268 | set(handles.ny_patch1,'String','50'); |
---|
| 2269 | end |
---|
| 2270 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 2271 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 2272 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2273 | end |
---|
| 2274 | |
---|
| 2275 | %get civ2 parameters |
---|
| 2276 | if box_test(4)==1 |
---|
| 2277 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 2278 | end |
---|
| 2279 | |
---|
| 2280 | %get fix2 parameters |
---|
| 2281 | if box_test(5)==1 |
---|
| 2282 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 2283 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 2284 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
| 2285 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 2286 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 2287 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2288 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
| 2289 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 2290 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 2291 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 2292 | |
---|
| 2293 | %%%%%%%%%%%%%%%%%%% |
---|
| 2294 | end |
---|
| 2295 | |
---|
| 2296 | |
---|
| 2297 | %get patch2 parameters |
---|
| 2298 | if box_test(6)==1 |
---|
| 2299 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 2300 | if isempty(rho_patch2) |
---|
| 2301 | rho_patch2='1000'; |
---|
| 2302 | set(handles.rho_patch2,'String','1') |
---|
| 2303 | else |
---|
| 2304 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 2305 | end |
---|
| 2306 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 2307 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 2308 | if isequal(str2num(nx_patch2),[]) |
---|
| 2309 | nx_patch2='50' ;%default |
---|
| 2310 | set(handles.nx_patch2,'String','50'); |
---|
| 2311 | end |
---|
| 2312 | if isequal(str2num(ny_patch2),[]) |
---|
| 2313 | ny_patch2='50' ;%default |
---|
| 2314 | set(handles.ny_patch2,'String','50'); |
---|
| 2315 | end |
---|
| 2316 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 2317 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 2318 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2319 | end |
---|
| 2320 | |
---|
| 2321 | if ~sge |
---|
| 2322 | |
---|
| 2323 | %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
| 2324 | name_lock=fullfile(todo_path,'lock'); %lock file |
---|
| 2325 | iwait=0; |
---|
| 2326 | while(exist(name_lock) & iwait<15) |
---|
| 2327 | pause(1); %wait 1 second |
---|
| 2328 | iwait=iwait+1; |
---|
| 2329 | end |
---|
| 2330 | if iwait==15 |
---|
| 2331 | msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
| 2332 | set(handles.BATCH, 'Enable','On') |
---|
| 2333 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2334 | return |
---|
| 2335 | end |
---|
| 2336 | p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
| 2337 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 2338 | p1=fopen(name_todo,'a'); |
---|
| 2339 | if (p1<0) |
---|
| 2340 | msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
| 2341 | set(handles.BATCH, 'Enable','On') |
---|
| 2342 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2343 | return; |
---|
| 2344 | end |
---|
| 2345 | end |
---|
| 2346 | |
---|
| 2347 | %MAIN LOOP |
---|
| 2348 | % for ifile=1:nbfield |
---|
| 2349 | p1text=[];%initiate command text |
---|
| 2350 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2351 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
[41] | 2352 | 'TESTbatch' |
---|
| 2353 | size(filecell.nc.civ1) |
---|
| 2354 | nbslice |
---|
| 2355 | nbfield |
---|
[2] | 2356 | for ifile=1:nbfield |
---|
| 2357 | for j=1:nbslice |
---|
| 2358 | i_cmd=0; |
---|
| 2359 | cmd=''; |
---|
| 2360 | if sge |
---|
[12] | 2361 | %fid=fopen([filename '.cmx'],'w') |
---|
[2] | 2362 | cmd='#!/bin/bash'; |
---|
[12] | 2363 | cmd=[cmd '\n' '#$ -cwd']; |
---|
| 2364 | cmd=[cmd '\n' 'hostname && date']; |
---|
[2] | 2365 | end |
---|
| 2366 | if civAll |
---|
| 2367 | civAllxml=xmltree;% xml contents, all parameters |
---|
| 2368 | civAllCmd=[]; |
---|
| 2369 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 2370 | end |
---|
| 2371 | % filecell.nc.civ1 |
---|
[41] | 2372 | filename_cmx=filecell.nc.civ1{ifile,j}%output netcdf file |
---|
| 2373 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
[2] | 2374 | filename_cmx=[filename_cmx 'x']; |
---|
| 2375 | |
---|
| 2376 | %CIV1 |
---|
| 2377 | if box_test(1)==1 |
---|
[41] | 2378 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[2] | 2379 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
[41] | 2380 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 2381 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2382 | |
---|
| 2383 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2384 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 2385 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 2386 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 2387 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 2388 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 2389 | if test_mask==0 |
---|
| 2390 | par_civ1.maskname='noFile use default'; |
---|
| 2391 | par_civ1.maskflag='n'; |
---|
| 2392 | else |
---|
| 2393 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 2394 | if exist(maskdispl,'file') |
---|
| 2395 | par_civ1.maskname=maskdispl; |
---|
| 2396 | par_civ1.maskflag='y'; |
---|
[2] | 2397 | else |
---|
[12] | 2398 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2399 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2400 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2401 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2402 | if exist(par_civ1.maskname,'file') |
---|
| 2403 | par_civ1.maskflag='y'; |
---|
| 2404 | else |
---|
| 2405 | par_civ1.maskname='noFile use default'; |
---|
| 2406 | par_civ1.maskflag='n'; |
---|
| 2407 | end |
---|
[2] | 2408 | end |
---|
| 2409 | end |
---|
| 2410 | |
---|
| 2411 | %TESTgrid |
---|
| 2412 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 2413 | if test_grid |
---|
| 2414 | par_civ1.gridflag='y'; |
---|
| 2415 | gridname=get(handles.grid_civ1,'String'); |
---|
| 2416 | if isequal(gridname(end-3:end),'grid') |
---|
| 2417 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2418 | if ~isempty(nbslice_grid) |
---|
| 2419 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2420 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2421 | if ~exist(par_civ1.gridname,'file') |
---|
| 2422 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2423 | end |
---|
| 2424 | elseif exist(gridname,'file') |
---|
| 2425 | par_civ1.gridname=gridname; |
---|
| 2426 | else |
---|
| 2427 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2428 | end |
---|
| 2429 | end |
---|
| 2430 | else |
---|
| 2431 | par_civ1.gridname='noFile use default'; |
---|
| 2432 | par_civ1.gridflag='n'; |
---|
| 2433 | end |
---|
| 2434 | %endTESTgrid |
---|
| 2435 | |
---|
| 2436 | i_cmd=i_cmd+1; |
---|
| 2437 | if isequal(civAll,0) |
---|
[12] | 2438 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)]; |
---|
[2] | 2439 | else |
---|
| 2440 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
| 2441 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
| 2442 | fieldnames=fields(str); |
---|
| 2443 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 2444 | for ilist=1:length(fieldnames) |
---|
| 2445 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2446 | if ischar(val) |
---|
| 2447 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 2448 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2449 | end |
---|
| 2450 | end |
---|
| 2451 | end |
---|
| 2452 | end |
---|
| 2453 | |
---|
| 2454 | % FIX1 |
---|
| 2455 | if box_test(2)==1 |
---|
| 2456 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2457 | if test_mask==0 |
---|
| 2458 | maskname=''; |
---|
| 2459 | else |
---|
| 2460 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 2461 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2462 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2463 | maskbase=[filebase '_' maskdispl]; |
---|
| 2464 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2465 | end |
---|
| 2466 | if isequal(civAll,0) |
---|
| 2467 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
| 2468 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 2469 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[12] | 2470 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2471 | else |
---|
| 2472 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2473 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 2474 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 2475 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 2476 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 2477 | fix1.threshV=num2str(thresh_vel1); |
---|
| 2478 | fieldnames=fields(fix1); |
---|
| 2479 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 2480 | for ilist=1:length(fieldnames) |
---|
| 2481 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 2482 | if ischar(val) |
---|
| 2483 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 2484 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2485 | end |
---|
| 2486 | end |
---|
| 2487 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 2488 | end |
---|
| 2489 | end |
---|
| 2490 | |
---|
| 2491 | %PATCH1 |
---|
| 2492 | if box_test(3)==1 |
---|
| 2493 | if isequal(civAll,0) |
---|
| 2494 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
[12] | 2495 | cmd=[cmd '\n' cmd_PATCH]; |
---|
[2] | 2496 | else |
---|
| 2497 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2498 | patch1.nopt=subdomain_patch1; |
---|
| 2499 | patch1.maxdiff=thresh_patch1; |
---|
| 2500 | patch1.ro=rho_patch1; |
---|
| 2501 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 2502 | if test_grid |
---|
| 2503 | patch1.gridflag='y'; |
---|
| 2504 | gridname=get(handles.grid_patch1,'String'); |
---|
| 2505 | if isequal(gridname(end-3:end),'grid') |
---|
| 2506 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2507 | if ~isempty(nbslice_grid) |
---|
| 2508 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2509 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2510 | if ~exist(patch1.gridPatch,'file') |
---|
| 2511 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2512 | end |
---|
| 2513 | elseif exist(gridname,'file') |
---|
| 2514 | patch1.gridPatch=gridname; |
---|
| 2515 | else |
---|
| 2516 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2517 | end |
---|
| 2518 | end |
---|
| 2519 | else |
---|
| 2520 | patch1.gridPatch='n'; |
---|
| 2521 | patch1.gridflag='n'; |
---|
| 2522 | patch1.m=nx_patch1; |
---|
| 2523 | patch1.n=ny_patch1; |
---|
| 2524 | end |
---|
| 2525 | patch1.convectFlow='n'; |
---|
| 2526 | fieldnames=fields(patch1); |
---|
| 2527 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2528 | for ilist=1:length(fieldnames) |
---|
| 2529 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2530 | if ischar(val) |
---|
| 2531 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2532 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2533 | end |
---|
| 2534 | end |
---|
| 2535 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2536 | end |
---|
| 2537 | end |
---|
| 2538 | |
---|
| 2539 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
| 2540 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
| 2541 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 2542 | filename_cmx=[filename_cmx 'x']; |
---|
| 2543 | end |
---|
| 2544 | |
---|
| 2545 | if box_test(4)==1 |
---|
| 2546 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2547 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2548 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2549 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2550 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2551 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 2552 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 2553 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 2554 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 2555 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2556 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2557 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 2558 | if test_mask==0 |
---|
| 2559 | par_civ2.maskname='noFile use default'; |
---|
| 2560 | par_civ2.maskflag='n'; |
---|
| 2561 | else |
---|
| 2562 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2563 | if exist(maskdispl,'file') |
---|
| 2564 | par_civ2.maskname=maskdispl; |
---|
| 2565 | par_civ2.maskflag='y'; |
---|
[2] | 2566 | else |
---|
[12] | 2567 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2568 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2569 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2570 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2571 | if exist(par_civ2.maskname,'file') |
---|
| 2572 | par_civ2.maskflag='y'; |
---|
| 2573 | else |
---|
| 2574 | par_civ2.maskname='noFile use default'; |
---|
| 2575 | par_civ2.maskflag='n'; |
---|
| 2576 | end |
---|
[2] | 2577 | end |
---|
| 2578 | end |
---|
| 2579 | %TESTgrid |
---|
| 2580 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 2581 | gridname=get(handles.grid_civ2,'String'); |
---|
| 2582 | gridflag='y'; |
---|
| 2583 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
| 2584 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2585 | if ~isempty(nbslice_grid) |
---|
| 2586 | par_civ2.gridflag='y'; |
---|
| 2587 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2588 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2589 | if exist(par_civ2.gridname,'file') |
---|
| 2590 | par_civ2.gridflag='y'; |
---|
| 2591 | else |
---|
| 2592 | par_civ2.gridname='noFile use default'; |
---|
| 2593 | par_civ2.gridflag='n'; |
---|
| 2594 | end |
---|
| 2595 | elseif exist(gridname,'file') |
---|
| 2596 | par_civ2.gridflag='y'; |
---|
| 2597 | else |
---|
| 2598 | par_civ2.gridname='noFile use default'; |
---|
| 2599 | par_civ2.gridflag='n'; |
---|
| 2600 | end |
---|
| 2601 | end |
---|
| 2602 | %endTESTgrid |
---|
| 2603 | i_cmd=i_cmd+1; |
---|
| 2604 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2); |
---|
| 2605 | if isequal(civAll,0) |
---|
| 2606 | if(isunix) |
---|
[12] | 2607 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2608 | else |
---|
[12] | 2609 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2610 | end |
---|
| 2611 | else |
---|
| 2612 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
| 2613 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
| 2614 | fieldnames=fields(str); |
---|
| 2615 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2616 | for ilist=1:length(fieldnames) |
---|
| 2617 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2618 | if ischar(val) |
---|
| 2619 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2620 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2621 | end |
---|
| 2622 | end |
---|
| 2623 | end |
---|
| 2624 | end |
---|
| 2625 | |
---|
| 2626 | % FIX2 |
---|
[12] | 2627 | if box_test(5)==1 |
---|
[2] | 2628 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2629 | if test_mask==0 |
---|
| 2630 | maskname=''; %no mask used |
---|
| 2631 | else |
---|
| 2632 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 2633 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2634 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2635 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2636 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2637 | end |
---|
| 2638 | if isequal(civAll,0) |
---|
| 2639 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2640 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2641 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[12] | 2642 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2643 | else |
---|
| 2644 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2645 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2646 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2647 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2648 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2649 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2650 | fieldnames=fields(fix2); |
---|
| 2651 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2652 | for ilist=1:length(fieldnames) |
---|
| 2653 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2654 | if ischar(val) |
---|
| 2655 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2656 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2657 | end |
---|
| 2658 | end |
---|
| 2659 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2660 | end |
---|
| 2661 | end |
---|
| 2662 | |
---|
| 2663 | %PATCH2 |
---|
[12] | 2664 | if box_test(6)==1 |
---|
| 2665 | if isequal(civAll,0) |
---|
| 2666 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
| 2667 | cmd=[cmd '\n' cmd_PATCH]; |
---|
| 2668 | else |
---|
| 2669 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2670 | patch2.nopt=subdomain_patch1; |
---|
| 2671 | patch2.maxdiff=thresh_patch1; |
---|
| 2672 | patch2.ro=rho_patch1; |
---|
| 2673 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2674 | if test_grid |
---|
| 2675 | patch2.gridflag='y'; |
---|
| 2676 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2677 | if isequal(gridname(end-3:end),'grid') |
---|
| 2678 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2679 | if ~isempty(nbslice_grid) |
---|
| 2680 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2681 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2682 | if ~exist(patch2.gridPatch,'file') |
---|
| 2683 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2684 | end |
---|
| 2685 | elseif exist(gridname,'file') |
---|
| 2686 | patch2.gridPatch=gridname; |
---|
| 2687 | else |
---|
| 2688 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2689 | end |
---|
| 2690 | end |
---|
[12] | 2691 | else |
---|
| 2692 | patch2.gridPatch='n'; |
---|
| 2693 | patch2.gridflag='n'; |
---|
| 2694 | patch2.m=nx_patch2; |
---|
| 2695 | patch2.n=ny_patch2; |
---|
[2] | 2696 | end |
---|
[12] | 2697 | patch2.convectFlow='n'; |
---|
| 2698 | fieldnames=fields(patch2); |
---|
| 2699 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2700 | for ilist=1:length(fieldnames) |
---|
| 2701 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2702 | if ischar(val) |
---|
| 2703 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2704 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2705 | end |
---|
| 2706 | end |
---|
| 2707 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
| 2708 | end |
---|
| 2709 | end |
---|
| 2710 | if isequal(civAll,1) |
---|
| 2711 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
| 2712 | cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
| 2713 | end |
---|
| 2714 | % create the .bat file: |
---|
| 2715 | if sge |
---|
| 2716 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2717 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
| 2718 | else |
---|
| 2719 | filename_bat=filename_cmx; |
---|
| 2720 | end |
---|
| 2721 | filename_bat(end-2:end)='bat'; |
---|
| 2722 | fid=fopen(filename_bat,'w'); |
---|
[39] | 2723 | fprintf(fid,cmd); |
---|
| 2724 | fclose(fid); |
---|
[12] | 2725 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
| 2726 | if sge |
---|
| 2727 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2728 | namelog=[filename_bat '.patch.log']; |
---|
| 2729 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
| 2730 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2731 | else |
---|
| 2732 | if(isunix) |
---|
| 2733 | cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
[2] | 2734 | else |
---|
[12] | 2735 | cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
[2] | 2736 | end |
---|
[12] | 2737 | count= fprintf(p1,'%s\n', cmdtodo); |
---|
| 2738 | end |
---|
[2] | 2739 | end |
---|
| 2740 | end |
---|
| 2741 | if ~sge |
---|
| 2742 | fclose(p1); |
---|
| 2743 | fclose(p0); |
---|
| 2744 | delete(name_lock); |
---|
| 2745 | end |
---|
| 2746 | |
---|
| 2747 | set(handles.BATCH, 'Enable','On') |
---|
| 2748 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2749 | |
---|
| 2750 | %save interface state |
---|
| 2751 | if isfield(filecell,'nc') |
---|
| 2752 | if isfield(filecell.nc,'civ2') |
---|
| 2753 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2754 | else |
---|
| 2755 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2756 | end |
---|
| 2757 | end |
---|
| 2758 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2759 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2760 | detect=1; |
---|
| 2761 | while detect==1 |
---|
| 2762 | namefigfull=[namedoc '.fig']; |
---|
| 2763 | hh=dir(namefigfull); |
---|
| 2764 | if ~isempty(hh) |
---|
| 2765 | detect=1; |
---|
| 2766 | namedoc=[namedoc '.0']; |
---|
| 2767 | else |
---|
| 2768 | detect=0; |
---|
| 2769 | end |
---|
| 2770 | end |
---|
| 2771 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2772 | |
---|
[12] | 2773 | %------------------------------------------------------------------------ |
---|
[2] | 2774 | %OUTPUT: |
---|
| 2775 | % filecell: structure of input and output files |
---|
| 2776 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
| 2777 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
| 2778 | % .imaA1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2, with camA in stereo case (then .ima1 corresponds to camB) |
---|
| 2779 | % .imaA2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations, with camA in stereo case (then .ima1 corresponds to camB) |
---|
| 2780 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
| 2781 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
| 2782 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
[41] | 2783 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
| 2784 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
| 2785 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
| 2786 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
| 2787 | % nom_type_nc: nomenclature type for velocity files |
---|
| 2788 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
[2] | 2789 | function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... |
---|
| 2790 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2791 | %------------------------------------------------------------------------ |
---|
[2] | 2792 | %get the filename root, nomenclature and numbers |
---|
| 2793 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2794 | browse=get(handles.browse_root,'UserData'); |
---|
| 2795 | compare_list=get(handles.compare,'String'); |
---|
| 2796 | val=get(handles.compare,'Value'); |
---|
| 2797 | compare=compare_list{val}; |
---|
| 2798 | if strcmp(compare,'displacement') |
---|
| 2799 | mode='displacement'; |
---|
| 2800 | else |
---|
| 2801 | mode_list=get(handles.mode,'String'); |
---|
| 2802 | mode_value=get(handles.mode,'Value'); |
---|
| 2803 | mode=mode_list{mode_value}; |
---|
| 2804 | end |
---|
| 2805 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2806 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 2807 | nom_type_nc=browse.nom_type_nc; |
---|
| 2808 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2809 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 2810 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 2811 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2812 | find_pair_indices(handles,mode); |
---|
| 2813 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2814 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2815 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
| 2816 | test_disp=1; |
---|
| 2817 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2818 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2819 | Path1=Path2; |
---|
| 2820 | Name1=get(handles.displ_filebase2,'String');% root name of the first field series for stereo |
---|
| 2821 | filebase_A=fullfile(Path1,Name1); |
---|
| 2822 | if length(Name1)>6 |
---|
| 2823 | Name1=Name1(end-5:end); |
---|
| 2824 | end |
---|
| 2825 | if length(Name2)>6 |
---|
| 2826 | Name2=Name2(end-5:end); |
---|
| 2827 | end |
---|
| 2828 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2829 | else |
---|
| 2830 | test_disp=0; |
---|
| 2831 | filebase_A=filebase; |
---|
| 2832 | nom_type_ima1=nom_type_ima2; |
---|
| 2833 | filebase_AB=filebase; |
---|
| 2834 | end |
---|
| 2835 | if strcmp(compare,'displacement') |
---|
| 2836 | filebase_ima1=filebase_A; |
---|
| 2837 | filebase_ima2=filebase_B; |
---|
| 2838 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
| 2839 | else |
---|
| 2840 | filebase_ima1=filebase_B; |
---|
| 2841 | filebase_ima2=filebase_B; |
---|
| 2842 | filebase_nc=filebase_B; |
---|
| 2843 | end |
---|
| 2844 | |
---|
| 2845 | %determine reference files for fix: |
---|
| 2846 | file_ref_fix1={};%default |
---|
| 2847 | file_ref_fix2={}; |
---|
| 2848 | nbfield=length(num1_civ1); |
---|
| 2849 | nbslice=length(num_a_civ1); |
---|
| 2850 | if box_test(2)==1% fix1 performed |
---|
| 2851 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2852 | if ~isempty(ref) |
---|
| 2853 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2854 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2855 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2856 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2857 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2858 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2859 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2860 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2861 | if isequal(mode,'displacement') |
---|
| 2862 | num_i1=num_i_ref; |
---|
| 2863 | num_i2=num_i_ref; |
---|
| 2864 | num_j1=num_j_ref; |
---|
| 2865 | num_j2=num_j_ref; |
---|
| 2866 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2867 | num_i1=num_i_ref; |
---|
| 2868 | num_i2=num_i1; |
---|
| 2869 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2870 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2871 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2872 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2873 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2874 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2875 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2876 | if isempty(ref.num_a) |
---|
| 2877 | ref.num_a=1; |
---|
| 2878 | end |
---|
| 2879 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2880 | num_j2=num_j1; |
---|
| 2881 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2882 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2883 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2884 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2885 | num_i2=num_i1; |
---|
| 2886 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2887 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2888 | end |
---|
| 2889 | for ifile=1:nbfield |
---|
| 2890 | for j=1:nbslice |
---|
| 2891 | file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);% |
---|
| 2892 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2893 | if ~exist(file_ref,'file') |
---|
| 2894 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2895 | filecell=[]; |
---|
[2] | 2896 | return |
---|
| 2897 | end |
---|
| 2898 | end |
---|
| 2899 | end |
---|
| 2900 | end |
---|
| 2901 | end |
---|
| 2902 | |
---|
| 2903 | %determine reference files for fix2: |
---|
| 2904 | if box_test(5)==1% fix2 performed |
---|
| 2905 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2906 | if ~isempty(ref) |
---|
| 2907 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2908 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2909 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2910 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2911 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2912 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2913 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2914 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2915 | if isequal(mode,'displacement') |
---|
| 2916 | num_i1=num_i_ref; |
---|
| 2917 | num_i2=num_i_ref; |
---|
| 2918 | num_j1=num_j_ref; |
---|
| 2919 | num_j2=num_j_ref; |
---|
| 2920 | elseif isequal(mode,'pair j1-j2') |
---|
| 2921 | num_i1=num_i_ref; |
---|
| 2922 | num_i2=num_i1; |
---|
| 2923 | num_j1=ref.num_a; |
---|
| 2924 | num_j2=ref.num_b; |
---|
| 2925 | elseif isequal(mode,'series(Di)') |
---|
| 2926 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2927 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2928 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2929 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2930 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2931 | num_j2=num_j1; |
---|
| 2932 | elseif isequal(mode,'series(Dj)') |
---|
| 2933 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2934 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2935 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2936 | num_i2=num_i1; |
---|
| 2937 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2938 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2939 | end |
---|
| 2940 | for ifile=1:nbfield |
---|
| 2941 | for j=1:nbslice |
---|
| 2942 | file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);% |
---|
| 2943 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2944 | if ~exist(file_ref,'file') |
---|
| 2945 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[12] | 2946 | filecell=[]; |
---|
[2] | 2947 | return |
---|
| 2948 | end |
---|
| 2949 | end |
---|
| 2950 | end |
---|
| 2951 | end |
---|
| 2952 | end |
---|
| 2953 | |
---|
| 2954 | %check dir |
---|
| 2955 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2956 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2957 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2958 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 2959 | currentdir=pwd;%store the current working directory |
---|
| 2960 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2961 | if ~exist(Path_ima,'dir') |
---|
[12] | 2962 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
| 2963 | filecell=[]; |
---|
[2] | 2964 | return |
---|
| 2965 | end |
---|
| 2966 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
| 2967 | dircur=pwd; %current working directory |
---|
| 2968 | m2=''; |
---|
| 2969 | [erread,message]=fileattrib(Path_ima); |
---|
| 2970 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 2971 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[12] | 2972 | filecell=[]; |
---|
[2] | 2973 | cd(currentdir); |
---|
| 2974 | return |
---|
| 2975 | end |
---|
| 2976 | |
---|
| 2977 | %check the existence of the netcdf and image files involved |
---|
| 2978 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2979 | if box_test(1)==1; |
---|
| 2980 | detect=1; |
---|
| 2981 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 2982 | for ifile=1:nbfield; |
---|
| 2983 | for j=1:nbslice |
---|
| 2984 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1); |
---|
| 2985 | detect=exist(filename,'file')==2; |
---|
| 2986 | if detect% if a netcdf file already exists |
---|
| 2987 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2988 | subdir_civ2=subdir_civ1; |
---|
| 2989 | break |
---|
| 2990 | end |
---|
| 2991 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2992 | end |
---|
| 2993 | if detect% if a netcdf file already exists |
---|
| 2994 | break |
---|
| 2995 | end |
---|
| 2996 | end |
---|
| 2997 | %create the new subdir_civ1 |
---|
| 2998 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2999 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 3000 | if ~isequal(m2,'') |
---|
| 3001 | msgbox_uvmat('ERROR', m2) |
---|
| 3002 | %msgbox(m2);%error message for directory creation |
---|
| 3003 | end |
---|
| 3004 | end |
---|
| 3005 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 3006 | for ifile=1:nbfield |
---|
| 3007 | for j=1:nbslice |
---|
| 3008 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3009 | detect=exist(filename,'file')==2; |
---|
| 3010 | if detect% if a netcdf file already exists |
---|
| 3011 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 3012 | subdir_civ2=subdir_civ1; |
---|
| 3013 | break |
---|
| 3014 | end |
---|
| 3015 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3016 | end |
---|
| 3017 | if detect% if a netcdf file already exists |
---|
| 3018 | break |
---|
| 3019 | end |
---|
| 3020 | end |
---|
| 3021 | %create the new subdir_civ1 |
---|
| 3022 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 3023 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 3024 | if ~isequal(m2,'') |
---|
| 3025 | msgbox_uvmat('ERROR', m2) |
---|
| 3026 | end |
---|
| 3027 | end |
---|
| 3028 | end |
---|
| 3029 | end |
---|
| 3030 | % get image names |
---|
| 3031 | for ifile=1:nbfield |
---|
| 3032 | for j=1:nbslice |
---|
| 3033 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3034 | idetect(j)=exist(filename,'file')==2; |
---|
| 3035 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 3036 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3037 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3038 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
| 3039 | end |
---|
| 3040 | [idetectmin,indexj]=min(idetect); |
---|
| 3041 | if idetectmin==0, |
---|
| 3042 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3043 | filecell=[]; |
---|
[2] | 3044 | return |
---|
| 3045 | end |
---|
| 3046 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3047 | if idetectmin==0, |
---|
| 3048 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3049 | filecell=[]; |
---|
[2] | 3050 | cd(currentdir) |
---|
| 3051 | return |
---|
| 3052 | end |
---|
| 3053 | end |
---|
| 3054 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 3055 | for ifile=1:nbfield |
---|
| 3056 | for j=1:nbslice |
---|
| 3057 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3058 | idetect(j)=exist(filename,'file')==2; |
---|
| 3059 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 3060 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3061 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3062 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 3063 | end |
---|
| 3064 | [idetectmin,indexj]=min(idetect); |
---|
| 3065 | if idetectmin==0, |
---|
| 3066 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3067 | filecell=[]; |
---|
| 3068 | cd(currentdir) |
---|
| 3069 | return |
---|
[2] | 3070 | end |
---|
| 3071 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3072 | if idetectmin==0, |
---|
[12] | 3073 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
| 3074 | filecell=[]; |
---|
| 3075 | cd(currentdir) |
---|
| 3076 | return |
---|
[2] | 3077 | end |
---|
| 3078 | end |
---|
| 3079 | end |
---|
| 3080 | |
---|
| 3081 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 3082 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
| 3083 | for ifile=1:nbfield |
---|
| 3084 | for j=1:nbslice |
---|
| 3085 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3086 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3087 | detect=exist(filename,'file')==2; |
---|
| 3088 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3089 | end |
---|
| 3090 | end |
---|
| 3091 | if strcmp(compare,'stereo PIV') |
---|
| 3092 | for ifile=1:nbfield |
---|
| 3093 | for j=1:nbslice |
---|
| 3094 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3095 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3096 | if ~exist(filename,'file') |
---|
| 3097 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3098 | set(handles.RUN, 'Enable','On') |
---|
| 3099 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3100 | set(handles.BATCH, 'Enable','On') |
---|
| 3101 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[12] | 3102 | filecell=[]; |
---|
[2] | 3103 | cd(currentdir) |
---|
| 3104 | return |
---|
| 3105 | end |
---|
| 3106 | end |
---|
| 3107 | end |
---|
| 3108 | end |
---|
| 3109 | end |
---|
| 3110 | |
---|
| 3111 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 3112 | testdiff=0; |
---|
| 3113 | if (box_test(4)==1)&&... |
---|
| 3114 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
| 3115 | testdiff=1; |
---|
| 3116 | detect=1; |
---|
| 3117 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3118 | for ifile=1:nbfield |
---|
| 3119 | for j=1:nbslice |
---|
| 3120 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3121 | detect=exist(filename,'file')==2; |
---|
| 3122 | if detect% if a netcdf file already exists |
---|
| 3123 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3124 | break |
---|
| 3125 | end |
---|
| 3126 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3127 | end |
---|
| 3128 | if detect% if a netcdf file already exists |
---|
| 3129 | break |
---|
| 3130 | end |
---|
| 3131 | end |
---|
| 3132 | %create the new subdir_civ2 |
---|
| 3133 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3134 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3135 | if ~isequal(m2,'') |
---|
| 3136 | msgbox_uvmat('ERROR', m2) |
---|
| 3137 | end |
---|
| 3138 | end |
---|
| 3139 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 3140 | for ifile=1:nbfield |
---|
| 3141 | for j=1:nbslice |
---|
| 3142 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3143 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
| 3144 | detect=exist(filename,'file')==2; |
---|
| 3145 | if detect% if a netcdf file already exists |
---|
| 3146 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3147 | break |
---|
| 3148 | end |
---|
| 3149 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3150 | end |
---|
| 3151 | if detect% if a netcdf file already exists |
---|
| 3152 | break |
---|
| 3153 | end |
---|
| 3154 | end |
---|
| 3155 | %create the new subdir_civ1 |
---|
| 3156 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3157 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3158 | if ~isequal(m2,'') |
---|
| 3159 | msgbox_uvmat('ERROR', m2) |
---|
| 3160 | %msgbox(m2);%error message for directory creation |
---|
| 3161 | end |
---|
| 3162 | end |
---|
| 3163 | end |
---|
| 3164 | end |
---|
| 3165 | end |
---|
| 3166 | cd(currentdir);%come back to the current working directory |
---|
| 3167 | |
---|
| 3168 | |
---|
| 3169 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 3170 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 3171 | %check source netcdf file of civ1 estimates |
---|
| 3172 | if box_test(1)==0; %no civ1 performed |
---|
| 3173 | for ifile=1:nbfield |
---|
| 3174 | for j=1:nbslice |
---|
| 3175 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3176 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3177 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 3178 | if ~exist(filename,'file') |
---|
| 3179 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3180 | filecell=[]; |
---|
[2] | 3181 | return |
---|
| 3182 | end |
---|
| 3183 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 3184 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 3185 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3186 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3187 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3188 | filecell=[]; |
---|
[2] | 3189 | return |
---|
| 3190 | end |
---|
| 3191 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 3192 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 3193 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 3194 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 3195 | filecell=[]; |
---|
[2] | 3196 | return |
---|
| 3197 | end |
---|
| 3198 | end |
---|
| 3199 | end |
---|
| 3200 | end |
---|
| 3201 | end |
---|
| 3202 | if strcmp(compare,'stereo PIV') |
---|
| 3203 | for ifile=1:nbfield |
---|
| 3204 | for j=1:nbslice |
---|
| 3205 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3206 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3207 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3208 | if ~exist(filename,'file') |
---|
| 3209 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3210 | set(handles.RUN, 'Enable','On') |
---|
| 3211 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3212 | set(handles.BATCH, 'Enable','On') |
---|
| 3213 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 3214 | cd(currentdir) |
---|
| 3215 | return |
---|
| 3216 | end |
---|
| 3217 | end |
---|
| 3218 | end |
---|
| 3219 | end |
---|
| 3220 | end |
---|
| 3221 | |
---|
| 3222 | detect=1; |
---|
| 3223 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 3224 | for ifile=1:nbfield |
---|
| 3225 | for j=1:nbslice |
---|
| 3226 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3227 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
| 3228 | detect=exist(filename,'file')==2; |
---|
| 3229 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3230 | end |
---|
| 3231 | end |
---|
| 3232 | %get first image names for civ2 |
---|
| 3233 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 3234 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 3235 | elseif box_test(4)==1 |
---|
| 3236 | for ifile=1:nbfield |
---|
| 3237 | for j=1:nbslice |
---|
| 3238 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 3239 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 3240 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 3241 | end |
---|
| 3242 | [idetectmin,indexj]=min(idetect_2); |
---|
| 3243 | if idetectmin==0, |
---|
| 3244 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3245 | filecell=[]; |
---|
[2] | 3246 | return |
---|
| 3247 | end |
---|
| 3248 | end |
---|
| 3249 | end |
---|
| 3250 | |
---|
| 3251 | %get second image names for civ2 |
---|
| 3252 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 3253 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 3254 | elseif box_test(4)==1 |
---|
| 3255 | for ifile=1:nbfield |
---|
| 3256 | for j=1:nbslice |
---|
| 3257 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 3258 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 3259 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 3260 | end |
---|
| 3261 | [idetectmin,indexj]=min(idetect_3); |
---|
| 3262 | if idetectmin==0, |
---|
| 3263 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3264 | filecell=[]; |
---|
[2] | 3265 | return |
---|
| 3266 | end |
---|
| 3267 | end |
---|
| 3268 | end |
---|
| 3269 | end |
---|
| 3270 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 3271 | if ~testdiff |
---|
| 3272 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
| 3273 | else % check the civ2 files |
---|
| 3274 | for ifile=1:nbfield |
---|
| 3275 | for j=1:nbslice |
---|
| 3276 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3277 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3278 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3279 | if ~exist(filename,'file') |
---|
| 3280 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3281 | filecell=[]; |
---|
[2] | 3282 | return |
---|
| 3283 | else |
---|
| 3284 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3285 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3286 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3287 | filecell=[]; |
---|
[2] | 3288 | return |
---|
| 3289 | end |
---|
| 3290 | end |
---|
| 3291 | end |
---|
| 3292 | end |
---|
| 3293 | end |
---|
| 3294 | end |
---|
| 3295 | |
---|
| 3296 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 3297 | if strcmp(compare,'stereo PIV') |
---|
| 3298 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 3299 | for ifile=1:nbfield |
---|
| 3300 | for j=1:nbslice |
---|
| 3301 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3302 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3303 | filecell.st(ifile,j)={filename}; |
---|
| 3304 | end |
---|
| 3305 | end |
---|
| 3306 | end |
---|
| 3307 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 3308 | for ifile=1:nbfield |
---|
| 3309 | for j=1:nbslice |
---|
| 3310 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3311 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3312 | filecell.st(ifile,j)={filename}; |
---|
| 3313 | end |
---|
| 3314 | end |
---|
| 3315 | end |
---|
| 3316 | end |
---|
| 3317 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3318 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3319 | browse.nom_type_nc=nom_type_nc; |
---|
| 3320 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 3321 | |
---|
| 3322 | |
---|
| 3323 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 3324 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 3325 | nom_type_imanew1='_i'; |
---|
[2] | 3326 | else |
---|
| 3327 | nom_type_imanew1=nom_type_ima1; |
---|
| 3328 | end |
---|
[45] | 3329 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 3330 | nom_type_imanew2='_i'; |
---|
[2] | 3331 | else |
---|
| 3332 | nom_type_imanew2=nom_type_ima2; |
---|
| 3333 | end |
---|
| 3334 | if ~isequal(ext_ima,'.png') |
---|
[45] | 3335 | %%type of image file |
---|
| 3336 | type_ima1='none';%default |
---|
| 3337 | movieobject1=[];%default |
---|
| 3338 | if isequal(lower(ext_ima),'.avi') |
---|
| 3339 | hhh=which('mmreader'); |
---|
| 3340 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3341 | type_ima1='movie'; |
---|
| 3342 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 3343 | else |
---|
| 3344 | type_ima1='avi'; |
---|
| 3345 | end |
---|
| 3346 | else |
---|
| 3347 | form=imformats(ext_ima(2:end)); |
---|
| 3348 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3349 | if isequal(nom_type_ima1,'*'); |
---|
| 3350 | type_ima1='multimage';%image series in a single image file |
---|
| 3351 | else |
---|
| 3352 | type_ima1='image'; |
---|
| 3353 | end |
---|
| 3354 | end |
---|
| 3355 | end |
---|
| 3356 | type_ima2='none';%default |
---|
| 3357 | movieobject2=[]; |
---|
| 3358 | if isequal(lower(ext_ima),'.avi') |
---|
| 3359 | hhh=which('mmreader'); |
---|
| 3360 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3361 | type_ima2='movie'; |
---|
| 3362 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 3363 | else |
---|
| 3364 | type_ima2='avi'; |
---|
| 3365 | end |
---|
| 3366 | else |
---|
| 3367 | form=imformats(ext_ima(2:end)); |
---|
| 3368 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3369 | if isequal(nom_type_ima1,'*'); |
---|
| 3370 | type_ima2='multimage';%image series in a single image file |
---|
| 3371 | else |
---|
| 3372 | type_ima2='image'; |
---|
| 3373 | end |
---|
| 3374 | end |
---|
| 3375 | end |
---|
[2] | 3376 | %npxy=get(handles.ext_ima,'UserData'); |
---|
| 3377 | % % if numel(npxy)<2 |
---|
| 3378 | % |
---|
| 3379 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1); |
---|
| 3380 | % A=imread(filename); |
---|
| 3381 | % npxy=size(A); |
---|
| 3382 | % % end |
---|
| 3383 | % npy=npxy(1); |
---|
| 3384 | % npx=npxy(2); |
---|
| 3385 | if box_test(1)==1 %if civ1 is performed |
---|
| 3386 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 3387 | for ifile=1:nbfield |
---|
| 3388 | waitbar(ifile/nbfield); |
---|
| 3389 | for j=1:nbslice |
---|
| 3390 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3391 | if ~exist(filename,'file') |
---|
[45] | 3392 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
[2] | 3393 | imwrite(A,filename,'BitDepth',16); |
---|
| 3394 | end |
---|
| 3395 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3396 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3397 | if ~exist(filename,'file') |
---|
[45] | 3398 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
[2] | 3399 | imwrite(A,filename,'BitDepth',16); |
---|
| 3400 | end |
---|
| 3401 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
| 3402 | end |
---|
| 3403 | end |
---|
| 3404 | close(h) |
---|
| 3405 | end |
---|
| 3406 | if box_test(4)==1 %if civ2 is performed |
---|
| 3407 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
| 3408 | for ifile=1:nbfield |
---|
| 3409 | waitbar(ifile/nbfield); |
---|
| 3410 | for j=1:nbslice |
---|
| 3411 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3412 | if ~exist(filename,'file') |
---|
| 3413 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
| 3414 | imwrite(A,filename,'BitDepth',16); |
---|
| 3415 | end |
---|
| 3416 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3417 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3418 | if ~exist(filename,'file') |
---|
| 3419 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
| 3420 | imwrite(A,filename,'BitDepth',16); |
---|
| 3421 | end |
---|
| 3422 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
| 3423 | end |
---|
| 3424 | end |
---|
| 3425 | close(h); |
---|
| 3426 | end |
---|
| 3427 | end |
---|
| 3428 | |
---|
[12] | 3429 | %------------------------------------------------------------------------ |
---|
[2] | 3430 | %CIV1 CIV1 CIV1 CIV1 |
---|
| 3431 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3432 | %------------------------------------------------------------------------ |
---|
[2] | 3433 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3434 | global civ1_exe sge%name of the executable for civ1 calculation |
---|
| 3435 | |
---|
| 3436 | %get civ parameters |
---|
| 3437 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 3438 | if isempty(ibx_val) |
---|
| 3439 | ibx='21'; set(handles.ibx,'String','21') |
---|
| 3440 | else |
---|
| 3441 | ibx=num2str(ibx_val); |
---|
| 3442 | end |
---|
| 3443 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 3444 | if isempty(iby_val) |
---|
| 3445 | iby='21'; set(handles.iby,'String','21') |
---|
| 3446 | else |
---|
| 3447 | iby=num2str(iby_val); |
---|
| 3448 | end |
---|
| 3449 | isx=get(handles.isx,'String'); |
---|
| 3450 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3451 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 3452 | isy=get(handles.isy,'String'); |
---|
| 3453 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3454 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 3455 | shiftx=get(handles.shiftx,'String'); |
---|
| 3456 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
| 3457 | shifty=get(handles.shifty,'String'); |
---|
| 3458 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
| 3459 | rho=get(handles.rho,'String'); |
---|
| 3460 | dx=get(handles.dx_civ1,'String'); |
---|
| 3461 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
| 3462 | dy=get(handles.dy_civ1,'String'); |
---|
| 3463 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
| 3464 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
| 3465 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
| 3466 | pxcmy='1'; |
---|
| 3467 | image_first=cell2mat(filecell(1,1)); |
---|
| 3468 | if ~exist(image_first,'file') |
---|
| 3469 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
| 3470 | set(handles.RUN, 'Enable','On') |
---|
| 3471 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3472 | return |
---|
| 3473 | end |
---|
| 3474 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
| 3475 | sizim=size(A); |
---|
| 3476 | npx=num2str(sizim(2)); |
---|
| 3477 | npy=num2str(sizim(1)); |
---|
| 3478 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3479 | gridname='';%default ='noFile use default' |
---|
| 3480 | gridflag='n';%default |
---|
| 3481 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 3482 | nbslice_grid=[]; |
---|
| 3483 | if test_grid |
---|
| 3484 | gridname=get(handles.grid_civ1,'String'); |
---|
| 3485 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3486 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3487 | if ~isempty(nbslice_grid) |
---|
| 3488 | gridflag='y'; |
---|
| 3489 | end |
---|
| 3490 | elseif exist(gridname,'file') |
---|
| 3491 | gridflag='y'; |
---|
| 3492 | else |
---|
| 3493 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3494 | return |
---|
| 3495 | end |
---|
| 3496 | end |
---|
| 3497 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 3498 | threshflag='y'; |
---|
| 3499 | min_ima=get(handles.MinIma,'String'); |
---|
| 3500 | max_ima=get(handles.MaxIma,'String'); |
---|
| 3501 | else |
---|
| 3502 | threshflag='n'; |
---|
| 3503 | min_ima='0'; |
---|
| 3504 | max_ima='4096'; |
---|
| 3505 | end |
---|
| 3506 | %main loop |
---|
| 3507 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3508 | sizcell=size(filecell); |
---|
| 3509 | nbfield=sizcell(1); |
---|
| 3510 | nbslice=sizcell(2); |
---|
| 3511 | icount=0; |
---|
| 3512 | for ifile=1:nbfield |
---|
| 3513 | for j=1:nbslice |
---|
| 3514 | icount=icount+1; |
---|
| 3515 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3516 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
| 3517 | drawnow |
---|
| 3518 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
| 3519 | filename_ima([end-3:end])=[];%remove .png extension |
---|
| 3520 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
| 3521 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
| 3522 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
| 3523 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3524 | filename_cmx=[filename_cmx 'x']; |
---|
| 3525 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3526 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3527 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3528 | if isequal(Dt,'0') |
---|
| 3529 | Dt='1' ;%case of 'displacement' mode |
---|
| 3530 | end |
---|
| 3531 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3532 | else |
---|
| 3533 | Dt='1'; |
---|
| 3534 | T0='0'; |
---|
| 3535 | end |
---|
| 3536 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
| 3537 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
| 3538 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3539 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3540 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3541 | if ~exist(gridname,'file') |
---|
| 3542 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3543 | return |
---|
| 3544 | end |
---|
| 3545 | end |
---|
| 3546 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 3547 | if test_mask==0 |
---|
| 3548 | maskname='noFile use default'; |
---|
| 3549 | maskflag='n'; |
---|
| 3550 | else |
---|
| 3551 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
| 3552 | maskbase=[filebase '_' maskdispl];% |
---|
| 3553 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
| 3554 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
| 3555 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3556 | if exist(maskname,'file') |
---|
| 3557 | maskflag='y'; |
---|
| 3558 | else |
---|
| 3559 | maskname='noFile use default'; |
---|
| 3560 | maskflag='n'; |
---|
| 3561 | end |
---|
| 3562 | end |
---|
| 3563 | textcmx={'############## CMX file';... |
---|
| 3564 | ['FirstImage ' filename_ima];... |
---|
| 3565 | ['LastImage ' filename_ima_1];... |
---|
| 3566 | 'XX' ;... |
---|
| 3567 | ['Mask ' maskflag] ;... |
---|
| 3568 | ['MaskName ' maskname];... |
---|
| 3569 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
| 3570 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3571 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
| 3572 | ['RO ' rho];... |
---|
| 3573 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3574 | 'XX 1.0';... |
---|
| 3575 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3576 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3577 | 'XX 1';... |
---|
| 3578 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
| 3579 | ['Grid ' gridflag];... |
---|
| 3580 | ['GridName ' gridname] ;... |
---|
| 3581 | 'XX 85';... |
---|
| 3582 | 'XX 1.0';... |
---|
| 3583 | 'XX 1.0';... |
---|
| 3584 | 'Hart 1';... |
---|
| 3585 | 'DecimalShift 0';... |
---|
| 3586 | 'Deformation 0';... |
---|
| 3587 | 'CorrelationMin 0';... |
---|
| 3588 | 'IntensityMin 0';... |
---|
| 3589 | ['SeuilImage ' threshflag];... |
---|
| 3590 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
| 3591 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3592 | 'ImageUsedBefore null null'}; |
---|
| 3593 | textout=char(textcmx); |
---|
[12] | 3594 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3595 | fid=fopen([filename_cmx],'w'); |
---|
| 3596 | fprintf(fid, ['############## CMX file' '\n']); |
---|
[16] | 3597 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
| 3598 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
[12] | 3599 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3600 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
| 3601 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
| 3602 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 3603 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
| 3604 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
| 3605 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
| 3606 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
| 3607 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3608 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
| 3609 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
| 3610 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 3611 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
| 3612 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
| 3613 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
| 3614 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 3615 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3616 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3617 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 3618 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 3619 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 3620 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 3621 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 3622 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 3623 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 3624 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
| 3625 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 3626 | fclose(fid); |
---|
| 3627 | |
---|
[2] | 3628 | s=-1; |
---|
| 3629 | display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3630 | eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3631 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3632 | % % [s,w] = unix(['qrsh -q fast.q ' civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
| 3633 | % end |
---|
| 3634 | % if s~=0 |
---|
| 3635 | % % ['!' civ1_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3636 | % % eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3637 | % end |
---|
| 3638 | end |
---|
| 3639 | end |
---|
| 3640 | |
---|
[12] | 3641 | %------------------------------------------------------------------------ |
---|
[2] | 3642 | % RUN CIV2 CIV2 CIV2 CIV2 |
---|
| 3643 | function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3644 | %------------------------------------------------------------------------ |
---|
[2] | 3645 | %filecell_2: names of first image |
---|
| 3646 | %filecell_3: names of second images |
---|
| 3647 | global civ2_exe sge |
---|
| 3648 | |
---|
| 3649 | %names of the civ2 fields |
---|
| 3650 | field.vel_type='civ2'; |
---|
| 3651 | field.nb='nb_vectors2'; |
---|
| 3652 | field.X='vec2_X'; |
---|
| 3653 | field.Y='vec2_Y'; |
---|
| 3654 | field.U='vec2_U'; |
---|
| 3655 | field.V='vec2_V'; |
---|
| 3656 | |
---|
| 3657 | %get civ parameters |
---|
| 3658 | ibx=get(handles.ibx_civ2,'String'); |
---|
| 3659 | iby=get(handles.iby_civ2,'String'); |
---|
| 3660 | rho=get(handles.rho_civ2,'String'); |
---|
| 3661 | decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3662 | deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3663 | dx=get(handles.dx_civ2,'String'); |
---|
| 3664 | dy=get(handles.dy_civ2,'String'); |
---|
| 3665 | if isequal(str2num(dx),[]) |
---|
| 3666 | dx='20';%default |
---|
| 3667 | end |
---|
| 3668 | if isequal(str2num(dy),[]) |
---|
| 3669 | dy='20';%default |
---|
| 3670 | end |
---|
| 3671 | pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
| 3672 | pxcmy='1'; |
---|
| 3673 | A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
| 3674 | sizim=size(A); |
---|
| 3675 | npx=num2str(sizim(2)); |
---|
| 3676 | npy=num2str(sizim(1)); |
---|
| 3677 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3678 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3679 | %grid |
---|
| 3680 | gridname='';%default ='noFile use default' |
---|
| 3681 | gridflag='n';%default |
---|
| 3682 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 3683 | nbslice_grid=[]; |
---|
| 3684 | if test_grid |
---|
| 3685 | gridname=get(handles.grid_civ2,'String'); |
---|
| 3686 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3687 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3688 | if ~isempty(nbslice_grid) |
---|
| 3689 | gridflag='y'; |
---|
| 3690 | end |
---|
| 3691 | elseif exist(gridname,'file') |
---|
| 3692 | gridflag='y'; |
---|
| 3693 | else |
---|
| 3694 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3695 | return |
---|
| 3696 | end |
---|
| 3697 | end |
---|
| 3698 | sizcell=size(filecell_2); |
---|
| 3699 | nbfield=sizcell(1); |
---|
| 3700 | nbslice=sizcell(2); |
---|
| 3701 | |
---|
| 3702 | %main loop |
---|
| 3703 | icount=0; |
---|
| 3704 | for ifile=1:nbfield |
---|
| 3705 | for j=1:nbslice |
---|
| 3706 | icount=icount+1; |
---|
| 3707 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3708 | set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
| 3709 | drawnow |
---|
| 3710 | filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
| 3711 | filename_ima_2([end-3:end])=[];%remove .png extension |
---|
| 3712 | filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
| 3713 | filename_ima_3([end-3:end])=[];%remove .png extension |
---|
| 3714 | filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
| 3715 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3716 | filename_cmx=[filename_cmx 'x']; |
---|
| 3717 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3718 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3719 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3720 | if isequal(Dt,'0') |
---|
| 3721 | Dt='1' ;%case of 'displacement' mode |
---|
| 3722 | end |
---|
| 3723 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3724 | else |
---|
| 3725 | Dt='1'; |
---|
| 3726 | T0='0'; |
---|
| 3727 | end |
---|
| 3728 | term_a=num2stra(num_a(j),nom_type_nc); |
---|
| 3729 | term_b=num2stra(num_b(j),nom_type_nc); |
---|
| 3730 | filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
| 3731 | filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 3732 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3733 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3734 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3735 | if ~exist(gridname,'file') |
---|
| 3736 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3737 | return |
---|
| 3738 | end |
---|
| 3739 | end |
---|
| 3740 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 3741 | if test_mask==0 |
---|
| 3742 | maskname='noFile use default'; |
---|
| 3743 | maskflag='n'; |
---|
| 3744 | else |
---|
| 3745 | maskdispl=get(handles.mask_civ2,'String'); |
---|
| 3746 | maskbase=[filebase '_' maskdispl]; % |
---|
| 3747 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 3748 | num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
| 3749 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3750 | if ~exist(maskname,'file') |
---|
| 3751 | maskflag='y'; |
---|
| 3752 | else |
---|
| 3753 | maskname='noFile use default'; |
---|
| 3754 | maskflag='n'; |
---|
| 3755 | end |
---|
| 3756 | end |
---|
| 3757 | |
---|
| 3758 | textcmx={'############## CMX file';... |
---|
| 3759 | ['FirstImage ' filename_ima_2];... |
---|
| 3760 | ['LastImage ' filename_ima_3];... |
---|
| 3761 | 'XX' ;... |
---|
| 3762 | ['Mask ' maskflag];... |
---|
| 3763 | ['MaskName ' maskname];... |
---|
| 3764 | ['ImageSize ' npx ' ' npy];... |
---|
| 3765 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3766 | ['SearchBoxeSize ' ibx ' ' iby];... |
---|
| 3767 | ['RO ' rho];... |
---|
| 3768 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3769 | 'XX 1.0';... |
---|
| 3770 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3771 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3772 | 'XX 1';... |
---|
| 3773 | ['ShiftXY 0 0'];... |
---|
| 3774 | ['Grid ' gridflag];... |
---|
| 3775 | ['GridName ' gridname];... |
---|
| 3776 | 'XX 85';... |
---|
| 3777 | 'XX 1.0';... |
---|
| 3778 | 'XX 1.0';... |
---|
| 3779 | 'Hart 1';... |
---|
| 3780 | ['DecimalShift ' decimal];... |
---|
| 3781 | ['Deformation ' deformation];... |
---|
| 3782 | 'CorrelationMin 0';... |
---|
| 3783 | 'IntensityMin 0';... |
---|
| 3784 | 'SeuilImage n';... |
---|
| 3785 | 'SeuilImageValues 0 4096';... |
---|
| 3786 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3787 | ['ImageUsedBefore ' filename_nc1]}; |
---|
| 3788 | textout=char(textcmx); |
---|
[12] | 3789 | dlmwrite(filename_cmx,textout,''); |
---|
[2] | 3790 | s=-1; |
---|
| 3791 | display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3792 | eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3793 | |
---|
| 3794 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3795 | % [s,w] = unix(['qrsh -q fast.q ' civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
| 3796 | % end |
---|
| 3797 | % if s~=0 |
---|
| 3798 | % eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3799 | % ['!' civ2_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3800 | % end |
---|
| 3801 | end |
---|
| 3802 | end |
---|
| 3803 | % close(h) |
---|
| 3804 | |
---|
[12] | 3805 | %------------------------------------------------------------------------ |
---|
| 3806 | % --- PATCH |
---|
[2] | 3807 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
[12] | 3808 | %------------------------------------------------------------------------ |
---|
[2] | 3809 | global patch_exe patch_new_exe |
---|
| 3810 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3811 | if test_interp==0 |
---|
| 3812 | cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3813 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3814 | else %nouveau programme patch |
---|
| 3815 | cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3816 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3817 | end |
---|
[12] | 3818 | |
---|
| 3819 | %------------------------------------------------------------------------ |
---|
| 3820 | % --- STEREO Interp |
---|
[2] | 3821 | function cmd=RUN_STINTERP(stinterp_exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
[12] | 3822 | %------------------------------------------------------------------------ |
---|
[2] | 3823 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
| 3824 | cmd=[stinterp_exe ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3825 | ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3826 | |
---|
[12] | 3827 | %------------------------------------------------------------------------ |
---|
[2] | 3828 | % --- Executes on button press in CIV1. |
---|
| 3829 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3830 | %------------------------------------------------------------------------ |
---|
[2] | 3831 | val=get(handles.CIV1,'Value'); |
---|
| 3832 | if isequal(val,1) |
---|
| 3833 | enable_civ1(handles,'on') |
---|
| 3834 | enable_pair1(handles,'on') |
---|
| 3835 | else |
---|
| 3836 | enable_civ1(handles,'off') |
---|
| 3837 | end |
---|
| 3838 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3839 | |
---|
[12] | 3840 | %------------------------------------------------------------------------ |
---|
[2] | 3841 | % --- Executes on button press in FIX1. |
---|
| 3842 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3843 | %------------------------------------------------------------------------ |
---|
[2] | 3844 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3845 | |
---|
[12] | 3846 | %------------------------------------------------------------------------ |
---|
[2] | 3847 | % --- Executes on button press in PATCH1. |
---|
| 3848 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3849 | %------------------------------------------------------------------------ |
---|
[2] | 3850 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3851 | enable_patch1(handles) |
---|
[2] | 3852 | else |
---|
[12] | 3853 | desable_patch1(handles) |
---|
[2] | 3854 | end |
---|
| 3855 | |
---|
[12] | 3856 | %------------------------------------------------------------------------ |
---|
[2] | 3857 | % --- Executes on button press in CIV2. |
---|
| 3858 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3859 | %------------------------------------------------------------------------ |
---|
[2] | 3860 | state=get(handles.CIV2,'Value'); |
---|
| 3861 | enable_civ2(handles,state) |
---|
| 3862 | if state |
---|
| 3863 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3864 | enable_pair1(handles,'on') |
---|
| 3865 | end |
---|
| 3866 | |
---|
[12] | 3867 | %------------------------------------------------------------------------ |
---|
[2] | 3868 | % --- Executes on button press in FIX2. |
---|
| 3869 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3870 | %------------------------------------------------------------------------ |
---|
[2] | 3871 | if get(handles.FIX2,'Value')==1 |
---|
| 3872 | enable_fix2(handles) |
---|
| 3873 | if get(handles.CIV2,'Value')==0 |
---|
| 3874 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3875 | end |
---|
| 3876 | else |
---|
| 3877 | desable_fix2(handles) |
---|
| 3878 | end |
---|
| 3879 | |
---|
[12] | 3880 | %------------------------------------------------------------------------ |
---|
[2] | 3881 | % --- Executes on button press in PATCH2. |
---|
| 3882 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3883 | %------------------------------------------------------------------------ |
---|
[2] | 3884 | if get(handles.PATCH2,'Value')==1 |
---|
| 3885 | enable_patch2(handles) |
---|
| 3886 | if get(handles.CIV2,'Value')==0 |
---|
| 3887 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3888 | end |
---|
| 3889 | else |
---|
| 3890 | desable_patch2(handles) |
---|
| 3891 | end |
---|
| 3892 | |
---|
[12] | 3893 | %------------------------------------------------------------------------ |
---|
| 3894 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3895 | %------------------------------------------------------------------------ |
---|
| 3896 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 3897 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 3898 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3899 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3900 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3901 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3902 | |
---|
[12] | 3903 | %------------------------------------------------------------------------ |
---|
| 3904 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3905 | %------------------------------------------------------------------------ |
---|
| 3906 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3907 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3908 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3909 | |
---|
[12] | 3910 | %------------------------------------------------------------------------ |
---|
[2] | 3911 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3912 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3913 | %------------------------------------------------------------------------ |
---|
[2] | 3914 | %determine pair numbers |
---|
| 3915 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3916 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3917 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3918 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3919 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3920 | pxcmx=pxcm_xy(1); |
---|
| 3921 | pxcmy=pxcm_xy(2); |
---|
| 3922 | mode_list=get(handles.mode,'String'); |
---|
| 3923 | mode_value=get(handles.mode,'Value'); |
---|
| 3924 | mode=mode_list{mode_value}; |
---|
| 3925 | if isequal (mode, 'series(Di)' ) |
---|
| 3926 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3927 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3928 | num2=ref_i+ceil(index/2); |
---|
| 3929 | num_a=1; |
---|
| 3930 | num_b=1; |
---|
| 3931 | elseif isequal (mode, 'series(Dj)') |
---|
| 3932 | num1=1; |
---|
| 3933 | num2=1; |
---|
| 3934 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3935 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3936 | num_b=ref_j+ceil(index/2); |
---|
| 3937 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3938 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3939 | num1=ref_i; |
---|
| 3940 | num2=ref_i; |
---|
| 3941 | num_a=displ_num(1,index); |
---|
| 3942 | num_b=displ_num(2,index); |
---|
| 3943 | end |
---|
| 3944 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3945 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 3946 | iby=str2num(get(handles.iby,'String')); |
---|
| 3947 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 3948 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 3949 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 3950 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 3951 | shiftx=round((umin+umax)/2); |
---|
| 3952 | shifty=round((vmin+vmax)/2); |
---|
| 3953 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3954 | isx=2*ceil(isx/2)+1; |
---|
| 3955 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3956 | isy=2*ceil(isy/2)+1; |
---|
| 3957 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3958 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3959 | set(handles.isx,'String',num2str(isx)); |
---|
| 3960 | set(handles.isy,'String',num2str(isy)); |
---|
| 3961 | |
---|
[12] | 3962 | %------------------------------------------------------------------------ |
---|
| 3963 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3964 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3965 | %------------------------------------------------------------------------ |
---|
[2] | 3966 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3967 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3968 | if get(handles.CIV1,'Value')==0 |
---|
| 3969 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3970 | end |
---|
| 3971 | |
---|
[12] | 3972 | %------------------------------------------------------------------------ |
---|
| 3973 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3974 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3975 | %------------------------------------------------------------------------ |
---|
[2] | 3976 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3977 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3978 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3979 | end |
---|
| 3980 | |
---|
[12] | 3981 | %------------------------------------------------------------------------ |
---|
[2] | 3982 | % --- Executes on button press in get_mask_civ1. |
---|
| 3983 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3984 | %------------------------------------------------------------------------ |
---|
[2] | 3985 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3986 | if isequal(maskval,0) |
---|
| 3987 | set(handles.mask_civ1,'String','') |
---|
| 3988 | else |
---|
| 3989 | mask_displ='no mask'; %default |
---|
| 3990 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3991 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3992 | if isequal(flag_mask,1) |
---|
| 3993 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
| 3994 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3995 | common_path=fileparts(filebase); |
---|
| 3996 | filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String')); |
---|
| 3997 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[12] | 3998 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
[2] | 3999 | mask_displ='no mask'; |
---|
| 4000 | end |
---|
| 4001 | end |
---|
| 4002 | if isequal(mask_displ,'no mask') |
---|
[12] | 4003 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4004 | {'*.png', ' (*.png)'; |
---|
| 4005 | '*.png', '.png files '; ... |
---|
| 4006 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4007 | 'Pick a mask file *.png',filebase); |
---|
| 4008 | mask_displ=fullfile(PathName,FileName); |
---|
| 4009 | if ~exist(mask_displ,'file') |
---|
| 4010 | mask_displ='no mask'; |
---|
| 4011 | end |
---|
| 4012 | end |
---|
| 4013 | if isequal(mask_displ,'no mask') |
---|
[2] | 4014 | set(handles.get_mask_civ1,'Value',0) |
---|
| 4015 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4016 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4017 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4018 | else |
---|
| 4019 | set(handles.get_mask_fix1,'Value',1) |
---|
| 4020 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4021 | end |
---|
| 4022 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 4023 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4024 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4025 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4026 | end |
---|
| 4027 | |
---|
[12] | 4028 | %------------------------------------------------------------------------ |
---|
[2] | 4029 | % --- Executes on button press in get_mask_fix1. |
---|
| 4030 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4031 | %------------------------------------------------------------------------ |
---|
[2] | 4032 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 4033 | if isequal(maskval,0) |
---|
| 4034 | set(handles.mask_fix1,'String','') |
---|
| 4035 | else |
---|
| 4036 | mask_displ='no mask'; %default |
---|
| 4037 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4038 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4039 | if isequal(flag_mask,1) |
---|
| 4040 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4041 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4042 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4043 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4044 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4045 | mask_displ='no mask'; |
---|
| 4046 | end |
---|
| 4047 | end |
---|
| 4048 | if isequal(mask_displ,'no mask') |
---|
[12] | 4049 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4050 | {'*.png', ' (*.png)'; |
---|
| 4051 | '*.png', '.png files '; ... |
---|
| 4052 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4053 | 'Pick a mask file *.png',filebase); |
---|
| 4054 | mask_displ=fullfile(PathName,FileName); |
---|
| 4055 | if ~exist(mask_displ,'file') |
---|
| 4056 | mask_displ='no mask'; |
---|
| 4057 | end |
---|
| 4058 | end |
---|
| 4059 | if isequal(mask_displ,'no mask') |
---|
[2] | 4060 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4061 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4062 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4063 | else |
---|
| 4064 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 4065 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4066 | end |
---|
| 4067 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4068 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4069 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4070 | end |
---|
[12] | 4071 | |
---|
| 4072 | %------------------------------------------------------------------------ |
---|
[2] | 4073 | % --- Executes on button press in get_mask_civ2. |
---|
| 4074 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4075 | %------------------------------------------------------------------------ |
---|
[2] | 4076 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 4077 | if isequal(maskval,0) |
---|
| 4078 | set(handles.mask_civ2,'String','') |
---|
| 4079 | else |
---|
| 4080 | mask_displ='no mask'; %default |
---|
| 4081 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4082 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4083 | if isequal(flag_mask,1) |
---|
| 4084 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4085 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4086 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4087 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4088 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4089 | mask_displ='no mask'; |
---|
| 4090 | end |
---|
| 4091 | end |
---|
| 4092 | if isequal(mask_displ,'no mask') |
---|
[12] | 4093 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4094 | {'*.png', ' (*.png)'; |
---|
| 4095 | '*.png', '.png files '; ... |
---|
| 4096 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4097 | 'Pick a mask file *.png',filebase); |
---|
| 4098 | mask_displ=fullfile(PathName,FileName); |
---|
| 4099 | if ~exist(mask_displ,'file') |
---|
| 4100 | mask_displ='no mask'; |
---|
| 4101 | end |
---|
| 4102 | end |
---|
| 4103 | if isequal(mask_displ,'no mask') |
---|
[2] | 4104 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4105 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4106 | else |
---|
| 4107 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4108 | end |
---|
| 4109 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4110 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4111 | end |
---|
[12] | 4112 | |
---|
| 4113 | %------------------------------------------------------------------------ |
---|
[2] | 4114 | % --- Executes on button press in get_mask_fix2. |
---|
| 4115 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4116 | %------------------------------------------------------------------------ |
---|
[2] | 4117 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 4118 | if isequal(maskval,0) |
---|
| 4119 | set(handles.mask_fix2,'String','') |
---|
| 4120 | else |
---|
[12] | 4121 | mask_displ='no mask'; %default |
---|
| 4122 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4123 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4124 | if isequal(flag_mask,1) |
---|
| 4125 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4126 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4127 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4128 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4129 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4130 | mask_displ='no mask'; |
---|
| 4131 | end |
---|
| 4132 | end |
---|
| 4133 | if isequal(mask_displ,'no mask') |
---|
| 4134 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4135 | {'*.png', ' (*.png)'; |
---|
| 4136 | '*.png', '.png files '; ... |
---|
| 4137 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4138 | 'Pick a mask file *.png',filebase); |
---|
| 4139 | mask_displ=fullfile(PathName,FileName); |
---|
| 4140 | if ~exist(mask_displ,'file') |
---|
[2] | 4141 | mask_displ='no mask'; |
---|
| 4142 | end |
---|
[12] | 4143 | end |
---|
| 4144 | if isequal(mask_displ,'no mask') |
---|
| 4145 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4146 | end |
---|
| 4147 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 4148 | end |
---|
| 4149 | |
---|
[12] | 4150 | %------------------------------------------------------------------------ |
---|
| 4151 | % --- function called to look for mask files |
---|
[2] | 4152 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 4153 | %------------------------------------------------------------------------ |
---|
[2] | 4154 | %detect mask files, images with appropriate file base |
---|
| 4155 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 4156 | %flag_mask=1 indicates detection |
---|
| 4157 | |
---|
| 4158 | flag_mask=0;%default |
---|
| 4159 | nbslice=1; |
---|
| 4160 | |
---|
| 4161 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 4162 | [Path,Name]=fileparts(filebase); |
---|
[12] | 4163 | if ~isdir(Path) |
---|
| 4164 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 4165 | return |
---|
| 4166 | end |
---|
[2] | 4167 | currentdir=pwd; |
---|
| 4168 | cd(Path);%move in the dir of the root name filebase |
---|
| 4169 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 4170 | cd(currentdir);%come back to the current working directory |
---|
[12] | 4171 | if ~isempty(maskfiles) |
---|
| 4172 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 4173 | % else |
---|
[2] | 4174 | flag_mask=1; |
---|
| 4175 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4176 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4177 | Namedouble=double(Name); |
---|
| 4178 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4179 | ind_mask=findstr('mask',Name); |
---|
| 4180 | i=ind_mask-1; |
---|
| 4181 | while val(i)==0 & i>0 |
---|
| 4182 | i=i-1; |
---|
| 4183 | end |
---|
| 4184 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4185 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4186 | flag_mask=1; |
---|
| 4187 | else |
---|
| 4188 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 4189 | return |
---|
| 4190 | nbslice=1; |
---|
| 4191 | end |
---|
| 4192 | end |
---|
| 4193 | |
---|
[12] | 4194 | %------------------------------------------------------------------------ |
---|
| 4195 | % --- function called to look for grid files |
---|
[2] | 4196 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 4197 | %------------------------------------------------------------------------ |
---|
[2] | 4198 | flag_mask=0;%default |
---|
| 4199 | nbslice=1; |
---|
| 4200 | [Path,Name]=fileparts(filebase); |
---|
| 4201 | currentdir=pwd; |
---|
| 4202 | cd(Path);%move in the dir of the root name filebase |
---|
| 4203 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 4204 | cd(currentdir);%come back to the current working directory |
---|
| 4205 | if ~isempty(maskfiles) |
---|
| 4206 | flag_mask=1; |
---|
| 4207 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4208 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4209 | Namedouble=double(Name); |
---|
| 4210 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4211 | ind_mask=findstr('grid',Name); |
---|
| 4212 | i=ind_mask-1; |
---|
| 4213 | while val(i)==0 & i>0 |
---|
| 4214 | i=i-1; |
---|
| 4215 | end |
---|
| 4216 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4217 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4218 | flag_mask=1; |
---|
| 4219 | else |
---|
| 4220 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 4221 | return |
---|
| 4222 | nbslice=1; |
---|
| 4223 | end |
---|
[12] | 4224 | end |
---|
[2] | 4225 | |
---|
[12] | 4226 | %------------------------------------------------------------------------ |
---|
| 4227 | % --- transform numbers to letters |
---|
[2] | 4228 | function str=num2stra(num,nom_type); |
---|
[12] | 4229 | %------------------------------------------------------------------------ |
---|
[2] | 4230 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 4231 | str=char(96+num); |
---|
| 4232 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 4233 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 4234 | str=''; |
---|
| 4235 | else |
---|
| 4236 | str=num2str(num); |
---|
| 4237 | end |
---|
[12] | 4238 | |
---|
| 4239 | %------------------------------------------------------------------------ |
---|
[2] | 4240 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4241 | %------------------------------------------------------------------------ |
---|
[2] | 4242 | set(handles.mask_civ1,'UserData',[]) |
---|
| 4243 | set(handles.mask_civ1,'String','') |
---|
[12] | 4244 | |
---|
| 4245 | %------------------------------------------------------------------------ |
---|
[2] | 4246 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4247 | %------------------------------------------------------------------------ |
---|
[2] | 4248 | set(handles.mask_civ2,'UserData',[]) |
---|
| 4249 | set(handles.mask_civ2,'String','') |
---|
[12] | 4250 | |
---|
| 4251 | %------------------------------------------------------------------------ |
---|
[2] | 4252 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4253 | %------------------------------------------------------------------------ |
---|
[2] | 4254 | set(handles.mask_fix1,'UserData',[]) |
---|
| 4255 | set(handles.mask_fix1,'String','') |
---|
[12] | 4256 | |
---|
| 4257 | %------------------------------------------------------------------------ |
---|
[2] | 4258 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4259 | %------------------------------------------------------------------------ |
---|
[2] | 4260 | set(handles.mask_fix2,'UserData',[]) |
---|
| 4261 | set(handles.mask_fix2,'String','') |
---|
| 4262 | |
---|
[12] | 4263 | %------------------------------------------------------------------------ |
---|
[2] | 4264 | % --- Executes on button press in list_subdir_civ1. |
---|
| 4265 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4266 | %------------------------------------------------------------------------ |
---|
[2] | 4267 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 4268 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 4269 | if val>1 |
---|
| 4270 | subdir=list_subdir_civ1{val}; |
---|
| 4271 | set(handles.subdir_civ1,'String',subdir); |
---|
| 4272 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 4273 | end |
---|
| 4274 | |
---|
[12] | 4275 | %------------------------------------------------------------------------ |
---|
[2] | 4276 | % --- Executes on button press in list_subdir_civ2. |
---|
| 4277 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4278 | %------------------------------------------------------------------------ |
---|
[2] | 4279 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 4280 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 4281 | if val>1 |
---|
| 4282 | subdir=list_subdir_civ2{val}; |
---|
| 4283 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4284 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 4285 | end |
---|
| 4286 | |
---|
[12] | 4287 | %------------------------------------------------------------------------ |
---|
[2] | 4288 | % --- Executes on button press in browse_gridciv1. |
---|
| 4289 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 4290 | %------------------------------------------------------------------------ |
---|
[2] | 4291 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 4292 | testgrid=0; |
---|
| 4293 | if value |
---|
| 4294 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4295 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4296 | if isequal(flag_grid,1) |
---|
| 4297 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 4298 | testgrid=1; |
---|
| 4299 | else |
---|
| 4300 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4301 | {'*.grid', ' (*.grid)'; |
---|
| 4302 | '*.grid', '.grid files '; ... |
---|
| 4303 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4304 | 'Pick a file',filebase); |
---|
| 4305 | filegrid=fullfile(PathName,FileName); |
---|
| 4306 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 4307 | testgrid=1; |
---|
| 4308 | end |
---|
| 4309 | end |
---|
| 4310 | end |
---|
| 4311 | if testgrid |
---|
| 4312 | set(handles.browse_gridciv2,'Value',1) |
---|
| 4313 | set(handles.get_gridpatch1,'Value',1) |
---|
| 4314 | set(handles.get_gridpatch2,'Value',1) |
---|
| 4315 | set(handles.dx_civ1,'Visible','off'); |
---|
| 4316 | set(handles.dy_civ1,'Visible','off'); |
---|
| 4317 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4318 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4319 | set(handles.grid_civ1,'String',filegrid) |
---|
| 4320 | set(handles.grid_patch1,'String',filegrid) |
---|
| 4321 | set(handles.grid_civ2,'String',filegrid) |
---|
| 4322 | set(handles.grid_patch2,'String',filegrid) |
---|
| 4323 | else |
---|
| 4324 | set(handles.browse_gridciv1,'Value',0); |
---|
| 4325 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4326 | set(handles.get_gridpatch1,'Value',0) |
---|
| 4327 | set(handles.get_gridpatch2,'Value',0) |
---|
| 4328 | set(handles.dx_civ1,'Visible','on'); |
---|
| 4329 | set(handles.dy_civ1,'Visible','on'); |
---|
| 4330 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4331 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4332 | set(handles.grid_civ1,'String','') |
---|
| 4333 | set(handles.grid_patch1,'String','') |
---|
| 4334 | set(handles.grid_civ2,'String','') |
---|
| 4335 | set(handles.grid_patch2,'String','') |
---|
| 4336 | end |
---|
| 4337 | |
---|
[12] | 4338 | %------------------------------------------------------------------------ |
---|
[2] | 4339 | % --- Executes on button press in browse_gridciv1. |
---|
| 4340 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 4341 | %------------------------------------------------------------------------ |
---|
[2] | 4342 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 4343 | if value |
---|
| 4344 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4345 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4346 | if isequal(flag_grid,1) |
---|
| 4347 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 4348 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 4349 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4350 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4351 | else |
---|
| 4352 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4353 | {'*.grid', ' (*.grid)'; |
---|
| 4354 | '*.grid', '.grid files '; ... |
---|
| 4355 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4356 | 'Pick a file',filebase); |
---|
| 4357 | filegrid=fullfile(PathName,FileName); |
---|
| 4358 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 4359 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4360 | set(handles.grid_civ2,'string',''); |
---|
| 4361 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4362 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4363 | set(handles.grid_civ2,'string',''); |
---|
| 4364 | else |
---|
| 4365 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4366 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4367 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4368 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4369 | end |
---|
| 4370 | end |
---|
| 4371 | else |
---|
| 4372 | set(handles.grid_civ2,'string',''); |
---|
| 4373 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4374 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4375 | set(handles.grid_civ2,'string',''); |
---|
| 4376 | end |
---|
| 4377 | |
---|
| 4378 | % % --- Executes on button press in browse_gridciv2. |
---|
| 4379 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 4380 | % |
---|
| 4381 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 4382 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4383 | % {'*.grid', ' (*.grid)'; |
---|
| 4384 | % '*.grid', '.grid files '; ... |
---|
| 4385 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 4386 | % 'Pick a file',filebase); |
---|
| 4387 | % filegrid=fullfile(PathName,FileName); |
---|
| 4388 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 4389 | % set(handles.dx_civ2,'String',' '); |
---|
| 4390 | % set(handles.dy_civ2,'String',' '); |
---|
| 4391 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 4392 | |
---|
| 4393 | % --- Executes on button press in get_gridpatch1. |
---|
| 4394 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 4395 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 4396 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4397 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4398 | |
---|
| 4399 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4400 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4401 | {'*.grid', ' (*.grid)'; |
---|
| 4402 | '*.grid', '.grid files '; ... |
---|
| 4403 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4404 | 'Pick a file',filebase); |
---|
| 4405 | filegrid=fullfile(PathName,FileName); |
---|
| 4406 | set(handles.grid_patch1,'string',filegrid); |
---|
| 4407 | % set(handles.grid_patch2,'string',filegrid |
---|
| 4408 | |
---|
[12] | 4409 | %------------------------------------------------------------------------ |
---|
[2] | 4410 | % --- Executes on button press in get_gridpatch2. |
---|
| 4411 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 4412 | %------------------------------------------------------------------------ |
---|
[2] | 4413 | |
---|
[12] | 4414 | %------------------------------------------------------------------------ |
---|
[2] | 4415 | function enable_civ1(handles,state) |
---|
[12] | 4416 | %------------------------------------------------------------------------ |
---|
[2] | 4417 | if isequal(state,0) |
---|
| 4418 | state='off'; |
---|
| 4419 | end |
---|
| 4420 | if isequal(state,1) |
---|
| 4421 | state='on'; |
---|
| 4422 | end |
---|
| 4423 | if isequal(state,'on') |
---|
| 4424 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4425 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4426 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4427 | else |
---|
| 4428 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4429 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4430 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4431 | end |
---|
| 4432 | set(handles.ibx,'Visible',state) |
---|
| 4433 | set(handles.iby,'Visible',state) |
---|
| 4434 | set(handles.isx,'Visible',state) |
---|
| 4435 | set(handles.isy,'Visible',state) |
---|
| 4436 | set(handles.shiftx,'Visible',state) |
---|
| 4437 | set(handles.shifty,'Visible',state) |
---|
| 4438 | set(handles.rho,'Visible',state) |
---|
| 4439 | set(handles.dx_civ1,'Visible',state) |
---|
| 4440 | set(handles.dy_civ1,'Visible',state) |
---|
| 4441 | set(handles.calcul_search,'Visible',state) |
---|
| 4442 | set(handles.u_text,'Visible',state) |
---|
| 4443 | set(handles.v_text,'Visible',state) |
---|
| 4444 | set(handles.min,'Visible',state) |
---|
| 4445 | set(handles.max,'Visible',state) |
---|
| 4446 | set(handles.umin,'Visible',state) |
---|
| 4447 | set(handles.umax,'Visible',state) |
---|
| 4448 | set(handles.vmin,'Visible',state) |
---|
| 4449 | set(handles.vmax,'Visible',state) |
---|
| 4450 | set(handles.grid_civ1,'Visible',state) |
---|
| 4451 | set(handles.mask_civ1,'Visible',state) |
---|
| 4452 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 4453 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 4454 | set(handles.parameters,'Visible',state) |
---|
| 4455 | set(handles.grid,'Visible',state) |
---|
| 4456 | set(handles.dx_civ1,'Visible',state) |
---|
| 4457 | set(handles.dy_civ1,'Visible',state) |
---|
| 4458 | set(handles.ImaThreshold,'Visible',state) |
---|
| 4459 | if isequal(state,'off') |
---|
| 4460 | set(handles.MinIma,'Visible','off') |
---|
| 4461 | set(handles.MaxIma,'Visible','off') |
---|
| 4462 | set(handles.ImaThreshold,'Value',0) |
---|
| 4463 | end |
---|
| 4464 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 4465 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 4466 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 4467 | set(handles.ib_title,'Visible',state) |
---|
| 4468 | set(handles.is_title,'Visible',state) |
---|
| 4469 | set(handles.shift_title,'Visible',state) |
---|
| 4470 | set(handles.rho_title,'Visible',state) |
---|
| 4471 | |
---|
[12] | 4472 | %------------------------------------------------------------------------ |
---|
[2] | 4473 | function enable_fix1(handles,state) |
---|
[12] | 4474 | %------------------------------------------------------------------------ |
---|
[2] | 4475 | if isequal(state,0) |
---|
| 4476 | state='off'; |
---|
| 4477 | end |
---|
| 4478 | if isequal(state,1) |
---|
| 4479 | state='on'; |
---|
| 4480 | end |
---|
| 4481 | if isequal(state,'on') |
---|
| 4482 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 4483 | else |
---|
| 4484 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4485 | end |
---|
| 4486 | set(handles.REMOVE,'Visible',state) |
---|
| 4487 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 4488 | set(handles.vec_F2,'Visible',state) |
---|
| 4489 | set(handles.vec_F3,'Visible',state) |
---|
| 4490 | set(handles.thresh_vecC,'Visible',state) |
---|
| 4491 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 4492 | set(handles.thresh_vel,'Visible',state) |
---|
| 4493 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 4494 | set(handles.mask_fix1,'Visible',state) |
---|
| 4495 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 4496 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 4497 | set(handles.ref_fix1,'Visible',state) |
---|
| 4498 | set(handles.inf_sup1,'Visible',state) |
---|
| 4499 | set(handles.field_ref1,'Visible',state) |
---|
| 4500 | |
---|
[12] | 4501 | %------------------------------------------------------------------------ |
---|
[2] | 4502 | function enable_patch1(handles) |
---|
[12] | 4503 | %------------------------------------------------------------------------ |
---|
[2] | 4504 | global patch_new_exe |
---|
| 4505 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 4506 | set(handles.rho_patch1,'Visible','on') |
---|
| 4507 | set(handles.rho_text1,'Visible','on') |
---|
| 4508 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4509 | set(handles.thresh_text1,'Visible','on') |
---|
| 4510 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4511 | set(handles.subdomain_text1,'Visible','on') |
---|
| 4512 | set(handles.nx_patch1,'Visible','on') |
---|
| 4513 | set(handles.ny_patch1,'Visible','on') |
---|
| 4514 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 4515 | set(handles.ny_patch1_title,'Visible','on') |
---|
| 4516 | if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[])) |
---|
| 4517 | set(handles.test_interp,'Visible','on'); |
---|
| 4518 | end |
---|
| 4519 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 4520 | set(handles.grid_patch1,'string','none'); |
---|
| 4521 | set(handles.grid_patch1,'Visible','on') |
---|
| 4522 | |
---|
[12] | 4523 | %------------------------------------------------------------------------ |
---|
[2] | 4524 | function desable_patch1(handles) |
---|
[12] | 4525 | %------------------------------------------------------------------------ |
---|
[2] | 4526 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4527 | set(handles.rho_patch1,'Visible','off') |
---|
| 4528 | set(handles.rho_text1,'Visible','off') |
---|
| 4529 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4530 | set(handles.thresh_text1,'Visible','off') |
---|
| 4531 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4532 | set(handles.subdomain_text1,'Visible','off') |
---|
| 4533 | set(handles.nx_patch1,'Visible','off') |
---|
| 4534 | set(handles.ny_patch1,'Visible','off') |
---|
| 4535 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 4536 | set(handles.ny_patch1_title,'Visible','off') |
---|
| 4537 | set(handles.test_interp,'Visible','off') |
---|
| 4538 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 4539 | set(handles.grid_patch1,'Visible','off') |
---|
| 4540 | |
---|
[12] | 4541 | %------------------------------------------------------------------------ |
---|
[2] | 4542 | function enable_civ2(handles,state) |
---|
[12] | 4543 | %------------------------------------------------------------------------ |
---|
[2] | 4544 | if isequal(state,0) |
---|
| 4545 | state='off'; |
---|
| 4546 | end |
---|
| 4547 | if isequal(state,1) |
---|
| 4548 | state='on'; |
---|
| 4549 | end |
---|
| 4550 | if isequal(state,'on') |
---|
| 4551 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4552 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4553 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4554 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4555 | else |
---|
| 4556 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4557 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4558 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4559 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4560 | end |
---|
| 4561 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4562 | set(handles.iby_civ2,'Visible',state) |
---|
| 4563 | set(handles.decimal,'Visible',state) |
---|
| 4564 | set(handles.deformation,'Visible',state) |
---|
| 4565 | set(handles.rho_civ2,'Visible',state) |
---|
| 4566 | set(handles.dx_civ2,'Visible',state) |
---|
| 4567 | set(handles.dy_civ2,'Visible',state) |
---|
| 4568 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4569 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4570 | set(handles.parameters,'Visible',state) |
---|
| 4571 | set(handles.grid,'Visible',state) |
---|
| 4572 | set(handles.parameters_text,'Visible',state) |
---|
| 4573 | set(handles.grid_text,'Visible',state) |
---|
| 4574 | set(handles.grid_civ2,'Visible',state) |
---|
| 4575 | set(handles.mask_civ2,'Visible',state) |
---|
| 4576 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4577 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4578 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4579 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4580 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4581 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4582 | if isequal(state,'off') |
---|
| 4583 | set(handles.MinIma2,'Visible','off') |
---|
| 4584 | set(handles.MaxIma2,'Visible','off') |
---|
| 4585 | set(handles.ImaThreshold2,'Value',0) |
---|
| 4586 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4587 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4588 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4589 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4590 | end |
---|
| 4591 | else |
---|
| 4592 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4593 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4594 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4595 | end |
---|
| 4596 | |
---|
[12] | 4597 | %------------------------------------------------------------------------ |
---|
[2] | 4598 | function enable_fix2(handles) |
---|
[12] | 4599 | %------------------------------------------------------------------------ |
---|
[2] | 4600 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4601 | set(handles.REMOVE2,'Visible','on') |
---|
| 4602 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4603 | set(handles.vec_F4,'Visible','on') |
---|
| 4604 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4605 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4606 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4607 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4608 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4609 | set(handles.mask_fix2,'Visible','on') |
---|
| 4610 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4611 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4612 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4613 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4614 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4615 | set(handles.ref_fix2,'Visible','on') |
---|
| 4616 | set(handles.inf_sup2,'Visible','on') |
---|
| 4617 | set(handles.field_ref2,'Visible','on') |
---|
| 4618 | |
---|
[12] | 4619 | %------------------------------------------------------------------------ |
---|
[2] | 4620 | function desable_fix2(handles) |
---|
[12] | 4621 | %------------------------------------------------------------------------ |
---|
[2] | 4622 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4623 | set(handles.REMOVE2,'Visible','off') |
---|
| 4624 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4625 | set(handles.vec_F4,'Visible','off') |
---|
| 4626 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4627 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4628 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4629 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4630 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4631 | set(handles.mask_fix2,'Visible','off') |
---|
| 4632 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4633 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4634 | set(handles.ref_fix2,'Visible','off') |
---|
| 4635 | set(handles.inf_sup2,'Visible','off') |
---|
| 4636 | set(handles.field_ref2,'Visible','off') |
---|
| 4637 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4638 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4639 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4640 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4641 | end |
---|
| 4642 | |
---|
[12] | 4643 | %------------------------------------------------------------------------ |
---|
[2] | 4644 | function enable_patch2(handles) |
---|
[12] | 4645 | %------------------------------------------------------------------------ |
---|
[2] | 4646 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 4647 | %set(handles.rho_patch2,'Visible','on') |
---|
| 4648 | set(handles.rho_text2,'Visible','on') |
---|
| 4649 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4650 | set(handles.thresh_text2,'Visible','on') |
---|
| 4651 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4652 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4653 | set(handles.nx_patch2,'Visible','on') |
---|
| 4654 | set(handles.ny_patch2,'Visible','on') |
---|
| 4655 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4656 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 4657 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 4658 | set(handles.grid_patch2,'Visible','on') |
---|
| 4659 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4660 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4661 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4662 | |
---|
[12] | 4663 | %------------------------------------------------------------------------ |
---|
[2] | 4664 | function desable_patch2(handles) |
---|
[12] | 4665 | %------------------------------------------------------------------------ |
---|
[2] | 4666 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4667 | set(handles.rho_patch2,'Visible','off') |
---|
| 4668 | set(handles.rho_text2,'Visible','off') |
---|
| 4669 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4670 | set(handles.thresh_text2,'Visible','off') |
---|
| 4671 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4672 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4673 | set(handles.nx_patch2,'Visible','off') |
---|
| 4674 | set(handles.ny_patch2,'Visible','off') |
---|
| 4675 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4676 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 4677 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 4678 | set(handles.grid_patch2,'Visible','off') |
---|
| 4679 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4680 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4681 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4682 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4683 | end |
---|
| 4684 | |
---|
[12] | 4685 | %------------------------------------------------------------------------ |
---|
[2] | 4686 | function enable_pair1(handles,state) |
---|
[12] | 4687 | %------------------------------------------------------------------------ |
---|
[2] | 4688 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4689 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4690 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4691 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4692 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4693 | set(handles.PAIR_txt,'Visible',state) |
---|
[12] | 4694 | %set(handles.dt_display_txt,'Visible',state) |
---|
[2] | 4695 | set(handles.dt_unit,'Visible',state) |
---|
| 4696 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4697 | |
---|
[12] | 4698 | %------------------------------------------------------------------------ |
---|
| 4699 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4700 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4701 | %------------------------------------------------------------------------ |
---|
[2] | 4702 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 4703 | par.ibx=num2str(ibx_val); |
---|
| 4704 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 4705 | par.iby=num2str(iby_val); |
---|
| 4706 | isx=get(handles.isx,'String'); |
---|
| 4707 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4708 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 4709 | isy=get(handles.isy,'String'); |
---|
| 4710 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4711 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 4712 | par.isx=get(handles.isx,'String'); |
---|
| 4713 | par.isy=get(handles.isy,'String'); |
---|
| 4714 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4715 | par.shifty=get(handles.shifty,'String'); |
---|
| 4716 | if isempty(str2num(par.isx)) |
---|
| 4717 | par.isx='41';%default |
---|
| 4718 | set(handles.isx,'String','41'); |
---|
| 4719 | end |
---|
| 4720 | if isempty(str2num(par.isy)) |
---|
| 4721 | par.isy='41'; %default |
---|
| 4722 | set(handles.isy,'String','41'); |
---|
[12] | 4723 | end |
---|
[2] | 4724 | if isempty(str2num(par.shiftx)) |
---|
| 4725 | par.shiftx='0';%default |
---|
| 4726 | set(handles.shiftx,'String','0'); |
---|
[12] | 4727 | end |
---|
[2] | 4728 | if isempty(str2num(par.shifty)) |
---|
| 4729 | par.shifty='0'; %default |
---|
| 4730 | set(handles.shifty,'String','0'); |
---|
[12] | 4731 | end |
---|
| 4732 | par.rho=get(handles.rho,'String'); |
---|
| 4733 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4734 | par.dy=get(handles.dy_civ1,'String'); |
---|
| 4735 | if isequal(str2num(par.dx),[]) |
---|
| 4736 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4737 | par.dx='0'; %just read by civ program, not used |
---|
| 4738 | else |
---|
| 4739 | par.dx='20';%default |
---|
| 4740 | set(handles.dx_civ1,'String','20'); |
---|
[2] | 4741 | end |
---|
[12] | 4742 | end |
---|
| 4743 | if isequal(str2num(par.dy),[]) |
---|
| 4744 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4745 | par.dy='0';%just read by civ program, not used |
---|
| 4746 | else |
---|
| 4747 | par.dy='20';%default |
---|
| 4748 | set(handles.dy_civ1_title,'String','20'); |
---|
[2] | 4749 | end |
---|
[12] | 4750 | end |
---|
| 4751 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4752 | par.pxcmy='1'; |
---|
[2] | 4753 | % end |
---|
[12] | 4754 | A=imread(file_ima);%read the first image to get the size |
---|
| 4755 | sizim=size(A); |
---|
| 4756 | par.npx=num2str(sizim(2)); |
---|
| 4757 | par.npy=num2str(sizim(1)); |
---|
| 4758 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4759 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4760 | par.gridflag='y'; |
---|
| 4761 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4762 | par.gridname='nogrid'; |
---|
| 4763 | par.gridflag='n'; |
---|
| 4764 | end |
---|
| 4765 | |
---|
| 4766 | %------------------------------------------------------------------------ |
---|
[2] | 4767 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4768 | %------------------------------------------------------------------------ |
---|
| 4769 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4770 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4771 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4772 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4773 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4774 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4775 | par.dy=get(handles.dy_civ2,'String'); |
---|
| 4776 | if isequal(str2num(par.dx),[]) |
---|
| 4777 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4778 | par.dx='0'; %just read by civ program, not used |
---|
| 4779 | else |
---|
| 4780 | par.dx='20';%default |
---|
| 4781 | set(handles.dx_civ2,'String','20'); |
---|
[2] | 4782 | end |
---|
[12] | 4783 | end |
---|
| 4784 | if isequal(str2num(par.dy),[]) |
---|
| 4785 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4786 | par.dy='0';%just read by civ program, not used |
---|
| 4787 | else |
---|
| 4788 | par.dy='20';%default |
---|
| 4789 | set(handles.dy_civ2,'String','20'); |
---|
[2] | 4790 | end |
---|
[12] | 4791 | end |
---|
| 4792 | par.pxcmx='1'; |
---|
| 4793 | par.pxcmy='1'; |
---|
| 4794 | A=imread(file_ima);%read the first image to get the size |
---|
| 4795 | sizim=size(A); |
---|
| 4796 | par.npx=num2str(sizim(2)); |
---|
| 4797 | par.npy=num2str(sizim(1)); |
---|
| 4798 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4799 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4800 | par.gridflag='y'; |
---|
| 4801 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4802 | par.gridname='nogrid'; |
---|
| 4803 | par.gridflag='n'; |
---|
| 4804 | end |
---|
[2] | 4805 | |
---|
[12] | 4806 | %------------------------------------------------------------------------ |
---|
| 4807 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[2] | 4808 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles) |
---|
[12] | 4809 | %------------------------------------------------------------------------ |
---|
[2] | 4810 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4811 | global civ1_exe Civ_exe sge%name of the executable for civ1 calculation |
---|
| 4812 | |
---|
| 4813 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4814 | |
---|
| 4815 | if isequal(par.Dt,'0') |
---|
| 4816 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4817 | end |
---|
[12] | 4818 | % |
---|
| 4819 | % textcmx={'############## CMX file';... |
---|
| 4820 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4821 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4822 | % 'XX' ;... |
---|
| 4823 | % ['Mask ' par.maskflag] ;... |
---|
| 4824 | % ['MaskName ' par.maskname];... |
---|
| 4825 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4826 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4827 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4828 | % ['RO ' par.rho];... |
---|
| 4829 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4830 | % 'XX 1.0';... |
---|
| 4831 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4832 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4833 | % 'XX 1';... |
---|
| 4834 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4835 | % ['Grid ' par.gridflag];... |
---|
| 4836 | % ['GridName ' par.gridname] ;... |
---|
| 4837 | % 'XX 85';... |
---|
| 4838 | % 'XX 1.0';... |
---|
| 4839 | % 'XX 1.0';... |
---|
| 4840 | % 'Hart 1';... |
---|
| 4841 | % 'DecimalShift 0';... |
---|
| 4842 | % 'Deformation 0';... |
---|
| 4843 | % 'CorrelationMin 0';... |
---|
| 4844 | % 'IntensityMin 0';... |
---|
| 4845 | % 'SeuilImage n';... |
---|
| 4846 | % 'SeuilImageValues 0 4096';... |
---|
| 4847 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4848 | % 'ImageUsedBefore null null'}; |
---|
| 4849 | % |
---|
| 4850 | % textout=char(textcmx); |
---|
[2] | 4851 | |
---|
[12] | 4852 | fid=fopen([filename '.cmx'],'w'); |
---|
| 4853 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4854 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
| 4855 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
| 4856 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4857 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4858 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
| 4859 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4860 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4861 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4862 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4863 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4864 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4865 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4866 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4867 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4868 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4869 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4870 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
| 4871 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4872 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4873 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4874 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4875 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4876 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4877 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4878 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4879 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4880 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4881 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4882 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4883 | fclose(fid); |
---|
| 4884 | |
---|
| 4885 | if sge |
---|
| 4886 | cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
| 4887 | else |
---|
| 4888 | cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4889 | end |
---|
| 4890 | if(isunix) |
---|
| 4891 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4892 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
| 4893 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
| 4894 | else |
---|
| 4895 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log']; |
---|
| 4896 | end |
---|
[2] | 4897 | |
---|
[12] | 4898 | %------------------------------------------------------------------------ |
---|
| 4899 | % --- CIV1 Unified |
---|
[2] | 4900 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
[12] | 4901 | %------------------------------------------------------------------------ |
---|
[2] | 4902 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4903 | global civ1_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4904 | |
---|
| 4905 | civ1.image1=par.filename_ima_a; |
---|
| 4906 | civ1.image2=par.filename_ima_b; |
---|
| 4907 | civ1.imageSize_X=par.npx; |
---|
| 4908 | civ1.imageSize_Y=par.npy; |
---|
| 4909 | civ1.outputFileName=[filename '.nc']; |
---|
| 4910 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4911 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4912 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4913 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4914 | civ1.globalShift_X=par.shiftx; |
---|
| 4915 | civ1.globalShift_Y=par.shifty; |
---|
| 4916 | civ1.ro=par.rho; |
---|
| 4917 | civ1.hart='y'; |
---|
| 4918 | if isequal(par.gridflag,'y') |
---|
| 4919 | civ1.grid=par.gridname; |
---|
| 4920 | else |
---|
| 4921 | civ1.grid='n'; |
---|
| 4922 | civ1.gridSpacing_X=par.dx; |
---|
| 4923 | civ1.gridSpacing_Y=par.dy; |
---|
| 4924 | end |
---|
| 4925 | if isequal(par.maskflag,'y') |
---|
| 4926 | civ1.mask=par.maskname; |
---|
| 4927 | end |
---|
| 4928 | civ1.dt=par.Dt; |
---|
| 4929 | civ1.unit='pixel'; |
---|
| 4930 | civ1.absolut_time_T0=par.T0; |
---|
| 4931 | civ1.pixcmx=par.pxcmx; |
---|
| 4932 | civ1.pixcmy=par.pxcmy; |
---|
| 4933 | civ1.convectFlow='n'; |
---|
| 4934 | |
---|
| 4935 | xml_civ1_parameters=civ1; |
---|
[12] | 4936 | |
---|
| 4937 | %------------------------------------------------------------------------ |
---|
| 4938 | % --- CIV2 Unified |
---|
[2] | 4939 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
[12] | 4940 | %------------------------------------------------------------------------ |
---|
[2] | 4941 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4942 | global civ2_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4943 | |
---|
| 4944 | civ2.image1=par.filename_ima_a; |
---|
| 4945 | civ2.image2=par.filename_ima_b; |
---|
| 4946 | civ2.imageSize_X=par.npx; |
---|
| 4947 | civ2.imageSize_Y=par.npy; |
---|
| 4948 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4949 | civ2.outputFileName=[filename '.nc']; |
---|
| 4950 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4951 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4952 | civ2.ro=par.rho; |
---|
| 4953 | %civ2.decimalShift=par.decimal; |
---|
| 4954 | %civ2.deformation=par.deformation; |
---|
| 4955 | if isequal(par.decimal,'1') |
---|
| 4956 | civ2.decimalShift='y'; |
---|
| 4957 | else |
---|
| 4958 | civ2.decimalShift='n'; |
---|
| 4959 | end |
---|
| 4960 | if isequal(par.deformation,'1') |
---|
| 4961 | civ2.deformation='y'; |
---|
| 4962 | else |
---|
| 4963 | civ2.deformation='n'; |
---|
| 4964 | end |
---|
| 4965 | if isequal(par.gridflag,'y') |
---|
| 4966 | civ2.grid=par.gridname; |
---|
| 4967 | else |
---|
| 4968 | civ2.grid='n'; |
---|
| 4969 | civ2.gridSpacing_X=par.dx; |
---|
| 4970 | civ2.gridSpacing_Y=par.dy; |
---|
| 4971 | end |
---|
| 4972 | civ2.gridSpacing_X='10'; |
---|
| 4973 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4974 | if isequal(par.maskflag,'y') |
---|
| 4975 | civ2.mask=par.maskname; |
---|
| 4976 | else |
---|
| 4977 | civ2.mask='n'; |
---|
| 4978 | end |
---|
| 4979 | civ2.dt=par.Dt; |
---|
| 4980 | civ2.unit='pixel'; |
---|
| 4981 | civ2.absolut_time_T0=par.T0; |
---|
| 4982 | civ2.pixcmx=par.pxcmx; |
---|
| 4983 | civ2.pixcmy=par.pxcmy; |
---|
| 4984 | civ2.convectFlow='n'; |
---|
| 4985 | civ2.pixcmx=par.pxcmx; |
---|
| 4986 | civ2.pixcmy=par.pxcmy; |
---|
| 4987 | civ2.convectFlow='n'; |
---|
| 4988 | |
---|
[12] | 4989 | %------------------------------------------------------------------------ |
---|
| 4990 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[2] | 4991 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par) |
---|
[12] | 4992 | %------------------------------------------------------------------------ |
---|
[2] | 4993 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4994 | global civ2_exe sge%name of the executable for civ1 calculation |
---|
| 4995 | if isequal(par.Dt,'0') |
---|
| 4996 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4997 | end |
---|
[12] | 4998 | textcmx=['############## CMX file' '\n'... |
---|
| 4999 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 5000 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 5001 | 'XX' '\n'... |
---|
| 5002 | ['Mask ' par.maskflag] '\n'... |
---|
| 5003 | ['MaskName ' par.maskname] '\n'... |
---|
| 5004 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
| 5005 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 5006 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 5007 | ['RO ' par.rho] '\n'... |
---|
| 5008 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 5009 | 'XX 1.0' '\n'... |
---|
| 5010 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 5011 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 5012 | 'XX 1' '\n'... |
---|
| 5013 | ['ShiftXY 0 0'] '\n'... |
---|
| 5014 | ['Grid ' par.gridflag] '\n'... |
---|
| 5015 | ['GridName ' par.gridname] '\n'... |
---|
| 5016 | 'XX 85' '\n'... |
---|
| 5017 | 'XX 1.0' '\n'... |
---|
| 5018 | 'XX 1.0' '\n'... |
---|
| 5019 | 'Hart 1' '\n'... |
---|
| 5020 | ['DecimalShift ' par.decimal] '\n'... |
---|
| 5021 | ['Deformation ' par.deformation] '\n'... |
---|
| 5022 | 'CorrelationMin 0' '\n'... |
---|
| 5023 | 'IntensityMin 0' '\n'... |
---|
| 5024 | 'SeuilImage n' '\n'... |
---|
| 5025 | 'SeuilImageValues 0 4096' '\n'... |
---|
| 5026 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 5027 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 5028 | textout=char(textcmx); |
---|
| 5029 | fid=fopen([filename_cmx '2'],'w'); |
---|
| 5030 | fprintf(fid,textout); |
---|
| 5031 | fclose(fid) |
---|
| 5032 | if sge |
---|
| 5033 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 5034 | else |
---|
| 5035 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 5036 | end |
---|
[2] | 5037 | |
---|
[12] | 5038 | %------------------------------------------------------------------------ |
---|
[2] | 5039 | % --- Executes on button press in HELP. |
---|
| 5040 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 5041 | %------------------------------------------------------------------------ |
---|
[2] | 5042 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 5043 | pathelp=fileparts(path_to_uvmat); |
---|
[45] | 5044 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html') |
---|
[36] | 5045 | 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] | 5046 | else |
---|
[36] | 5047 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 5048 | web([helpfile '#civ']) |
---|
[2] | 5049 | end |
---|
| 5050 | |
---|
[12] | 5051 | %------------------------------------------------------------------------ |
---|
[2] | 5052 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 5053 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 5054 | %------------------------------------------------------------------------ |
---|
[2] | 5055 | %num is the view number needed for an avi movie |
---|
[45] | 5056 | switch type_ima |
---|
| 5057 | case 'movie' |
---|
| 5058 | A=read(movieobject,num); |
---|
| 5059 | case 'avi' |
---|
| 5060 | mov=aviread(filename,num); |
---|
| 5061 | A=frame2im(mov(1)); |
---|
| 5062 | case 'multimage' |
---|
| 5063 | A=imread(filename,num); |
---|
| 5064 | case 'image' |
---|
| 5065 | A=imread(filename); |
---|
| 5066 | end |
---|
| 5067 | siz=size(A); |
---|
| 5068 | if length(siz)==3;%color images |
---|
[2] | 5069 | A=sum(double(A),3); |
---|
| 5070 | A=uint16(A); |
---|
| 5071 | end |
---|
| 5072 | |
---|
[12] | 5073 | %------------------------------------------------------------------------ |
---|
[2] | 5074 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 5075 | %------------------------------------------------------------------------ |
---|
[2] | 5076 | mode_list=get(handles.mode,'String'); |
---|
| 5077 | mode_value=get(handles.mode,'Value'); |
---|
| 5078 | mode=mode_list{mode_value}; |
---|
[45] | 5079 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 5080 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[45] | 5081 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 5082 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5083 | end |
---|
| 5084 | |
---|
[12] | 5085 | %------------------------------------------------------------------------ |
---|
[2] | 5086 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 5087 | %------------------------------------------------------------------------ |
---|
[2] | 5088 | mode_list=get(handles.mode,'String'); |
---|
| 5089 | mode_value=get(handles.mode,'Value'); |
---|
| 5090 | mode=mode_list{mode_value}; |
---|
[45] | 5091 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 5092 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5093 | end |
---|
[45] | 5094 | if isequal(mode,'series(Dj)') || ... |
---|
| 5095 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 5096 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5097 | end |
---|
[12] | 5098 | |
---|
| 5099 | %------------------------------------------------------------------------ |
---|
[2] | 5100 | % --- Executes on button press in compare. |
---|
| 5101 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 5102 | %------------------------------------------------------------------------ |
---|
[2] | 5103 | test=get(handles.compare,'Value'); |
---|
| 5104 | if test==2 || test==3 |
---|
| 5105 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5106 | browse=get(handles.browse_root,'Userdata'); |
---|
| 5107 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 5108 | set(handles.browse_root,'UserData',browse); |
---|
| 5109 | set(handles.sub_txt,'Visible','on') |
---|
| 5110 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
| 5111 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 5112 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 5113 | set(handles.mode,'Visible','off') |
---|
| 5114 | if test==2 |
---|
| 5115 | set(handles.mode,'Visible','off') |
---|
| 5116 | else |
---|
| 5117 | set(handles.mode,'Visible','on') |
---|
| 5118 | end |
---|
| 5119 | |
---|
| 5120 | % open an image file with the browser |
---|
| 5121 | ind_opening=1;%default |
---|
| 5122 | browse.incr_pair=[0 0]; %default |
---|
| 5123 | oldfile=get(handles.displ_filebase,'String'); |
---|
| 5124 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 5125 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 5126 | '*.*', 'All Files (*.*)'}; |
---|
| 5127 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 5128 | fileinput=[PathName FileName];%complete file name |
---|
| 5129 | sizf=size(fileinput); |
---|
| 5130 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5131 | [path,name,ext]=fileparts(fileinput); |
---|
| 5132 | [path1]=fileparts(filebase); |
---|
| 5133 | if ~strcmp(path1,path) |
---|
| 5134 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
| 5135 | return |
---|
| 5136 | end |
---|
| 5137 | set(handles.displ_filebase2,'String',name); |
---|
| 5138 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 5139 | browse=get(handles.browse_root,'UserData'); |
---|
| 5140 | browse.nom_type_ima_1=nom_type; |
---|
| 5141 | set(handles.browse_root,'UserData',browse) |
---|
| 5142 | |
---|
| 5143 | %check image extension |
---|
| 5144 | if ~strcmp(ext,get(handles.ext_ima,'String')) |
---|
| 5145 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 5146 | return |
---|
| 5147 | end |
---|
| 5148 | |
---|
| 5149 | %check image size |
---|
| 5150 | A=imread(fileinput); |
---|
| 5151 | npxy=get(handles.ext_ima,'UserData'); |
---|
| 5152 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 5153 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 5154 | return |
---|
| 5155 | end |
---|
| 5156 | else |
---|
| 5157 | set(handles.mode,'Visible','on') |
---|
| 5158 | set(handles.displ_filebase2,'Visible','Off'); |
---|
| 5159 | set(handles.sub_txt,'Visible','off') |
---|
| 5160 | set(handles.displ_filebase2,'String',[]); |
---|
| 5161 | mode_store=get(handles.compare,'UserData'); |
---|
| 5162 | set(handles.mode,'String',mode_store) |
---|
| 5163 | set(handles.test_stereo1,'Value',0) |
---|
| 5164 | set(handles.test_stereo2,'Value',0) |
---|
| 5165 | end |
---|
| 5166 | mode_Callback(hObject, eventdata, handles) |
---|
| 5167 | |
---|
[12] | 5168 | %------------------------------------------------------------------------ |
---|
[2] | 5169 | % --- Executes on button press in get_ref_fix1. |
---|
| 5170 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5171 | %------------------------------------------------------------------------ |
---|
[2] | 5172 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5173 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5174 | {'*.nc', ' (*.nc)'; |
---|
| 5175 | '*.nc', 'netcdf files '; ... |
---|
| 5176 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5177 | 'Pick a file',filebase); |
---|
| 5178 | |
---|
| 5179 | fileinput=[PathName FileName]; |
---|
| 5180 | sizf=size(fileinput); |
---|
| 5181 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5182 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5183 | ref.filebase=fullfile(Path,File); |
---|
| 5184 | ref.num_a=stra2num(str_a); |
---|
| 5185 | ref.num_b=stra2num(str_b); |
---|
| 5186 | ref.num1=str2num(field_count); |
---|
| 5187 | ref.num2=str2num(str2); |
---|
| 5188 | browse=[];%initialisation |
---|
| 5189 | if ~isequal(ref.ext,'.nc') |
---|
| 5190 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5191 | return |
---|
| 5192 | end |
---|
| 5193 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5194 | set(handles.ref_fix1,'UserData',ref) |
---|
| 5195 | menu_field{1}='civ1'; |
---|
| 5196 | Data=nc2struct(fileinput,[]); |
---|
[45] | 5197 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 5198 | menu_field{2}='filter1'; |
---|
| 5199 | end |
---|
[45] | 5200 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 5201 | menu_field{3}='civ2'; |
---|
| 5202 | end |
---|
[45] | 5203 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 5204 | menu_field{4}='filter2'; |
---|
| 5205 | end |
---|
| 5206 | set(handles.field_ref1,'String',menu_field); |
---|
| 5207 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 5208 | set(handles.inf_sup1,'Value',2); |
---|
| 5209 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 5210 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 5211 | |
---|
| 5212 | %------------------------------------------------------------------------ |
---|
[2] | 5213 | % --- Executes on button press in get_ref_fix2. |
---|
| 5214 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5215 | %------------------------------------------------------------------------ |
---|
[2] | 5216 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 5217 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5218 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5219 | {'*.nc', ' (*.nc)'; |
---|
| 5220 | '*.nc', 'netcdf files '; ... |
---|
| 5221 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5222 | 'Pick a file',filebase); |
---|
| 5223 | fileinput=[PathName FileName]; |
---|
| 5224 | sizf=size(fileinput); |
---|
[45] | 5225 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 5226 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5227 | ref.filebase=fullfile(Path,File); |
---|
| 5228 | ref.num_a=stra2num(str_a); |
---|
| 5229 | ref.num_b=stra2num(str_b); |
---|
| 5230 | ref.num1=str2num(field_count); |
---|
| 5231 | ref.num2=str2num(str2); |
---|
| 5232 | browse=[];%initialisation |
---|
| 5233 | if ~isequal(ref.ext,'.nc') |
---|
| 5234 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5235 | return |
---|
| 5236 | end |
---|
| 5237 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5238 | set(handles.ref_fix2,'UserData',ref) |
---|
| 5239 | menu_field{1}='civ1'; |
---|
| 5240 | Data=nc2struct(fileinput,[]); |
---|
| 5241 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5242 | menu_field{2}='filter1'; |
---|
| 5243 | end |
---|
| 5244 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5245 | menu_field{3}='civ2'; |
---|
| 5246 | end |
---|
| 5247 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5248 | menu_field{4}='filter2'; |
---|
| 5249 | end |
---|
| 5250 | set(handles.field_ref2,'String',menu_field); |
---|
| 5251 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 5252 | set(handles.inf_sup2,'Value',2); |
---|
| 5253 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 5254 | set(handles.ref_fix2,'Enable','on') |
---|
| 5255 | set(handles.ref_fix2,'Visible','on') |
---|
| 5256 | set(handles.field_ref2,'Visible','on') |
---|
| 5257 | else |
---|
| 5258 | set(handles.ref_fix2,'Visible','off') |
---|
| 5259 | set(handles.field_ref2,'Visible','off') |
---|
| 5260 | end |
---|
| 5261 | |
---|
[12] | 5262 | %------------------------------------------------------------------------ |
---|
[2] | 5263 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5264 | %------------------------------------------------------------------------ |
---|
| 5265 | set(handles.inf_sup1,'Value',1); |
---|
| 5266 | set(handles.field_ref1,'Value',1) |
---|
| 5267 | set(handles.field_ref1,'String',{' '}) |
---|
| 5268 | set(handles.ref_fix1,'UserData',[]); |
---|
| 5269 | set(handles.ref_fix1,'String',''); |
---|
| 5270 | set(handles.thresh_vel1,'String','0'); |
---|
[2] | 5271 | |
---|
[12] | 5272 | %------------------------------------------------------------------------ |
---|
[2] | 5273 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5274 | %------------------------------------------------------------------------ |
---|
| 5275 | set(handles.inf_sup2,'Value',1); |
---|
| 5276 | set(handles.field_ref2,'Value',1) |
---|
| 5277 | set(handles.field_ref2,'String',{' '}) |
---|
| 5278 | set(handles.ref_fix2,'UserData',[]); |
---|
| 5279 | set(handles.ref_fix2,'String',''); |
---|
| 5280 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 5281 | |
---|
[12] | 5282 | %------------------------------------------------------------------------ |
---|
[2] | 5283 | % transform letters to numbers |
---|
| 5284 | function numres=stra2num(str) |
---|
[12] | 5285 | %------------------------------------------------------------------------ |
---|
[2] | 5286 | numres=double(str)-96; |
---|
| 5287 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 5288 | numres=str2num(str); |
---|
| 5289 | end |
---|
| 5290 | |
---|
[12] | 5291 | %------------------------------------------------------------------------ |
---|
[2] | 5292 | % --- Executes on button press in test_stereo1. |
---|
| 5293 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 5294 | %------------------------------------------------------------------------ |
---|
[2] | 5295 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 5296 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 5297 | set(handles.rho_patch1,'Visible','on') |
---|
| 5298 | else |
---|
| 5299 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 5300 | set(handles.rho_patch1,'Visible','off') |
---|
| 5301 | end |
---|
| 5302 | |
---|
[12] | 5303 | %------------------------------------------------------------------------ |
---|
[2] | 5304 | % --- Executes on button press in test_stereo2. |
---|
| 5305 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 5306 | %------------------------------------------------------------------------ |
---|
[2] | 5307 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 5308 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 5309 | set(handles.rho_patch2,'Visible','on') |
---|
| 5310 | else |
---|
| 5311 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 5312 | set(handles.rho_patch2,'Visible','off') |
---|
| 5313 | end |
---|
| 5314 | |
---|
[12] | 5315 | %------------------------------------------------------------------------ |
---|
[2] | 5316 | % --- Executes on button press in ImaThreshold. |
---|
| 5317 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 5318 | %------------------------------------------------------------------------ |
---|
[2] | 5319 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 5320 | set(handles.MinIma,'Visible','on') |
---|
| 5321 | set(handles.MaxIma,'Visible','on') |
---|
| 5322 | else |
---|
| 5323 | set(handles.MinIma,'Visible','off') |
---|
| 5324 | set(handles.MaxIma,'Visible','off') |
---|
| 5325 | end |
---|
| 5326 | |
---|
[12] | 5327 | %------------------------------------------------------------------------ |
---|
[2] | 5328 | % --- Executes on button press in ImaThreshold2. |
---|
| 5329 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 5330 | %------------------------------------------------------------------------ |
---|
[2] | 5331 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 5332 | set(handles.MinIma2,'Visible','on') |
---|
| 5333 | set(handles.MaxIma2,'Visible','on') |
---|
| 5334 | else |
---|
| 5335 | set(handles.MinIma2,'Visible','off') |
---|
| 5336 | set(handles.MaxIma2,'Visible','off') |
---|
| 5337 | end |
---|
| 5338 | |
---|