[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) |
---|
[67] | 53 | global test_batch patch_newBin%=1 if patch processing available |
---|
[2] | 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 |
---|
[67] | 134 | patch_newBin=''; |
---|
[2] | 135 | % todo_patch=''; |
---|
| 136 | sge=0; |
---|
| 137 | |
---|
[67] | 138 | if isfield(sparam,'PatchNewBin') |
---|
| 139 | patch_newBin=sparam.PatchNewBin; |
---|
[2] | 140 | end |
---|
[55] | 141 | |
---|
| 142 | if isfield(sparam,'SGE') |
---|
| 143 | sge=str2double(sparam.SGE); |
---|
| 144 | end |
---|
| 145 | |
---|
| 146 | test_batch=sge;%default |
---|
[2] | 147 | if isfield(sparam,'Todo_path') |
---|
| 148 | todo_path=sparam.Todo_path; |
---|
[55] | 149 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 150 | if exist(name_todo,'file') |
---|
| 151 | test_batch=1; |
---|
[12] | 152 | end |
---|
[2] | 153 | end |
---|
| 154 | if test_batch==0 |
---|
| 155 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 156 | end |
---|
| 157 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 158 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 159 | |
---|
| 160 | %initiate advised operations |
---|
| 161 | if isequal(ind_opening,[]) |
---|
| 162 | ind_opening=1; % default |
---|
| 163 | end |
---|
| 164 | % set default operation options |
---|
| 165 | enable_civ1(handles,'off') |
---|
| 166 | enable_civ2(handles,'off') |
---|
| 167 | enable_pair1(handles,'on') |
---|
| 168 | enable_fix1(handles,'off') |
---|
| 169 | desable_patch1(handles) |
---|
| 170 | desable_fix2(handles) |
---|
| 171 | desable_patch2(handles) |
---|
| 172 | set(handles.CIV1,'Value',0) |
---|
| 173 | set(handles.FIX1,'Value',0) |
---|
| 174 | set(handles.PATCH1,'Value',0) |
---|
| 175 | set(handles.CIV2,'Value',0) |
---|
| 176 | set(handles.FIX2,'Value',0) |
---|
| 177 | set(handles.PATCH2,'Value',0) |
---|
| 178 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 179 | if isequal(ind_opening,1) |
---|
| 180 | set(handles.CIV1,'Value',1) |
---|
| 181 | enable_civ1(handles,'on') |
---|
| 182 | elseif isequal(ind_opening,2) |
---|
| 183 | set(handles.FIX1,'Value',1) |
---|
| 184 | enable_fix1(handles,'on') |
---|
| 185 | elseif isequal(ind_opening,3) |
---|
| 186 | set(handles.PATCH1,'Value',1) |
---|
| 187 | enable_patch1(handles) |
---|
| 188 | elseif isequal(ind_opening,4) |
---|
| 189 | set(handles.CIV2,'Value',1) |
---|
| 190 | enable_civ2(handles,1) |
---|
| 191 | elseif isequal(ind_opening,5) |
---|
| 192 | set(handles.FIX2,'Value',1) |
---|
| 193 | enable_fix2(handles) |
---|
| 194 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 195 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 196 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 197 | enable_pair1(handles,'off') |
---|
| 198 | elseif isequal(ind_opening,6) |
---|
| 199 | set(handles.PATCH2,'Value',1) |
---|
| 200 | enable_patch2(handles) |
---|
| 201 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 202 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 203 | enable_pair1(handles,'off') |
---|
| 204 | end |
---|
| 205 | |
---|
| 206 | % set the range of fields (1:1 by default) and selected pair |
---|
[12] | 207 | if isempty(num2)||isequal(num2,num1) |
---|
[2] | 208 | num_ref_i=num1; |
---|
| 209 | else |
---|
| 210 | num_ref_i=floor((num1+num2)/2); |
---|
| 211 | browse.incr_pair(1)=num2-num1; |
---|
| 212 | browse.incr_pair(2)=0; |
---|
| 213 | end |
---|
[12] | 214 | if isempty(num_b)||isequal(num_a,num_b) |
---|
[2] | 215 | if isempty(num_a) |
---|
| 216 | num_ref_j=1; |
---|
| 217 | else |
---|
| 218 | num_ref_j=num_a; |
---|
| 219 | end |
---|
| 220 | else |
---|
| 221 | num_ref_j=floor((num_a+num_b)/2); |
---|
| 222 | browse.incr_pair(2)=num_b-num_a; |
---|
| 223 | end |
---|
| 224 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 225 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 226 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 227 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 228 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 229 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
| 230 | set(handles.browse_root,'UserData',browse); |
---|
| 231 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 232 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 233 | end |
---|
| 234 | |
---|
| 235 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 236 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 237 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 238 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 239 | |
---|
[12] | 240 | %------------------------------------------------------------------------ |
---|
[2] | 241 | % --- Outputs from this function are returned to the command line. |
---|
| 242 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 243 | %------------------------------------------------------------------------ |
---|
[2] | 244 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 245 | % hObject handle to figure |
---|
| 246 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 247 | % handles structure with handles and user data (see GUIDATA) |
---|
| 248 | % Get default command line output from handles structure |
---|
| 249 | varargout{1} = handles.output; |
---|
| 250 | |
---|
[12] | 251 | %------------------------------------------------------------------------ |
---|
[2] | 252 | % --- Executes on button press in browse_root. |
---|
| 253 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 254 | %------------------------------------------------------------------------ |
---|
[2] | 255 | %get the input file properties |
---|
| 256 | filebase=get(handles.displ_filebase,'String'); |
---|
| 257 | oldfile=''; %default |
---|
[39] | 258 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 259 | dir_perso=prefdir; |
---|
| 260 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 261 | display(profil_perso) |
---|
| 262 | if exist(profil_perso,'file') |
---|
| 263 | h=load (profil_perso); |
---|
| 264 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 265 | oldfile=h.filebase; |
---|
| 266 | end |
---|
| 267 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 268 | oldfile=h.RootPath; |
---|
| 269 | end |
---|
| 270 | end |
---|
| 271 | else |
---|
| 272 | oldfile=filebase; |
---|
| 273 | end |
---|
| 274 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 275 | ind_opening=1;%default |
---|
| 276 | browse.incr_pair=[0 0]; %default |
---|
| 277 | if testall |
---|
| 278 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 279 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 280 | else % menu selecting only .civ or .avi files |
---|
| 281 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 282 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 283 | '*.*', 'All Files (*.*)'}; |
---|
| 284 | end |
---|
| 285 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 286 | fileinput=[PathName FileName];%complete file name |
---|
| 287 | sizf=size(fileinput); |
---|
| 288 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 289 | [path,name,ext]=fileparts(fileinput); |
---|
| 290 | testeditxml=0; |
---|
| 291 | if isequal(ext,'.xml') |
---|
| 292 | testeditxml=1; |
---|
| 293 | t_browse=xmltree(fileinput); |
---|
| 294 | head_element=get(t_browse,1); |
---|
[45] | 295 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 296 | testeditxml=0; |
---|
| 297 | end |
---|
| 298 | end |
---|
[45] | 299 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[2] | 300 | heditxml=editxml({fileinput}); |
---|
| 301 | set(heditxml,'Tag','browser') |
---|
| 302 | waitfor(heditxml,'Tag','idle') |
---|
| 303 | if ~ishandle(heditxml) |
---|
| 304 | return |
---|
| 305 | end |
---|
| 306 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 307 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 308 | fileinput=get(attr,'UserData'); |
---|
| 309 | if ~exist(fileinput,'file') |
---|
| 310 | return |
---|
| 311 | end |
---|
| 312 | end |
---|
[54] | 313 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 314 | filebase=fullfile(RootPath,RootFile); |
---|
[54] | 315 | % if isequal(nom_type,'*')% all fields in a single file ( movie files) |
---|
| 316 | % num_i1=1;num_i2=1;num_j1=1;num_j2=1; |
---|
| 317 | % else |
---|
| 318 | num_i1=stra2num(str1); |
---|
| 319 | if isempty(num_i1),num_i1=1;end |
---|
| 320 | num_i2=stra2num(str2); |
---|
| 321 | if isempty(num_i2),num_i2=1;end |
---|
| 322 | num_j1=stra2num(str_a); |
---|
| 323 | if isempty(num_j1),num_j1=1;end |
---|
| 324 | num_j2=stra2num(str_b); |
---|
| 325 | if isempty(num_j2),num_j2=1;end |
---|
[2] | 326 | if isequal(get(handles.compare,'Value'),1) |
---|
| 327 | browse=[];%initialisation |
---|
| 328 | else |
---|
| 329 | browse=get(handles.browse_root,'UserData'); |
---|
| 330 | end |
---|
[45] | 331 | if length(ext)>1 && (~isempty(imformats(ext([2:end])))||... |
---|
| 332 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
[2] | 333 | set(handles.ext_ima,'String',ext) |
---|
| 334 | browse.nom_type_ima=nom_type; |
---|
[45] | 335 | browse.field_count=num_i1; |
---|
| 336 | % A=imread(fileinput); |
---|
| 337 | % npxy=size(A); |
---|
| 338 | % set(handles.ext_ima,'UserData',npxy) |
---|
[2] | 339 | end |
---|
| 340 | set(handles.ImaDoc,'String',ext); |
---|
| 341 | |
---|
| 342 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 343 | if isequal(ext,'.nc') |
---|
| 344 | browse.nom_type_nc=nom_type; |
---|
| 345 | ind_opening=2;% propose 'fix' as the default option |
---|
| 346 | Data=nc2struct(fileinput,[]); |
---|
| 347 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
| 348 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 349 | ind_opening=3; |
---|
| 350 | end |
---|
| 351 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 352 | ind_opening=4; |
---|
| 353 | end |
---|
| 354 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 355 | ind_opening=5; |
---|
| 356 | end |
---|
| 357 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 358 | ind_opening=6; |
---|
| 359 | end |
---|
| 360 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 361 | else |
---|
| 362 | ind_opening=3; %GUI used only for patch |
---|
| 363 | testciv=0; |
---|
| 364 | end |
---|
| 365 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 366 | set(handles.subdir_civ2,'String',subdir); |
---|
| 367 | browse.testciv=testciv; |
---|
| 368 | browse.ind_opening=ind_opening; |
---|
| 369 | end |
---|
| 370 | set(handles.displ_filebase,'String',filebase); |
---|
| 371 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 372 | if ~isempty(num_i1) |
---|
| 373 | ref_i=num_i1; |
---|
| 374 | if ~isempty(num_i2) |
---|
| 375 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 376 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 377 | browse.incr_pair(2)=0; |
---|
| 378 | end |
---|
| 379 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 380 | set(handles.last_i,'String',num2str(ref_i)); |
---|
| 381 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 382 | end |
---|
[45] | 383 | if isempty(num_j1) |
---|
[2] | 384 | set(handles.ref_j,'String','1'); |
---|
| 385 | else |
---|
[45] | 386 | ref_j=num_j1; |
---|
| 387 | if ~isempty(num_j2) |
---|
| 388 | ref_j=floor((num_j1+num_j2)/2); |
---|
| 389 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 390 | end |
---|
| 391 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 392 | set(handles.last_j,'String',num2str(ref_j)); |
---|
| 393 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
| 394 | end |
---|
| 395 | |
---|
| 396 | % set default operation options |
---|
| 397 | enable_civ1(handles,'off') |
---|
| 398 | enable_civ2(handles,'off') |
---|
| 399 | enable_pair1(handles,'on') |
---|
| 400 | enable_fix1(handles,'off') |
---|
| 401 | desable_patch1(handles) |
---|
| 402 | desable_fix2(handles) |
---|
| 403 | desable_patch2(handles) |
---|
| 404 | set(handles.CIV1,'Value',0) |
---|
| 405 | set(handles.FIX1,'Value',0) |
---|
| 406 | set(handles.PATCH1,'Value',0) |
---|
| 407 | set(handles.CIV2,'Value',0) |
---|
| 408 | set(handles.FIX2,'Value',0) |
---|
| 409 | set(handles.PATCH2,'Value',0) |
---|
| 410 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 411 | if isequal(ind_opening,1) |
---|
| 412 | set(handles.CIV1,'Value',1) |
---|
| 413 | enable_civ1(handles,'on') |
---|
| 414 | elseif isequal(ind_opening,2) |
---|
| 415 | set(handles.FIX1,'Value',1) |
---|
| 416 | enable_fix1(handles,'on') |
---|
| 417 | elseif isequal(ind_opening,3) |
---|
| 418 | set(handles.PATCH1,'Value',1) |
---|
| 419 | enable_patch1(handles) |
---|
| 420 | elseif isequal(ind_opening,4) |
---|
| 421 | set(handles.CIV2,'Value',1) |
---|
| 422 | enable_civ2(handles,1) |
---|
| 423 | elseif isequal(ind_opening,5) |
---|
| 424 | enable_pair1(handles,'off') |
---|
| 425 | set(handles.FIX2,'Value',1) |
---|
| 426 | enable_fix2(handles) |
---|
| 427 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 428 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 429 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 430 | elseif isequal(ind_opening,6) |
---|
| 431 | enable_pair1(handles,'off') |
---|
| 432 | set(handles.PATCH2,'Value',1) |
---|
| 433 | enable_patch2(handles) |
---|
| 434 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 435 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 436 | end |
---|
| 437 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 438 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 439 | set(handles.ImaDoc,'UserData',testall); |
---|
| 440 | |
---|
| 441 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 442 | |
---|
[12] | 443 | %------------------------------------------------------------------------ |
---|
[2] | 444 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 445 | %------------------------------------------------------------------------ |
---|
[2] | 446 | displ_filebase_Callback(hObject, eventdata, handles) |
---|
| 447 | |
---|
[12] | 448 | %------------------------------------------------------------------------ |
---|
[54] | 449 | % --- function activated when a new filebase (image series) is introduced |
---|
[2] | 450 | function displ_filebase_Callback(hObject, eventdata, handles) |
---|
[12] | 451 | %------------------------------------------------------------------------ |
---|
[2] | 452 | global test_batch |
---|
| 453 | set(handles.compare,'Visible','on') |
---|
| 454 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 455 | nom_type_ima=[];%default |
---|
| 456 | field_count=1;%default |
---|
| 457 | nom_type_nc=[]; |
---|
| 458 | time=[]; |
---|
| 459 | TimeUnit=[]; %default |
---|
| 460 | CoordUnit=[];%default |
---|
| 461 | pxcmx_search=[];%default |
---|
| 462 | pxcmy_search=[];%default |
---|
| 463 | filebase=get(handles.displ_filebase,'String'); |
---|
| 464 | |
---|
| 465 | ext=get(handles.ImaDoc,'String'); |
---|
| 466 | browse=get(handles.browse_root,'UserData');%default |
---|
| 467 | if ~isempty(browse) |
---|
| 468 | if isfield(browse,'nom_type_ima') |
---|
[12] | 469 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[2] | 470 | end |
---|
| 471 | if isfield(browse,'field_count') |
---|
[12] | 472 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
[2] | 473 | end |
---|
| 474 | end |
---|
| 475 | |
---|
| 476 | %default first_i and j and increments |
---|
| 477 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
[12] | 478 | if isempty(first_i)|| first_i < 1 |
---|
[2] | 479 | first_i=1; %default first_i |
---|
| 480 | end |
---|
| 481 | last_i=str2num(get(handles.last_i,'String')); |
---|
[12] | 482 | if isempty(last_i)|| last_i < first_i |
---|
[2] | 483 | last_i=first_i; %default last_i |
---|
| 484 | end |
---|
| 485 | first_j=str2num(get(handles.first_j,'String')); |
---|
[39] | 486 | if isempty(first_j)|| first_j < 1 |
---|
[2] | 487 | first_j=1; %default first_j |
---|
| 488 | end |
---|
| 489 | last_j=str2num(get(handles.last_j,'String')); |
---|
[39] | 490 | if isempty(last_j)|| last_j < first_j |
---|
[2] | 491 | last_j=first_j; %default last_j |
---|
| 492 | end |
---|
| 493 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
[39] | 494 | if isempty(incr_i) || incr_i < 1; |
---|
[2] | 495 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 496 | end |
---|
| 497 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
[39] | 498 | if isempty(incr_j) || incr_j < 1; |
---|
[2] | 499 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 500 | end |
---|
| 501 | dt=[];%default |
---|
| 502 | testmode=0;%default |
---|
| 503 | nbfield=[]; %default |
---|
| 504 | nburst=[];%default |
---|
| 505 | pxcmx=1; |
---|
| 506 | pxcmy=1; |
---|
| 507 | |
---|
| 508 | %look for an image documentation file |
---|
| 509 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
| 510 | if exist([filebase '.xml'],'file') |
---|
| 511 | ext='.xml'; |
---|
| 512 | elseif exist([filebase '.civxml'],'file') |
---|
| 513 | ext='.civxml'; |
---|
| 514 | elseif exist([filebase '.civ'],'file') |
---|
| 515 | ext='.civ'; |
---|
| 516 | elseif exist([filebase '.avi'],'file') |
---|
| 517 | ext='.avi'; |
---|
| 518 | elseif exist([filebase '.AVI'],'file') |
---|
| 519 | ext='.AVI'; |
---|
| 520 | end |
---|
| 521 | set(handles.ImaDoc,'String',ext) |
---|
| 522 | end |
---|
| 523 | |
---|
| 524 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 525 | mode=''; %default |
---|
| 526 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 527 | drawnow |
---|
| 528 | %read the image documentation file if found |
---|
[12] | 529 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
[2] | 530 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 531 | set(handles.ref_j,'Visible','On') |
---|
| 532 | set(handles.dt,'Visible','Off') |
---|
[12] | 533 | set(handles.dt_text,'String','') |
---|
| 534 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
[2] | 535 | set(handles.ref_j,'Visible','Off') |
---|
| 536 | set(handles.dt,'Visible','Off') |
---|
| 537 | set(handles.dt_text,'String','ref. ind.') |
---|
| 538 | else |
---|
| 539 | set(handles.ref_i,'Visible','Off') |
---|
| 540 | set(handles.ref_j,'Visible','Off') |
---|
| 541 | set(handles.dt,'Visible','On') |
---|
| 542 | set(handles.dt_text,'String','dt(ms)=') |
---|
| 543 | end |
---|
[12] | 544 | testima_xml=0; |
---|
[2] | 545 | if isequal(ext,'.civxml')%TO ABANDON |
---|
| 546 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
| 547 | mode='pair j1-j2'; |
---|
| 548 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
| 549 | nom_type_ima='_i_j'; |
---|
| 550 | end |
---|
| 551 | elseif isequal(ext,'.xml') |
---|
| 552 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
| 553 | if isfield(XmlData,'Time') |
---|
| 554 | time=XmlData.Time; |
---|
[54] | 555 | nbfield=size(time,1); |
---|
| 556 | nburst=size(time,2); |
---|
[2] | 557 | end |
---|
| 558 | ext_ima_read=[]; |
---|
| 559 | nom_type_read=[]; |
---|
[12] | 560 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 561 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[39] | 562 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 563 | if ~exist(fullname,'file') |
---|
| 564 | % testima_xml=1; |
---|
| 565 | % else |
---|
[12] | 566 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 567 | end |
---|
[2] | 568 | end |
---|
| 569 | if isfield(XmlData,'Camera') |
---|
| 570 | if isfield(XmlData.Camera,'TimeUnit') |
---|
| 571 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 572 | end |
---|
| 573 | if isfield(XmlData.Camera,'ImageSize') |
---|
| 574 | ImageSize=XmlData.Camera.ImageSize; |
---|
| 575 | if ~isempty(ImageSize)&& ~isempty(ImageSize) |
---|
| 576 | xindex=findstr(ImageSize,'x'); |
---|
[45] | 577 | % if length(xindex)>=2 |
---|
| 578 | % npx=str2num(ImageSize(1:xindex(1)-1)); |
---|
| 579 | % npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1)); |
---|
| 580 | % end |
---|
[2] | 581 | end |
---|
| 582 | end |
---|
| 583 | end |
---|
| 584 | pxcmx_search=1; |
---|
| 585 | pxcmy_search=1; |
---|
| 586 | if isfield(XmlData,'GeometryCalib') |
---|
| 587 | tsai=XmlData.GeometryCalib; |
---|
| 588 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
| 589 | rot2D=tsai.R([1:2],[1,2]); |
---|
| 590 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 591 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
| 592 | end |
---|
| 593 | if isfield(tsai,'CoordUnit') |
---|
| 594 | CoordUnit=tsai.CoordUnit; |
---|
| 595 | end |
---|
| 596 | end |
---|
| 597 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
| 598 | if isempty(ext_ima) |
---|
| 599 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
| 600 | else %keep the image extension |
---|
| 601 | if ~strcmp(ext_ima_read,ext_ima) |
---|
| 602 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
| 603 | end |
---|
| 604 | end |
---|
| 605 | nom_type_ima=nom_type_read; |
---|
| 606 | end |
---|
| 607 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
| 608 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
[12] | 609 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 610 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
[2] | 611 | end |
---|
| 612 | % ext_ima='.png'; |
---|
| 613 | nom_type_ima='png_old'; |
---|
| 614 | elseif isequal(lower(ext),'.avi') |
---|
| 615 | nom_type_ima='*'; |
---|
| 616 | ext_ima=ext; |
---|
| 617 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 618 | dt=0.04;%default |
---|
| 619 | if exist([filebase ext],'file')==2 |
---|
| 620 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
| 621 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 622 | nbfield=info.NumFrames;%number of frames |
---|
| 623 | end |
---|
| 624 | time=(dt*[0:nbfield-1])';%list of image times |
---|
| 625 | set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
| 626 | end |
---|
| 627 | if isempty(time) |
---|
| 628 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 629 | end |
---|
| 630 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 631 | |
---|
[12] | 632 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
| 633 | if isempty(nom_type_ima) |
---|
| 634 | %look for double image series '_i_j' |
---|
| 635 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 636 | if isempty(dirima) |
---|
| 637 | % look for images series with sub marker '_' |
---|
| 638 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 639 | if isempty(dirima) |
---|
| 640 | % look for other images series |
---|
| 641 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
| 642 | if ~isempty(dirima) |
---|
| 643 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 644 | end |
---|
| 645 | else |
---|
| 646 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 647 | end |
---|
| 648 | else |
---|
| 649 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 650 | end |
---|
| 651 | end |
---|
| 652 | |
---|
[2] | 653 | % no image documentation file found: look for a series of existing images or .nc files |
---|
| 654 | if isempty(time) && ~isequal(ext,'.nc') |
---|
[12] | 655 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 656 | incr_pair=[0 0];%default |
---|
| 657 | if isfield(browse,'incr_pair') |
---|
| 658 | incr_pair=browse.incr_pair; |
---|
| 659 | end |
---|
| 660 | nbdetect=0;%test of detected images |
---|
| 661 | field_i=field_count; |
---|
| 662 | idetect=1; |
---|
| 663 | while idetect==1 %look for the maximum file number in the series |
---|
| 664 | field_i=field_i+1; |
---|
| 665 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
| 666 | if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 667 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 668 | nbdetect=1; |
---|
| 669 | else |
---|
| 670 | idetect=(exist(imagename,'file')==2); |
---|
| 671 | end |
---|
| 672 | %SEE CASE OF NETCDF FILES |
---|
| 673 | nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 674 | end |
---|
| 675 | nb_field=field_i;% last detected field number |
---|
| 676 | field_i=field_count;%look for the minimum file number in the series |
---|
| 677 | idetect=1; |
---|
| 678 | while idetect==1 |
---|
| 679 | field_i=field_i-1; |
---|
[2] | 680 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
[12] | 681 | if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 682 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 683 | nbdetect=1; |
---|
[2] | 684 | else |
---|
| 685 | idetect=(exist(imagename,'file')==2); |
---|
| 686 | end |
---|
[12] | 687 | nbdetect=nbdetect+idetect; |
---|
| 688 | end |
---|
| 689 | first_i=max(field_i+1,1); |
---|
| 690 | %determine the set of times and possible intervals for CIV |
---|
| 691 | dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 692 | time=(dt*[0:nb_field-1])'; |
---|
| 693 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 694 | end |
---|
| 695 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
| 696 | first_i=1; |
---|
| 697 | last_i=1; |
---|
| 698 | first_j=1; |
---|
| 699 | last_j=1; |
---|
| 700 | end |
---|
| 701 | if exist('time','var') |
---|
| 702 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 703 | nbfield=size(time,1); |
---|
| 704 | nbfield2=size(time,2); |
---|
| 705 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 706 | if isempty(TimeUnit) |
---|
[12] | 707 | set(handles.dt_unit,'String','dt in e-03'); |
---|
[2] | 708 | set(handles.TimeUnit,'String',''); |
---|
| 709 | else |
---|
[12] | 710 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
[2] | 711 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 712 | end |
---|
| 713 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 714 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 715 | end |
---|
| 716 | end |
---|
| 717 | set(handles.CoordUnit,'String',[CoordUnit '/']) |
---|
| 718 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 719 | % npxy=[npy npx]; |
---|
| 720 | set(handles.ext_ima,'String',ext_ima) |
---|
| 721 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 722 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 723 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 724 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 725 | browse.nom_type_ima=nom_type_ima; |
---|
| 726 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 727 | |
---|
| 728 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[41] | 729 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 730 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 731 | set(handles.mode,'Value',1) |
---|
[41] | 732 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
[2] | 733 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
| 734 | set(handles.mode,'Value',1) |
---|
| 735 | elseif (nbfield==1)% simple series in j |
---|
| 736 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 737 | set(handles.mode,'Value',1) |
---|
| 738 | else |
---|
| 739 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[41] | 740 | if nbfield2 <= 5 |
---|
| 741 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 742 | end |
---|
[41] | 743 | % else |
---|
| 744 | % if isequal(mode,'volume') |
---|
| 745 | % set(handles.mode,'Value',3) |
---|
| 746 | % elseif nbfield2 <= 5 |
---|
| 747 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 748 | % else |
---|
| 749 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 750 | % end |
---|
[2] | 751 | end |
---|
| 752 | |
---|
| 753 | %update the subdir |
---|
| 754 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 755 | listot=dir(pathdir); |
---|
| 756 | idir=0; |
---|
| 757 | listdir={''};%default |
---|
| 758 | for ilist=1:length(listot) |
---|
| 759 | if listot(ilist).isdir |
---|
| 760 | name=listot(ilist).name; |
---|
| 761 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 762 | idir=idir+1; |
---|
| 763 | listdir{idir,1}=listot(ilist).name; |
---|
| 764 | end |
---|
| 765 | end |
---|
| 766 | end |
---|
| 767 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 768 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 769 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
| 770 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
| 771 | %check wether the current subdir exists: |
---|
| 772 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 773 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 774 | |
---|
| 775 | mode_Callback(hObject, eventdata, handles) |
---|
| 776 | |
---|
| 777 | %%%%%% initialize waitbars and RUN button |
---|
| 778 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 779 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 780 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 781 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 782 | set(handles.RUN, 'Enable','On') |
---|
| 783 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 784 | if isequal(test_batch,1)%if batch installation is available |
---|
| 785 | set(handles.BATCH, 'Enable','On') |
---|
| 786 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 787 | end |
---|
| 788 | |
---|
| 789 | %%%%% store the root input filename for future opening |
---|
| 790 | dir_perso=prefdir; |
---|
| 791 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 792 | RootPath=fileparts(filebase); |
---|
| 793 | if exist(profil_perso,'file') |
---|
| 794 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 795 | else |
---|
| 796 | txt=ver; |
---|
| 797 | Release=txt(1).Release; |
---|
| 798 | relnumb=str2num(Release(3:4)); |
---|
| 799 | if relnumb >= 14 |
---|
| 800 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 801 | else |
---|
| 802 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 803 | end |
---|
| 804 | end |
---|
| 805 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 806 | set(gcf,'Pointer','arrow') |
---|
| 807 | |
---|
[12] | 808 | %------------------------------------------------------------------------ |
---|
[2] | 809 | % --- Executes on button press in mode. |
---|
| 810 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 811 | %------------------------------------------------------------------------ |
---|
[2] | 812 | browse=get(handles.browse_root,'UserData'); |
---|
| 813 | compare_list=get(handles.compare,'String'); |
---|
| 814 | val=get(handles.compare,'Value'); |
---|
| 815 | compare=compare_list{val}; |
---|
| 816 | if strcmp(compare,'displacement') |
---|
| 817 | mode='displacement'; |
---|
| 818 | else |
---|
| 819 | mode_list=get(handles.mode,'String'); |
---|
| 820 | mode_value=get(handles.mode,'Value'); |
---|
| 821 | mode=mode_list{mode_value}; |
---|
| 822 | end |
---|
| 823 | displ_num=[];%default |
---|
[54] | 824 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
[2] | 825 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 826 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 827 | siztime=size(time); |
---|
| 828 | nbfield=siztime(1); |
---|
| 829 | nbfield2=siztime(2); |
---|
| 830 | indchosen=1; %%first pair selected by default |
---|
| 831 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 832 | dt=1; |
---|
| 833 | displ=''; |
---|
| 834 | index=0; |
---|
| 835 | numlist_a=[]; |
---|
| 836 | numlist_B=[]; |
---|
| 837 | %get all the time intervals in bursts |
---|
| 838 | displ_dt=1;%default |
---|
| 839 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 840 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 841 | for numod_b=(numod_a+1):nbfield2 |
---|
| 842 | index=index+1; |
---|
| 843 | numlist_a(index)=numod_a; |
---|
| 844 | numlist_b(index)=numod_b; |
---|
| 845 | if ~isempty(time) |
---|
[54] | 846 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 847 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 848 | else |
---|
| 849 | displ_dt(index)=1; |
---|
| 850 | end |
---|
| 851 | end |
---|
| 852 | end |
---|
| 853 | [dtsort,indsort]=sort(displ_dt); |
---|
| 854 | if ~isempty(numlist_a) |
---|
| 855 | displ_num(1,:)=numlist_a(indsort); |
---|
| 856 | displ_num(2,:)=numlist_b(indsort); |
---|
| 857 | end |
---|
| 858 | displ_num(3,:)=0; |
---|
| 859 | displ_num(4,:)=0; |
---|
| 860 | set(handles.jtext,'Visible','Off') |
---|
| 861 | set(handles.first_j,'Visible','Off') |
---|
| 862 | set(handles.last_j,'Visible','Off') |
---|
| 863 | set(handles.incr_j,'Visible','Off') |
---|
| 864 | set(handles.nb_field2,'Visible','Off') |
---|
| 865 | set(handles.ref_j,'Visible','Off') |
---|
| 866 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 867 | for index=1:min(nbfield2-1,200) |
---|
| 868 | displ_num(1,index)=-floor(index/2); |
---|
| 869 | displ_num(2,index)=ceil(index/2); |
---|
| 870 | displ_num(3,index)=0; |
---|
| 871 | displ_num(4,index)=0; |
---|
| 872 | end |
---|
| 873 | set(handles.jtext,'Visible','On') |
---|
| 874 | set(handles.first_j,'Visible','On') |
---|
| 875 | set(handles.last_j,'Visible','On') |
---|
| 876 | set(handles.incr_j,'Visible','On') |
---|
| 877 | set(handles.nb_field2,'Visible','On') |
---|
| 878 | set(handles.ref_j,'Visible','On') |
---|
| 879 | if nbfield > 1 |
---|
| 880 | set(handles.itext,'Visible','On') |
---|
| 881 | set(handles.first_i,'Visible','On') |
---|
| 882 | set(handles.last_i,'Visible','On') |
---|
| 883 | set(handles.incr_i,'Visible','On') |
---|
| 884 | set(handles.nb_field,'Visible','On') |
---|
| 885 | set(handles.ref_i,'Visible','On') |
---|
| 886 | else |
---|
| 887 | set(handles.itext,'Visible','Off') |
---|
| 888 | set(handles.first_i,'Visible','Off') |
---|
| 889 | set(handles.last_i,'Visible','Off') |
---|
| 890 | set(handles.incr_i,'Visible','Off') |
---|
| 891 | set(handles.nb_field,'Visible','Off') |
---|
| 892 | set(handles.ref_i,'Visible','Off') |
---|
| 893 | end |
---|
| 894 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 895 | for index=1:200%min(nbfield-1,200) |
---|
| 896 | displ_num(1,index)=0; |
---|
| 897 | displ_num(2,index)=0; |
---|
| 898 | displ_num(3,index)=-floor(index/2); |
---|
| 899 | displ_num(4,index)=ceil(index/2); |
---|
| 900 | end |
---|
| 901 | set(handles.itext,'Visible','On') |
---|
| 902 | set(handles.first_i,'Visible','On') |
---|
| 903 | set(handles.last_i,'Visible','On') |
---|
| 904 | set(handles.incr_i,'Visible','On') |
---|
| 905 | set(handles.nb_field,'Visible','On') |
---|
| 906 | set(handles.ref_i,'Visible','On') |
---|
| 907 | if nbfield2 > 1 |
---|
| 908 | set(handles.jtext,'Visible','On') |
---|
| 909 | set(handles.first_j,'Visible','On') |
---|
| 910 | set(handles.last_j,'Visible','On') |
---|
| 911 | set(handles.incr_j,'Visible','On') |
---|
| 912 | set(handles.nb_field2,'Visible','On') |
---|
| 913 | set(handles.ref_j,'Visible','On') |
---|
| 914 | else |
---|
| 915 | set(handles.jtext,'Visible','Off') |
---|
| 916 | set(handles.first_j,'Visible','Off') |
---|
| 917 | set(handles.last_j,'Visible','Off') |
---|
| 918 | set(handles.incr_j,'Visible','Off') |
---|
| 919 | set(handles.nb_field2,'Visible','Off') |
---|
| 920 | set(handles.ref_j,'Visible','Off') |
---|
| 921 | end |
---|
| 922 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 923 | displ_num(1,1)=0; |
---|
| 924 | displ_num(2,1)=0; |
---|
| 925 | displ_num(3,1)=0; |
---|
| 926 | displ_num(4,1)=0; |
---|
| 927 | if nbfield > 1 |
---|
| 928 | set(handles.itext,'Visible','On') |
---|
| 929 | set(handles.first_i,'Visible','On') |
---|
| 930 | set(handles.last_i,'Visible','On') |
---|
| 931 | set(handles.incr_i,'Visible','On') |
---|
| 932 | set(handles.nb_field,'Visible','On') |
---|
| 933 | set(handles.ref_i,'Visible','On') |
---|
| 934 | else |
---|
| 935 | set(handles.itext,'Visible','Off') |
---|
| 936 | set(handles.first_i,'Visible','Off') |
---|
| 937 | set(handles.last_i,'Visible','Off') |
---|
| 938 | set(handles.incr_i,'Visible','Off') |
---|
| 939 | set(handles.nb_field,'Visible','Off') |
---|
| 940 | set(handles.ref_i,'Visible','Off') |
---|
| 941 | end |
---|
| 942 | if nbfield2 > 1 |
---|
| 943 | set(handles.jtext,'Visible','On') |
---|
| 944 | set(handles.first_j,'Visible','On') |
---|
| 945 | set(handles.last_j,'Visible','On') |
---|
| 946 | set(handles.incr_j,'Visible','On') |
---|
| 947 | set(handles.nb_field2,'Visible','On') |
---|
| 948 | set(handles.ref_j,'Visible','On') |
---|
| 949 | else |
---|
| 950 | set(handles.jtext,'Visible','Off') |
---|
| 951 | set(handles.first_j,'Visible','Off') |
---|
| 952 | set(handles.last_j,'Visible','Off') |
---|
| 953 | set(handles.incr_j,'Visible','Off') |
---|
| 954 | set(handles.nb_field2,'Visible','Off') |
---|
| 955 | set(handles.ref_j,'Visible','Off') |
---|
| 956 | end |
---|
| 957 | end |
---|
| 958 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 959 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 960 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 961 | |
---|
[12] | 962 | %------------------------------------------------------------------------ |
---|
[2] | 963 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 964 | % the field series set by first_i, incr, last_i |
---|
| 965 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 966 | %------------------------------------------------------------------------ |
---|
[2] | 967 | set(gcf,'Pointer','watch') |
---|
| 968 | %nomenclature types |
---|
| 969 | filebase=get(handles.displ_filebase,'String'); |
---|
| 970 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 971 | browse=get(handles.browse_root,'UserData'); |
---|
| 972 | compare_list=get(handles.compare,'String'); |
---|
| 973 | val=get(handles.compare,'Value'); |
---|
| 974 | compare=compare_list{val}; |
---|
| 975 | if strcmp(compare,'displacement') |
---|
| 976 | mode='displacement'; |
---|
| 977 | else |
---|
| 978 | mode_list=get(handles.mode,'String'); |
---|
| 979 | mode_value=get(handles.mode,'Value'); |
---|
| 980 | mode=mode_list{mode_value}; |
---|
| 981 | end |
---|
| 982 | |
---|
| 983 | % nomenclature type of the .nc files |
---|
| 984 | nom_type_ima=[];%default |
---|
| 985 | if isfield(browse,'nom_type_ima') |
---|
| 986 | nom_type_ima=browse.nom_type_ima; |
---|
| 987 | end |
---|
| 988 | |
---|
| 989 | %determine nom_type_nc: |
---|
| 990 | nom_type_nc=[];%default |
---|
| 991 | if isfield(browse,'nom_type_nc') |
---|
| 992 | nom_type_nc=browse.nom_type_nc; |
---|
| 993 | end |
---|
| 994 | if isempty(nom_type_nc) |
---|
| 995 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
| 996 | end |
---|
| 997 | browse.nom_type_nc=nom_type_nc; |
---|
| 998 | set(handles.browse_root,'UserData',browse) |
---|
| 999 | |
---|
| 1000 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 1001 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 1002 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1003 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1004 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1005 | % num1=first_i:incr:last_i; |
---|
| 1006 | % if isempty(num1) |
---|
| 1007 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1008 | % return |
---|
| 1009 | % end |
---|
| 1010 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1011 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1012 | ref_j=0; |
---|
| 1013 | else |
---|
[45] | 1014 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1015 | end |
---|
| 1016 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
| 1017 | if isempty(time) |
---|
| 1018 | time=[0 1]; |
---|
| 1019 | end |
---|
[45] | 1020 | dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[2] | 1021 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1022 | |
---|
| 1023 | %eliminate the first pairs inconsistent with the position |
---|
| 1024 | if isempty(displ_num) |
---|
| 1025 | nbpair=0; |
---|
| 1026 | else |
---|
| 1027 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1028 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1029 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1030 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1031 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1032 | end |
---|
| 1033 | end |
---|
| 1034 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1035 | |
---|
| 1036 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1037 | % be performed, while the result is needed for next steps. |
---|
| 1038 | displ_pair={''}; |
---|
| 1039 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1040 | testpair=0; |
---|
| 1041 | if get(handles.CIV1,'Value')==0 % |
---|
| 1042 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1043 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1044 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1045 | return |
---|
| 1046 | end |
---|
| 1047 | for ipair=1:nbpair |
---|
| 1048 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1049 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1050 | select(ipair)=exist(filename,'file')==2; |
---|
| 1051 | end |
---|
| 1052 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
| 1053 | if isfield(browse,'incr_pair') |
---|
| 1054 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1055 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1056 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1057 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1058 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1059 | select(1)=exist(filename,'file')==2; |
---|
| 1060 | testpair=1; |
---|
| 1061 | else |
---|
| 1062 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1063 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1064 | else |
---|
| 1065 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1066 | end |
---|
| 1067 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1068 | %COMPLETER CAS STEREO |
---|
| 1069 | return |
---|
| 1070 | end |
---|
| 1071 | end |
---|
| 1072 | end |
---|
| 1073 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1074 | if testpair |
---|
| 1075 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1076 | elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1077 | for ipair=1:nbpair |
---|
| 1078 | if select(ipair) |
---|
| 1079 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1080 | 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 |
---|
| 1081 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1082 | end |
---|
| 1083 | else |
---|
| 1084 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1085 | end |
---|
| 1086 | end |
---|
| 1087 | else |
---|
| 1088 | for ipair=1:nbpair |
---|
| 1089 | if select(ipair) |
---|
| 1090 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
| 1091 | else |
---|
| 1092 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1093 | end |
---|
| 1094 | end |
---|
| 1095 | end |
---|
| 1096 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1097 | if testpair |
---|
| 1098 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1099 | else |
---|
| 1100 | for ipair=1:nbpair |
---|
| 1101 | if select(ipair) |
---|
| 1102 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1103 | 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 |
---|
| 1104 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1105 | end |
---|
| 1106 | elseif testpair |
---|
| 1107 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1108 | else |
---|
| 1109 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1110 | end |
---|
| 1111 | end |
---|
| 1112 | end |
---|
| 1113 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1114 | for ipair=1:nbpair |
---|
| 1115 | if select(ipair) |
---|
| 1116 | 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 |
---|
| 1117 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1118 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1119 | else |
---|
| 1120 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1121 | end |
---|
| 1122 | end |
---|
| 1123 | elseif isequal(mode,'displacement') |
---|
| 1124 | displ_pair={'Di=Dj=0'}; |
---|
| 1125 | end |
---|
| 1126 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1127 | ichoice=min(find(select)); |
---|
[45] | 1128 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1129 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
| 1130 | if initial>nbpair |
---|
| 1131 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1132 | end |
---|
| 1133 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1134 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1135 | end |
---|
[45] | 1136 | |
---|
[2] | 1137 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1138 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1139 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1140 | if ichoice <= length(displ_pair') |
---|
| 1141 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1142 | else |
---|
| 1143 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1144 | end |
---|
| 1145 | end |
---|
| 1146 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1147 | set(gcf,'Pointer','arrow') |
---|
[12] | 1148 | |
---|
| 1149 | %------------------------------------------------------------------------ |
---|
[2] | 1150 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1151 | %middle of the series set by first_i, incr, last_i |
---|
| 1152 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1153 | %------------------------------------------------------------------------ |
---|
[2] | 1154 | set(gcf,'Pointer','watch') |
---|
| 1155 | %nomenclature types |
---|
| 1156 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1157 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1158 | browse=get(handles.browse_root,'UserData'); |
---|
| 1159 | compare_list=get(handles.compare,'String'); |
---|
| 1160 | val=get(handles.compare,'Value'); |
---|
| 1161 | compare=compare_list{val}; |
---|
| 1162 | if strcmp(compare,'displacement') |
---|
| 1163 | mode='displacement'; |
---|
| 1164 | else |
---|
| 1165 | mode_list=get(handles.mode,'String'); |
---|
| 1166 | mode_value=get(handles.mode,'Value'); |
---|
| 1167 | mode=mode_list{mode_value}; |
---|
| 1168 | end |
---|
| 1169 | |
---|
| 1170 | % nomenclature type of the .nc files |
---|
| 1171 | nom_type_ima='ima_num';%default |
---|
| 1172 | if isfield(browse,'nom_type_ima') |
---|
| 1173 | nom_type_ima=browse.nom_type_ima; |
---|
| 1174 | end |
---|
| 1175 | nom_type_nc='_i1-i2';%default |
---|
| 1176 | if isfield(browse,'nom_type_nc') |
---|
| 1177 | nom_type_nc=browse.nom_type_nc; |
---|
| 1178 | end |
---|
| 1179 | 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') |
---|
| 1180 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 1181 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 1182 | nom_type_nc='none'; |
---|
| 1183 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
| 1184 | nom_type_nc='_i1-i2'; |
---|
| 1185 | else |
---|
| 1186 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1187 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1188 | else |
---|
| 1189 | nom_type_nc='_i_j1-j2'; |
---|
| 1190 | end |
---|
| 1191 | end |
---|
| 1192 | browse.nom_type_nc=nom_type_nc; |
---|
| 1193 | set(handles.browse_root,'UserData',browse) |
---|
| 1194 | |
---|
| 1195 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1196 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1197 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1198 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1199 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1200 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1201 | % num1=first_i:incr:last_i; |
---|
| 1202 | % if isempty(num1) |
---|
| 1203 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1204 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1205 | % return |
---|
| 1206 | % end |
---|
[2] | 1207 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1208 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1209 | ref_j=0; |
---|
| 1210 | else |
---|
| 1211 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1212 | end |
---|
[57] | 1213 | % if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval |
---|
| 1214 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 1215 | % ref_j=1; |
---|
| 1216 | % end |
---|
[2] | 1217 | % ref_i=browse.num_ref;%field number initially selected by the browser |
---|
| 1218 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1219 | if isempty(time) |
---|
| 1220 | time=[0 1];%default |
---|
| 1221 | end |
---|
| 1222 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1223 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1224 | |
---|
| 1225 | |
---|
| 1226 | %eliminate the first pairs inconsistent with the position |
---|
| 1227 | if isempty(displ_num) |
---|
| 1228 | nbpair=0; |
---|
| 1229 | else |
---|
| 1230 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1231 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
| 1232 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1233 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1234 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1235 | end |
---|
| 1236 | end |
---|
| 1237 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1238 | |
---|
| 1239 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1240 | % be performed, while the result is needed for next steps. |
---|
| 1241 | displ_pair={''}; %default |
---|
| 1242 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1243 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1244 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1245 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1246 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1247 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1248 | return |
---|
| 1249 | end |
---|
| 1250 | for ipair=1:nbpair |
---|
| 1251 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1252 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1253 | select(ipair)=exist(filename,'file')==2; |
---|
| 1254 | end |
---|
| 1255 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1256 | if isfield(browse,'incr_pair') |
---|
| 1257 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1258 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1259 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1260 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1261 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1262 | select(1)=exist(filename,'file')==2; |
---|
| 1263 | else |
---|
| 1264 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1265 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1266 | else |
---|
| 1267 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1268 | end |
---|
| 1269 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1270 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1271 | return |
---|
| 1272 | end |
---|
| 1273 | end |
---|
| 1274 | end |
---|
| 1275 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1276 | % if ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1277 | for ipair=1:nbpair |
---|
| 1278 | if select(ipair) |
---|
| 1279 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1280 | 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 |
---|
| 1281 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1282 | end |
---|
| 1283 | else |
---|
| 1284 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1285 | end |
---|
| 1286 | end |
---|
| 1287 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1288 | for ipair=1:nbpair |
---|
| 1289 | if select(ipair) |
---|
| 1290 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1291 | 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 |
---|
| 1292 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1293 | end |
---|
| 1294 | else |
---|
| 1295 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1296 | end |
---|
| 1297 | end |
---|
| 1298 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1299 | for ipair=1:nbpair |
---|
| 1300 | if select(ipair) |
---|
| 1301 | 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 |
---|
| 1302 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1303 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1304 | else |
---|
| 1305 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1306 | end |
---|
| 1307 | end |
---|
| 1308 | elseif isequal(mode,'displacement') |
---|
| 1309 | displ_pair={'Di=Dj=0'}; |
---|
| 1310 | end |
---|
| 1311 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1312 | ichoice=min(find(select)); |
---|
| 1313 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1314 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1315 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1316 | end |
---|
| 1317 | if val>length(displ_pair') |
---|
| 1318 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1319 | else |
---|
| 1320 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1321 | end |
---|
| 1322 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1323 | set(gcf,'Pointer','arrow') |
---|
[2] | 1324 | |
---|
[12] | 1325 | %------------------------------------------------------------------------ |
---|
[2] | 1326 | % determine the list of index pairs of processing file |
---|
| 1327 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1328 | find_pair_indices(handles,mode) |
---|
[12] | 1329 | %------------------------------------------------------------------------ |
---|
[45] | 1330 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1331 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1332 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
[39] | 1333 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
[2] | 1334 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
[45] | 1335 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1336 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1337 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
[2] | 1338 | else |
---|
| 1339 | first_j=1; |
---|
| 1340 | last_j=1; |
---|
| 1341 | incr_j=1; |
---|
| 1342 | end |
---|
[36] | 1343 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
[2] | 1344 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1345 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
[36] | 1346 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
[2] | 1347 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1348 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1349 | return |
---|
| 1350 | end |
---|
| 1351 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1352 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1353 | if index_civ2>length(list_civ2) |
---|
| 1354 | list_civ2=list_civ1; |
---|
| 1355 | index_civ2=index_civ1; |
---|
| 1356 | end |
---|
[36] | 1357 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 1358 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
| 1359 | return,end; |
---|
[39] | 1360 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[36] | 1361 | return,end; |
---|
[39] | 1362 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[36] | 1363 | return,end; |
---|
[39] | 1364 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[36] | 1365 | return,end; |
---|
| 1366 | if isequal (mode,'series(Di)') |
---|
[2] | 1367 | %recognize the pair civ1 from the display |
---|
| 1368 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1369 | str_raw=str_civ1(indsel); |
---|
| 1370 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
[45] | 1371 | d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
[2] | 1372 | if indsepar==length(str_raw) |
---|
[45] | 1373 | d2=str2double(str_civ1([indsel(indsepar)+1:end])); |
---|
[2] | 1374 | else |
---|
[45] | 1375 | d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
[2] | 1376 | end |
---|
[39] | 1377 | num1_civ1=num_i-d1;% set of first image numbers |
---|
| 1378 | num2_civ1=num_i+d2; |
---|
[2] | 1379 | num_a_civ1=num_j; |
---|
| 1380 | num_b_civ1=num_j; |
---|
| 1381 | |
---|
| 1382 | %recognize the pair civ2 from the display |
---|
| 1383 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1384 | str_raw=str_civ2(indsel); |
---|
| 1385 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1386 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1387 | if indsepar==length(str_raw) |
---|
| 1388 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
| 1389 | else |
---|
| 1390 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1391 | end |
---|
| 1392 | if isempty(d1) |
---|
[39] | 1393 | num1_civ2=num_i; |
---|
[2] | 1394 | else |
---|
[39] | 1395 | num1_civ2=num_i-d1;% set of first image numbers |
---|
[2] | 1396 | end |
---|
| 1397 | if isempty(d2) |
---|
[39] | 1398 | num2_civ2=num_i; |
---|
[2] | 1399 | else |
---|
[39] | 1400 | num2_civ2=num_i+d2; |
---|
[2] | 1401 | end |
---|
| 1402 | num_a_civ2=num_j; |
---|
| 1403 | num_b_civ2=num_j; |
---|
| 1404 | |
---|
| 1405 | % adjust the first and last field number |
---|
| 1406 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1407 | if isequal(lastfield,[]) |
---|
| 1408 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1409 | else |
---|
| 1410 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1411 | end |
---|
| 1412 | if length(indsel)>=1 |
---|
| 1413 | firstind=indsel(1); |
---|
| 1414 | lastind=indsel(end); |
---|
[39] | 1415 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
| 1416 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
| 1417 | num_i=num_i(indsel); |
---|
[2] | 1418 | num1_civ1=num1_civ1(indsel); |
---|
| 1419 | num1_civ2=num1_civ2(indsel); |
---|
| 1420 | num2_civ1=num2_civ1(indsel); |
---|
| 1421 | num2_civ2=num2_civ2(indsel); |
---|
| 1422 | end |
---|
[36] | 1423 | elseif isequal (mode,'series(Dj)') |
---|
[2] | 1424 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
[39] | 1425 | num1_civ1=num_i;% set of first image numbers |
---|
| 1426 | num2_civ1=num_i; |
---|
[2] | 1427 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1428 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
[39] | 1429 | num1_civ2=num_i; |
---|
| 1430 | num2_civ2=num_i; |
---|
[2] | 1431 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1432 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1433 | % adjust the first and last field number |
---|
| 1434 | if isequal(lastfield_j,[]) |
---|
| 1435 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1436 | else |
---|
| 1437 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1438 | end |
---|
| 1439 | if length(indsel)>=1 |
---|
| 1440 | firstind=indsel(1); |
---|
| 1441 | lastind=indsel(end); |
---|
| 1442 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1443 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1444 | num_j=num_j(indsel); |
---|
| 1445 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1446 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1447 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1448 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1449 | end |
---|
[36] | 1450 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[39] | 1451 | num1_civ1=num_i; |
---|
| 1452 | num1_civ2=num_i; |
---|
[2] | 1453 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[39] | 1454 | num2_civ1=num_i; |
---|
[2] | 1455 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1456 | num_b_civ1=displ_num(2,index_civ1); |
---|
[39] | 1457 | num2_civ2=num_i; |
---|
[2] | 1458 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1459 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1460 | elseif isequal(mode,'displacement') |
---|
[39] | 1461 | num1_civ1=num_i; |
---|
| 1462 | num2_civ1=num_i; |
---|
[2] | 1463 | num_a_civ1=num_j; |
---|
| 1464 | num_b_civ1=num_j; |
---|
[39] | 1465 | num1_civ2=num_i; |
---|
| 1466 | num2_civ2=num_i; |
---|
[2] | 1467 | num_a_civ2=num_j; |
---|
| 1468 | num_b_civ2=num_j; |
---|
| 1469 | end |
---|
| 1470 | |
---|
[41] | 1471 | |
---|
[12] | 1472 | %------------------------------------------------------------------------ |
---|
[2] | 1473 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1474 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1475 | %------------------------------------------------------------------------ |
---|
[2] | 1476 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1477 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1478 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1479 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1480 | num_a=displ_num(1,index_pair); |
---|
| 1481 | num_b=displ_num(2,index_pair); |
---|
| 1482 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1483 | if index_pair<=length(list_pair2) |
---|
| 1484 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1485 | end |
---|
| 1486 | |
---|
| 1487 | %update first_i and last_i according to the chosen image pairs |
---|
| 1488 | mode_list=get(handles.mode,'String'); |
---|
| 1489 | mode_value=get(handles.mode,'Value'); |
---|
| 1490 | mode=mode_list{mode_value}; |
---|
| 1491 | if isequal(mode,'series(Di)') |
---|
| 1492 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1493 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1494 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1495 | num1=first_i:incr_i:last_i; |
---|
| 1496 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1497 | if ~isequal(lastfield,[]) |
---|
| 1498 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1499 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1500 | num1=num1(ind); |
---|
| 1501 | end |
---|
| 1502 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1503 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1504 | elseif isequal(mode,'series(Dj)') |
---|
| 1505 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1506 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1507 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1508 | num_j=first_j:incr_j:last_j; |
---|
| 1509 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1510 | if ~isequal(lastfield2,[]) |
---|
| 1511 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1512 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1513 | num1=num_j(ind); |
---|
| 1514 | end |
---|
| 1515 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1516 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1517 | end |
---|
| 1518 | |
---|
[12] | 1519 | %------------------------------------------------------------------------ |
---|
[2] | 1520 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1521 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1522 | %------------------------------------------------------------------------ |
---|
[2] | 1523 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1524 | |
---|
| 1525 | %update first_i and last_i according to the chosen image pairs |
---|
| 1526 | mode_list=get(handles.mode,'String'); |
---|
| 1527 | mode_value=get(handles.mode,'Value'); |
---|
| 1528 | mode=mode_list{mode_value}; |
---|
| 1529 | if isequal(mode,'series(Di)') |
---|
| 1530 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1531 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1532 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1533 | num1=first_i:incr_i:last_i; |
---|
| 1534 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1535 | if ~isequal(lastfield,[]) |
---|
| 1536 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1537 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1538 | num1=num1(ind); |
---|
| 1539 | end |
---|
| 1540 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1541 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1542 | elseif isequal(mode,'series(Dj)') |
---|
| 1543 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1544 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1545 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1546 | num_j=first_j:incr_j:last_j; |
---|
| 1547 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1548 | if ~isequal(lastfield2,[]) |
---|
| 1549 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1550 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1551 | num1=num_j(ind); |
---|
| 1552 | end |
---|
| 1553 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1554 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1555 | end |
---|
| 1556 | |
---|
[12] | 1557 | %------------------------------------------------------------------------ |
---|
[2] | 1558 | % --- Executes on button press in RUN. |
---|
| 1559 | |
---|
| 1560 | |
---|
| 1561 | |
---|
[67] | 1562 | % compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1563 | % %check the list of operations: |
---|
| 1564 | % operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1565 | % run_flag=1; |
---|
| 1566 | % box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1567 | % box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1568 | % box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1569 | % box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1570 | % box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1571 | % box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1572 | % index=find(box_test==1); |
---|
| 1573 | % if isempty(index) |
---|
| 1574 | % msgbox_uvmat('ERROR','no selected operation') |
---|
| 1575 | % return |
---|
| 1576 | % end |
---|
| 1577 | % index_first=min(index); |
---|
| 1578 | % index_last=max(index); |
---|
| 1579 | % box_used=box_test([index_first : index_last]); |
---|
| 1580 | % [box_missing,ind_missing]=min(box_used); |
---|
| 1581 | % if isequal(box_missing,0) |
---|
| 1582 | % msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1583 | % return |
---|
| 1584 | % end |
---|
| 1585 | % |
---|
| 1586 | % %root name |
---|
| 1587 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 1588 | % if isempty(filebase)||isequal(filebase,'') |
---|
| 1589 | % msgbox_uvmat('ERROR','no input files') |
---|
| 1590 | % return |
---|
| 1591 | % end |
---|
| 1592 | % %check mask if selecetd |
---|
| 1593 | % if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
| 1594 | % maskname=get(handles.mask_civ1,'String'); |
---|
| 1595 | % if ~exist(maskname,'file') |
---|
| 1596 | % get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1597 | % end |
---|
| 1598 | % end |
---|
| 1599 | % if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
| 1600 | % maskname=get(handles.mask_fix1,'String'); |
---|
| 1601 | % if ~exist(maskname,'file') |
---|
| 1602 | % get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1603 | % end |
---|
| 1604 | % end |
---|
| 1605 | % if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
| 1606 | % maskname=get(handles.mask_civ2,'String'); |
---|
| 1607 | % if ~exist(maskname,'file') |
---|
| 1608 | % get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
| 1609 | % end |
---|
| 1610 | % end |
---|
| 1611 | % if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
| 1612 | % maskname=get(handles.mask_fix2,'String'); |
---|
| 1613 | % if ~exist(maskname,'file') |
---|
| 1614 | % get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
| 1615 | % end |
---|
| 1616 | % end |
---|
| 1617 | % |
---|
| 1618 | % %read names of the .exe file |
---|
| 1619 | % if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 |
---|
| 1620 | % path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1621 | % path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 1622 | % %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 1623 | % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 1624 | % if exist(xmlfile,'file') |
---|
| 1625 | % t=xmltree(xmlfile); |
---|
| 1626 | % sparam=convert(t); |
---|
| 1627 | % end |
---|
| 1628 | % if isfield(sparam,'Civ1Bin') |
---|
| 1629 | % civ1Bin=sparam.Civ1Bin; |
---|
| 1630 | % if ~exist(civ1Bin,'file') |
---|
| 1631 | % civ1Bin=fullfile(path_UVMAT,civ1Bin); |
---|
| 1632 | % end |
---|
| 1633 | % end |
---|
| 1634 | % if isfield(sparam,'Civ2Bin') |
---|
| 1635 | % civ2Bin=sparam.Civ2Bin; |
---|
| 1636 | % if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting |
---|
| 1637 | % civ2_exe=fullfile(path_UVMAT,civ2_exe); |
---|
| 1638 | % end |
---|
| 1639 | % end |
---|
| 1640 | % if isfield(sparam,'Patch_exe') |
---|
| 1641 | % patch_exe=sparam.Patch_exe; |
---|
| 1642 | % if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting |
---|
| 1643 | % patch_exe=fullfile(path_UVMAT,patch_exe); |
---|
| 1644 | % end |
---|
| 1645 | % end |
---|
| 1646 | % if isfield(sparam,'Stinterp_exe') |
---|
| 1647 | % stinterp_exe=sparam.Stinterp_exe; |
---|
| 1648 | % end |
---|
| 1649 | % if isfield(sparam,'SGE') |
---|
| 1650 | % sge=str2double(sparam.SGE); |
---|
| 1651 | % end |
---|
| 1652 | % if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
| 1653 | % dircur=pwd; |
---|
| 1654 | % if ~isequal(dircur([2 3]),':\') |
---|
| 1655 | % msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
| 1656 | % return; |
---|
| 1657 | % end |
---|
| 1658 | % end |
---|
| 1659 | % end |
---|
| 1660 | % |
---|
| 1661 | % %initialize the waitbars |
---|
| 1662 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 1663 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 1664 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 1665 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 1666 | % set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1667 | % set(handles.RUN, 'Enable','Off') |
---|
| 1668 | % drawnow |
---|
| 1669 | % |
---|
| 1670 | % % get the list of file names and check the files |
---|
| 1671 | % display('checking the files...') |
---|
| 1672 | % [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]=... |
---|
| 1673 | % set_civ_filenames(handles,compare,box_test); |
---|
| 1674 | % nbfield=numel(num1_civ1); |
---|
| 1675 | % nbslice=size(num_a_civ1); |
---|
| 1676 | % |
---|
| 1677 | % if isempty(filecell) |
---|
| 1678 | % set(handles.RUN, 'Enable','On') |
---|
| 1679 | % set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1680 | % set(handles.BATCH, 'Enable','On') |
---|
| 1681 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1682 | % return |
---|
| 1683 | % end |
---|
| 1684 | % display('files OK, processing...') |
---|
| 1685 | % nbfield=size(num1_civ1,2); |
---|
| 1686 | % nbslice=size(num1_civ1,1); |
---|
| 1687 | % |
---|
| 1688 | % %RUN CIV1 |
---|
| 1689 | % if box_test(1)==1 |
---|
| 1690 | % 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) |
---|
| 1691 | % if compare==3 |
---|
| 1692 | % 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) |
---|
| 1693 | % end |
---|
| 1694 | % end |
---|
| 1695 | % |
---|
| 1696 | % %RUN FIX1 |
---|
| 1697 | % if box_test(2)==1 |
---|
| 1698 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 1699 | % %names of the civ1 fields |
---|
| 1700 | % field1.vel_type='civ1'; |
---|
| 1701 | % field1.nb='nb_vectors'; |
---|
| 1702 | % % field1.X='vec_X'; |
---|
| 1703 | % % field1.Y='vec_Y'; |
---|
| 1704 | % % field1.U='vec_U'; |
---|
| 1705 | % % field1.V='vec_V'; |
---|
| 1706 | % field1.fixflag='vec_FixFlag'; |
---|
| 1707 | % flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1708 | % flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
| 1709 | % flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
| 1710 | % thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1711 | % thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 1712 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 1713 | % menu=get(handles.field_ref1,'String'); |
---|
| 1714 | % index=get(handles.field_ref1,'Value'); |
---|
| 1715 | % if isempty(menu) |
---|
| 1716 | % fieldchoice=''; |
---|
| 1717 | % else |
---|
| 1718 | % fieldchoice=menu{index}; |
---|
| 1719 | % end |
---|
| 1720 | % h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar |
---|
| 1721 | % test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1722 | % if test_mask |
---|
| 1723 | % maskdispl=get(handles.mask_fix1,'String'); |
---|
| 1724 | % if exist(maskdispl,'file') |
---|
| 1725 | % test_mask=2; |
---|
| 1726 | % maskname=maskdispl; |
---|
| 1727 | % else |
---|
| 1728 | % maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1729 | % end |
---|
| 1730 | % end |
---|
| 1731 | % for ifile=1:nbfield |
---|
| 1732 | % waitbar(ifile/nbfield); %update the waitbar |
---|
| 1733 | % for j=1:nbslice |
---|
| 1734 | % if test_mask==0 |
---|
| 1735 | % maskname='noFile use default'; |
---|
| 1736 | % maskflag=0; |
---|
| 1737 | % elseif test_mask==1 |
---|
| 1738 | % nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
| 1739 | % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1740 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
| 1741 | % maskflag= exist(maskname,'file')==2; |
---|
| 1742 | % if ~maskflag; |
---|
| 1743 | % maskname='noFile use default'; |
---|
| 1744 | % end |
---|
| 1745 | % end |
---|
| 1746 | % if ~isempty(file_ref_fix1) |
---|
| 1747 | % file_ref=file_ref_fix1{ifile,j}; |
---|
| 1748 | % else |
---|
| 1749 | % file_ref=''; |
---|
| 1750 | % end |
---|
| 1751 | % error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1752 | % thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1753 | % |
---|
| 1754 | % if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
| 1755 | % if test_mask==0 |
---|
| 1756 | % maskname='noFile use default'; |
---|
| 1757 | % maskflag=0; |
---|
| 1758 | % else |
---|
| 1759 | % maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1760 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1761 | % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1762 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1763 | % maskflag= exist(maskname,'file')==2; |
---|
| 1764 | % if ~maskflag; |
---|
| 1765 | % maskname='noFile use default'; |
---|
| 1766 | % end |
---|
| 1767 | % end |
---|
| 1768 | % error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1769 | % thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1770 | % if ~isempty(error) |
---|
| 1771 | % msgbox_uvmat('ERROR',error) |
---|
| 1772 | % return |
---|
| 1773 | % end |
---|
| 1774 | % end |
---|
| 1775 | % end |
---|
| 1776 | % end |
---|
| 1777 | % close(h) |
---|
| 1778 | % end |
---|
| 1779 | % |
---|
| 1780 | % % RUN PATCH1 |
---|
| 1781 | % if box_test(3)==1 |
---|
| 1782 | % rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 1783 | % if isempty(rho_patch1) |
---|
| 1784 | % rho_patch1='1000'; |
---|
| 1785 | % set(handles.rho_patch1,'String','1') |
---|
| 1786 | % else |
---|
| 1787 | % rho_patch1=num2str(1000*rho_patch1); |
---|
| 1788 | % end |
---|
| 1789 | % nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1790 | % if isequal(str2num(nx_patch1),[]) |
---|
| 1791 | % nx_patch1='50' ;%default |
---|
| 1792 | % set(handles.nx_patch1,'String','50'); |
---|
| 1793 | % end |
---|
| 1794 | % ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 1795 | % if isequal(str2num(ny_patch1),[]) |
---|
| 1796 | % ny_patch1='50' ;%default |
---|
| 1797 | % set(handles.ny_patch1,'String','50'); |
---|
| 1798 | % end |
---|
| 1799 | % subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1800 | % thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1801 | % test_interp=get(handles.test_interp,'Value'); |
---|
| 1802 | % icount=0; |
---|
| 1803 | % for ifile=1:nbfield |
---|
| 1804 | % for j=1:nbslice |
---|
| 1805 | % icount=icount+1; |
---|
| 1806 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1807 | % set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
| 1808 | % drawnow |
---|
| 1809 | % if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1810 | % cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1811 | % s=-1; |
---|
| 1812 | % if sge |
---|
| 1813 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1814 | % end |
---|
| 1815 | % if s~=0 |
---|
| 1816 | % display(['!' cmd]) |
---|
| 1817 | % eval(['!' cmd]); |
---|
| 1818 | % end |
---|
| 1819 | % |
---|
| 1820 | % %stereo case: |
---|
| 1821 | % elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 1822 | % if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1823 | % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
| 1824 | % nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1825 | % display(['!' cmd]) |
---|
| 1826 | % eval(['!' cmd]); |
---|
| 1827 | % else |
---|
| 1828 | % RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1829 | % str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1830 | % end |
---|
| 1831 | % end |
---|
| 1832 | % if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1833 | % cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1834 | % s=-1; |
---|
| 1835 | % if sge |
---|
| 1836 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1837 | % end |
---|
| 1838 | % if s~=0 |
---|
| 1839 | % display(['!' cmd]) |
---|
| 1840 | % eval(['!' cmd]); |
---|
| 1841 | % end |
---|
| 1842 | % end |
---|
| 1843 | % end |
---|
| 1844 | % end |
---|
| 1845 | % end |
---|
| 1846 | % |
---|
| 1847 | % % CIV2 |
---|
| 1848 | % if box_test(4)==1 |
---|
| 1849 | % RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
| 1850 | % num_a_civ2,num_b_civ2,nom_type_nc) |
---|
| 1851 | % end |
---|
| 1852 | % |
---|
| 1853 | % % FIX2 |
---|
| 1854 | % if box_test(5)==1 |
---|
| 1855 | % %names of the civ2 fields |
---|
| 1856 | % field2.vel_type='civ2'; |
---|
| 1857 | % field2.nb='nb_vectors2'; |
---|
| 1858 | % field2.X='vec2_X'; |
---|
| 1859 | % field2.Y='vec2_Y'; |
---|
| 1860 | % field2.U='vec2_U'; |
---|
| 1861 | % field2.V='vec2_V'; |
---|
| 1862 | % field2.fixflag='vec2_FixFlag'; |
---|
| 1863 | % flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1864 | % flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1865 | % flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
| 1866 | % thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1867 | % thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 1868 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1869 | % menu=get(handles.field_ref2,'String'); |
---|
| 1870 | % index=get(handles.field_ref2,'Value'); |
---|
| 1871 | % if isempty(menu) |
---|
| 1872 | % fieldchoice=''; |
---|
| 1873 | % else |
---|
| 1874 | % fieldchoice=menu{index}; |
---|
| 1875 | % end |
---|
| 1876 | % h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
| 1877 | % test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1878 | % if test_mask |
---|
| 1879 | % maskdispl=get(handles.mask_fix2,'String'); |
---|
| 1880 | % if exist(maskdispl,'file') |
---|
| 1881 | % test_mask=2; |
---|
| 1882 | % maskname=maskdispl; |
---|
| 1883 | % else |
---|
| 1884 | % maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1885 | % end |
---|
| 1886 | % end |
---|
| 1887 | % for ifile=1:nbfield |
---|
| 1888 | % waitbar(ifile/nbfield); %update the waitbar |
---|
| 1889 | % for j=1:nbslice |
---|
| 1890 | % if test_mask==0 |
---|
| 1891 | % maskname='noFile use default'; |
---|
| 1892 | % maskflag=0; |
---|
| 1893 | % elseif test_mask==1 |
---|
| 1894 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1895 | % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1896 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1897 | % maskflag= exist(maskname,'file')==2; |
---|
| 1898 | % if ~maskflag; |
---|
| 1899 | % maskname='noFile use default'; |
---|
| 1900 | % end |
---|
| 1901 | % end |
---|
| 1902 | % if ~isempty(file_ref_fix2) |
---|
| 1903 | % file_ref=file_ref_fix2{ifile,j}; |
---|
| 1904 | % else |
---|
| 1905 | % file_ref=''; |
---|
| 1906 | % end |
---|
| 1907 | % error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
| 1908 | % thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1909 | % if ~isempty(error) |
---|
| 1910 | % msgbox_uvmat('ERROR',error) |
---|
| 1911 | % return |
---|
| 1912 | % end |
---|
| 1913 | % if compare==3 |
---|
| 1914 | % if test_mask==0 |
---|
| 1915 | % maskname='noFile use default'; |
---|
| 1916 | % maskflag=0; |
---|
| 1917 | % else |
---|
| 1918 | % maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1919 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1920 | % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1921 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1922 | % maskflag= exist(maskname,'file')==2; |
---|
| 1923 | % if ~maskflag; |
---|
| 1924 | % maskname='noFile use default'; |
---|
| 1925 | % end |
---|
| 1926 | % end |
---|
| 1927 | % error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
| 1928 | % thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1929 | % if ~isempty(error) |
---|
| 1930 | % msgbox_uvmat('ERROR',error) |
---|
| 1931 | % return |
---|
| 1932 | % end |
---|
| 1933 | % end |
---|
| 1934 | % end |
---|
| 1935 | % end |
---|
| 1936 | % close(h) |
---|
| 1937 | % end |
---|
| 1938 | % |
---|
| 1939 | % %PATCH 2 |
---|
| 1940 | % if box_test(6)==1 |
---|
| 1941 | % rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 1942 | % if isempty(rho_patch2) |
---|
| 1943 | % rho_patch2='1000'; |
---|
| 1944 | % set(handles.rho_patch2,'String','1') |
---|
| 1945 | % else |
---|
| 1946 | % rho_patch2=num2str(1000*rho_patch2); |
---|
| 1947 | % end |
---|
| 1948 | % nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1949 | % ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 1950 | % thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1951 | % if isequal(str2num(nx_patch2),[]) |
---|
| 1952 | % nx_patch2='50' ;%default |
---|
| 1953 | % set(handles.nx_patch2,'String','50'); |
---|
| 1954 | % end |
---|
| 1955 | % if isequal(str2num(ny_patch2),[]) |
---|
| 1956 | % ny_patch2='50' ;%default |
---|
| 1957 | % set(handles.ny_patch2,'String','50'); |
---|
| 1958 | % end |
---|
| 1959 | % subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1960 | % icount=0; |
---|
| 1961 | % for ifile=1:nbfield |
---|
| 1962 | % for j=1:nbslice |
---|
| 1963 | % icount=icount+1; |
---|
| 1964 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1965 | % set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
| 1966 | % drawnow |
---|
| 1967 | % if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1968 | % cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1969 | % s=-1; |
---|
| 1970 | % if sge |
---|
| 1971 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1972 | % end |
---|
| 1973 | % if s~=0 |
---|
| 1974 | % display(['!' cmd]) |
---|
| 1975 | % eval(['!' cmd]); |
---|
| 1976 | % end |
---|
| 1977 | % elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 1978 | % if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1979 | % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
| 1980 | % nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1981 | % display(['!' cmd]) |
---|
| 1982 | % eval(['!' cmd]) |
---|
| 1983 | % else |
---|
| 1984 | % RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 1985 | % str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1986 | % end |
---|
| 1987 | % end |
---|
| 1988 | % if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1989 | % cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1990 | % s=-1; |
---|
| 1991 | % if sge |
---|
| 1992 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1993 | % end |
---|
| 1994 | % if s~=0 |
---|
| 1995 | % display(['!' cmd]) |
---|
| 1996 | % eval(['!' cmd]); |
---|
| 1997 | % end |
---|
| 1998 | % end |
---|
| 1999 | % end |
---|
| 2000 | % end |
---|
| 2001 | % end |
---|
| 2002 | % |
---|
| 2003 | % set(handles.RUN, 'Enable','On') |
---|
| 2004 | % set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2005 | % |
---|
| 2006 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 2007 | % if isfield(filecell,'st') |
---|
| 2008 | % fileresu=filecell.st{1,1}; |
---|
| 2009 | % elseif isfield(filecell,'nc') |
---|
| 2010 | % if isfield(filecell.nc,'civ2') |
---|
| 2011 | % fileresu=filecell.nc.civ2{1,1}; |
---|
| 2012 | % else |
---|
| 2013 | % fileresu=filecell.nc.civ1{1,1}; |
---|
| 2014 | % end |
---|
| 2015 | % end |
---|
| 2016 | % [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2017 | % namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2018 | % detect=1; |
---|
| 2019 | % while detect==1 |
---|
| 2020 | % namefigfull=[namedoc '.fig']; |
---|
| 2021 | % hh=dir(namefigfull); |
---|
| 2022 | % if ~isempty(hh) |
---|
| 2023 | % detect=1; |
---|
| 2024 | % namedoc=[namedoc '.0']; |
---|
| 2025 | % else |
---|
| 2026 | % detect=0; |
---|
| 2027 | % end |
---|
| 2028 | % end |
---|
| 2029 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
[2] | 2030 | |
---|
[67] | 2031 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 2032 | %------------------------------------------------------------------------ |
---|
| 2033 | % global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
[2] | 2034 | |
---|
[67] | 2035 | batch=0; |
---|
| 2036 | launch_jobs(hObject, eventdata, handles,batch); |
---|
[36] | 2037 | |
---|
[2] | 2038 | |
---|
[12] | 2039 | %------------------------------------------------------------------------ |
---|
[2] | 2040 | % --- Executes on button press in BATCH: remote processing |
---|
| 2041 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[12] | 2042 | %------------------------------------------------------------------------ |
---|
[67] | 2043 | %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove |
---|
| 2044 | batch=1; |
---|
| 2045 | launch_jobs(hObject, eventdata, handles, batch) |
---|
| 2046 | |
---|
| 2047 | %------------------------------------------------------------------------ |
---|
| 2048 | % --- Executes on button press in BATCH: remote processing |
---|
| 2049 | function launch_jobs(hObject, eventdata, handles, batch) |
---|
| 2050 | %----------------------------------------------------------------------- |
---|
| 2051 | % global civ2Bin patchBin patch_newBin fixBin CivBin % probabely to remove |
---|
| 2052 | |
---|
[2] | 2053 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 2054 | |
---|
| 2055 | %check the list of operations: |
---|
| 2056 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 2057 | run_flag=1; |
---|
| 2058 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 2059 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 2060 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 2061 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 2062 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 2063 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 2064 | index=find(box_test==1); |
---|
| 2065 | if isempty(index) |
---|
| 2066 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 2067 | return |
---|
| 2068 | end |
---|
| 2069 | index_first=min(index); |
---|
| 2070 | index_last=max(index); |
---|
| 2071 | box_used=box_test([index_first : index_last]); |
---|
| 2072 | [box_missing,ind_missing]=min(box_used); |
---|
| 2073 | if isequal(box_missing,0) |
---|
| 2074 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 2075 | return |
---|
| 2076 | end |
---|
| 2077 | |
---|
| 2078 | %root name |
---|
| 2079 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2080 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2081 | msgbox_uvmat('ERROR','no input files') |
---|
| 2082 | return |
---|
| 2083 | end |
---|
| 2084 | |
---|
| 2085 | %check mask if selecetd |
---|
| 2086 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 2087 | maskname=get(handles.mask_civ1,'String'); |
---|
| 2088 | if ~exist(maskname,'file') |
---|
| 2089 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 2090 | end |
---|
[2] | 2091 | end |
---|
| 2092 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 2093 | maskname=get(handles.mask_fix1,'String'); |
---|
| 2094 | if ~exist(maskname,'file') |
---|
| 2095 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 2096 | end |
---|
[2] | 2097 | end |
---|
| 2098 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 2099 | maskname=get(handles.mask_civ2,'String'); |
---|
| 2100 | if ~exist(maskname,'file') |
---|
[2] | 2101 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 2102 | end |
---|
[2] | 2103 | end |
---|
| 2104 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 2105 | maskname=get(handles.mask_fix2,'String'); |
---|
| 2106 | if ~exist(maskname,'file') |
---|
[2] | 2107 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 2108 | end |
---|
[2] | 2109 | end |
---|
| 2110 | |
---|
| 2111 | %read names of the .exe file |
---|
| 2112 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 2113 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[54] | 2114 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 2115 | if exist(xmlfile,'file') |
---|
| 2116 | t=xmltree(xmlfile); |
---|
[67] | 2117 | s=convert(t); |
---|
[2] | 2118 | end |
---|
[54] | 2119 | % else |
---|
| 2120 | % xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 2121 | % if exist(xmlfile,'file') |
---|
| 2122 | % t=xmltree(xmlfile); |
---|
| 2123 | % sparam=convert(t); |
---|
| 2124 | % end |
---|
| 2125 | % end |
---|
[67] | 2126 | % batch=0; |
---|
| 2127 | if batch |
---|
| 2128 | if isfield(s,'BatchParam') |
---|
| 2129 | sparam=s.BatchParam; |
---|
| 2130 | if ~ismember(sparam.BatchMode,{'sge'}) |
---|
| 2131 | msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT']) |
---|
| 2132 | end |
---|
| 2133 | else |
---|
| 2134 | msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml') |
---|
| 2135 | return |
---|
| 2136 | end |
---|
| 2137 | else |
---|
| 2138 | if isfield(s,'RunParam') |
---|
| 2139 | sparam=s.RunParam; |
---|
| 2140 | else |
---|
| 2141 | msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml') |
---|
| 2142 | return |
---|
| 2143 | end |
---|
[2] | 2144 | end |
---|
[67] | 2145 | if isfield(sparam,'CivBin') |
---|
| 2146 | CivBin=sparam.CivBin; |
---|
[2] | 2147 | end |
---|
[67] | 2148 | if isfield(sparam,'Civ1Bin') |
---|
| 2149 | civ1Bin=sparam.Civ1Bin; |
---|
[2] | 2150 | end |
---|
[67] | 2151 | if isfield(sparam,'Civ2Bin') |
---|
| 2152 | civ2Bin=sparam.Civ2Bin; |
---|
[2] | 2153 | end |
---|
[67] | 2154 | if isfield(sparam,'PatchBin') |
---|
| 2155 | patchBin=sparam.PatchBin; |
---|
| 2156 | end |
---|
| 2157 | if isfield(sparam,'PatchNewBin') |
---|
| 2158 | patch_newBin=sparam.PatchNewBin; |
---|
[2] | 2159 | end |
---|
[67] | 2160 | if isfield(sparam,'FixBin') |
---|
| 2161 | fixBin=sparam.FixBin; |
---|
[2] | 2162 | end |
---|
[67] | 2163 | % if isfield(sparam,'Todo_path') |
---|
| 2164 | % todo_path=sparam.Todo_path; |
---|
| 2165 | % end |
---|
| 2166 | if batch |
---|
| 2167 | if isfield(sparam,'BatchMode') |
---|
| 2168 | batch_mode=sparam.BatchMode; |
---|
[2] | 2169 | end |
---|
[67] | 2170 | else |
---|
| 2171 | MaxCivProcesses=50; |
---|
| 2172 | if isfield(sparam,'MaxCivProcesses') |
---|
| 2173 | MaxCivProcesses=str2double(sparam.MaxCivProcesses); |
---|
| 2174 | end |
---|
[2] | 2175 | end |
---|
| 2176 | |
---|
| 2177 | %initialize the waitbars |
---|
| 2178 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 2179 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 2180 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 2181 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 2182 | set(handles.BATCH, 'Enable','Off') |
---|
| 2183 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2184 | drawnow |
---|
| 2185 | %get the filename root, nomenclature and numbers |
---|
| 2186 | |
---|
| 2187 | % for Windows system find the UBC path name if needed |
---|
| 2188 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 2189 | cur_dir=pwd; |
---|
| 2190 | if ~isequal(cur_dir(2:3),':\') |
---|
| 2191 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 2192 | end |
---|
| 2193 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 2194 | if isequal(ss,0) |
---|
| 2195 | rankpath=findstr(ww,'\\'); |
---|
| 2196 | if ~isempty(rankpath) |
---|
| 2197 | wwrest=ww(rankpath:end); |
---|
| 2198 | rankend=min(find(double(wwrest)==10))-1; |
---|
| 2199 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 2200 | set(handles.displ_filebase,'String',filebase); |
---|
| 2201 | end |
---|
| 2202 | else |
---|
| 2203 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
| 2204 | set(handles.BATCH, 'Enable','On') |
---|
| 2205 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2206 | return |
---|
| 2207 | end |
---|
| 2208 | end |
---|
| 2209 | |
---|
| 2210 | % set the list of files and check them |
---|
| 2211 | display('checking the files...') |
---|
| 2212 | [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]=... |
---|
| 2213 | set_civ_filenames(handles,compare,box_test); |
---|
[67] | 2214 | |
---|
| 2215 | %choice of batch priority |
---|
| 2216 | ind_answer=2; |
---|
| 2217 | if batch |
---|
| 2218 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2219 | if isequal(s,0) |
---|
| 2220 | w(end)=[]; |
---|
| 2221 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 2222 | str={'urgent';'normal';'low'}; |
---|
| 2223 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2224 | 'SelectionMode','single',... |
---|
| 2225 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 2226 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 2227 | return % a better way should be create |
---|
| 2228 | end |
---|
| 2229 | else |
---|
| 2230 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 2231 | return |
---|
| 2232 | end |
---|
| 2233 | else |
---|
| 2234 | if isunix |
---|
| 2235 | [s,w]=unix('ps faux |grep civ|wc -l'); |
---|
| 2236 | w(end)=[]; |
---|
| 2237 | if str2num(w)+numel(filecell)> MaxCivProcesses |
---|
| 2238 | msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) |
---|
| 2239 | return |
---|
| 2240 | end |
---|
| 2241 | end |
---|
| 2242 | end |
---|
[41] | 2243 | |
---|
[2] | 2244 | display('files OK, processing...') |
---|
[41] | 2245 | nbfield=numel(num1_civ1); |
---|
| 2246 | nbslice=numel(num_a_civ1); |
---|
[2] | 2247 | |
---|
| 2248 | %GET PARAMETERS: |
---|
| 2249 | %get civ parameters |
---|
| 2250 | if box_test(1)==1 |
---|
| 2251 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
| 2252 | end |
---|
| 2253 | |
---|
| 2254 | %get fix1 parameters |
---|
| 2255 | if box_test(2)==1 |
---|
| 2256 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 2257 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 2258 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 2259 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 2260 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 2261 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2262 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 2263 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
| 2264 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 2265 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 2266 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 2267 | % fileref=fullfile(refpath,fileref); |
---|
| 2268 | menu=get(handles.field_ref1,'String'); |
---|
| 2269 | index=get(handles.field_ref1,'Value'); |
---|
| 2270 | if isempty(menu) |
---|
| 2271 | fieldchoice=''; |
---|
| 2272 | else |
---|
| 2273 | fieldchoice=menu{index}; |
---|
| 2274 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 2275 | end |
---|
| 2276 | end |
---|
| 2277 | |
---|
| 2278 | %get patch1 parameters |
---|
[67] | 2279 | if box_test(3)==1 |
---|
[2] | 2280 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 2281 | if isempty(rho_patch1) |
---|
| 2282 | rho_patch1='1000'; |
---|
| 2283 | set(handles.rho_patch1,'String','1') |
---|
| 2284 | else |
---|
| 2285 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 2286 | end |
---|
| 2287 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 2288 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 2289 | if isequal(str2num(nx_patch1),[]) |
---|
| 2290 | nx_patch1='50' ;%default |
---|
| 2291 | set(handles.nx_patch1,'String','50'); |
---|
| 2292 | end |
---|
| 2293 | if isequal(str2num(ny_patch1),[]) |
---|
| 2294 | ny_patch1='50' ;%default |
---|
| 2295 | set(handles.ny_patch1,'String','50'); |
---|
| 2296 | end |
---|
| 2297 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 2298 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 2299 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2300 | end |
---|
| 2301 | |
---|
| 2302 | %get civ2 parameters |
---|
| 2303 | if box_test(4)==1 |
---|
| 2304 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 2305 | end |
---|
| 2306 | |
---|
| 2307 | %get fix2 parameters |
---|
| 2308 | if box_test(5)==1 |
---|
| 2309 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 2310 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 2311 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
| 2312 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 2313 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 2314 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2315 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
| 2316 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 2317 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 2318 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 2319 | |
---|
| 2320 | %%%%%%%%%%%%%%%%%%% |
---|
| 2321 | end |
---|
| 2322 | |
---|
| 2323 | |
---|
| 2324 | %get patch2 parameters |
---|
| 2325 | if box_test(6)==1 |
---|
| 2326 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 2327 | if isempty(rho_patch2) |
---|
| 2328 | rho_patch2='1000'; |
---|
| 2329 | set(handles.rho_patch2,'String','1') |
---|
| 2330 | else |
---|
| 2331 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 2332 | end |
---|
| 2333 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 2334 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 2335 | if isequal(str2num(nx_patch2),[]) |
---|
| 2336 | nx_patch2='50' ;%default |
---|
| 2337 | set(handles.nx_patch2,'String','50'); |
---|
| 2338 | end |
---|
| 2339 | if isequal(str2num(ny_patch2),[]) |
---|
| 2340 | ny_patch2='50' ;%default |
---|
| 2341 | set(handles.ny_patch2,'String','50'); |
---|
| 2342 | end |
---|
| 2343 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 2344 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 2345 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2346 | end |
---|
| 2347 | |
---|
[67] | 2348 | % if ~sge |
---|
| 2349 | % |
---|
| 2350 | % %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
| 2351 | % name_lock=fullfile(todo_path,'lock'); %lock file |
---|
| 2352 | % iwait=0; |
---|
| 2353 | % while(exist(name_lock) & iwait<15) |
---|
| 2354 | % pause(1); %wait 1 second |
---|
| 2355 | % iwait=iwait+1; |
---|
| 2356 | % end |
---|
| 2357 | % if iwait==15 |
---|
| 2358 | % msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
| 2359 | % set(handles.BATCH, 'Enable','On') |
---|
| 2360 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2361 | % return |
---|
| 2362 | % end |
---|
| 2363 | % p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
| 2364 | % name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 2365 | % p1=fopen(name_todo,'a'); |
---|
| 2366 | % if (p1<0) |
---|
| 2367 | % msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
| 2368 | % set(handles.BATCH, 'Enable','On') |
---|
| 2369 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2370 | % return; |
---|
| 2371 | % end |
---|
| 2372 | % end |
---|
[2] | 2373 | |
---|
| 2374 | %MAIN LOOP |
---|
| 2375 | % for ifile=1:nbfield |
---|
| 2376 | p1text=[];%initiate command text |
---|
| 2377 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2378 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
| 2379 | for ifile=1:nbfield |
---|
| 2380 | for j=1:nbslice |
---|
| 2381 | i_cmd=0; |
---|
| 2382 | cmd=''; |
---|
[67] | 2383 | if batch |
---|
[12] | 2384 | %fid=fopen([filename '.cmx'],'w') |
---|
[2] | 2385 | cmd='#!/bin/bash'; |
---|
[12] | 2386 | cmd=[cmd '\n' '#$ -cwd']; |
---|
| 2387 | cmd=[cmd '\n' 'hostname && date']; |
---|
[2] | 2388 | end |
---|
| 2389 | if civAll |
---|
| 2390 | civAllxml=xmltree;% xml contents, all parameters |
---|
| 2391 | civAllCmd=[]; |
---|
| 2392 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 2393 | end |
---|
| 2394 | % filecell.nc.civ1 |
---|
[41] | 2395 | filename_cmx=filecell.nc.civ1{ifile,j}%output netcdf file |
---|
| 2396 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
[2] | 2397 | filename_cmx=[filename_cmx 'x']; |
---|
| 2398 | |
---|
| 2399 | %CIV1 |
---|
| 2400 | if box_test(1)==1 |
---|
[41] | 2401 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[2] | 2402 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
[41] | 2403 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 2404 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2405 | |
---|
| 2406 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2407 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 2408 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 2409 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 2410 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 2411 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 2412 | if test_mask==0 |
---|
| 2413 | par_civ1.maskname='noFile use default'; |
---|
| 2414 | par_civ1.maskflag='n'; |
---|
| 2415 | else |
---|
| 2416 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 2417 | if exist(maskdispl,'file') |
---|
| 2418 | par_civ1.maskname=maskdispl; |
---|
| 2419 | par_civ1.maskflag='y'; |
---|
[2] | 2420 | else |
---|
[12] | 2421 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2422 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2423 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2424 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2425 | if exist(par_civ1.maskname,'file') |
---|
| 2426 | par_civ1.maskflag='y'; |
---|
| 2427 | else |
---|
| 2428 | par_civ1.maskname='noFile use default'; |
---|
| 2429 | par_civ1.maskflag='n'; |
---|
| 2430 | end |
---|
[2] | 2431 | end |
---|
| 2432 | end |
---|
| 2433 | |
---|
| 2434 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 2435 | if test_grid |
---|
| 2436 | par_civ1.gridflag='y'; |
---|
| 2437 | gridname=get(handles.grid_civ1,'String'); |
---|
| 2438 | if isequal(gridname(end-3:end),'grid') |
---|
| 2439 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2440 | if ~isempty(nbslice_grid) |
---|
| 2441 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2442 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2443 | if ~exist(par_civ1.gridname,'file') |
---|
| 2444 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2445 | end |
---|
| 2446 | elseif exist(gridname,'file') |
---|
| 2447 | par_civ1.gridname=gridname; |
---|
| 2448 | else |
---|
| 2449 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2450 | end |
---|
| 2451 | end |
---|
| 2452 | else |
---|
| 2453 | par_civ1.gridname='noFile use default'; |
---|
| 2454 | par_civ1.gridflag='n'; |
---|
| 2455 | end |
---|
[54] | 2456 | % |
---|
[2] | 2457 | i_cmd=i_cmd+1; |
---|
| 2458 | if isequal(civAll,0) |
---|
[67] | 2459 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam)]; |
---|
[2] | 2460 | else |
---|
| 2461 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
| 2462 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
| 2463 | fieldnames=fields(str); |
---|
| 2464 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 2465 | for ilist=1:length(fieldnames) |
---|
| 2466 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2467 | if ischar(val) |
---|
| 2468 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 2469 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2470 | end |
---|
| 2471 | end |
---|
| 2472 | end |
---|
| 2473 | end |
---|
| 2474 | |
---|
| 2475 | % FIX1 |
---|
| 2476 | if box_test(2)==1 |
---|
| 2477 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2478 | if test_mask==0 |
---|
| 2479 | maskname=''; |
---|
| 2480 | else |
---|
| 2481 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 2482 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2483 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2484 | maskbase=[filebase '_' maskdispl]; |
---|
| 2485 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2486 | end |
---|
| 2487 | if isequal(civAll,0) |
---|
[67] | 2488 | cmd_FIX=[fixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
[2] | 2489 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 2490 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[12] | 2491 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2492 | else |
---|
| 2493 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2494 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 2495 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 2496 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 2497 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 2498 | fix1.threshV=num2str(thresh_vel1); |
---|
| 2499 | fieldnames=fields(fix1); |
---|
| 2500 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 2501 | for ilist=1:length(fieldnames) |
---|
| 2502 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 2503 | if ischar(val) |
---|
| 2504 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 2505 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2506 | end |
---|
| 2507 | end |
---|
| 2508 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 2509 | end |
---|
| 2510 | end |
---|
| 2511 | |
---|
| 2512 | %PATCH1 |
---|
| 2513 | if box_test(3)==1 |
---|
| 2514 | if isequal(civAll,0) |
---|
| 2515 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
[12] | 2516 | cmd=[cmd '\n' cmd_PATCH]; |
---|
[2] | 2517 | else |
---|
| 2518 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2519 | patch1.nopt=subdomain_patch1; |
---|
| 2520 | patch1.maxdiff=thresh_patch1; |
---|
| 2521 | patch1.ro=rho_patch1; |
---|
| 2522 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 2523 | if test_grid |
---|
| 2524 | patch1.gridflag='y'; |
---|
| 2525 | gridname=get(handles.grid_patch1,'String'); |
---|
| 2526 | if isequal(gridname(end-3:end),'grid') |
---|
| 2527 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2528 | if ~isempty(nbslice_grid) |
---|
| 2529 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2530 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2531 | if ~exist(patch1.gridPatch,'file') |
---|
| 2532 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2533 | end |
---|
| 2534 | elseif exist(gridname,'file') |
---|
| 2535 | patch1.gridPatch=gridname; |
---|
| 2536 | else |
---|
| 2537 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2538 | end |
---|
| 2539 | end |
---|
| 2540 | else |
---|
| 2541 | patch1.gridPatch='n'; |
---|
| 2542 | patch1.gridflag='n'; |
---|
| 2543 | patch1.m=nx_patch1; |
---|
| 2544 | patch1.n=ny_patch1; |
---|
| 2545 | end |
---|
| 2546 | patch1.convectFlow='n'; |
---|
| 2547 | fieldnames=fields(patch1); |
---|
| 2548 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2549 | for ilist=1:length(fieldnames) |
---|
| 2550 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2551 | if ischar(val) |
---|
| 2552 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2553 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2554 | end |
---|
| 2555 | end |
---|
| 2556 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2557 | end |
---|
| 2558 | end |
---|
| 2559 | |
---|
| 2560 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
| 2561 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
| 2562 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 2563 | filename_cmx=[filename_cmx 'x']; |
---|
| 2564 | end |
---|
| 2565 | |
---|
| 2566 | if box_test(4)==1 |
---|
| 2567 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2568 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2569 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2570 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2571 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2572 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 2573 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 2574 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 2575 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 2576 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2577 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2578 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 2579 | if test_mask==0 |
---|
| 2580 | par_civ2.maskname='noFile use default'; |
---|
| 2581 | par_civ2.maskflag='n'; |
---|
| 2582 | else |
---|
| 2583 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2584 | if exist(maskdispl,'file') |
---|
| 2585 | par_civ2.maskname=maskdispl; |
---|
| 2586 | par_civ2.maskflag='y'; |
---|
[2] | 2587 | else |
---|
[12] | 2588 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2589 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2590 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2591 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2592 | if exist(par_civ2.maskname,'file') |
---|
| 2593 | par_civ2.maskflag='y'; |
---|
| 2594 | else |
---|
| 2595 | par_civ2.maskname='noFile use default'; |
---|
| 2596 | par_civ2.maskflag='n'; |
---|
| 2597 | end |
---|
[2] | 2598 | end |
---|
| 2599 | end |
---|
| 2600 | %TESTgrid |
---|
| 2601 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 2602 | gridname=get(handles.grid_civ2,'String'); |
---|
| 2603 | gridflag='y'; |
---|
| 2604 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
| 2605 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2606 | if ~isempty(nbslice_grid) |
---|
| 2607 | par_civ2.gridflag='y'; |
---|
| 2608 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2609 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2610 | if exist(par_civ2.gridname,'file') |
---|
| 2611 | par_civ2.gridflag='y'; |
---|
| 2612 | else |
---|
| 2613 | par_civ2.gridname='noFile use default'; |
---|
| 2614 | par_civ2.gridflag='n'; |
---|
| 2615 | end |
---|
| 2616 | elseif exist(gridname,'file') |
---|
| 2617 | par_civ2.gridflag='y'; |
---|
| 2618 | else |
---|
| 2619 | par_civ2.gridname='noFile use default'; |
---|
| 2620 | par_civ2.gridflag='n'; |
---|
| 2621 | end |
---|
| 2622 | end |
---|
| 2623 | %endTESTgrid |
---|
| 2624 | i_cmd=i_cmd+1; |
---|
[67] | 2625 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2,sparam); |
---|
[2] | 2626 | if isequal(civAll,0) |
---|
| 2627 | if(isunix) |
---|
[12] | 2628 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2629 | else |
---|
[12] | 2630 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2631 | end |
---|
| 2632 | else |
---|
| 2633 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
[67] | 2634 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2,sparam); |
---|
[2] | 2635 | fieldnames=fields(str); |
---|
| 2636 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2637 | for ilist=1:length(fieldnames) |
---|
| 2638 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2639 | if ischar(val) |
---|
| 2640 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2641 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2642 | end |
---|
| 2643 | end |
---|
| 2644 | end |
---|
| 2645 | end |
---|
| 2646 | |
---|
| 2647 | % FIX2 |
---|
[12] | 2648 | if box_test(5)==1 |
---|
[2] | 2649 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2650 | if test_mask==0 |
---|
| 2651 | maskname=''; %no mask used |
---|
| 2652 | else |
---|
| 2653 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 2654 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2655 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2656 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2657 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2658 | end |
---|
| 2659 | if isequal(civAll,0) |
---|
[67] | 2660 | cmd_FIX=[fixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[2] | 2661 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2662 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[12] | 2663 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2664 | else |
---|
| 2665 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2666 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2667 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2668 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2669 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2670 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2671 | fieldnames=fields(fix2); |
---|
| 2672 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2673 | for ilist=1:length(fieldnames) |
---|
| 2674 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2675 | if ischar(val) |
---|
| 2676 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2677 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2678 | end |
---|
| 2679 | end |
---|
| 2680 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2681 | end |
---|
| 2682 | end |
---|
| 2683 | |
---|
| 2684 | %PATCH2 |
---|
[12] | 2685 | if box_test(6)==1 |
---|
| 2686 | if isequal(civAll,0) |
---|
| 2687 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
| 2688 | cmd=[cmd '\n' cmd_PATCH]; |
---|
| 2689 | else |
---|
| 2690 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2691 | patch2.nopt=subdomain_patch1; |
---|
| 2692 | patch2.maxdiff=thresh_patch1; |
---|
| 2693 | patch2.ro=rho_patch1; |
---|
| 2694 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2695 | if test_grid |
---|
| 2696 | patch2.gridflag='y'; |
---|
| 2697 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2698 | if isequal(gridname(end-3:end),'grid') |
---|
| 2699 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2700 | if ~isempty(nbslice_grid) |
---|
| 2701 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2702 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2703 | if ~exist(patch2.gridPatch,'file') |
---|
| 2704 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2705 | end |
---|
| 2706 | elseif exist(gridname,'file') |
---|
| 2707 | patch2.gridPatch=gridname; |
---|
| 2708 | else |
---|
| 2709 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2710 | end |
---|
| 2711 | end |
---|
[12] | 2712 | else |
---|
| 2713 | patch2.gridPatch='n'; |
---|
| 2714 | patch2.gridflag='n'; |
---|
| 2715 | patch2.m=nx_patch2; |
---|
| 2716 | patch2.n=ny_patch2; |
---|
[2] | 2717 | end |
---|
[12] | 2718 | patch2.convectFlow='n'; |
---|
| 2719 | fieldnames=fields(patch2); |
---|
| 2720 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2721 | for ilist=1:length(fieldnames) |
---|
| 2722 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2723 | if ischar(val) |
---|
| 2724 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2725 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2726 | end |
---|
| 2727 | end |
---|
| 2728 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
| 2729 | end |
---|
| 2730 | end |
---|
| 2731 | if isequal(civAll,1) |
---|
| 2732 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
[67] | 2733 | cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
[12] | 2734 | end |
---|
| 2735 | % create the .bat file: |
---|
[67] | 2736 | if batch |
---|
[12] | 2737 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2738 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
| 2739 | else |
---|
| 2740 | filename_bat=filename_cmx; |
---|
| 2741 | end |
---|
| 2742 | filename_bat(end-2:end)='bat'; |
---|
| 2743 | fid=fopen(filename_bat,'w'); |
---|
[39] | 2744 | fprintf(fid,cmd); |
---|
| 2745 | fclose(fid); |
---|
[12] | 2746 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
[67] | 2747 | if batch |
---|
| 2748 | switch batch_mode |
---|
| 2749 | case 'sge' |
---|
| 2750 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2751 | namelog=[filename_bat '.patch.log']; |
---|
| 2752 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
| 2753 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2754 | end |
---|
| 2755 | |
---|
| 2756 | |
---|
| 2757 | |
---|
[12] | 2758 | else |
---|
[67] | 2759 | %% to lauch the jobs locally : |
---|
[12] | 2760 | if(isunix) |
---|
[67] | 2761 | eval(['!. ' filename_bat ' &']); |
---|
[2] | 2762 | else |
---|
[67] | 2763 | eval(['!' filename_bat ' &']); |
---|
[2] | 2764 | end |
---|
[67] | 2765 | % if(isunix) |
---|
| 2766 | % cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
| 2767 | % else |
---|
| 2768 | % cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
| 2769 | % end |
---|
| 2770 | % count= fprintf(p1,'%s\n', cmdtodo); |
---|
[12] | 2771 | end |
---|
[2] | 2772 | end |
---|
| 2773 | end |
---|
[67] | 2774 | % if ~sge |
---|
| 2775 | % fclose(p1); |
---|
| 2776 | % fclose(p0); |
---|
| 2777 | % delete(name_lock); |
---|
| 2778 | % end |
---|
[2] | 2779 | |
---|
| 2780 | set(handles.BATCH, 'Enable','On') |
---|
| 2781 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2782 | |
---|
| 2783 | %save interface state |
---|
| 2784 | if isfield(filecell,'nc') |
---|
| 2785 | if isfield(filecell.nc,'civ2') |
---|
| 2786 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2787 | else |
---|
| 2788 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2789 | end |
---|
| 2790 | end |
---|
| 2791 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2792 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2793 | detect=1; |
---|
| 2794 | while detect==1 |
---|
| 2795 | namefigfull=[namedoc '.fig']; |
---|
| 2796 | hh=dir(namefigfull); |
---|
| 2797 | if ~isempty(hh) |
---|
| 2798 | detect=1; |
---|
| 2799 | namedoc=[namedoc '.0']; |
---|
| 2800 | else |
---|
| 2801 | detect=0; |
---|
| 2802 | end |
---|
| 2803 | end |
---|
| 2804 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2805 | |
---|
[12] | 2806 | %------------------------------------------------------------------------ |
---|
[2] | 2807 | %OUTPUT: |
---|
| 2808 | % filecell: structure of input and output files |
---|
| 2809 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
| 2810 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
| 2811 | % .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) |
---|
| 2812 | % .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) |
---|
| 2813 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
| 2814 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
| 2815 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
[41] | 2816 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
| 2817 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
| 2818 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
| 2819 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
| 2820 | % nom_type_nc: nomenclature type for velocity files |
---|
| 2821 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
[2] | 2822 | 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]=... |
---|
| 2823 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2824 | %------------------------------------------------------------------------ |
---|
[2] | 2825 | %get the filename root, nomenclature and numbers |
---|
| 2826 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2827 | browse=get(handles.browse_root,'UserData'); |
---|
| 2828 | compare_list=get(handles.compare,'String'); |
---|
| 2829 | val=get(handles.compare,'Value'); |
---|
| 2830 | compare=compare_list{val}; |
---|
| 2831 | if strcmp(compare,'displacement') |
---|
| 2832 | mode='displacement'; |
---|
| 2833 | else |
---|
| 2834 | mode_list=get(handles.mode,'String'); |
---|
| 2835 | mode_value=get(handles.mode,'Value'); |
---|
| 2836 | mode=mode_list{mode_value}; |
---|
| 2837 | end |
---|
| 2838 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2839 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 2840 | nom_type_nc=browse.nom_type_nc; |
---|
| 2841 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2842 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 2843 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 2844 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2845 | find_pair_indices(handles,mode); |
---|
| 2846 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2847 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2848 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
| 2849 | test_disp=1; |
---|
| 2850 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2851 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2852 | Path1=Path2; |
---|
| 2853 | Name1=get(handles.displ_filebase2,'String');% root name of the first field series for stereo |
---|
| 2854 | filebase_A=fullfile(Path1,Name1); |
---|
| 2855 | if length(Name1)>6 |
---|
| 2856 | Name1=Name1(end-5:end); |
---|
| 2857 | end |
---|
| 2858 | if length(Name2)>6 |
---|
| 2859 | Name2=Name2(end-5:end); |
---|
| 2860 | end |
---|
| 2861 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2862 | else |
---|
| 2863 | test_disp=0; |
---|
| 2864 | filebase_A=filebase; |
---|
| 2865 | nom_type_ima1=nom_type_ima2; |
---|
| 2866 | filebase_AB=filebase; |
---|
| 2867 | end |
---|
| 2868 | if strcmp(compare,'displacement') |
---|
| 2869 | filebase_ima1=filebase_A; |
---|
| 2870 | filebase_ima2=filebase_B; |
---|
| 2871 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
| 2872 | else |
---|
| 2873 | filebase_ima1=filebase_B; |
---|
| 2874 | filebase_ima2=filebase_B; |
---|
| 2875 | filebase_nc=filebase_B; |
---|
| 2876 | end |
---|
| 2877 | |
---|
| 2878 | %determine reference files for fix: |
---|
| 2879 | file_ref_fix1={};%default |
---|
| 2880 | file_ref_fix2={}; |
---|
| 2881 | nbfield=length(num1_civ1); |
---|
| 2882 | nbslice=length(num_a_civ1); |
---|
| 2883 | if box_test(2)==1% fix1 performed |
---|
| 2884 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2885 | if ~isempty(ref) |
---|
| 2886 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2887 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2888 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2889 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2890 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2891 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2892 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2893 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2894 | if isequal(mode,'displacement') |
---|
| 2895 | num_i1=num_i_ref; |
---|
| 2896 | num_i2=num_i_ref; |
---|
| 2897 | num_j1=num_j_ref; |
---|
| 2898 | num_j2=num_j_ref; |
---|
| 2899 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2900 | num_i1=num_i_ref; |
---|
| 2901 | num_i2=num_i1; |
---|
| 2902 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2903 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2904 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2905 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2906 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2907 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2908 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2909 | if isempty(ref.num_a) |
---|
| 2910 | ref.num_a=1; |
---|
| 2911 | end |
---|
| 2912 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2913 | num_j2=num_j1; |
---|
| 2914 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2915 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2916 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2917 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2918 | num_i2=num_i1; |
---|
| 2919 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2920 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2921 | end |
---|
| 2922 | for ifile=1:nbfield |
---|
| 2923 | for j=1:nbslice |
---|
| 2924 | 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);% |
---|
| 2925 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2926 | if ~exist(file_ref,'file') |
---|
| 2927 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2928 | filecell=[]; |
---|
[2] | 2929 | return |
---|
| 2930 | end |
---|
| 2931 | end |
---|
| 2932 | end |
---|
| 2933 | end |
---|
| 2934 | end |
---|
| 2935 | |
---|
| 2936 | %determine reference files for fix2: |
---|
| 2937 | if box_test(5)==1% fix2 performed |
---|
| 2938 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2939 | if ~isempty(ref) |
---|
| 2940 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2941 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2942 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2943 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2944 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2945 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2946 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2947 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2948 | if isequal(mode,'displacement') |
---|
| 2949 | num_i1=num_i_ref; |
---|
| 2950 | num_i2=num_i_ref; |
---|
| 2951 | num_j1=num_j_ref; |
---|
| 2952 | num_j2=num_j_ref; |
---|
| 2953 | elseif isequal(mode,'pair j1-j2') |
---|
| 2954 | num_i1=num_i_ref; |
---|
| 2955 | num_i2=num_i1; |
---|
| 2956 | num_j1=ref.num_a; |
---|
| 2957 | num_j2=ref.num_b; |
---|
| 2958 | elseif isequal(mode,'series(Di)') |
---|
| 2959 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2960 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2961 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2962 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2963 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2964 | num_j2=num_j1; |
---|
| 2965 | elseif isequal(mode,'series(Dj)') |
---|
| 2966 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2967 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2968 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2969 | num_i2=num_i1; |
---|
| 2970 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2971 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2972 | end |
---|
| 2973 | for ifile=1:nbfield |
---|
| 2974 | for j=1:nbslice |
---|
| 2975 | 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);% |
---|
| 2976 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2977 | if ~exist(file_ref,'file') |
---|
| 2978 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[12] | 2979 | filecell=[]; |
---|
[2] | 2980 | return |
---|
| 2981 | end |
---|
| 2982 | end |
---|
| 2983 | end |
---|
| 2984 | end |
---|
| 2985 | end |
---|
| 2986 | |
---|
| 2987 | %check dir |
---|
| 2988 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2989 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2990 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2991 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 2992 | currentdir=pwd;%store the current working directory |
---|
| 2993 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2994 | if ~exist(Path_ima,'dir') |
---|
[12] | 2995 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
| 2996 | filecell=[]; |
---|
[2] | 2997 | return |
---|
| 2998 | end |
---|
| 2999 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
| 3000 | dircur=pwd; %current working directory |
---|
| 3001 | m2=''; |
---|
| 3002 | [erread,message]=fileattrib(Path_ima); |
---|
| 3003 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 3004 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[12] | 3005 | filecell=[]; |
---|
[2] | 3006 | cd(currentdir); |
---|
| 3007 | return |
---|
| 3008 | end |
---|
| 3009 | |
---|
| 3010 | %check the existence of the netcdf and image files involved |
---|
| 3011 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 3012 | if box_test(1)==1; |
---|
| 3013 | detect=1; |
---|
| 3014 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3015 | for ifile=1:nbfield; |
---|
| 3016 | for j=1:nbslice |
---|
| 3017 | 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); |
---|
| 3018 | detect=exist(filename,'file')==2; |
---|
| 3019 | if detect% if a netcdf file already exists |
---|
| 3020 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 3021 | subdir_civ2=subdir_civ1; |
---|
| 3022 | break |
---|
| 3023 | end |
---|
| 3024 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3025 | end |
---|
| 3026 | if detect% if a netcdf file already exists |
---|
| 3027 | break |
---|
| 3028 | end |
---|
| 3029 | end |
---|
| 3030 | %create the new subdir_civ1 |
---|
| 3031 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 3032 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 3033 | if ~isequal(m2,'') |
---|
| 3034 | msgbox_uvmat('ERROR', m2) |
---|
| 3035 | %msgbox(m2);%error message for directory creation |
---|
| 3036 | end |
---|
| 3037 | end |
---|
| 3038 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 3039 | for ifile=1:nbfield |
---|
| 3040 | for j=1:nbslice |
---|
| 3041 | 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);% |
---|
| 3042 | detect=exist(filename,'file')==2; |
---|
| 3043 | if detect% if a netcdf file already exists |
---|
| 3044 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 3045 | subdir_civ2=subdir_civ1; |
---|
| 3046 | break |
---|
| 3047 | end |
---|
| 3048 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3049 | end |
---|
| 3050 | if detect% if a netcdf file already exists |
---|
| 3051 | break |
---|
| 3052 | end |
---|
| 3053 | end |
---|
| 3054 | %create the new subdir_civ1 |
---|
| 3055 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 3056 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 3057 | if ~isequal(m2,'') |
---|
| 3058 | msgbox_uvmat('ERROR', m2) |
---|
| 3059 | end |
---|
| 3060 | end |
---|
| 3061 | end |
---|
| 3062 | end |
---|
| 3063 | % get image names |
---|
| 3064 | for ifile=1:nbfield |
---|
| 3065 | for j=1:nbslice |
---|
| 3066 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3067 | idetect(j)=exist(filename,'file')==2; |
---|
| 3068 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 3069 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3070 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3071 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
| 3072 | end |
---|
| 3073 | [idetectmin,indexj]=min(idetect); |
---|
| 3074 | if idetectmin==0, |
---|
| 3075 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3076 | filecell=[]; |
---|
[2] | 3077 | return |
---|
| 3078 | end |
---|
| 3079 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3080 | if idetectmin==0, |
---|
| 3081 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3082 | filecell=[]; |
---|
[2] | 3083 | cd(currentdir) |
---|
| 3084 | return |
---|
| 3085 | end |
---|
| 3086 | end |
---|
| 3087 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 3088 | for ifile=1:nbfield |
---|
| 3089 | for j=1:nbslice |
---|
| 3090 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3091 | idetect(j)=exist(filename,'file')==2; |
---|
| 3092 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 3093 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3094 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3095 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 3096 | end |
---|
| 3097 | [idetectmin,indexj]=min(idetect); |
---|
| 3098 | if idetectmin==0, |
---|
| 3099 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3100 | filecell=[]; |
---|
| 3101 | cd(currentdir) |
---|
| 3102 | return |
---|
[2] | 3103 | end |
---|
| 3104 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3105 | if idetectmin==0, |
---|
[12] | 3106 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
| 3107 | filecell=[]; |
---|
| 3108 | cd(currentdir) |
---|
| 3109 | return |
---|
[2] | 3110 | end |
---|
| 3111 | end |
---|
| 3112 | end |
---|
| 3113 | |
---|
| 3114 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 3115 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
| 3116 | for ifile=1:nbfield |
---|
| 3117 | for j=1:nbslice |
---|
| 3118 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3119 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3120 | detect=exist(filename,'file')==2; |
---|
| 3121 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3122 | end |
---|
| 3123 | end |
---|
| 3124 | if strcmp(compare,'stereo PIV') |
---|
| 3125 | for ifile=1:nbfield |
---|
| 3126 | for j=1:nbslice |
---|
| 3127 | 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);% |
---|
| 3128 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3129 | if ~exist(filename,'file') |
---|
| 3130 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3131 | set(handles.RUN, 'Enable','On') |
---|
| 3132 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3133 | set(handles.BATCH, 'Enable','On') |
---|
| 3134 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[12] | 3135 | filecell=[]; |
---|
[2] | 3136 | cd(currentdir) |
---|
| 3137 | return |
---|
| 3138 | end |
---|
| 3139 | end |
---|
| 3140 | end |
---|
| 3141 | end |
---|
| 3142 | end |
---|
| 3143 | |
---|
| 3144 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 3145 | testdiff=0; |
---|
| 3146 | if (box_test(4)==1)&&... |
---|
| 3147 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
| 3148 | testdiff=1; |
---|
| 3149 | detect=1; |
---|
| 3150 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3151 | for ifile=1:nbfield |
---|
| 3152 | for j=1:nbslice |
---|
| 3153 | 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);% |
---|
| 3154 | detect=exist(filename,'file')==2; |
---|
| 3155 | if detect% if a netcdf file already exists |
---|
| 3156 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3157 | break |
---|
| 3158 | end |
---|
| 3159 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3160 | end |
---|
| 3161 | if detect% if a netcdf file already exists |
---|
| 3162 | break |
---|
| 3163 | end |
---|
| 3164 | end |
---|
| 3165 | %create the new subdir_civ2 |
---|
| 3166 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3167 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3168 | if ~isequal(m2,'') |
---|
| 3169 | msgbox_uvmat('ERROR', m2) |
---|
| 3170 | end |
---|
| 3171 | end |
---|
| 3172 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 3173 | for ifile=1:nbfield |
---|
| 3174 | for j=1:nbslice |
---|
| 3175 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3176 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
| 3177 | detect=exist(filename,'file')==2; |
---|
| 3178 | if detect% if a netcdf file already exists |
---|
| 3179 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3180 | break |
---|
| 3181 | end |
---|
| 3182 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3183 | end |
---|
| 3184 | if detect% if a netcdf file already exists |
---|
| 3185 | break |
---|
| 3186 | end |
---|
| 3187 | end |
---|
| 3188 | %create the new subdir_civ1 |
---|
| 3189 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3190 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3191 | if ~isequal(m2,'') |
---|
| 3192 | msgbox_uvmat('ERROR', m2) |
---|
| 3193 | %msgbox(m2);%error message for directory creation |
---|
| 3194 | end |
---|
| 3195 | end |
---|
| 3196 | end |
---|
| 3197 | end |
---|
| 3198 | end |
---|
| 3199 | cd(currentdir);%come back to the current working directory |
---|
| 3200 | |
---|
| 3201 | |
---|
| 3202 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 3203 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 3204 | %check source netcdf file of civ1 estimates |
---|
| 3205 | if box_test(1)==0; %no civ1 performed |
---|
| 3206 | for ifile=1:nbfield |
---|
| 3207 | for j=1:nbslice |
---|
| 3208 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3209 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3210 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 3211 | if ~exist(filename,'file') |
---|
| 3212 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3213 | filecell=[]; |
---|
[2] | 3214 | return |
---|
| 3215 | end |
---|
| 3216 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 3217 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 3218 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3219 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3220 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3221 | filecell=[]; |
---|
[2] | 3222 | return |
---|
| 3223 | end |
---|
| 3224 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 3225 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 3226 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 3227 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 3228 | filecell=[]; |
---|
[2] | 3229 | return |
---|
| 3230 | end |
---|
| 3231 | end |
---|
| 3232 | end |
---|
| 3233 | end |
---|
| 3234 | end |
---|
| 3235 | if strcmp(compare,'stereo PIV') |
---|
| 3236 | for ifile=1:nbfield |
---|
| 3237 | for j=1:nbslice |
---|
| 3238 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3239 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3240 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3241 | if ~exist(filename,'file') |
---|
| 3242 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3243 | set(handles.RUN, 'Enable','On') |
---|
| 3244 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3245 | set(handles.BATCH, 'Enable','On') |
---|
| 3246 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 3247 | cd(currentdir) |
---|
| 3248 | return |
---|
| 3249 | end |
---|
| 3250 | end |
---|
| 3251 | end |
---|
| 3252 | end |
---|
| 3253 | end |
---|
| 3254 | |
---|
| 3255 | detect=1; |
---|
| 3256 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 3257 | for ifile=1:nbfield |
---|
| 3258 | for j=1:nbslice |
---|
| 3259 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3260 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
| 3261 | detect=exist(filename,'file')==2; |
---|
| 3262 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3263 | end |
---|
| 3264 | end |
---|
| 3265 | %get first image names for civ2 |
---|
| 3266 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 3267 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 3268 | elseif box_test(4)==1 |
---|
| 3269 | for ifile=1:nbfield |
---|
| 3270 | for j=1:nbslice |
---|
| 3271 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 3272 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 3273 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 3274 | end |
---|
| 3275 | [idetectmin,indexj]=min(idetect_2); |
---|
| 3276 | if idetectmin==0, |
---|
| 3277 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3278 | filecell=[]; |
---|
[2] | 3279 | return |
---|
| 3280 | end |
---|
| 3281 | end |
---|
| 3282 | end |
---|
| 3283 | |
---|
| 3284 | %get second image names for civ2 |
---|
| 3285 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 3286 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 3287 | elseif box_test(4)==1 |
---|
| 3288 | for ifile=1:nbfield |
---|
| 3289 | for j=1:nbslice |
---|
| 3290 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 3291 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 3292 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 3293 | end |
---|
| 3294 | [idetectmin,indexj]=min(idetect_3); |
---|
| 3295 | if idetectmin==0, |
---|
| 3296 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3297 | filecell=[]; |
---|
[2] | 3298 | return |
---|
| 3299 | end |
---|
| 3300 | end |
---|
| 3301 | end |
---|
| 3302 | end |
---|
| 3303 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 3304 | if ~testdiff |
---|
| 3305 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
| 3306 | else % check the civ2 files |
---|
| 3307 | for ifile=1:nbfield |
---|
| 3308 | for j=1:nbslice |
---|
| 3309 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3310 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3311 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3312 | if ~exist(filename,'file') |
---|
| 3313 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3314 | filecell=[]; |
---|
[2] | 3315 | return |
---|
| 3316 | else |
---|
| 3317 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3318 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3319 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3320 | filecell=[]; |
---|
[2] | 3321 | return |
---|
| 3322 | end |
---|
| 3323 | end |
---|
| 3324 | end |
---|
| 3325 | end |
---|
| 3326 | end |
---|
| 3327 | end |
---|
| 3328 | |
---|
| 3329 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 3330 | if strcmp(compare,'stereo PIV') |
---|
| 3331 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 3332 | for ifile=1:nbfield |
---|
| 3333 | for j=1:nbslice |
---|
| 3334 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3335 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3336 | filecell.st(ifile,j)={filename}; |
---|
| 3337 | end |
---|
| 3338 | end |
---|
| 3339 | end |
---|
| 3340 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 3341 | for ifile=1:nbfield |
---|
| 3342 | for j=1:nbslice |
---|
| 3343 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3344 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3345 | filecell.st(ifile,j)={filename}; |
---|
| 3346 | end |
---|
| 3347 | end |
---|
| 3348 | end |
---|
| 3349 | end |
---|
| 3350 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3351 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3352 | browse.nom_type_nc=nom_type_nc; |
---|
| 3353 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 3354 | |
---|
| 3355 | |
---|
| 3356 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 3357 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 3358 | nom_type_imanew1='_i'; |
---|
[2] | 3359 | else |
---|
| 3360 | nom_type_imanew1=nom_type_ima1; |
---|
| 3361 | end |
---|
[45] | 3362 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 3363 | nom_type_imanew2='_i'; |
---|
[2] | 3364 | else |
---|
| 3365 | nom_type_imanew2=nom_type_ima2; |
---|
| 3366 | end |
---|
| 3367 | if ~isequal(ext_ima,'.png') |
---|
[45] | 3368 | %%type of image file |
---|
| 3369 | type_ima1='none';%default |
---|
| 3370 | movieobject1=[];%default |
---|
| 3371 | if isequal(lower(ext_ima),'.avi') |
---|
| 3372 | hhh=which('mmreader'); |
---|
| 3373 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3374 | type_ima1='movie'; |
---|
| 3375 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 3376 | else |
---|
| 3377 | type_ima1='avi'; |
---|
| 3378 | end |
---|
| 3379 | else |
---|
| 3380 | form=imformats(ext_ima(2:end)); |
---|
| 3381 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3382 | if isequal(nom_type_ima1,'*'); |
---|
| 3383 | type_ima1='multimage';%image series in a single image file |
---|
| 3384 | else |
---|
| 3385 | type_ima1='image'; |
---|
| 3386 | end |
---|
| 3387 | end |
---|
| 3388 | end |
---|
| 3389 | type_ima2='none';%default |
---|
| 3390 | movieobject2=[]; |
---|
| 3391 | if isequal(lower(ext_ima),'.avi') |
---|
| 3392 | hhh=which('mmreader'); |
---|
| 3393 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3394 | type_ima2='movie'; |
---|
| 3395 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 3396 | else |
---|
| 3397 | type_ima2='avi'; |
---|
| 3398 | end |
---|
| 3399 | else |
---|
| 3400 | form=imformats(ext_ima(2:end)); |
---|
| 3401 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3402 | if isequal(nom_type_ima1,'*'); |
---|
| 3403 | type_ima2='multimage';%image series in a single image file |
---|
| 3404 | else |
---|
| 3405 | type_ima2='image'; |
---|
| 3406 | end |
---|
| 3407 | end |
---|
| 3408 | end |
---|
[2] | 3409 | %npxy=get(handles.ext_ima,'UserData'); |
---|
| 3410 | % % if numel(npxy)<2 |
---|
| 3411 | % |
---|
| 3412 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1); |
---|
| 3413 | % A=imread(filename); |
---|
| 3414 | % npxy=size(A); |
---|
| 3415 | % % end |
---|
| 3416 | % npy=npxy(1); |
---|
| 3417 | % npx=npxy(2); |
---|
| 3418 | if box_test(1)==1 %if civ1 is performed |
---|
| 3419 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 3420 | for ifile=1:nbfield |
---|
| 3421 | waitbar(ifile/nbfield); |
---|
| 3422 | for j=1:nbslice |
---|
| 3423 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3424 | if ~exist(filename,'file') |
---|
[45] | 3425 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
[2] | 3426 | imwrite(A,filename,'BitDepth',16); |
---|
| 3427 | end |
---|
| 3428 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3429 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3430 | if ~exist(filename,'file') |
---|
[45] | 3431 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
[2] | 3432 | imwrite(A,filename,'BitDepth',16); |
---|
| 3433 | end |
---|
| 3434 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
| 3435 | end |
---|
| 3436 | end |
---|
| 3437 | close(h) |
---|
| 3438 | end |
---|
| 3439 | if box_test(4)==1 %if civ2 is performed |
---|
| 3440 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
| 3441 | for ifile=1:nbfield |
---|
| 3442 | waitbar(ifile/nbfield); |
---|
| 3443 | for j=1:nbslice |
---|
| 3444 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3445 | if ~exist(filename,'file') |
---|
| 3446 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
| 3447 | imwrite(A,filename,'BitDepth',16); |
---|
| 3448 | end |
---|
| 3449 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3450 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3451 | if ~exist(filename,'file') |
---|
| 3452 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
| 3453 | imwrite(A,filename,'BitDepth',16); |
---|
| 3454 | end |
---|
| 3455 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
| 3456 | end |
---|
| 3457 | end |
---|
| 3458 | close(h); |
---|
| 3459 | end |
---|
| 3460 | end |
---|
| 3461 | |
---|
[12] | 3462 | %------------------------------------------------------------------------ |
---|
[2] | 3463 | %CIV1 CIV1 CIV1 CIV1 |
---|
| 3464 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3465 | %------------------------------------------------------------------------ |
---|
[2] | 3466 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 3467 | global civ1Bin sge%name of the executable for civ1 calculation |
---|
[2] | 3468 | |
---|
| 3469 | %get civ parameters |
---|
| 3470 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 3471 | if isempty(ibx_val) |
---|
| 3472 | ibx='21'; set(handles.ibx,'String','21') |
---|
| 3473 | else |
---|
| 3474 | ibx=num2str(ibx_val); |
---|
| 3475 | end |
---|
| 3476 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 3477 | if isempty(iby_val) |
---|
| 3478 | iby='21'; set(handles.iby,'String','21') |
---|
| 3479 | else |
---|
| 3480 | iby=num2str(iby_val); |
---|
| 3481 | end |
---|
| 3482 | isx=get(handles.isx,'String'); |
---|
| 3483 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3484 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 3485 | isy=get(handles.isy,'String'); |
---|
| 3486 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3487 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 3488 | shiftx=get(handles.shiftx,'String'); |
---|
| 3489 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
| 3490 | shifty=get(handles.shifty,'String'); |
---|
| 3491 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
| 3492 | rho=get(handles.rho,'String'); |
---|
| 3493 | dx=get(handles.dx_civ1,'String'); |
---|
| 3494 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
| 3495 | dy=get(handles.dy_civ1,'String'); |
---|
| 3496 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
| 3497 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
| 3498 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
| 3499 | pxcmy='1'; |
---|
| 3500 | image_first=cell2mat(filecell(1,1)); |
---|
| 3501 | if ~exist(image_first,'file') |
---|
| 3502 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
| 3503 | set(handles.RUN, 'Enable','On') |
---|
| 3504 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3505 | return |
---|
| 3506 | end |
---|
| 3507 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
| 3508 | sizim=size(A); |
---|
| 3509 | npx=num2str(sizim(2)); |
---|
| 3510 | npy=num2str(sizim(1)); |
---|
| 3511 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3512 | gridname='';%default ='noFile use default' |
---|
| 3513 | gridflag='n';%default |
---|
| 3514 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 3515 | nbslice_grid=[]; |
---|
| 3516 | if test_grid |
---|
| 3517 | gridname=get(handles.grid_civ1,'String'); |
---|
| 3518 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3519 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3520 | if ~isempty(nbslice_grid) |
---|
| 3521 | gridflag='y'; |
---|
| 3522 | end |
---|
| 3523 | elseif exist(gridname,'file') |
---|
| 3524 | gridflag='y'; |
---|
| 3525 | else |
---|
| 3526 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3527 | return |
---|
| 3528 | end |
---|
| 3529 | end |
---|
| 3530 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 3531 | threshflag='y'; |
---|
| 3532 | min_ima=get(handles.MinIma,'String'); |
---|
| 3533 | max_ima=get(handles.MaxIma,'String'); |
---|
| 3534 | else |
---|
| 3535 | threshflag='n'; |
---|
| 3536 | min_ima='0'; |
---|
| 3537 | max_ima='4096'; |
---|
| 3538 | end |
---|
| 3539 | %main loop |
---|
| 3540 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3541 | sizcell=size(filecell); |
---|
| 3542 | nbfield=sizcell(1); |
---|
| 3543 | nbslice=sizcell(2); |
---|
| 3544 | icount=0; |
---|
| 3545 | for ifile=1:nbfield |
---|
| 3546 | for j=1:nbslice |
---|
| 3547 | icount=icount+1; |
---|
| 3548 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3549 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
| 3550 | drawnow |
---|
| 3551 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
| 3552 | filename_ima([end-3:end])=[];%remove .png extension |
---|
| 3553 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
| 3554 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
| 3555 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
| 3556 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3557 | filename_cmx=[filename_cmx 'x']; |
---|
| 3558 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3559 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3560 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3561 | if isequal(Dt,'0') |
---|
| 3562 | Dt='1' ;%case of 'displacement' mode |
---|
| 3563 | end |
---|
| 3564 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3565 | else |
---|
| 3566 | Dt='1'; |
---|
| 3567 | T0='0'; |
---|
| 3568 | end |
---|
| 3569 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
| 3570 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
| 3571 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3572 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3573 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3574 | if ~exist(gridname,'file') |
---|
| 3575 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3576 | return |
---|
| 3577 | end |
---|
| 3578 | end |
---|
| 3579 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 3580 | if test_mask==0 |
---|
| 3581 | maskname='noFile use default'; |
---|
| 3582 | maskflag='n'; |
---|
| 3583 | else |
---|
| 3584 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
| 3585 | maskbase=[filebase '_' maskdispl];% |
---|
| 3586 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
| 3587 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
| 3588 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3589 | if exist(maskname,'file') |
---|
| 3590 | maskflag='y'; |
---|
| 3591 | else |
---|
| 3592 | maskname='noFile use default'; |
---|
| 3593 | maskflag='n'; |
---|
| 3594 | end |
---|
| 3595 | end |
---|
| 3596 | textcmx={'############## CMX file';... |
---|
| 3597 | ['FirstImage ' filename_ima];... |
---|
| 3598 | ['LastImage ' filename_ima_1];... |
---|
| 3599 | 'XX' ;... |
---|
| 3600 | ['Mask ' maskflag] ;... |
---|
| 3601 | ['MaskName ' maskname];... |
---|
| 3602 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
| 3603 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3604 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
| 3605 | ['RO ' rho];... |
---|
| 3606 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3607 | 'XX 1.0';... |
---|
| 3608 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3609 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3610 | 'XX 1';... |
---|
| 3611 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
| 3612 | ['Grid ' gridflag];... |
---|
| 3613 | ['GridName ' gridname] ;... |
---|
| 3614 | 'XX 85';... |
---|
| 3615 | 'XX 1.0';... |
---|
| 3616 | 'XX 1.0';... |
---|
| 3617 | 'Hart 1';... |
---|
| 3618 | 'DecimalShift 0';... |
---|
| 3619 | 'Deformation 0';... |
---|
| 3620 | 'CorrelationMin 0';... |
---|
| 3621 | 'IntensityMin 0';... |
---|
| 3622 | ['SeuilImage ' threshflag];... |
---|
| 3623 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
| 3624 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3625 | 'ImageUsedBefore null null'}; |
---|
| 3626 | textout=char(textcmx); |
---|
[12] | 3627 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3628 | fid=fopen([filename_cmx],'w'); |
---|
| 3629 | fprintf(fid, ['############## CMX file' '\n']); |
---|
[16] | 3630 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
| 3631 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
[12] | 3632 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3633 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
| 3634 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
| 3635 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 3636 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
| 3637 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
| 3638 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
| 3639 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
| 3640 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3641 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
| 3642 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
| 3643 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 3644 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
| 3645 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
| 3646 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
| 3647 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 3648 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3649 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3650 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 3651 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 3652 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 3653 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 3654 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 3655 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 3656 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 3657 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
| 3658 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 3659 | fclose(fid); |
---|
| 3660 | |
---|
[2] | 3661 | s=-1; |
---|
[67] | 3662 | display(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]) |
---|
| 3663 | eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]); |
---|
[2] | 3664 | % if sge%dispatch computation on the cluster using interactive queue |
---|
[67] | 3665 | % % [s,w] = unix(['qrsh -q fast.q ' civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
[2] | 3666 | % end |
---|
| 3667 | % if s~=0 |
---|
[67] | 3668 | % % ['!' civ1Bin ' -f ' filename_cmx ' > ' namelog] |
---|
| 3669 | % % eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]); |
---|
[2] | 3670 | % end |
---|
| 3671 | end |
---|
| 3672 | end |
---|
| 3673 | |
---|
[67] | 3674 | % %------------------------------------------------------------------------ |
---|
| 3675 | % % RUN CIV2 CIV2 CIV2 CIV2 |
---|
| 3676 | % function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
| 3677 | % %------------------------------------------------------------------------ |
---|
| 3678 | % %filecell_2: names of first image |
---|
| 3679 | % %filecell_3: names of second images |
---|
| 3680 | % global civ2Bin sge |
---|
| 3681 | % |
---|
| 3682 | % %names of the civ2 fields |
---|
| 3683 | % field.vel_type='civ2'; |
---|
| 3684 | % field.nb='nb_vectors2'; |
---|
| 3685 | % field.X='vec2_X'; |
---|
| 3686 | % field.Y='vec2_Y'; |
---|
| 3687 | % field.U='vec2_U'; |
---|
| 3688 | % field.V='vec2_V'; |
---|
| 3689 | % |
---|
| 3690 | % %get civ parameters |
---|
| 3691 | % ibx=get(handles.ibx_civ2,'String'); |
---|
| 3692 | % iby=get(handles.iby_civ2,'String'); |
---|
| 3693 | % rho=get(handles.rho_civ2,'String'); |
---|
| 3694 | % decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3695 | % deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3696 | % dx=get(handles.dx_civ2,'String'); |
---|
| 3697 | % dy=get(handles.dy_civ2,'String'); |
---|
| 3698 | % if isequal(str2num(dx),[]) |
---|
| 3699 | % dx='20';%default |
---|
| 3700 | % end |
---|
| 3701 | % if isequal(str2num(dy),[]) |
---|
| 3702 | % dy='20';%default |
---|
| 3703 | % end |
---|
| 3704 | % pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
| 3705 | % pxcmy='1'; |
---|
| 3706 | % A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
| 3707 | % sizim=size(A); |
---|
| 3708 | % npx=num2str(sizim(2)); |
---|
| 3709 | % npy=num2str(sizim(1)); |
---|
| 3710 | % time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3711 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 3712 | % %grid |
---|
| 3713 | % gridname='';%default ='noFile use default' |
---|
| 3714 | % gridflag='n';%default |
---|
| 3715 | % test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 3716 | % nbslice_grid=[]; |
---|
| 3717 | % if test_grid |
---|
| 3718 | % gridname=get(handles.grid_civ2,'String'); |
---|
| 3719 | % if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3720 | % nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3721 | % if ~isempty(nbslice_grid) |
---|
| 3722 | % gridflag='y'; |
---|
| 3723 | % end |
---|
| 3724 | % elseif exist(gridname,'file') |
---|
| 3725 | % gridflag='y'; |
---|
| 3726 | % else |
---|
| 3727 | % msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3728 | % return |
---|
| 3729 | % end |
---|
| 3730 | % end |
---|
| 3731 | % sizcell=size(filecell_2); |
---|
| 3732 | % nbfield=sizcell(1); |
---|
| 3733 | % nbslice=sizcell(2); |
---|
| 3734 | % |
---|
| 3735 | % %main loop |
---|
| 3736 | % icount=0; |
---|
| 3737 | % for ifile=1:nbfield |
---|
| 3738 | % for j=1:nbslice |
---|
| 3739 | % icount=icount+1; |
---|
| 3740 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3741 | % set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
| 3742 | % drawnow |
---|
| 3743 | % filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
| 3744 | % filename_ima_2([end-3:end])=[];%remove .png extension |
---|
| 3745 | % filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
| 3746 | % filename_ima_3([end-3:end])=[];%remove .png extension |
---|
| 3747 | % filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
| 3748 | % filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3749 | % filename_cmx=[filename_cmx 'x']; |
---|
| 3750 | % namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3751 | % if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3752 | % Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3753 | % if isequal(Dt,'0') |
---|
| 3754 | % Dt='1' ;%case of 'displacement' mode |
---|
| 3755 | % end |
---|
| 3756 | % T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3757 | % else |
---|
| 3758 | % Dt='1'; |
---|
| 3759 | % T0='0'; |
---|
| 3760 | % end |
---|
| 3761 | % term_a=num2stra(num_a(j),nom_type_nc); |
---|
| 3762 | % term_b=num2stra(num_b(j),nom_type_nc); |
---|
| 3763 | % filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
| 3764 | % filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 3765 | % if test_grid && ~isempty(nbslice_grid) |
---|
| 3766 | % num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
| 3767 | % gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3768 | % if ~exist(gridname,'file') |
---|
| 3769 | % msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3770 | % return |
---|
| 3771 | % end |
---|
| 3772 | % end |
---|
| 3773 | % test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 3774 | % if test_mask==0 |
---|
| 3775 | % maskname='noFile use default'; |
---|
| 3776 | % maskflag='n'; |
---|
| 3777 | % else |
---|
| 3778 | % maskdispl=get(handles.mask_civ2,'String'); |
---|
| 3779 | % maskbase=[filebase '_' maskdispl]; % |
---|
| 3780 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 3781 | % num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
| 3782 | % maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3783 | % if ~exist(maskname,'file') |
---|
| 3784 | % maskflag='y'; |
---|
| 3785 | % else |
---|
| 3786 | % maskname='noFile use default'; |
---|
| 3787 | % maskflag='n'; |
---|
| 3788 | % end |
---|
| 3789 | % end |
---|
| 3790 | % |
---|
| 3791 | % textcmx={'############## CMX file';... |
---|
| 3792 | % ['FirstImage ' filename_ima_2];... |
---|
| 3793 | % ['LastImage ' filename_ima_3];... |
---|
| 3794 | % 'XX' ;... |
---|
| 3795 | % ['Mask ' maskflag];... |
---|
| 3796 | % ['MaskName ' maskname];... |
---|
| 3797 | % ['ImageSize ' npx ' ' npy];... |
---|
| 3798 | % ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3799 | % ['SearchBoxeSize ' ibx ' ' iby];... |
---|
| 3800 | % ['RO ' rho];... |
---|
| 3801 | % ['GridSpacing ' dx ' ' dy];... |
---|
| 3802 | % 'XX 1.0';... |
---|
| 3803 | % ['Dt_TO ' Dt ' ' T0];... |
---|
| 3804 | % ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3805 | % 'XX 1';... |
---|
| 3806 | % ['ShiftXY 0 0'];... |
---|
| 3807 | % ['Grid ' gridflag];... |
---|
| 3808 | % ['GridName ' gridname];... |
---|
| 3809 | % 'XX 85';... |
---|
| 3810 | % 'XX 1.0';... |
---|
| 3811 | % 'XX 1.0';... |
---|
| 3812 | % 'Hart 1';... |
---|
| 3813 | % ['DecimalShift ' decimal];... |
---|
| 3814 | % ['Deformation ' deformation];... |
---|
| 3815 | % 'CorrelationMin 0';... |
---|
| 3816 | % 'IntensityMin 0';... |
---|
| 3817 | % 'SeuilImage n';... |
---|
| 3818 | % 'SeuilImageValues 0 4096';... |
---|
| 3819 | % ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3820 | % ['ImageUsedBefore ' filename_nc1]}; |
---|
| 3821 | % textout=char(textcmx); |
---|
| 3822 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3823 | % s=-1; |
---|
| 3824 | % display(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]) |
---|
| 3825 | % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]); |
---|
| 3826 | % |
---|
| 3827 | % % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3828 | % % [s,w] = unix(['qrsh -q fast.q ' civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
| 3829 | % % end |
---|
| 3830 | % % if s~=0 |
---|
| 3831 | % % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3832 | % % ['!' civ2Bin ' -f ' filename_cmx ' > ' namelog] |
---|
| 3833 | % % end |
---|
| 3834 | % end |
---|
| 3835 | % end |
---|
| 3836 | % % close(h) |
---|
[2] | 3837 | |
---|
[12] | 3838 | %------------------------------------------------------------------------ |
---|
| 3839 | % --- PATCH |
---|
[2] | 3840 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
[12] | 3841 | %------------------------------------------------------------------------ |
---|
[67] | 3842 | global patchBin patch_newBin |
---|
[2] | 3843 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3844 | if test_interp==0 |
---|
[67] | 3845 | cmd_PATCH=[patchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
[66] | 3846 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[2] | 3847 | else %nouveau programme patch |
---|
[67] | 3848 | cmd_PATCH=[patch_newBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
[66] | 3849 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[2] | 3850 | end |
---|
[12] | 3851 | |
---|
| 3852 | %------------------------------------------------------------------------ |
---|
| 3853 | % --- STEREO Interp |
---|
[67] | 3854 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
[12] | 3855 | %------------------------------------------------------------------------ |
---|
[2] | 3856 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
[67] | 3857 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3858 | ' -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 |
---|
| 3859 | |
---|
[12] | 3860 | %------------------------------------------------------------------------ |
---|
[2] | 3861 | % --- Executes on button press in CIV1. |
---|
| 3862 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3863 | %------------------------------------------------------------------------ |
---|
[2] | 3864 | val=get(handles.CIV1,'Value'); |
---|
| 3865 | if isequal(val,1) |
---|
| 3866 | enable_civ1(handles,'on') |
---|
| 3867 | enable_pair1(handles,'on') |
---|
| 3868 | else |
---|
| 3869 | enable_civ1(handles,'off') |
---|
| 3870 | end |
---|
| 3871 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3872 | |
---|
[12] | 3873 | %------------------------------------------------------------------------ |
---|
[2] | 3874 | % --- Executes on button press in FIX1. |
---|
| 3875 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3876 | %------------------------------------------------------------------------ |
---|
[2] | 3877 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3878 | |
---|
[12] | 3879 | %------------------------------------------------------------------------ |
---|
[2] | 3880 | % --- Executes on button press in PATCH1. |
---|
| 3881 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3882 | %------------------------------------------------------------------------ |
---|
[2] | 3883 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3884 | enable_patch1(handles) |
---|
[2] | 3885 | else |
---|
[12] | 3886 | desable_patch1(handles) |
---|
[2] | 3887 | end |
---|
| 3888 | |
---|
[12] | 3889 | %------------------------------------------------------------------------ |
---|
[2] | 3890 | % --- Executes on button press in CIV2. |
---|
| 3891 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3892 | %------------------------------------------------------------------------ |
---|
[2] | 3893 | state=get(handles.CIV2,'Value'); |
---|
| 3894 | enable_civ2(handles,state) |
---|
| 3895 | if state |
---|
| 3896 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3897 | enable_pair1(handles,'on') |
---|
| 3898 | end |
---|
| 3899 | |
---|
[12] | 3900 | %------------------------------------------------------------------------ |
---|
[2] | 3901 | % --- Executes on button press in FIX2. |
---|
| 3902 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3903 | %------------------------------------------------------------------------ |
---|
[2] | 3904 | if get(handles.FIX2,'Value')==1 |
---|
| 3905 | enable_fix2(handles) |
---|
| 3906 | if get(handles.CIV2,'Value')==0 |
---|
| 3907 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3908 | end |
---|
| 3909 | else |
---|
| 3910 | desable_fix2(handles) |
---|
| 3911 | end |
---|
| 3912 | |
---|
[12] | 3913 | %------------------------------------------------------------------------ |
---|
[2] | 3914 | % --- Executes on button press in PATCH2. |
---|
| 3915 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3916 | %------------------------------------------------------------------------ |
---|
[2] | 3917 | if get(handles.PATCH2,'Value')==1 |
---|
| 3918 | enable_patch2(handles) |
---|
| 3919 | if get(handles.CIV2,'Value')==0 |
---|
| 3920 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3921 | end |
---|
| 3922 | else |
---|
| 3923 | desable_patch2(handles) |
---|
| 3924 | end |
---|
| 3925 | |
---|
[12] | 3926 | %------------------------------------------------------------------------ |
---|
| 3927 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3928 | %------------------------------------------------------------------------ |
---|
| 3929 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 3930 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 3931 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3932 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3933 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3934 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3935 | |
---|
[12] | 3936 | %------------------------------------------------------------------------ |
---|
| 3937 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3938 | %------------------------------------------------------------------------ |
---|
| 3939 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3940 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3941 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3942 | |
---|
[12] | 3943 | %------------------------------------------------------------------------ |
---|
[2] | 3944 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3945 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3946 | %------------------------------------------------------------------------ |
---|
[2] | 3947 | %determine pair numbers |
---|
| 3948 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3949 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3950 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3951 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3952 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3953 | pxcmx=pxcm_xy(1); |
---|
| 3954 | pxcmy=pxcm_xy(2); |
---|
| 3955 | mode_list=get(handles.mode,'String'); |
---|
| 3956 | mode_value=get(handles.mode,'Value'); |
---|
| 3957 | mode=mode_list{mode_value}; |
---|
| 3958 | if isequal (mode, 'series(Di)' ) |
---|
| 3959 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3960 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3961 | num2=ref_i+ceil(index/2); |
---|
| 3962 | num_a=1; |
---|
| 3963 | num_b=1; |
---|
| 3964 | elseif isequal (mode, 'series(Dj)') |
---|
| 3965 | num1=1; |
---|
| 3966 | num2=1; |
---|
| 3967 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3968 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3969 | num_b=ref_j+ceil(index/2); |
---|
| 3970 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3971 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3972 | num1=ref_i; |
---|
| 3973 | num2=ref_i; |
---|
| 3974 | num_a=displ_num(1,index); |
---|
| 3975 | num_b=displ_num(2,index); |
---|
| 3976 | end |
---|
| 3977 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3978 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 3979 | iby=str2num(get(handles.iby,'String')); |
---|
| 3980 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 3981 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 3982 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 3983 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 3984 | shiftx=round((umin+umax)/2); |
---|
| 3985 | shifty=round((vmin+vmax)/2); |
---|
| 3986 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3987 | isx=2*ceil(isx/2)+1; |
---|
| 3988 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3989 | isy=2*ceil(isy/2)+1; |
---|
| 3990 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3991 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3992 | set(handles.isx,'String',num2str(isx)); |
---|
| 3993 | set(handles.isy,'String',num2str(isy)); |
---|
| 3994 | |
---|
[12] | 3995 | %------------------------------------------------------------------------ |
---|
| 3996 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3997 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3998 | %------------------------------------------------------------------------ |
---|
[2] | 3999 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 4000 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4001 | if get(handles.CIV1,'Value')==0 |
---|
| 4002 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 4003 | end |
---|
| 4004 | |
---|
[12] | 4005 | %------------------------------------------------------------------------ |
---|
| 4006 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 4007 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4008 | %------------------------------------------------------------------------ |
---|
[2] | 4009 | %update the list of available pairs from netcdf files in the new directory |
---|
| 4010 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 4011 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4012 | end |
---|
| 4013 | |
---|
[12] | 4014 | %------------------------------------------------------------------------ |
---|
[2] | 4015 | % --- Executes on button press in get_mask_civ1. |
---|
| 4016 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4017 | %------------------------------------------------------------------------ |
---|
[2] | 4018 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 4019 | if isequal(maskval,0) |
---|
| 4020 | set(handles.mask_civ1,'String','') |
---|
| 4021 | else |
---|
| 4022 | mask_displ='no mask'; %default |
---|
| 4023 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4024 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 4025 | if isequal(flag_mask,1) |
---|
| 4026 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
| 4027 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4028 | common_path=fileparts(filebase); |
---|
| 4029 | filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String')); |
---|
| 4030 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[12] | 4031 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
[2] | 4032 | mask_displ='no mask'; |
---|
| 4033 | end |
---|
| 4034 | end |
---|
| 4035 | if isequal(mask_displ,'no mask') |
---|
[12] | 4036 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4037 | {'*.png', ' (*.png)'; |
---|
| 4038 | '*.png', '.png files '; ... |
---|
| 4039 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4040 | 'Pick a mask file *.png',filebase); |
---|
| 4041 | mask_displ=fullfile(PathName,FileName); |
---|
| 4042 | if ~exist(mask_displ,'file') |
---|
| 4043 | mask_displ='no mask'; |
---|
| 4044 | end |
---|
| 4045 | end |
---|
| 4046 | if isequal(mask_displ,'no mask') |
---|
[2] | 4047 | set(handles.get_mask_civ1,'Value',0) |
---|
| 4048 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4049 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4050 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4051 | else |
---|
| 4052 | set(handles.get_mask_fix1,'Value',1) |
---|
| 4053 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4054 | end |
---|
| 4055 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 4056 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4057 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4058 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4059 | end |
---|
| 4060 | |
---|
[12] | 4061 | %------------------------------------------------------------------------ |
---|
[2] | 4062 | % --- Executes on button press in get_mask_fix1. |
---|
| 4063 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4064 | %------------------------------------------------------------------------ |
---|
[2] | 4065 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 4066 | if isequal(maskval,0) |
---|
| 4067 | set(handles.mask_fix1,'String','') |
---|
| 4068 | else |
---|
| 4069 | mask_displ='no mask'; %default |
---|
| 4070 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4071 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4072 | if isequal(flag_mask,1) |
---|
| 4073 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4074 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4075 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4076 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4077 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4078 | mask_displ='no mask'; |
---|
| 4079 | end |
---|
| 4080 | end |
---|
| 4081 | if isequal(mask_displ,'no mask') |
---|
[12] | 4082 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4083 | {'*.png', ' (*.png)'; |
---|
| 4084 | '*.png', '.png files '; ... |
---|
| 4085 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4086 | 'Pick a mask file *.png',filebase); |
---|
| 4087 | mask_displ=fullfile(PathName,FileName); |
---|
| 4088 | if ~exist(mask_displ,'file') |
---|
| 4089 | mask_displ='no mask'; |
---|
| 4090 | end |
---|
| 4091 | end |
---|
| 4092 | if isequal(mask_displ,'no mask') |
---|
[2] | 4093 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4094 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4095 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4096 | else |
---|
| 4097 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 4098 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4099 | end |
---|
| 4100 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4101 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4102 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4103 | end |
---|
[12] | 4104 | |
---|
| 4105 | %------------------------------------------------------------------------ |
---|
[2] | 4106 | % --- Executes on button press in get_mask_civ2. |
---|
| 4107 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4108 | %------------------------------------------------------------------------ |
---|
[2] | 4109 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 4110 | if isequal(maskval,0) |
---|
| 4111 | set(handles.mask_civ2,'String','') |
---|
| 4112 | else |
---|
| 4113 | mask_displ='no mask'; %default |
---|
| 4114 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4115 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4116 | if isequal(flag_mask,1) |
---|
| 4117 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4118 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4119 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4120 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4121 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4122 | mask_displ='no mask'; |
---|
| 4123 | end |
---|
| 4124 | end |
---|
| 4125 | if isequal(mask_displ,'no mask') |
---|
[12] | 4126 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4127 | {'*.png', ' (*.png)'; |
---|
| 4128 | '*.png', '.png files '; ... |
---|
| 4129 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4130 | 'Pick a mask file *.png',filebase); |
---|
| 4131 | mask_displ=fullfile(PathName,FileName); |
---|
| 4132 | if ~exist(mask_displ,'file') |
---|
| 4133 | mask_displ='no mask'; |
---|
| 4134 | end |
---|
| 4135 | end |
---|
| 4136 | if isequal(mask_displ,'no mask') |
---|
[2] | 4137 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4138 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4139 | else |
---|
| 4140 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4141 | end |
---|
| 4142 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4143 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4144 | end |
---|
[12] | 4145 | |
---|
| 4146 | %------------------------------------------------------------------------ |
---|
[2] | 4147 | % --- Executes on button press in get_mask_fix2. |
---|
| 4148 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4149 | %------------------------------------------------------------------------ |
---|
[2] | 4150 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 4151 | if isequal(maskval,0) |
---|
| 4152 | set(handles.mask_fix2,'String','') |
---|
| 4153 | else |
---|
[12] | 4154 | mask_displ='no mask'; %default |
---|
| 4155 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4156 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4157 | if isequal(flag_mask,1) |
---|
| 4158 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4159 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4160 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4161 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4162 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4163 | mask_displ='no mask'; |
---|
| 4164 | end |
---|
| 4165 | end |
---|
| 4166 | if isequal(mask_displ,'no mask') |
---|
| 4167 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4168 | {'*.png', ' (*.png)'; |
---|
| 4169 | '*.png', '.png files '; ... |
---|
| 4170 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4171 | 'Pick a mask file *.png',filebase); |
---|
| 4172 | mask_displ=fullfile(PathName,FileName); |
---|
| 4173 | if ~exist(mask_displ,'file') |
---|
[2] | 4174 | mask_displ='no mask'; |
---|
| 4175 | end |
---|
[12] | 4176 | end |
---|
| 4177 | if isequal(mask_displ,'no mask') |
---|
| 4178 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4179 | end |
---|
| 4180 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 4181 | end |
---|
| 4182 | |
---|
[12] | 4183 | %------------------------------------------------------------------------ |
---|
| 4184 | % --- function called to look for mask files |
---|
[2] | 4185 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 4186 | %------------------------------------------------------------------------ |
---|
[2] | 4187 | %detect mask files, images with appropriate file base |
---|
| 4188 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 4189 | %flag_mask=1 indicates detection |
---|
| 4190 | |
---|
| 4191 | flag_mask=0;%default |
---|
| 4192 | nbslice=1; |
---|
| 4193 | |
---|
| 4194 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 4195 | [Path,Name]=fileparts(filebase); |
---|
[12] | 4196 | if ~isdir(Path) |
---|
| 4197 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 4198 | return |
---|
| 4199 | end |
---|
[2] | 4200 | currentdir=pwd; |
---|
| 4201 | cd(Path);%move in the dir of the root name filebase |
---|
| 4202 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 4203 | cd(currentdir);%come back to the current working directory |
---|
[12] | 4204 | if ~isempty(maskfiles) |
---|
| 4205 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 4206 | % else |
---|
[2] | 4207 | flag_mask=1; |
---|
| 4208 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4209 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4210 | Namedouble=double(Name); |
---|
| 4211 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4212 | ind_mask=findstr('mask',Name); |
---|
| 4213 | i=ind_mask-1; |
---|
| 4214 | while val(i)==0 & i>0 |
---|
| 4215 | i=i-1; |
---|
| 4216 | end |
---|
| 4217 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4218 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4219 | flag_mask=1; |
---|
| 4220 | else |
---|
| 4221 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 4222 | return |
---|
| 4223 | nbslice=1; |
---|
| 4224 | end |
---|
| 4225 | end |
---|
| 4226 | |
---|
[12] | 4227 | %------------------------------------------------------------------------ |
---|
| 4228 | % --- function called to look for grid files |
---|
[2] | 4229 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 4230 | %------------------------------------------------------------------------ |
---|
[2] | 4231 | flag_mask=0;%default |
---|
| 4232 | nbslice=1; |
---|
| 4233 | [Path,Name]=fileparts(filebase); |
---|
| 4234 | currentdir=pwd; |
---|
| 4235 | cd(Path);%move in the dir of the root name filebase |
---|
| 4236 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 4237 | cd(currentdir);%come back to the current working directory |
---|
| 4238 | if ~isempty(maskfiles) |
---|
| 4239 | flag_mask=1; |
---|
| 4240 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4241 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4242 | Namedouble=double(Name); |
---|
| 4243 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4244 | ind_mask=findstr('grid',Name); |
---|
| 4245 | i=ind_mask-1; |
---|
| 4246 | while val(i)==0 & i>0 |
---|
| 4247 | i=i-1; |
---|
| 4248 | end |
---|
| 4249 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4250 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4251 | flag_mask=1; |
---|
| 4252 | else |
---|
| 4253 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 4254 | return |
---|
| 4255 | nbslice=1; |
---|
| 4256 | end |
---|
[12] | 4257 | end |
---|
[2] | 4258 | |
---|
[12] | 4259 | %------------------------------------------------------------------------ |
---|
| 4260 | % --- transform numbers to letters |
---|
[2] | 4261 | function str=num2stra(num,nom_type); |
---|
[12] | 4262 | %------------------------------------------------------------------------ |
---|
[2] | 4263 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 4264 | str=char(96+num); |
---|
| 4265 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 4266 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 4267 | str=''; |
---|
| 4268 | else |
---|
| 4269 | str=num2str(num); |
---|
| 4270 | end |
---|
[12] | 4271 | |
---|
| 4272 | %------------------------------------------------------------------------ |
---|
[2] | 4273 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4274 | %------------------------------------------------------------------------ |
---|
[2] | 4275 | set(handles.mask_civ1,'UserData',[]) |
---|
| 4276 | set(handles.mask_civ1,'String','') |
---|
[12] | 4277 | |
---|
| 4278 | %------------------------------------------------------------------------ |
---|
[2] | 4279 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4280 | %------------------------------------------------------------------------ |
---|
[2] | 4281 | set(handles.mask_civ2,'UserData',[]) |
---|
| 4282 | set(handles.mask_civ2,'String','') |
---|
[12] | 4283 | |
---|
| 4284 | %------------------------------------------------------------------------ |
---|
[2] | 4285 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4286 | %------------------------------------------------------------------------ |
---|
[2] | 4287 | set(handles.mask_fix1,'UserData',[]) |
---|
| 4288 | set(handles.mask_fix1,'String','') |
---|
[12] | 4289 | |
---|
| 4290 | %------------------------------------------------------------------------ |
---|
[2] | 4291 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4292 | %------------------------------------------------------------------------ |
---|
[2] | 4293 | set(handles.mask_fix2,'UserData',[]) |
---|
| 4294 | set(handles.mask_fix2,'String','') |
---|
| 4295 | |
---|
[12] | 4296 | %------------------------------------------------------------------------ |
---|
[2] | 4297 | % --- Executes on button press in list_subdir_civ1. |
---|
| 4298 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4299 | %------------------------------------------------------------------------ |
---|
[2] | 4300 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 4301 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 4302 | if val>1 |
---|
| 4303 | subdir=list_subdir_civ1{val}; |
---|
| 4304 | set(handles.subdir_civ1,'String',subdir); |
---|
| 4305 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 4306 | end |
---|
| 4307 | |
---|
[12] | 4308 | %------------------------------------------------------------------------ |
---|
[2] | 4309 | % --- Executes on button press in list_subdir_civ2. |
---|
| 4310 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4311 | %------------------------------------------------------------------------ |
---|
[2] | 4312 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 4313 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 4314 | if val>1 |
---|
| 4315 | subdir=list_subdir_civ2{val}; |
---|
| 4316 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4317 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 4318 | end |
---|
| 4319 | |
---|
[12] | 4320 | %------------------------------------------------------------------------ |
---|
[2] | 4321 | % --- Executes on button press in browse_gridciv1. |
---|
| 4322 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 4323 | %------------------------------------------------------------------------ |
---|
[2] | 4324 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 4325 | testgrid=0; |
---|
| 4326 | if value |
---|
| 4327 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4328 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4329 | if isequal(flag_grid,1) |
---|
| 4330 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 4331 | testgrid=1; |
---|
| 4332 | else |
---|
| 4333 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4334 | {'*.grid', ' (*.grid)'; |
---|
| 4335 | '*.grid', '.grid files '; ... |
---|
| 4336 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4337 | 'Pick a file',filebase); |
---|
| 4338 | filegrid=fullfile(PathName,FileName); |
---|
| 4339 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 4340 | testgrid=1; |
---|
| 4341 | end |
---|
| 4342 | end |
---|
| 4343 | end |
---|
| 4344 | if testgrid |
---|
| 4345 | set(handles.browse_gridciv2,'Value',1) |
---|
| 4346 | set(handles.get_gridpatch1,'Value',1) |
---|
| 4347 | set(handles.get_gridpatch2,'Value',1) |
---|
| 4348 | set(handles.dx_civ1,'Visible','off'); |
---|
| 4349 | set(handles.dy_civ1,'Visible','off'); |
---|
| 4350 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4351 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4352 | set(handles.grid_civ1,'String',filegrid) |
---|
| 4353 | set(handles.grid_patch1,'String',filegrid) |
---|
| 4354 | set(handles.grid_civ2,'String',filegrid) |
---|
| 4355 | set(handles.grid_patch2,'String',filegrid) |
---|
| 4356 | else |
---|
| 4357 | set(handles.browse_gridciv1,'Value',0); |
---|
| 4358 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4359 | set(handles.get_gridpatch1,'Value',0) |
---|
| 4360 | set(handles.get_gridpatch2,'Value',0) |
---|
| 4361 | set(handles.dx_civ1,'Visible','on'); |
---|
| 4362 | set(handles.dy_civ1,'Visible','on'); |
---|
| 4363 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4364 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4365 | set(handles.grid_civ1,'String','') |
---|
| 4366 | set(handles.grid_patch1,'String','') |
---|
| 4367 | set(handles.grid_civ2,'String','') |
---|
| 4368 | set(handles.grid_patch2,'String','') |
---|
| 4369 | end |
---|
| 4370 | |
---|
[12] | 4371 | %------------------------------------------------------------------------ |
---|
[2] | 4372 | % --- Executes on button press in browse_gridciv1. |
---|
| 4373 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 4374 | %------------------------------------------------------------------------ |
---|
[2] | 4375 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 4376 | if value |
---|
| 4377 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4378 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4379 | if isequal(flag_grid,1) |
---|
| 4380 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 4381 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 4382 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4383 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4384 | else |
---|
| 4385 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4386 | {'*.grid', ' (*.grid)'; |
---|
| 4387 | '*.grid', '.grid files '; ... |
---|
| 4388 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4389 | 'Pick a file',filebase); |
---|
| 4390 | filegrid=fullfile(PathName,FileName); |
---|
| 4391 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 4392 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4393 | set(handles.grid_civ2,'string',''); |
---|
| 4394 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4395 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4396 | set(handles.grid_civ2,'string',''); |
---|
| 4397 | else |
---|
| 4398 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4399 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4400 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4401 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4402 | end |
---|
| 4403 | end |
---|
| 4404 | else |
---|
| 4405 | set(handles.grid_civ2,'string',''); |
---|
| 4406 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4407 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4408 | set(handles.grid_civ2,'string',''); |
---|
| 4409 | end |
---|
| 4410 | |
---|
| 4411 | % % --- Executes on button press in browse_gridciv2. |
---|
| 4412 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 4413 | % |
---|
| 4414 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 4415 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4416 | % {'*.grid', ' (*.grid)'; |
---|
| 4417 | % '*.grid', '.grid files '; ... |
---|
| 4418 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 4419 | % 'Pick a file',filebase); |
---|
| 4420 | % filegrid=fullfile(PathName,FileName); |
---|
| 4421 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 4422 | % set(handles.dx_civ2,'String',' '); |
---|
| 4423 | % set(handles.dy_civ2,'String',' '); |
---|
| 4424 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 4425 | |
---|
| 4426 | % --- Executes on button press in get_gridpatch1. |
---|
| 4427 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 4428 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 4429 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4430 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4431 | |
---|
| 4432 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4433 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4434 | {'*.grid', ' (*.grid)'; |
---|
| 4435 | '*.grid', '.grid files '; ... |
---|
| 4436 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4437 | 'Pick a file',filebase); |
---|
| 4438 | filegrid=fullfile(PathName,FileName); |
---|
| 4439 | set(handles.grid_patch1,'string',filegrid); |
---|
| 4440 | % set(handles.grid_patch2,'string',filegrid |
---|
| 4441 | |
---|
[12] | 4442 | %------------------------------------------------------------------------ |
---|
[2] | 4443 | % --- Executes on button press in get_gridpatch2. |
---|
| 4444 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 4445 | %------------------------------------------------------------------------ |
---|
[2] | 4446 | |
---|
[12] | 4447 | %------------------------------------------------------------------------ |
---|
[2] | 4448 | function enable_civ1(handles,state) |
---|
[12] | 4449 | %------------------------------------------------------------------------ |
---|
[2] | 4450 | if isequal(state,0) |
---|
| 4451 | state='off'; |
---|
| 4452 | end |
---|
| 4453 | if isequal(state,1) |
---|
| 4454 | state='on'; |
---|
| 4455 | end |
---|
| 4456 | if isequal(state,'on') |
---|
| 4457 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4458 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4459 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4460 | else |
---|
| 4461 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4462 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4463 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4464 | end |
---|
| 4465 | set(handles.ibx,'Visible',state) |
---|
| 4466 | set(handles.iby,'Visible',state) |
---|
| 4467 | set(handles.isx,'Visible',state) |
---|
| 4468 | set(handles.isy,'Visible',state) |
---|
| 4469 | set(handles.shiftx,'Visible',state) |
---|
| 4470 | set(handles.shifty,'Visible',state) |
---|
| 4471 | set(handles.rho,'Visible',state) |
---|
| 4472 | set(handles.dx_civ1,'Visible',state) |
---|
| 4473 | set(handles.dy_civ1,'Visible',state) |
---|
| 4474 | set(handles.calcul_search,'Visible',state) |
---|
| 4475 | set(handles.u_text,'Visible',state) |
---|
| 4476 | set(handles.v_text,'Visible',state) |
---|
| 4477 | set(handles.min,'Visible',state) |
---|
| 4478 | set(handles.max,'Visible',state) |
---|
| 4479 | set(handles.umin,'Visible',state) |
---|
| 4480 | set(handles.umax,'Visible',state) |
---|
| 4481 | set(handles.vmin,'Visible',state) |
---|
| 4482 | set(handles.vmax,'Visible',state) |
---|
| 4483 | set(handles.grid_civ1,'Visible',state) |
---|
| 4484 | set(handles.mask_civ1,'Visible',state) |
---|
| 4485 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 4486 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 4487 | set(handles.parameters,'Visible',state) |
---|
| 4488 | set(handles.grid,'Visible',state) |
---|
| 4489 | set(handles.dx_civ1,'Visible',state) |
---|
| 4490 | set(handles.dy_civ1,'Visible',state) |
---|
| 4491 | set(handles.ImaThreshold,'Visible',state) |
---|
| 4492 | if isequal(state,'off') |
---|
| 4493 | set(handles.MinIma,'Visible','off') |
---|
| 4494 | set(handles.MaxIma,'Visible','off') |
---|
| 4495 | set(handles.ImaThreshold,'Value',0) |
---|
| 4496 | end |
---|
| 4497 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 4498 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 4499 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 4500 | set(handles.ib_title,'Visible',state) |
---|
| 4501 | set(handles.is_title,'Visible',state) |
---|
| 4502 | set(handles.shift_title,'Visible',state) |
---|
| 4503 | set(handles.rho_title,'Visible',state) |
---|
| 4504 | |
---|
[12] | 4505 | %------------------------------------------------------------------------ |
---|
[2] | 4506 | function enable_fix1(handles,state) |
---|
[12] | 4507 | %------------------------------------------------------------------------ |
---|
[2] | 4508 | if isequal(state,0) |
---|
| 4509 | state='off'; |
---|
| 4510 | end |
---|
| 4511 | if isequal(state,1) |
---|
| 4512 | state='on'; |
---|
| 4513 | end |
---|
| 4514 | if isequal(state,'on') |
---|
| 4515 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 4516 | else |
---|
| 4517 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4518 | end |
---|
| 4519 | set(handles.REMOVE,'Visible',state) |
---|
| 4520 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 4521 | set(handles.vec_F2,'Visible',state) |
---|
| 4522 | set(handles.vec_F3,'Visible',state) |
---|
| 4523 | set(handles.thresh_vecC,'Visible',state) |
---|
| 4524 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 4525 | set(handles.thresh_vel,'Visible',state) |
---|
| 4526 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 4527 | set(handles.mask_fix1,'Visible',state) |
---|
| 4528 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 4529 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 4530 | set(handles.ref_fix1,'Visible',state) |
---|
| 4531 | set(handles.inf_sup1,'Visible',state) |
---|
| 4532 | set(handles.field_ref1,'Visible',state) |
---|
| 4533 | |
---|
[12] | 4534 | %------------------------------------------------------------------------ |
---|
[2] | 4535 | function enable_patch1(handles) |
---|
[12] | 4536 | %------------------------------------------------------------------------ |
---|
[67] | 4537 | global patch_newBin |
---|
[2] | 4538 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 4539 | set(handles.rho_patch1,'Visible','on') |
---|
| 4540 | set(handles.rho_text1,'Visible','on') |
---|
| 4541 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4542 | set(handles.thresh_text1,'Visible','on') |
---|
| 4543 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4544 | set(handles.subdomain_text1,'Visible','on') |
---|
| 4545 | set(handles.nx_patch1,'Visible','on') |
---|
| 4546 | set(handles.ny_patch1,'Visible','on') |
---|
| 4547 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 4548 | set(handles.ny_patch1_title,'Visible','on') |
---|
[67] | 4549 | if (~isequal(patch_newBin,[]) & ~isequal(patch_newBin,[])) |
---|
[2] | 4550 | set(handles.test_interp,'Visible','on'); |
---|
| 4551 | end |
---|
| 4552 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 4553 | set(handles.grid_patch1,'string','none'); |
---|
| 4554 | set(handles.grid_patch1,'Visible','on') |
---|
| 4555 | |
---|
[12] | 4556 | %------------------------------------------------------------------------ |
---|
[2] | 4557 | function desable_patch1(handles) |
---|
[12] | 4558 | %------------------------------------------------------------------------ |
---|
[2] | 4559 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4560 | set(handles.rho_patch1,'Visible','off') |
---|
| 4561 | set(handles.rho_text1,'Visible','off') |
---|
| 4562 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4563 | set(handles.thresh_text1,'Visible','off') |
---|
| 4564 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4565 | set(handles.subdomain_text1,'Visible','off') |
---|
| 4566 | set(handles.nx_patch1,'Visible','off') |
---|
| 4567 | set(handles.ny_patch1,'Visible','off') |
---|
| 4568 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 4569 | set(handles.ny_patch1_title,'Visible','off') |
---|
| 4570 | set(handles.test_interp,'Visible','off') |
---|
| 4571 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 4572 | set(handles.grid_patch1,'Visible','off') |
---|
| 4573 | |
---|
[12] | 4574 | %------------------------------------------------------------------------ |
---|
[2] | 4575 | function enable_civ2(handles,state) |
---|
[12] | 4576 | %------------------------------------------------------------------------ |
---|
[2] | 4577 | if isequal(state,0) |
---|
| 4578 | state='off'; |
---|
| 4579 | end |
---|
| 4580 | if isequal(state,1) |
---|
| 4581 | state='on'; |
---|
| 4582 | end |
---|
| 4583 | if isequal(state,'on') |
---|
| 4584 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4585 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4586 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4587 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4588 | else |
---|
| 4589 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4590 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4591 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4592 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4593 | end |
---|
| 4594 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4595 | set(handles.iby_civ2,'Visible',state) |
---|
| 4596 | set(handles.decimal,'Visible',state) |
---|
| 4597 | set(handles.deformation,'Visible',state) |
---|
| 4598 | set(handles.rho_civ2,'Visible',state) |
---|
| 4599 | set(handles.dx_civ2,'Visible',state) |
---|
| 4600 | set(handles.dy_civ2,'Visible',state) |
---|
| 4601 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4602 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4603 | set(handles.parameters,'Visible',state) |
---|
| 4604 | set(handles.grid,'Visible',state) |
---|
| 4605 | set(handles.parameters_text,'Visible',state) |
---|
| 4606 | set(handles.grid_text,'Visible',state) |
---|
| 4607 | set(handles.grid_civ2,'Visible',state) |
---|
| 4608 | set(handles.mask_civ2,'Visible',state) |
---|
| 4609 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4610 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4611 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4612 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4613 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4614 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4615 | if isequal(state,'off') |
---|
| 4616 | set(handles.MinIma2,'Visible','off') |
---|
| 4617 | set(handles.MaxIma2,'Visible','off') |
---|
| 4618 | set(handles.ImaThreshold2,'Value',0) |
---|
| 4619 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4620 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4621 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4622 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4623 | end |
---|
| 4624 | else |
---|
| 4625 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4626 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4627 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4628 | end |
---|
| 4629 | |
---|
[12] | 4630 | %------------------------------------------------------------------------ |
---|
[2] | 4631 | function enable_fix2(handles) |
---|
[12] | 4632 | %------------------------------------------------------------------------ |
---|
[2] | 4633 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4634 | set(handles.REMOVE2,'Visible','on') |
---|
| 4635 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4636 | set(handles.vec_F4,'Visible','on') |
---|
| 4637 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4638 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4639 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4640 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4641 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4642 | set(handles.mask_fix2,'Visible','on') |
---|
| 4643 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4644 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4645 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4646 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4647 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4648 | set(handles.ref_fix2,'Visible','on') |
---|
| 4649 | set(handles.inf_sup2,'Visible','on') |
---|
| 4650 | set(handles.field_ref2,'Visible','on') |
---|
| 4651 | |
---|
[12] | 4652 | %------------------------------------------------------------------------ |
---|
[2] | 4653 | function desable_fix2(handles) |
---|
[12] | 4654 | %------------------------------------------------------------------------ |
---|
[2] | 4655 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4656 | set(handles.REMOVE2,'Visible','off') |
---|
| 4657 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4658 | set(handles.vec_F4,'Visible','off') |
---|
| 4659 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4660 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4661 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4662 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4663 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4664 | set(handles.mask_fix2,'Visible','off') |
---|
| 4665 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4666 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4667 | set(handles.ref_fix2,'Visible','off') |
---|
| 4668 | set(handles.inf_sup2,'Visible','off') |
---|
| 4669 | set(handles.field_ref2,'Visible','off') |
---|
| 4670 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4671 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4672 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4673 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4674 | end |
---|
| 4675 | |
---|
[12] | 4676 | %------------------------------------------------------------------------ |
---|
[2] | 4677 | function enable_patch2(handles) |
---|
[12] | 4678 | %------------------------------------------------------------------------ |
---|
[2] | 4679 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 4680 | %set(handles.rho_patch2,'Visible','on') |
---|
| 4681 | set(handles.rho_text2,'Visible','on') |
---|
| 4682 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4683 | set(handles.thresh_text2,'Visible','on') |
---|
| 4684 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4685 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4686 | set(handles.nx_patch2,'Visible','on') |
---|
| 4687 | set(handles.ny_patch2,'Visible','on') |
---|
| 4688 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4689 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 4690 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 4691 | set(handles.grid_patch2,'Visible','on') |
---|
| 4692 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4693 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4694 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4695 | |
---|
[12] | 4696 | %------------------------------------------------------------------------ |
---|
[2] | 4697 | function desable_patch2(handles) |
---|
[12] | 4698 | %------------------------------------------------------------------------ |
---|
[2] | 4699 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4700 | set(handles.rho_patch2,'Visible','off') |
---|
| 4701 | set(handles.rho_text2,'Visible','off') |
---|
| 4702 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4703 | set(handles.thresh_text2,'Visible','off') |
---|
| 4704 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4705 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4706 | set(handles.nx_patch2,'Visible','off') |
---|
| 4707 | set(handles.ny_patch2,'Visible','off') |
---|
| 4708 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4709 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 4710 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 4711 | set(handles.grid_patch2,'Visible','off') |
---|
| 4712 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4713 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4714 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4715 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4716 | end |
---|
| 4717 | |
---|
[12] | 4718 | %------------------------------------------------------------------------ |
---|
[2] | 4719 | function enable_pair1(handles,state) |
---|
[12] | 4720 | %------------------------------------------------------------------------ |
---|
[2] | 4721 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4722 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4723 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4724 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4725 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4726 | set(handles.PAIR_txt,'Visible',state) |
---|
[12] | 4727 | %set(handles.dt_display_txt,'Visible',state) |
---|
[2] | 4728 | set(handles.dt_unit,'Visible',state) |
---|
| 4729 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4730 | |
---|
[12] | 4731 | %------------------------------------------------------------------------ |
---|
| 4732 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4733 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4734 | %------------------------------------------------------------------------ |
---|
[2] | 4735 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 4736 | par.ibx=num2str(ibx_val); |
---|
| 4737 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 4738 | par.iby=num2str(iby_val); |
---|
| 4739 | isx=get(handles.isx,'String'); |
---|
| 4740 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4741 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 4742 | isy=get(handles.isy,'String'); |
---|
| 4743 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4744 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 4745 | par.isx=get(handles.isx,'String'); |
---|
| 4746 | par.isy=get(handles.isy,'String'); |
---|
| 4747 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4748 | par.shifty=get(handles.shifty,'String'); |
---|
| 4749 | if isempty(str2num(par.isx)) |
---|
| 4750 | par.isx='41';%default |
---|
| 4751 | set(handles.isx,'String','41'); |
---|
| 4752 | end |
---|
| 4753 | if isempty(str2num(par.isy)) |
---|
| 4754 | par.isy='41'; %default |
---|
| 4755 | set(handles.isy,'String','41'); |
---|
[12] | 4756 | end |
---|
[2] | 4757 | if isempty(str2num(par.shiftx)) |
---|
| 4758 | par.shiftx='0';%default |
---|
| 4759 | set(handles.shiftx,'String','0'); |
---|
[12] | 4760 | end |
---|
[2] | 4761 | if isempty(str2num(par.shifty)) |
---|
| 4762 | par.shifty='0'; %default |
---|
| 4763 | set(handles.shifty,'String','0'); |
---|
[12] | 4764 | end |
---|
| 4765 | par.rho=get(handles.rho,'String'); |
---|
| 4766 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4767 | par.dy=get(handles.dy_civ1,'String'); |
---|
| 4768 | if isequal(str2num(par.dx),[]) |
---|
| 4769 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4770 | par.dx='0'; %just read by civ program, not used |
---|
| 4771 | else |
---|
| 4772 | par.dx='20';%default |
---|
| 4773 | set(handles.dx_civ1,'String','20'); |
---|
[2] | 4774 | end |
---|
[12] | 4775 | end |
---|
| 4776 | if isequal(str2num(par.dy),[]) |
---|
| 4777 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4778 | par.dy='0';%just read by civ program, not used |
---|
| 4779 | else |
---|
| 4780 | par.dy='20';%default |
---|
| 4781 | set(handles.dy_civ1_title,'String','20'); |
---|
[2] | 4782 | end |
---|
[12] | 4783 | end |
---|
| 4784 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4785 | par.pxcmy='1'; |
---|
[2] | 4786 | % end |
---|
[12] | 4787 | A=imread(file_ima);%read the first image to get the size |
---|
| 4788 | sizim=size(A); |
---|
| 4789 | par.npx=num2str(sizim(2)); |
---|
| 4790 | par.npy=num2str(sizim(1)); |
---|
| 4791 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4792 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4793 | par.gridflag='y'; |
---|
| 4794 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4795 | par.gridname='nogrid'; |
---|
| 4796 | par.gridflag='n'; |
---|
| 4797 | end |
---|
| 4798 | |
---|
| 4799 | %------------------------------------------------------------------------ |
---|
[2] | 4800 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4801 | %------------------------------------------------------------------------ |
---|
| 4802 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4803 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4804 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4805 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4806 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4807 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4808 | par.dy=get(handles.dy_civ2,'String'); |
---|
| 4809 | if isequal(str2num(par.dx),[]) |
---|
| 4810 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4811 | par.dx='0'; %just read by civ program, not used |
---|
| 4812 | else |
---|
| 4813 | par.dx='20';%default |
---|
| 4814 | set(handles.dx_civ2,'String','20'); |
---|
[2] | 4815 | end |
---|
[12] | 4816 | end |
---|
| 4817 | if isequal(str2num(par.dy),[]) |
---|
| 4818 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4819 | par.dy='0';%just read by civ program, not used |
---|
| 4820 | else |
---|
| 4821 | par.dy='20';%default |
---|
| 4822 | set(handles.dy_civ2,'String','20'); |
---|
[2] | 4823 | end |
---|
[12] | 4824 | end |
---|
| 4825 | par.pxcmx='1'; |
---|
| 4826 | par.pxcmy='1'; |
---|
| 4827 | A=imread(file_ima);%read the first image to get the size |
---|
| 4828 | sizim=size(A); |
---|
| 4829 | par.npx=num2str(sizim(2)); |
---|
| 4830 | par.npy=num2str(sizim(1)); |
---|
| 4831 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4832 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4833 | par.gridflag='y'; |
---|
| 4834 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4835 | par.gridname='nogrid'; |
---|
| 4836 | par.gridflag='n'; |
---|
| 4837 | end |
---|
[2] | 4838 | |
---|
[12] | 4839 | %------------------------------------------------------------------------ |
---|
| 4840 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[67] | 4841 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles,sparam) |
---|
[12] | 4842 | %------------------------------------------------------------------------ |
---|
[2] | 4843 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4844 | |
---|
| 4845 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4846 | |
---|
| 4847 | if isequal(par.Dt,'0') |
---|
| 4848 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4849 | end |
---|
[12] | 4850 | % |
---|
| 4851 | % textcmx={'############## CMX file';... |
---|
| 4852 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4853 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4854 | % 'XX' ;... |
---|
| 4855 | % ['Mask ' par.maskflag] ;... |
---|
| 4856 | % ['MaskName ' par.maskname];... |
---|
| 4857 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4858 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4859 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4860 | % ['RO ' par.rho];... |
---|
| 4861 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4862 | % 'XX 1.0';... |
---|
| 4863 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4864 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4865 | % 'XX 1';... |
---|
| 4866 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4867 | % ['Grid ' par.gridflag];... |
---|
| 4868 | % ['GridName ' par.gridname] ;... |
---|
| 4869 | % 'XX 85';... |
---|
| 4870 | % 'XX 1.0';... |
---|
| 4871 | % 'XX 1.0';... |
---|
| 4872 | % 'Hart 1';... |
---|
| 4873 | % 'DecimalShift 0';... |
---|
| 4874 | % 'Deformation 0';... |
---|
| 4875 | % 'CorrelationMin 0';... |
---|
| 4876 | % 'IntensityMin 0';... |
---|
| 4877 | % 'SeuilImage n';... |
---|
| 4878 | % 'SeuilImageValues 0 4096';... |
---|
| 4879 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4880 | % 'ImageUsedBefore null null'}; |
---|
| 4881 | % |
---|
| 4882 | % textout=char(textcmx); |
---|
[2] | 4883 | |
---|
[12] | 4884 | fid=fopen([filename '.cmx'],'w'); |
---|
| 4885 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4886 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
| 4887 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
| 4888 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4889 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4890 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
| 4891 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4892 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4893 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4894 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4895 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4896 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4897 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4898 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4899 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4900 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4901 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4902 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
| 4903 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4904 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4905 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4906 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4907 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4908 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4909 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4910 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4911 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4912 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4913 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4914 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4915 | fclose(fid); |
---|
| 4916 | |
---|
[67] | 4917 | % if sge |
---|
| 4918 | cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
| 4919 | % else |
---|
| 4920 | % cmd_CIV1=[civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4921 | % end |
---|
[12] | 4922 | if(isunix) |
---|
| 4923 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4924 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
[67] | 4925 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
[12] | 4926 | else |
---|
[67] | 4927 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log']; |
---|
[12] | 4928 | end |
---|
[2] | 4929 | |
---|
[12] | 4930 | %------------------------------------------------------------------------ |
---|
| 4931 | % --- CIV1 Unified |
---|
[2] | 4932 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
[12] | 4933 | %------------------------------------------------------------------------ |
---|
[2] | 4934 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4935 | global civ1Bin CivBin%name of the executable for civ1 calculation |
---|
[2] | 4936 | |
---|
| 4937 | civ1.image1=par.filename_ima_a; |
---|
| 4938 | civ1.image2=par.filename_ima_b; |
---|
| 4939 | civ1.imageSize_X=par.npx; |
---|
| 4940 | civ1.imageSize_Y=par.npy; |
---|
| 4941 | civ1.outputFileName=[filename '.nc']; |
---|
| 4942 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4943 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4944 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4945 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4946 | civ1.globalShift_X=par.shiftx; |
---|
| 4947 | civ1.globalShift_Y=par.shifty; |
---|
| 4948 | civ1.ro=par.rho; |
---|
| 4949 | civ1.hart='y'; |
---|
| 4950 | if isequal(par.gridflag,'y') |
---|
| 4951 | civ1.grid=par.gridname; |
---|
| 4952 | else |
---|
| 4953 | civ1.grid='n'; |
---|
| 4954 | civ1.gridSpacing_X=par.dx; |
---|
| 4955 | civ1.gridSpacing_Y=par.dy; |
---|
| 4956 | end |
---|
| 4957 | if isequal(par.maskflag,'y') |
---|
| 4958 | civ1.mask=par.maskname; |
---|
| 4959 | end |
---|
| 4960 | civ1.dt=par.Dt; |
---|
| 4961 | civ1.unit='pixel'; |
---|
| 4962 | civ1.absolut_time_T0=par.T0; |
---|
| 4963 | civ1.pixcmx=par.pxcmx; |
---|
| 4964 | civ1.pixcmy=par.pxcmy; |
---|
| 4965 | civ1.convectFlow='n'; |
---|
| 4966 | |
---|
| 4967 | xml_civ1_parameters=civ1; |
---|
[12] | 4968 | |
---|
| 4969 | %------------------------------------------------------------------------ |
---|
| 4970 | % --- CIV2 Unified |
---|
[2] | 4971 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
[12] | 4972 | %------------------------------------------------------------------------ |
---|
[2] | 4973 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4974 | global civ2Bin CivBin%name of the executable for civ1 calculation |
---|
[2] | 4975 | |
---|
| 4976 | civ2.image1=par.filename_ima_a; |
---|
| 4977 | civ2.image2=par.filename_ima_b; |
---|
| 4978 | civ2.imageSize_X=par.npx; |
---|
| 4979 | civ2.imageSize_Y=par.npy; |
---|
| 4980 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4981 | civ2.outputFileName=[filename '.nc']; |
---|
| 4982 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4983 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4984 | civ2.ro=par.rho; |
---|
| 4985 | %civ2.decimalShift=par.decimal; |
---|
| 4986 | %civ2.deformation=par.deformation; |
---|
| 4987 | if isequal(par.decimal,'1') |
---|
| 4988 | civ2.decimalShift='y'; |
---|
| 4989 | else |
---|
| 4990 | civ2.decimalShift='n'; |
---|
| 4991 | end |
---|
| 4992 | if isequal(par.deformation,'1') |
---|
| 4993 | civ2.deformation='y'; |
---|
| 4994 | else |
---|
| 4995 | civ2.deformation='n'; |
---|
| 4996 | end |
---|
| 4997 | if isequal(par.gridflag,'y') |
---|
| 4998 | civ2.grid=par.gridname; |
---|
| 4999 | else |
---|
| 5000 | civ2.grid='n'; |
---|
| 5001 | civ2.gridSpacing_X=par.dx; |
---|
| 5002 | civ2.gridSpacing_Y=par.dy; |
---|
| 5003 | end |
---|
| 5004 | civ2.gridSpacing_X='10'; |
---|
| 5005 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 5006 | if isequal(par.maskflag,'y') |
---|
| 5007 | civ2.mask=par.maskname; |
---|
| 5008 | else |
---|
| 5009 | civ2.mask='n'; |
---|
| 5010 | end |
---|
| 5011 | civ2.dt=par.Dt; |
---|
| 5012 | civ2.unit='pixel'; |
---|
| 5013 | civ2.absolut_time_T0=par.T0; |
---|
| 5014 | civ2.pixcmx=par.pxcmx; |
---|
| 5015 | civ2.pixcmy=par.pxcmy; |
---|
| 5016 | civ2.convectFlow='n'; |
---|
| 5017 | civ2.pixcmx=par.pxcmx; |
---|
| 5018 | civ2.pixcmy=par.pxcmy; |
---|
| 5019 | civ2.convectFlow='n'; |
---|
| 5020 | |
---|
[12] | 5021 | %------------------------------------------------------------------------ |
---|
| 5022 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[67] | 5023 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par,sparam) |
---|
[12] | 5024 | %------------------------------------------------------------------------ |
---|
[2] | 5025 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 5026 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[2] | 5027 | if isequal(par.Dt,'0') |
---|
| 5028 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 5029 | end |
---|
[12] | 5030 | textcmx=['############## CMX file' '\n'... |
---|
| 5031 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 5032 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 5033 | 'XX' '\n'... |
---|
| 5034 | ['Mask ' par.maskflag] '\n'... |
---|
| 5035 | ['MaskName ' par.maskname] '\n'... |
---|
| 5036 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
| 5037 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 5038 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 5039 | ['RO ' par.rho] '\n'... |
---|
| 5040 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 5041 | 'XX 1.0' '\n'... |
---|
| 5042 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 5043 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 5044 | 'XX 1' '\n'... |
---|
| 5045 | ['ShiftXY 0 0'] '\n'... |
---|
| 5046 | ['Grid ' par.gridflag] '\n'... |
---|
| 5047 | ['GridName ' par.gridname] '\n'... |
---|
| 5048 | 'XX 85' '\n'... |
---|
| 5049 | 'XX 1.0' '\n'... |
---|
| 5050 | 'XX 1.0' '\n'... |
---|
| 5051 | 'Hart 1' '\n'... |
---|
| 5052 | ['DecimalShift ' par.decimal] '\n'... |
---|
| 5053 | ['Deformation ' par.deformation] '\n'... |
---|
| 5054 | 'CorrelationMin 0' '\n'... |
---|
| 5055 | 'IntensityMin 0' '\n'... |
---|
| 5056 | 'SeuilImage n' '\n'... |
---|
| 5057 | 'SeuilImageValues 0 4096' '\n'... |
---|
| 5058 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 5059 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 5060 | textout=char(textcmx); |
---|
| 5061 | fid=fopen([filename_cmx '2'],'w'); |
---|
| 5062 | fprintf(fid,textout); |
---|
| 5063 | fclose(fid) |
---|
[67] | 5064 | % if sge |
---|
| 5065 | cmd_CIV2=[sparam.Civ2Bin ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 5066 | % else |
---|
| 5067 | % cmd_CIV2=[civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 5068 | % end |
---|
[2] | 5069 | |
---|
[12] | 5070 | %------------------------------------------------------------------------ |
---|
[2] | 5071 | % --- Executes on button press in HELP. |
---|
| 5072 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 5073 | %------------------------------------------------------------------------ |
---|
[2] | 5074 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 5075 | pathelp=fileparts(path_to_uvmat); |
---|
[45] | 5076 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html') |
---|
[36] | 5077 | 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] | 5078 | else |
---|
[36] | 5079 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 5080 | web([helpfile '#civ']) |
---|
[2] | 5081 | end |
---|
| 5082 | |
---|
[12] | 5083 | %------------------------------------------------------------------------ |
---|
[2] | 5084 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 5085 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 5086 | %------------------------------------------------------------------------ |
---|
[2] | 5087 | %num is the view number needed for an avi movie |
---|
[45] | 5088 | switch type_ima |
---|
| 5089 | case 'movie' |
---|
| 5090 | A=read(movieobject,num); |
---|
| 5091 | case 'avi' |
---|
[57] | 5092 | mov=aviread(filename,num); |
---|
| 5093 | A=frame2im(mov(1)); |
---|
[45] | 5094 | case 'multimage' |
---|
| 5095 | A=imread(filename,num); |
---|
| 5096 | case 'image' |
---|
| 5097 | A=imread(filename); |
---|
| 5098 | end |
---|
| 5099 | siz=size(A); |
---|
| 5100 | if length(siz)==3;%color images |
---|
[2] | 5101 | A=sum(double(A),3); |
---|
| 5102 | A=uint16(A); |
---|
| 5103 | end |
---|
| 5104 | |
---|
[12] | 5105 | %------------------------------------------------------------------------ |
---|
[2] | 5106 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 5107 | %------------------------------------------------------------------------ |
---|
[2] | 5108 | mode_list=get(handles.mode,'String'); |
---|
| 5109 | mode_value=get(handles.mode,'Value'); |
---|
| 5110 | mode=mode_list{mode_value}; |
---|
[45] | 5111 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 5112 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[45] | 5113 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 5114 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5115 | end |
---|
| 5116 | |
---|
[12] | 5117 | %------------------------------------------------------------------------ |
---|
[2] | 5118 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 5119 | %------------------------------------------------------------------------ |
---|
[2] | 5120 | mode_list=get(handles.mode,'String'); |
---|
| 5121 | mode_value=get(handles.mode,'Value'); |
---|
| 5122 | mode=mode_list{mode_value}; |
---|
[45] | 5123 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 5124 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5125 | end |
---|
[45] | 5126 | if isequal(mode,'series(Dj)') || ... |
---|
| 5127 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 5128 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5129 | end |
---|
[12] | 5130 | |
---|
| 5131 | %------------------------------------------------------------------------ |
---|
[2] | 5132 | % --- Executes on button press in compare. |
---|
| 5133 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 5134 | %------------------------------------------------------------------------ |
---|
[2] | 5135 | test=get(handles.compare,'Value'); |
---|
| 5136 | if test==2 || test==3 |
---|
| 5137 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5138 | browse=get(handles.browse_root,'Userdata'); |
---|
| 5139 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 5140 | set(handles.browse_root,'UserData',browse); |
---|
| 5141 | set(handles.sub_txt,'Visible','on') |
---|
| 5142 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
| 5143 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 5144 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 5145 | set(handles.mode,'Visible','off') |
---|
| 5146 | if test==2 |
---|
| 5147 | set(handles.mode,'Visible','off') |
---|
| 5148 | else |
---|
| 5149 | set(handles.mode,'Visible','on') |
---|
| 5150 | end |
---|
| 5151 | |
---|
| 5152 | % open an image file with the browser |
---|
| 5153 | ind_opening=1;%default |
---|
| 5154 | browse.incr_pair=[0 0]; %default |
---|
| 5155 | oldfile=get(handles.displ_filebase,'String'); |
---|
| 5156 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 5157 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 5158 | '*.*', 'All Files (*.*)'}; |
---|
| 5159 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 5160 | fileinput=[PathName FileName];%complete file name |
---|
| 5161 | sizf=size(fileinput); |
---|
| 5162 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5163 | [path,name,ext]=fileparts(fileinput); |
---|
| 5164 | [path1]=fileparts(filebase); |
---|
| 5165 | if ~strcmp(path1,path) |
---|
| 5166 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
| 5167 | return |
---|
| 5168 | end |
---|
| 5169 | set(handles.displ_filebase2,'String',name); |
---|
| 5170 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 5171 | browse=get(handles.browse_root,'UserData'); |
---|
| 5172 | browse.nom_type_ima_1=nom_type; |
---|
| 5173 | set(handles.browse_root,'UserData',browse) |
---|
| 5174 | |
---|
| 5175 | %check image extension |
---|
| 5176 | if ~strcmp(ext,get(handles.ext_ima,'String')) |
---|
| 5177 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 5178 | return |
---|
| 5179 | end |
---|
| 5180 | |
---|
| 5181 | %check image size |
---|
| 5182 | A=imread(fileinput); |
---|
| 5183 | npxy=get(handles.ext_ima,'UserData'); |
---|
| 5184 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 5185 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 5186 | return |
---|
| 5187 | end |
---|
| 5188 | else |
---|
| 5189 | set(handles.mode,'Visible','on') |
---|
| 5190 | set(handles.displ_filebase2,'Visible','Off'); |
---|
| 5191 | set(handles.sub_txt,'Visible','off') |
---|
| 5192 | set(handles.displ_filebase2,'String',[]); |
---|
| 5193 | mode_store=get(handles.compare,'UserData'); |
---|
| 5194 | set(handles.mode,'String',mode_store) |
---|
| 5195 | set(handles.test_stereo1,'Value',0) |
---|
| 5196 | set(handles.test_stereo2,'Value',0) |
---|
| 5197 | end |
---|
| 5198 | mode_Callback(hObject, eventdata, handles) |
---|
| 5199 | |
---|
[12] | 5200 | %------------------------------------------------------------------------ |
---|
[2] | 5201 | % --- Executes on button press in get_ref_fix1. |
---|
| 5202 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5203 | %------------------------------------------------------------------------ |
---|
[2] | 5204 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5205 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5206 | {'*.nc', ' (*.nc)'; |
---|
| 5207 | '*.nc', 'netcdf files '; ... |
---|
| 5208 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5209 | 'Pick a file',filebase); |
---|
| 5210 | |
---|
| 5211 | fileinput=[PathName FileName]; |
---|
| 5212 | sizf=size(fileinput); |
---|
| 5213 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5214 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5215 | ref.filebase=fullfile(Path,File); |
---|
| 5216 | ref.num_a=stra2num(str_a); |
---|
| 5217 | ref.num_b=stra2num(str_b); |
---|
| 5218 | ref.num1=str2num(field_count); |
---|
| 5219 | ref.num2=str2num(str2); |
---|
| 5220 | browse=[];%initialisation |
---|
| 5221 | if ~isequal(ref.ext,'.nc') |
---|
| 5222 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5223 | return |
---|
| 5224 | end |
---|
| 5225 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5226 | set(handles.ref_fix1,'UserData',ref) |
---|
| 5227 | menu_field{1}='civ1'; |
---|
| 5228 | Data=nc2struct(fileinput,[]); |
---|
[45] | 5229 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 5230 | menu_field{2}='filter1'; |
---|
| 5231 | end |
---|
[45] | 5232 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 5233 | menu_field{3}='civ2'; |
---|
| 5234 | end |
---|
[45] | 5235 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 5236 | menu_field{4}='filter2'; |
---|
| 5237 | end |
---|
| 5238 | set(handles.field_ref1,'String',menu_field); |
---|
| 5239 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 5240 | set(handles.inf_sup1,'Value',2); |
---|
| 5241 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 5242 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 5243 | |
---|
| 5244 | %------------------------------------------------------------------------ |
---|
[2] | 5245 | % --- Executes on button press in get_ref_fix2. |
---|
| 5246 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5247 | %------------------------------------------------------------------------ |
---|
[2] | 5248 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 5249 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5250 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5251 | {'*.nc', ' (*.nc)'; |
---|
| 5252 | '*.nc', 'netcdf files '; ... |
---|
| 5253 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5254 | 'Pick a file',filebase); |
---|
| 5255 | fileinput=[PathName FileName]; |
---|
| 5256 | sizf=size(fileinput); |
---|
[45] | 5257 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 5258 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5259 | ref.filebase=fullfile(Path,File); |
---|
| 5260 | ref.num_a=stra2num(str_a); |
---|
| 5261 | ref.num_b=stra2num(str_b); |
---|
| 5262 | ref.num1=str2num(field_count); |
---|
| 5263 | ref.num2=str2num(str2); |
---|
| 5264 | browse=[];%initialisation |
---|
| 5265 | if ~isequal(ref.ext,'.nc') |
---|
| 5266 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5267 | return |
---|
| 5268 | end |
---|
| 5269 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5270 | set(handles.ref_fix2,'UserData',ref) |
---|
| 5271 | menu_field{1}='civ1'; |
---|
| 5272 | Data=nc2struct(fileinput,[]); |
---|
| 5273 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5274 | menu_field{2}='filter1'; |
---|
| 5275 | end |
---|
| 5276 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5277 | menu_field{3}='civ2'; |
---|
| 5278 | end |
---|
| 5279 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5280 | menu_field{4}='filter2'; |
---|
| 5281 | end |
---|
| 5282 | set(handles.field_ref2,'String',menu_field); |
---|
| 5283 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 5284 | set(handles.inf_sup2,'Value',2); |
---|
| 5285 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 5286 | set(handles.ref_fix2,'Enable','on') |
---|
| 5287 | set(handles.ref_fix2,'Visible','on') |
---|
| 5288 | set(handles.field_ref2,'Visible','on') |
---|
| 5289 | else |
---|
| 5290 | set(handles.ref_fix2,'Visible','off') |
---|
| 5291 | set(handles.field_ref2,'Visible','off') |
---|
| 5292 | end |
---|
| 5293 | |
---|
[12] | 5294 | %------------------------------------------------------------------------ |
---|
[2] | 5295 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5296 | %------------------------------------------------------------------------ |
---|
| 5297 | set(handles.inf_sup1,'Value',1); |
---|
| 5298 | set(handles.field_ref1,'Value',1) |
---|
| 5299 | set(handles.field_ref1,'String',{' '}) |
---|
| 5300 | set(handles.ref_fix1,'UserData',[]); |
---|
| 5301 | set(handles.ref_fix1,'String',''); |
---|
| 5302 | set(handles.thresh_vel1,'String','0'); |
---|
[2] | 5303 | |
---|
[12] | 5304 | %------------------------------------------------------------------------ |
---|
[2] | 5305 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5306 | %------------------------------------------------------------------------ |
---|
| 5307 | set(handles.inf_sup2,'Value',1); |
---|
| 5308 | set(handles.field_ref2,'Value',1) |
---|
| 5309 | set(handles.field_ref2,'String',{' '}) |
---|
| 5310 | set(handles.ref_fix2,'UserData',[]); |
---|
| 5311 | set(handles.ref_fix2,'String',''); |
---|
| 5312 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 5313 | |
---|
[12] | 5314 | %------------------------------------------------------------------------ |
---|
[2] | 5315 | % transform letters to numbers |
---|
| 5316 | function numres=stra2num(str) |
---|
[12] | 5317 | %------------------------------------------------------------------------ |
---|
[2] | 5318 | numres=double(str)-96; |
---|
| 5319 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 5320 | numres=str2num(str); |
---|
| 5321 | end |
---|
| 5322 | |
---|
[12] | 5323 | %------------------------------------------------------------------------ |
---|
[2] | 5324 | % --- Executes on button press in test_stereo1. |
---|
| 5325 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 5326 | %------------------------------------------------------------------------ |
---|
[2] | 5327 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 5328 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 5329 | set(handles.rho_patch1,'Visible','on') |
---|
| 5330 | else |
---|
| 5331 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 5332 | set(handles.rho_patch1,'Visible','off') |
---|
| 5333 | end |
---|
| 5334 | |
---|
[12] | 5335 | %------------------------------------------------------------------------ |
---|
[2] | 5336 | % --- Executes on button press in test_stereo2. |
---|
| 5337 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 5338 | %------------------------------------------------------------------------ |
---|
[2] | 5339 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 5340 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 5341 | set(handles.rho_patch2,'Visible','on') |
---|
| 5342 | else |
---|
| 5343 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 5344 | set(handles.rho_patch2,'Visible','off') |
---|
| 5345 | end |
---|
| 5346 | |
---|
[12] | 5347 | %------------------------------------------------------------------------ |
---|
[2] | 5348 | % --- Executes on button press in ImaThreshold. |
---|
| 5349 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 5350 | %------------------------------------------------------------------------ |
---|
[2] | 5351 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 5352 | set(handles.MinIma,'Visible','on') |
---|
| 5353 | set(handles.MaxIma,'Visible','on') |
---|
| 5354 | else |
---|
| 5355 | set(handles.MinIma,'Visible','off') |
---|
| 5356 | set(handles.MaxIma,'Visible','off') |
---|
| 5357 | end |
---|
| 5358 | |
---|
[12] | 5359 | %------------------------------------------------------------------------ |
---|
[2] | 5360 | % --- Executes on button press in ImaThreshold2. |
---|
| 5361 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 5362 | %------------------------------------------------------------------------ |
---|
[2] | 5363 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 5364 | set(handles.MinIma2,'Visible','on') |
---|
| 5365 | set(handles.MaxIma2,'Visible','on') |
---|
| 5366 | else |
---|
| 5367 | set(handles.MinIma2,'Visible','off') |
---|
| 5368 | set(handles.MaxIma2,'Visible','off') |
---|
| 5369 | end |
---|
| 5370 | |
---|