[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 | else |
---|
| 117 | syst='WIN'; |
---|
[54] | 118 | end |
---|
| 119 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 120 | if exist(xmlfile,'file') |
---|
| 121 | try |
---|
| 122 | t=xmltree(xmlfile); |
---|
| 123 | sparam=convert(t); |
---|
| 124 | catch |
---|
| 125 | errormsg={[' Problem for reading ' xmlfile]; lasterr}; |
---|
[2] | 126 | end |
---|
[54] | 127 | else |
---|
| 128 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[2] | 129 | end |
---|
[45] | 130 | display(syst) |
---|
| 131 | if ~isempty(errormsg) |
---|
| 132 | msgbox_uvmat('ERROR',errormsg); |
---|
| 133 | end |
---|
[2] | 134 | patch_new_exe=''; |
---|
| 135 | % todo_patch=''; |
---|
| 136 | sge=0; |
---|
| 137 | |
---|
| 138 | if isfield(sparam,'PatchNew_exe') |
---|
| 139 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 140 | end |
---|
| 141 | if isfield(sparam,'Todo_path') |
---|
| 142 | todo_path=sparam.Todo_path; |
---|
| 143 | end |
---|
| 144 | if isfield(sparam,'SGE') |
---|
| 145 | sge=str2num(sparam.SGE); |
---|
| 146 | end |
---|
| 147 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 148 | test_batch=1; |
---|
| 149 | if ~sge |
---|
[12] | 150 | if isequal(todo_path,'') || isequal(todo_path,[]) |
---|
[54] | 151 | display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM.xml']) |
---|
[12] | 152 | test_batch=0; |
---|
| 153 | end |
---|
| 154 | if exist(name_todo,'file')~=2 |
---|
| 155 | msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']); |
---|
| 156 | % test_batch=0; % Problems to detect file on linux/nfs filesystems |
---|
| 157 | end |
---|
[2] | 158 | end |
---|
| 159 | if test_batch==0 |
---|
| 160 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 161 | end |
---|
| 162 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 163 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 164 | |
---|
| 165 | %initiate advised operations |
---|
| 166 | if isequal(ind_opening,[]) |
---|
| 167 | ind_opening=1; % default |
---|
| 168 | end |
---|
| 169 | % set default operation options |
---|
| 170 | enable_civ1(handles,'off') |
---|
| 171 | enable_civ2(handles,'off') |
---|
| 172 | enable_pair1(handles,'on') |
---|
| 173 | enable_fix1(handles,'off') |
---|
| 174 | desable_patch1(handles) |
---|
| 175 | desable_fix2(handles) |
---|
| 176 | desable_patch2(handles) |
---|
| 177 | set(handles.CIV1,'Value',0) |
---|
| 178 | set(handles.FIX1,'Value',0) |
---|
| 179 | set(handles.PATCH1,'Value',0) |
---|
| 180 | set(handles.CIV2,'Value',0) |
---|
| 181 | set(handles.FIX2,'Value',0) |
---|
| 182 | set(handles.PATCH2,'Value',0) |
---|
| 183 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 184 | if isequal(ind_opening,1) |
---|
| 185 | set(handles.CIV1,'Value',1) |
---|
| 186 | enable_civ1(handles,'on') |
---|
| 187 | elseif isequal(ind_opening,2) |
---|
| 188 | set(handles.FIX1,'Value',1) |
---|
| 189 | enable_fix1(handles,'on') |
---|
| 190 | elseif isequal(ind_opening,3) |
---|
| 191 | set(handles.PATCH1,'Value',1) |
---|
| 192 | enable_patch1(handles) |
---|
| 193 | elseif isequal(ind_opening,4) |
---|
| 194 | set(handles.CIV2,'Value',1) |
---|
| 195 | enable_civ2(handles,1) |
---|
| 196 | elseif isequal(ind_opening,5) |
---|
| 197 | set(handles.FIX2,'Value',1) |
---|
| 198 | enable_fix2(handles) |
---|
| 199 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 200 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 201 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 202 | enable_pair1(handles,'off') |
---|
| 203 | elseif isequal(ind_opening,6) |
---|
| 204 | set(handles.PATCH2,'Value',1) |
---|
| 205 | enable_patch2(handles) |
---|
| 206 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 207 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 208 | enable_pair1(handles,'off') |
---|
| 209 | end |
---|
| 210 | |
---|
| 211 | % set the range of fields (1:1 by default) and selected pair |
---|
[12] | 212 | if isempty(num2)||isequal(num2,num1) |
---|
[2] | 213 | num_ref_i=num1; |
---|
| 214 | else |
---|
| 215 | num_ref_i=floor((num1+num2)/2); |
---|
| 216 | browse.incr_pair(1)=num2-num1; |
---|
| 217 | browse.incr_pair(2)=0; |
---|
| 218 | end |
---|
[12] | 219 | if isempty(num_b)||isequal(num_a,num_b) |
---|
[2] | 220 | if isempty(num_a) |
---|
| 221 | num_ref_j=1; |
---|
| 222 | else |
---|
| 223 | num_ref_j=num_a; |
---|
| 224 | end |
---|
| 225 | else |
---|
| 226 | num_ref_j=floor((num_a+num_b)/2); |
---|
| 227 | browse.incr_pair(2)=num_b-num_a; |
---|
| 228 | end |
---|
| 229 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 230 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 231 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 232 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 233 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 234 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
| 235 | set(handles.browse_root,'UserData',browse); |
---|
| 236 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 237 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 238 | end |
---|
| 239 | |
---|
| 240 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 241 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 242 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 243 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 244 | |
---|
[12] | 245 | %------------------------------------------------------------------------ |
---|
[2] | 246 | % --- Outputs from this function are returned to the command line. |
---|
| 247 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 248 | %------------------------------------------------------------------------ |
---|
[2] | 249 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 250 | % hObject handle to figure |
---|
| 251 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 252 | % handles structure with handles and user data (see GUIDATA) |
---|
| 253 | % Get default command line output from handles structure |
---|
| 254 | varargout{1} = handles.output; |
---|
| 255 | |
---|
[12] | 256 | %------------------------------------------------------------------------ |
---|
[2] | 257 | % --- Executes on button press in browse_root. |
---|
| 258 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 259 | %------------------------------------------------------------------------ |
---|
[2] | 260 | %get the input file properties |
---|
| 261 | filebase=get(handles.displ_filebase,'String'); |
---|
| 262 | oldfile=''; %default |
---|
[39] | 263 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 264 | dir_perso=prefdir; |
---|
| 265 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 266 | display(profil_perso) |
---|
| 267 | if exist(profil_perso,'file') |
---|
| 268 | h=load (profil_perso); |
---|
| 269 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 270 | oldfile=h.filebase; |
---|
| 271 | end |
---|
| 272 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 273 | oldfile=h.RootPath; |
---|
| 274 | end |
---|
| 275 | end |
---|
| 276 | else |
---|
| 277 | oldfile=filebase; |
---|
| 278 | end |
---|
| 279 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 280 | ind_opening=1;%default |
---|
| 281 | browse.incr_pair=[0 0]; %default |
---|
| 282 | if testall |
---|
| 283 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 284 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 285 | else % menu selecting only .civ or .avi files |
---|
| 286 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 287 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 288 | '*.*', 'All Files (*.*)'}; |
---|
| 289 | end |
---|
| 290 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 291 | fileinput=[PathName FileName];%complete file name |
---|
| 292 | sizf=size(fileinput); |
---|
| 293 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 294 | [path,name,ext]=fileparts(fileinput); |
---|
| 295 | testeditxml=0; |
---|
| 296 | if isequal(ext,'.xml') |
---|
| 297 | testeditxml=1; |
---|
| 298 | t_browse=xmltree(fileinput); |
---|
| 299 | head_element=get(t_browse,1); |
---|
[45] | 300 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 301 | testeditxml=0; |
---|
| 302 | end |
---|
| 303 | end |
---|
[45] | 304 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[2] | 305 | heditxml=editxml({fileinput}); |
---|
| 306 | set(heditxml,'Tag','browser') |
---|
| 307 | waitfor(heditxml,'Tag','idle') |
---|
| 308 | if ~ishandle(heditxml) |
---|
| 309 | return |
---|
| 310 | end |
---|
| 311 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 312 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 313 | fileinput=get(attr,'UserData'); |
---|
| 314 | if ~exist(fileinput,'file') |
---|
| 315 | return |
---|
| 316 | end |
---|
| 317 | end |
---|
[54] | 318 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 319 | filebase=fullfile(RootPath,RootFile); |
---|
[54] | 320 | % if isequal(nom_type,'*')% all fields in a single file ( movie files) |
---|
| 321 | % num_i1=1;num_i2=1;num_j1=1;num_j2=1; |
---|
| 322 | % else |
---|
| 323 | num_i1=stra2num(str1); |
---|
| 324 | if isempty(num_i1),num_i1=1;end |
---|
| 325 | num_i2=stra2num(str2); |
---|
| 326 | if isempty(num_i2),num_i2=1;end |
---|
| 327 | num_j1=stra2num(str_a); |
---|
| 328 | if isempty(num_j1),num_j1=1;end |
---|
| 329 | num_j2=stra2num(str_b); |
---|
| 330 | if isempty(num_j2),num_j2=1;end |
---|
[2] | 331 | if isequal(get(handles.compare,'Value'),1) |
---|
| 332 | browse=[];%initialisation |
---|
| 333 | else |
---|
| 334 | browse=get(handles.browse_root,'UserData'); |
---|
| 335 | end |
---|
[45] | 336 | if length(ext)>1 && (~isempty(imformats(ext([2:end])))||... |
---|
| 337 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
[2] | 338 | set(handles.ext_ima,'String',ext) |
---|
| 339 | browse.nom_type_ima=nom_type; |
---|
[45] | 340 | browse.field_count=num_i1; |
---|
| 341 | % A=imread(fileinput); |
---|
| 342 | % npxy=size(A); |
---|
| 343 | % set(handles.ext_ima,'UserData',npxy) |
---|
[2] | 344 | end |
---|
| 345 | set(handles.ImaDoc,'String',ext); |
---|
| 346 | |
---|
| 347 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 348 | if isequal(ext,'.nc') |
---|
| 349 | browse.nom_type_nc=nom_type; |
---|
| 350 | ind_opening=2;% propose 'fix' as the default option |
---|
| 351 | Data=nc2struct(fileinput,[]); |
---|
| 352 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
| 353 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 354 | ind_opening=3; |
---|
| 355 | end |
---|
| 356 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 357 | ind_opening=4; |
---|
| 358 | end |
---|
| 359 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 360 | ind_opening=5; |
---|
| 361 | end |
---|
| 362 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 363 | ind_opening=6; |
---|
| 364 | end |
---|
| 365 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 366 | else |
---|
| 367 | ind_opening=3; %GUI used only for patch |
---|
| 368 | testciv=0; |
---|
| 369 | end |
---|
| 370 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 371 | set(handles.subdir_civ2,'String',subdir); |
---|
| 372 | browse.testciv=testciv; |
---|
| 373 | browse.ind_opening=ind_opening; |
---|
| 374 | end |
---|
| 375 | set(handles.displ_filebase,'String',filebase); |
---|
| 376 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 377 | if ~isempty(num_i1) |
---|
| 378 | ref_i=num_i1; |
---|
| 379 | if ~isempty(num_i2) |
---|
| 380 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 381 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 382 | browse.incr_pair(2)=0; |
---|
| 383 | end |
---|
| 384 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 385 | set(handles.last_i,'String',num2str(ref_i)); |
---|
| 386 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 387 | end |
---|
[45] | 388 | if isempty(num_j1) |
---|
[2] | 389 | set(handles.ref_j,'String','1'); |
---|
| 390 | else |
---|
[45] | 391 | ref_j=num_j1; |
---|
| 392 | if ~isempty(num_j2) |
---|
| 393 | ref_j=floor((num_j1+num_j2)/2); |
---|
| 394 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 395 | end |
---|
| 396 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 397 | set(handles.last_j,'String',num2str(ref_j)); |
---|
| 398 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
| 399 | end |
---|
| 400 | |
---|
| 401 | % set default operation options |
---|
| 402 | enable_civ1(handles,'off') |
---|
| 403 | enable_civ2(handles,'off') |
---|
| 404 | enable_pair1(handles,'on') |
---|
| 405 | enable_fix1(handles,'off') |
---|
| 406 | desable_patch1(handles) |
---|
| 407 | desable_fix2(handles) |
---|
| 408 | desable_patch2(handles) |
---|
| 409 | set(handles.CIV1,'Value',0) |
---|
| 410 | set(handles.FIX1,'Value',0) |
---|
| 411 | set(handles.PATCH1,'Value',0) |
---|
| 412 | set(handles.CIV2,'Value',0) |
---|
| 413 | set(handles.FIX2,'Value',0) |
---|
| 414 | set(handles.PATCH2,'Value',0) |
---|
| 415 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 416 | if isequal(ind_opening,1) |
---|
| 417 | set(handles.CIV1,'Value',1) |
---|
| 418 | enable_civ1(handles,'on') |
---|
| 419 | elseif isequal(ind_opening,2) |
---|
| 420 | set(handles.FIX1,'Value',1) |
---|
| 421 | enable_fix1(handles,'on') |
---|
| 422 | elseif isequal(ind_opening,3) |
---|
| 423 | set(handles.PATCH1,'Value',1) |
---|
| 424 | enable_patch1(handles) |
---|
| 425 | elseif isequal(ind_opening,4) |
---|
| 426 | set(handles.CIV2,'Value',1) |
---|
| 427 | enable_civ2(handles,1) |
---|
| 428 | elseif isequal(ind_opening,5) |
---|
| 429 | enable_pair1(handles,'off') |
---|
| 430 | set(handles.FIX2,'Value',1) |
---|
| 431 | enable_fix2(handles) |
---|
| 432 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 433 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 434 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 435 | elseif isequal(ind_opening,6) |
---|
| 436 | enable_pair1(handles,'off') |
---|
| 437 | set(handles.PATCH2,'Value',1) |
---|
| 438 | enable_patch2(handles) |
---|
| 439 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 440 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 441 | end |
---|
| 442 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 443 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 444 | set(handles.ImaDoc,'UserData',testall); |
---|
| 445 | |
---|
| 446 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 447 | |
---|
[12] | 448 | %------------------------------------------------------------------------ |
---|
[2] | 449 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 450 | %------------------------------------------------------------------------ |
---|
[2] | 451 | displ_filebase_Callback(hObject, eventdata, handles) |
---|
| 452 | |
---|
[12] | 453 | %------------------------------------------------------------------------ |
---|
[54] | 454 | % --- function activated when a new filebase (image series) is introduced |
---|
[2] | 455 | function displ_filebase_Callback(hObject, eventdata, handles) |
---|
[12] | 456 | %------------------------------------------------------------------------ |
---|
[2] | 457 | global test_batch |
---|
| 458 | set(handles.compare,'Visible','on') |
---|
| 459 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 460 | nom_type_ima=[];%default |
---|
| 461 | field_count=1;%default |
---|
| 462 | nom_type_nc=[]; |
---|
| 463 | time=[]; |
---|
| 464 | TimeUnit=[]; %default |
---|
| 465 | CoordUnit=[];%default |
---|
| 466 | pxcmx_search=[];%default |
---|
| 467 | pxcmy_search=[];%default |
---|
| 468 | filebase=get(handles.displ_filebase,'String'); |
---|
| 469 | |
---|
| 470 | ext=get(handles.ImaDoc,'String'); |
---|
| 471 | browse=get(handles.browse_root,'UserData');%default |
---|
| 472 | if ~isempty(browse) |
---|
| 473 | if isfield(browse,'nom_type_ima') |
---|
[12] | 474 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[2] | 475 | end |
---|
| 476 | if isfield(browse,'field_count') |
---|
[12] | 477 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
[2] | 478 | end |
---|
| 479 | end |
---|
| 480 | |
---|
| 481 | %default first_i and j and increments |
---|
| 482 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
[12] | 483 | if isempty(first_i)|| first_i < 1 |
---|
[2] | 484 | first_i=1; %default first_i |
---|
| 485 | end |
---|
| 486 | last_i=str2num(get(handles.last_i,'String')); |
---|
[12] | 487 | if isempty(last_i)|| last_i < first_i |
---|
[2] | 488 | last_i=first_i; %default last_i |
---|
| 489 | end |
---|
| 490 | first_j=str2num(get(handles.first_j,'String')); |
---|
[39] | 491 | if isempty(first_j)|| first_j < 1 |
---|
[2] | 492 | first_j=1; %default first_j |
---|
| 493 | end |
---|
| 494 | last_j=str2num(get(handles.last_j,'String')); |
---|
[39] | 495 | if isempty(last_j)|| last_j < first_j |
---|
[2] | 496 | last_j=first_j; %default last_j |
---|
| 497 | end |
---|
| 498 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
[39] | 499 | if isempty(incr_i) || incr_i < 1; |
---|
[2] | 500 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 501 | end |
---|
| 502 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
[39] | 503 | if isempty(incr_j) || incr_j < 1; |
---|
[2] | 504 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 505 | end |
---|
| 506 | dt=[];%default |
---|
| 507 | testmode=0;%default |
---|
| 508 | nbfield=[]; %default |
---|
| 509 | nburst=[];%default |
---|
| 510 | pxcmx=1; |
---|
| 511 | pxcmy=1; |
---|
| 512 | |
---|
| 513 | %look for an image documentation file |
---|
| 514 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
| 515 | if exist([filebase '.xml'],'file') |
---|
| 516 | ext='.xml'; |
---|
| 517 | elseif exist([filebase '.civxml'],'file') |
---|
| 518 | ext='.civxml'; |
---|
| 519 | elseif exist([filebase '.civ'],'file') |
---|
| 520 | ext='.civ'; |
---|
| 521 | elseif exist([filebase '.avi'],'file') |
---|
| 522 | ext='.avi'; |
---|
| 523 | elseif exist([filebase '.AVI'],'file') |
---|
| 524 | ext='.AVI'; |
---|
| 525 | end |
---|
| 526 | set(handles.ImaDoc,'String',ext) |
---|
| 527 | end |
---|
| 528 | |
---|
| 529 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 530 | mode=''; %default |
---|
| 531 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 532 | drawnow |
---|
| 533 | %read the image documentation file if found |
---|
[12] | 534 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
[2] | 535 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 536 | set(handles.ref_j,'Visible','On') |
---|
| 537 | set(handles.dt,'Visible','Off') |
---|
[12] | 538 | set(handles.dt_text,'String','') |
---|
| 539 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
[2] | 540 | set(handles.ref_j,'Visible','Off') |
---|
| 541 | set(handles.dt,'Visible','Off') |
---|
| 542 | set(handles.dt_text,'String','ref. ind.') |
---|
| 543 | else |
---|
| 544 | set(handles.ref_i,'Visible','Off') |
---|
| 545 | set(handles.ref_j,'Visible','Off') |
---|
| 546 | set(handles.dt,'Visible','On') |
---|
| 547 | set(handles.dt_text,'String','dt(ms)=') |
---|
| 548 | end |
---|
[12] | 549 | testima_xml=0; |
---|
[2] | 550 | if isequal(ext,'.civxml')%TO ABANDON |
---|
| 551 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
| 552 | mode='pair j1-j2'; |
---|
| 553 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
| 554 | nom_type_ima='_i_j'; |
---|
| 555 | end |
---|
| 556 | elseif isequal(ext,'.xml') |
---|
| 557 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
| 558 | if isfield(XmlData,'Time') |
---|
| 559 | time=XmlData.Time; |
---|
[54] | 560 | nbfield=size(time,1); |
---|
| 561 | nburst=size(time,2); |
---|
[2] | 562 | end |
---|
| 563 | ext_ima_read=[]; |
---|
| 564 | nom_type_read=[]; |
---|
[12] | 565 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 566 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[39] | 567 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 568 | if ~exist(fullname,'file') |
---|
| 569 | % testima_xml=1; |
---|
| 570 | % else |
---|
[12] | 571 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 572 | end |
---|
[2] | 573 | end |
---|
| 574 | if isfield(XmlData,'Camera') |
---|
| 575 | if isfield(XmlData.Camera,'TimeUnit') |
---|
| 576 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 577 | end |
---|
| 578 | if isfield(XmlData.Camera,'ImageSize') |
---|
| 579 | ImageSize=XmlData.Camera.ImageSize; |
---|
| 580 | if ~isempty(ImageSize)&& ~isempty(ImageSize) |
---|
| 581 | xindex=findstr(ImageSize,'x'); |
---|
[45] | 582 | % if length(xindex)>=2 |
---|
| 583 | % npx=str2num(ImageSize(1:xindex(1)-1)); |
---|
| 584 | % npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1)); |
---|
| 585 | % end |
---|
[2] | 586 | end |
---|
| 587 | end |
---|
| 588 | end |
---|
| 589 | pxcmx_search=1; |
---|
| 590 | pxcmy_search=1; |
---|
| 591 | if isfield(XmlData,'GeometryCalib') |
---|
| 592 | tsai=XmlData.GeometryCalib; |
---|
| 593 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
| 594 | rot2D=tsai.R([1:2],[1,2]); |
---|
| 595 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 596 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
| 597 | end |
---|
| 598 | if isfield(tsai,'CoordUnit') |
---|
| 599 | CoordUnit=tsai.CoordUnit; |
---|
| 600 | end |
---|
| 601 | end |
---|
| 602 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
| 603 | if isempty(ext_ima) |
---|
| 604 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
| 605 | else %keep the image extension |
---|
| 606 | if ~strcmp(ext_ima_read,ext_ima) |
---|
| 607 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
| 608 | end |
---|
| 609 | end |
---|
| 610 | nom_type_ima=nom_type_read; |
---|
| 611 | end |
---|
| 612 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
| 613 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
[12] | 614 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 615 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
[2] | 616 | end |
---|
| 617 | % ext_ima='.png'; |
---|
| 618 | nom_type_ima='png_old'; |
---|
| 619 | elseif isequal(lower(ext),'.avi') |
---|
| 620 | nom_type_ima='*'; |
---|
| 621 | ext_ima=ext; |
---|
| 622 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 623 | dt=0.04;%default |
---|
| 624 | if exist([filebase ext],'file')==2 |
---|
| 625 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
| 626 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 627 | nbfield=info.NumFrames;%number of frames |
---|
| 628 | end |
---|
| 629 | time=(dt*[0:nbfield-1])';%list of image times |
---|
| 630 | set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
| 631 | end |
---|
| 632 | if isempty(time) |
---|
| 633 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 634 | end |
---|
| 635 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 636 | |
---|
[12] | 637 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
| 638 | if isempty(nom_type_ima) |
---|
| 639 | %look for double image series '_i_j' |
---|
| 640 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 641 | if isempty(dirima) |
---|
| 642 | % look for images series with sub marker '_' |
---|
| 643 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 644 | if isempty(dirima) |
---|
| 645 | % look for other images series |
---|
| 646 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
| 647 | if ~isempty(dirima) |
---|
| 648 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 649 | end |
---|
| 650 | else |
---|
| 651 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 652 | end |
---|
| 653 | else |
---|
| 654 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 655 | end |
---|
| 656 | end |
---|
| 657 | |
---|
[2] | 658 | % no image documentation file found: look for a series of existing images or .nc files |
---|
| 659 | if isempty(time) && ~isequal(ext,'.nc') |
---|
[12] | 660 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 661 | incr_pair=[0 0];%default |
---|
| 662 | if isfield(browse,'incr_pair') |
---|
| 663 | incr_pair=browse.incr_pair; |
---|
| 664 | end |
---|
| 665 | nbdetect=0;%test of detected images |
---|
| 666 | field_i=field_count; |
---|
| 667 | idetect=1; |
---|
| 668 | while idetect==1 %look for the maximum file number in the series |
---|
| 669 | field_i=field_i+1; |
---|
| 670 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
| 671 | if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 672 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 673 | nbdetect=1; |
---|
| 674 | else |
---|
| 675 | idetect=(exist(imagename,'file')==2); |
---|
| 676 | end |
---|
| 677 | %SEE CASE OF NETCDF FILES |
---|
| 678 | nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 679 | end |
---|
| 680 | nb_field=field_i;% last detected field number |
---|
| 681 | field_i=field_count;%look for the minimum file number in the series |
---|
| 682 | idetect=1; |
---|
| 683 | while idetect==1 |
---|
| 684 | field_i=field_i-1; |
---|
[2] | 685 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
[12] | 686 | if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 687 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 688 | nbdetect=1; |
---|
[2] | 689 | else |
---|
| 690 | idetect=(exist(imagename,'file')==2); |
---|
| 691 | end |
---|
[12] | 692 | nbdetect=nbdetect+idetect; |
---|
| 693 | end |
---|
| 694 | first_i=max(field_i+1,1); |
---|
| 695 | %determine the set of times and possible intervals for CIV |
---|
| 696 | dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 697 | time=(dt*[0:nb_field-1])'; |
---|
| 698 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 699 | end |
---|
| 700 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
| 701 | first_i=1; |
---|
| 702 | last_i=1; |
---|
| 703 | first_j=1; |
---|
| 704 | last_j=1; |
---|
| 705 | end |
---|
| 706 | if exist('time','var') |
---|
| 707 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 708 | nbfield=size(time,1); |
---|
| 709 | nbfield2=size(time,2); |
---|
| 710 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 711 | if isempty(TimeUnit) |
---|
[12] | 712 | set(handles.dt_unit,'String','dt in e-03'); |
---|
[2] | 713 | set(handles.TimeUnit,'String',''); |
---|
| 714 | else |
---|
[12] | 715 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
[2] | 716 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 717 | end |
---|
| 718 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 719 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 720 | end |
---|
| 721 | end |
---|
| 722 | set(handles.CoordUnit,'String',[CoordUnit '/']) |
---|
| 723 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 724 | % npxy=[npy npx]; |
---|
| 725 | set(handles.ext_ima,'String',ext_ima) |
---|
| 726 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 727 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 728 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 729 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 730 | browse.nom_type_ima=nom_type_ima; |
---|
| 731 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 732 | |
---|
| 733 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[41] | 734 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 735 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 736 | set(handles.mode,'Value',1) |
---|
[41] | 737 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
[2] | 738 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
| 739 | set(handles.mode,'Value',1) |
---|
| 740 | elseif (nbfield==1)% simple series in j |
---|
| 741 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 742 | set(handles.mode,'Value',1) |
---|
| 743 | else |
---|
| 744 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[41] | 745 | if nbfield2 <= 5 |
---|
| 746 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 747 | end |
---|
[41] | 748 | % else |
---|
| 749 | % if isequal(mode,'volume') |
---|
| 750 | % set(handles.mode,'Value',3) |
---|
| 751 | % elseif nbfield2 <= 5 |
---|
| 752 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 753 | % else |
---|
| 754 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 755 | % end |
---|
[2] | 756 | end |
---|
| 757 | |
---|
| 758 | %update the subdir |
---|
| 759 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 760 | listot=dir(pathdir); |
---|
| 761 | idir=0; |
---|
| 762 | listdir={''};%default |
---|
| 763 | for ilist=1:length(listot) |
---|
| 764 | if listot(ilist).isdir |
---|
| 765 | name=listot(ilist).name; |
---|
| 766 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 767 | idir=idir+1; |
---|
| 768 | listdir{idir,1}=listot(ilist).name; |
---|
| 769 | end |
---|
| 770 | end |
---|
| 771 | end |
---|
| 772 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 773 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 774 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
| 775 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
| 776 | %check wether the current subdir exists: |
---|
| 777 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 778 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 779 | |
---|
| 780 | mode_Callback(hObject, eventdata, handles) |
---|
| 781 | |
---|
| 782 | %%%%%% initialize waitbars and RUN button |
---|
| 783 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 784 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 785 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 786 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 787 | set(handles.RUN, 'Enable','On') |
---|
| 788 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 789 | if isequal(test_batch,1)%if batch installation is available |
---|
| 790 | set(handles.BATCH, 'Enable','On') |
---|
| 791 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 792 | end |
---|
| 793 | |
---|
| 794 | %%%%% store the root input filename for future opening |
---|
| 795 | dir_perso=prefdir; |
---|
| 796 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 797 | RootPath=fileparts(filebase); |
---|
| 798 | if exist(profil_perso,'file') |
---|
| 799 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 800 | else |
---|
| 801 | txt=ver; |
---|
| 802 | Release=txt(1).Release; |
---|
| 803 | relnumb=str2num(Release(3:4)); |
---|
| 804 | if relnumb >= 14 |
---|
| 805 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 806 | else |
---|
| 807 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 808 | end |
---|
| 809 | end |
---|
| 810 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 811 | set(gcf,'Pointer','arrow') |
---|
| 812 | |
---|
[12] | 813 | %------------------------------------------------------------------------ |
---|
[2] | 814 | % --- Executes on button press in mode. |
---|
| 815 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 816 | %------------------------------------------------------------------------ |
---|
[2] | 817 | browse=get(handles.browse_root,'UserData'); |
---|
| 818 | compare_list=get(handles.compare,'String'); |
---|
| 819 | val=get(handles.compare,'Value'); |
---|
| 820 | compare=compare_list{val}; |
---|
| 821 | if strcmp(compare,'displacement') |
---|
| 822 | mode='displacement'; |
---|
| 823 | else |
---|
| 824 | mode_list=get(handles.mode,'String'); |
---|
| 825 | mode_value=get(handles.mode,'Value'); |
---|
| 826 | mode=mode_list{mode_value}; |
---|
| 827 | end |
---|
| 828 | displ_num=[];%default |
---|
[54] | 829 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
[2] | 830 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 831 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 832 | siztime=size(time); |
---|
| 833 | nbfield=siztime(1); |
---|
| 834 | nbfield2=siztime(2); |
---|
| 835 | indchosen=1; %%first pair selected by default |
---|
| 836 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 837 | dt=1; |
---|
| 838 | displ=''; |
---|
| 839 | index=0; |
---|
| 840 | numlist_a=[]; |
---|
| 841 | numlist_B=[]; |
---|
| 842 | %get all the time intervals in bursts |
---|
| 843 | displ_dt=1;%default |
---|
| 844 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 845 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 846 | for numod_b=(numod_a+1):nbfield2 |
---|
| 847 | index=index+1; |
---|
| 848 | numlist_a(index)=numod_a; |
---|
| 849 | numlist_b(index)=numod_b; |
---|
| 850 | if ~isempty(time) |
---|
[54] | 851 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 852 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 853 | else |
---|
| 854 | displ_dt(index)=1; |
---|
| 855 | end |
---|
| 856 | end |
---|
| 857 | end |
---|
| 858 | [dtsort,indsort]=sort(displ_dt); |
---|
| 859 | if ~isempty(numlist_a) |
---|
| 860 | displ_num(1,:)=numlist_a(indsort); |
---|
| 861 | displ_num(2,:)=numlist_b(indsort); |
---|
| 862 | end |
---|
| 863 | displ_num(3,:)=0; |
---|
| 864 | displ_num(4,:)=0; |
---|
| 865 | set(handles.jtext,'Visible','Off') |
---|
| 866 | set(handles.first_j,'Visible','Off') |
---|
| 867 | set(handles.last_j,'Visible','Off') |
---|
| 868 | set(handles.incr_j,'Visible','Off') |
---|
| 869 | set(handles.nb_field2,'Visible','Off') |
---|
| 870 | set(handles.ref_j,'Visible','Off') |
---|
| 871 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 872 | for index=1:min(nbfield2-1,200) |
---|
| 873 | displ_num(1,index)=-floor(index/2); |
---|
| 874 | displ_num(2,index)=ceil(index/2); |
---|
| 875 | displ_num(3,index)=0; |
---|
| 876 | displ_num(4,index)=0; |
---|
| 877 | end |
---|
| 878 | set(handles.jtext,'Visible','On') |
---|
| 879 | set(handles.first_j,'Visible','On') |
---|
| 880 | set(handles.last_j,'Visible','On') |
---|
| 881 | set(handles.incr_j,'Visible','On') |
---|
| 882 | set(handles.nb_field2,'Visible','On') |
---|
| 883 | set(handles.ref_j,'Visible','On') |
---|
| 884 | if nbfield > 1 |
---|
| 885 | set(handles.itext,'Visible','On') |
---|
| 886 | set(handles.first_i,'Visible','On') |
---|
| 887 | set(handles.last_i,'Visible','On') |
---|
| 888 | set(handles.incr_i,'Visible','On') |
---|
| 889 | set(handles.nb_field,'Visible','On') |
---|
| 890 | set(handles.ref_i,'Visible','On') |
---|
| 891 | else |
---|
| 892 | set(handles.itext,'Visible','Off') |
---|
| 893 | set(handles.first_i,'Visible','Off') |
---|
| 894 | set(handles.last_i,'Visible','Off') |
---|
| 895 | set(handles.incr_i,'Visible','Off') |
---|
| 896 | set(handles.nb_field,'Visible','Off') |
---|
| 897 | set(handles.ref_i,'Visible','Off') |
---|
| 898 | end |
---|
| 899 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 900 | for index=1:200%min(nbfield-1,200) |
---|
| 901 | displ_num(1,index)=0; |
---|
| 902 | displ_num(2,index)=0; |
---|
| 903 | displ_num(3,index)=-floor(index/2); |
---|
| 904 | displ_num(4,index)=ceil(index/2); |
---|
| 905 | end |
---|
| 906 | set(handles.itext,'Visible','On') |
---|
| 907 | set(handles.first_i,'Visible','On') |
---|
| 908 | set(handles.last_i,'Visible','On') |
---|
| 909 | set(handles.incr_i,'Visible','On') |
---|
| 910 | set(handles.nb_field,'Visible','On') |
---|
| 911 | set(handles.ref_i,'Visible','On') |
---|
| 912 | if nbfield2 > 1 |
---|
| 913 | set(handles.jtext,'Visible','On') |
---|
| 914 | set(handles.first_j,'Visible','On') |
---|
| 915 | set(handles.last_j,'Visible','On') |
---|
| 916 | set(handles.incr_j,'Visible','On') |
---|
| 917 | set(handles.nb_field2,'Visible','On') |
---|
| 918 | set(handles.ref_j,'Visible','On') |
---|
| 919 | else |
---|
| 920 | set(handles.jtext,'Visible','Off') |
---|
| 921 | set(handles.first_j,'Visible','Off') |
---|
| 922 | set(handles.last_j,'Visible','Off') |
---|
| 923 | set(handles.incr_j,'Visible','Off') |
---|
| 924 | set(handles.nb_field2,'Visible','Off') |
---|
| 925 | set(handles.ref_j,'Visible','Off') |
---|
| 926 | end |
---|
| 927 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 928 | displ_num(1,1)=0; |
---|
| 929 | displ_num(2,1)=0; |
---|
| 930 | displ_num(3,1)=0; |
---|
| 931 | displ_num(4,1)=0; |
---|
| 932 | if nbfield > 1 |
---|
| 933 | set(handles.itext,'Visible','On') |
---|
| 934 | set(handles.first_i,'Visible','On') |
---|
| 935 | set(handles.last_i,'Visible','On') |
---|
| 936 | set(handles.incr_i,'Visible','On') |
---|
| 937 | set(handles.nb_field,'Visible','On') |
---|
| 938 | set(handles.ref_i,'Visible','On') |
---|
| 939 | else |
---|
| 940 | set(handles.itext,'Visible','Off') |
---|
| 941 | set(handles.first_i,'Visible','Off') |
---|
| 942 | set(handles.last_i,'Visible','Off') |
---|
| 943 | set(handles.incr_i,'Visible','Off') |
---|
| 944 | set(handles.nb_field,'Visible','Off') |
---|
| 945 | set(handles.ref_i,'Visible','Off') |
---|
| 946 | end |
---|
| 947 | if nbfield2 > 1 |
---|
| 948 | set(handles.jtext,'Visible','On') |
---|
| 949 | set(handles.first_j,'Visible','On') |
---|
| 950 | set(handles.last_j,'Visible','On') |
---|
| 951 | set(handles.incr_j,'Visible','On') |
---|
| 952 | set(handles.nb_field2,'Visible','On') |
---|
| 953 | set(handles.ref_j,'Visible','On') |
---|
| 954 | else |
---|
| 955 | set(handles.jtext,'Visible','Off') |
---|
| 956 | set(handles.first_j,'Visible','Off') |
---|
| 957 | set(handles.last_j,'Visible','Off') |
---|
| 958 | set(handles.incr_j,'Visible','Off') |
---|
| 959 | set(handles.nb_field2,'Visible','Off') |
---|
| 960 | set(handles.ref_j,'Visible','Off') |
---|
| 961 | end |
---|
| 962 | end |
---|
| 963 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 964 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 965 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 966 | |
---|
[12] | 967 | %------------------------------------------------------------------------ |
---|
[2] | 968 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 969 | % the field series set by first_i, incr, last_i |
---|
| 970 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 971 | %------------------------------------------------------------------------ |
---|
[2] | 972 | set(gcf,'Pointer','watch') |
---|
| 973 | %nomenclature types |
---|
| 974 | filebase=get(handles.displ_filebase,'String'); |
---|
| 975 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 976 | browse=get(handles.browse_root,'UserData'); |
---|
| 977 | compare_list=get(handles.compare,'String'); |
---|
| 978 | val=get(handles.compare,'Value'); |
---|
| 979 | compare=compare_list{val}; |
---|
| 980 | if strcmp(compare,'displacement') |
---|
| 981 | mode='displacement'; |
---|
| 982 | else |
---|
| 983 | mode_list=get(handles.mode,'String'); |
---|
| 984 | mode_value=get(handles.mode,'Value'); |
---|
| 985 | mode=mode_list{mode_value}; |
---|
| 986 | end |
---|
| 987 | |
---|
| 988 | % nomenclature type of the .nc files |
---|
| 989 | nom_type_ima=[];%default |
---|
| 990 | if isfield(browse,'nom_type_ima') |
---|
| 991 | nom_type_ima=browse.nom_type_ima; |
---|
| 992 | end |
---|
| 993 | |
---|
| 994 | %determine nom_type_nc: |
---|
| 995 | nom_type_nc=[];%default |
---|
| 996 | if isfield(browse,'nom_type_nc') |
---|
| 997 | nom_type_nc=browse.nom_type_nc; |
---|
| 998 | end |
---|
| 999 | if isempty(nom_type_nc) |
---|
| 1000 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
| 1001 | end |
---|
| 1002 | browse.nom_type_nc=nom_type_nc; |
---|
| 1003 | set(handles.browse_root,'UserData',browse) |
---|
| 1004 | |
---|
| 1005 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 1006 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 1007 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1008 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1009 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1010 | % num1=first_i:incr:last_i; |
---|
| 1011 | % if isempty(num1) |
---|
| 1012 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1013 | % return |
---|
| 1014 | % end |
---|
| 1015 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1016 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1017 | ref_j=0; |
---|
| 1018 | else |
---|
[45] | 1019 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1020 | end |
---|
| 1021 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
| 1022 | if isempty(time) |
---|
| 1023 | time=[0 1]; |
---|
| 1024 | end |
---|
[45] | 1025 | dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[2] | 1026 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1027 | |
---|
| 1028 | %eliminate the first pairs inconsistent with the position |
---|
| 1029 | if isempty(displ_num) |
---|
| 1030 | nbpair=0; |
---|
| 1031 | else |
---|
| 1032 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1033 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1034 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1035 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1036 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1037 | end |
---|
| 1038 | end |
---|
| 1039 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1040 | |
---|
| 1041 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1042 | % be performed, while the result is needed for next steps. |
---|
| 1043 | displ_pair={''}; |
---|
| 1044 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1045 | testpair=0; |
---|
| 1046 | if get(handles.CIV1,'Value')==0 % |
---|
| 1047 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1048 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1049 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1050 | return |
---|
| 1051 | end |
---|
| 1052 | for ipair=1:nbpair |
---|
| 1053 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1054 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1055 | select(ipair)=exist(filename,'file')==2; |
---|
| 1056 | end |
---|
| 1057 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
| 1058 | if isfield(browse,'incr_pair') |
---|
| 1059 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1060 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1061 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1062 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1063 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1064 | select(1)=exist(filename,'file')==2; |
---|
| 1065 | testpair=1; |
---|
| 1066 | else |
---|
| 1067 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1068 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1069 | else |
---|
| 1070 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1071 | end |
---|
| 1072 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1073 | %COMPLETER CAS STEREO |
---|
| 1074 | return |
---|
| 1075 | end |
---|
| 1076 | end |
---|
| 1077 | end |
---|
| 1078 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1079 | if testpair |
---|
| 1080 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1081 | elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1082 | for ipair=1:nbpair |
---|
| 1083 | if select(ipair) |
---|
| 1084 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1085 | 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 |
---|
| 1086 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1087 | end |
---|
| 1088 | else |
---|
| 1089 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1090 | end |
---|
| 1091 | end |
---|
| 1092 | else |
---|
| 1093 | for ipair=1:nbpair |
---|
| 1094 | if select(ipair) |
---|
| 1095 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
| 1096 | else |
---|
| 1097 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1098 | end |
---|
| 1099 | end |
---|
| 1100 | end |
---|
| 1101 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1102 | if testpair |
---|
| 1103 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1104 | else |
---|
| 1105 | for ipair=1:nbpair |
---|
| 1106 | if select(ipair) |
---|
| 1107 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1108 | 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 |
---|
| 1109 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1110 | end |
---|
| 1111 | elseif testpair |
---|
| 1112 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1113 | else |
---|
| 1114 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1115 | end |
---|
| 1116 | end |
---|
| 1117 | end |
---|
| 1118 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1119 | for ipair=1:nbpair |
---|
| 1120 | if select(ipair) |
---|
| 1121 | 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 |
---|
| 1122 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1123 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1124 | else |
---|
| 1125 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1126 | end |
---|
| 1127 | end |
---|
| 1128 | elseif isequal(mode,'displacement') |
---|
| 1129 | displ_pair={'Di=Dj=0'}; |
---|
| 1130 | end |
---|
| 1131 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1132 | ichoice=min(find(select)); |
---|
[45] | 1133 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1134 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
| 1135 | if initial>nbpair |
---|
| 1136 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1137 | end |
---|
| 1138 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1139 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1140 | end |
---|
[45] | 1141 | |
---|
[2] | 1142 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1143 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1144 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1145 | if ichoice <= length(displ_pair') |
---|
| 1146 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1147 | else |
---|
| 1148 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1149 | end |
---|
| 1150 | end |
---|
| 1151 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1152 | set(gcf,'Pointer','arrow') |
---|
[12] | 1153 | |
---|
| 1154 | %------------------------------------------------------------------------ |
---|
[2] | 1155 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1156 | %middle of the series set by first_i, incr, last_i |
---|
| 1157 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1158 | %------------------------------------------------------------------------ |
---|
[2] | 1159 | set(gcf,'Pointer','watch') |
---|
| 1160 | %nomenclature types |
---|
| 1161 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1162 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1163 | browse=get(handles.browse_root,'UserData'); |
---|
| 1164 | compare_list=get(handles.compare,'String'); |
---|
| 1165 | val=get(handles.compare,'Value'); |
---|
| 1166 | compare=compare_list{val}; |
---|
| 1167 | if strcmp(compare,'displacement') |
---|
| 1168 | mode='displacement'; |
---|
| 1169 | else |
---|
| 1170 | mode_list=get(handles.mode,'String'); |
---|
| 1171 | mode_value=get(handles.mode,'Value'); |
---|
| 1172 | mode=mode_list{mode_value}; |
---|
| 1173 | end |
---|
| 1174 | |
---|
| 1175 | % nomenclature type of the .nc files |
---|
| 1176 | nom_type_ima='ima_num';%default |
---|
| 1177 | if isfield(browse,'nom_type_ima') |
---|
| 1178 | nom_type_ima=browse.nom_type_ima; |
---|
| 1179 | end |
---|
| 1180 | nom_type_nc='_i1-i2';%default |
---|
| 1181 | if isfield(browse,'nom_type_nc') |
---|
| 1182 | nom_type_nc=browse.nom_type_nc; |
---|
| 1183 | end |
---|
| 1184 | 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') |
---|
| 1185 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 1186 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 1187 | nom_type_nc='none'; |
---|
| 1188 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
| 1189 | nom_type_nc='_i1-i2'; |
---|
| 1190 | else |
---|
| 1191 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1192 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1193 | else |
---|
| 1194 | nom_type_nc='_i_j1-j2'; |
---|
| 1195 | end |
---|
| 1196 | end |
---|
| 1197 | browse.nom_type_nc=nom_type_nc; |
---|
| 1198 | set(handles.browse_root,'UserData',browse) |
---|
| 1199 | |
---|
| 1200 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1201 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1202 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1203 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1204 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1205 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1206 | % num1=first_i:incr:last_i; |
---|
| 1207 | % if isempty(num1) |
---|
| 1208 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1209 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1210 | % return |
---|
| 1211 | % end |
---|
[2] | 1212 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1213 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1214 | ref_j=0; |
---|
| 1215 | else |
---|
| 1216 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1217 | end |
---|
| 1218 | if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval |
---|
| 1219 | ref_i=ceil((first_i+last_i)/2); |
---|
| 1220 | ref_j=1; |
---|
| 1221 | end |
---|
| 1222 | % ref_i=browse.num_ref;%field number initially selected by the browser |
---|
| 1223 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1224 | if isempty(time) |
---|
| 1225 | time=[0 1];%default |
---|
| 1226 | end |
---|
| 1227 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1228 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1229 | |
---|
| 1230 | |
---|
| 1231 | %eliminate the first pairs inconsistent with the position |
---|
| 1232 | if isempty(displ_num) |
---|
| 1233 | nbpair=0; |
---|
| 1234 | else |
---|
| 1235 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1236 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
| 1237 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1238 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1239 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1240 | end |
---|
| 1241 | end |
---|
| 1242 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1243 | |
---|
| 1244 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1245 | % be performed, while the result is needed for next steps. |
---|
| 1246 | displ_pair={''}; %default |
---|
| 1247 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1248 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1249 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1250 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1251 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1252 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1253 | return |
---|
| 1254 | end |
---|
| 1255 | for ipair=1:nbpair |
---|
| 1256 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1257 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1258 | select(ipair)=exist(filename,'file')==2; |
---|
| 1259 | end |
---|
| 1260 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1261 | if isfield(browse,'incr_pair') |
---|
| 1262 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1263 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1264 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1265 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1266 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1267 | select(1)=exist(filename,'file')==2; |
---|
| 1268 | else |
---|
| 1269 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1270 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1271 | else |
---|
| 1272 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1273 | end |
---|
| 1274 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1275 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1276 | return |
---|
| 1277 | end |
---|
| 1278 | end |
---|
| 1279 | end |
---|
| 1280 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1281 | % if ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1282 | for ipair=1:nbpair |
---|
| 1283 | if select(ipair) |
---|
| 1284 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1285 | 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 |
---|
| 1286 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1287 | end |
---|
| 1288 | else |
---|
| 1289 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1290 | end |
---|
| 1291 | end |
---|
| 1292 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1293 | for ipair=1:nbpair |
---|
| 1294 | if select(ipair) |
---|
| 1295 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1296 | 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 |
---|
| 1297 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1298 | end |
---|
| 1299 | else |
---|
| 1300 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1301 | end |
---|
| 1302 | end |
---|
| 1303 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1304 | for ipair=1:nbpair |
---|
| 1305 | if select(ipair) |
---|
| 1306 | 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 |
---|
| 1307 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1308 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1309 | else |
---|
| 1310 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1311 | end |
---|
| 1312 | end |
---|
| 1313 | elseif isequal(mode,'displacement') |
---|
| 1314 | displ_pair={'Di=Dj=0'}; |
---|
| 1315 | end |
---|
| 1316 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1317 | ichoice=min(find(select)); |
---|
| 1318 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1319 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1320 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1321 | end |
---|
| 1322 | if val>length(displ_pair') |
---|
| 1323 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1324 | else |
---|
| 1325 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1326 | end |
---|
| 1327 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1328 | set(gcf,'Pointer','arrow') |
---|
[2] | 1329 | |
---|
[12] | 1330 | %------------------------------------------------------------------------ |
---|
[2] | 1331 | % determine the list of index pairs of processing file |
---|
| 1332 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1333 | find_pair_indices(handles,mode) |
---|
[12] | 1334 | %------------------------------------------------------------------------ |
---|
[45] | 1335 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1336 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1337 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
[39] | 1338 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
[2] | 1339 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
[45] | 1340 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1341 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1342 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
[2] | 1343 | else |
---|
| 1344 | first_j=1; |
---|
| 1345 | last_j=1; |
---|
| 1346 | incr_j=1; |
---|
| 1347 | end |
---|
[36] | 1348 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
[2] | 1349 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1350 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
[36] | 1351 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
[2] | 1352 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1353 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1354 | return |
---|
| 1355 | end |
---|
| 1356 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1357 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1358 | if index_civ2>length(list_civ2) |
---|
| 1359 | list_civ2=list_civ1; |
---|
| 1360 | index_civ2=index_civ1; |
---|
| 1361 | end |
---|
[36] | 1362 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 1363 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
| 1364 | return,end; |
---|
[39] | 1365 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[36] | 1366 | return,end; |
---|
[39] | 1367 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[36] | 1368 | return,end; |
---|
[39] | 1369 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[36] | 1370 | return,end; |
---|
| 1371 | if isequal (mode,'series(Di)') |
---|
[2] | 1372 | %recognize the pair civ1 from the display |
---|
| 1373 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1374 | str_raw=str_civ1(indsel); |
---|
| 1375 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
[45] | 1376 | d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
[2] | 1377 | if indsepar==length(str_raw) |
---|
[45] | 1378 | d2=str2double(str_civ1([indsel(indsepar)+1:end])); |
---|
[2] | 1379 | else |
---|
[45] | 1380 | d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
[2] | 1381 | end |
---|
[39] | 1382 | num1_civ1=num_i-d1;% set of first image numbers |
---|
| 1383 | num2_civ1=num_i+d2; |
---|
[2] | 1384 | num_a_civ1=num_j; |
---|
| 1385 | num_b_civ1=num_j; |
---|
| 1386 | |
---|
| 1387 | %recognize the pair civ2 from the display |
---|
| 1388 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1389 | str_raw=str_civ2(indsel); |
---|
| 1390 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1391 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1392 | if indsepar==length(str_raw) |
---|
| 1393 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
| 1394 | else |
---|
| 1395 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1396 | end |
---|
| 1397 | if isempty(d1) |
---|
[39] | 1398 | num1_civ2=num_i; |
---|
[2] | 1399 | else |
---|
[39] | 1400 | num1_civ2=num_i-d1;% set of first image numbers |
---|
[2] | 1401 | end |
---|
| 1402 | if isempty(d2) |
---|
[39] | 1403 | num2_civ2=num_i; |
---|
[2] | 1404 | else |
---|
[39] | 1405 | num2_civ2=num_i+d2; |
---|
[2] | 1406 | end |
---|
| 1407 | num_a_civ2=num_j; |
---|
| 1408 | num_b_civ2=num_j; |
---|
| 1409 | |
---|
| 1410 | % adjust the first and last field number |
---|
| 1411 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1412 | if isequal(lastfield,[]) |
---|
| 1413 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1414 | else |
---|
| 1415 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1416 | end |
---|
| 1417 | if length(indsel)>=1 |
---|
| 1418 | firstind=indsel(1); |
---|
| 1419 | lastind=indsel(end); |
---|
[39] | 1420 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
| 1421 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
| 1422 | num_i=num_i(indsel); |
---|
[2] | 1423 | num1_civ1=num1_civ1(indsel); |
---|
| 1424 | num1_civ2=num1_civ2(indsel); |
---|
| 1425 | num2_civ1=num2_civ1(indsel); |
---|
| 1426 | num2_civ2=num2_civ2(indsel); |
---|
| 1427 | end |
---|
[36] | 1428 | elseif isequal (mode,'series(Dj)') |
---|
[2] | 1429 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
[39] | 1430 | num1_civ1=num_i;% set of first image numbers |
---|
| 1431 | num2_civ1=num_i; |
---|
[2] | 1432 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1433 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
[39] | 1434 | num1_civ2=num_i; |
---|
| 1435 | num2_civ2=num_i; |
---|
[2] | 1436 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1437 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1438 | % adjust the first and last field number |
---|
| 1439 | if isequal(lastfield_j,[]) |
---|
| 1440 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1441 | else |
---|
| 1442 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1443 | end |
---|
| 1444 | if length(indsel)>=1 |
---|
| 1445 | firstind=indsel(1); |
---|
| 1446 | lastind=indsel(end); |
---|
| 1447 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1448 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1449 | num_j=num_j(indsel); |
---|
| 1450 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1451 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1452 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1453 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1454 | end |
---|
[36] | 1455 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[39] | 1456 | num1_civ1=num_i; |
---|
| 1457 | num1_civ2=num_i; |
---|
[2] | 1458 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[39] | 1459 | num2_civ1=num_i; |
---|
[2] | 1460 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1461 | num_b_civ1=displ_num(2,index_civ1); |
---|
[39] | 1462 | num2_civ2=num_i; |
---|
[2] | 1463 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1464 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1465 | elseif isequal(mode,'displacement') |
---|
[39] | 1466 | num1_civ1=num_i; |
---|
| 1467 | num2_civ1=num_i; |
---|
[2] | 1468 | num_a_civ1=num_j; |
---|
| 1469 | num_b_civ1=num_j; |
---|
[39] | 1470 | num1_civ2=num_i; |
---|
| 1471 | num2_civ2=num_i; |
---|
[2] | 1472 | num_a_civ2=num_j; |
---|
| 1473 | num_b_civ2=num_j; |
---|
| 1474 | end |
---|
| 1475 | |
---|
[41] | 1476 | |
---|
[12] | 1477 | %------------------------------------------------------------------------ |
---|
[2] | 1478 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1479 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1480 | %------------------------------------------------------------------------ |
---|
[2] | 1481 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1482 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1483 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1484 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1485 | num_a=displ_num(1,index_pair); |
---|
| 1486 | num_b=displ_num(2,index_pair); |
---|
| 1487 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1488 | if index_pair<=length(list_pair2) |
---|
| 1489 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1490 | end |
---|
| 1491 | |
---|
| 1492 | %update first_i and last_i according to the chosen image pairs |
---|
| 1493 | mode_list=get(handles.mode,'String'); |
---|
| 1494 | mode_value=get(handles.mode,'Value'); |
---|
| 1495 | mode=mode_list{mode_value}; |
---|
| 1496 | if isequal(mode,'series(Di)') |
---|
| 1497 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1498 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1499 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1500 | num1=first_i:incr_i:last_i; |
---|
| 1501 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1502 | if ~isequal(lastfield,[]) |
---|
| 1503 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1504 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1505 | num1=num1(ind); |
---|
| 1506 | end |
---|
| 1507 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1508 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1509 | elseif isequal(mode,'series(Dj)') |
---|
| 1510 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1511 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1512 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1513 | num_j=first_j:incr_j:last_j; |
---|
| 1514 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1515 | if ~isequal(lastfield2,[]) |
---|
| 1516 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1517 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1518 | num1=num_j(ind); |
---|
| 1519 | end |
---|
| 1520 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1521 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1522 | end |
---|
| 1523 | |
---|
[12] | 1524 | %------------------------------------------------------------------------ |
---|
[2] | 1525 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1526 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1527 | %------------------------------------------------------------------------ |
---|
[2] | 1528 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1529 | |
---|
| 1530 | %update first_i and last_i according to the chosen image pairs |
---|
| 1531 | mode_list=get(handles.mode,'String'); |
---|
| 1532 | mode_value=get(handles.mode,'Value'); |
---|
| 1533 | mode=mode_list{mode_value}; |
---|
| 1534 | if isequal(mode,'series(Di)') |
---|
| 1535 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1536 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1537 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1538 | num1=first_i:incr_i:last_i; |
---|
| 1539 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1540 | if ~isequal(lastfield,[]) |
---|
| 1541 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1542 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1543 | num1=num1(ind); |
---|
| 1544 | end |
---|
| 1545 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1546 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1547 | elseif isequal(mode,'series(Dj)') |
---|
| 1548 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1549 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1550 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1551 | num_j=first_j:incr_j:last_j; |
---|
| 1552 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1553 | if ~isequal(lastfield2,[]) |
---|
| 1554 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1555 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1556 | num1=num_j(ind); |
---|
| 1557 | end |
---|
| 1558 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1559 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1560 | end |
---|
| 1561 | |
---|
[12] | 1562 | %------------------------------------------------------------------------ |
---|
[2] | 1563 | % --- Executes on button press in RUN. |
---|
| 1564 | function RUN_Callback(hObject, eventdata, handles) |
---|
[12] | 1565 | %------------------------------------------------------------------------ |
---|
[2] | 1566 | global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
| 1567 | |
---|
| 1568 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1569 | %check the list of operations: |
---|
| 1570 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1571 | run_flag=1; |
---|
| 1572 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1573 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1574 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1575 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1576 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1577 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1578 | index=find(box_test==1); |
---|
| 1579 | if isempty(index) |
---|
| 1580 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 1581 | return |
---|
| 1582 | end |
---|
| 1583 | index_first=min(index); |
---|
| 1584 | index_last=max(index); |
---|
| 1585 | box_used=box_test([index_first : index_last]); |
---|
| 1586 | [box_missing,ind_missing]=min(box_used); |
---|
| 1587 | if isequal(box_missing,0) |
---|
| 1588 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1589 | return |
---|
| 1590 | end |
---|
| 1591 | |
---|
| 1592 | %root name |
---|
| 1593 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1594 | if isempty(filebase)||isequal(filebase,'') |
---|
| 1595 | msgbox_uvmat('ERROR','no input files') |
---|
| 1596 | return |
---|
| 1597 | end |
---|
| 1598 | %check mask if selecetd |
---|
| 1599 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1600 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1601 | if ~exist(maskname,'file') |
---|
| 1602 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1603 | end |
---|
[2] | 1604 | end |
---|
| 1605 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1606 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1607 | if ~exist(maskname,'file') |
---|
[2] | 1608 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
[12] | 1609 | end |
---|
[2] | 1610 | end |
---|
| 1611 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1612 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1613 | if ~exist(maskname,'file') |
---|
[2] | 1614 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1615 | end |
---|
[2] | 1616 | end |
---|
| 1617 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1618 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1619 | if ~exist(maskname,'file') |
---|
[2] | 1620 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1621 | end |
---|
[2] | 1622 | end |
---|
| 1623 | |
---|
| 1624 | %read names of the .exe file |
---|
[45] | 1625 | if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 |
---|
[2] | 1626 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1627 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[54] | 1628 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 1629 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 1630 | if exist(xmlfile,'file') |
---|
| 1631 | t=xmltree(xmlfile); |
---|
| 1632 | sparam=convert(t); |
---|
| 1633 | end |
---|
[2] | 1634 | if isfield(sparam,'Civ1_exe') |
---|
| 1635 | civ1_exe=sparam.Civ1_exe; |
---|
[54] | 1636 | if ~exist(civ1_exe,'file') |
---|
[45] | 1637 | civ1_exe=fullfile(path_UVMAT,civ1_exe); |
---|
| 1638 | end |
---|
[2] | 1639 | end |
---|
| 1640 | if isfield(sparam,'Civ2_exe') |
---|
| 1641 | civ2_exe=sparam.Civ2_exe; |
---|
[54] | 1642 | if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting |
---|
[45] | 1643 | civ2_exe=fullfile(path_UVMAT,civ2_exe); |
---|
| 1644 | end |
---|
[2] | 1645 | end |
---|
| 1646 | if isfield(sparam,'Patch_exe') |
---|
| 1647 | patch_exe=sparam.Patch_exe; |
---|
[54] | 1648 | if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting |
---|
[45] | 1649 | patch_exe=fullfile(path_UVMAT,patch_exe); |
---|
| 1650 | end |
---|
[2] | 1651 | end |
---|
| 1652 | if isfield(sparam,'Stinterp_exe') |
---|
| 1653 | stinterp_exe=sparam.Stinterp_exe; |
---|
| 1654 | end |
---|
| 1655 | if isfield(sparam,'SGE') |
---|
[45] | 1656 | sge=str2double(sparam.SGE); |
---|
[2] | 1657 | end |
---|
| 1658 | if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
| 1659 | dircur=pwd; |
---|
| 1660 | if ~isequal(dircur([2 3]),':\') |
---|
| 1661 | msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
| 1662 | return; |
---|
| 1663 | end |
---|
| 1664 | end |
---|
| 1665 | end |
---|
| 1666 | |
---|
| 1667 | %initialize the waitbars |
---|
| 1668 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 1669 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 1670 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 1671 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 1672 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1673 | set(handles.RUN, 'Enable','Off') |
---|
| 1674 | drawnow |
---|
| 1675 | |
---|
| 1676 | % get the list of file names and check the files |
---|
| 1677 | display('checking the files...') |
---|
| 1678 | [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]=... |
---|
| 1679 | set_civ_filenames(handles,compare,box_test); |
---|
[41] | 1680 | nbfield=numel(num1_civ1); |
---|
| 1681 | nbslice=size(num_a_civ1); |
---|
[36] | 1682 | |
---|
[12] | 1683 | if isempty(filecell) |
---|
| 1684 | set(handles.RUN, 'Enable','On') |
---|
| 1685 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1686 | set(handles.BATCH, 'Enable','On') |
---|
| 1687 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1688 | return |
---|
| 1689 | end |
---|
[2] | 1690 | display('files OK, processing...') |
---|
| 1691 | nbfield=size(num1_civ1,2); |
---|
| 1692 | nbslice=size(num1_civ1,1); |
---|
| 1693 | |
---|
| 1694 | %RUN CIV1 |
---|
| 1695 | if box_test(1)==1 |
---|
| 1696 | 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) |
---|
| 1697 | if compare==3 |
---|
| 1698 | 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) |
---|
| 1699 | end |
---|
| 1700 | end |
---|
| 1701 | |
---|
| 1702 | %RUN FIX1 |
---|
| 1703 | if box_test(2)==1 |
---|
| 1704 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1705 | %names of the civ1 fields |
---|
| 1706 | field1.vel_type='civ1'; |
---|
| 1707 | field1.nb='nb_vectors'; |
---|
[45] | 1708 | % field1.X='vec_X'; |
---|
| 1709 | % field1.Y='vec_Y'; |
---|
| 1710 | % field1.U='vec_U'; |
---|
| 1711 | % field1.V='vec_V'; |
---|
[2] | 1712 | field1.fixflag='vec_FixFlag'; |
---|
| 1713 | flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1714 | flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
| 1715 | flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
[45] | 1716 | thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1717 | thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1718 | inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 1719 | menu=get(handles.field_ref1,'String'); |
---|
| 1720 | index=get(handles.field_ref1,'Value'); |
---|
| 1721 | if isempty(menu) |
---|
| 1722 | fieldchoice=''; |
---|
| 1723 | else |
---|
| 1724 | fieldchoice=menu{index}; |
---|
| 1725 | end |
---|
[45] | 1726 | h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar |
---|
[12] | 1727 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1728 | if test_mask |
---|
| 1729 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 1730 | if exist(maskdispl,'file') |
---|
| 1731 | test_mask=2; |
---|
| 1732 | maskname=maskdispl; |
---|
| 1733 | else |
---|
| 1734 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1735 | end |
---|
| 1736 | end |
---|
[2] | 1737 | for ifile=1:nbfield |
---|
| 1738 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1739 | for j=1:nbslice |
---|
| 1740 | if test_mask==0 |
---|
| 1741 | maskname='noFile use default'; |
---|
| 1742 | maskflag=0; |
---|
[12] | 1743 | elseif test_mask==1 |
---|
[45] | 1744 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1745 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1746 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
| 1747 | maskflag= exist(maskname,'file')==2; |
---|
| 1748 | if ~maskflag; |
---|
| 1749 | maskname='noFile use default'; |
---|
| 1750 | end |
---|
| 1751 | end |
---|
| 1752 | if ~isempty(file_ref_fix1) |
---|
| 1753 | file_ref=file_ref_fix1{ifile,j}; |
---|
| 1754 | else |
---|
| 1755 | file_ref=''; |
---|
| 1756 | end |
---|
| 1757 | error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1758 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1759 | |
---|
| 1760 | if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
| 1761 | if test_mask==0 |
---|
| 1762 | maskname='noFile use default'; |
---|
| 1763 | maskflag=0; |
---|
| 1764 | else |
---|
| 1765 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1766 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1767 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1768 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1769 | maskflag= exist(maskname,'file')==2; |
---|
| 1770 | if ~maskflag; |
---|
| 1771 | maskname='noFile use default'; |
---|
| 1772 | end |
---|
| 1773 | end |
---|
| 1774 | error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1775 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1776 | if ~isempty(error) |
---|
| 1777 | msgbox_uvmat('ERROR',error) |
---|
| 1778 | return |
---|
| 1779 | end |
---|
| 1780 | end |
---|
| 1781 | end |
---|
| 1782 | end |
---|
| 1783 | close(h) |
---|
| 1784 | end |
---|
| 1785 | |
---|
| 1786 | % RUN PATCH1 |
---|
| 1787 | if box_test(3)==1 |
---|
| 1788 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 1789 | if isempty(rho_patch1) |
---|
| 1790 | rho_patch1='1000'; |
---|
| 1791 | set(handles.rho_patch1,'String','1') |
---|
| 1792 | else |
---|
| 1793 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1794 | end |
---|
| 1795 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1796 | if isequal(str2num(nx_patch1),[]) |
---|
| 1797 | nx_patch1='50' ;%default |
---|
| 1798 | set(handles.nx_patch1,'String','50'); |
---|
| 1799 | end |
---|
| 1800 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 1801 | if isequal(str2num(ny_patch1),[]) |
---|
| 1802 | ny_patch1='50' ;%default |
---|
| 1803 | set(handles.ny_patch1,'String','50'); |
---|
| 1804 | end |
---|
| 1805 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1806 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1807 | test_interp=get(handles.test_interp,'Value'); |
---|
| 1808 | icount=0; |
---|
| 1809 | for ifile=1:nbfield |
---|
| 1810 | for j=1:nbslice |
---|
| 1811 | icount=icount+1; |
---|
| 1812 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1813 | set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
| 1814 | drawnow |
---|
| 1815 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1816 | cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1817 | s=-1; |
---|
| 1818 | if sge |
---|
| 1819 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1820 | end |
---|
| 1821 | if s~=0 |
---|
| 1822 | display(['!' cmd]) |
---|
| 1823 | eval(['!' cmd]); |
---|
| 1824 | end |
---|
| 1825 | |
---|
| 1826 | %stereo case: |
---|
| 1827 | elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 1828 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1829 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
| 1830 | nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1831 | display(['!' cmd]) |
---|
| 1832 | eval(['!' cmd]); |
---|
| 1833 | else |
---|
| 1834 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1835 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1836 | end |
---|
| 1837 | end |
---|
| 1838 | if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1839 | cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1840 | s=-1; |
---|
| 1841 | if sge |
---|
| 1842 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1843 | end |
---|
| 1844 | if s~=0 |
---|
| 1845 | display(['!' cmd]) |
---|
| 1846 | eval(['!' cmd]); |
---|
| 1847 | end |
---|
| 1848 | end |
---|
| 1849 | end |
---|
| 1850 | end |
---|
| 1851 | end |
---|
| 1852 | |
---|
| 1853 | % CIV2 |
---|
| 1854 | if box_test(4)==1 |
---|
| 1855 | RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
| 1856 | num_a_civ2,num_b_civ2,nom_type_nc) |
---|
| 1857 | end |
---|
| 1858 | |
---|
| 1859 | % FIX2 |
---|
| 1860 | if box_test(5)==1 |
---|
| 1861 | %names of the civ2 fields |
---|
| 1862 | field2.vel_type='civ2'; |
---|
| 1863 | field2.nb='nb_vectors2'; |
---|
| 1864 | field2.X='vec2_X'; |
---|
| 1865 | field2.Y='vec2_Y'; |
---|
| 1866 | field2.U='vec2_U'; |
---|
| 1867 | field2.V='vec2_V'; |
---|
| 1868 | field2.fixflag='vec2_FixFlag'; |
---|
| 1869 | flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1870 | flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1871 | flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
| 1872 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1873 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 1874 | inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1875 | menu=get(handles.field_ref2,'String'); |
---|
| 1876 | index=get(handles.field_ref2,'Value'); |
---|
| 1877 | if isempty(menu) |
---|
| 1878 | fieldchoice=''; |
---|
| 1879 | else |
---|
| 1880 | fieldchoice=menu{index}; |
---|
| 1881 | end |
---|
| 1882 | h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
| 1883 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
[12] | 1884 | if test_mask |
---|
| 1885 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 1886 | if exist(maskdispl,'file') |
---|
| 1887 | test_mask=2; |
---|
| 1888 | maskname=maskdispl; |
---|
| 1889 | else |
---|
| 1890 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1891 | end |
---|
| 1892 | end |
---|
[2] | 1893 | for ifile=1:nbfield |
---|
| 1894 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1895 | for j=1:nbslice |
---|
| 1896 | if test_mask==0 |
---|
| 1897 | maskname='noFile use default'; |
---|
| 1898 | maskflag=0; |
---|
[12] | 1899 | elseif test_mask==1 |
---|
[2] | 1900 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1901 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1902 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1903 | maskflag= exist(maskname,'file')==2; |
---|
| 1904 | if ~maskflag; |
---|
| 1905 | maskname='noFile use default'; |
---|
| 1906 | end |
---|
| 1907 | end |
---|
| 1908 | if ~isempty(file_ref_fix2) |
---|
| 1909 | file_ref=file_ref_fix2{ifile,j}; |
---|
| 1910 | else |
---|
| 1911 | file_ref=''; |
---|
| 1912 | end |
---|
| 1913 | error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
| 1914 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1915 | if ~isempty(error) |
---|
| 1916 | msgbox_uvmat('ERROR',error) |
---|
| 1917 | return |
---|
| 1918 | end |
---|
| 1919 | if compare==3 |
---|
| 1920 | if test_mask==0 |
---|
| 1921 | maskname='noFile use default'; |
---|
| 1922 | maskflag=0; |
---|
| 1923 | else |
---|
| 1924 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1925 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1926 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1927 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1928 | maskflag= exist(maskname,'file')==2; |
---|
| 1929 | if ~maskflag; |
---|
| 1930 | maskname='noFile use default'; |
---|
| 1931 | end |
---|
| 1932 | end |
---|
| 1933 | error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
| 1934 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1935 | if ~isempty(error) |
---|
| 1936 | msgbox_uvmat('ERROR',error) |
---|
| 1937 | return |
---|
| 1938 | end |
---|
| 1939 | end |
---|
| 1940 | end |
---|
| 1941 | end |
---|
| 1942 | close(h) |
---|
| 1943 | end |
---|
| 1944 | |
---|
| 1945 | %PATCH 2 |
---|
| 1946 | if box_test(6)==1 |
---|
| 1947 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 1948 | if isempty(rho_patch2) |
---|
| 1949 | rho_patch2='1000'; |
---|
| 1950 | set(handles.rho_patch2,'String','1') |
---|
| 1951 | else |
---|
| 1952 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1953 | end |
---|
| 1954 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1955 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 1956 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1957 | if isequal(str2num(nx_patch2),[]) |
---|
| 1958 | nx_patch2='50' ;%default |
---|
| 1959 | set(handles.nx_patch2,'String','50'); |
---|
| 1960 | end |
---|
| 1961 | if isequal(str2num(ny_patch2),[]) |
---|
| 1962 | ny_patch2='50' ;%default |
---|
| 1963 | set(handles.ny_patch2,'String','50'); |
---|
| 1964 | end |
---|
| 1965 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1966 | icount=0; |
---|
| 1967 | for ifile=1:nbfield |
---|
| 1968 | for j=1:nbslice |
---|
| 1969 | icount=icount+1; |
---|
| 1970 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1971 | set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
| 1972 | drawnow |
---|
| 1973 | if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1974 | cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1975 | s=-1; |
---|
| 1976 | if sge |
---|
| 1977 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1978 | end |
---|
| 1979 | if s~=0 |
---|
| 1980 | display(['!' cmd]) |
---|
| 1981 | eval(['!' cmd]); |
---|
| 1982 | end |
---|
| 1983 | elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 1984 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1985 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
| 1986 | nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1987 | display(['!' cmd]) |
---|
| 1988 | eval(['!' cmd]) |
---|
| 1989 | else |
---|
| 1990 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 1991 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1992 | end |
---|
| 1993 | end |
---|
| 1994 | if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1995 | cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1996 | s=-1; |
---|
| 1997 | if sge |
---|
| 1998 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1999 | end |
---|
| 2000 | if s~=0 |
---|
| 2001 | display(['!' cmd]) |
---|
| 2002 | eval(['!' cmd]); |
---|
| 2003 | end |
---|
| 2004 | end |
---|
| 2005 | end |
---|
| 2006 | end |
---|
| 2007 | end |
---|
| 2008 | |
---|
| 2009 | set(handles.RUN, 'Enable','On') |
---|
| 2010 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2011 | |
---|
| 2012 | %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 2013 | if isfield(filecell,'st') |
---|
| 2014 | fileresu=filecell.st{1,1}; |
---|
| 2015 | elseif isfield(filecell,'nc') |
---|
| 2016 | if isfield(filecell.nc,'civ2') |
---|
| 2017 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2018 | else |
---|
| 2019 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2020 | end |
---|
| 2021 | end |
---|
| 2022 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2023 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2024 | detect=1; |
---|
| 2025 | while detect==1 |
---|
| 2026 | namefigfull=[namedoc '.fig']; |
---|
| 2027 | hh=dir(namefigfull); |
---|
| 2028 | if ~isempty(hh) |
---|
| 2029 | detect=1; |
---|
| 2030 | namedoc=[namedoc '.0']; |
---|
| 2031 | else |
---|
| 2032 | detect=0; |
---|
| 2033 | end |
---|
| 2034 | end |
---|
| 2035 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2036 | |
---|
[12] | 2037 | %------------------------------------------------------------------------ |
---|
[2] | 2038 | % --- Executes on button press in BATCH: remote processing |
---|
| 2039 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[12] | 2040 | %------------------------------------------------------------------------ |
---|
[2] | 2041 | global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe |
---|
| 2042 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 2043 | |
---|
| 2044 | %check the list of operations: |
---|
| 2045 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 2046 | run_flag=1; |
---|
| 2047 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 2048 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 2049 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 2050 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 2051 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 2052 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 2053 | index=find(box_test==1); |
---|
| 2054 | if isempty(index) |
---|
| 2055 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 2056 | return |
---|
| 2057 | end |
---|
| 2058 | index_first=min(index); |
---|
| 2059 | index_last=max(index); |
---|
| 2060 | box_used=box_test([index_first : index_last]); |
---|
| 2061 | [box_missing,ind_missing]=min(box_used); |
---|
| 2062 | if isequal(box_missing,0) |
---|
| 2063 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 2064 | return |
---|
| 2065 | end |
---|
| 2066 | |
---|
| 2067 | %root name |
---|
| 2068 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2069 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2070 | msgbox_uvmat('ERROR','no input files') |
---|
| 2071 | return |
---|
| 2072 | end |
---|
| 2073 | |
---|
| 2074 | %check mask if selecetd |
---|
| 2075 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 2076 | maskname=get(handles.mask_civ1,'String'); |
---|
| 2077 | if ~exist(maskname,'file') |
---|
| 2078 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 2079 | end |
---|
[2] | 2080 | end |
---|
| 2081 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 2082 | maskname=get(handles.mask_fix1,'String'); |
---|
| 2083 | if ~exist(maskname,'file') |
---|
| 2084 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 2085 | end |
---|
[2] | 2086 | end |
---|
| 2087 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 2088 | maskname=get(handles.mask_civ2,'String'); |
---|
| 2089 | if ~exist(maskname,'file') |
---|
[2] | 2090 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 2091 | end |
---|
[2] | 2092 | end |
---|
| 2093 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 2094 | maskname=get(handles.mask_fix2,'String'); |
---|
| 2095 | if ~exist(maskname,'file') |
---|
[2] | 2096 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 2097 | end |
---|
[2] | 2098 | end |
---|
| 2099 | |
---|
| 2100 | %read names of the .exe file |
---|
| 2101 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 2102 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[54] | 2103 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 2104 | if exist(xmlfile,'file') |
---|
| 2105 | t=xmltree(xmlfile); |
---|
| 2106 | sparam=convert(t); |
---|
[2] | 2107 | end |
---|
[54] | 2108 | % else |
---|
| 2109 | % xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 2110 | % if exist(xmlfile,'file') |
---|
| 2111 | % t=xmltree(xmlfile); |
---|
| 2112 | % sparam=convert(t); |
---|
| 2113 | % end |
---|
| 2114 | % end |
---|
[2] | 2115 | sge=0; |
---|
| 2116 | if isfield(sparam,'Civ_exe') |
---|
| 2117 | Civ_exe=sparam.Civ_exe; |
---|
| 2118 | end |
---|
| 2119 | if isfield(sparam,'Civ1_exe') |
---|
| 2120 | civ1_exe=sparam.Civ1_exe; |
---|
| 2121 | end |
---|
| 2122 | if isfield(sparam,'Civ2_exe') |
---|
| 2123 | civ2_exe=sparam.Civ2_exe; |
---|
| 2124 | end |
---|
| 2125 | if isfield(sparam,'Patch_exe') |
---|
| 2126 | patch_exe=sparam.Patch_exe; |
---|
| 2127 | end |
---|
| 2128 | if isfield(sparam,'PatchNew_exe') |
---|
| 2129 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 2130 | end |
---|
| 2131 | if isfield(sparam,'Fix_exe') |
---|
| 2132 | fix_exe=sparam.Fix_exe; |
---|
| 2133 | end |
---|
| 2134 | if isfield(sparam,'Todo_path') |
---|
| 2135 | todo_path=sparam.Todo_path; |
---|
| 2136 | end |
---|
| 2137 | if isfield(sparam,'SGE') |
---|
| 2138 | sge=str2num(sparam.SGE); |
---|
| 2139 | end |
---|
| 2140 | |
---|
| 2141 | %choice of batch priority |
---|
| 2142 | ind_answer=2; |
---|
| 2143 | if sge |
---|
| 2144 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2145 | if isequal(s,0) |
---|
| 2146 | w(end)=[]; |
---|
| 2147 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 2148 | str={'urgent';'normal';'low'}; |
---|
| 2149 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2150 | 'SelectionMode','single',... |
---|
| 2151 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 2152 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 2153 | return % a better way should be create |
---|
| 2154 | end |
---|
| 2155 | else |
---|
| 2156 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 2157 | return |
---|
| 2158 | end |
---|
| 2159 | end |
---|
| 2160 | |
---|
| 2161 | %initialize the waitbars |
---|
| 2162 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 2163 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 2164 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 2165 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 2166 | set(handles.BATCH, 'Enable','Off') |
---|
| 2167 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2168 | drawnow |
---|
| 2169 | %get the filename root, nomenclature and numbers |
---|
| 2170 | |
---|
| 2171 | % for Windows system find the UBC path name if needed |
---|
| 2172 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 2173 | cur_dir=pwd; |
---|
| 2174 | if ~isequal(cur_dir(2:3),':\') |
---|
| 2175 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 2176 | end |
---|
| 2177 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 2178 | if isequal(ss,0) |
---|
| 2179 | rankpath=findstr(ww,'\\'); |
---|
| 2180 | if ~isempty(rankpath) |
---|
| 2181 | wwrest=ww(rankpath:end); |
---|
| 2182 | rankend=min(find(double(wwrest)==10))-1; |
---|
| 2183 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 2184 | set(handles.displ_filebase,'String',filebase); |
---|
| 2185 | end |
---|
| 2186 | else |
---|
| 2187 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
| 2188 | set(handles.BATCH, 'Enable','On') |
---|
| 2189 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2190 | return |
---|
| 2191 | end |
---|
| 2192 | end |
---|
| 2193 | |
---|
| 2194 | % set the list of files and check them |
---|
| 2195 | display('checking the files...') |
---|
| 2196 | [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]=... |
---|
| 2197 | set_civ_filenames(handles,compare,box_test); |
---|
[41] | 2198 | |
---|
[2] | 2199 | display('files OK, processing...') |
---|
[41] | 2200 | nbfield=numel(num1_civ1); |
---|
| 2201 | nbslice=numel(num_a_civ1); |
---|
[2] | 2202 | |
---|
| 2203 | %GET PARAMETERS: |
---|
| 2204 | %get civ parameters |
---|
| 2205 | if box_test(1)==1 |
---|
| 2206 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
| 2207 | end |
---|
| 2208 | |
---|
| 2209 | %get fix1 parameters |
---|
| 2210 | if box_test(2)==1 |
---|
| 2211 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 2212 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 2213 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 2214 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 2215 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 2216 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2217 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 2218 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
| 2219 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 2220 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 2221 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 2222 | % fileref=fullfile(refpath,fileref); |
---|
| 2223 | menu=get(handles.field_ref1,'String'); |
---|
| 2224 | index=get(handles.field_ref1,'Value'); |
---|
| 2225 | if isempty(menu) |
---|
| 2226 | fieldchoice=''; |
---|
| 2227 | else |
---|
| 2228 | fieldchoice=menu{index}; |
---|
| 2229 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 2230 | end |
---|
| 2231 | end |
---|
| 2232 | |
---|
| 2233 | %get patch1 parameters |
---|
| 2234 | if box_test(3)==1 |
---|
| 2235 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 2236 | if isempty(rho_patch1) |
---|
| 2237 | rho_patch1='1000'; |
---|
| 2238 | set(handles.rho_patch1,'String','1') |
---|
| 2239 | else |
---|
| 2240 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 2241 | end |
---|
| 2242 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 2243 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 2244 | if isequal(str2num(nx_patch1),[]) |
---|
| 2245 | nx_patch1='50' ;%default |
---|
| 2246 | set(handles.nx_patch1,'String','50'); |
---|
| 2247 | end |
---|
| 2248 | if isequal(str2num(ny_patch1),[]) |
---|
| 2249 | ny_patch1='50' ;%default |
---|
| 2250 | set(handles.ny_patch1,'String','50'); |
---|
| 2251 | end |
---|
| 2252 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 2253 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 2254 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2255 | end |
---|
| 2256 | |
---|
| 2257 | %get civ2 parameters |
---|
| 2258 | if box_test(4)==1 |
---|
| 2259 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 2260 | end |
---|
| 2261 | |
---|
| 2262 | %get fix2 parameters |
---|
| 2263 | if box_test(5)==1 |
---|
| 2264 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 2265 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 2266 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
| 2267 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 2268 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 2269 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2270 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
| 2271 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 2272 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 2273 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 2274 | |
---|
| 2275 | %%%%%%%%%%%%%%%%%%% |
---|
| 2276 | end |
---|
| 2277 | |
---|
| 2278 | |
---|
| 2279 | %get patch2 parameters |
---|
| 2280 | if box_test(6)==1 |
---|
| 2281 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 2282 | if isempty(rho_patch2) |
---|
| 2283 | rho_patch2='1000'; |
---|
| 2284 | set(handles.rho_patch2,'String','1') |
---|
| 2285 | else |
---|
| 2286 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 2287 | end |
---|
| 2288 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 2289 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 2290 | if isequal(str2num(nx_patch2),[]) |
---|
| 2291 | nx_patch2='50' ;%default |
---|
| 2292 | set(handles.nx_patch2,'String','50'); |
---|
| 2293 | end |
---|
| 2294 | if isequal(str2num(ny_patch2),[]) |
---|
| 2295 | ny_patch2='50' ;%default |
---|
| 2296 | set(handles.ny_patch2,'String','50'); |
---|
| 2297 | end |
---|
| 2298 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 2299 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 2300 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2301 | end |
---|
| 2302 | |
---|
| 2303 | if ~sge |
---|
| 2304 | |
---|
| 2305 | %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
| 2306 | name_lock=fullfile(todo_path,'lock'); %lock file |
---|
| 2307 | iwait=0; |
---|
| 2308 | while(exist(name_lock) & iwait<15) |
---|
| 2309 | pause(1); %wait 1 second |
---|
| 2310 | iwait=iwait+1; |
---|
| 2311 | end |
---|
| 2312 | if iwait==15 |
---|
| 2313 | msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
| 2314 | set(handles.BATCH, 'Enable','On') |
---|
| 2315 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2316 | return |
---|
| 2317 | end |
---|
| 2318 | p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
| 2319 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 2320 | p1=fopen(name_todo,'a'); |
---|
| 2321 | if (p1<0) |
---|
| 2322 | msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
| 2323 | set(handles.BATCH, 'Enable','On') |
---|
| 2324 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2325 | return; |
---|
| 2326 | end |
---|
| 2327 | end |
---|
| 2328 | |
---|
| 2329 | %MAIN LOOP |
---|
| 2330 | % for ifile=1:nbfield |
---|
| 2331 | p1text=[];%initiate command text |
---|
| 2332 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2333 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
| 2334 | for ifile=1:nbfield |
---|
| 2335 | for j=1:nbslice |
---|
| 2336 | i_cmd=0; |
---|
| 2337 | cmd=''; |
---|
| 2338 | if sge |
---|
[12] | 2339 | %fid=fopen([filename '.cmx'],'w') |
---|
[2] | 2340 | cmd='#!/bin/bash'; |
---|
[12] | 2341 | cmd=[cmd '\n' '#$ -cwd']; |
---|
| 2342 | cmd=[cmd '\n' 'hostname && date']; |
---|
[2] | 2343 | end |
---|
| 2344 | if civAll |
---|
| 2345 | civAllxml=xmltree;% xml contents, all parameters |
---|
| 2346 | civAllCmd=[]; |
---|
| 2347 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 2348 | end |
---|
| 2349 | % filecell.nc.civ1 |
---|
[41] | 2350 | filename_cmx=filecell.nc.civ1{ifile,j}%output netcdf file |
---|
| 2351 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
[2] | 2352 | filename_cmx=[filename_cmx 'x']; |
---|
| 2353 | |
---|
| 2354 | %CIV1 |
---|
| 2355 | if box_test(1)==1 |
---|
[41] | 2356 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[2] | 2357 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
[41] | 2358 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 2359 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2360 | |
---|
| 2361 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2362 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 2363 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 2364 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 2365 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 2366 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 2367 | if test_mask==0 |
---|
| 2368 | par_civ1.maskname='noFile use default'; |
---|
| 2369 | par_civ1.maskflag='n'; |
---|
| 2370 | else |
---|
| 2371 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 2372 | if exist(maskdispl,'file') |
---|
| 2373 | par_civ1.maskname=maskdispl; |
---|
| 2374 | par_civ1.maskflag='y'; |
---|
[2] | 2375 | else |
---|
[12] | 2376 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2377 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2378 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2379 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2380 | if exist(par_civ1.maskname,'file') |
---|
| 2381 | par_civ1.maskflag='y'; |
---|
| 2382 | else |
---|
| 2383 | par_civ1.maskname='noFile use default'; |
---|
| 2384 | par_civ1.maskflag='n'; |
---|
| 2385 | end |
---|
[2] | 2386 | end |
---|
| 2387 | end |
---|
| 2388 | |
---|
| 2389 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 2390 | if test_grid |
---|
| 2391 | par_civ1.gridflag='y'; |
---|
| 2392 | gridname=get(handles.grid_civ1,'String'); |
---|
| 2393 | if isequal(gridname(end-3:end),'grid') |
---|
| 2394 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2395 | if ~isempty(nbslice_grid) |
---|
| 2396 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2397 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2398 | if ~exist(par_civ1.gridname,'file') |
---|
| 2399 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2400 | end |
---|
| 2401 | elseif exist(gridname,'file') |
---|
| 2402 | par_civ1.gridname=gridname; |
---|
| 2403 | else |
---|
| 2404 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2405 | end |
---|
| 2406 | end |
---|
| 2407 | else |
---|
| 2408 | par_civ1.gridname='noFile use default'; |
---|
| 2409 | par_civ1.gridflag='n'; |
---|
| 2410 | end |
---|
[54] | 2411 | % |
---|
[2] | 2412 | i_cmd=i_cmd+1; |
---|
| 2413 | if isequal(civAll,0) |
---|
[12] | 2414 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)]; |
---|
[2] | 2415 | else |
---|
| 2416 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
| 2417 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
| 2418 | fieldnames=fields(str); |
---|
| 2419 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 2420 | for ilist=1:length(fieldnames) |
---|
| 2421 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2422 | if ischar(val) |
---|
| 2423 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 2424 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2425 | end |
---|
| 2426 | end |
---|
| 2427 | end |
---|
| 2428 | end |
---|
| 2429 | |
---|
| 2430 | % FIX1 |
---|
| 2431 | if box_test(2)==1 |
---|
| 2432 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2433 | if test_mask==0 |
---|
| 2434 | maskname=''; |
---|
| 2435 | else |
---|
| 2436 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 2437 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2438 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2439 | maskbase=[filebase '_' maskdispl]; |
---|
| 2440 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2441 | end |
---|
| 2442 | if isequal(civAll,0) |
---|
| 2443 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
| 2444 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 2445 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[12] | 2446 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2447 | else |
---|
| 2448 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2449 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 2450 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 2451 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 2452 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 2453 | fix1.threshV=num2str(thresh_vel1); |
---|
| 2454 | fieldnames=fields(fix1); |
---|
| 2455 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 2456 | for ilist=1:length(fieldnames) |
---|
| 2457 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 2458 | if ischar(val) |
---|
| 2459 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 2460 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2461 | end |
---|
| 2462 | end |
---|
| 2463 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 2464 | end |
---|
| 2465 | end |
---|
| 2466 | |
---|
| 2467 | %PATCH1 |
---|
| 2468 | if box_test(3)==1 |
---|
| 2469 | if isequal(civAll,0) |
---|
| 2470 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
[12] | 2471 | cmd=[cmd '\n' cmd_PATCH]; |
---|
[2] | 2472 | else |
---|
| 2473 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2474 | patch1.nopt=subdomain_patch1; |
---|
| 2475 | patch1.maxdiff=thresh_patch1; |
---|
| 2476 | patch1.ro=rho_patch1; |
---|
| 2477 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 2478 | if test_grid |
---|
| 2479 | patch1.gridflag='y'; |
---|
| 2480 | gridname=get(handles.grid_patch1,'String'); |
---|
| 2481 | if isequal(gridname(end-3:end),'grid') |
---|
| 2482 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2483 | if ~isempty(nbslice_grid) |
---|
| 2484 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2485 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2486 | if ~exist(patch1.gridPatch,'file') |
---|
| 2487 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2488 | end |
---|
| 2489 | elseif exist(gridname,'file') |
---|
| 2490 | patch1.gridPatch=gridname; |
---|
| 2491 | else |
---|
| 2492 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2493 | end |
---|
| 2494 | end |
---|
| 2495 | else |
---|
| 2496 | patch1.gridPatch='n'; |
---|
| 2497 | patch1.gridflag='n'; |
---|
| 2498 | patch1.m=nx_patch1; |
---|
| 2499 | patch1.n=ny_patch1; |
---|
| 2500 | end |
---|
| 2501 | patch1.convectFlow='n'; |
---|
| 2502 | fieldnames=fields(patch1); |
---|
| 2503 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2504 | for ilist=1:length(fieldnames) |
---|
| 2505 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2506 | if ischar(val) |
---|
| 2507 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2508 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2509 | end |
---|
| 2510 | end |
---|
| 2511 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2512 | end |
---|
| 2513 | end |
---|
| 2514 | |
---|
| 2515 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
| 2516 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
| 2517 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 2518 | filename_cmx=[filename_cmx 'x']; |
---|
| 2519 | end |
---|
| 2520 | |
---|
| 2521 | if box_test(4)==1 |
---|
| 2522 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2523 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2524 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2525 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2526 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2527 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 2528 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 2529 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 2530 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 2531 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2532 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2533 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 2534 | if test_mask==0 |
---|
| 2535 | par_civ2.maskname='noFile use default'; |
---|
| 2536 | par_civ2.maskflag='n'; |
---|
| 2537 | else |
---|
| 2538 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2539 | if exist(maskdispl,'file') |
---|
| 2540 | par_civ2.maskname=maskdispl; |
---|
| 2541 | par_civ2.maskflag='y'; |
---|
[2] | 2542 | else |
---|
[12] | 2543 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2544 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2545 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2546 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2547 | if exist(par_civ2.maskname,'file') |
---|
| 2548 | par_civ2.maskflag='y'; |
---|
| 2549 | else |
---|
| 2550 | par_civ2.maskname='noFile use default'; |
---|
| 2551 | par_civ2.maskflag='n'; |
---|
| 2552 | end |
---|
[2] | 2553 | end |
---|
| 2554 | end |
---|
| 2555 | %TESTgrid |
---|
| 2556 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 2557 | gridname=get(handles.grid_civ2,'String'); |
---|
| 2558 | gridflag='y'; |
---|
| 2559 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
| 2560 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2561 | if ~isempty(nbslice_grid) |
---|
| 2562 | par_civ2.gridflag='y'; |
---|
| 2563 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2564 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2565 | if exist(par_civ2.gridname,'file') |
---|
| 2566 | par_civ2.gridflag='y'; |
---|
| 2567 | else |
---|
| 2568 | par_civ2.gridname='noFile use default'; |
---|
| 2569 | par_civ2.gridflag='n'; |
---|
| 2570 | end |
---|
| 2571 | elseif exist(gridname,'file') |
---|
| 2572 | par_civ2.gridflag='y'; |
---|
| 2573 | else |
---|
| 2574 | par_civ2.gridname='noFile use default'; |
---|
| 2575 | par_civ2.gridflag='n'; |
---|
| 2576 | end |
---|
| 2577 | end |
---|
| 2578 | %endTESTgrid |
---|
| 2579 | i_cmd=i_cmd+1; |
---|
| 2580 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2); |
---|
| 2581 | if isequal(civAll,0) |
---|
| 2582 | if(isunix) |
---|
[12] | 2583 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2584 | else |
---|
[12] | 2585 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2586 | end |
---|
| 2587 | else |
---|
| 2588 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
| 2589 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
| 2590 | fieldnames=fields(str); |
---|
| 2591 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2592 | for ilist=1:length(fieldnames) |
---|
| 2593 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2594 | if ischar(val) |
---|
| 2595 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2596 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2597 | end |
---|
| 2598 | end |
---|
| 2599 | end |
---|
| 2600 | end |
---|
| 2601 | |
---|
| 2602 | % FIX2 |
---|
[12] | 2603 | if box_test(5)==1 |
---|
[2] | 2604 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2605 | if test_mask==0 |
---|
| 2606 | maskname=''; %no mask used |
---|
| 2607 | else |
---|
| 2608 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 2609 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2610 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2611 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2612 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2613 | end |
---|
| 2614 | if isequal(civAll,0) |
---|
| 2615 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2616 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2617 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[12] | 2618 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2619 | else |
---|
| 2620 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2621 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2622 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2623 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2624 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2625 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2626 | fieldnames=fields(fix2); |
---|
| 2627 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2628 | for ilist=1:length(fieldnames) |
---|
| 2629 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2630 | if ischar(val) |
---|
| 2631 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2632 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2633 | end |
---|
| 2634 | end |
---|
| 2635 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2636 | end |
---|
| 2637 | end |
---|
| 2638 | |
---|
| 2639 | %PATCH2 |
---|
[12] | 2640 | if box_test(6)==1 |
---|
| 2641 | if isequal(civAll,0) |
---|
| 2642 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
| 2643 | cmd=[cmd '\n' cmd_PATCH]; |
---|
| 2644 | else |
---|
| 2645 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2646 | patch2.nopt=subdomain_patch1; |
---|
| 2647 | patch2.maxdiff=thresh_patch1; |
---|
| 2648 | patch2.ro=rho_patch1; |
---|
| 2649 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2650 | if test_grid |
---|
| 2651 | patch2.gridflag='y'; |
---|
| 2652 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2653 | if isequal(gridname(end-3:end),'grid') |
---|
| 2654 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2655 | if ~isempty(nbslice_grid) |
---|
| 2656 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2657 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2658 | if ~exist(patch2.gridPatch,'file') |
---|
| 2659 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2660 | end |
---|
| 2661 | elseif exist(gridname,'file') |
---|
| 2662 | patch2.gridPatch=gridname; |
---|
| 2663 | else |
---|
| 2664 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2665 | end |
---|
| 2666 | end |
---|
[12] | 2667 | else |
---|
| 2668 | patch2.gridPatch='n'; |
---|
| 2669 | patch2.gridflag='n'; |
---|
| 2670 | patch2.m=nx_patch2; |
---|
| 2671 | patch2.n=ny_patch2; |
---|
[2] | 2672 | end |
---|
[12] | 2673 | patch2.convectFlow='n'; |
---|
| 2674 | fieldnames=fields(patch2); |
---|
| 2675 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2676 | for ilist=1:length(fieldnames) |
---|
| 2677 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2678 | if ischar(val) |
---|
| 2679 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2680 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2681 | end |
---|
| 2682 | end |
---|
| 2683 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
| 2684 | end |
---|
| 2685 | end |
---|
| 2686 | if isequal(civAll,1) |
---|
| 2687 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
| 2688 | cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
| 2689 | end |
---|
| 2690 | % create the .bat file: |
---|
| 2691 | if sge |
---|
| 2692 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2693 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
| 2694 | else |
---|
| 2695 | filename_bat=filename_cmx; |
---|
| 2696 | end |
---|
| 2697 | filename_bat(end-2:end)='bat'; |
---|
| 2698 | fid=fopen(filename_bat,'w'); |
---|
[39] | 2699 | fprintf(fid,cmd); |
---|
| 2700 | fclose(fid); |
---|
[12] | 2701 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
| 2702 | if sge |
---|
| 2703 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2704 | namelog=[filename_bat '.patch.log']; |
---|
| 2705 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
| 2706 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2707 | else |
---|
| 2708 | if(isunix) |
---|
| 2709 | cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
[2] | 2710 | else |
---|
[12] | 2711 | cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
[2] | 2712 | end |
---|
[12] | 2713 | count= fprintf(p1,'%s\n', cmdtodo); |
---|
| 2714 | end |
---|
[2] | 2715 | end |
---|
| 2716 | end |
---|
| 2717 | if ~sge |
---|
| 2718 | fclose(p1); |
---|
| 2719 | fclose(p0); |
---|
| 2720 | delete(name_lock); |
---|
| 2721 | end |
---|
| 2722 | |
---|
| 2723 | set(handles.BATCH, 'Enable','On') |
---|
| 2724 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2725 | |
---|
| 2726 | %save interface state |
---|
| 2727 | if isfield(filecell,'nc') |
---|
| 2728 | if isfield(filecell.nc,'civ2') |
---|
| 2729 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2730 | else |
---|
| 2731 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2732 | end |
---|
| 2733 | end |
---|
| 2734 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2735 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2736 | detect=1; |
---|
| 2737 | while detect==1 |
---|
| 2738 | namefigfull=[namedoc '.fig']; |
---|
| 2739 | hh=dir(namefigfull); |
---|
| 2740 | if ~isempty(hh) |
---|
| 2741 | detect=1; |
---|
| 2742 | namedoc=[namedoc '.0']; |
---|
| 2743 | else |
---|
| 2744 | detect=0; |
---|
| 2745 | end |
---|
| 2746 | end |
---|
| 2747 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2748 | |
---|
[12] | 2749 | %------------------------------------------------------------------------ |
---|
[2] | 2750 | %OUTPUT: |
---|
| 2751 | % filecell: structure of input and output files |
---|
| 2752 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
| 2753 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
| 2754 | % .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) |
---|
| 2755 | % .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) |
---|
| 2756 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
| 2757 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
| 2758 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
[41] | 2759 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
| 2760 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
| 2761 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
| 2762 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
| 2763 | % nom_type_nc: nomenclature type for velocity files |
---|
| 2764 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
[2] | 2765 | 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]=... |
---|
| 2766 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2767 | %------------------------------------------------------------------------ |
---|
[2] | 2768 | %get the filename root, nomenclature and numbers |
---|
| 2769 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2770 | browse=get(handles.browse_root,'UserData'); |
---|
| 2771 | compare_list=get(handles.compare,'String'); |
---|
| 2772 | val=get(handles.compare,'Value'); |
---|
| 2773 | compare=compare_list{val}; |
---|
| 2774 | if strcmp(compare,'displacement') |
---|
| 2775 | mode='displacement'; |
---|
| 2776 | else |
---|
| 2777 | mode_list=get(handles.mode,'String'); |
---|
| 2778 | mode_value=get(handles.mode,'Value'); |
---|
| 2779 | mode=mode_list{mode_value}; |
---|
| 2780 | end |
---|
| 2781 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2782 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 2783 | nom_type_nc=browse.nom_type_nc; |
---|
| 2784 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2785 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 2786 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 2787 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2788 | find_pair_indices(handles,mode); |
---|
| 2789 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2790 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2791 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
| 2792 | test_disp=1; |
---|
| 2793 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2794 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2795 | Path1=Path2; |
---|
| 2796 | Name1=get(handles.displ_filebase2,'String');% root name of the first field series for stereo |
---|
| 2797 | filebase_A=fullfile(Path1,Name1); |
---|
| 2798 | if length(Name1)>6 |
---|
| 2799 | Name1=Name1(end-5:end); |
---|
| 2800 | end |
---|
| 2801 | if length(Name2)>6 |
---|
| 2802 | Name2=Name2(end-5:end); |
---|
| 2803 | end |
---|
| 2804 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2805 | else |
---|
| 2806 | test_disp=0; |
---|
| 2807 | filebase_A=filebase; |
---|
| 2808 | nom_type_ima1=nom_type_ima2; |
---|
| 2809 | filebase_AB=filebase; |
---|
| 2810 | end |
---|
| 2811 | if strcmp(compare,'displacement') |
---|
| 2812 | filebase_ima1=filebase_A; |
---|
| 2813 | filebase_ima2=filebase_B; |
---|
| 2814 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
| 2815 | else |
---|
| 2816 | filebase_ima1=filebase_B; |
---|
| 2817 | filebase_ima2=filebase_B; |
---|
| 2818 | filebase_nc=filebase_B; |
---|
| 2819 | end |
---|
| 2820 | |
---|
| 2821 | %determine reference files for fix: |
---|
| 2822 | file_ref_fix1={};%default |
---|
| 2823 | file_ref_fix2={}; |
---|
| 2824 | nbfield=length(num1_civ1); |
---|
| 2825 | nbslice=length(num_a_civ1); |
---|
| 2826 | if box_test(2)==1% fix1 performed |
---|
| 2827 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2828 | if ~isempty(ref) |
---|
| 2829 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2830 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2831 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2832 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2833 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2834 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2835 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2836 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2837 | if isequal(mode,'displacement') |
---|
| 2838 | num_i1=num_i_ref; |
---|
| 2839 | num_i2=num_i_ref; |
---|
| 2840 | num_j1=num_j_ref; |
---|
| 2841 | num_j2=num_j_ref; |
---|
| 2842 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2843 | num_i1=num_i_ref; |
---|
| 2844 | num_i2=num_i1; |
---|
| 2845 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2846 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2847 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2848 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2849 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2850 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2851 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2852 | if isempty(ref.num_a) |
---|
| 2853 | ref.num_a=1; |
---|
| 2854 | end |
---|
| 2855 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2856 | num_j2=num_j1; |
---|
| 2857 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2858 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2859 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2860 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2861 | num_i2=num_i1; |
---|
| 2862 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2863 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2864 | end |
---|
| 2865 | for ifile=1:nbfield |
---|
| 2866 | for j=1:nbslice |
---|
| 2867 | 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);% |
---|
| 2868 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2869 | if ~exist(file_ref,'file') |
---|
| 2870 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2871 | filecell=[]; |
---|
[2] | 2872 | return |
---|
| 2873 | end |
---|
| 2874 | end |
---|
| 2875 | end |
---|
| 2876 | end |
---|
| 2877 | end |
---|
| 2878 | |
---|
| 2879 | %determine reference files for fix2: |
---|
| 2880 | if box_test(5)==1% fix2 performed |
---|
| 2881 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2882 | if ~isempty(ref) |
---|
| 2883 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2884 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2885 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2886 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2887 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2888 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2889 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2890 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2891 | if isequal(mode,'displacement') |
---|
| 2892 | num_i1=num_i_ref; |
---|
| 2893 | num_i2=num_i_ref; |
---|
| 2894 | num_j1=num_j_ref; |
---|
| 2895 | num_j2=num_j_ref; |
---|
| 2896 | elseif isequal(mode,'pair j1-j2') |
---|
| 2897 | num_i1=num_i_ref; |
---|
| 2898 | num_i2=num_i1; |
---|
| 2899 | num_j1=ref.num_a; |
---|
| 2900 | num_j2=ref.num_b; |
---|
| 2901 | elseif isequal(mode,'series(Di)') |
---|
| 2902 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2903 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2904 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2905 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2906 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2907 | num_j2=num_j1; |
---|
| 2908 | elseif isequal(mode,'series(Dj)') |
---|
| 2909 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2910 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2911 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2912 | num_i2=num_i1; |
---|
| 2913 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2914 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2915 | end |
---|
| 2916 | for ifile=1:nbfield |
---|
| 2917 | for j=1:nbslice |
---|
| 2918 | 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);% |
---|
| 2919 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2920 | if ~exist(file_ref,'file') |
---|
| 2921 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[12] | 2922 | filecell=[]; |
---|
[2] | 2923 | return |
---|
| 2924 | end |
---|
| 2925 | end |
---|
| 2926 | end |
---|
| 2927 | end |
---|
| 2928 | end |
---|
| 2929 | |
---|
| 2930 | %check dir |
---|
| 2931 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2932 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2933 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2934 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 2935 | currentdir=pwd;%store the current working directory |
---|
| 2936 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2937 | if ~exist(Path_ima,'dir') |
---|
[12] | 2938 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
| 2939 | filecell=[]; |
---|
[2] | 2940 | return |
---|
| 2941 | end |
---|
| 2942 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
| 2943 | dircur=pwd; %current working directory |
---|
| 2944 | m2=''; |
---|
| 2945 | [erread,message]=fileattrib(Path_ima); |
---|
| 2946 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 2947 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[12] | 2948 | filecell=[]; |
---|
[2] | 2949 | cd(currentdir); |
---|
| 2950 | return |
---|
| 2951 | end |
---|
| 2952 | |
---|
| 2953 | %check the existence of the netcdf and image files involved |
---|
| 2954 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2955 | if box_test(1)==1; |
---|
| 2956 | detect=1; |
---|
| 2957 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 2958 | for ifile=1:nbfield; |
---|
| 2959 | for j=1:nbslice |
---|
| 2960 | 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); |
---|
| 2961 | detect=exist(filename,'file')==2; |
---|
| 2962 | if detect% if a netcdf file already exists |
---|
| 2963 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2964 | subdir_civ2=subdir_civ1; |
---|
| 2965 | break |
---|
| 2966 | end |
---|
| 2967 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2968 | end |
---|
| 2969 | if detect% if a netcdf file already exists |
---|
| 2970 | break |
---|
| 2971 | end |
---|
| 2972 | end |
---|
| 2973 | %create the new subdir_civ1 |
---|
| 2974 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2975 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 2976 | if ~isequal(m2,'') |
---|
| 2977 | msgbox_uvmat('ERROR', m2) |
---|
| 2978 | %msgbox(m2);%error message for directory creation |
---|
| 2979 | end |
---|
| 2980 | end |
---|
| 2981 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2982 | for ifile=1:nbfield |
---|
| 2983 | for j=1:nbslice |
---|
| 2984 | 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);% |
---|
| 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.ncA.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 | end |
---|
| 3003 | end |
---|
| 3004 | end |
---|
| 3005 | end |
---|
| 3006 | % get image names |
---|
| 3007 | for ifile=1:nbfield |
---|
| 3008 | for j=1:nbslice |
---|
| 3009 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3010 | idetect(j)=exist(filename,'file')==2; |
---|
| 3011 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 3012 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3013 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3014 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
| 3015 | end |
---|
| 3016 | [idetectmin,indexj]=min(idetect); |
---|
| 3017 | if idetectmin==0, |
---|
| 3018 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3019 | filecell=[]; |
---|
[2] | 3020 | return |
---|
| 3021 | end |
---|
| 3022 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3023 | if idetectmin==0, |
---|
| 3024 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3025 | filecell=[]; |
---|
[2] | 3026 | cd(currentdir) |
---|
| 3027 | return |
---|
| 3028 | end |
---|
| 3029 | end |
---|
| 3030 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 3031 | for ifile=1:nbfield |
---|
| 3032 | for j=1:nbslice |
---|
| 3033 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3034 | idetect(j)=exist(filename,'file')==2; |
---|
| 3035 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 3036 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3037 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3038 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 3039 | end |
---|
| 3040 | [idetectmin,indexj]=min(idetect); |
---|
| 3041 | if idetectmin==0, |
---|
| 3042 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3043 | filecell=[]; |
---|
| 3044 | cd(currentdir) |
---|
| 3045 | return |
---|
[2] | 3046 | end |
---|
| 3047 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3048 | if idetectmin==0, |
---|
[12] | 3049 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
| 3050 | filecell=[]; |
---|
| 3051 | cd(currentdir) |
---|
| 3052 | return |
---|
[2] | 3053 | end |
---|
| 3054 | end |
---|
| 3055 | end |
---|
| 3056 | |
---|
| 3057 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 3058 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
| 3059 | for ifile=1:nbfield |
---|
| 3060 | for j=1:nbslice |
---|
| 3061 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3062 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3063 | detect=exist(filename,'file')==2; |
---|
| 3064 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3065 | end |
---|
| 3066 | end |
---|
| 3067 | if strcmp(compare,'stereo PIV') |
---|
| 3068 | for ifile=1:nbfield |
---|
| 3069 | for j=1:nbslice |
---|
| 3070 | 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);% |
---|
| 3071 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3072 | if ~exist(filename,'file') |
---|
| 3073 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3074 | set(handles.RUN, 'Enable','On') |
---|
| 3075 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3076 | set(handles.BATCH, 'Enable','On') |
---|
| 3077 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[12] | 3078 | filecell=[]; |
---|
[2] | 3079 | cd(currentdir) |
---|
| 3080 | return |
---|
| 3081 | end |
---|
| 3082 | end |
---|
| 3083 | end |
---|
| 3084 | end |
---|
| 3085 | end |
---|
| 3086 | |
---|
| 3087 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 3088 | testdiff=0; |
---|
| 3089 | if (box_test(4)==1)&&... |
---|
| 3090 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
| 3091 | testdiff=1; |
---|
| 3092 | detect=1; |
---|
| 3093 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3094 | for ifile=1:nbfield |
---|
| 3095 | for j=1:nbslice |
---|
| 3096 | 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);% |
---|
| 3097 | detect=exist(filename,'file')==2; |
---|
| 3098 | if detect% if a netcdf file already exists |
---|
| 3099 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3100 | break |
---|
| 3101 | end |
---|
| 3102 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3103 | end |
---|
| 3104 | if detect% if a netcdf file already exists |
---|
| 3105 | break |
---|
| 3106 | end |
---|
| 3107 | end |
---|
| 3108 | %create the new subdir_civ2 |
---|
| 3109 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3110 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3111 | if ~isequal(m2,'') |
---|
| 3112 | msgbox_uvmat('ERROR', m2) |
---|
| 3113 | end |
---|
| 3114 | end |
---|
| 3115 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 3116 | for ifile=1:nbfield |
---|
| 3117 | for j=1:nbslice |
---|
| 3118 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3119 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
| 3120 | detect=exist(filename,'file')==2; |
---|
| 3121 | if detect% if a netcdf file already exists |
---|
| 3122 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3123 | break |
---|
| 3124 | end |
---|
| 3125 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3126 | end |
---|
| 3127 | if detect% if a netcdf file already exists |
---|
| 3128 | break |
---|
| 3129 | end |
---|
| 3130 | end |
---|
| 3131 | %create the new subdir_civ1 |
---|
| 3132 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3133 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3134 | if ~isequal(m2,'') |
---|
| 3135 | msgbox_uvmat('ERROR', m2) |
---|
| 3136 | %msgbox(m2);%error message for directory creation |
---|
| 3137 | end |
---|
| 3138 | end |
---|
| 3139 | end |
---|
| 3140 | end |
---|
| 3141 | end |
---|
| 3142 | cd(currentdir);%come back to the current working directory |
---|
| 3143 | |
---|
| 3144 | |
---|
| 3145 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 3146 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 3147 | %check source netcdf file of civ1 estimates |
---|
| 3148 | if box_test(1)==0; %no civ1 performed |
---|
| 3149 | for ifile=1:nbfield |
---|
| 3150 | for j=1:nbslice |
---|
| 3151 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3152 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3153 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 3154 | if ~exist(filename,'file') |
---|
| 3155 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3156 | filecell=[]; |
---|
[2] | 3157 | return |
---|
| 3158 | end |
---|
| 3159 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 3160 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 3161 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3162 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3163 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3164 | filecell=[]; |
---|
[2] | 3165 | return |
---|
| 3166 | end |
---|
| 3167 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 3168 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 3169 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 3170 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 3171 | filecell=[]; |
---|
[2] | 3172 | return |
---|
| 3173 | end |
---|
| 3174 | end |
---|
| 3175 | end |
---|
| 3176 | end |
---|
| 3177 | end |
---|
| 3178 | if strcmp(compare,'stereo PIV') |
---|
| 3179 | for ifile=1:nbfield |
---|
| 3180 | for j=1:nbslice |
---|
| 3181 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3182 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3183 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3184 | if ~exist(filename,'file') |
---|
| 3185 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3186 | set(handles.RUN, 'Enable','On') |
---|
| 3187 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3188 | set(handles.BATCH, 'Enable','On') |
---|
| 3189 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 3190 | cd(currentdir) |
---|
| 3191 | return |
---|
| 3192 | end |
---|
| 3193 | end |
---|
| 3194 | end |
---|
| 3195 | end |
---|
| 3196 | end |
---|
| 3197 | |
---|
| 3198 | detect=1; |
---|
| 3199 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 3200 | for ifile=1:nbfield |
---|
| 3201 | for j=1:nbslice |
---|
| 3202 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3203 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
| 3204 | detect=exist(filename,'file')==2; |
---|
| 3205 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3206 | end |
---|
| 3207 | end |
---|
| 3208 | %get first image names for civ2 |
---|
| 3209 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 3210 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 3211 | elseif box_test(4)==1 |
---|
| 3212 | for ifile=1:nbfield |
---|
| 3213 | for j=1:nbslice |
---|
| 3214 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 3215 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 3216 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 3217 | end |
---|
| 3218 | [idetectmin,indexj]=min(idetect_2); |
---|
| 3219 | if idetectmin==0, |
---|
| 3220 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3221 | filecell=[]; |
---|
[2] | 3222 | return |
---|
| 3223 | end |
---|
| 3224 | end |
---|
| 3225 | end |
---|
| 3226 | |
---|
| 3227 | %get second image names for civ2 |
---|
| 3228 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 3229 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 3230 | elseif box_test(4)==1 |
---|
| 3231 | for ifile=1:nbfield |
---|
| 3232 | for j=1:nbslice |
---|
| 3233 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 3234 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 3235 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 3236 | end |
---|
| 3237 | [idetectmin,indexj]=min(idetect_3); |
---|
| 3238 | if idetectmin==0, |
---|
| 3239 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3240 | filecell=[]; |
---|
[2] | 3241 | return |
---|
| 3242 | end |
---|
| 3243 | end |
---|
| 3244 | end |
---|
| 3245 | end |
---|
| 3246 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 3247 | if ~testdiff |
---|
| 3248 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
| 3249 | else % check the civ2 files |
---|
| 3250 | for ifile=1:nbfield |
---|
| 3251 | for j=1:nbslice |
---|
| 3252 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3253 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3254 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3255 | if ~exist(filename,'file') |
---|
| 3256 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3257 | filecell=[]; |
---|
[2] | 3258 | return |
---|
| 3259 | else |
---|
| 3260 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3261 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3262 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3263 | filecell=[]; |
---|
[2] | 3264 | return |
---|
| 3265 | end |
---|
| 3266 | end |
---|
| 3267 | end |
---|
| 3268 | end |
---|
| 3269 | end |
---|
| 3270 | end |
---|
| 3271 | |
---|
| 3272 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 3273 | if strcmp(compare,'stereo PIV') |
---|
| 3274 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 3275 | for ifile=1:nbfield |
---|
| 3276 | for j=1:nbslice |
---|
| 3277 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3278 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3279 | filecell.st(ifile,j)={filename}; |
---|
| 3280 | end |
---|
| 3281 | end |
---|
| 3282 | end |
---|
| 3283 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 3284 | for ifile=1:nbfield |
---|
| 3285 | for j=1:nbslice |
---|
| 3286 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3287 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3288 | filecell.st(ifile,j)={filename}; |
---|
| 3289 | end |
---|
| 3290 | end |
---|
| 3291 | end |
---|
| 3292 | end |
---|
| 3293 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3294 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3295 | browse.nom_type_nc=nom_type_nc; |
---|
| 3296 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 3297 | |
---|
| 3298 | |
---|
| 3299 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 3300 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 3301 | nom_type_imanew1='_i'; |
---|
[2] | 3302 | else |
---|
| 3303 | nom_type_imanew1=nom_type_ima1; |
---|
| 3304 | end |
---|
[45] | 3305 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 3306 | nom_type_imanew2='_i'; |
---|
[2] | 3307 | else |
---|
| 3308 | nom_type_imanew2=nom_type_ima2; |
---|
| 3309 | end |
---|
| 3310 | if ~isequal(ext_ima,'.png') |
---|
[45] | 3311 | %%type of image file |
---|
| 3312 | type_ima1='none';%default |
---|
| 3313 | movieobject1=[];%default |
---|
| 3314 | if isequal(lower(ext_ima),'.avi') |
---|
| 3315 | hhh=which('mmreader'); |
---|
| 3316 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3317 | type_ima1='movie'; |
---|
| 3318 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 3319 | else |
---|
| 3320 | type_ima1='avi'; |
---|
| 3321 | end |
---|
| 3322 | else |
---|
| 3323 | form=imformats(ext_ima(2:end)); |
---|
| 3324 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3325 | if isequal(nom_type_ima1,'*'); |
---|
| 3326 | type_ima1='multimage';%image series in a single image file |
---|
| 3327 | else |
---|
| 3328 | type_ima1='image'; |
---|
| 3329 | end |
---|
| 3330 | end |
---|
| 3331 | end |
---|
| 3332 | type_ima2='none';%default |
---|
| 3333 | movieobject2=[]; |
---|
| 3334 | if isequal(lower(ext_ima),'.avi') |
---|
| 3335 | hhh=which('mmreader'); |
---|
| 3336 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3337 | type_ima2='movie'; |
---|
| 3338 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 3339 | else |
---|
| 3340 | type_ima2='avi'; |
---|
| 3341 | end |
---|
| 3342 | else |
---|
| 3343 | form=imformats(ext_ima(2:end)); |
---|
| 3344 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3345 | if isequal(nom_type_ima1,'*'); |
---|
| 3346 | type_ima2='multimage';%image series in a single image file |
---|
| 3347 | else |
---|
| 3348 | type_ima2='image'; |
---|
| 3349 | end |
---|
| 3350 | end |
---|
| 3351 | end |
---|
[2] | 3352 | %npxy=get(handles.ext_ima,'UserData'); |
---|
| 3353 | % % if numel(npxy)<2 |
---|
| 3354 | % |
---|
| 3355 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1); |
---|
| 3356 | % A=imread(filename); |
---|
| 3357 | % npxy=size(A); |
---|
| 3358 | % % end |
---|
| 3359 | % npy=npxy(1); |
---|
| 3360 | % npx=npxy(2); |
---|
| 3361 | if box_test(1)==1 %if civ1 is performed |
---|
| 3362 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 3363 | for ifile=1:nbfield |
---|
| 3364 | waitbar(ifile/nbfield); |
---|
| 3365 | for j=1:nbslice |
---|
| 3366 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3367 | if ~exist(filename,'file') |
---|
[45] | 3368 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
[2] | 3369 | imwrite(A,filename,'BitDepth',16); |
---|
| 3370 | end |
---|
| 3371 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3372 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3373 | if ~exist(filename,'file') |
---|
[45] | 3374 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
[2] | 3375 | imwrite(A,filename,'BitDepth',16); |
---|
| 3376 | end |
---|
| 3377 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
| 3378 | end |
---|
| 3379 | end |
---|
| 3380 | close(h) |
---|
| 3381 | end |
---|
| 3382 | if box_test(4)==1 %if civ2 is performed |
---|
| 3383 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
| 3384 | for ifile=1:nbfield |
---|
| 3385 | waitbar(ifile/nbfield); |
---|
| 3386 | for j=1:nbslice |
---|
| 3387 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3388 | if ~exist(filename,'file') |
---|
| 3389 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
| 3390 | imwrite(A,filename,'BitDepth',16); |
---|
| 3391 | end |
---|
| 3392 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3393 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3394 | if ~exist(filename,'file') |
---|
| 3395 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
| 3396 | imwrite(A,filename,'BitDepth',16); |
---|
| 3397 | end |
---|
| 3398 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
| 3399 | end |
---|
| 3400 | end |
---|
| 3401 | close(h); |
---|
| 3402 | end |
---|
| 3403 | end |
---|
| 3404 | |
---|
[12] | 3405 | %------------------------------------------------------------------------ |
---|
[2] | 3406 | %CIV1 CIV1 CIV1 CIV1 |
---|
| 3407 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3408 | %------------------------------------------------------------------------ |
---|
[2] | 3409 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3410 | global civ1_exe sge%name of the executable for civ1 calculation |
---|
| 3411 | |
---|
| 3412 | %get civ parameters |
---|
| 3413 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 3414 | if isempty(ibx_val) |
---|
| 3415 | ibx='21'; set(handles.ibx,'String','21') |
---|
| 3416 | else |
---|
| 3417 | ibx=num2str(ibx_val); |
---|
| 3418 | end |
---|
| 3419 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 3420 | if isempty(iby_val) |
---|
| 3421 | iby='21'; set(handles.iby,'String','21') |
---|
| 3422 | else |
---|
| 3423 | iby=num2str(iby_val); |
---|
| 3424 | end |
---|
| 3425 | isx=get(handles.isx,'String'); |
---|
| 3426 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3427 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 3428 | isy=get(handles.isy,'String'); |
---|
| 3429 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3430 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 3431 | shiftx=get(handles.shiftx,'String'); |
---|
| 3432 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
| 3433 | shifty=get(handles.shifty,'String'); |
---|
| 3434 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
| 3435 | rho=get(handles.rho,'String'); |
---|
| 3436 | dx=get(handles.dx_civ1,'String'); |
---|
| 3437 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
| 3438 | dy=get(handles.dy_civ1,'String'); |
---|
| 3439 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
| 3440 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
| 3441 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
| 3442 | pxcmy='1'; |
---|
| 3443 | image_first=cell2mat(filecell(1,1)); |
---|
| 3444 | if ~exist(image_first,'file') |
---|
| 3445 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
| 3446 | set(handles.RUN, 'Enable','On') |
---|
| 3447 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3448 | return |
---|
| 3449 | end |
---|
| 3450 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
| 3451 | sizim=size(A); |
---|
| 3452 | npx=num2str(sizim(2)); |
---|
| 3453 | npy=num2str(sizim(1)); |
---|
| 3454 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3455 | gridname='';%default ='noFile use default' |
---|
| 3456 | gridflag='n';%default |
---|
| 3457 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 3458 | nbslice_grid=[]; |
---|
| 3459 | if test_grid |
---|
| 3460 | gridname=get(handles.grid_civ1,'String'); |
---|
| 3461 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3462 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3463 | if ~isempty(nbslice_grid) |
---|
| 3464 | gridflag='y'; |
---|
| 3465 | end |
---|
| 3466 | elseif exist(gridname,'file') |
---|
| 3467 | gridflag='y'; |
---|
| 3468 | else |
---|
| 3469 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3470 | return |
---|
| 3471 | end |
---|
| 3472 | end |
---|
| 3473 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 3474 | threshflag='y'; |
---|
| 3475 | min_ima=get(handles.MinIma,'String'); |
---|
| 3476 | max_ima=get(handles.MaxIma,'String'); |
---|
| 3477 | else |
---|
| 3478 | threshflag='n'; |
---|
| 3479 | min_ima='0'; |
---|
| 3480 | max_ima='4096'; |
---|
| 3481 | end |
---|
| 3482 | %main loop |
---|
| 3483 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3484 | sizcell=size(filecell); |
---|
| 3485 | nbfield=sizcell(1); |
---|
| 3486 | nbslice=sizcell(2); |
---|
| 3487 | icount=0; |
---|
| 3488 | for ifile=1:nbfield |
---|
| 3489 | for j=1:nbslice |
---|
| 3490 | icount=icount+1; |
---|
| 3491 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3492 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
| 3493 | drawnow |
---|
| 3494 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
| 3495 | filename_ima([end-3:end])=[];%remove .png extension |
---|
| 3496 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
| 3497 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
| 3498 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
| 3499 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3500 | filename_cmx=[filename_cmx 'x']; |
---|
| 3501 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3502 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3503 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3504 | if isequal(Dt,'0') |
---|
| 3505 | Dt='1' ;%case of 'displacement' mode |
---|
| 3506 | end |
---|
| 3507 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3508 | else |
---|
| 3509 | Dt='1'; |
---|
| 3510 | T0='0'; |
---|
| 3511 | end |
---|
| 3512 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
| 3513 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
| 3514 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3515 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3516 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3517 | if ~exist(gridname,'file') |
---|
| 3518 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3519 | return |
---|
| 3520 | end |
---|
| 3521 | end |
---|
| 3522 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 3523 | if test_mask==0 |
---|
| 3524 | maskname='noFile use default'; |
---|
| 3525 | maskflag='n'; |
---|
| 3526 | else |
---|
| 3527 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
| 3528 | maskbase=[filebase '_' maskdispl];% |
---|
| 3529 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
| 3530 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
| 3531 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3532 | if exist(maskname,'file') |
---|
| 3533 | maskflag='y'; |
---|
| 3534 | else |
---|
| 3535 | maskname='noFile use default'; |
---|
| 3536 | maskflag='n'; |
---|
| 3537 | end |
---|
| 3538 | end |
---|
| 3539 | textcmx={'############## CMX file';... |
---|
| 3540 | ['FirstImage ' filename_ima];... |
---|
| 3541 | ['LastImage ' filename_ima_1];... |
---|
| 3542 | 'XX' ;... |
---|
| 3543 | ['Mask ' maskflag] ;... |
---|
| 3544 | ['MaskName ' maskname];... |
---|
| 3545 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
| 3546 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3547 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
| 3548 | ['RO ' rho];... |
---|
| 3549 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3550 | 'XX 1.0';... |
---|
| 3551 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3552 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3553 | 'XX 1';... |
---|
| 3554 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
| 3555 | ['Grid ' gridflag];... |
---|
| 3556 | ['GridName ' gridname] ;... |
---|
| 3557 | 'XX 85';... |
---|
| 3558 | 'XX 1.0';... |
---|
| 3559 | 'XX 1.0';... |
---|
| 3560 | 'Hart 1';... |
---|
| 3561 | 'DecimalShift 0';... |
---|
| 3562 | 'Deformation 0';... |
---|
| 3563 | 'CorrelationMin 0';... |
---|
| 3564 | 'IntensityMin 0';... |
---|
| 3565 | ['SeuilImage ' threshflag];... |
---|
| 3566 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
| 3567 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3568 | 'ImageUsedBefore null null'}; |
---|
| 3569 | textout=char(textcmx); |
---|
[12] | 3570 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3571 | fid=fopen([filename_cmx],'w'); |
---|
| 3572 | fprintf(fid, ['############## CMX file' '\n']); |
---|
[16] | 3573 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
| 3574 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
[12] | 3575 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3576 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
| 3577 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
| 3578 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 3579 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
| 3580 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
| 3581 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
| 3582 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
| 3583 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3584 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
| 3585 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
| 3586 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 3587 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
| 3588 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
| 3589 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
| 3590 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 3591 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3592 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3593 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 3594 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 3595 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 3596 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 3597 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 3598 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 3599 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 3600 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
| 3601 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 3602 | fclose(fid); |
---|
| 3603 | |
---|
[2] | 3604 | s=-1; |
---|
| 3605 | display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3606 | eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3607 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3608 | % % [s,w] = unix(['qrsh -q fast.q ' civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
| 3609 | % end |
---|
| 3610 | % if s~=0 |
---|
| 3611 | % % ['!' civ1_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3612 | % % eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3613 | % end |
---|
| 3614 | end |
---|
| 3615 | end |
---|
| 3616 | |
---|
[12] | 3617 | %------------------------------------------------------------------------ |
---|
[2] | 3618 | % RUN CIV2 CIV2 CIV2 CIV2 |
---|
| 3619 | function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3620 | %------------------------------------------------------------------------ |
---|
[2] | 3621 | %filecell_2: names of first image |
---|
| 3622 | %filecell_3: names of second images |
---|
| 3623 | global civ2_exe sge |
---|
| 3624 | |
---|
| 3625 | %names of the civ2 fields |
---|
| 3626 | field.vel_type='civ2'; |
---|
| 3627 | field.nb='nb_vectors2'; |
---|
| 3628 | field.X='vec2_X'; |
---|
| 3629 | field.Y='vec2_Y'; |
---|
| 3630 | field.U='vec2_U'; |
---|
| 3631 | field.V='vec2_V'; |
---|
| 3632 | |
---|
| 3633 | %get civ parameters |
---|
| 3634 | ibx=get(handles.ibx_civ2,'String'); |
---|
| 3635 | iby=get(handles.iby_civ2,'String'); |
---|
| 3636 | rho=get(handles.rho_civ2,'String'); |
---|
| 3637 | decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3638 | deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3639 | dx=get(handles.dx_civ2,'String'); |
---|
| 3640 | dy=get(handles.dy_civ2,'String'); |
---|
| 3641 | if isequal(str2num(dx),[]) |
---|
| 3642 | dx='20';%default |
---|
| 3643 | end |
---|
| 3644 | if isequal(str2num(dy),[]) |
---|
| 3645 | dy='20';%default |
---|
| 3646 | end |
---|
| 3647 | pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
| 3648 | pxcmy='1'; |
---|
| 3649 | A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
| 3650 | sizim=size(A); |
---|
| 3651 | npx=num2str(sizim(2)); |
---|
| 3652 | npy=num2str(sizim(1)); |
---|
| 3653 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3654 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3655 | %grid |
---|
| 3656 | gridname='';%default ='noFile use default' |
---|
| 3657 | gridflag='n';%default |
---|
| 3658 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 3659 | nbslice_grid=[]; |
---|
| 3660 | if test_grid |
---|
| 3661 | gridname=get(handles.grid_civ2,'String'); |
---|
| 3662 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3663 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3664 | if ~isempty(nbslice_grid) |
---|
| 3665 | gridflag='y'; |
---|
| 3666 | end |
---|
| 3667 | elseif exist(gridname,'file') |
---|
| 3668 | gridflag='y'; |
---|
| 3669 | else |
---|
| 3670 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3671 | return |
---|
| 3672 | end |
---|
| 3673 | end |
---|
| 3674 | sizcell=size(filecell_2); |
---|
| 3675 | nbfield=sizcell(1); |
---|
| 3676 | nbslice=sizcell(2); |
---|
| 3677 | |
---|
| 3678 | %main loop |
---|
| 3679 | icount=0; |
---|
| 3680 | for ifile=1:nbfield |
---|
| 3681 | for j=1:nbslice |
---|
| 3682 | icount=icount+1; |
---|
| 3683 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3684 | set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
| 3685 | drawnow |
---|
| 3686 | filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
| 3687 | filename_ima_2([end-3:end])=[];%remove .png extension |
---|
| 3688 | filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
| 3689 | filename_ima_3([end-3:end])=[];%remove .png extension |
---|
| 3690 | filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
| 3691 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3692 | filename_cmx=[filename_cmx 'x']; |
---|
| 3693 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3694 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3695 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3696 | if isequal(Dt,'0') |
---|
| 3697 | Dt='1' ;%case of 'displacement' mode |
---|
| 3698 | end |
---|
| 3699 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3700 | else |
---|
| 3701 | Dt='1'; |
---|
| 3702 | T0='0'; |
---|
| 3703 | end |
---|
| 3704 | term_a=num2stra(num_a(j),nom_type_nc); |
---|
| 3705 | term_b=num2stra(num_b(j),nom_type_nc); |
---|
| 3706 | filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
| 3707 | filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 3708 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3709 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3710 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3711 | if ~exist(gridname,'file') |
---|
| 3712 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3713 | return |
---|
| 3714 | end |
---|
| 3715 | end |
---|
| 3716 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 3717 | if test_mask==0 |
---|
| 3718 | maskname='noFile use default'; |
---|
| 3719 | maskflag='n'; |
---|
| 3720 | else |
---|
| 3721 | maskdispl=get(handles.mask_civ2,'String'); |
---|
| 3722 | maskbase=[filebase '_' maskdispl]; % |
---|
| 3723 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 3724 | num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
| 3725 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3726 | if ~exist(maskname,'file') |
---|
| 3727 | maskflag='y'; |
---|
| 3728 | else |
---|
| 3729 | maskname='noFile use default'; |
---|
| 3730 | maskflag='n'; |
---|
| 3731 | end |
---|
| 3732 | end |
---|
| 3733 | |
---|
| 3734 | textcmx={'############## CMX file';... |
---|
| 3735 | ['FirstImage ' filename_ima_2];... |
---|
| 3736 | ['LastImage ' filename_ima_3];... |
---|
| 3737 | 'XX' ;... |
---|
| 3738 | ['Mask ' maskflag];... |
---|
| 3739 | ['MaskName ' maskname];... |
---|
| 3740 | ['ImageSize ' npx ' ' npy];... |
---|
| 3741 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3742 | ['SearchBoxeSize ' ibx ' ' iby];... |
---|
| 3743 | ['RO ' rho];... |
---|
| 3744 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3745 | 'XX 1.0';... |
---|
| 3746 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3747 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3748 | 'XX 1';... |
---|
| 3749 | ['ShiftXY 0 0'];... |
---|
| 3750 | ['Grid ' gridflag];... |
---|
| 3751 | ['GridName ' gridname];... |
---|
| 3752 | 'XX 85';... |
---|
| 3753 | 'XX 1.0';... |
---|
| 3754 | 'XX 1.0';... |
---|
| 3755 | 'Hart 1';... |
---|
| 3756 | ['DecimalShift ' decimal];... |
---|
| 3757 | ['Deformation ' deformation];... |
---|
| 3758 | 'CorrelationMin 0';... |
---|
| 3759 | 'IntensityMin 0';... |
---|
| 3760 | 'SeuilImage n';... |
---|
| 3761 | 'SeuilImageValues 0 4096';... |
---|
| 3762 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3763 | ['ImageUsedBefore ' filename_nc1]}; |
---|
| 3764 | textout=char(textcmx); |
---|
[12] | 3765 | dlmwrite(filename_cmx,textout,''); |
---|
[2] | 3766 | s=-1; |
---|
| 3767 | display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3768 | eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3769 | |
---|
| 3770 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3771 | % [s,w] = unix(['qrsh -q fast.q ' civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
| 3772 | % end |
---|
| 3773 | % if s~=0 |
---|
| 3774 | % eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3775 | % ['!' civ2_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3776 | % end |
---|
| 3777 | end |
---|
| 3778 | end |
---|
| 3779 | % close(h) |
---|
| 3780 | |
---|
[12] | 3781 | %------------------------------------------------------------------------ |
---|
| 3782 | % --- PATCH |
---|
[2] | 3783 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
[12] | 3784 | %------------------------------------------------------------------------ |
---|
[2] | 3785 | global patch_exe patch_new_exe |
---|
| 3786 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3787 | if test_interp==0 |
---|
| 3788 | cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3789 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3790 | else %nouveau programme patch |
---|
| 3791 | cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3792 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3793 | end |
---|
[12] | 3794 | |
---|
| 3795 | %------------------------------------------------------------------------ |
---|
| 3796 | % --- STEREO Interp |
---|
[2] | 3797 | 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] | 3798 | %------------------------------------------------------------------------ |
---|
[2] | 3799 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
| 3800 | cmd=[stinterp_exe ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3801 | ' -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 |
---|
| 3802 | |
---|
[12] | 3803 | %------------------------------------------------------------------------ |
---|
[2] | 3804 | % --- Executes on button press in CIV1. |
---|
| 3805 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3806 | %------------------------------------------------------------------------ |
---|
[2] | 3807 | val=get(handles.CIV1,'Value'); |
---|
| 3808 | if isequal(val,1) |
---|
| 3809 | enable_civ1(handles,'on') |
---|
| 3810 | enable_pair1(handles,'on') |
---|
| 3811 | else |
---|
| 3812 | enable_civ1(handles,'off') |
---|
| 3813 | end |
---|
| 3814 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3815 | |
---|
[12] | 3816 | %------------------------------------------------------------------------ |
---|
[2] | 3817 | % --- Executes on button press in FIX1. |
---|
| 3818 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3819 | %------------------------------------------------------------------------ |
---|
[2] | 3820 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3821 | |
---|
[12] | 3822 | %------------------------------------------------------------------------ |
---|
[2] | 3823 | % --- Executes on button press in PATCH1. |
---|
| 3824 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3825 | %------------------------------------------------------------------------ |
---|
[2] | 3826 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3827 | enable_patch1(handles) |
---|
[2] | 3828 | else |
---|
[12] | 3829 | desable_patch1(handles) |
---|
[2] | 3830 | end |
---|
| 3831 | |
---|
[12] | 3832 | %------------------------------------------------------------------------ |
---|
[2] | 3833 | % --- Executes on button press in CIV2. |
---|
| 3834 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3835 | %------------------------------------------------------------------------ |
---|
[2] | 3836 | state=get(handles.CIV2,'Value'); |
---|
| 3837 | enable_civ2(handles,state) |
---|
| 3838 | if state |
---|
| 3839 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3840 | enable_pair1(handles,'on') |
---|
| 3841 | end |
---|
| 3842 | |
---|
[12] | 3843 | %------------------------------------------------------------------------ |
---|
[2] | 3844 | % --- Executes on button press in FIX2. |
---|
| 3845 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3846 | %------------------------------------------------------------------------ |
---|
[2] | 3847 | if get(handles.FIX2,'Value')==1 |
---|
| 3848 | enable_fix2(handles) |
---|
| 3849 | if get(handles.CIV2,'Value')==0 |
---|
| 3850 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3851 | end |
---|
| 3852 | else |
---|
| 3853 | desable_fix2(handles) |
---|
| 3854 | end |
---|
| 3855 | |
---|
[12] | 3856 | %------------------------------------------------------------------------ |
---|
[2] | 3857 | % --- Executes on button press in PATCH2. |
---|
| 3858 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3859 | %------------------------------------------------------------------------ |
---|
[2] | 3860 | if get(handles.PATCH2,'Value')==1 |
---|
| 3861 | enable_patch2(handles) |
---|
| 3862 | if get(handles.CIV2,'Value')==0 |
---|
| 3863 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3864 | end |
---|
| 3865 | else |
---|
| 3866 | desable_patch2(handles) |
---|
| 3867 | end |
---|
| 3868 | |
---|
[12] | 3869 | %------------------------------------------------------------------------ |
---|
| 3870 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3871 | %------------------------------------------------------------------------ |
---|
| 3872 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 3873 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 3874 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3875 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3876 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3877 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3878 | |
---|
[12] | 3879 | %------------------------------------------------------------------------ |
---|
| 3880 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3881 | %------------------------------------------------------------------------ |
---|
| 3882 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3883 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3884 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3885 | |
---|
[12] | 3886 | %------------------------------------------------------------------------ |
---|
[2] | 3887 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3888 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3889 | %------------------------------------------------------------------------ |
---|
[2] | 3890 | %determine pair numbers |
---|
| 3891 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3892 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3893 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3894 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3895 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3896 | pxcmx=pxcm_xy(1); |
---|
| 3897 | pxcmy=pxcm_xy(2); |
---|
| 3898 | mode_list=get(handles.mode,'String'); |
---|
| 3899 | mode_value=get(handles.mode,'Value'); |
---|
| 3900 | mode=mode_list{mode_value}; |
---|
| 3901 | if isequal (mode, 'series(Di)' ) |
---|
| 3902 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3903 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3904 | num2=ref_i+ceil(index/2); |
---|
| 3905 | num_a=1; |
---|
| 3906 | num_b=1; |
---|
| 3907 | elseif isequal (mode, 'series(Dj)') |
---|
| 3908 | num1=1; |
---|
| 3909 | num2=1; |
---|
| 3910 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3911 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3912 | num_b=ref_j+ceil(index/2); |
---|
| 3913 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3914 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3915 | num1=ref_i; |
---|
| 3916 | num2=ref_i; |
---|
| 3917 | num_a=displ_num(1,index); |
---|
| 3918 | num_b=displ_num(2,index); |
---|
| 3919 | end |
---|
| 3920 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3921 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 3922 | iby=str2num(get(handles.iby,'String')); |
---|
| 3923 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 3924 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 3925 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 3926 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 3927 | shiftx=round((umin+umax)/2); |
---|
| 3928 | shifty=round((vmin+vmax)/2); |
---|
| 3929 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3930 | isx=2*ceil(isx/2)+1; |
---|
| 3931 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3932 | isy=2*ceil(isy/2)+1; |
---|
| 3933 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3934 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3935 | set(handles.isx,'String',num2str(isx)); |
---|
| 3936 | set(handles.isy,'String',num2str(isy)); |
---|
| 3937 | |
---|
[12] | 3938 | %------------------------------------------------------------------------ |
---|
| 3939 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3940 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3941 | %------------------------------------------------------------------------ |
---|
[2] | 3942 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3943 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3944 | if get(handles.CIV1,'Value')==0 |
---|
| 3945 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3946 | end |
---|
| 3947 | |
---|
[12] | 3948 | %------------------------------------------------------------------------ |
---|
| 3949 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3950 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3951 | %------------------------------------------------------------------------ |
---|
[2] | 3952 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3953 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3954 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3955 | end |
---|
| 3956 | |
---|
[12] | 3957 | %------------------------------------------------------------------------ |
---|
[2] | 3958 | % --- Executes on button press in get_mask_civ1. |
---|
| 3959 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3960 | %------------------------------------------------------------------------ |
---|
[2] | 3961 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3962 | if isequal(maskval,0) |
---|
| 3963 | set(handles.mask_civ1,'String','') |
---|
| 3964 | else |
---|
| 3965 | mask_displ='no mask'; %default |
---|
| 3966 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3967 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3968 | if isequal(flag_mask,1) |
---|
| 3969 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
| 3970 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3971 | common_path=fileparts(filebase); |
---|
| 3972 | filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String')); |
---|
| 3973 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[12] | 3974 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
[2] | 3975 | mask_displ='no mask'; |
---|
| 3976 | end |
---|
| 3977 | end |
---|
| 3978 | if isequal(mask_displ,'no mask') |
---|
[12] | 3979 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3980 | {'*.png', ' (*.png)'; |
---|
| 3981 | '*.png', '.png files '; ... |
---|
| 3982 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3983 | 'Pick a mask file *.png',filebase); |
---|
| 3984 | mask_displ=fullfile(PathName,FileName); |
---|
| 3985 | if ~exist(mask_displ,'file') |
---|
| 3986 | mask_displ='no mask'; |
---|
| 3987 | end |
---|
| 3988 | end |
---|
| 3989 | if isequal(mask_displ,'no mask') |
---|
[2] | 3990 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3991 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3992 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3993 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3994 | else |
---|
| 3995 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3996 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3997 | end |
---|
| 3998 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3999 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4000 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4001 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4002 | end |
---|
| 4003 | |
---|
[12] | 4004 | %------------------------------------------------------------------------ |
---|
[2] | 4005 | % --- Executes on button press in get_mask_fix1. |
---|
| 4006 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4007 | %------------------------------------------------------------------------ |
---|
[2] | 4008 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 4009 | if isequal(maskval,0) |
---|
| 4010 | set(handles.mask_fix1,'String','') |
---|
| 4011 | else |
---|
| 4012 | mask_displ='no mask'; %default |
---|
| 4013 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4014 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4015 | if isequal(flag_mask,1) |
---|
| 4016 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4017 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4018 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4019 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4020 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4021 | mask_displ='no mask'; |
---|
| 4022 | end |
---|
| 4023 | end |
---|
| 4024 | if isequal(mask_displ,'no mask') |
---|
[12] | 4025 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4026 | {'*.png', ' (*.png)'; |
---|
| 4027 | '*.png', '.png files '; ... |
---|
| 4028 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4029 | 'Pick a mask file *.png',filebase); |
---|
| 4030 | mask_displ=fullfile(PathName,FileName); |
---|
| 4031 | if ~exist(mask_displ,'file') |
---|
| 4032 | mask_displ='no mask'; |
---|
| 4033 | end |
---|
| 4034 | end |
---|
| 4035 | if isequal(mask_displ,'no mask') |
---|
[2] | 4036 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4037 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4038 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4039 | else |
---|
| 4040 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 4041 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4042 | end |
---|
| 4043 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4044 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4045 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4046 | end |
---|
[12] | 4047 | |
---|
| 4048 | %------------------------------------------------------------------------ |
---|
[2] | 4049 | % --- Executes on button press in get_mask_civ2. |
---|
| 4050 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4051 | %------------------------------------------------------------------------ |
---|
[2] | 4052 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 4053 | if isequal(maskval,0) |
---|
| 4054 | set(handles.mask_civ2,'String','') |
---|
| 4055 | else |
---|
| 4056 | mask_displ='no mask'; %default |
---|
| 4057 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4058 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4059 | if isequal(flag_mask,1) |
---|
| 4060 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4061 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4062 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4063 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4064 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4065 | mask_displ='no mask'; |
---|
| 4066 | end |
---|
| 4067 | end |
---|
| 4068 | if isequal(mask_displ,'no mask') |
---|
[12] | 4069 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4070 | {'*.png', ' (*.png)'; |
---|
| 4071 | '*.png', '.png files '; ... |
---|
| 4072 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4073 | 'Pick a mask file *.png',filebase); |
---|
| 4074 | mask_displ=fullfile(PathName,FileName); |
---|
| 4075 | if ~exist(mask_displ,'file') |
---|
| 4076 | mask_displ='no mask'; |
---|
| 4077 | end |
---|
| 4078 | end |
---|
| 4079 | if isequal(mask_displ,'no mask') |
---|
[2] | 4080 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4081 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4082 | else |
---|
| 4083 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4084 | end |
---|
| 4085 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4086 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4087 | end |
---|
[12] | 4088 | |
---|
| 4089 | %------------------------------------------------------------------------ |
---|
[2] | 4090 | % --- Executes on button press in get_mask_fix2. |
---|
| 4091 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4092 | %------------------------------------------------------------------------ |
---|
[2] | 4093 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 4094 | if isequal(maskval,0) |
---|
| 4095 | set(handles.mask_fix2,'String','') |
---|
| 4096 | else |
---|
[12] | 4097 | mask_displ='no mask'; %default |
---|
| 4098 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4099 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4100 | if isequal(flag_mask,1) |
---|
| 4101 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4102 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4103 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4104 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4105 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4106 | mask_displ='no mask'; |
---|
| 4107 | end |
---|
| 4108 | end |
---|
| 4109 | if isequal(mask_displ,'no mask') |
---|
| 4110 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4111 | {'*.png', ' (*.png)'; |
---|
| 4112 | '*.png', '.png files '; ... |
---|
| 4113 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4114 | 'Pick a mask file *.png',filebase); |
---|
| 4115 | mask_displ=fullfile(PathName,FileName); |
---|
| 4116 | if ~exist(mask_displ,'file') |
---|
[2] | 4117 | mask_displ='no mask'; |
---|
| 4118 | end |
---|
[12] | 4119 | end |
---|
| 4120 | if isequal(mask_displ,'no mask') |
---|
| 4121 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4122 | end |
---|
| 4123 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 4124 | end |
---|
| 4125 | |
---|
[12] | 4126 | %------------------------------------------------------------------------ |
---|
| 4127 | % --- function called to look for mask files |
---|
[2] | 4128 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 4129 | %------------------------------------------------------------------------ |
---|
[2] | 4130 | %detect mask files, images with appropriate file base |
---|
| 4131 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 4132 | %flag_mask=1 indicates detection |
---|
| 4133 | |
---|
| 4134 | flag_mask=0;%default |
---|
| 4135 | nbslice=1; |
---|
| 4136 | |
---|
| 4137 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 4138 | [Path,Name]=fileparts(filebase); |
---|
[12] | 4139 | if ~isdir(Path) |
---|
| 4140 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 4141 | return |
---|
| 4142 | end |
---|
[2] | 4143 | currentdir=pwd; |
---|
| 4144 | cd(Path);%move in the dir of the root name filebase |
---|
| 4145 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 4146 | cd(currentdir);%come back to the current working directory |
---|
[12] | 4147 | if ~isempty(maskfiles) |
---|
| 4148 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 4149 | % else |
---|
[2] | 4150 | flag_mask=1; |
---|
| 4151 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4152 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4153 | Namedouble=double(Name); |
---|
| 4154 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4155 | ind_mask=findstr('mask',Name); |
---|
| 4156 | i=ind_mask-1; |
---|
| 4157 | while val(i)==0 & i>0 |
---|
| 4158 | i=i-1; |
---|
| 4159 | end |
---|
| 4160 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4161 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4162 | flag_mask=1; |
---|
| 4163 | else |
---|
| 4164 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 4165 | return |
---|
| 4166 | nbslice=1; |
---|
| 4167 | end |
---|
| 4168 | end |
---|
| 4169 | |
---|
[12] | 4170 | %------------------------------------------------------------------------ |
---|
| 4171 | % --- function called to look for grid files |
---|
[2] | 4172 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 4173 | %------------------------------------------------------------------------ |
---|
[2] | 4174 | flag_mask=0;%default |
---|
| 4175 | nbslice=1; |
---|
| 4176 | [Path,Name]=fileparts(filebase); |
---|
| 4177 | currentdir=pwd; |
---|
| 4178 | cd(Path);%move in the dir of the root name filebase |
---|
| 4179 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 4180 | cd(currentdir);%come back to the current working directory |
---|
| 4181 | if ~isempty(maskfiles) |
---|
| 4182 | flag_mask=1; |
---|
| 4183 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4184 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4185 | Namedouble=double(Name); |
---|
| 4186 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4187 | ind_mask=findstr('grid',Name); |
---|
| 4188 | i=ind_mask-1; |
---|
| 4189 | while val(i)==0 & i>0 |
---|
| 4190 | i=i-1; |
---|
| 4191 | end |
---|
| 4192 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4193 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4194 | flag_mask=1; |
---|
| 4195 | else |
---|
| 4196 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 4197 | return |
---|
| 4198 | nbslice=1; |
---|
| 4199 | end |
---|
[12] | 4200 | end |
---|
[2] | 4201 | |
---|
[12] | 4202 | %------------------------------------------------------------------------ |
---|
| 4203 | % --- transform numbers to letters |
---|
[2] | 4204 | function str=num2stra(num,nom_type); |
---|
[12] | 4205 | %------------------------------------------------------------------------ |
---|
[2] | 4206 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 4207 | str=char(96+num); |
---|
| 4208 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 4209 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 4210 | str=''; |
---|
| 4211 | else |
---|
| 4212 | str=num2str(num); |
---|
| 4213 | end |
---|
[12] | 4214 | |
---|
| 4215 | %------------------------------------------------------------------------ |
---|
[2] | 4216 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4217 | %------------------------------------------------------------------------ |
---|
[2] | 4218 | set(handles.mask_civ1,'UserData',[]) |
---|
| 4219 | set(handles.mask_civ1,'String','') |
---|
[12] | 4220 | |
---|
| 4221 | %------------------------------------------------------------------------ |
---|
[2] | 4222 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4223 | %------------------------------------------------------------------------ |
---|
[2] | 4224 | set(handles.mask_civ2,'UserData',[]) |
---|
| 4225 | set(handles.mask_civ2,'String','') |
---|
[12] | 4226 | |
---|
| 4227 | %------------------------------------------------------------------------ |
---|
[2] | 4228 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4229 | %------------------------------------------------------------------------ |
---|
[2] | 4230 | set(handles.mask_fix1,'UserData',[]) |
---|
| 4231 | set(handles.mask_fix1,'String','') |
---|
[12] | 4232 | |
---|
| 4233 | %------------------------------------------------------------------------ |
---|
[2] | 4234 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4235 | %------------------------------------------------------------------------ |
---|
[2] | 4236 | set(handles.mask_fix2,'UserData',[]) |
---|
| 4237 | set(handles.mask_fix2,'String','') |
---|
| 4238 | |
---|
[12] | 4239 | %------------------------------------------------------------------------ |
---|
[2] | 4240 | % --- Executes on button press in list_subdir_civ1. |
---|
| 4241 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4242 | %------------------------------------------------------------------------ |
---|
[2] | 4243 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 4244 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 4245 | if val>1 |
---|
| 4246 | subdir=list_subdir_civ1{val}; |
---|
| 4247 | set(handles.subdir_civ1,'String',subdir); |
---|
| 4248 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 4249 | end |
---|
| 4250 | |
---|
[12] | 4251 | %------------------------------------------------------------------------ |
---|
[2] | 4252 | % --- Executes on button press in list_subdir_civ2. |
---|
| 4253 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4254 | %------------------------------------------------------------------------ |
---|
[2] | 4255 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 4256 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 4257 | if val>1 |
---|
| 4258 | subdir=list_subdir_civ2{val}; |
---|
| 4259 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4260 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 4261 | end |
---|
| 4262 | |
---|
[12] | 4263 | %------------------------------------------------------------------------ |
---|
[2] | 4264 | % --- Executes on button press in browse_gridciv1. |
---|
| 4265 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 4266 | %------------------------------------------------------------------------ |
---|
[2] | 4267 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 4268 | testgrid=0; |
---|
| 4269 | if value |
---|
| 4270 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4271 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4272 | if isequal(flag_grid,1) |
---|
| 4273 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 4274 | testgrid=1; |
---|
| 4275 | else |
---|
| 4276 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4277 | {'*.grid', ' (*.grid)'; |
---|
| 4278 | '*.grid', '.grid files '; ... |
---|
| 4279 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4280 | 'Pick a file',filebase); |
---|
| 4281 | filegrid=fullfile(PathName,FileName); |
---|
| 4282 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 4283 | testgrid=1; |
---|
| 4284 | end |
---|
| 4285 | end |
---|
| 4286 | end |
---|
| 4287 | if testgrid |
---|
| 4288 | set(handles.browse_gridciv2,'Value',1) |
---|
| 4289 | set(handles.get_gridpatch1,'Value',1) |
---|
| 4290 | set(handles.get_gridpatch2,'Value',1) |
---|
| 4291 | set(handles.dx_civ1,'Visible','off'); |
---|
| 4292 | set(handles.dy_civ1,'Visible','off'); |
---|
| 4293 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4294 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4295 | set(handles.grid_civ1,'String',filegrid) |
---|
| 4296 | set(handles.grid_patch1,'String',filegrid) |
---|
| 4297 | set(handles.grid_civ2,'String',filegrid) |
---|
| 4298 | set(handles.grid_patch2,'String',filegrid) |
---|
| 4299 | else |
---|
| 4300 | set(handles.browse_gridciv1,'Value',0); |
---|
| 4301 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4302 | set(handles.get_gridpatch1,'Value',0) |
---|
| 4303 | set(handles.get_gridpatch2,'Value',0) |
---|
| 4304 | set(handles.dx_civ1,'Visible','on'); |
---|
| 4305 | set(handles.dy_civ1,'Visible','on'); |
---|
| 4306 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4307 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4308 | set(handles.grid_civ1,'String','') |
---|
| 4309 | set(handles.grid_patch1,'String','') |
---|
| 4310 | set(handles.grid_civ2,'String','') |
---|
| 4311 | set(handles.grid_patch2,'String','') |
---|
| 4312 | end |
---|
| 4313 | |
---|
[12] | 4314 | %------------------------------------------------------------------------ |
---|
[2] | 4315 | % --- Executes on button press in browse_gridciv1. |
---|
| 4316 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 4317 | %------------------------------------------------------------------------ |
---|
[2] | 4318 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 4319 | if value |
---|
| 4320 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4321 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4322 | if isequal(flag_grid,1) |
---|
| 4323 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 4324 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 4325 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4326 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4327 | else |
---|
| 4328 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4329 | {'*.grid', ' (*.grid)'; |
---|
| 4330 | '*.grid', '.grid files '; ... |
---|
| 4331 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4332 | 'Pick a file',filebase); |
---|
| 4333 | filegrid=fullfile(PathName,FileName); |
---|
| 4334 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 4335 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4336 | set(handles.grid_civ2,'string',''); |
---|
| 4337 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4338 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4339 | set(handles.grid_civ2,'string',''); |
---|
| 4340 | else |
---|
| 4341 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4342 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4343 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4344 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4345 | end |
---|
| 4346 | end |
---|
| 4347 | else |
---|
| 4348 | set(handles.grid_civ2,'string',''); |
---|
| 4349 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4350 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4351 | set(handles.grid_civ2,'string',''); |
---|
| 4352 | end |
---|
| 4353 | |
---|
| 4354 | % % --- Executes on button press in browse_gridciv2. |
---|
| 4355 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 4356 | % |
---|
| 4357 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 4358 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4359 | % {'*.grid', ' (*.grid)'; |
---|
| 4360 | % '*.grid', '.grid files '; ... |
---|
| 4361 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 4362 | % 'Pick a file',filebase); |
---|
| 4363 | % filegrid=fullfile(PathName,FileName); |
---|
| 4364 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 4365 | % set(handles.dx_civ2,'String',' '); |
---|
| 4366 | % set(handles.dy_civ2,'String',' '); |
---|
| 4367 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 4368 | |
---|
| 4369 | % --- Executes on button press in get_gridpatch1. |
---|
| 4370 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 4371 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 4372 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4373 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4374 | |
---|
| 4375 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4376 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4377 | {'*.grid', ' (*.grid)'; |
---|
| 4378 | '*.grid', '.grid files '; ... |
---|
| 4379 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4380 | 'Pick a file',filebase); |
---|
| 4381 | filegrid=fullfile(PathName,FileName); |
---|
| 4382 | set(handles.grid_patch1,'string',filegrid); |
---|
| 4383 | % set(handles.grid_patch2,'string',filegrid |
---|
| 4384 | |
---|
[12] | 4385 | %------------------------------------------------------------------------ |
---|
[2] | 4386 | % --- Executes on button press in get_gridpatch2. |
---|
| 4387 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 4388 | %------------------------------------------------------------------------ |
---|
[2] | 4389 | |
---|
[12] | 4390 | %------------------------------------------------------------------------ |
---|
[2] | 4391 | function enable_civ1(handles,state) |
---|
[12] | 4392 | %------------------------------------------------------------------------ |
---|
[2] | 4393 | if isequal(state,0) |
---|
| 4394 | state='off'; |
---|
| 4395 | end |
---|
| 4396 | if isequal(state,1) |
---|
| 4397 | state='on'; |
---|
| 4398 | end |
---|
| 4399 | if isequal(state,'on') |
---|
| 4400 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4401 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4402 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4403 | else |
---|
| 4404 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4405 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4406 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4407 | end |
---|
| 4408 | set(handles.ibx,'Visible',state) |
---|
| 4409 | set(handles.iby,'Visible',state) |
---|
| 4410 | set(handles.isx,'Visible',state) |
---|
| 4411 | set(handles.isy,'Visible',state) |
---|
| 4412 | set(handles.shiftx,'Visible',state) |
---|
| 4413 | set(handles.shifty,'Visible',state) |
---|
| 4414 | set(handles.rho,'Visible',state) |
---|
| 4415 | set(handles.dx_civ1,'Visible',state) |
---|
| 4416 | set(handles.dy_civ1,'Visible',state) |
---|
| 4417 | set(handles.calcul_search,'Visible',state) |
---|
| 4418 | set(handles.u_text,'Visible',state) |
---|
| 4419 | set(handles.v_text,'Visible',state) |
---|
| 4420 | set(handles.min,'Visible',state) |
---|
| 4421 | set(handles.max,'Visible',state) |
---|
| 4422 | set(handles.umin,'Visible',state) |
---|
| 4423 | set(handles.umax,'Visible',state) |
---|
| 4424 | set(handles.vmin,'Visible',state) |
---|
| 4425 | set(handles.vmax,'Visible',state) |
---|
| 4426 | set(handles.grid_civ1,'Visible',state) |
---|
| 4427 | set(handles.mask_civ1,'Visible',state) |
---|
| 4428 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 4429 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 4430 | set(handles.parameters,'Visible',state) |
---|
| 4431 | set(handles.grid,'Visible',state) |
---|
| 4432 | set(handles.dx_civ1,'Visible',state) |
---|
| 4433 | set(handles.dy_civ1,'Visible',state) |
---|
| 4434 | set(handles.ImaThreshold,'Visible',state) |
---|
| 4435 | if isequal(state,'off') |
---|
| 4436 | set(handles.MinIma,'Visible','off') |
---|
| 4437 | set(handles.MaxIma,'Visible','off') |
---|
| 4438 | set(handles.ImaThreshold,'Value',0) |
---|
| 4439 | end |
---|
| 4440 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 4441 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 4442 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 4443 | set(handles.ib_title,'Visible',state) |
---|
| 4444 | set(handles.is_title,'Visible',state) |
---|
| 4445 | set(handles.shift_title,'Visible',state) |
---|
| 4446 | set(handles.rho_title,'Visible',state) |
---|
| 4447 | |
---|
[12] | 4448 | %------------------------------------------------------------------------ |
---|
[2] | 4449 | function enable_fix1(handles,state) |
---|
[12] | 4450 | %------------------------------------------------------------------------ |
---|
[2] | 4451 | if isequal(state,0) |
---|
| 4452 | state='off'; |
---|
| 4453 | end |
---|
| 4454 | if isequal(state,1) |
---|
| 4455 | state='on'; |
---|
| 4456 | end |
---|
| 4457 | if isequal(state,'on') |
---|
| 4458 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 4459 | else |
---|
| 4460 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4461 | end |
---|
| 4462 | set(handles.REMOVE,'Visible',state) |
---|
| 4463 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 4464 | set(handles.vec_F2,'Visible',state) |
---|
| 4465 | set(handles.vec_F3,'Visible',state) |
---|
| 4466 | set(handles.thresh_vecC,'Visible',state) |
---|
| 4467 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 4468 | set(handles.thresh_vel,'Visible',state) |
---|
| 4469 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 4470 | set(handles.mask_fix1,'Visible',state) |
---|
| 4471 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 4472 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 4473 | set(handles.ref_fix1,'Visible',state) |
---|
| 4474 | set(handles.inf_sup1,'Visible',state) |
---|
| 4475 | set(handles.field_ref1,'Visible',state) |
---|
| 4476 | |
---|
[12] | 4477 | %------------------------------------------------------------------------ |
---|
[2] | 4478 | function enable_patch1(handles) |
---|
[12] | 4479 | %------------------------------------------------------------------------ |
---|
[2] | 4480 | global patch_new_exe |
---|
| 4481 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 4482 | set(handles.rho_patch1,'Visible','on') |
---|
| 4483 | set(handles.rho_text1,'Visible','on') |
---|
| 4484 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4485 | set(handles.thresh_text1,'Visible','on') |
---|
| 4486 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4487 | set(handles.subdomain_text1,'Visible','on') |
---|
| 4488 | set(handles.nx_patch1,'Visible','on') |
---|
| 4489 | set(handles.ny_patch1,'Visible','on') |
---|
| 4490 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 4491 | set(handles.ny_patch1_title,'Visible','on') |
---|
| 4492 | if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[])) |
---|
| 4493 | set(handles.test_interp,'Visible','on'); |
---|
| 4494 | end |
---|
| 4495 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 4496 | set(handles.grid_patch1,'string','none'); |
---|
| 4497 | set(handles.grid_patch1,'Visible','on') |
---|
| 4498 | |
---|
[12] | 4499 | %------------------------------------------------------------------------ |
---|
[2] | 4500 | function desable_patch1(handles) |
---|
[12] | 4501 | %------------------------------------------------------------------------ |
---|
[2] | 4502 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4503 | set(handles.rho_patch1,'Visible','off') |
---|
| 4504 | set(handles.rho_text1,'Visible','off') |
---|
| 4505 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4506 | set(handles.thresh_text1,'Visible','off') |
---|
| 4507 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4508 | set(handles.subdomain_text1,'Visible','off') |
---|
| 4509 | set(handles.nx_patch1,'Visible','off') |
---|
| 4510 | set(handles.ny_patch1,'Visible','off') |
---|
| 4511 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 4512 | set(handles.ny_patch1_title,'Visible','off') |
---|
| 4513 | set(handles.test_interp,'Visible','off') |
---|
| 4514 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 4515 | set(handles.grid_patch1,'Visible','off') |
---|
| 4516 | |
---|
[12] | 4517 | %------------------------------------------------------------------------ |
---|
[2] | 4518 | function enable_civ2(handles,state) |
---|
[12] | 4519 | %------------------------------------------------------------------------ |
---|
[2] | 4520 | if isequal(state,0) |
---|
| 4521 | state='off'; |
---|
| 4522 | end |
---|
| 4523 | if isequal(state,1) |
---|
| 4524 | state='on'; |
---|
| 4525 | end |
---|
| 4526 | if isequal(state,'on') |
---|
| 4527 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4528 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4529 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4530 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4531 | else |
---|
| 4532 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4533 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4534 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4535 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4536 | end |
---|
| 4537 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4538 | set(handles.iby_civ2,'Visible',state) |
---|
| 4539 | set(handles.decimal,'Visible',state) |
---|
| 4540 | set(handles.deformation,'Visible',state) |
---|
| 4541 | set(handles.rho_civ2,'Visible',state) |
---|
| 4542 | set(handles.dx_civ2,'Visible',state) |
---|
| 4543 | set(handles.dy_civ2,'Visible',state) |
---|
| 4544 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4545 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4546 | set(handles.parameters,'Visible',state) |
---|
| 4547 | set(handles.grid,'Visible',state) |
---|
| 4548 | set(handles.parameters_text,'Visible',state) |
---|
| 4549 | set(handles.grid_text,'Visible',state) |
---|
| 4550 | set(handles.grid_civ2,'Visible',state) |
---|
| 4551 | set(handles.mask_civ2,'Visible',state) |
---|
| 4552 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4553 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4554 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4555 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4556 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4557 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4558 | if isequal(state,'off') |
---|
| 4559 | set(handles.MinIma2,'Visible','off') |
---|
| 4560 | set(handles.MaxIma2,'Visible','off') |
---|
| 4561 | set(handles.ImaThreshold2,'Value',0) |
---|
| 4562 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4563 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4564 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4565 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4566 | end |
---|
| 4567 | else |
---|
| 4568 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4569 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4570 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4571 | end |
---|
| 4572 | |
---|
[12] | 4573 | %------------------------------------------------------------------------ |
---|
[2] | 4574 | function enable_fix2(handles) |
---|
[12] | 4575 | %------------------------------------------------------------------------ |
---|
[2] | 4576 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4577 | set(handles.REMOVE2,'Visible','on') |
---|
| 4578 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4579 | set(handles.vec_F4,'Visible','on') |
---|
| 4580 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4581 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4582 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4583 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4584 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4585 | set(handles.mask_fix2,'Visible','on') |
---|
| 4586 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4587 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4588 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4589 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4590 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4591 | set(handles.ref_fix2,'Visible','on') |
---|
| 4592 | set(handles.inf_sup2,'Visible','on') |
---|
| 4593 | set(handles.field_ref2,'Visible','on') |
---|
| 4594 | |
---|
[12] | 4595 | %------------------------------------------------------------------------ |
---|
[2] | 4596 | function desable_fix2(handles) |
---|
[12] | 4597 | %------------------------------------------------------------------------ |
---|
[2] | 4598 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4599 | set(handles.REMOVE2,'Visible','off') |
---|
| 4600 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4601 | set(handles.vec_F4,'Visible','off') |
---|
| 4602 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4603 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4604 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4605 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4606 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4607 | set(handles.mask_fix2,'Visible','off') |
---|
| 4608 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4609 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4610 | set(handles.ref_fix2,'Visible','off') |
---|
| 4611 | set(handles.inf_sup2,'Visible','off') |
---|
| 4612 | set(handles.field_ref2,'Visible','off') |
---|
| 4613 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4614 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4615 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4616 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4617 | end |
---|
| 4618 | |
---|
[12] | 4619 | %------------------------------------------------------------------------ |
---|
[2] | 4620 | function enable_patch2(handles) |
---|
[12] | 4621 | %------------------------------------------------------------------------ |
---|
[2] | 4622 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 4623 | %set(handles.rho_patch2,'Visible','on') |
---|
| 4624 | set(handles.rho_text2,'Visible','on') |
---|
| 4625 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4626 | set(handles.thresh_text2,'Visible','on') |
---|
| 4627 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4628 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4629 | set(handles.nx_patch2,'Visible','on') |
---|
| 4630 | set(handles.ny_patch2,'Visible','on') |
---|
| 4631 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4632 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 4633 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 4634 | set(handles.grid_patch2,'Visible','on') |
---|
| 4635 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4636 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4637 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4638 | |
---|
[12] | 4639 | %------------------------------------------------------------------------ |
---|
[2] | 4640 | function desable_patch2(handles) |
---|
[12] | 4641 | %------------------------------------------------------------------------ |
---|
[2] | 4642 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4643 | set(handles.rho_patch2,'Visible','off') |
---|
| 4644 | set(handles.rho_text2,'Visible','off') |
---|
| 4645 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4646 | set(handles.thresh_text2,'Visible','off') |
---|
| 4647 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4648 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4649 | set(handles.nx_patch2,'Visible','off') |
---|
| 4650 | set(handles.ny_patch2,'Visible','off') |
---|
| 4651 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4652 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 4653 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 4654 | set(handles.grid_patch2,'Visible','off') |
---|
| 4655 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4656 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4657 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4658 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4659 | end |
---|
| 4660 | |
---|
[12] | 4661 | %------------------------------------------------------------------------ |
---|
[2] | 4662 | function enable_pair1(handles,state) |
---|
[12] | 4663 | %------------------------------------------------------------------------ |
---|
[2] | 4664 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4665 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4666 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4667 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4668 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4669 | set(handles.PAIR_txt,'Visible',state) |
---|
[12] | 4670 | %set(handles.dt_display_txt,'Visible',state) |
---|
[2] | 4671 | set(handles.dt_unit,'Visible',state) |
---|
| 4672 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4673 | |
---|
[12] | 4674 | %------------------------------------------------------------------------ |
---|
| 4675 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4676 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4677 | %------------------------------------------------------------------------ |
---|
[2] | 4678 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 4679 | par.ibx=num2str(ibx_val); |
---|
| 4680 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 4681 | par.iby=num2str(iby_val); |
---|
| 4682 | isx=get(handles.isx,'String'); |
---|
| 4683 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4684 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 4685 | isy=get(handles.isy,'String'); |
---|
| 4686 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4687 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 4688 | par.isx=get(handles.isx,'String'); |
---|
| 4689 | par.isy=get(handles.isy,'String'); |
---|
| 4690 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4691 | par.shifty=get(handles.shifty,'String'); |
---|
| 4692 | if isempty(str2num(par.isx)) |
---|
| 4693 | par.isx='41';%default |
---|
| 4694 | set(handles.isx,'String','41'); |
---|
| 4695 | end |
---|
| 4696 | if isempty(str2num(par.isy)) |
---|
| 4697 | par.isy='41'; %default |
---|
| 4698 | set(handles.isy,'String','41'); |
---|
[12] | 4699 | end |
---|
[2] | 4700 | if isempty(str2num(par.shiftx)) |
---|
| 4701 | par.shiftx='0';%default |
---|
| 4702 | set(handles.shiftx,'String','0'); |
---|
[12] | 4703 | end |
---|
[2] | 4704 | if isempty(str2num(par.shifty)) |
---|
| 4705 | par.shifty='0'; %default |
---|
| 4706 | set(handles.shifty,'String','0'); |
---|
[12] | 4707 | end |
---|
| 4708 | par.rho=get(handles.rho,'String'); |
---|
| 4709 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4710 | par.dy=get(handles.dy_civ1,'String'); |
---|
| 4711 | if isequal(str2num(par.dx),[]) |
---|
| 4712 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4713 | par.dx='0'; %just read by civ program, not used |
---|
| 4714 | else |
---|
| 4715 | par.dx='20';%default |
---|
| 4716 | set(handles.dx_civ1,'String','20'); |
---|
[2] | 4717 | end |
---|
[12] | 4718 | end |
---|
| 4719 | if isequal(str2num(par.dy),[]) |
---|
| 4720 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4721 | par.dy='0';%just read by civ program, not used |
---|
| 4722 | else |
---|
| 4723 | par.dy='20';%default |
---|
| 4724 | set(handles.dy_civ1_title,'String','20'); |
---|
[2] | 4725 | end |
---|
[12] | 4726 | end |
---|
| 4727 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4728 | par.pxcmy='1'; |
---|
[2] | 4729 | % end |
---|
[12] | 4730 | A=imread(file_ima);%read the first image to get the size |
---|
| 4731 | sizim=size(A); |
---|
| 4732 | par.npx=num2str(sizim(2)); |
---|
| 4733 | par.npy=num2str(sizim(1)); |
---|
| 4734 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4735 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4736 | par.gridflag='y'; |
---|
| 4737 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4738 | par.gridname='nogrid'; |
---|
| 4739 | par.gridflag='n'; |
---|
| 4740 | end |
---|
| 4741 | |
---|
| 4742 | %------------------------------------------------------------------------ |
---|
[2] | 4743 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4744 | %------------------------------------------------------------------------ |
---|
| 4745 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4746 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4747 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4748 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4749 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4750 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4751 | par.dy=get(handles.dy_civ2,'String'); |
---|
| 4752 | if isequal(str2num(par.dx),[]) |
---|
| 4753 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4754 | par.dx='0'; %just read by civ program, not used |
---|
| 4755 | else |
---|
| 4756 | par.dx='20';%default |
---|
| 4757 | set(handles.dx_civ2,'String','20'); |
---|
[2] | 4758 | end |
---|
[12] | 4759 | end |
---|
| 4760 | if isequal(str2num(par.dy),[]) |
---|
| 4761 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4762 | par.dy='0';%just read by civ program, not used |
---|
| 4763 | else |
---|
| 4764 | par.dy='20';%default |
---|
| 4765 | set(handles.dy_civ2,'String','20'); |
---|
[2] | 4766 | end |
---|
[12] | 4767 | end |
---|
| 4768 | par.pxcmx='1'; |
---|
| 4769 | par.pxcmy='1'; |
---|
| 4770 | A=imread(file_ima);%read the first image to get the size |
---|
| 4771 | sizim=size(A); |
---|
| 4772 | par.npx=num2str(sizim(2)); |
---|
| 4773 | par.npy=num2str(sizim(1)); |
---|
| 4774 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4775 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4776 | par.gridflag='y'; |
---|
| 4777 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4778 | par.gridname='nogrid'; |
---|
| 4779 | par.gridflag='n'; |
---|
| 4780 | end |
---|
[2] | 4781 | |
---|
[12] | 4782 | %------------------------------------------------------------------------ |
---|
| 4783 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[2] | 4784 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles) |
---|
[12] | 4785 | %------------------------------------------------------------------------ |
---|
[2] | 4786 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4787 | global civ1_exe Civ_exe sge%name of the executable for civ1 calculation |
---|
| 4788 | |
---|
| 4789 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4790 | |
---|
| 4791 | if isequal(par.Dt,'0') |
---|
| 4792 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4793 | end |
---|
[12] | 4794 | % |
---|
| 4795 | % textcmx={'############## CMX file';... |
---|
| 4796 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4797 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4798 | % 'XX' ;... |
---|
| 4799 | % ['Mask ' par.maskflag] ;... |
---|
| 4800 | % ['MaskName ' par.maskname];... |
---|
| 4801 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4802 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4803 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4804 | % ['RO ' par.rho];... |
---|
| 4805 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4806 | % 'XX 1.0';... |
---|
| 4807 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4808 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4809 | % 'XX 1';... |
---|
| 4810 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4811 | % ['Grid ' par.gridflag];... |
---|
| 4812 | % ['GridName ' par.gridname] ;... |
---|
| 4813 | % 'XX 85';... |
---|
| 4814 | % 'XX 1.0';... |
---|
| 4815 | % 'XX 1.0';... |
---|
| 4816 | % 'Hart 1';... |
---|
| 4817 | % 'DecimalShift 0';... |
---|
| 4818 | % 'Deformation 0';... |
---|
| 4819 | % 'CorrelationMin 0';... |
---|
| 4820 | % 'IntensityMin 0';... |
---|
| 4821 | % 'SeuilImage n';... |
---|
| 4822 | % 'SeuilImageValues 0 4096';... |
---|
| 4823 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4824 | % 'ImageUsedBefore null null'}; |
---|
| 4825 | % |
---|
| 4826 | % textout=char(textcmx); |
---|
[2] | 4827 | |
---|
[12] | 4828 | fid=fopen([filename '.cmx'],'w'); |
---|
| 4829 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4830 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
| 4831 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
| 4832 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4833 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4834 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
| 4835 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4836 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4837 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4838 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4839 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4840 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4841 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4842 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4843 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4844 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4845 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4846 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
| 4847 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4848 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4849 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4850 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4851 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4852 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4853 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4854 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4855 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4856 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4857 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4858 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4859 | fclose(fid); |
---|
| 4860 | |
---|
| 4861 | if sge |
---|
| 4862 | cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
| 4863 | else |
---|
| 4864 | cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4865 | end |
---|
| 4866 | if(isunix) |
---|
| 4867 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4868 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
| 4869 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
| 4870 | else |
---|
| 4871 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log']; |
---|
| 4872 | end |
---|
[2] | 4873 | |
---|
[12] | 4874 | %------------------------------------------------------------------------ |
---|
| 4875 | % --- CIV1 Unified |
---|
[2] | 4876 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
[12] | 4877 | %------------------------------------------------------------------------ |
---|
[2] | 4878 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4879 | global civ1_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4880 | |
---|
| 4881 | civ1.image1=par.filename_ima_a; |
---|
| 4882 | civ1.image2=par.filename_ima_b; |
---|
| 4883 | civ1.imageSize_X=par.npx; |
---|
| 4884 | civ1.imageSize_Y=par.npy; |
---|
| 4885 | civ1.outputFileName=[filename '.nc']; |
---|
| 4886 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4887 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4888 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4889 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4890 | civ1.globalShift_X=par.shiftx; |
---|
| 4891 | civ1.globalShift_Y=par.shifty; |
---|
| 4892 | civ1.ro=par.rho; |
---|
| 4893 | civ1.hart='y'; |
---|
| 4894 | if isequal(par.gridflag,'y') |
---|
| 4895 | civ1.grid=par.gridname; |
---|
| 4896 | else |
---|
| 4897 | civ1.grid='n'; |
---|
| 4898 | civ1.gridSpacing_X=par.dx; |
---|
| 4899 | civ1.gridSpacing_Y=par.dy; |
---|
| 4900 | end |
---|
| 4901 | if isequal(par.maskflag,'y') |
---|
| 4902 | civ1.mask=par.maskname; |
---|
| 4903 | end |
---|
| 4904 | civ1.dt=par.Dt; |
---|
| 4905 | civ1.unit='pixel'; |
---|
| 4906 | civ1.absolut_time_T0=par.T0; |
---|
| 4907 | civ1.pixcmx=par.pxcmx; |
---|
| 4908 | civ1.pixcmy=par.pxcmy; |
---|
| 4909 | civ1.convectFlow='n'; |
---|
| 4910 | |
---|
| 4911 | xml_civ1_parameters=civ1; |
---|
[12] | 4912 | |
---|
| 4913 | %------------------------------------------------------------------------ |
---|
| 4914 | % --- CIV2 Unified |
---|
[2] | 4915 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
[12] | 4916 | %------------------------------------------------------------------------ |
---|
[2] | 4917 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4918 | global civ2_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4919 | |
---|
| 4920 | civ2.image1=par.filename_ima_a; |
---|
| 4921 | civ2.image2=par.filename_ima_b; |
---|
| 4922 | civ2.imageSize_X=par.npx; |
---|
| 4923 | civ2.imageSize_Y=par.npy; |
---|
| 4924 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4925 | civ2.outputFileName=[filename '.nc']; |
---|
| 4926 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4927 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4928 | civ2.ro=par.rho; |
---|
| 4929 | %civ2.decimalShift=par.decimal; |
---|
| 4930 | %civ2.deformation=par.deformation; |
---|
| 4931 | if isequal(par.decimal,'1') |
---|
| 4932 | civ2.decimalShift='y'; |
---|
| 4933 | else |
---|
| 4934 | civ2.decimalShift='n'; |
---|
| 4935 | end |
---|
| 4936 | if isequal(par.deformation,'1') |
---|
| 4937 | civ2.deformation='y'; |
---|
| 4938 | else |
---|
| 4939 | civ2.deformation='n'; |
---|
| 4940 | end |
---|
| 4941 | if isequal(par.gridflag,'y') |
---|
| 4942 | civ2.grid=par.gridname; |
---|
| 4943 | else |
---|
| 4944 | civ2.grid='n'; |
---|
| 4945 | civ2.gridSpacing_X=par.dx; |
---|
| 4946 | civ2.gridSpacing_Y=par.dy; |
---|
| 4947 | end |
---|
| 4948 | civ2.gridSpacing_X='10'; |
---|
| 4949 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4950 | if isequal(par.maskflag,'y') |
---|
| 4951 | civ2.mask=par.maskname; |
---|
| 4952 | else |
---|
| 4953 | civ2.mask='n'; |
---|
| 4954 | end |
---|
| 4955 | civ2.dt=par.Dt; |
---|
| 4956 | civ2.unit='pixel'; |
---|
| 4957 | civ2.absolut_time_T0=par.T0; |
---|
| 4958 | civ2.pixcmx=par.pxcmx; |
---|
| 4959 | civ2.pixcmy=par.pxcmy; |
---|
| 4960 | civ2.convectFlow='n'; |
---|
| 4961 | civ2.pixcmx=par.pxcmx; |
---|
| 4962 | civ2.pixcmy=par.pxcmy; |
---|
| 4963 | civ2.convectFlow='n'; |
---|
| 4964 | |
---|
[12] | 4965 | %------------------------------------------------------------------------ |
---|
| 4966 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[2] | 4967 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par) |
---|
[12] | 4968 | %------------------------------------------------------------------------ |
---|
[2] | 4969 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4970 | global civ2_exe sge%name of the executable for civ1 calculation |
---|
| 4971 | if isequal(par.Dt,'0') |
---|
| 4972 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4973 | end |
---|
[12] | 4974 | textcmx=['############## CMX file' '\n'... |
---|
| 4975 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 4976 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 4977 | 'XX' '\n'... |
---|
| 4978 | ['Mask ' par.maskflag] '\n'... |
---|
| 4979 | ['MaskName ' par.maskname] '\n'... |
---|
| 4980 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
| 4981 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4982 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4983 | ['RO ' par.rho] '\n'... |
---|
| 4984 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 4985 | 'XX 1.0' '\n'... |
---|
| 4986 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 4987 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 4988 | 'XX 1' '\n'... |
---|
| 4989 | ['ShiftXY 0 0'] '\n'... |
---|
| 4990 | ['Grid ' par.gridflag] '\n'... |
---|
| 4991 | ['GridName ' par.gridname] '\n'... |
---|
| 4992 | 'XX 85' '\n'... |
---|
| 4993 | 'XX 1.0' '\n'... |
---|
| 4994 | 'XX 1.0' '\n'... |
---|
| 4995 | 'Hart 1' '\n'... |
---|
| 4996 | ['DecimalShift ' par.decimal] '\n'... |
---|
| 4997 | ['Deformation ' par.deformation] '\n'... |
---|
| 4998 | 'CorrelationMin 0' '\n'... |
---|
| 4999 | 'IntensityMin 0' '\n'... |
---|
| 5000 | 'SeuilImage n' '\n'... |
---|
| 5001 | 'SeuilImageValues 0 4096' '\n'... |
---|
| 5002 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 5003 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 5004 | textout=char(textcmx); |
---|
| 5005 | fid=fopen([filename_cmx '2'],'w'); |
---|
| 5006 | fprintf(fid,textout); |
---|
| 5007 | fclose(fid) |
---|
| 5008 | if sge |
---|
| 5009 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 5010 | else |
---|
| 5011 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 5012 | end |
---|
[2] | 5013 | |
---|
[12] | 5014 | %------------------------------------------------------------------------ |
---|
[2] | 5015 | % --- Executes on button press in HELP. |
---|
| 5016 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 5017 | %------------------------------------------------------------------------ |
---|
[2] | 5018 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 5019 | pathelp=fileparts(path_to_uvmat); |
---|
[45] | 5020 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html') |
---|
[36] | 5021 | 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] | 5022 | else |
---|
[36] | 5023 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 5024 | web([helpfile '#civ']) |
---|
[2] | 5025 | end |
---|
| 5026 | |
---|
[12] | 5027 | %------------------------------------------------------------------------ |
---|
[2] | 5028 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 5029 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 5030 | %------------------------------------------------------------------------ |
---|
[2] | 5031 | %num is the view number needed for an avi movie |
---|
[45] | 5032 | switch type_ima |
---|
| 5033 | case 'movie' |
---|
| 5034 | A=read(movieobject,num); |
---|
| 5035 | case 'avi' |
---|
| 5036 | mov=aviread(filename,num); |
---|
| 5037 | A=frame2im(mov(1)); |
---|
| 5038 | case 'multimage' |
---|
| 5039 | A=imread(filename,num); |
---|
| 5040 | case 'image' |
---|
| 5041 | A=imread(filename); |
---|
| 5042 | end |
---|
| 5043 | siz=size(A); |
---|
| 5044 | if length(siz)==3;%color images |
---|
[2] | 5045 | A=sum(double(A),3); |
---|
| 5046 | A=uint16(A); |
---|
| 5047 | end |
---|
| 5048 | |
---|
[12] | 5049 | %------------------------------------------------------------------------ |
---|
[2] | 5050 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 5051 | %------------------------------------------------------------------------ |
---|
[2] | 5052 | mode_list=get(handles.mode,'String'); |
---|
| 5053 | mode_value=get(handles.mode,'Value'); |
---|
| 5054 | mode=mode_list{mode_value}; |
---|
[45] | 5055 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 5056 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[45] | 5057 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 5058 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5059 | end |
---|
| 5060 | |
---|
[12] | 5061 | %------------------------------------------------------------------------ |
---|
[2] | 5062 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 5063 | %------------------------------------------------------------------------ |
---|
[2] | 5064 | mode_list=get(handles.mode,'String'); |
---|
| 5065 | mode_value=get(handles.mode,'Value'); |
---|
| 5066 | mode=mode_list{mode_value}; |
---|
[45] | 5067 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 5068 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5069 | end |
---|
[45] | 5070 | if isequal(mode,'series(Dj)') || ... |
---|
| 5071 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 5072 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5073 | end |
---|
[12] | 5074 | |
---|
| 5075 | %------------------------------------------------------------------------ |
---|
[2] | 5076 | % --- Executes on button press in compare. |
---|
| 5077 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 5078 | %------------------------------------------------------------------------ |
---|
[2] | 5079 | test=get(handles.compare,'Value'); |
---|
| 5080 | if test==2 || test==3 |
---|
| 5081 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5082 | browse=get(handles.browse_root,'Userdata'); |
---|
| 5083 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 5084 | set(handles.browse_root,'UserData',browse); |
---|
| 5085 | set(handles.sub_txt,'Visible','on') |
---|
| 5086 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
| 5087 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 5088 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 5089 | set(handles.mode,'Visible','off') |
---|
| 5090 | if test==2 |
---|
| 5091 | set(handles.mode,'Visible','off') |
---|
| 5092 | else |
---|
| 5093 | set(handles.mode,'Visible','on') |
---|
| 5094 | end |
---|
| 5095 | |
---|
| 5096 | % open an image file with the browser |
---|
| 5097 | ind_opening=1;%default |
---|
| 5098 | browse.incr_pair=[0 0]; %default |
---|
| 5099 | oldfile=get(handles.displ_filebase,'String'); |
---|
| 5100 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 5101 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 5102 | '*.*', 'All Files (*.*)'}; |
---|
| 5103 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 5104 | fileinput=[PathName FileName];%complete file name |
---|
| 5105 | sizf=size(fileinput); |
---|
| 5106 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5107 | [path,name,ext]=fileparts(fileinput); |
---|
| 5108 | [path1]=fileparts(filebase); |
---|
| 5109 | if ~strcmp(path1,path) |
---|
| 5110 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
| 5111 | return |
---|
| 5112 | end |
---|
| 5113 | set(handles.displ_filebase2,'String',name); |
---|
| 5114 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 5115 | browse=get(handles.browse_root,'UserData'); |
---|
| 5116 | browse.nom_type_ima_1=nom_type; |
---|
| 5117 | set(handles.browse_root,'UserData',browse) |
---|
| 5118 | |
---|
| 5119 | %check image extension |
---|
| 5120 | if ~strcmp(ext,get(handles.ext_ima,'String')) |
---|
| 5121 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 5122 | return |
---|
| 5123 | end |
---|
| 5124 | |
---|
| 5125 | %check image size |
---|
| 5126 | A=imread(fileinput); |
---|
| 5127 | npxy=get(handles.ext_ima,'UserData'); |
---|
| 5128 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 5129 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 5130 | return |
---|
| 5131 | end |
---|
| 5132 | else |
---|
| 5133 | set(handles.mode,'Visible','on') |
---|
| 5134 | set(handles.displ_filebase2,'Visible','Off'); |
---|
| 5135 | set(handles.sub_txt,'Visible','off') |
---|
| 5136 | set(handles.displ_filebase2,'String',[]); |
---|
| 5137 | mode_store=get(handles.compare,'UserData'); |
---|
| 5138 | set(handles.mode,'String',mode_store) |
---|
| 5139 | set(handles.test_stereo1,'Value',0) |
---|
| 5140 | set(handles.test_stereo2,'Value',0) |
---|
| 5141 | end |
---|
| 5142 | mode_Callback(hObject, eventdata, handles) |
---|
| 5143 | |
---|
[12] | 5144 | %------------------------------------------------------------------------ |
---|
[2] | 5145 | % --- Executes on button press in get_ref_fix1. |
---|
| 5146 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5147 | %------------------------------------------------------------------------ |
---|
[2] | 5148 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5149 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5150 | {'*.nc', ' (*.nc)'; |
---|
| 5151 | '*.nc', 'netcdf files '; ... |
---|
| 5152 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5153 | 'Pick a file',filebase); |
---|
| 5154 | |
---|
| 5155 | fileinput=[PathName FileName]; |
---|
| 5156 | sizf=size(fileinput); |
---|
| 5157 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5158 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5159 | ref.filebase=fullfile(Path,File); |
---|
| 5160 | ref.num_a=stra2num(str_a); |
---|
| 5161 | ref.num_b=stra2num(str_b); |
---|
| 5162 | ref.num1=str2num(field_count); |
---|
| 5163 | ref.num2=str2num(str2); |
---|
| 5164 | browse=[];%initialisation |
---|
| 5165 | if ~isequal(ref.ext,'.nc') |
---|
| 5166 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5167 | return |
---|
| 5168 | end |
---|
| 5169 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5170 | set(handles.ref_fix1,'UserData',ref) |
---|
| 5171 | menu_field{1}='civ1'; |
---|
| 5172 | Data=nc2struct(fileinput,[]); |
---|
[45] | 5173 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 5174 | menu_field{2}='filter1'; |
---|
| 5175 | end |
---|
[45] | 5176 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 5177 | menu_field{3}='civ2'; |
---|
| 5178 | end |
---|
[45] | 5179 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 5180 | menu_field{4}='filter2'; |
---|
| 5181 | end |
---|
| 5182 | set(handles.field_ref1,'String',menu_field); |
---|
| 5183 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 5184 | set(handles.inf_sup1,'Value',2); |
---|
| 5185 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 5186 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 5187 | |
---|
| 5188 | %------------------------------------------------------------------------ |
---|
[2] | 5189 | % --- Executes on button press in get_ref_fix2. |
---|
| 5190 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5191 | %------------------------------------------------------------------------ |
---|
[2] | 5192 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 5193 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5194 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5195 | {'*.nc', ' (*.nc)'; |
---|
| 5196 | '*.nc', 'netcdf files '; ... |
---|
| 5197 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5198 | 'Pick a file',filebase); |
---|
| 5199 | fileinput=[PathName FileName]; |
---|
| 5200 | sizf=size(fileinput); |
---|
[45] | 5201 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 5202 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5203 | ref.filebase=fullfile(Path,File); |
---|
| 5204 | ref.num_a=stra2num(str_a); |
---|
| 5205 | ref.num_b=stra2num(str_b); |
---|
| 5206 | ref.num1=str2num(field_count); |
---|
| 5207 | ref.num2=str2num(str2); |
---|
| 5208 | browse=[];%initialisation |
---|
| 5209 | if ~isequal(ref.ext,'.nc') |
---|
| 5210 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5211 | return |
---|
| 5212 | end |
---|
| 5213 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5214 | set(handles.ref_fix2,'UserData',ref) |
---|
| 5215 | menu_field{1}='civ1'; |
---|
| 5216 | Data=nc2struct(fileinput,[]); |
---|
| 5217 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5218 | menu_field{2}='filter1'; |
---|
| 5219 | end |
---|
| 5220 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5221 | menu_field{3}='civ2'; |
---|
| 5222 | end |
---|
| 5223 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5224 | menu_field{4}='filter2'; |
---|
| 5225 | end |
---|
| 5226 | set(handles.field_ref2,'String',menu_field); |
---|
| 5227 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 5228 | set(handles.inf_sup2,'Value',2); |
---|
| 5229 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 5230 | set(handles.ref_fix2,'Enable','on') |
---|
| 5231 | set(handles.ref_fix2,'Visible','on') |
---|
| 5232 | set(handles.field_ref2,'Visible','on') |
---|
| 5233 | else |
---|
| 5234 | set(handles.ref_fix2,'Visible','off') |
---|
| 5235 | set(handles.field_ref2,'Visible','off') |
---|
| 5236 | end |
---|
| 5237 | |
---|
[12] | 5238 | %------------------------------------------------------------------------ |
---|
[2] | 5239 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5240 | %------------------------------------------------------------------------ |
---|
| 5241 | set(handles.inf_sup1,'Value',1); |
---|
| 5242 | set(handles.field_ref1,'Value',1) |
---|
| 5243 | set(handles.field_ref1,'String',{' '}) |
---|
| 5244 | set(handles.ref_fix1,'UserData',[]); |
---|
| 5245 | set(handles.ref_fix1,'String',''); |
---|
| 5246 | set(handles.thresh_vel1,'String','0'); |
---|
[2] | 5247 | |
---|
[12] | 5248 | %------------------------------------------------------------------------ |
---|
[2] | 5249 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5250 | %------------------------------------------------------------------------ |
---|
| 5251 | set(handles.inf_sup2,'Value',1); |
---|
| 5252 | set(handles.field_ref2,'Value',1) |
---|
| 5253 | set(handles.field_ref2,'String',{' '}) |
---|
| 5254 | set(handles.ref_fix2,'UserData',[]); |
---|
| 5255 | set(handles.ref_fix2,'String',''); |
---|
| 5256 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 5257 | |
---|
[12] | 5258 | %------------------------------------------------------------------------ |
---|
[2] | 5259 | % transform letters to numbers |
---|
| 5260 | function numres=stra2num(str) |
---|
[12] | 5261 | %------------------------------------------------------------------------ |
---|
[2] | 5262 | numres=double(str)-96; |
---|
| 5263 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 5264 | numres=str2num(str); |
---|
| 5265 | end |
---|
| 5266 | |
---|
[12] | 5267 | %------------------------------------------------------------------------ |
---|
[2] | 5268 | % --- Executes on button press in test_stereo1. |
---|
| 5269 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 5270 | %------------------------------------------------------------------------ |
---|
[2] | 5271 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 5272 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 5273 | set(handles.rho_patch1,'Visible','on') |
---|
| 5274 | else |
---|
| 5275 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 5276 | set(handles.rho_patch1,'Visible','off') |
---|
| 5277 | end |
---|
| 5278 | |
---|
[12] | 5279 | %------------------------------------------------------------------------ |
---|
[2] | 5280 | % --- Executes on button press in test_stereo2. |
---|
| 5281 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 5282 | %------------------------------------------------------------------------ |
---|
[2] | 5283 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 5284 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 5285 | set(handles.rho_patch2,'Visible','on') |
---|
| 5286 | else |
---|
| 5287 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 5288 | set(handles.rho_patch2,'Visible','off') |
---|
| 5289 | end |
---|
| 5290 | |
---|
[12] | 5291 | %------------------------------------------------------------------------ |
---|
[2] | 5292 | % --- Executes on button press in ImaThreshold. |
---|
| 5293 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 5294 | %------------------------------------------------------------------------ |
---|
[2] | 5295 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 5296 | set(handles.MinIma,'Visible','on') |
---|
| 5297 | set(handles.MaxIma,'Visible','on') |
---|
| 5298 | else |
---|
| 5299 | set(handles.MinIma,'Visible','off') |
---|
| 5300 | set(handles.MaxIma,'Visible','off') |
---|
| 5301 | end |
---|
| 5302 | |
---|
[12] | 5303 | %------------------------------------------------------------------------ |
---|
[2] | 5304 | % --- Executes on button press in ImaThreshold2. |
---|
| 5305 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 5306 | %------------------------------------------------------------------------ |
---|
[2] | 5307 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 5308 | set(handles.MinIma2,'Visible','on') |
---|
| 5309 | set(handles.MaxIma2,'Visible','on') |
---|
| 5310 | else |
---|
| 5311 | set(handles.MinIma2,'Visible','off') |
---|
| 5312 | set(handles.MaxIma2,'Visible','off') |
---|
| 5313 | end |
---|
| 5314 | |
---|