[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 | |
---|
[71] | 24 | % Last Modified by GUIDE v2.5 27-Mar-2010 13:41:11 |
---|
[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. |
---|
[71] | 46 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
---|
[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) |
---|
[84] | 53 | global patch_newBin %=1 if new 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) |
---|
| 67 | ext=[]; |
---|
| 68 | testall=0; |
---|
| 69 | browse=[]; |
---|
[71] | 70 | %default input parameters: |
---|
| 71 | num1=1; % set of field i numbers |
---|
| 72 | num2=2; % set of field i numbers |
---|
| 73 | num_a=1; % set of field j numbers (fields a) |
---|
| 74 | num_b=1; % second set of field j numbers (fields b) |
---|
| 75 | subdir='A'; % subdir for the netcdf result files |
---|
| 76 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
[2] | 77 | %load the initial parameters if the interface is started from uvmat |
---|
[71] | 78 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 79 | filebase=param.RootName; |
---|
| 80 | nom_type_read=param.NomType; |
---|
| 81 | num1=param.num1; |
---|
| 82 | num2=param.num2; |
---|
| 83 | num_a=param.num_a; |
---|
| 84 | num_b=param.num_b; |
---|
| 85 | subdir=param.SubDir; |
---|
| 86 | ind_opening=param.IndOpening; |
---|
| 87 | ext=param.ImaExt; |
---|
[2] | 88 | end |
---|
[71] | 89 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||... |
---|
| 90 | strcmp(lower(ext),'.avi'));%if an image file has been opened by uvmat |
---|
| 91 | set(handles.ImaExt,'String',ext) |
---|
[2] | 92 | if exist('nom_type_read','var') |
---|
| 93 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 94 | end |
---|
| 95 | elseif isequal(ext,'.nc') |
---|
| 96 | if exist('nom_type_read','var') |
---|
| 97 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 98 | end |
---|
| 99 | end |
---|
[71] | 100 | set(handles.RootName,'String',filebase); |
---|
[2] | 101 | set(handles.ImaDoc,'UserData',testall); |
---|
| 102 | set(handles.ImaDoc,'String',ext) |
---|
| 103 | |
---|
| 104 | %read names of the .exe file to adjust the interface according to |
---|
[71] | 105 | %available binaries |
---|
[2] | 106 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 107 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 108 | errormsg=[];%default error message |
---|
[54] | 109 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 110 | if exist(xmlfile,'file') |
---|
| 111 | try |
---|
| 112 | t=xmltree(xmlfile); |
---|
| 113 | sparam=convert(t); |
---|
| 114 | catch |
---|
[94] | 115 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
[2] | 116 | end |
---|
[54] | 117 | else |
---|
| 118 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[2] | 119 | end |
---|
[71] | 120 | |
---|
[45] | 121 | if ~isempty(errormsg) |
---|
| 122 | msgbox_uvmat('ERROR',errormsg); |
---|
| 123 | end |
---|
[71] | 124 | % patch_newBin=''; |
---|
| 125 | test_batch=0;%default: ,no batch mode available |
---|
| 126 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 127 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
[2] | 128 | end |
---|
| 129 | if test_batch==0 |
---|
[84] | 130 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
[2] | 131 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 132 | end |
---|
[94] | 133 | if isfield(sparam.RunParam,'CivBin') |
---|
| 134 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
| 135 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
| 136 | end |
---|
[97] | 137 | else |
---|
| 138 | sparam.RunParam.CivBin=''; |
---|
[94] | 139 | end |
---|
[96] | 140 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
[2] | 141 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 142 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 143 | |
---|
| 144 | %initiate advised operations |
---|
| 145 | if isequal(ind_opening,[]) |
---|
| 146 | ind_opening=1; % default |
---|
| 147 | end |
---|
| 148 | % set default operation options |
---|
| 149 | enable_civ1(handles,'off') |
---|
| 150 | enable_civ2(handles,'off') |
---|
| 151 | enable_pair1(handles,'on') |
---|
| 152 | enable_fix1(handles,'off') |
---|
| 153 | desable_patch1(handles) |
---|
| 154 | desable_fix2(handles) |
---|
| 155 | desable_patch2(handles) |
---|
| 156 | set(handles.CIV1,'Value',0) |
---|
| 157 | set(handles.FIX1,'Value',0) |
---|
| 158 | set(handles.PATCH1,'Value',0) |
---|
| 159 | set(handles.CIV2,'Value',0) |
---|
| 160 | set(handles.FIX2,'Value',0) |
---|
| 161 | set(handles.PATCH2,'Value',0) |
---|
| 162 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 163 | if isequal(ind_opening,1) |
---|
| 164 | set(handles.CIV1,'Value',1) |
---|
| 165 | enable_civ1(handles,'on') |
---|
| 166 | elseif isequal(ind_opening,2) |
---|
| 167 | set(handles.FIX1,'Value',1) |
---|
| 168 | enable_fix1(handles,'on') |
---|
| 169 | elseif isequal(ind_opening,3) |
---|
| 170 | set(handles.PATCH1,'Value',1) |
---|
| 171 | enable_patch1(handles) |
---|
| 172 | elseif isequal(ind_opening,4) |
---|
| 173 | set(handles.CIV2,'Value',1) |
---|
| 174 | enable_civ2(handles,1) |
---|
| 175 | elseif isequal(ind_opening,5) |
---|
| 176 | set(handles.FIX2,'Value',1) |
---|
| 177 | enable_fix2(handles) |
---|
| 178 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 179 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 180 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 181 | enable_pair1(handles,'off') |
---|
| 182 | elseif isequal(ind_opening,6) |
---|
| 183 | set(handles.PATCH2,'Value',1) |
---|
| 184 | enable_patch2(handles) |
---|
| 185 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 186 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 187 | enable_pair1(handles,'off') |
---|
| 188 | end |
---|
| 189 | |
---|
| 190 | % set the range of fields (1:1 by default) and selected pair |
---|
[89] | 191 | if isnan(num2)||isequal(num2,num1) |
---|
[2] | 192 | num_ref_i=num1; |
---|
| 193 | else |
---|
| 194 | num_ref_i=floor((num1+num2)/2); |
---|
| 195 | browse.incr_pair(1)=num2-num1; |
---|
| 196 | browse.incr_pair(2)=0; |
---|
| 197 | end |
---|
[89] | 198 | if isnan(num_b)||isequal(num_a,num_b) |
---|
| 199 | if isnan(num_a) |
---|
[2] | 200 | num_ref_j=1; |
---|
| 201 | else |
---|
| 202 | num_ref_j=num_a; |
---|
| 203 | end |
---|
| 204 | else |
---|
| 205 | num_ref_j=floor((num_a+num_b)/2); |
---|
| 206 | browse.incr_pair(2)=num_b-num_a; |
---|
| 207 | end |
---|
| 208 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 209 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 210 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 211 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 212 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 213 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[71] | 214 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 215 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
[2] | 216 | set(handles.browse_root,'UserData',browse); |
---|
[71] | 217 | if exist('param','var')%varargin the interface is opened from uvmat |
---|
| 218 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 219 | end |
---|
| 220 | |
---|
| 221 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 222 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 223 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 224 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 225 | |
---|
[12] | 226 | %------------------------------------------------------------------------ |
---|
[2] | 227 | % --- Outputs from this function are returned to the command line. |
---|
| 228 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 229 | %------------------------------------------------------------------------ |
---|
[2] | 230 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 231 | % hObject handle to figure |
---|
| 232 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 233 | % handles structure with handles and user data (see GUIDATA) |
---|
| 234 | % Get default command line output from handles structure |
---|
| 235 | varargout{1} = handles.output; |
---|
| 236 | |
---|
[12] | 237 | %------------------------------------------------------------------------ |
---|
[2] | 238 | % --- Executes on button press in browse_root. |
---|
| 239 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 240 | %------------------------------------------------------------------------ |
---|
[2] | 241 | %get the input file properties |
---|
[71] | 242 | filebase=get(handles.RootName,'String'); |
---|
[2] | 243 | oldfile=''; %default |
---|
[39] | 244 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 245 | dir_perso=prefdir; |
---|
| 246 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 247 | display(profil_perso) |
---|
| 248 | if exist(profil_perso,'file') |
---|
| 249 | h=load (profil_perso); |
---|
| 250 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 251 | oldfile=h.filebase; |
---|
| 252 | end |
---|
| 253 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 254 | oldfile=h.RootPath; |
---|
| 255 | end |
---|
| 256 | end |
---|
| 257 | else |
---|
| 258 | oldfile=filebase; |
---|
| 259 | end |
---|
| 260 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 261 | ind_opening=1;%default |
---|
| 262 | browse.incr_pair=[0 0]; %default |
---|
| 263 | if testall |
---|
| 264 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 265 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 266 | else % menu selecting only .civ or .avi files |
---|
| 267 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 268 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 269 | '*.*', 'All Files (*.*)'}; |
---|
| 270 | end |
---|
| 271 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 272 | fileinput=[PathName FileName];%complete file name |
---|
| 273 | sizf=size(fileinput); |
---|
| 274 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 275 | [path,name,ext]=fileparts(fileinput); |
---|
| 276 | testeditxml=0; |
---|
| 277 | if isequal(ext,'.xml') |
---|
| 278 | testeditxml=1; |
---|
| 279 | t_browse=xmltree(fileinput); |
---|
| 280 | head_element=get(t_browse,1); |
---|
[45] | 281 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 282 | testeditxml=0; |
---|
| 283 | end |
---|
| 284 | end |
---|
[45] | 285 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[2] | 286 | heditxml=editxml({fileinput}); |
---|
| 287 | set(heditxml,'Tag','browser') |
---|
| 288 | waitfor(heditxml,'Tag','idle') |
---|
| 289 | if ~ishandle(heditxml) |
---|
| 290 | return |
---|
| 291 | end |
---|
| 292 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 293 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 294 | fileinput=get(attr,'UserData'); |
---|
| 295 | if ~exist(fileinput,'file') |
---|
| 296 | return |
---|
| 297 | end |
---|
| 298 | end |
---|
[82] | 299 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 300 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 301 | num_i1=str2double(str1); |
---|
| 302 | if isnan(num_i1),num_i1=1;end |
---|
| 303 | num_i2=str2double(str2); |
---|
| 304 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 305 | num_j1=stra2num(str_a); |
---|
[89] | 306 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 307 | num_j2=stra2num(str_b); |
---|
[89] | 308 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 309 | if isequal(get(handles.compare,'Value'),1) |
---|
| 310 | browse=[];%initialisation |
---|
| 311 | else |
---|
| 312 | browse=get(handles.browse_root,'UserData'); |
---|
| 313 | end |
---|
[94] | 314 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||... |
---|
[45] | 315 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
[71] | 316 | set(handles.ImaExt,'String',ext) |
---|
[2] | 317 | browse.nom_type_ima=nom_type; |
---|
[45] | 318 | browse.field_count=num_i1; |
---|
[2] | 319 | end |
---|
| 320 | set(handles.ImaDoc,'String',ext); |
---|
| 321 | |
---|
| 322 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 323 | if isequal(ext,'.nc') |
---|
| 324 | browse.nom_type_nc=nom_type; |
---|
| 325 | ind_opening=2;% propose 'fix' as the default option |
---|
| 326 | Data=nc2struct(fileinput,[]); |
---|
| 327 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
| 328 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 329 | ind_opening=3; |
---|
| 330 | end |
---|
| 331 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 332 | ind_opening=4; |
---|
| 333 | end |
---|
| 334 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 335 | ind_opening=5; |
---|
| 336 | end |
---|
| 337 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 338 | ind_opening=6; |
---|
| 339 | end |
---|
| 340 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 341 | else |
---|
| 342 | ind_opening=3; %GUI used only for patch |
---|
| 343 | testciv=0; |
---|
| 344 | end |
---|
| 345 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 346 | set(handles.subdir_civ2,'String',subdir); |
---|
| 347 | browse.testciv=testciv; |
---|
| 348 | browse.ind_opening=ind_opening; |
---|
| 349 | end |
---|
[71] | 350 | set(handles.RootName,'String',filebase); |
---|
[2] | 351 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 352 | if ~isempty(num_i1) |
---|
[82] | 353 | ref_i=num_i1; |
---|
[45] | 354 | if ~isempty(num_i2) |
---|
| 355 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 356 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 357 | browse.incr_pair(2)=0; |
---|
| 358 | end |
---|
| 359 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 360 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 361 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 362 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 363 | end |
---|
[45] | 364 | if isempty(num_j1) |
---|
[2] | 365 | set(handles.ref_j,'String','1'); |
---|
[71] | 366 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 367 | else |
---|
[45] | 368 | ref_j=num_j1; |
---|
| 369 | if ~isempty(num_j2) |
---|
| 370 | ref_j=floor((num_j1+num_j2)/2); |
---|
| 371 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 372 | end |
---|
| 373 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 374 | set(handles.last_j,'String',num2str(ref_j)); |
---|
| 375 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[71] | 376 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 377 | end |
---|
| 378 | |
---|
| 379 | % set default operation options |
---|
| 380 | enable_civ1(handles,'off') |
---|
| 381 | enable_civ2(handles,'off') |
---|
| 382 | enable_pair1(handles,'on') |
---|
| 383 | enable_fix1(handles,'off') |
---|
| 384 | desable_patch1(handles) |
---|
| 385 | desable_fix2(handles) |
---|
| 386 | desable_patch2(handles) |
---|
| 387 | set(handles.CIV1,'Value',0) |
---|
| 388 | set(handles.FIX1,'Value',0) |
---|
| 389 | set(handles.PATCH1,'Value',0) |
---|
| 390 | set(handles.CIV2,'Value',0) |
---|
| 391 | set(handles.FIX2,'Value',0) |
---|
| 392 | set(handles.PATCH2,'Value',0) |
---|
| 393 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 394 | if isequal(ind_opening,1) |
---|
| 395 | set(handles.CIV1,'Value',1) |
---|
| 396 | enable_civ1(handles,'on') |
---|
| 397 | elseif isequal(ind_opening,2) |
---|
| 398 | set(handles.FIX1,'Value',1) |
---|
| 399 | enable_fix1(handles,'on') |
---|
| 400 | elseif isequal(ind_opening,3) |
---|
| 401 | set(handles.PATCH1,'Value',1) |
---|
| 402 | enable_patch1(handles) |
---|
| 403 | elseif isequal(ind_opening,4) |
---|
| 404 | set(handles.CIV2,'Value',1) |
---|
| 405 | enable_civ2(handles,1) |
---|
| 406 | elseif isequal(ind_opening,5) |
---|
| 407 | enable_pair1(handles,'off') |
---|
| 408 | set(handles.FIX2,'Value',1) |
---|
| 409 | enable_fix2(handles) |
---|
| 410 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 411 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 412 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 413 | elseif isequal(ind_opening,6) |
---|
| 414 | enable_pair1(handles,'off') |
---|
| 415 | set(handles.PATCH2,'Value',1) |
---|
| 416 | enable_patch2(handles) |
---|
| 417 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 418 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 419 | end |
---|
| 420 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 421 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 422 | set(handles.ImaDoc,'UserData',testall); |
---|
| 423 | |
---|
[71] | 424 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 425 | |
---|
[12] | 426 | %------------------------------------------------------------------------ |
---|
[2] | 427 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 428 | %------------------------------------------------------------------------ |
---|
[71] | 429 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 430 | |
---|
[12] | 431 | %------------------------------------------------------------------------ |
---|
[54] | 432 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 433 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 434 | %------------------------------------------------------------------------ |
---|
[2] | 435 | set(handles.compare,'Visible','on') |
---|
[71] | 436 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 437 | nom_type_ima=[];%default |
---|
| 438 | field_count=1;%default |
---|
| 439 | nom_type_nc=[]; |
---|
| 440 | time=[]; |
---|
[71] | 441 | TimeUnit='frame'; %default |
---|
| 442 | CoordUnit='px';%default |
---|
[2] | 443 | pxcmx_search=[];%default |
---|
| 444 | pxcmy_search=[];%default |
---|
[71] | 445 | filebase=get(handles.RootName,'String'); |
---|
[2] | 446 | |
---|
| 447 | ext=get(handles.ImaDoc,'String'); |
---|
| 448 | browse=get(handles.browse_root,'UserData');%default |
---|
| 449 | if ~isempty(browse) |
---|
| 450 | if isfield(browse,'nom_type_ima') |
---|
[12] | 451 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[2] | 452 | end |
---|
| 453 | if isfield(browse,'field_count') |
---|
[12] | 454 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
[2] | 455 | end |
---|
| 456 | end |
---|
| 457 | |
---|
| 458 | %default first_i and j and increments |
---|
| 459 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
[12] | 460 | if isempty(first_i)|| first_i < 1 |
---|
[2] | 461 | first_i=1; %default first_i |
---|
| 462 | end |
---|
| 463 | last_i=str2num(get(handles.last_i,'String')); |
---|
[12] | 464 | if isempty(last_i)|| last_i < first_i |
---|
[2] | 465 | last_i=first_i; %default last_i |
---|
| 466 | end |
---|
| 467 | first_j=str2num(get(handles.first_j,'String')); |
---|
[39] | 468 | if isempty(first_j)|| first_j < 1 |
---|
[2] | 469 | first_j=1; %default first_j |
---|
| 470 | end |
---|
| 471 | last_j=str2num(get(handles.last_j,'String')); |
---|
[39] | 472 | if isempty(last_j)|| last_j < first_j |
---|
[2] | 473 | last_j=first_j; %default last_j |
---|
| 474 | end |
---|
| 475 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
[39] | 476 | if isempty(incr_i) || incr_i < 1; |
---|
[2] | 477 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 478 | end |
---|
| 479 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
[39] | 480 | if isempty(incr_j) || incr_j < 1; |
---|
[2] | 481 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 482 | end |
---|
| 483 | dt=[];%default |
---|
| 484 | testmode=0;%default |
---|
| 485 | nbfield=[]; %default |
---|
| 486 | nburst=[];%default |
---|
| 487 | pxcmx=1; |
---|
| 488 | pxcmy=1; |
---|
| 489 | |
---|
| 490 | %look for an image documentation file |
---|
| 491 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
| 492 | if exist([filebase '.xml'],'file') |
---|
| 493 | ext='.xml'; |
---|
| 494 | elseif exist([filebase '.civxml'],'file') |
---|
| 495 | ext='.civxml'; |
---|
| 496 | elseif exist([filebase '.civ'],'file') |
---|
| 497 | ext='.civ'; |
---|
| 498 | elseif exist([filebase '.avi'],'file') |
---|
| 499 | ext='.avi'; |
---|
| 500 | elseif exist([filebase '.AVI'],'file') |
---|
| 501 | ext='.AVI'; |
---|
| 502 | end |
---|
| 503 | set(handles.ImaDoc,'String',ext) |
---|
| 504 | end |
---|
| 505 | |
---|
| 506 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 507 | mode=''; %default |
---|
| 508 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 509 | drawnow |
---|
[12] | 510 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
[2] | 511 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 512 | set(handles.ref_j,'Visible','On') |
---|
[12] | 513 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
[2] | 514 | set(handles.ref_j,'Visible','Off') |
---|
| 515 | else |
---|
| 516 | set(handles.ref_i,'Visible','Off') |
---|
| 517 | set(handles.ref_j,'Visible','Off') |
---|
| 518 | end |
---|
[12] | 519 | testima_xml=0; |
---|
[2] | 520 | if isequal(ext,'.civxml')%TO ABANDON |
---|
| 521 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
| 522 | mode='pair j1-j2'; |
---|
| 523 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
| 524 | nom_type_ima='_i_j'; |
---|
| 525 | end |
---|
| 526 | elseif isequal(ext,'.xml') |
---|
[73] | 527 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 528 | ext_ima_read=[]; |
---|
| 529 | nom_type_read=[]; |
---|
[12] | 530 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 531 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[39] | 532 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 533 | if ~exist(fullname,'file') |
---|
[12] | 534 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 535 | end |
---|
[2] | 536 | end |
---|
[84] | 537 | if isfield(XmlData,'Time') |
---|
[85] | 538 | time=XmlData.Time; |
---|
[84] | 539 | nbfield=size(time,1); |
---|
| 540 | nburst=size(time,2); |
---|
| 541 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
| 542 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector |
---|
| 543 | if numel(nom_type_read)>=2 && (strcmp(nom_type_read,'_i')||strcmp(nom_type_read(1:2),'%0')||strcmp(nom_type_read(1:2),'_%')) |
---|
| 544 | time=time'; |
---|
| 545 | nbfield=nburst; |
---|
| 546 | nburst=1; |
---|
| 547 | end |
---|
| 548 | end |
---|
| 549 | end |
---|
[71] | 550 | if isfield(XmlData,'TimeUnit') |
---|
| 551 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 552 | end |
---|
[71] | 553 | if isfield(XmlData,'Npx') |
---|
| 554 | npx=XmlData.Npx; |
---|
| 555 | npy=XmlData.Npy; |
---|
| 556 | end |
---|
[2] | 557 | pxcmx_search=1; |
---|
| 558 | pxcmy_search=1; |
---|
| 559 | if isfield(XmlData,'GeometryCalib') |
---|
| 560 | tsai=XmlData.GeometryCalib; |
---|
[94] | 561 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 562 | rot2D=tsai.R(1:2,[1,2]); |
---|
[2] | 563 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 564 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
| 565 | end |
---|
| 566 | if isfield(tsai,'CoordUnit') |
---|
| 567 | CoordUnit=tsai.CoordUnit; |
---|
| 568 | end |
---|
| 569 | end |
---|
| 570 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
| 571 | if isempty(ext_ima) |
---|
| 572 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
| 573 | else %keep the image extension |
---|
| 574 | if ~strcmp(ext_ima_read,ext_ima) |
---|
| 575 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
| 576 | end |
---|
| 577 | end |
---|
| 578 | nom_type_ima=nom_type_read; |
---|
| 579 | end |
---|
| 580 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
| 581 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
[12] | 582 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 583 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
[2] | 584 | end |
---|
[71] | 585 | % ImaExt='.png'; |
---|
[2] | 586 | nom_type_ima='png_old'; |
---|
| 587 | elseif isequal(lower(ext),'.avi') |
---|
| 588 | nom_type_ima='*'; |
---|
| 589 | ext_ima=ext; |
---|
| 590 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 591 | dt=0.04;%default |
---|
| 592 | if exist([filebase ext],'file')==2 |
---|
| 593 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
| 594 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 595 | nbfield=info.NumFrames;%number of frames |
---|
| 596 | end |
---|
[94] | 597 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[71] | 598 | %set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
[2] | 599 | end |
---|
| 600 | if isempty(time) |
---|
| 601 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 602 | end |
---|
| 603 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 604 | |
---|
[12] | 605 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
| 606 | if isempty(nom_type_ima) |
---|
| 607 | %look for double image series '_i_j' |
---|
| 608 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 609 | if isempty(dirima) |
---|
| 610 | % look for images series with sub marker '_' |
---|
| 611 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 612 | if isempty(dirima) |
---|
| 613 | % look for other images series |
---|
| 614 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
| 615 | if ~isempty(dirima) |
---|
| 616 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 617 | end |
---|
| 618 | else |
---|
| 619 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 620 | end |
---|
| 621 | else |
---|
| 622 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 623 | end |
---|
| 624 | end |
---|
[2] | 625 | % no image documentation file found: look for a series of existing images or .nc files |
---|
[81] | 626 | if isempty(time) && ~isequal(ext,'.nc') && ~strcmp(nom_type_ima,'none') && ~strcmp(nom_type_ima,'') && ~strcmp(nom_type_ima,'*') |
---|
[12] | 627 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 628 | incr_pair=[0 0];%default |
---|
| 629 | if isfield(browse,'incr_pair') |
---|
| 630 | incr_pair=browse.incr_pair; |
---|
| 631 | end |
---|
[81] | 632 | % nbdetect=0;%test of detected images |
---|
[12] | 633 | field_i=field_count; |
---|
| 634 | idetect=1; |
---|
[81] | 635 | while idetect==1 %look for the maximum file number in the series |
---|
| 636 | imagename=name_generator(filebase,field_i+1,1,ext_ima,nom_type_ima); |
---|
| 637 | idetect=(exist(imagename,'file')==2); |
---|
| 638 | if idetect |
---|
[12] | 639 | field_i=field_i+1; |
---|
[81] | 640 | end |
---|
[12] | 641 | %SEE CASE OF NETCDF FILES |
---|
[81] | 642 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 643 | end |
---|
| 644 | nb_field=field_i;% last detected field number |
---|
| 645 | field_i=field_count;%look for the minimum file number in the series |
---|
| 646 | idetect=1; |
---|
| 647 | while idetect==1 |
---|
[81] | 648 | imagename=name_generator(filebase,field_i-1,1,ext_ima,nom_type_ima); |
---|
| 649 | idetect=(exist(imagename,'file')==2); |
---|
| 650 | if idetect |
---|
| 651 | field_i=field_i-1; |
---|
| 652 | end |
---|
[12] | 653 | end |
---|
[81] | 654 | first_i=max(field_i,1); |
---|
[89] | 655 | |
---|
| 656 | if strcmp(nom_type_ima,'_i_j') |
---|
| 657 | field_i=field_count; |
---|
| 658 | field_j=1; |
---|
| 659 | jdetect=1; |
---|
| 660 | while jdetect==1 %look for the maximum file number in the series |
---|
| 661 | imagename=name_generator(filebase,field_i,field_j,ext_ima,nom_type_ima); |
---|
| 662 | jdetect=(exist(imagename,'file')==2); |
---|
| 663 | if jdetect |
---|
| 664 | field_j=field_j+1; |
---|
| 665 | end |
---|
| 666 | %SEE CASE OF NETCDF FILES |
---|
| 667 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 668 | end |
---|
| 669 | nb_field_j=field_j-1;% last detected field number |
---|
| 670 | end |
---|
| 671 | |
---|
| 672 | |
---|
| 673 | %determine the set of times and possible intervals for CIV |
---|
[71] | 674 | % dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
[94] | 675 | time=(0:nb_field-1)';% time=file index -1 by default |
---|
[89] | 676 | if strcmp(nom_type_ima,'_i_j') |
---|
| 677 | % time=[0:nb_field-1]'*ones(1,nb_field_j);% time=file index -1 by default |
---|
| 678 | time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1 by default |
---|
| 679 | end |
---|
| 680 | |
---|
| 681 | |
---|
[12] | 682 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 683 | end |
---|
[81] | 684 | % if isequal(nom_type_ima,'none')% no file numbering used |
---|
| 685 | % first_i=1; |
---|
| 686 | % last_i=1; |
---|
| 687 | % first_j=1; |
---|
| 688 | % last_j=1; |
---|
| 689 | % end |
---|
[2] | 690 | if exist('time','var') |
---|
| 691 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 692 | nbfield=size(time,1); |
---|
| 693 | nbfield2=size(time,2); |
---|
[71] | 694 | set(handles.RootName,'UserData',time); %store the set of times |
---|
| 695 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 696 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
| 697 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 698 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 699 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 700 | end |
---|
| 701 | end |
---|
[71] | 702 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[2] | 703 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 704 | % npxy=[npy npx]; |
---|
[71] | 705 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 706 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 707 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 708 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 709 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 710 | browse.nom_type_ima=nom_type_ima; |
---|
| 711 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 712 | |
---|
| 713 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[41] | 714 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 715 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 716 | set(handles.mode,'Value',1) |
---|
[41] | 717 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
[2] | 718 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
| 719 | set(handles.mode,'Value',1) |
---|
| 720 | elseif (nbfield==1)% simple series in j |
---|
| 721 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 722 | set(handles.mode,'Value',1) |
---|
| 723 | else |
---|
| 724 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[41] | 725 | if nbfield2 <= 5 |
---|
| 726 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 727 | end |
---|
[41] | 728 | % else |
---|
| 729 | % if isequal(mode,'volume') |
---|
| 730 | % set(handles.mode,'Value',3) |
---|
| 731 | % elseif nbfield2 <= 5 |
---|
| 732 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 733 | % else |
---|
| 734 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 735 | % end |
---|
[2] | 736 | end |
---|
| 737 | |
---|
| 738 | %update the subdir |
---|
| 739 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 740 | listot=dir(pathdir); |
---|
| 741 | idir=0; |
---|
| 742 | listdir={''};%default |
---|
| 743 | for ilist=1:length(listot) |
---|
| 744 | if listot(ilist).isdir |
---|
| 745 | name=listot(ilist).name; |
---|
| 746 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 747 | idir=idir+1; |
---|
| 748 | listdir{idir,1}=listot(ilist).name; |
---|
| 749 | end |
---|
| 750 | end |
---|
| 751 | end |
---|
| 752 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 753 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 754 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
| 755 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
| 756 | %check wether the current subdir exists: |
---|
| 757 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 758 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 759 | |
---|
| 760 | mode_Callback(hObject, eventdata, handles) |
---|
| 761 | |
---|
| 762 | %%%%%% initialize waitbars and RUN button |
---|
| 763 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 764 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 765 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 766 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 767 | set(handles.RUN, 'Enable','On') |
---|
| 768 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[84] | 769 | if isequal(get(handles.BATCH, 'Enable'),'On') |
---|
[2] | 770 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 771 | end |
---|
| 772 | |
---|
| 773 | %%%%% store the root input filename for future opening |
---|
| 774 | dir_perso=prefdir; |
---|
| 775 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 776 | RootPath=fileparts(filebase); |
---|
| 777 | if exist(profil_perso,'file') |
---|
| 778 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 779 | else |
---|
| 780 | txt=ver; |
---|
| 781 | Release=txt(1).Release; |
---|
| 782 | relnumb=str2num(Release(3:4)); |
---|
| 783 | if relnumb >= 14 |
---|
| 784 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 785 | else |
---|
| 786 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 787 | end |
---|
| 788 | end |
---|
| 789 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 790 | set(gcf,'Pointer','arrow') |
---|
| 791 | |
---|
[12] | 792 | %------------------------------------------------------------------------ |
---|
[2] | 793 | % --- Executes on button press in mode. |
---|
| 794 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 795 | %------------------------------------------------------------------------ |
---|
[2] | 796 | browse=get(handles.browse_root,'UserData'); |
---|
| 797 | compare_list=get(handles.compare,'String'); |
---|
| 798 | val=get(handles.compare,'Value'); |
---|
| 799 | compare=compare_list{val}; |
---|
| 800 | if strcmp(compare,'displacement') |
---|
| 801 | mode='displacement'; |
---|
| 802 | else |
---|
| 803 | mode_list=get(handles.mode,'String'); |
---|
| 804 | mode_value=get(handles.mode,'Value'); |
---|
| 805 | mode=mode_list{mode_value}; |
---|
| 806 | end |
---|
| 807 | displ_num=[];%default |
---|
[54] | 808 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
[2] | 809 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[71] | 810 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 811 | siztime=size(time); |
---|
| 812 | nbfield=siztime(1); |
---|
| 813 | nbfield2=siztime(2); |
---|
| 814 | indchosen=1; %%first pair selected by default |
---|
| 815 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 816 | dt=1; |
---|
| 817 | displ=''; |
---|
| 818 | index=0; |
---|
| 819 | numlist_a=[]; |
---|
| 820 | numlist_B=[]; |
---|
| 821 | %get all the time intervals in bursts |
---|
| 822 | displ_dt=1;%default |
---|
| 823 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 824 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 825 | for numod_b=(numod_a+1):nbfield2 |
---|
| 826 | index=index+1; |
---|
| 827 | numlist_a(index)=numod_a; |
---|
| 828 | numlist_b(index)=numod_b; |
---|
| 829 | if ~isempty(time) |
---|
[54] | 830 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 831 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 832 | else |
---|
| 833 | displ_dt(index)=1; |
---|
| 834 | end |
---|
| 835 | end |
---|
| 836 | end |
---|
| 837 | [dtsort,indsort]=sort(displ_dt); |
---|
| 838 | if ~isempty(numlist_a) |
---|
| 839 | displ_num(1,:)=numlist_a(indsort); |
---|
| 840 | displ_num(2,:)=numlist_b(indsort); |
---|
| 841 | end |
---|
| 842 | displ_num(3,:)=0; |
---|
| 843 | displ_num(4,:)=0; |
---|
| 844 | set(handles.jtext,'Visible','Off') |
---|
| 845 | set(handles.first_j,'Visible','Off') |
---|
| 846 | set(handles.last_j,'Visible','Off') |
---|
| 847 | set(handles.incr_j,'Visible','Off') |
---|
| 848 | set(handles.nb_field2,'Visible','Off') |
---|
| 849 | set(handles.ref_j,'Visible','Off') |
---|
| 850 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 851 | for index=1:min(nbfield2-1,200) |
---|
| 852 | displ_num(1,index)=-floor(index/2); |
---|
| 853 | displ_num(2,index)=ceil(index/2); |
---|
| 854 | displ_num(3,index)=0; |
---|
| 855 | displ_num(4,index)=0; |
---|
| 856 | end |
---|
| 857 | set(handles.jtext,'Visible','On') |
---|
| 858 | set(handles.first_j,'Visible','On') |
---|
| 859 | set(handles.last_j,'Visible','On') |
---|
| 860 | set(handles.incr_j,'Visible','On') |
---|
| 861 | set(handles.nb_field2,'Visible','On') |
---|
| 862 | set(handles.ref_j,'Visible','On') |
---|
| 863 | if nbfield > 1 |
---|
| 864 | set(handles.itext,'Visible','On') |
---|
| 865 | set(handles.first_i,'Visible','On') |
---|
| 866 | set(handles.last_i,'Visible','On') |
---|
| 867 | set(handles.incr_i,'Visible','On') |
---|
| 868 | set(handles.nb_field,'Visible','On') |
---|
| 869 | set(handles.ref_i,'Visible','On') |
---|
| 870 | else |
---|
| 871 | set(handles.itext,'Visible','Off') |
---|
| 872 | set(handles.first_i,'Visible','Off') |
---|
| 873 | set(handles.last_i,'Visible','Off') |
---|
| 874 | set(handles.incr_i,'Visible','Off') |
---|
| 875 | set(handles.nb_field,'Visible','Off') |
---|
| 876 | set(handles.ref_i,'Visible','Off') |
---|
| 877 | end |
---|
| 878 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 879 | for index=1:200%min(nbfield-1,200) |
---|
| 880 | displ_num(1,index)=0; |
---|
| 881 | displ_num(2,index)=0; |
---|
| 882 | displ_num(3,index)=-floor(index/2); |
---|
| 883 | displ_num(4,index)=ceil(index/2); |
---|
| 884 | end |
---|
| 885 | set(handles.itext,'Visible','On') |
---|
| 886 | set(handles.first_i,'Visible','On') |
---|
| 887 | set(handles.last_i,'Visible','On') |
---|
| 888 | set(handles.incr_i,'Visible','On') |
---|
| 889 | set(handles.nb_field,'Visible','On') |
---|
| 890 | set(handles.ref_i,'Visible','On') |
---|
| 891 | if nbfield2 > 1 |
---|
| 892 | set(handles.jtext,'Visible','On') |
---|
| 893 | set(handles.first_j,'Visible','On') |
---|
| 894 | set(handles.last_j,'Visible','On') |
---|
| 895 | set(handles.incr_j,'Visible','On') |
---|
| 896 | set(handles.nb_field2,'Visible','On') |
---|
| 897 | set(handles.ref_j,'Visible','On') |
---|
| 898 | else |
---|
| 899 | set(handles.jtext,'Visible','Off') |
---|
| 900 | set(handles.first_j,'Visible','Off') |
---|
| 901 | set(handles.last_j,'Visible','Off') |
---|
| 902 | set(handles.incr_j,'Visible','Off') |
---|
| 903 | set(handles.nb_field2,'Visible','Off') |
---|
| 904 | set(handles.ref_j,'Visible','Off') |
---|
| 905 | end |
---|
| 906 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 907 | displ_num(1,1)=0; |
---|
| 908 | displ_num(2,1)=0; |
---|
| 909 | displ_num(3,1)=0; |
---|
| 910 | displ_num(4,1)=0; |
---|
| 911 | if nbfield > 1 |
---|
| 912 | set(handles.itext,'Visible','On') |
---|
| 913 | set(handles.first_i,'Visible','On') |
---|
| 914 | set(handles.last_i,'Visible','On') |
---|
| 915 | set(handles.incr_i,'Visible','On') |
---|
| 916 | set(handles.nb_field,'Visible','On') |
---|
| 917 | set(handles.ref_i,'Visible','On') |
---|
| 918 | else |
---|
| 919 | set(handles.itext,'Visible','Off') |
---|
| 920 | set(handles.first_i,'Visible','Off') |
---|
| 921 | set(handles.last_i,'Visible','Off') |
---|
| 922 | set(handles.incr_i,'Visible','Off') |
---|
| 923 | set(handles.nb_field,'Visible','Off') |
---|
| 924 | set(handles.ref_i,'Visible','Off') |
---|
| 925 | end |
---|
| 926 | if nbfield2 > 1 |
---|
| 927 | set(handles.jtext,'Visible','On') |
---|
| 928 | set(handles.first_j,'Visible','On') |
---|
| 929 | set(handles.last_j,'Visible','On') |
---|
| 930 | set(handles.incr_j,'Visible','On') |
---|
| 931 | set(handles.nb_field2,'Visible','On') |
---|
| 932 | set(handles.ref_j,'Visible','On') |
---|
| 933 | else |
---|
| 934 | set(handles.jtext,'Visible','Off') |
---|
| 935 | set(handles.first_j,'Visible','Off') |
---|
| 936 | set(handles.last_j,'Visible','Off') |
---|
| 937 | set(handles.incr_j,'Visible','Off') |
---|
| 938 | set(handles.nb_field2,'Visible','Off') |
---|
| 939 | set(handles.ref_j,'Visible','Off') |
---|
| 940 | end |
---|
| 941 | end |
---|
| 942 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 943 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 944 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 945 | |
---|
[12] | 946 | %------------------------------------------------------------------------ |
---|
[2] | 947 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 948 | % the field series set by first_i, incr, last_i |
---|
| 949 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 950 | %------------------------------------------------------------------------ |
---|
[2] | 951 | set(gcf,'Pointer','watch') |
---|
| 952 | %nomenclature types |
---|
[71] | 953 | filebase=get(handles.RootName,'String'); |
---|
[2] | 954 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 955 | browse=get(handles.browse_root,'UserData'); |
---|
| 956 | compare_list=get(handles.compare,'String'); |
---|
| 957 | val=get(handles.compare,'Value'); |
---|
| 958 | compare=compare_list{val}; |
---|
| 959 | if strcmp(compare,'displacement') |
---|
| 960 | mode='displacement'; |
---|
| 961 | else |
---|
| 962 | mode_list=get(handles.mode,'String'); |
---|
| 963 | mode_value=get(handles.mode,'Value'); |
---|
| 964 | mode=mode_list{mode_value}; |
---|
| 965 | end |
---|
| 966 | |
---|
| 967 | % nomenclature type of the .nc files |
---|
| 968 | nom_type_ima=[];%default |
---|
| 969 | if isfield(browse,'nom_type_ima') |
---|
| 970 | nom_type_ima=browse.nom_type_ima; |
---|
| 971 | end |
---|
| 972 | |
---|
| 973 | %determine nom_type_nc: |
---|
| 974 | nom_type_nc=[];%default |
---|
| 975 | if isfield(browse,'nom_type_nc') |
---|
| 976 | nom_type_nc=browse.nom_type_nc; |
---|
| 977 | end |
---|
| 978 | if isempty(nom_type_nc) |
---|
| 979 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
| 980 | end |
---|
| 981 | browse.nom_type_nc=nom_type_nc; |
---|
| 982 | set(handles.browse_root,'UserData',browse) |
---|
| 983 | |
---|
| 984 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 985 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 986 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 987 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 988 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 989 | % num1=first_i:incr:last_i; |
---|
| 990 | % if isempty(num1) |
---|
| 991 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 992 | % return |
---|
| 993 | % end |
---|
| 994 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 995 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 996 | ref_j=0; |
---|
| 997 | else |
---|
[45] | 998 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 999 | end |
---|
[71] | 1000 | time=get(handles.RootName,'UserData');%get the set of times |
---|
[2] | 1001 | if isempty(time) |
---|
| 1002 | time=[0 1]; |
---|
| 1003 | end |
---|
[71] | 1004 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1005 | dt_unit=1000;%default |
---|
[2] | 1006 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1007 | |
---|
| 1008 | %eliminate the first pairs inconsistent with the position |
---|
| 1009 | if isempty(displ_num) |
---|
| 1010 | nbpair=0; |
---|
| 1011 | else |
---|
| 1012 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1013 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1014 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1015 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1016 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1017 | end |
---|
| 1018 | end |
---|
| 1019 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1020 | |
---|
| 1021 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1022 | % be performed, while the result is needed for next steps. |
---|
| 1023 | displ_pair={''}; |
---|
| 1024 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1025 | testpair=0; |
---|
| 1026 | if get(handles.CIV1,'Value')==0 % |
---|
| 1027 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1028 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1029 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1030 | return |
---|
| 1031 | end |
---|
| 1032 | for ipair=1:nbpair |
---|
| 1033 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1034 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1035 | select(ipair)=exist(filename,'file')==2; |
---|
| 1036 | end |
---|
| 1037 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
| 1038 | if isfield(browse,'incr_pair') |
---|
| 1039 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1040 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1041 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1042 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1043 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1044 | select(1)=exist(filename,'file')==2; |
---|
| 1045 | testpair=1; |
---|
| 1046 | else |
---|
| 1047 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1048 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1049 | else |
---|
| 1050 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1051 | end |
---|
| 1052 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1053 | %COMPLETER CAS STEREO |
---|
| 1054 | return |
---|
| 1055 | end |
---|
| 1056 | end |
---|
| 1057 | end |
---|
| 1058 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1059 | if testpair |
---|
[73] | 1060 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1061 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
| 1062 | % for ipair=1:nbpair |
---|
| 1063 | % if select(ipair) |
---|
| 1064 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1065 | % 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 |
---|
| 1066 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1067 | % end |
---|
| 1068 | % else |
---|
| 1069 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1070 | % end |
---|
| 1071 | % end |
---|
[2] | 1072 | else |
---|
[73] | 1073 | for ipair=1:nbpair |
---|
| 1074 | if select(ipair) |
---|
| 1075 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1076 | 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 |
---|
| 1077 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1078 | else |
---|
| 1079 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1080 | end |
---|
| 1081 | end |
---|
| 1082 | end |
---|
[2] | 1083 | end |
---|
| 1084 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1085 | if testpair |
---|
| 1086 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1087 | else |
---|
| 1088 | for ipair=1:nbpair |
---|
| 1089 | if select(ipair) |
---|
| 1090 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1091 | 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 |
---|
| 1092 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1093 | end |
---|
| 1094 | elseif testpair |
---|
| 1095 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1096 | else |
---|
| 1097 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1098 | end |
---|
| 1099 | end |
---|
| 1100 | end |
---|
| 1101 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1102 | for ipair=1:nbpair |
---|
| 1103 | if select(ipair) |
---|
| 1104 | 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 |
---|
| 1105 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1106 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1107 | else |
---|
| 1108 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1109 | end |
---|
| 1110 | end |
---|
| 1111 | elseif isequal(mode,'displacement') |
---|
| 1112 | displ_pair={'Di=Dj=0'}; |
---|
| 1113 | end |
---|
| 1114 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1115 | ichoice=min(find(select)); |
---|
[45] | 1116 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1117 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
| 1118 | if initial>nbpair |
---|
| 1119 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1120 | end |
---|
| 1121 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1122 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1123 | end |
---|
[45] | 1124 | |
---|
[2] | 1125 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1126 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1127 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1128 | if ichoice <= length(displ_pair') |
---|
| 1129 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1130 | else |
---|
| 1131 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1132 | end |
---|
| 1133 | end |
---|
| 1134 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1135 | set(gcf,'Pointer','arrow') |
---|
[12] | 1136 | |
---|
| 1137 | %------------------------------------------------------------------------ |
---|
[2] | 1138 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1139 | %middle of the series set by first_i, incr, last_i |
---|
| 1140 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1141 | %------------------------------------------------------------------------ |
---|
[2] | 1142 | set(gcf,'Pointer','watch') |
---|
| 1143 | %nomenclature types |
---|
[71] | 1144 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1145 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1146 | browse=get(handles.browse_root,'UserData'); |
---|
| 1147 | compare_list=get(handles.compare,'String'); |
---|
| 1148 | val=get(handles.compare,'Value'); |
---|
| 1149 | compare=compare_list{val}; |
---|
| 1150 | if strcmp(compare,'displacement') |
---|
| 1151 | mode='displacement'; |
---|
| 1152 | else |
---|
| 1153 | mode_list=get(handles.mode,'String'); |
---|
| 1154 | mode_value=get(handles.mode,'Value'); |
---|
| 1155 | mode=mode_list{mode_value}; |
---|
| 1156 | end |
---|
| 1157 | |
---|
| 1158 | % nomenclature type of the .nc files |
---|
| 1159 | nom_type_ima='ima_num';%default |
---|
| 1160 | if isfield(browse,'nom_type_ima') |
---|
| 1161 | nom_type_ima=browse.nom_type_ima; |
---|
| 1162 | end |
---|
| 1163 | nom_type_nc='_i1-i2';%default |
---|
| 1164 | if isfield(browse,'nom_type_nc') |
---|
| 1165 | nom_type_nc=browse.nom_type_nc; |
---|
| 1166 | end |
---|
[94] | 1167 | 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') |
---|
[2] | 1168 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1169 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1170 | nom_type_nc='none'; |
---|
[94] | 1171 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[2] | 1172 | nom_type_nc='_i1-i2'; |
---|
| 1173 | else |
---|
| 1174 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1175 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1176 | else |
---|
| 1177 | nom_type_nc='_i_j1-j2'; |
---|
| 1178 | end |
---|
| 1179 | end |
---|
| 1180 | browse.nom_type_nc=nom_type_nc; |
---|
| 1181 | set(handles.browse_root,'UserData',browse) |
---|
| 1182 | |
---|
| 1183 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1184 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1185 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1186 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1187 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1188 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1189 | % num1=first_i:incr:last_i; |
---|
| 1190 | % if isempty(num1) |
---|
| 1191 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1192 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1193 | % return |
---|
| 1194 | % end |
---|
[71] | 1195 | ref_i=str2num(get(handles.ref_i_civ2,'String')); |
---|
[2] | 1196 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1197 | ref_j=0; |
---|
| 1198 | else |
---|
[71] | 1199 | ref_j=str2num(get(handles.ref_j_civ2,'String')); |
---|
[2] | 1200 | end |
---|
[71] | 1201 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 1202 | if isempty(time) |
---|
| 1203 | time=[0 1];%default |
---|
| 1204 | end |
---|
[71] | 1205 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1206 | %dt_unit=1000; |
---|
[2] | 1207 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1208 | |
---|
| 1209 | |
---|
| 1210 | %eliminate the first pairs inconsistent with the position |
---|
| 1211 | if isempty(displ_num) |
---|
| 1212 | nbpair=0; |
---|
| 1213 | else |
---|
| 1214 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1215 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
| 1216 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1217 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1218 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1219 | end |
---|
| 1220 | end |
---|
| 1221 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1222 | |
---|
| 1223 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1224 | % be performed, while the result is needed for next steps. |
---|
| 1225 | displ_pair={''}; %default |
---|
| 1226 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1227 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1228 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1229 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1230 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1231 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1232 | return |
---|
| 1233 | end |
---|
| 1234 | for ipair=1:nbpair |
---|
| 1235 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1236 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1237 | select(ipair)=exist(filename,'file')==2; |
---|
| 1238 | end |
---|
| 1239 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1240 | if isfield(browse,'incr_pair') |
---|
| 1241 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1242 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1243 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1244 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1245 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1246 | select(1)=exist(filename,'file')==2; |
---|
| 1247 | else |
---|
| 1248 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1249 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1250 | else |
---|
| 1251 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1252 | end |
---|
| 1253 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1254 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1255 | return |
---|
| 1256 | end |
---|
| 1257 | end |
---|
| 1258 | end |
---|
| 1259 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1260 | for ipair=1:nbpair |
---|
| 1261 | if select(ipair) |
---|
| 1262 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1263 | 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 |
---|
| 1264 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1265 | end |
---|
| 1266 | else |
---|
| 1267 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1268 | end |
---|
| 1269 | end |
---|
| 1270 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1271 | for ipair=1:nbpair |
---|
| 1272 | if select(ipair) |
---|
| 1273 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1274 | 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 |
---|
| 1275 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1276 | end |
---|
| 1277 | else |
---|
| 1278 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1279 | end |
---|
| 1280 | end |
---|
| 1281 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1282 | for ipair=1:nbpair |
---|
| 1283 | if select(ipair) |
---|
| 1284 | 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 |
---|
| 1285 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1286 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1287 | else |
---|
| 1288 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1289 | end |
---|
| 1290 | end |
---|
| 1291 | elseif isequal(mode,'displacement') |
---|
| 1292 | displ_pair={'Di=Dj=0'}; |
---|
| 1293 | end |
---|
| 1294 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1295 | ichoice=min(find(select)); |
---|
| 1296 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1297 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1298 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1299 | end |
---|
| 1300 | if val>length(displ_pair') |
---|
| 1301 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1302 | else |
---|
| 1303 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1304 | end |
---|
| 1305 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1306 | set(gcf,'Pointer','arrow') |
---|
[2] | 1307 | |
---|
[12] | 1308 | %------------------------------------------------------------------------ |
---|
[2] | 1309 | % determine the list of index pairs of processing file |
---|
| 1310 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1311 | find_pair_indices(handles,mode) |
---|
[12] | 1312 | %------------------------------------------------------------------------ |
---|
[45] | 1313 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1314 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1315 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
[39] | 1316 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
[2] | 1317 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
[45] | 1318 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1319 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1320 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
[2] | 1321 | else |
---|
| 1322 | first_j=1; |
---|
| 1323 | last_j=1; |
---|
| 1324 | incr_j=1; |
---|
| 1325 | end |
---|
[36] | 1326 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
[2] | 1327 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1328 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
[36] | 1329 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
[2] | 1330 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1331 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1332 | return |
---|
| 1333 | end |
---|
| 1334 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1335 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1336 | if index_civ2>length(list_civ2) |
---|
| 1337 | list_civ2=list_civ1; |
---|
| 1338 | index_civ2=index_civ1; |
---|
| 1339 | end |
---|
[36] | 1340 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 1341 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
| 1342 | return,end; |
---|
[39] | 1343 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[36] | 1344 | return,end; |
---|
[39] | 1345 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[36] | 1346 | return,end; |
---|
[39] | 1347 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[36] | 1348 | return,end; |
---|
| 1349 | if isequal (mode,'series(Di)') |
---|
[2] | 1350 | %recognize the pair civ1 from the display |
---|
| 1351 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1352 | str_raw=str_civ1(indsel); |
---|
| 1353 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
[45] | 1354 | d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
[2] | 1355 | if indsepar==length(str_raw) |
---|
[45] | 1356 | d2=str2double(str_civ1([indsel(indsepar)+1:end])); |
---|
[2] | 1357 | else |
---|
[45] | 1358 | d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
[2] | 1359 | end |
---|
[39] | 1360 | num1_civ1=num_i-d1;% set of first image numbers |
---|
| 1361 | num2_civ1=num_i+d2; |
---|
[2] | 1362 | num_a_civ1=num_j; |
---|
| 1363 | num_b_civ1=num_j; |
---|
| 1364 | |
---|
| 1365 | %recognize the pair civ2 from the display |
---|
| 1366 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1367 | str_raw=str_civ2(indsel); |
---|
| 1368 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1369 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1370 | if indsepar==length(str_raw) |
---|
| 1371 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
| 1372 | else |
---|
| 1373 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1374 | end |
---|
| 1375 | if isempty(d1) |
---|
[39] | 1376 | num1_civ2=num_i; |
---|
[2] | 1377 | else |
---|
[39] | 1378 | num1_civ2=num_i-d1;% set of first image numbers |
---|
[2] | 1379 | end |
---|
| 1380 | if isempty(d2) |
---|
[39] | 1381 | num2_civ2=num_i; |
---|
[2] | 1382 | else |
---|
[39] | 1383 | num2_civ2=num_i+d2; |
---|
[2] | 1384 | end |
---|
| 1385 | num_a_civ2=num_j; |
---|
| 1386 | num_b_civ2=num_j; |
---|
| 1387 | |
---|
| 1388 | % adjust the first and last field number |
---|
| 1389 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1390 | if isequal(lastfield,[]) |
---|
| 1391 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1392 | else |
---|
| 1393 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1394 | end |
---|
| 1395 | if length(indsel)>=1 |
---|
| 1396 | firstind=indsel(1); |
---|
| 1397 | lastind=indsel(end); |
---|
[39] | 1398 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
| 1399 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
| 1400 | num_i=num_i(indsel); |
---|
[2] | 1401 | num1_civ1=num1_civ1(indsel); |
---|
| 1402 | num1_civ2=num1_civ2(indsel); |
---|
| 1403 | num2_civ1=num2_civ1(indsel); |
---|
| 1404 | num2_civ2=num2_civ2(indsel); |
---|
| 1405 | end |
---|
[36] | 1406 | elseif isequal (mode,'series(Dj)') |
---|
[2] | 1407 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
[39] | 1408 | num1_civ1=num_i;% set of first image numbers |
---|
| 1409 | num2_civ1=num_i; |
---|
[2] | 1410 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1411 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
[39] | 1412 | num1_civ2=num_i; |
---|
| 1413 | num2_civ2=num_i; |
---|
[2] | 1414 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1415 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1416 | % adjust the first and last field number |
---|
| 1417 | if isequal(lastfield_j,[]) |
---|
| 1418 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1419 | else |
---|
| 1420 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1421 | end |
---|
| 1422 | if length(indsel)>=1 |
---|
| 1423 | firstind=indsel(1); |
---|
| 1424 | lastind=indsel(end); |
---|
| 1425 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1426 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1427 | num_j=num_j(indsel); |
---|
| 1428 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1429 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1430 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1431 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1432 | end |
---|
[36] | 1433 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[39] | 1434 | num1_civ1=num_i; |
---|
| 1435 | num1_civ2=num_i; |
---|
[2] | 1436 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[39] | 1437 | num2_civ1=num_i; |
---|
[2] | 1438 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1439 | num_b_civ1=displ_num(2,index_civ1); |
---|
[39] | 1440 | num2_civ2=num_i; |
---|
[2] | 1441 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1442 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1443 | elseif isequal(mode,'displacement') |
---|
[39] | 1444 | num1_civ1=num_i; |
---|
| 1445 | num2_civ1=num_i; |
---|
[2] | 1446 | num_a_civ1=num_j; |
---|
| 1447 | num_b_civ1=num_j; |
---|
[39] | 1448 | num1_civ2=num_i; |
---|
| 1449 | num2_civ2=num_i; |
---|
[2] | 1450 | num_a_civ2=num_j; |
---|
| 1451 | num_b_civ2=num_j; |
---|
| 1452 | end |
---|
| 1453 | |
---|
[41] | 1454 | |
---|
[12] | 1455 | %------------------------------------------------------------------------ |
---|
[2] | 1456 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1457 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1458 | %------------------------------------------------------------------------ |
---|
[2] | 1459 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1460 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1461 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1462 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1463 | num_a=displ_num(1,index_pair); |
---|
| 1464 | num_b=displ_num(2,index_pair); |
---|
| 1465 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1466 | if index_pair<=length(list_pair2) |
---|
| 1467 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1468 | end |
---|
| 1469 | |
---|
| 1470 | %update first_i and last_i according to the chosen image pairs |
---|
| 1471 | mode_list=get(handles.mode,'String'); |
---|
| 1472 | mode_value=get(handles.mode,'Value'); |
---|
| 1473 | mode=mode_list{mode_value}; |
---|
| 1474 | if isequal(mode,'series(Di)') |
---|
| 1475 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1476 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1477 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1478 | num1=first_i:incr_i:last_i; |
---|
| 1479 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1480 | if ~isequal(lastfield,[]) |
---|
| 1481 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1482 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1483 | num1=num1(ind); |
---|
| 1484 | end |
---|
| 1485 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1486 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1487 | elseif isequal(mode,'series(Dj)') |
---|
| 1488 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1489 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1490 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1491 | num_j=first_j:incr_j:last_j; |
---|
| 1492 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1493 | if ~isequal(lastfield2,[]) |
---|
| 1494 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1495 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1496 | num1=num_j(ind); |
---|
| 1497 | end |
---|
| 1498 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1499 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1500 | end |
---|
| 1501 | |
---|
[12] | 1502 | %------------------------------------------------------------------------ |
---|
[2] | 1503 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1504 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1505 | %------------------------------------------------------------------------ |
---|
[2] | 1506 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1507 | |
---|
| 1508 | %update first_i and last_i according to the chosen image pairs |
---|
| 1509 | mode_list=get(handles.mode,'String'); |
---|
| 1510 | mode_value=get(handles.mode,'Value'); |
---|
| 1511 | mode=mode_list{mode_value}; |
---|
| 1512 | if isequal(mode,'series(Di)') |
---|
| 1513 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1514 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1515 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1516 | num1=first_i:incr_i:last_i; |
---|
| 1517 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1518 | if ~isequal(lastfield,[]) |
---|
| 1519 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1520 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1521 | num1=num1(ind); |
---|
| 1522 | end |
---|
| 1523 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1524 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1525 | elseif isequal(mode,'series(Dj)') |
---|
| 1526 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1527 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1528 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1529 | num_j=first_j:incr_j:last_j; |
---|
| 1530 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1531 | if ~isequal(lastfield2,[]) |
---|
| 1532 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1533 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1534 | num1=num_j(ind); |
---|
| 1535 | end |
---|
| 1536 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1537 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1538 | end |
---|
| 1539 | |
---|
[12] | 1540 | %------------------------------------------------------------------------ |
---|
[2] | 1541 | % --- Executes on button press in RUN. |
---|
| 1542 | |
---|
| 1543 | |
---|
| 1544 | |
---|
[67] | 1545 | % compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1546 | % %check the list of operations: |
---|
| 1547 | % operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1548 | % run_flag=1; |
---|
| 1549 | % box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1550 | % box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1551 | % box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1552 | % box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1553 | % box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1554 | % box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1555 | % index=find(box_test==1); |
---|
| 1556 | % if isempty(index) |
---|
| 1557 | % msgbox_uvmat('ERROR','no selected operation') |
---|
| 1558 | % return |
---|
| 1559 | % end |
---|
| 1560 | % index_first=min(index); |
---|
| 1561 | % index_last=max(index); |
---|
| 1562 | % box_used=box_test([index_first : index_last]); |
---|
| 1563 | % [box_missing,ind_missing]=min(box_used); |
---|
| 1564 | % if isequal(box_missing,0) |
---|
| 1565 | % msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1566 | % return |
---|
| 1567 | % end |
---|
| 1568 | % |
---|
| 1569 | % %root name |
---|
[71] | 1570 | % filebase=get(handles.RootName,'String'); |
---|
[67] | 1571 | % if isempty(filebase)||isequal(filebase,'') |
---|
| 1572 | % msgbox_uvmat('ERROR','no input files') |
---|
| 1573 | % return |
---|
| 1574 | % end |
---|
| 1575 | % %check mask if selecetd |
---|
| 1576 | % if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
| 1577 | % maskname=get(handles.mask_civ1,'String'); |
---|
| 1578 | % if ~exist(maskname,'file') |
---|
| 1579 | % get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1580 | % end |
---|
| 1581 | % end |
---|
| 1582 | % if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
| 1583 | % maskname=get(handles.mask_fix1,'String'); |
---|
| 1584 | % if ~exist(maskname,'file') |
---|
| 1585 | % get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1586 | % end |
---|
| 1587 | % end |
---|
| 1588 | % if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
| 1589 | % maskname=get(handles.mask_civ2,'String'); |
---|
| 1590 | % if ~exist(maskname,'file') |
---|
| 1591 | % get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
| 1592 | % end |
---|
| 1593 | % end |
---|
| 1594 | % if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
| 1595 | % maskname=get(handles.mask_fix2,'String'); |
---|
| 1596 | % if ~exist(maskname,'file') |
---|
| 1597 | % get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
| 1598 | % end |
---|
| 1599 | % end |
---|
| 1600 | % |
---|
| 1601 | % %read names of the .exe file |
---|
| 1602 | % if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 |
---|
| 1603 | % path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1604 | % path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 1605 | % %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 1606 | % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 1607 | % if exist(xmlfile,'file') |
---|
| 1608 | % t=xmltree(xmlfile); |
---|
| 1609 | % sparam=convert(t); |
---|
| 1610 | % end |
---|
| 1611 | % if isfield(sparam,'Civ1Bin') |
---|
| 1612 | % civ1Bin=sparam.Civ1Bin; |
---|
| 1613 | % if ~exist(civ1Bin,'file') |
---|
| 1614 | % civ1Bin=fullfile(path_UVMAT,civ1Bin); |
---|
| 1615 | % end |
---|
| 1616 | % end |
---|
| 1617 | % if isfield(sparam,'Civ2Bin') |
---|
| 1618 | % civ2Bin=sparam.Civ2Bin; |
---|
| 1619 | % if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting |
---|
| 1620 | % civ2_exe=fullfile(path_UVMAT,civ2_exe); |
---|
| 1621 | % end |
---|
| 1622 | % end |
---|
| 1623 | % if isfield(sparam,'Patch_exe') |
---|
| 1624 | % patch_exe=sparam.Patch_exe; |
---|
| 1625 | % if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting |
---|
| 1626 | % patch_exe=fullfile(path_UVMAT,patch_exe); |
---|
| 1627 | % end |
---|
| 1628 | % end |
---|
| 1629 | % if isfield(sparam,'Stinterp_exe') |
---|
| 1630 | % stinterp_exe=sparam.Stinterp_exe; |
---|
| 1631 | % end |
---|
| 1632 | % if isfield(sparam,'SGE') |
---|
| 1633 | % sge=str2double(sparam.SGE); |
---|
| 1634 | % end |
---|
| 1635 | % if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
| 1636 | % dircur=pwd; |
---|
| 1637 | % if ~isequal(dircur([2 3]),':\') |
---|
| 1638 | % msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
| 1639 | % return; |
---|
| 1640 | % end |
---|
| 1641 | % end |
---|
| 1642 | % end |
---|
| 1643 | % |
---|
| 1644 | % %initialize the waitbars |
---|
| 1645 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 1646 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 1647 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 1648 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 1649 | % set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1650 | % set(handles.RUN, 'Enable','Off') |
---|
| 1651 | % drawnow |
---|
| 1652 | % |
---|
| 1653 | % % get the list of file names and check the files |
---|
| 1654 | % display('checking the files...') |
---|
| 1655 | % [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]=... |
---|
| 1656 | % set_civ_filenames(handles,compare,box_test); |
---|
| 1657 | % nbfield=numel(num1_civ1); |
---|
| 1658 | % nbslice=size(num_a_civ1); |
---|
| 1659 | % |
---|
| 1660 | % if isempty(filecell) |
---|
| 1661 | % set(handles.RUN, 'Enable','On') |
---|
| 1662 | % set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1663 | % set(handles.BATCH, 'Enable','On') |
---|
| 1664 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1665 | % return |
---|
| 1666 | % end |
---|
| 1667 | % display('files OK, processing...') |
---|
| 1668 | % nbfield=size(num1_civ1,2); |
---|
| 1669 | % nbslice=size(num1_civ1,1); |
---|
| 1670 | % |
---|
| 1671 | % %RUN CIV1 |
---|
| 1672 | % if box_test(1)==1 |
---|
| 1673 | % 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) |
---|
| 1674 | % if compare==3 |
---|
| 1675 | % 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) |
---|
| 1676 | % end |
---|
| 1677 | % end |
---|
| 1678 | % |
---|
| 1679 | % %RUN FIX1 |
---|
| 1680 | % if box_test(2)==1 |
---|
[71] | 1681 | % filebase=get(handles.RootName,'String'); |
---|
[67] | 1682 | % %names of the civ1 fields |
---|
| 1683 | % field1.vel_type='civ1'; |
---|
| 1684 | % field1.nb='nb_vectors'; |
---|
| 1685 | % % field1.X='vec_X'; |
---|
| 1686 | % % field1.Y='vec_Y'; |
---|
| 1687 | % % field1.U='vec_U'; |
---|
| 1688 | % % field1.V='vec_V'; |
---|
| 1689 | % field1.fixflag='vec_FixFlag'; |
---|
| 1690 | % flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1691 | % flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
| 1692 | % flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
| 1693 | % thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1694 | % thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 1695 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 1696 | % menu=get(handles.field_ref1,'String'); |
---|
| 1697 | % index=get(handles.field_ref1,'Value'); |
---|
| 1698 | % if isempty(menu) |
---|
| 1699 | % fieldchoice=''; |
---|
| 1700 | % else |
---|
| 1701 | % fieldchoice=menu{index}; |
---|
| 1702 | % end |
---|
| 1703 | % h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar |
---|
| 1704 | % test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1705 | % if test_mask |
---|
| 1706 | % maskdispl=get(handles.mask_fix1,'String'); |
---|
| 1707 | % if exist(maskdispl,'file') |
---|
| 1708 | % test_mask=2; |
---|
| 1709 | % maskname=maskdispl; |
---|
| 1710 | % else |
---|
[71] | 1711 | % maskbase=[get(handles.RootName,'String') '_' maskdispl]; % mask root name |
---|
[67] | 1712 | % end |
---|
| 1713 | % end |
---|
| 1714 | % for ifile=1:nbfield |
---|
| 1715 | % waitbar(ifile/nbfield); %update the waitbar |
---|
| 1716 | % for j=1:nbslice |
---|
| 1717 | % if test_mask==0 |
---|
| 1718 | % maskname='noFile use default'; |
---|
| 1719 | % maskflag=0; |
---|
| 1720 | % elseif test_mask==1 |
---|
| 1721 | % nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
| 1722 | % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1723 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
| 1724 | % maskflag= exist(maskname,'file')==2; |
---|
| 1725 | % if ~maskflag; |
---|
| 1726 | % maskname='noFile use default'; |
---|
| 1727 | % end |
---|
| 1728 | % end |
---|
| 1729 | % if ~isempty(file_ref_fix1) |
---|
| 1730 | % file_ref=file_ref_fix1{ifile,j}; |
---|
| 1731 | % else |
---|
| 1732 | % file_ref=''; |
---|
| 1733 | % end |
---|
| 1734 | % error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1735 | % thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1736 | % |
---|
| 1737 | % if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
| 1738 | % if test_mask==0 |
---|
| 1739 | % maskname='noFile use default'; |
---|
| 1740 | % maskflag=0; |
---|
| 1741 | % else |
---|
[71] | 1742 | % maskbase=[get(handles.RootName2,'String') '_' maskdispl]; % mask root name |
---|
[67] | 1743 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1744 | % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1745 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1746 | % maskflag= exist(maskname,'file')==2; |
---|
| 1747 | % if ~maskflag; |
---|
| 1748 | % maskname='noFile use default'; |
---|
| 1749 | % end |
---|
| 1750 | % end |
---|
| 1751 | % error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1752 | % thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1753 | % if ~isempty(error) |
---|
| 1754 | % msgbox_uvmat('ERROR',error) |
---|
| 1755 | % return |
---|
| 1756 | % end |
---|
| 1757 | % end |
---|
| 1758 | % end |
---|
| 1759 | % end |
---|
| 1760 | % close(h) |
---|
| 1761 | % end |
---|
| 1762 | % |
---|
| 1763 | % % RUN PATCH1 |
---|
| 1764 | % if box_test(3)==1 |
---|
| 1765 | % rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 1766 | % if isempty(rho_patch1) |
---|
| 1767 | % rho_patch1='1000'; |
---|
| 1768 | % set(handles.rho_patch1,'String','1') |
---|
| 1769 | % else |
---|
| 1770 | % rho_patch1=num2str(1000*rho_patch1); |
---|
| 1771 | % end |
---|
| 1772 | % nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1773 | % if isequal(str2num(nx_patch1),[]) |
---|
| 1774 | % nx_patch1='50' ;%default |
---|
| 1775 | % set(handles.nx_patch1,'String','50'); |
---|
| 1776 | % end |
---|
| 1777 | % ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 1778 | % if isequal(str2num(ny_patch1),[]) |
---|
| 1779 | % ny_patch1='50' ;%default |
---|
| 1780 | % set(handles.ny_patch1,'String','50'); |
---|
| 1781 | % end |
---|
| 1782 | % subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1783 | % thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1784 | % test_interp=get(handles.test_interp,'Value'); |
---|
| 1785 | % icount=0; |
---|
| 1786 | % for ifile=1:nbfield |
---|
| 1787 | % for j=1:nbslice |
---|
| 1788 | % icount=icount+1; |
---|
| 1789 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1790 | % set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
| 1791 | % drawnow |
---|
| 1792 | % if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1793 | % cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1794 | % s=-1; |
---|
| 1795 | % if sge |
---|
| 1796 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1797 | % end |
---|
| 1798 | % if s~=0 |
---|
| 1799 | % display(['!' cmd]) |
---|
| 1800 | % eval(['!' cmd]); |
---|
| 1801 | % end |
---|
| 1802 | % |
---|
| 1803 | % %stereo case: |
---|
| 1804 | % elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 1805 | % if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1806 | % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
| 1807 | % nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1808 | % display(['!' cmd]) |
---|
| 1809 | % eval(['!' cmd]); |
---|
| 1810 | % else |
---|
| 1811 | % RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1812 | % str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1813 | % end |
---|
| 1814 | % end |
---|
| 1815 | % if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1816 | % cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1817 | % s=-1; |
---|
| 1818 | % if sge |
---|
| 1819 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1820 | % end |
---|
| 1821 | % if s~=0 |
---|
| 1822 | % display(['!' cmd]) |
---|
| 1823 | % eval(['!' cmd]); |
---|
| 1824 | % end |
---|
| 1825 | % end |
---|
| 1826 | % end |
---|
| 1827 | % end |
---|
| 1828 | % end |
---|
| 1829 | % |
---|
| 1830 | % % CIV2 |
---|
| 1831 | % if box_test(4)==1 |
---|
| 1832 | % RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
| 1833 | % num_a_civ2,num_b_civ2,nom_type_nc) |
---|
| 1834 | % end |
---|
| 1835 | % |
---|
| 1836 | % % FIX2 |
---|
| 1837 | % if box_test(5)==1 |
---|
| 1838 | % %names of the civ2 fields |
---|
| 1839 | % field2.vel_type='civ2'; |
---|
| 1840 | % field2.nb='nb_vectors2'; |
---|
| 1841 | % field2.X='vec2_X'; |
---|
| 1842 | % field2.Y='vec2_Y'; |
---|
| 1843 | % field2.U='vec2_U'; |
---|
| 1844 | % field2.V='vec2_V'; |
---|
| 1845 | % field2.fixflag='vec2_FixFlag'; |
---|
| 1846 | % flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1847 | % flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1848 | % flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
| 1849 | % thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1850 | % thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 1851 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1852 | % menu=get(handles.field_ref2,'String'); |
---|
| 1853 | % index=get(handles.field_ref2,'Value'); |
---|
| 1854 | % if isempty(menu) |
---|
| 1855 | % fieldchoice=''; |
---|
| 1856 | % else |
---|
| 1857 | % fieldchoice=menu{index}; |
---|
| 1858 | % end |
---|
| 1859 | % h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
| 1860 | % test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1861 | % if test_mask |
---|
| 1862 | % maskdispl=get(handles.mask_fix2,'String'); |
---|
| 1863 | % if exist(maskdispl,'file') |
---|
| 1864 | % test_mask=2; |
---|
| 1865 | % maskname=maskdispl; |
---|
| 1866 | % else |
---|
[71] | 1867 | % maskbase=[get(handles.RootName,'String') '_' maskdispl]; % mask root name |
---|
[67] | 1868 | % end |
---|
| 1869 | % end |
---|
| 1870 | % for ifile=1:nbfield |
---|
| 1871 | % waitbar(ifile/nbfield); %update the waitbar |
---|
| 1872 | % for j=1:nbslice |
---|
| 1873 | % if test_mask==0 |
---|
| 1874 | % maskname='noFile use default'; |
---|
| 1875 | % maskflag=0; |
---|
| 1876 | % elseif test_mask==1 |
---|
| 1877 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1878 | % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1879 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1880 | % maskflag= exist(maskname,'file')==2; |
---|
| 1881 | % if ~maskflag; |
---|
| 1882 | % maskname='noFile use default'; |
---|
| 1883 | % end |
---|
| 1884 | % end |
---|
| 1885 | % if ~isempty(file_ref_fix2) |
---|
| 1886 | % file_ref=file_ref_fix2{ifile,j}; |
---|
| 1887 | % else |
---|
| 1888 | % file_ref=''; |
---|
| 1889 | % end |
---|
| 1890 | % error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
| 1891 | % thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1892 | % if ~isempty(error) |
---|
| 1893 | % msgbox_uvmat('ERROR',error) |
---|
| 1894 | % return |
---|
| 1895 | % end |
---|
| 1896 | % if compare==3 |
---|
| 1897 | % if test_mask==0 |
---|
| 1898 | % maskname='noFile use default'; |
---|
| 1899 | % maskflag=0; |
---|
| 1900 | % else |
---|
[71] | 1901 | % maskbase=[get(handles.RootName2,'String') '_' maskdispl]; % mask root name |
---|
[67] | 1902 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1903 | % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1904 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1905 | % maskflag= exist(maskname,'file')==2; |
---|
| 1906 | % if ~maskflag; |
---|
| 1907 | % maskname='noFile use default'; |
---|
| 1908 | % end |
---|
| 1909 | % end |
---|
| 1910 | % error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
| 1911 | % thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1912 | % if ~isempty(error) |
---|
| 1913 | % msgbox_uvmat('ERROR',error) |
---|
| 1914 | % return |
---|
| 1915 | % end |
---|
| 1916 | % end |
---|
| 1917 | % end |
---|
| 1918 | % end |
---|
| 1919 | % close(h) |
---|
| 1920 | % end |
---|
| 1921 | % |
---|
| 1922 | % %PATCH 2 |
---|
| 1923 | % if box_test(6)==1 |
---|
| 1924 | % rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 1925 | % if isempty(rho_patch2) |
---|
| 1926 | % rho_patch2='1000'; |
---|
| 1927 | % set(handles.rho_patch2,'String','1') |
---|
| 1928 | % else |
---|
| 1929 | % rho_patch2=num2str(1000*rho_patch2); |
---|
| 1930 | % end |
---|
| 1931 | % nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1932 | % ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 1933 | % thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1934 | % if isequal(str2num(nx_patch2),[]) |
---|
| 1935 | % nx_patch2='50' ;%default |
---|
| 1936 | % set(handles.nx_patch2,'String','50'); |
---|
| 1937 | % end |
---|
| 1938 | % if isequal(str2num(ny_patch2),[]) |
---|
| 1939 | % ny_patch2='50' ;%default |
---|
| 1940 | % set(handles.ny_patch2,'String','50'); |
---|
| 1941 | % end |
---|
| 1942 | % subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1943 | % icount=0; |
---|
| 1944 | % for ifile=1:nbfield |
---|
| 1945 | % for j=1:nbslice |
---|
| 1946 | % icount=icount+1; |
---|
| 1947 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1948 | % set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
| 1949 | % drawnow |
---|
| 1950 | % if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1951 | % cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1952 | % s=-1; |
---|
| 1953 | % if sge |
---|
| 1954 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1955 | % end |
---|
| 1956 | % if s~=0 |
---|
| 1957 | % display(['!' cmd]) |
---|
| 1958 | % eval(['!' cmd]); |
---|
| 1959 | % end |
---|
| 1960 | % elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 1961 | % if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1962 | % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
| 1963 | % nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1964 | % display(['!' cmd]) |
---|
| 1965 | % eval(['!' cmd]) |
---|
| 1966 | % else |
---|
| 1967 | % RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 1968 | % str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1969 | % end |
---|
| 1970 | % end |
---|
| 1971 | % if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1972 | % cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1973 | % s=-1; |
---|
| 1974 | % if sge |
---|
| 1975 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1976 | % end |
---|
| 1977 | % if s~=0 |
---|
| 1978 | % display(['!' cmd]) |
---|
| 1979 | % eval(['!' cmd]); |
---|
| 1980 | % end |
---|
| 1981 | % end |
---|
| 1982 | % end |
---|
| 1983 | % end |
---|
| 1984 | % end |
---|
| 1985 | % |
---|
| 1986 | % set(handles.RUN, 'Enable','On') |
---|
| 1987 | % set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1988 | % |
---|
| 1989 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 1990 | % if isfield(filecell,'st') |
---|
| 1991 | % fileresu=filecell.st{1,1}; |
---|
| 1992 | % elseif isfield(filecell,'nc') |
---|
| 1993 | % if isfield(filecell.nc,'civ2') |
---|
| 1994 | % fileresu=filecell.nc.civ2{1,1}; |
---|
| 1995 | % else |
---|
| 1996 | % fileresu=filecell.nc.civ1{1,1}; |
---|
| 1997 | % end |
---|
| 1998 | % end |
---|
| 1999 | % [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2000 | % namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2001 | % detect=1; |
---|
| 2002 | % while detect==1 |
---|
| 2003 | % namefigfull=[namedoc '.fig']; |
---|
| 2004 | % hh=dir(namefigfull); |
---|
| 2005 | % if ~isempty(hh) |
---|
| 2006 | % detect=1; |
---|
| 2007 | % namedoc=[namedoc '.0']; |
---|
| 2008 | % else |
---|
| 2009 | % detect=0; |
---|
| 2010 | % end |
---|
| 2011 | % end |
---|
| 2012 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
[2] | 2013 | |
---|
[67] | 2014 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 2015 | %------------------------------------------------------------------------ |
---|
| 2016 | % global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
[73] | 2017 | set(handles.RUN, 'Enable','Off') |
---|
| 2018 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 2019 | batch=0; |
---|
| 2020 | launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 2021 | set(handles.RUN, 'Enable','On') |
---|
| 2022 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 2023 | |
---|
[12] | 2024 | %------------------------------------------------------------------------ |
---|
[2] | 2025 | % --- Executes on button press in BATCH: remote processing |
---|
| 2026 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[12] | 2027 | %------------------------------------------------------------------------ |
---|
[67] | 2028 | %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove |
---|
[73] | 2029 | set(handles.BATCH, 'Enable','Off') |
---|
| 2030 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 2031 | batch=1; |
---|
| 2032 | launch_jobs(hObject, eventdata, handles, batch) |
---|
[73] | 2033 | set(handles.BATCH, 'Enable','On') |
---|
| 2034 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 2035 | |
---|
| 2036 | %------------------------------------------------------------------------ |
---|
| 2037 | % --- Executes on button press in BATCH: remote processing |
---|
| 2038 | function launch_jobs(hObject, eventdata, handles, batch) |
---|
| 2039 | %----------------------------------------------------------------------- |
---|
[2] | 2040 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 2041 | |
---|
| 2042 | %check the list of operations: |
---|
| 2043 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 2044 | run_flag=1; |
---|
| 2045 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 2046 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 2047 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 2048 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 2049 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 2050 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 2051 | index=find(box_test==1); |
---|
| 2052 | if isempty(index) |
---|
| 2053 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 2054 | return |
---|
| 2055 | end |
---|
| 2056 | index_first=min(index); |
---|
| 2057 | index_last=max(index); |
---|
| 2058 | box_used=box_test([index_first : index_last]); |
---|
| 2059 | [box_missing,ind_missing]=min(box_used); |
---|
| 2060 | if isequal(box_missing,0) |
---|
| 2061 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 2062 | return |
---|
| 2063 | end |
---|
| 2064 | |
---|
| 2065 | %root name |
---|
[71] | 2066 | filebase=get(handles.RootName,'String'); |
---|
[2] | 2067 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2068 | msgbox_uvmat('ERROR','no input files') |
---|
| 2069 | return |
---|
| 2070 | end |
---|
| 2071 | |
---|
| 2072 | %check mask if selecetd |
---|
| 2073 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 2074 | maskname=get(handles.mask_civ1,'String'); |
---|
| 2075 | if ~exist(maskname,'file') |
---|
| 2076 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 2077 | end |
---|
[2] | 2078 | end |
---|
| 2079 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 2080 | maskname=get(handles.mask_fix1,'String'); |
---|
| 2081 | if ~exist(maskname,'file') |
---|
| 2082 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 2083 | end |
---|
[2] | 2084 | end |
---|
| 2085 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 2086 | maskname=get(handles.mask_civ2,'String'); |
---|
| 2087 | if ~exist(maskname,'file') |
---|
[2] | 2088 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 2089 | end |
---|
[2] | 2090 | end |
---|
| 2091 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 2092 | maskname=get(handles.mask_fix2,'String'); |
---|
| 2093 | if ~exist(maskname,'file') |
---|
[2] | 2094 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 2095 | end |
---|
[2] | 2096 | end |
---|
| 2097 | |
---|
| 2098 | %read names of the .exe file |
---|
| 2099 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 2100 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[54] | 2101 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 2102 | if exist(xmlfile,'file') |
---|
| 2103 | t=xmltree(xmlfile); |
---|
[67] | 2104 | s=convert(t); |
---|
[2] | 2105 | end |
---|
[67] | 2106 | if batch |
---|
| 2107 | if isfield(s,'BatchParam') |
---|
| 2108 | sparam=s.BatchParam; |
---|
| 2109 | if ~ismember(sparam.BatchMode,{'sge'}) |
---|
| 2110 | msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT']) |
---|
| 2111 | end |
---|
| 2112 | else |
---|
| 2113 | msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml') |
---|
| 2114 | return |
---|
| 2115 | end |
---|
| 2116 | else |
---|
| 2117 | if isfield(s,'RunParam') |
---|
| 2118 | sparam=s.RunParam; |
---|
| 2119 | else |
---|
| 2120 | msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml') |
---|
| 2121 | return |
---|
| 2122 | end |
---|
[2] | 2123 | end |
---|
[67] | 2124 | if isfield(sparam,'CivBin') |
---|
[94] | 2125 | if ~exist(sparam.CivBin,'file') |
---|
| 2126 | sparam.CivBin=fullfile(path_UVMAT,sparam.CivBin); |
---|
| 2127 | end |
---|
[2] | 2128 | end |
---|
[67] | 2129 | if isfield(sparam,'Civ1Bin') |
---|
[94] | 2130 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 2131 | sparam.Civ1Bin=fullfile(path_UVMAT,sparam.Civ1Bin); |
---|
| 2132 | end |
---|
[2] | 2133 | end |
---|
[67] | 2134 | if isfield(sparam,'Civ2Bin') |
---|
[94] | 2135 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 2136 | sparam.Civ2Bin=fullfile(path_UVMAT,sparam.Civ2Bin); |
---|
| 2137 | end |
---|
[2] | 2138 | end |
---|
[100] | 2139 | %test_interp=get(handles.test_interp,'Value'); |
---|
| 2140 | test_interp=0; |
---|
| 2141 | if isfield(sparam,'PatchBin') |
---|
[94] | 2142 | if ~exist(sparam.PatchBin,'file') |
---|
| 2143 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
| 2144 | end |
---|
[67] | 2145 | end |
---|
[100] | 2146 | % if test_interp && isfield(sparam,'PatchNewBin') |
---|
| 2147 | % if ~exist(sparam.PatchNewBin,'file') |
---|
| 2148 | % sparam.PatchNewBin=fullfile(path_UVMAT,sparam.PatchNewBin); |
---|
| 2149 | % end |
---|
| 2150 | % end |
---|
[73] | 2151 | if isfield(sparam,'FixBin') |
---|
[94] | 2152 | % fixBin=sparam.FixBin; |
---|
| 2153 | if ~exist(sparam.FixBin,'file') |
---|
| 2154 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
| 2155 | end |
---|
[73] | 2156 | end |
---|
[67] | 2157 | if batch |
---|
| 2158 | if isfield(sparam,'BatchMode') |
---|
| 2159 | batch_mode=sparam.BatchMode; |
---|
[2] | 2160 | end |
---|
[67] | 2161 | else |
---|
| 2162 | MaxCivProcesses=50; |
---|
| 2163 | if isfield(sparam,'MaxCivProcesses') |
---|
| 2164 | MaxCivProcesses=str2double(sparam.MaxCivProcesses); |
---|
| 2165 | end |
---|
[2] | 2166 | end |
---|
| 2167 | |
---|
| 2168 | %initialize the waitbars |
---|
| 2169 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 2170 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 2171 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 2172 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
[73] | 2173 | |
---|
[2] | 2174 | drawnow |
---|
| 2175 | %get the filename root, nomenclature and numbers |
---|
| 2176 | |
---|
| 2177 | % for Windows system find the UBC path name if needed |
---|
[87] | 2178 | % if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 2179 | % cur_dir=pwd; |
---|
| 2180 | % if ~isequal(cur_dir(2:3),':\') |
---|
| 2181 | % cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 2182 | % end |
---|
| 2183 | % [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 2184 | % if isequal(ss,0) |
---|
| 2185 | % rankpath=findstr(ww,'\\'); |
---|
| 2186 | % if ~isempty(rankpath) |
---|
| 2187 | % wwrest=ww(rankpath:end); |
---|
| 2188 | % rankend=min(find(double(wwrest)==10))-1; |
---|
| 2189 | % filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 2190 | % set(handles.RootName,'String',filebase); |
---|
| 2191 | % end |
---|
| 2192 | % else |
---|
| 2193 | % msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
| 2194 | % % set(handles.BATCH, 'Enable','On') |
---|
| 2195 | % % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2196 | % return |
---|
| 2197 | % end |
---|
| 2198 | % end |
---|
[2] | 2199 | |
---|
| 2200 | % set the list of files and check them |
---|
| 2201 | display('checking the files...') |
---|
| 2202 | [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]=... |
---|
| 2203 | set_civ_filenames(handles,compare,box_test); |
---|
[85] | 2204 | if isempty(filecell) |
---|
| 2205 | return |
---|
| 2206 | end |
---|
[67] | 2207 | %choice of batch priority |
---|
| 2208 | ind_answer=2; |
---|
| 2209 | if batch |
---|
| 2210 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2211 | if isequal(s,0) |
---|
| 2212 | w(end)=[]; |
---|
| 2213 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 2214 | str={'urgent';'normal';'low'}; |
---|
| 2215 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2216 | 'SelectionMode','single',... |
---|
| 2217 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 2218 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 2219 | return % a better way should be create |
---|
| 2220 | end |
---|
| 2221 | else |
---|
| 2222 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 2223 | return |
---|
| 2224 | end |
---|
| 2225 | else |
---|
| 2226 | if isunix |
---|
| 2227 | [s,w]=unix('ps faux |grep civ|wc -l'); |
---|
| 2228 | w(end)=[]; |
---|
| 2229 | if str2num(w)+numel(filecell)> MaxCivProcesses |
---|
| 2230 | msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) |
---|
| 2231 | return |
---|
| 2232 | end |
---|
| 2233 | end |
---|
| 2234 | end |
---|
[41] | 2235 | |
---|
[2] | 2236 | display('files OK, processing...') |
---|
[41] | 2237 | nbfield=numel(num1_civ1); |
---|
| 2238 | nbslice=numel(num_a_civ1); |
---|
[2] | 2239 | |
---|
| 2240 | %GET PARAMETERS: |
---|
| 2241 | %get civ parameters |
---|
| 2242 | if box_test(1)==1 |
---|
| 2243 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
| 2244 | end |
---|
| 2245 | |
---|
| 2246 | %get fix1 parameters |
---|
| 2247 | if box_test(2)==1 |
---|
| 2248 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 2249 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 2250 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 2251 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 2252 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 2253 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2254 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 2255 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[85] | 2256 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
[2] | 2257 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 2258 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 2259 | % fileref=fullfile(refpath,fileref); |
---|
| 2260 | menu=get(handles.field_ref1,'String'); |
---|
| 2261 | index=get(handles.field_ref1,'Value'); |
---|
| 2262 | if isempty(menu) |
---|
| 2263 | fieldchoice=''; |
---|
| 2264 | else |
---|
| 2265 | fieldchoice=menu{index}; |
---|
| 2266 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 2267 | end |
---|
| 2268 | end |
---|
| 2269 | |
---|
| 2270 | %get patch1 parameters |
---|
[67] | 2271 | if box_test(3)==1 |
---|
[2] | 2272 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 2273 | if isempty(rho_patch1) |
---|
| 2274 | rho_patch1='1000'; |
---|
| 2275 | set(handles.rho_patch1,'String','1') |
---|
| 2276 | else |
---|
| 2277 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 2278 | end |
---|
| 2279 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 2280 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 2281 | if isequal(str2num(nx_patch1),[]) |
---|
| 2282 | nx_patch1='50' ;%default |
---|
| 2283 | set(handles.nx_patch1,'String','50'); |
---|
| 2284 | end |
---|
| 2285 | if isequal(str2num(ny_patch1),[]) |
---|
| 2286 | ny_patch1='50' ;%default |
---|
| 2287 | set(handles.ny_patch1,'String','50'); |
---|
| 2288 | end |
---|
| 2289 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 2290 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 2291 | end |
---|
| 2292 | |
---|
| 2293 | %get civ2 parameters |
---|
| 2294 | if box_test(4)==1 |
---|
| 2295 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 2296 | end |
---|
| 2297 | |
---|
| 2298 | %get fix2 parameters |
---|
| 2299 | if box_test(5)==1 |
---|
| 2300 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 2301 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 2302 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
| 2303 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 2304 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 2305 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2306 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
| 2307 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 2308 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 2309 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 2310 | |
---|
| 2311 | %%%%%%%%%%%%%%%%%%% |
---|
| 2312 | end |
---|
| 2313 | |
---|
| 2314 | |
---|
[73] | 2315 | |
---|
[2] | 2316 | %get patch2 parameters |
---|
| 2317 | if box_test(6)==1 |
---|
| 2318 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 2319 | if isempty(rho_patch2) |
---|
| 2320 | rho_patch2='1000'; |
---|
| 2321 | set(handles.rho_patch2,'String','1') |
---|
| 2322 | else |
---|
| 2323 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 2324 | end |
---|
| 2325 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 2326 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 2327 | if isequal(str2num(nx_patch2),[]) |
---|
| 2328 | nx_patch2='50' ;%default |
---|
| 2329 | set(handles.nx_patch2,'String','50'); |
---|
| 2330 | end |
---|
| 2331 | if isequal(str2num(ny_patch2),[]) |
---|
| 2332 | ny_patch2='50' ;%default |
---|
| 2333 | set(handles.ny_patch2,'String','50'); |
---|
| 2334 | end |
---|
| 2335 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 2336 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
[73] | 2337 | % test_interp=get(handles.test_interp,'Value'); |
---|
[2] | 2338 | end |
---|
| 2339 | |
---|
| 2340 | %MAIN LOOP |
---|
| 2341 | % for ifile=1:nbfield |
---|
| 2342 | p1text=[];%initiate command text |
---|
[71] | 2343 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 2344 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
| 2345 | for ifile=1:nbfield |
---|
| 2346 | for j=1:nbslice |
---|
| 2347 | i_cmd=0; |
---|
| 2348 | cmd=''; |
---|
[73] | 2349 | if isunix % check: necessaire aussi en RUN? |
---|
[12] | 2350 | %fid=fopen([filename '.cmx'],'w') |
---|
[90] | 2351 | cmd='#!/bin/bash \n'; |
---|
| 2352 | cmd=[cmd '#$ -cwd \n']; |
---|
| 2353 | cmd=[cmd 'hostname && date \n']; |
---|
[2] | 2354 | end |
---|
| 2355 | if civAll |
---|
| 2356 | civAllxml=xmltree;% xml contents, all parameters |
---|
[73] | 2357 | civAllCmd=''; |
---|
[2] | 2358 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 2359 | end |
---|
[73] | 2360 | filename_cmx=filecell.nc.civ1{ifile,j};%output netcdf file |
---|
[41] | 2361 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
[2] | 2362 | filename_cmx=[filename_cmx 'x']; |
---|
| 2363 | |
---|
| 2364 | %CIV1 |
---|
| 2365 | if box_test(1)==1 |
---|
[41] | 2366 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[73] | 2367 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 2368 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2369 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 2370 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 2371 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 2372 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 2373 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 2374 | if test_mask==0 |
---|
| 2375 | par_civ1.maskname='noFile use default'; |
---|
| 2376 | par_civ1.maskflag='n'; |
---|
| 2377 | else |
---|
| 2378 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 2379 | if exist(maskdispl,'file') |
---|
| 2380 | par_civ1.maskname=maskdispl; |
---|
| 2381 | par_civ1.maskflag='y'; |
---|
[2] | 2382 | else |
---|
[12] | 2383 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2384 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2385 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2386 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2387 | if exist(par_civ1.maskname,'file') |
---|
[82] | 2388 | par_civ1.maskflag='y'; |
---|
[12] | 2389 | else |
---|
| 2390 | par_civ1.maskname='noFile use default'; |
---|
| 2391 | par_civ1.maskflag='n'; |
---|
| 2392 | end |
---|
[2] | 2393 | end |
---|
| 2394 | end |
---|
| 2395 | |
---|
| 2396 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 2397 | if test_grid |
---|
| 2398 | par_civ1.gridflag='y'; |
---|
| 2399 | gridname=get(handles.grid_civ1,'String'); |
---|
| 2400 | if isequal(gridname(end-3:end),'grid') |
---|
| 2401 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2402 | if ~isempty(nbslice_grid) |
---|
| 2403 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2404 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2405 | if ~exist(par_civ1.gridname,'file') |
---|
| 2406 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2407 | end |
---|
| 2408 | elseif exist(gridname,'file') |
---|
| 2409 | par_civ1.gridname=gridname; |
---|
| 2410 | else |
---|
| 2411 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2412 | end |
---|
| 2413 | end |
---|
| 2414 | else |
---|
| 2415 | par_civ1.gridname='noFile use default'; |
---|
| 2416 | par_civ1.gridflag='n'; |
---|
| 2417 | end |
---|
[54] | 2418 | % |
---|
[2] | 2419 | i_cmd=i_cmd+1; |
---|
| 2420 | if isequal(civAll,0) |
---|
[94] | 2421 | cmd=[cmd CIV1_CMD(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam) '\n']; |
---|
[2] | 2422 | else |
---|
| 2423 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
[94] | 2424 | str=CIV1_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
[2] | 2425 | fieldnames=fields(str); |
---|
| 2426 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 2427 | for ilist=1:length(fieldnames) |
---|
| 2428 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2429 | if ischar(val) |
---|
| 2430 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 2431 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2432 | end |
---|
| 2433 | end |
---|
| 2434 | end |
---|
| 2435 | end |
---|
| 2436 | |
---|
| 2437 | % FIX1 |
---|
| 2438 | if box_test(2)==1 |
---|
| 2439 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2440 | if test_mask==0 |
---|
| 2441 | maskname=''; |
---|
| 2442 | else |
---|
| 2443 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 2444 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2445 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2446 | maskbase=[filebase '_' maskdispl]; |
---|
| 2447 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2448 | end |
---|
| 2449 | if isequal(civAll,0) |
---|
[94] | 2450 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
[2] | 2451 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 2452 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[94] | 2453 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 2454 | cmd=[cmd cmd_FIX '\n']; |
---|
[2] | 2455 | else |
---|
| 2456 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2457 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 2458 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 2459 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 2460 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 2461 | fix1.threshV=num2str(thresh_vel1); |
---|
| 2462 | fieldnames=fields(fix1); |
---|
| 2463 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 2464 | for ilist=1:length(fieldnames) |
---|
| 2465 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 2466 | if ischar(val) |
---|
| 2467 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 2468 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2469 | end |
---|
| 2470 | end |
---|
| 2471 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 2472 | end |
---|
| 2473 | end |
---|
| 2474 | |
---|
| 2475 | %PATCH1 |
---|
| 2476 | if box_test(3)==1 |
---|
| 2477 | if isequal(civAll,0) |
---|
[94] | 2478 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 2479 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[90] | 2480 | cmd=[cmd cmd_PATCH '\n']; |
---|
[2] | 2481 | else |
---|
| 2482 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2483 | patch1.nopt=subdomain_patch1; |
---|
| 2484 | patch1.maxdiff=thresh_patch1; |
---|
| 2485 | patch1.ro=rho_patch1; |
---|
| 2486 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 2487 | if test_grid |
---|
| 2488 | patch1.gridflag='y'; |
---|
| 2489 | gridname=get(handles.grid_patch1,'String'); |
---|
| 2490 | if isequal(gridname(end-3:end),'grid') |
---|
| 2491 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2492 | if ~isempty(nbslice_grid) |
---|
| 2493 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2494 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2495 | if ~exist(patch1.gridPatch,'file') |
---|
| 2496 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2497 | end |
---|
| 2498 | elseif exist(gridname,'file') |
---|
| 2499 | patch1.gridPatch=gridname; |
---|
| 2500 | else |
---|
| 2501 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2502 | end |
---|
| 2503 | end |
---|
| 2504 | else |
---|
[86] | 2505 | patch1.gridPatch='none'; |
---|
[2] | 2506 | patch1.gridflag='n'; |
---|
| 2507 | patch1.m=nx_patch1; |
---|
| 2508 | patch1.n=ny_patch1; |
---|
| 2509 | end |
---|
| 2510 | patch1.convectFlow='n'; |
---|
| 2511 | fieldnames=fields(patch1); |
---|
| 2512 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2513 | for ilist=1:length(fieldnames) |
---|
| 2514 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2515 | if ischar(val) |
---|
| 2516 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2517 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2518 | end |
---|
| 2519 | end |
---|
| 2520 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2521 | end |
---|
| 2522 | end |
---|
| 2523 | |
---|
| 2524 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
| 2525 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
| 2526 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 2527 | filename_cmx=[filename_cmx 'x']; |
---|
| 2528 | end |
---|
| 2529 | |
---|
| 2530 | if box_test(4)==1 |
---|
| 2531 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2532 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2533 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2534 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2535 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2536 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 2537 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 2538 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 2539 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 2540 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2541 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2542 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 2543 | if test_mask==0 |
---|
| 2544 | par_civ2.maskname='noFile use default'; |
---|
| 2545 | par_civ2.maskflag='n'; |
---|
| 2546 | else |
---|
| 2547 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2548 | if exist(maskdispl,'file') |
---|
| 2549 | par_civ2.maskname=maskdispl; |
---|
| 2550 | par_civ2.maskflag='y'; |
---|
[2] | 2551 | else |
---|
[12] | 2552 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2553 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2554 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2555 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2556 | if exist(par_civ2.maskname,'file') |
---|
| 2557 | par_civ2.maskflag='y'; |
---|
| 2558 | else |
---|
| 2559 | par_civ2.maskname='noFile use default'; |
---|
| 2560 | par_civ2.maskflag='n'; |
---|
| 2561 | end |
---|
[2] | 2562 | end |
---|
| 2563 | end |
---|
| 2564 | %TESTgrid |
---|
| 2565 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 2566 | gridname=get(handles.grid_civ2,'String'); |
---|
| 2567 | gridflag='y'; |
---|
| 2568 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
| 2569 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2570 | if ~isempty(nbslice_grid) |
---|
| 2571 | par_civ2.gridflag='y'; |
---|
| 2572 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2573 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2574 | if exist(par_civ2.gridname,'file') |
---|
| 2575 | par_civ2.gridflag='y'; |
---|
| 2576 | else |
---|
| 2577 | par_civ2.gridname='noFile use default'; |
---|
| 2578 | par_civ2.gridflag='n'; |
---|
| 2579 | end |
---|
| 2580 | elseif exist(gridname,'file') |
---|
| 2581 | par_civ2.gridflag='y'; |
---|
| 2582 | else |
---|
| 2583 | par_civ2.gridname='noFile use default'; |
---|
| 2584 | par_civ2.gridflag='n'; |
---|
| 2585 | end |
---|
| 2586 | end |
---|
| 2587 | %endTESTgrid |
---|
| 2588 | i_cmd=i_cmd+1; |
---|
[94] | 2589 | cmd_CIV2=CIV2_CMD(filename_cmx,namelog,par_civ2,sparam); |
---|
[2] | 2590 | if isequal(civAll,0) |
---|
| 2591 | if(isunix) |
---|
[90] | 2592 | cmd=[cmd 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2 '\n']; |
---|
[2] | 2593 | else |
---|
[94] | 2594 | filename_cmx=regexprep(filename_cmx,'\\','\\\\'); |
---|
[90] | 2595 | cmd=[cmd 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2 '\n']; |
---|
[2] | 2596 | end |
---|
| 2597 | else |
---|
| 2598 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
[94] | 2599 | str=CIV2_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
[2] | 2600 | fieldnames=fields(str); |
---|
| 2601 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2602 | for ilist=1:length(fieldnames) |
---|
| 2603 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2604 | if ischar(val) |
---|
| 2605 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2606 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2607 | end |
---|
| 2608 | end |
---|
| 2609 | end |
---|
| 2610 | end |
---|
| 2611 | |
---|
| 2612 | % FIX2 |
---|
[12] | 2613 | if box_test(5)==1 |
---|
[2] | 2614 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2615 | if test_mask==0 |
---|
| 2616 | maskname=''; %no mask used |
---|
| 2617 | else |
---|
| 2618 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 2619 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2620 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2621 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2622 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2623 | end |
---|
| 2624 | if isequal(civAll,0) |
---|
[94] | 2625 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[2] | 2626 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2627 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[94] | 2628 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 2629 | cmd=[cmd cmd_FIX '\n']; |
---|
[2] | 2630 | else |
---|
| 2631 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2632 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2633 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2634 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2635 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2636 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2637 | fieldnames=fields(fix2); |
---|
| 2638 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2639 | for ilist=1:length(fieldnames) |
---|
| 2640 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2641 | if ischar(val) |
---|
| 2642 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2643 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2644 | end |
---|
| 2645 | end |
---|
| 2646 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2647 | end |
---|
| 2648 | end |
---|
| 2649 | |
---|
| 2650 | %PATCH2 |
---|
[12] | 2651 | if box_test(6)==1 |
---|
| 2652 | if isequal(civAll,0) |
---|
[94] | 2653 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
| 2654 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[90] | 2655 | cmd=[cmd cmd_PATCH '\n']; |
---|
[12] | 2656 | else |
---|
| 2657 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2658 | patch2.nopt=subdomain_patch1; |
---|
| 2659 | patch2.maxdiff=thresh_patch1; |
---|
| 2660 | patch2.ro=rho_patch1; |
---|
| 2661 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2662 | if test_grid |
---|
| 2663 | patch2.gridflag='y'; |
---|
| 2664 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2665 | if isequal(gridname(end-3:end),'grid') |
---|
| 2666 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2667 | if ~isempty(nbslice_grid) |
---|
| 2668 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2669 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2670 | if ~exist(patch2.gridPatch,'file') |
---|
| 2671 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2672 | end |
---|
| 2673 | elseif exist(gridname,'file') |
---|
| 2674 | patch2.gridPatch=gridname; |
---|
| 2675 | else |
---|
| 2676 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2677 | end |
---|
| 2678 | end |
---|
[12] | 2679 | else |
---|
[86] | 2680 | patch2.gridPatch='none'; |
---|
[12] | 2681 | patch2.gridflag='n'; |
---|
| 2682 | patch2.m=nx_patch2; |
---|
| 2683 | patch2.n=ny_patch2; |
---|
[2] | 2684 | end |
---|
[12] | 2685 | patch2.convectFlow='n'; |
---|
| 2686 | fieldnames=fields(patch2); |
---|
| 2687 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2688 | for ilist=1:length(fieldnames) |
---|
| 2689 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2690 | if ischar(val) |
---|
| 2691 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2692 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2693 | end |
---|
| 2694 | end |
---|
| 2695 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
| 2696 | end |
---|
| 2697 | end |
---|
| 2698 | if isequal(civAll,1) |
---|
| 2699 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
[73] | 2700 | %cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
[90] | 2701 | cmd=[cmd CivBin ' -f ' filename_cmx(1:end-4) '.xml ' civAllCmd '\n']; |
---|
[12] | 2702 | end |
---|
| 2703 | % create the .bat file: |
---|
[67] | 2704 | if batch |
---|
[12] | 2705 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2706 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
| 2707 | else |
---|
| 2708 | filename_bat=filename_cmx; |
---|
| 2709 | end |
---|
| 2710 | filename_bat(end-2:end)='bat'; |
---|
| 2711 | fid=fopen(filename_bat,'w'); |
---|
[39] | 2712 | fprintf(fid,cmd); |
---|
| 2713 | fclose(fid); |
---|
[12] | 2714 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
[67] | 2715 | if batch |
---|
| 2716 | switch batch_mode |
---|
| 2717 | case 'sge' |
---|
| 2718 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2719 | namelog=[filename_bat '.patch.log']; |
---|
[73] | 2720 | display(['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
[67] | 2721 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2722 | end |
---|
[12] | 2723 | else |
---|
[67] | 2724 | %% to lauch the jobs locally : |
---|
[12] | 2725 | if(isunix) |
---|
[67] | 2726 | eval(['!. ' filename_bat ' &']); |
---|
[73] | 2727 | display(['!. ' filename_bat ' &']) |
---|
[2] | 2728 | else |
---|
[67] | 2729 | eval(['!' filename_bat ' &']); |
---|
[73] | 2730 | display(['!' filename_bat ' &']) |
---|
[2] | 2731 | end |
---|
[12] | 2732 | end |
---|
[2] | 2733 | end |
---|
| 2734 | end |
---|
[85] | 2735 | % set(handles.BATCH, 'Enable','On') |
---|
| 2736 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[2] | 2737 | |
---|
| 2738 | %save interface state |
---|
| 2739 | if isfield(filecell,'nc') |
---|
| 2740 | if isfield(filecell.nc,'civ2') |
---|
| 2741 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2742 | else |
---|
| 2743 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2744 | end |
---|
| 2745 | end |
---|
| 2746 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2747 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2748 | detect=1; |
---|
| 2749 | while detect==1 |
---|
| 2750 | namefigfull=[namedoc '.fig']; |
---|
| 2751 | hh=dir(namefigfull); |
---|
| 2752 | if ~isempty(hh) |
---|
| 2753 | detect=1; |
---|
| 2754 | namedoc=[namedoc '.0']; |
---|
| 2755 | else |
---|
| 2756 | detect=0; |
---|
| 2757 | end |
---|
| 2758 | end |
---|
| 2759 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2760 | |
---|
[12] | 2761 | %------------------------------------------------------------------------ |
---|
[2] | 2762 | %OUTPUT: |
---|
| 2763 | % filecell: structure of input and output files |
---|
| 2764 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
| 2765 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
| 2766 | % .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) |
---|
| 2767 | % .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) |
---|
| 2768 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
| 2769 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
| 2770 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
[41] | 2771 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
| 2772 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
| 2773 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
| 2774 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
| 2775 | % nom_type_nc: nomenclature type for velocity files |
---|
| 2776 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
[2] | 2777 | 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]=... |
---|
| 2778 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2779 | %------------------------------------------------------------------------ |
---|
[85] | 2780 | filecell=[];%default |
---|
[2] | 2781 | %get the filename root, nomenclature and numbers |
---|
[71] | 2782 | filebase=get(handles.RootName,'String'); |
---|
[2] | 2783 | browse=get(handles.browse_root,'UserData'); |
---|
| 2784 | compare_list=get(handles.compare,'String'); |
---|
| 2785 | val=get(handles.compare,'Value'); |
---|
| 2786 | compare=compare_list{val}; |
---|
| 2787 | if strcmp(compare,'displacement') |
---|
| 2788 | mode='displacement'; |
---|
| 2789 | else |
---|
| 2790 | mode_list=get(handles.mode,'String'); |
---|
| 2791 | mode_value=get(handles.mode,'Value'); |
---|
| 2792 | mode=mode_list{mode_value}; |
---|
| 2793 | end |
---|
[71] | 2794 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
| 2795 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2796 | nom_type_nc=browse.nom_type_nc; |
---|
| 2797 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2798 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 2799 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 2800 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2801 | find_pair_indices(handles,mode); |
---|
| 2802 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2803 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2804 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
| 2805 | test_disp=1; |
---|
| 2806 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2807 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2808 | Path1=Path2; |
---|
[71] | 2809 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2810 | filebase_A=fullfile(Path1,Name1); |
---|
| 2811 | if length(Name1)>6 |
---|
| 2812 | Name1=Name1(end-5:end); |
---|
| 2813 | end |
---|
| 2814 | if length(Name2)>6 |
---|
| 2815 | Name2=Name2(end-5:end); |
---|
| 2816 | end |
---|
| 2817 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2818 | else |
---|
| 2819 | test_disp=0; |
---|
| 2820 | filebase_A=filebase; |
---|
| 2821 | nom_type_ima1=nom_type_ima2; |
---|
| 2822 | filebase_AB=filebase; |
---|
| 2823 | end |
---|
| 2824 | if strcmp(compare,'displacement') |
---|
| 2825 | filebase_ima1=filebase_A; |
---|
| 2826 | filebase_ima2=filebase_B; |
---|
| 2827 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
| 2828 | else |
---|
| 2829 | filebase_ima1=filebase_B; |
---|
| 2830 | filebase_ima2=filebase_B; |
---|
| 2831 | filebase_nc=filebase_B; |
---|
| 2832 | end |
---|
| 2833 | |
---|
| 2834 | %determine reference files for fix: |
---|
| 2835 | file_ref_fix1={};%default |
---|
| 2836 | file_ref_fix2={}; |
---|
| 2837 | nbfield=length(num1_civ1); |
---|
| 2838 | nbslice=length(num_a_civ1); |
---|
| 2839 | if box_test(2)==1% fix1 performed |
---|
| 2840 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2841 | if ~isempty(ref) |
---|
| 2842 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2843 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2844 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2845 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2846 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2847 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2848 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2849 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2850 | if isequal(mode,'displacement') |
---|
| 2851 | num_i1=num_i_ref; |
---|
| 2852 | num_i2=num_i_ref; |
---|
| 2853 | num_j1=num_j_ref; |
---|
| 2854 | num_j2=num_j_ref; |
---|
| 2855 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2856 | num_i1=num_i_ref; |
---|
| 2857 | num_i2=num_i1; |
---|
| 2858 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2859 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2860 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2861 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2862 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2863 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2864 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2865 | if isempty(ref.num_a) |
---|
| 2866 | ref.num_a=1; |
---|
| 2867 | end |
---|
| 2868 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2869 | num_j2=num_j1; |
---|
| 2870 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2871 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2872 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2873 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2874 | num_i2=num_i1; |
---|
| 2875 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2876 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2877 | end |
---|
| 2878 | for ifile=1:nbfield |
---|
| 2879 | for j=1:nbslice |
---|
| 2880 | 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);% |
---|
| 2881 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2882 | if ~exist(file_ref,'file') |
---|
| 2883 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2884 | filecell=[]; |
---|
[2] | 2885 | return |
---|
| 2886 | end |
---|
| 2887 | end |
---|
| 2888 | end |
---|
| 2889 | end |
---|
| 2890 | end |
---|
| 2891 | |
---|
| 2892 | %determine reference files for fix2: |
---|
| 2893 | if box_test(5)==1% fix2 performed |
---|
| 2894 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2895 | if ~isempty(ref) |
---|
| 2896 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2897 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2898 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2899 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2900 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2901 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2902 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2903 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2904 | if isequal(mode,'displacement') |
---|
| 2905 | num_i1=num_i_ref; |
---|
| 2906 | num_i2=num_i_ref; |
---|
| 2907 | num_j1=num_j_ref; |
---|
| 2908 | num_j2=num_j_ref; |
---|
| 2909 | elseif isequal(mode,'pair j1-j2') |
---|
| 2910 | num_i1=num_i_ref; |
---|
| 2911 | num_i2=num_i1; |
---|
| 2912 | num_j1=ref.num_a; |
---|
| 2913 | num_j2=ref.num_b; |
---|
| 2914 | elseif isequal(mode,'series(Di)') |
---|
| 2915 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2916 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2917 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2918 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2919 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2920 | num_j2=num_j1; |
---|
| 2921 | elseif isequal(mode,'series(Dj)') |
---|
| 2922 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2923 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2924 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2925 | num_i2=num_i1; |
---|
| 2926 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2927 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2928 | end |
---|
| 2929 | for ifile=1:nbfield |
---|
| 2930 | for j=1:nbslice |
---|
| 2931 | 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);% |
---|
| 2932 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2933 | if ~exist(file_ref,'file') |
---|
| 2934 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[12] | 2935 | filecell=[]; |
---|
[2] | 2936 | return |
---|
| 2937 | end |
---|
| 2938 | end |
---|
| 2939 | end |
---|
| 2940 | end |
---|
| 2941 | end |
---|
| 2942 | |
---|
| 2943 | %check dir |
---|
| 2944 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2945 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2946 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2947 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 2948 | currentdir=pwd;%store the current working directory |
---|
| 2949 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2950 | if ~exist(Path_ima,'dir') |
---|
[12] | 2951 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
| 2952 | filecell=[]; |
---|
[2] | 2953 | return |
---|
| 2954 | end |
---|
| 2955 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
| 2956 | dircur=pwd; %current working directory |
---|
| 2957 | m2=''; |
---|
| 2958 | [erread,message]=fileattrib(Path_ima); |
---|
| 2959 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 2960 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[12] | 2961 | filecell=[]; |
---|
[2] | 2962 | cd(currentdir); |
---|
| 2963 | return |
---|
| 2964 | end |
---|
| 2965 | |
---|
| 2966 | %check the existence of the netcdf and image files involved |
---|
| 2967 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2968 | if box_test(1)==1; |
---|
| 2969 | detect=1; |
---|
| 2970 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 2971 | for ifile=1:nbfield; |
---|
| 2972 | for j=1:nbslice |
---|
| 2973 | 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); |
---|
| 2974 | detect=exist(filename,'file')==2; |
---|
| 2975 | if detect% if a netcdf file already exists |
---|
| 2976 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2977 | subdir_civ2=subdir_civ1; |
---|
| 2978 | break |
---|
| 2979 | end |
---|
| 2980 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2981 | end |
---|
| 2982 | if detect% if a netcdf file already exists |
---|
| 2983 | break |
---|
| 2984 | end |
---|
| 2985 | end |
---|
| 2986 | %create the new subdir_civ1 |
---|
| 2987 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2988 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 2989 | if ~isequal(m2,'') |
---|
| 2990 | msgbox_uvmat('ERROR', m2) |
---|
| 2991 | %msgbox(m2);%error message for directory creation |
---|
| 2992 | end |
---|
| 2993 | end |
---|
| 2994 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2995 | for ifile=1:nbfield |
---|
| 2996 | for j=1:nbslice |
---|
| 2997 | 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);% |
---|
| 2998 | detect=exist(filename,'file')==2; |
---|
| 2999 | if detect% if a netcdf file already exists |
---|
| 3000 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 3001 | subdir_civ2=subdir_civ1; |
---|
| 3002 | break |
---|
| 3003 | end |
---|
| 3004 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3005 | end |
---|
| 3006 | if detect% if a netcdf file already exists |
---|
| 3007 | break |
---|
| 3008 | end |
---|
| 3009 | end |
---|
| 3010 | %create the new subdir_civ1 |
---|
| 3011 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 3012 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 3013 | if ~isequal(m2,'') |
---|
| 3014 | msgbox_uvmat('ERROR', m2) |
---|
| 3015 | end |
---|
| 3016 | end |
---|
| 3017 | end |
---|
| 3018 | end |
---|
| 3019 | % get image names |
---|
| 3020 | for ifile=1:nbfield |
---|
| 3021 | for j=1:nbslice |
---|
| 3022 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3023 | idetect(j)=exist(filename,'file')==2; |
---|
| 3024 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 3025 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3026 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3027 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
| 3028 | end |
---|
| 3029 | [idetectmin,indexj]=min(idetect); |
---|
| 3030 | if idetectmin==0, |
---|
| 3031 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3032 | filecell=[]; |
---|
[2] | 3033 | return |
---|
| 3034 | end |
---|
| 3035 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3036 | if idetectmin==0, |
---|
| 3037 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3038 | filecell=[]; |
---|
[2] | 3039 | cd(currentdir) |
---|
| 3040 | return |
---|
| 3041 | end |
---|
| 3042 | end |
---|
| 3043 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 3044 | for ifile=1:nbfield |
---|
| 3045 | for j=1:nbslice |
---|
| 3046 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3047 | idetect(j)=exist(filename,'file')==2; |
---|
| 3048 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 3049 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3050 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3051 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 3052 | end |
---|
| 3053 | [idetectmin,indexj]=min(idetect); |
---|
| 3054 | if idetectmin==0, |
---|
| 3055 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3056 | filecell=[]; |
---|
| 3057 | cd(currentdir) |
---|
| 3058 | return |
---|
[2] | 3059 | end |
---|
| 3060 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3061 | if idetectmin==0, |
---|
[12] | 3062 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
| 3063 | filecell=[]; |
---|
| 3064 | cd(currentdir) |
---|
| 3065 | return |
---|
[2] | 3066 | end |
---|
| 3067 | end |
---|
| 3068 | end |
---|
| 3069 | |
---|
| 3070 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 3071 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
| 3072 | for ifile=1:nbfield |
---|
| 3073 | for j=1:nbslice |
---|
| 3074 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3075 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3076 | detect=exist(filename,'file')==2; |
---|
| 3077 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3078 | end |
---|
| 3079 | end |
---|
| 3080 | if strcmp(compare,'stereo PIV') |
---|
| 3081 | for ifile=1:nbfield |
---|
| 3082 | for j=1:nbslice |
---|
| 3083 | 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);% |
---|
| 3084 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3085 | if ~exist(filename,'file') |
---|
| 3086 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3087 | set(handles.RUN, 'Enable','On') |
---|
| 3088 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[85] | 3089 | % set(handles.BATCH, 'Enable','On') |
---|
| 3090 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 3091 | filecell=[]; |
---|
[2] | 3092 | cd(currentdir) |
---|
| 3093 | return |
---|
| 3094 | end |
---|
| 3095 | end |
---|
| 3096 | end |
---|
| 3097 | end |
---|
| 3098 | end |
---|
| 3099 | |
---|
| 3100 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 3101 | testdiff=0; |
---|
| 3102 | if (box_test(4)==1)&&... |
---|
| 3103 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
| 3104 | testdiff=1; |
---|
| 3105 | detect=1; |
---|
| 3106 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3107 | for ifile=1:nbfield |
---|
| 3108 | for j=1:nbslice |
---|
| 3109 | 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);% |
---|
| 3110 | detect=exist(filename,'file')==2; |
---|
| 3111 | if detect% if a netcdf file already exists |
---|
| 3112 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3113 | break |
---|
| 3114 | end |
---|
| 3115 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3116 | end |
---|
| 3117 | if detect% if a netcdf file already exists |
---|
| 3118 | break |
---|
| 3119 | end |
---|
| 3120 | end |
---|
| 3121 | %create the new subdir_civ2 |
---|
| 3122 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3123 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3124 | if ~isequal(m2,'') |
---|
| 3125 | msgbox_uvmat('ERROR', m2) |
---|
| 3126 | end |
---|
| 3127 | end |
---|
| 3128 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 3129 | for ifile=1:nbfield |
---|
| 3130 | for j=1:nbslice |
---|
| 3131 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3132 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
| 3133 | detect=exist(filename,'file')==2; |
---|
| 3134 | if detect% if a netcdf file already exists |
---|
| 3135 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3136 | break |
---|
| 3137 | end |
---|
| 3138 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3139 | end |
---|
| 3140 | if detect% if a netcdf file already exists |
---|
| 3141 | break |
---|
| 3142 | end |
---|
| 3143 | end |
---|
| 3144 | %create the new subdir_civ1 |
---|
| 3145 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3146 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3147 | if ~isequal(m2,'') |
---|
| 3148 | msgbox_uvmat('ERROR', m2) |
---|
| 3149 | %msgbox(m2);%error message for directory creation |
---|
| 3150 | end |
---|
| 3151 | end |
---|
| 3152 | end |
---|
| 3153 | end |
---|
| 3154 | end |
---|
| 3155 | cd(currentdir);%come back to the current working directory |
---|
| 3156 | |
---|
| 3157 | |
---|
| 3158 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 3159 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 3160 | %check source netcdf file of civ1 estimates |
---|
| 3161 | if box_test(1)==0; %no civ1 performed |
---|
| 3162 | for ifile=1:nbfield |
---|
| 3163 | for j=1:nbslice |
---|
| 3164 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3165 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3166 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 3167 | if ~exist(filename,'file') |
---|
| 3168 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3169 | filecell=[]; |
---|
[2] | 3170 | return |
---|
| 3171 | end |
---|
| 3172 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 3173 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 3174 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3175 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3176 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3177 | filecell=[]; |
---|
[2] | 3178 | return |
---|
| 3179 | end |
---|
| 3180 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 3181 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 3182 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 3183 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 3184 | filecell=[]; |
---|
[2] | 3185 | return |
---|
| 3186 | end |
---|
| 3187 | end |
---|
| 3188 | end |
---|
| 3189 | end |
---|
| 3190 | end |
---|
| 3191 | if strcmp(compare,'stereo PIV') |
---|
| 3192 | for ifile=1:nbfield |
---|
| 3193 | for j=1:nbslice |
---|
| 3194 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3195 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3196 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3197 | if ~exist(filename,'file') |
---|
| 3198 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3199 | set(handles.RUN, 'Enable','On') |
---|
| 3200 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[85] | 3201 | % set(handles.BATCH, 'Enable','On') |
---|
| 3202 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[2] | 3203 | cd(currentdir) |
---|
| 3204 | return |
---|
| 3205 | end |
---|
| 3206 | end |
---|
| 3207 | end |
---|
| 3208 | end |
---|
| 3209 | end |
---|
| 3210 | |
---|
| 3211 | detect=1; |
---|
| 3212 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 3213 | for ifile=1:nbfield |
---|
| 3214 | for j=1:nbslice |
---|
| 3215 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3216 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
| 3217 | detect=exist(filename,'file')==2; |
---|
| 3218 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3219 | end |
---|
| 3220 | end |
---|
| 3221 | %get first image names for civ2 |
---|
| 3222 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 3223 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 3224 | elseif box_test(4)==1 |
---|
| 3225 | for ifile=1:nbfield |
---|
| 3226 | for j=1:nbslice |
---|
| 3227 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 3228 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 3229 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 3230 | end |
---|
| 3231 | [idetectmin,indexj]=min(idetect_2); |
---|
| 3232 | if idetectmin==0, |
---|
| 3233 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3234 | filecell=[]; |
---|
[2] | 3235 | return |
---|
| 3236 | end |
---|
| 3237 | end |
---|
| 3238 | end |
---|
| 3239 | |
---|
| 3240 | %get second image names for civ2 |
---|
| 3241 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 3242 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 3243 | elseif box_test(4)==1 |
---|
| 3244 | for ifile=1:nbfield |
---|
| 3245 | for j=1:nbslice |
---|
| 3246 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 3247 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 3248 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 3249 | end |
---|
| 3250 | [idetectmin,indexj]=min(idetect_3); |
---|
| 3251 | if idetectmin==0, |
---|
| 3252 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3253 | filecell=[]; |
---|
[2] | 3254 | return |
---|
| 3255 | end |
---|
| 3256 | end |
---|
| 3257 | end |
---|
| 3258 | end |
---|
| 3259 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 3260 | if ~testdiff |
---|
| 3261 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
| 3262 | else % check the civ2 files |
---|
| 3263 | for ifile=1:nbfield |
---|
| 3264 | for j=1:nbslice |
---|
| 3265 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3266 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3267 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3268 | if ~exist(filename,'file') |
---|
| 3269 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3270 | filecell=[]; |
---|
[2] | 3271 | return |
---|
| 3272 | else |
---|
| 3273 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3274 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3275 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3276 | filecell=[]; |
---|
[2] | 3277 | return |
---|
| 3278 | end |
---|
| 3279 | end |
---|
| 3280 | end |
---|
| 3281 | end |
---|
| 3282 | end |
---|
| 3283 | end |
---|
| 3284 | |
---|
| 3285 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 3286 | if strcmp(compare,'stereo PIV') |
---|
| 3287 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 3288 | for ifile=1:nbfield |
---|
| 3289 | for j=1:nbslice |
---|
| 3290 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3291 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3292 | filecell.st(ifile,j)={filename}; |
---|
| 3293 | end |
---|
| 3294 | end |
---|
| 3295 | end |
---|
| 3296 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 3297 | for ifile=1:nbfield |
---|
| 3298 | for j=1:nbslice |
---|
| 3299 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3300 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3301 | filecell.st(ifile,j)={filename}; |
---|
| 3302 | end |
---|
| 3303 | end |
---|
| 3304 | end |
---|
| 3305 | end |
---|
| 3306 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3307 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3308 | browse.nom_type_nc=nom_type_nc; |
---|
| 3309 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 3310 | |
---|
| 3311 | |
---|
| 3312 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 3313 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 3314 | nom_type_imanew1='_i'; |
---|
[2] | 3315 | else |
---|
| 3316 | nom_type_imanew1=nom_type_ima1; |
---|
| 3317 | end |
---|
[45] | 3318 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 3319 | nom_type_imanew2='_i'; |
---|
[2] | 3320 | else |
---|
| 3321 | nom_type_imanew2=nom_type_ima2; |
---|
| 3322 | end |
---|
| 3323 | if ~isequal(ext_ima,'.png') |
---|
[45] | 3324 | %%type of image file |
---|
| 3325 | type_ima1='none';%default |
---|
| 3326 | movieobject1=[];%default |
---|
| 3327 | if isequal(lower(ext_ima),'.avi') |
---|
| 3328 | hhh=which('mmreader'); |
---|
| 3329 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3330 | type_ima1='movie'; |
---|
| 3331 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 3332 | else |
---|
| 3333 | type_ima1='avi'; |
---|
| 3334 | end |
---|
| 3335 | else |
---|
| 3336 | form=imformats(ext_ima(2:end)); |
---|
| 3337 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3338 | if isequal(nom_type_ima1,'*'); |
---|
| 3339 | type_ima1='multimage';%image series in a single image file |
---|
| 3340 | else |
---|
| 3341 | type_ima1='image'; |
---|
| 3342 | end |
---|
| 3343 | end |
---|
| 3344 | end |
---|
| 3345 | type_ima2='none';%default |
---|
| 3346 | movieobject2=[]; |
---|
| 3347 | if isequal(lower(ext_ima),'.avi') |
---|
| 3348 | hhh=which('mmreader'); |
---|
| 3349 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3350 | type_ima2='movie'; |
---|
| 3351 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 3352 | else |
---|
| 3353 | type_ima2='avi'; |
---|
| 3354 | end |
---|
| 3355 | else |
---|
| 3356 | form=imformats(ext_ima(2:end)); |
---|
| 3357 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3358 | if isequal(nom_type_ima1,'*'); |
---|
| 3359 | type_ima2='multimage';%image series in a single image file |
---|
| 3360 | else |
---|
| 3361 | type_ima2='image'; |
---|
| 3362 | end |
---|
| 3363 | end |
---|
| 3364 | end |
---|
[71] | 3365 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[2] | 3366 | % % if numel(npxy)<2 |
---|
| 3367 | % |
---|
[71] | 3368 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
[2] | 3369 | % A=imread(filename); |
---|
| 3370 | % npxy=size(A); |
---|
| 3371 | % % end |
---|
| 3372 | % npy=npxy(1); |
---|
| 3373 | % npx=npxy(2); |
---|
| 3374 | if box_test(1)==1 %if civ1 is performed |
---|
| 3375 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 3376 | for ifile=1:nbfield |
---|
| 3377 | waitbar(ifile/nbfield); |
---|
| 3378 | for j=1:nbslice |
---|
| 3379 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3380 | if ~exist(filename,'file') |
---|
[45] | 3381 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
[2] | 3382 | imwrite(A,filename,'BitDepth',16); |
---|
| 3383 | end |
---|
| 3384 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3385 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3386 | if ~exist(filename,'file') |
---|
[45] | 3387 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
[2] | 3388 | imwrite(A,filename,'BitDepth',16); |
---|
| 3389 | end |
---|
| 3390 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
| 3391 | end |
---|
| 3392 | end |
---|
| 3393 | close(h) |
---|
| 3394 | end |
---|
| 3395 | if box_test(4)==1 %if civ2 is performed |
---|
| 3396 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
| 3397 | for ifile=1:nbfield |
---|
| 3398 | waitbar(ifile/nbfield); |
---|
| 3399 | for j=1:nbslice |
---|
| 3400 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3401 | if ~exist(filename,'file') |
---|
[84] | 3402 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
[2] | 3403 | imwrite(A,filename,'BitDepth',16); |
---|
| 3404 | end |
---|
| 3405 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3406 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3407 | if ~exist(filename,'file') |
---|
[84] | 3408 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
[2] | 3409 | imwrite(A,filename,'BitDepth',16); |
---|
| 3410 | end |
---|
| 3411 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
| 3412 | end |
---|
| 3413 | end |
---|
| 3414 | close(h); |
---|
| 3415 | end |
---|
| 3416 | end |
---|
| 3417 | |
---|
[12] | 3418 | %------------------------------------------------------------------------ |
---|
[73] | 3419 | %CIV1 CIV1 CIV1 CIV1 NOT USED: replaced by RUN_BATCH |
---|
[2] | 3420 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3421 | %------------------------------------------------------------------------ |
---|
[2] | 3422 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 3423 | global civ1Bin sge%name of the executable for civ1 calculation |
---|
[2] | 3424 | |
---|
| 3425 | %get civ parameters |
---|
| 3426 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 3427 | if isempty(ibx_val) |
---|
| 3428 | ibx='21'; set(handles.ibx,'String','21') |
---|
| 3429 | else |
---|
| 3430 | ibx=num2str(ibx_val); |
---|
| 3431 | end |
---|
| 3432 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 3433 | if isempty(iby_val) |
---|
| 3434 | iby='21'; set(handles.iby,'String','21') |
---|
| 3435 | else |
---|
| 3436 | iby=num2str(iby_val); |
---|
| 3437 | end |
---|
| 3438 | isx=get(handles.isx,'String'); |
---|
| 3439 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3440 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 3441 | isy=get(handles.isy,'String'); |
---|
| 3442 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3443 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 3444 | shiftx=get(handles.shiftx,'String'); |
---|
| 3445 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
| 3446 | shifty=get(handles.shifty,'String'); |
---|
| 3447 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
| 3448 | rho=get(handles.rho,'String'); |
---|
| 3449 | dx=get(handles.dx_civ1,'String'); |
---|
| 3450 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
| 3451 | dy=get(handles.dy_civ1,'String'); |
---|
| 3452 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
| 3453 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
| 3454 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
| 3455 | pxcmy='1'; |
---|
| 3456 | image_first=cell2mat(filecell(1,1)); |
---|
| 3457 | if ~exist(image_first,'file') |
---|
| 3458 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
| 3459 | set(handles.RUN, 'Enable','On') |
---|
| 3460 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3461 | return |
---|
| 3462 | end |
---|
| 3463 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
| 3464 | sizim=size(A); |
---|
| 3465 | npx=num2str(sizim(2)); |
---|
| 3466 | npy=num2str(sizim(1)); |
---|
[71] | 3467 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3468 | gridname='';%default ='noFile use default' |
---|
| 3469 | gridflag='n';%default |
---|
| 3470 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 3471 | nbslice_grid=[]; |
---|
| 3472 | if test_grid |
---|
| 3473 | gridname=get(handles.grid_civ1,'String'); |
---|
| 3474 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3475 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3476 | if ~isempty(nbslice_grid) |
---|
| 3477 | gridflag='y'; |
---|
| 3478 | end |
---|
| 3479 | elseif exist(gridname,'file') |
---|
| 3480 | gridflag='y'; |
---|
| 3481 | else |
---|
| 3482 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3483 | return |
---|
| 3484 | end |
---|
| 3485 | end |
---|
| 3486 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 3487 | threshflag='y'; |
---|
| 3488 | min_ima=get(handles.MinIma,'String'); |
---|
| 3489 | max_ima=get(handles.MaxIma,'String'); |
---|
| 3490 | else |
---|
| 3491 | threshflag='n'; |
---|
| 3492 | min_ima='0'; |
---|
| 3493 | max_ima='4096'; |
---|
| 3494 | end |
---|
| 3495 | %main loop |
---|
[71] | 3496 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3497 | sizcell=size(filecell); |
---|
| 3498 | nbfield=sizcell(1); |
---|
| 3499 | nbslice=sizcell(2); |
---|
| 3500 | icount=0; |
---|
| 3501 | for ifile=1:nbfield |
---|
| 3502 | for j=1:nbslice |
---|
| 3503 | icount=icount+1; |
---|
| 3504 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3505 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
| 3506 | drawnow |
---|
| 3507 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
| 3508 | filename_ima([end-3:end])=[];%remove .png extension |
---|
| 3509 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
| 3510 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
| 3511 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
| 3512 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3513 | filename_cmx=[filename_cmx 'x']; |
---|
| 3514 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3515 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3516 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3517 | if isequal(Dt,'0') |
---|
| 3518 | Dt='1' ;%case of 'displacement' mode |
---|
| 3519 | end |
---|
| 3520 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3521 | else |
---|
| 3522 | Dt='1'; |
---|
| 3523 | T0='0'; |
---|
| 3524 | end |
---|
| 3525 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
| 3526 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
| 3527 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3528 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3529 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3530 | if ~exist(gridname,'file') |
---|
| 3531 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3532 | return |
---|
| 3533 | end |
---|
| 3534 | end |
---|
| 3535 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 3536 | if test_mask==0 |
---|
| 3537 | maskname='noFile use default'; |
---|
| 3538 | maskflag='n'; |
---|
| 3539 | else |
---|
| 3540 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
| 3541 | maskbase=[filebase '_' maskdispl];% |
---|
| 3542 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
| 3543 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
| 3544 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3545 | if exist(maskname,'file') |
---|
| 3546 | maskflag='y'; |
---|
| 3547 | else |
---|
| 3548 | maskname='noFile use default'; |
---|
| 3549 | maskflag='n'; |
---|
| 3550 | end |
---|
| 3551 | end |
---|
| 3552 | textcmx={'############## CMX file';... |
---|
| 3553 | ['FirstImage ' filename_ima];... |
---|
| 3554 | ['LastImage ' filename_ima_1];... |
---|
| 3555 | 'XX' ;... |
---|
| 3556 | ['Mask ' maskflag] ;... |
---|
| 3557 | ['MaskName ' maskname];... |
---|
| 3558 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
| 3559 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3560 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
| 3561 | ['RO ' rho];... |
---|
| 3562 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3563 | 'XX 1.0';... |
---|
| 3564 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3565 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3566 | 'XX 1';... |
---|
| 3567 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
| 3568 | ['Grid ' gridflag];... |
---|
| 3569 | ['GridName ' gridname] ;... |
---|
| 3570 | 'XX 85';... |
---|
| 3571 | 'XX 1.0';... |
---|
| 3572 | 'XX 1.0';... |
---|
| 3573 | 'Hart 1';... |
---|
| 3574 | 'DecimalShift 0';... |
---|
| 3575 | 'Deformation 0';... |
---|
| 3576 | 'CorrelationMin 0';... |
---|
| 3577 | 'IntensityMin 0';... |
---|
| 3578 | ['SeuilImage ' threshflag];... |
---|
| 3579 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
| 3580 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3581 | 'ImageUsedBefore null null'}; |
---|
| 3582 | textout=char(textcmx); |
---|
[12] | 3583 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3584 | fid=fopen([filename_cmx],'w'); |
---|
| 3585 | fprintf(fid, ['############## CMX file' '\n']); |
---|
[16] | 3586 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
| 3587 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
[12] | 3588 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3589 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
| 3590 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
| 3591 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 3592 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
| 3593 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
| 3594 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
| 3595 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
| 3596 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3597 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
| 3598 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
| 3599 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 3600 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
| 3601 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
| 3602 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
| 3603 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 3604 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3605 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3606 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 3607 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 3608 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 3609 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 3610 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 3611 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 3612 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 3613 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
| 3614 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 3615 | fclose(fid); |
---|
| 3616 | |
---|
[2] | 3617 | s=-1; |
---|
[67] | 3618 | display(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]) |
---|
| 3619 | eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]); |
---|
[2] | 3620 | % if sge%dispatch computation on the cluster using interactive queue |
---|
[67] | 3621 | % % [s,w] = unix(['qrsh -q fast.q ' civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
[2] | 3622 | % end |
---|
| 3623 | % if s~=0 |
---|
[67] | 3624 | % % ['!' civ1Bin ' -f ' filename_cmx ' > ' namelog] |
---|
| 3625 | % % eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]); |
---|
[2] | 3626 | % end |
---|
| 3627 | end |
---|
| 3628 | end |
---|
| 3629 | |
---|
[67] | 3630 | % %------------------------------------------------------------------------ |
---|
| 3631 | % % RUN CIV2 CIV2 CIV2 CIV2 |
---|
| 3632 | % function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
| 3633 | % %------------------------------------------------------------------------ |
---|
| 3634 | % %filecell_2: names of first image |
---|
| 3635 | % %filecell_3: names of second images |
---|
| 3636 | % global civ2Bin sge |
---|
| 3637 | % |
---|
| 3638 | % %names of the civ2 fields |
---|
| 3639 | % field.vel_type='civ2'; |
---|
| 3640 | % field.nb='nb_vectors2'; |
---|
| 3641 | % field.X='vec2_X'; |
---|
| 3642 | % field.Y='vec2_Y'; |
---|
| 3643 | % field.U='vec2_U'; |
---|
| 3644 | % field.V='vec2_V'; |
---|
| 3645 | % |
---|
| 3646 | % %get civ parameters |
---|
| 3647 | % ibx=get(handles.ibx_civ2,'String'); |
---|
| 3648 | % iby=get(handles.iby_civ2,'String'); |
---|
| 3649 | % rho=get(handles.rho_civ2,'String'); |
---|
| 3650 | % decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3651 | % deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3652 | % dx=get(handles.dx_civ2,'String'); |
---|
| 3653 | % dy=get(handles.dy_civ2,'String'); |
---|
| 3654 | % if isequal(str2num(dx),[]) |
---|
| 3655 | % dx='20';%default |
---|
| 3656 | % end |
---|
| 3657 | % if isequal(str2num(dy),[]) |
---|
| 3658 | % dy='20';%default |
---|
| 3659 | % end |
---|
| 3660 | % pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
| 3661 | % pxcmy='1'; |
---|
| 3662 | % A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
| 3663 | % sizim=size(A); |
---|
| 3664 | % npx=num2str(sizim(2)); |
---|
| 3665 | % npy=num2str(sizim(1)); |
---|
[71] | 3666 | % time=get(handles.RootName,'UserData'); %get the set of times |
---|
| 3667 | % filebase=get(handles.RootName,'String'); |
---|
[67] | 3668 | % %grid |
---|
| 3669 | % gridname='';%default ='noFile use default' |
---|
| 3670 | % gridflag='n';%default |
---|
| 3671 | % test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 3672 | % nbslice_grid=[]; |
---|
| 3673 | % if test_grid |
---|
| 3674 | % gridname=get(handles.grid_civ2,'String'); |
---|
| 3675 | % if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3676 | % nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3677 | % if ~isempty(nbslice_grid) |
---|
| 3678 | % gridflag='y'; |
---|
| 3679 | % end |
---|
| 3680 | % elseif exist(gridname,'file') |
---|
| 3681 | % gridflag='y'; |
---|
| 3682 | % else |
---|
| 3683 | % msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3684 | % return |
---|
| 3685 | % end |
---|
| 3686 | % end |
---|
| 3687 | % sizcell=size(filecell_2); |
---|
| 3688 | % nbfield=sizcell(1); |
---|
| 3689 | % nbslice=sizcell(2); |
---|
| 3690 | % |
---|
| 3691 | % %main loop |
---|
| 3692 | % icount=0; |
---|
| 3693 | % for ifile=1:nbfield |
---|
| 3694 | % for j=1:nbslice |
---|
| 3695 | % icount=icount+1; |
---|
| 3696 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3697 | % set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
| 3698 | % drawnow |
---|
| 3699 | % filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
| 3700 | % filename_ima_2([end-3:end])=[];%remove .png extension |
---|
| 3701 | % filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
| 3702 | % filename_ima_3([end-3:end])=[];%remove .png extension |
---|
| 3703 | % filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
| 3704 | % filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3705 | % filename_cmx=[filename_cmx 'x']; |
---|
| 3706 | % namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3707 | % if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3708 | % Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3709 | % if isequal(Dt,'0') |
---|
| 3710 | % Dt='1' ;%case of 'displacement' mode |
---|
| 3711 | % end |
---|
| 3712 | % T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3713 | % else |
---|
| 3714 | % Dt='1'; |
---|
| 3715 | % T0='0'; |
---|
| 3716 | % end |
---|
| 3717 | % term_a=num2stra(num_a(j),nom_type_nc); |
---|
| 3718 | % term_b=num2stra(num_b(j),nom_type_nc); |
---|
| 3719 | % filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
| 3720 | % filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 3721 | % if test_grid && ~isempty(nbslice_grid) |
---|
| 3722 | % num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
| 3723 | % gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3724 | % if ~exist(gridname,'file') |
---|
| 3725 | % msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3726 | % return |
---|
| 3727 | % end |
---|
| 3728 | % end |
---|
| 3729 | % test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 3730 | % if test_mask==0 |
---|
| 3731 | % maskname='noFile use default'; |
---|
| 3732 | % maskflag='n'; |
---|
| 3733 | % else |
---|
| 3734 | % maskdispl=get(handles.mask_civ2,'String'); |
---|
| 3735 | % maskbase=[filebase '_' maskdispl]; % |
---|
| 3736 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 3737 | % num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
| 3738 | % maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3739 | % if ~exist(maskname,'file') |
---|
| 3740 | % maskflag='y'; |
---|
| 3741 | % else |
---|
| 3742 | % maskname='noFile use default'; |
---|
| 3743 | % maskflag='n'; |
---|
| 3744 | % end |
---|
| 3745 | % end |
---|
| 3746 | % |
---|
| 3747 | % textcmx={'############## CMX file';... |
---|
| 3748 | % ['FirstImage ' filename_ima_2];... |
---|
| 3749 | % ['LastImage ' filename_ima_3];... |
---|
| 3750 | % 'XX' ;... |
---|
| 3751 | % ['Mask ' maskflag];... |
---|
| 3752 | % ['MaskName ' maskname];... |
---|
| 3753 | % ['ImageSize ' npx ' ' npy];... |
---|
| 3754 | % ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3755 | % ['SearchBoxeSize ' ibx ' ' iby];... |
---|
| 3756 | % ['RO ' rho];... |
---|
| 3757 | % ['GridSpacing ' dx ' ' dy];... |
---|
| 3758 | % 'XX 1.0';... |
---|
| 3759 | % ['Dt_TO ' Dt ' ' T0];... |
---|
| 3760 | % ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3761 | % 'XX 1';... |
---|
| 3762 | % ['ShiftXY 0 0'];... |
---|
| 3763 | % ['Grid ' gridflag];... |
---|
| 3764 | % ['GridName ' gridname];... |
---|
| 3765 | % 'XX 85';... |
---|
| 3766 | % 'XX 1.0';... |
---|
| 3767 | % 'XX 1.0';... |
---|
| 3768 | % 'Hart 1';... |
---|
| 3769 | % ['DecimalShift ' decimal];... |
---|
| 3770 | % ['Deformation ' deformation];... |
---|
| 3771 | % 'CorrelationMin 0';... |
---|
| 3772 | % 'IntensityMin 0';... |
---|
| 3773 | % 'SeuilImage n';... |
---|
| 3774 | % 'SeuilImageValues 0 4096';... |
---|
| 3775 | % ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3776 | % ['ImageUsedBefore ' filename_nc1]}; |
---|
| 3777 | % textout=char(textcmx); |
---|
| 3778 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3779 | % s=-1; |
---|
| 3780 | % display(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]) |
---|
| 3781 | % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]); |
---|
| 3782 | % |
---|
| 3783 | % % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3784 | % % [s,w] = unix(['qrsh -q fast.q ' civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
| 3785 | % % end |
---|
| 3786 | % % if s~=0 |
---|
| 3787 | % % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3788 | % % ['!' civ2Bin ' -f ' filename_cmx ' > ' namelog] |
---|
| 3789 | % % end |
---|
| 3790 | % end |
---|
| 3791 | % end |
---|
| 3792 | % % close(h) |
---|
[2] | 3793 | |
---|
[12] | 3794 | %------------------------------------------------------------------------ |
---|
| 3795 | % --- PATCH |
---|
[94] | 3796 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 3797 | %------------------------------------------------------------------------ |
---|
[2] | 3798 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3799 | if test_interp==0 |
---|
[73] | 3800 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
[66] | 3801 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[2] | 3802 | else %nouveau programme patch |
---|
[73] | 3803 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
[66] | 3804 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[2] | 3805 | end |
---|
[12] | 3806 | |
---|
| 3807 | %------------------------------------------------------------------------ |
---|
| 3808 | % --- STEREO Interp |
---|
[67] | 3809 | 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] | 3810 | %------------------------------------------------------------------------ |
---|
[2] | 3811 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
[67] | 3812 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3813 | ' -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 |
---|
| 3814 | |
---|
[12] | 3815 | %------------------------------------------------------------------------ |
---|
[2] | 3816 | % --- Executes on button press in CIV1. |
---|
| 3817 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3818 | %------------------------------------------------------------------------ |
---|
[2] | 3819 | val=get(handles.CIV1,'Value'); |
---|
| 3820 | if isequal(val,1) |
---|
| 3821 | enable_civ1(handles,'on') |
---|
| 3822 | enable_pair1(handles,'on') |
---|
| 3823 | else |
---|
| 3824 | enable_civ1(handles,'off') |
---|
| 3825 | end |
---|
| 3826 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3827 | |
---|
[12] | 3828 | %------------------------------------------------------------------------ |
---|
[2] | 3829 | % --- Executes on button press in FIX1. |
---|
| 3830 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3831 | %------------------------------------------------------------------------ |
---|
[2] | 3832 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3833 | |
---|
[12] | 3834 | %------------------------------------------------------------------------ |
---|
[2] | 3835 | % --- Executes on button press in PATCH1. |
---|
| 3836 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3837 | %------------------------------------------------------------------------ |
---|
[2] | 3838 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3839 | enable_patch1(handles) |
---|
[2] | 3840 | else |
---|
[12] | 3841 | desable_patch1(handles) |
---|
[2] | 3842 | end |
---|
| 3843 | |
---|
[12] | 3844 | %------------------------------------------------------------------------ |
---|
[2] | 3845 | % --- Executes on button press in CIV2. |
---|
| 3846 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3847 | %------------------------------------------------------------------------ |
---|
[2] | 3848 | state=get(handles.CIV2,'Value'); |
---|
| 3849 | enable_civ2(handles,state) |
---|
| 3850 | if state |
---|
| 3851 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3852 | enable_pair1(handles,'on') |
---|
| 3853 | end |
---|
| 3854 | |
---|
[12] | 3855 | %------------------------------------------------------------------------ |
---|
[2] | 3856 | % --- Executes on button press in FIX2. |
---|
| 3857 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3858 | %------------------------------------------------------------------------ |
---|
[2] | 3859 | if get(handles.FIX2,'Value')==1 |
---|
| 3860 | enable_fix2(handles) |
---|
| 3861 | if get(handles.CIV2,'Value')==0 |
---|
| 3862 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3863 | end |
---|
| 3864 | else |
---|
| 3865 | desable_fix2(handles) |
---|
| 3866 | end |
---|
| 3867 | |
---|
[12] | 3868 | %------------------------------------------------------------------------ |
---|
[2] | 3869 | % --- Executes on button press in PATCH2. |
---|
| 3870 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3871 | %------------------------------------------------------------------------ |
---|
[2] | 3872 | if get(handles.PATCH2,'Value')==1 |
---|
| 3873 | enable_patch2(handles) |
---|
| 3874 | if get(handles.CIV2,'Value')==0 |
---|
| 3875 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3876 | end |
---|
| 3877 | else |
---|
| 3878 | desable_patch2(handles) |
---|
| 3879 | end |
---|
| 3880 | |
---|
[12] | 3881 | %------------------------------------------------------------------------ |
---|
| 3882 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3883 | %------------------------------------------------------------------------ |
---|
| 3884 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 3885 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 3886 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3887 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3888 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3889 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3890 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3891 | |
---|
[12] | 3892 | %------------------------------------------------------------------------ |
---|
| 3893 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3894 | %------------------------------------------------------------------------ |
---|
| 3895 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3896 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3897 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3898 | |
---|
[12] | 3899 | %------------------------------------------------------------------------ |
---|
[2] | 3900 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3901 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3902 | %------------------------------------------------------------------------ |
---|
[2] | 3903 | %determine pair numbers |
---|
| 3904 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3905 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3906 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3907 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3908 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3909 | pxcmx=pxcm_xy(1); |
---|
| 3910 | pxcmy=pxcm_xy(2); |
---|
| 3911 | mode_list=get(handles.mode,'String'); |
---|
| 3912 | mode_value=get(handles.mode,'Value'); |
---|
| 3913 | mode=mode_list{mode_value}; |
---|
| 3914 | if isequal (mode, 'series(Di)' ) |
---|
| 3915 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3916 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3917 | num2=ref_i+ceil(index/2); |
---|
| 3918 | num_a=1; |
---|
| 3919 | num_b=1; |
---|
| 3920 | elseif isequal (mode, 'series(Dj)') |
---|
| 3921 | num1=1; |
---|
| 3922 | num2=1; |
---|
| 3923 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3924 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3925 | num_b=ref_j+ceil(index/2); |
---|
| 3926 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3927 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3928 | num1=ref_i; |
---|
| 3929 | num2=ref_i; |
---|
| 3930 | num_a=displ_num(1,index); |
---|
| 3931 | num_b=displ_num(2,index); |
---|
| 3932 | end |
---|
| 3933 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3934 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 3935 | iby=str2num(get(handles.iby,'String')); |
---|
| 3936 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 3937 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 3938 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 3939 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 3940 | shiftx=round((umin+umax)/2); |
---|
| 3941 | shifty=round((vmin+vmax)/2); |
---|
| 3942 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3943 | isx=2*ceil(isx/2)+1; |
---|
| 3944 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3945 | isy=2*ceil(isy/2)+1; |
---|
| 3946 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3947 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3948 | set(handles.isx,'String',num2str(isx)); |
---|
| 3949 | set(handles.isy,'String',num2str(isy)); |
---|
| 3950 | |
---|
[12] | 3951 | %------------------------------------------------------------------------ |
---|
| 3952 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3953 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3954 | %------------------------------------------------------------------------ |
---|
[2] | 3955 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3956 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3957 | if get(handles.CIV1,'Value')==0 |
---|
| 3958 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3959 | end |
---|
| 3960 | |
---|
[12] | 3961 | %------------------------------------------------------------------------ |
---|
| 3962 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3963 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3964 | %------------------------------------------------------------------------ |
---|
[2] | 3965 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3966 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3967 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3968 | end |
---|
| 3969 | |
---|
[12] | 3970 | %------------------------------------------------------------------------ |
---|
[2] | 3971 | % --- Executes on button press in get_mask_civ1. |
---|
| 3972 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3973 | %------------------------------------------------------------------------ |
---|
[2] | 3974 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3975 | if isequal(maskval,0) |
---|
| 3976 | set(handles.mask_civ1,'String','') |
---|
| 3977 | else |
---|
| 3978 | mask_displ='no mask'; %default |
---|
[71] | 3979 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3980 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3981 | if isequal(flag_mask,1) |
---|
| 3982 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
| 3983 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3984 | common_path=fileparts(filebase); |
---|
[71] | 3985 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
[2] | 3986 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[12] | 3987 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
[2] | 3988 | mask_displ='no mask'; |
---|
| 3989 | end |
---|
| 3990 | end |
---|
| 3991 | if isequal(mask_displ,'no mask') |
---|
[12] | 3992 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3993 | {'*.png', ' (*.png)'; |
---|
| 3994 | '*.png', '.png files '; ... |
---|
| 3995 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3996 | 'Pick a mask file *.png',filebase); |
---|
| 3997 | mask_displ=fullfile(PathName,FileName); |
---|
| 3998 | if ~exist(mask_displ,'file') |
---|
| 3999 | mask_displ='no mask'; |
---|
| 4000 | end |
---|
| 4001 | end |
---|
| 4002 | if isequal(mask_displ,'no mask') |
---|
[2] | 4003 | set(handles.get_mask_civ1,'Value',0) |
---|
| 4004 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4005 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4006 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4007 | else |
---|
| 4008 | set(handles.get_mask_fix1,'Value',1) |
---|
| 4009 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4010 | end |
---|
| 4011 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 4012 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4013 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4014 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4015 | end |
---|
[82] | 4016 | set(handles.mask_civ2,'Value',maskval) |
---|
[2] | 4017 | |
---|
[12] | 4018 | %------------------------------------------------------------------------ |
---|
[2] | 4019 | % --- Executes on button press in get_mask_fix1. |
---|
| 4020 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4021 | %------------------------------------------------------------------------ |
---|
[2] | 4022 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 4023 | if isequal(maskval,0) |
---|
| 4024 | set(handles.mask_fix1,'String','') |
---|
| 4025 | else |
---|
| 4026 | mask_displ='no mask'; %default |
---|
[71] | 4027 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4028 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4029 | if isequal(flag_mask,1) |
---|
| 4030 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4031 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 4032 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 4033 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4034 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4035 | mask_displ='no mask'; |
---|
| 4036 | end |
---|
| 4037 | end |
---|
| 4038 | if isequal(mask_displ,'no mask') |
---|
[12] | 4039 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4040 | {'*.png', ' (*.png)'; |
---|
| 4041 | '*.png', '.png files '; ... |
---|
| 4042 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4043 | 'Pick a mask file *.png',filebase); |
---|
| 4044 | mask_displ=fullfile(PathName,FileName); |
---|
| 4045 | if ~exist(mask_displ,'file') |
---|
| 4046 | mask_displ='no mask'; |
---|
| 4047 | end |
---|
| 4048 | end |
---|
| 4049 | if isequal(mask_displ,'no mask') |
---|
[2] | 4050 | set(handles.get_mask_fix1,'Value',0) |
---|
| 4051 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4052 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4053 | else |
---|
| 4054 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 4055 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4056 | end |
---|
| 4057 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 4058 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4059 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4060 | end |
---|
[12] | 4061 | |
---|
| 4062 | %------------------------------------------------------------------------ |
---|
[2] | 4063 | % --- Executes on button press in get_mask_civ2. |
---|
| 4064 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4065 | %------------------------------------------------------------------------ |
---|
[2] | 4066 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 4067 | if isequal(maskval,0) |
---|
| 4068 | set(handles.mask_civ2,'String','') |
---|
| 4069 | else |
---|
| 4070 | mask_displ='no mask'; %default |
---|
[71] | 4071 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4072 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4073 | if isequal(flag_mask,1) |
---|
| 4074 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4075 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 4076 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 4077 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4078 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4079 | mask_displ='no mask'; |
---|
| 4080 | end |
---|
| 4081 | end |
---|
| 4082 | if isequal(mask_displ,'no mask') |
---|
[12] | 4083 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4084 | {'*.png', ' (*.png)'; |
---|
| 4085 | '*.png', '.png files '; ... |
---|
| 4086 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4087 | 'Pick a mask file *.png',filebase); |
---|
| 4088 | mask_displ=fullfile(PathName,FileName); |
---|
| 4089 | if ~exist(mask_displ,'file') |
---|
| 4090 | mask_displ='no mask'; |
---|
| 4091 | end |
---|
| 4092 | end |
---|
| 4093 | if isequal(mask_displ,'no mask') |
---|
[2] | 4094 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4095 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4096 | else |
---|
| 4097 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4098 | end |
---|
| 4099 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4100 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4101 | end |
---|
[12] | 4102 | |
---|
| 4103 | %------------------------------------------------------------------------ |
---|
[2] | 4104 | % --- Executes on button press in get_mask_fix2. |
---|
| 4105 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4106 | %------------------------------------------------------------------------ |
---|
[2] | 4107 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 4108 | if isequal(maskval,0) |
---|
| 4109 | set(handles.mask_fix2,'String','') |
---|
| 4110 | else |
---|
[12] | 4111 | mask_displ='no mask'; %default |
---|
[71] | 4112 | filebase=get(handles.RootName,'String'); |
---|
[12] | 4113 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4114 | if isequal(flag_mask,1) |
---|
| 4115 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4116 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 4117 | filebase_a=get(handles.RootName_1,'String'); |
---|
[12] | 4118 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4119 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4120 | mask_displ='no mask'; |
---|
| 4121 | end |
---|
| 4122 | end |
---|
| 4123 | if isequal(mask_displ,'no mask') |
---|
| 4124 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4125 | {'*.png', ' (*.png)'; |
---|
| 4126 | '*.png', '.png files '; ... |
---|
| 4127 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4128 | 'Pick a mask file *.png',filebase); |
---|
| 4129 | mask_displ=fullfile(PathName,FileName); |
---|
| 4130 | if ~exist(mask_displ,'file') |
---|
[2] | 4131 | mask_displ='no mask'; |
---|
| 4132 | end |
---|
[12] | 4133 | end |
---|
| 4134 | if isequal(mask_displ,'no mask') |
---|
| 4135 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4136 | end |
---|
| 4137 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 4138 | end |
---|
| 4139 | |
---|
[12] | 4140 | %------------------------------------------------------------------------ |
---|
| 4141 | % --- function called to look for mask files |
---|
[2] | 4142 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 4143 | %------------------------------------------------------------------------ |
---|
[2] | 4144 | %detect mask files, images with appropriate file base |
---|
| 4145 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 4146 | %flag_mask=1 indicates detection |
---|
| 4147 | |
---|
| 4148 | flag_mask=0;%default |
---|
| 4149 | nbslice=1; |
---|
| 4150 | |
---|
| 4151 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 4152 | [Path,Name]=fileparts(filebase); |
---|
[12] | 4153 | if ~isdir(Path) |
---|
| 4154 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 4155 | return |
---|
| 4156 | end |
---|
[2] | 4157 | currentdir=pwd; |
---|
| 4158 | cd(Path);%move in the dir of the root name filebase |
---|
| 4159 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 4160 | cd(currentdir);%come back to the current working directory |
---|
[12] | 4161 | if ~isempty(maskfiles) |
---|
| 4162 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 4163 | % else |
---|
[2] | 4164 | flag_mask=1; |
---|
| 4165 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4166 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4167 | Namedouble=double(Name); |
---|
| 4168 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4169 | ind_mask=findstr('mask',Name); |
---|
| 4170 | i=ind_mask-1; |
---|
| 4171 | while val(i)==0 & i>0 |
---|
| 4172 | i=i-1; |
---|
| 4173 | end |
---|
| 4174 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4175 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4176 | flag_mask=1; |
---|
| 4177 | else |
---|
| 4178 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 4179 | return |
---|
| 4180 | nbslice=1; |
---|
| 4181 | end |
---|
| 4182 | end |
---|
| 4183 | |
---|
[12] | 4184 | %------------------------------------------------------------------------ |
---|
| 4185 | % --- function called to look for grid files |
---|
[2] | 4186 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 4187 | %------------------------------------------------------------------------ |
---|
[2] | 4188 | flag_mask=0;%default |
---|
| 4189 | nbslice=1; |
---|
| 4190 | [Path,Name]=fileparts(filebase); |
---|
| 4191 | currentdir=pwd; |
---|
| 4192 | cd(Path);%move in the dir of the root name filebase |
---|
| 4193 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 4194 | cd(currentdir);%come back to the current working directory |
---|
| 4195 | if ~isempty(maskfiles) |
---|
| 4196 | flag_mask=1; |
---|
| 4197 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4198 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4199 | Namedouble=double(Name); |
---|
| 4200 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4201 | ind_mask=findstr('grid',Name); |
---|
| 4202 | i=ind_mask-1; |
---|
| 4203 | while val(i)==0 & i>0 |
---|
| 4204 | i=i-1; |
---|
| 4205 | end |
---|
| 4206 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4207 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4208 | flag_mask=1; |
---|
| 4209 | else |
---|
| 4210 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 4211 | return |
---|
| 4212 | nbslice=1; |
---|
| 4213 | end |
---|
[12] | 4214 | end |
---|
[2] | 4215 | |
---|
[12] | 4216 | %------------------------------------------------------------------------ |
---|
| 4217 | % --- transform numbers to letters |
---|
[2] | 4218 | function str=num2stra(num,nom_type); |
---|
[12] | 4219 | %------------------------------------------------------------------------ |
---|
[2] | 4220 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 4221 | str=char(96+num); |
---|
| 4222 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 4223 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 4224 | str=''; |
---|
| 4225 | else |
---|
| 4226 | str=num2str(num); |
---|
| 4227 | end |
---|
[12] | 4228 | |
---|
| 4229 | %------------------------------------------------------------------------ |
---|
[2] | 4230 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4231 | %------------------------------------------------------------------------ |
---|
[2] | 4232 | set(handles.mask_civ1,'UserData',[]) |
---|
| 4233 | set(handles.mask_civ1,'String','') |
---|
[12] | 4234 | |
---|
| 4235 | %------------------------------------------------------------------------ |
---|
[2] | 4236 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4237 | %------------------------------------------------------------------------ |
---|
[2] | 4238 | set(handles.mask_civ2,'UserData',[]) |
---|
| 4239 | set(handles.mask_civ2,'String','') |
---|
[12] | 4240 | |
---|
| 4241 | %------------------------------------------------------------------------ |
---|
[2] | 4242 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4243 | %------------------------------------------------------------------------ |
---|
[2] | 4244 | set(handles.mask_fix1,'UserData',[]) |
---|
| 4245 | set(handles.mask_fix1,'String','') |
---|
[12] | 4246 | |
---|
| 4247 | %------------------------------------------------------------------------ |
---|
[2] | 4248 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4249 | %------------------------------------------------------------------------ |
---|
[2] | 4250 | set(handles.mask_fix2,'UserData',[]) |
---|
| 4251 | set(handles.mask_fix2,'String','') |
---|
| 4252 | |
---|
[12] | 4253 | %------------------------------------------------------------------------ |
---|
[2] | 4254 | % --- Executes on button press in list_subdir_civ1. |
---|
| 4255 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4256 | %------------------------------------------------------------------------ |
---|
[2] | 4257 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 4258 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 4259 | if val>1 |
---|
| 4260 | subdir=list_subdir_civ1{val}; |
---|
| 4261 | set(handles.subdir_civ1,'String',subdir); |
---|
| 4262 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 4263 | end |
---|
| 4264 | |
---|
[12] | 4265 | %------------------------------------------------------------------------ |
---|
[2] | 4266 | % --- Executes on button press in list_subdir_civ2. |
---|
| 4267 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4268 | %------------------------------------------------------------------------ |
---|
[2] | 4269 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 4270 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 4271 | if val>1 |
---|
| 4272 | subdir=list_subdir_civ2{val}; |
---|
| 4273 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4274 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 4275 | end |
---|
| 4276 | |
---|
[12] | 4277 | %------------------------------------------------------------------------ |
---|
[2] | 4278 | % --- Executes on button press in browse_gridciv1. |
---|
| 4279 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 4280 | %------------------------------------------------------------------------ |
---|
[2] | 4281 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 4282 | testgrid=0; |
---|
| 4283 | if value |
---|
[71] | 4284 | filebase=get(handles.RootName,'String'); |
---|
[39] | 4285 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4286 | if isequal(flag_grid,1) |
---|
| 4287 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 4288 | testgrid=1; |
---|
| 4289 | else |
---|
| 4290 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4291 | {'*.grid', ' (*.grid)'; |
---|
| 4292 | '*.grid', '.grid files '; ... |
---|
| 4293 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4294 | 'Pick a file',filebase); |
---|
| 4295 | filegrid=fullfile(PathName,FileName); |
---|
| 4296 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 4297 | testgrid=1; |
---|
| 4298 | end |
---|
| 4299 | end |
---|
| 4300 | end |
---|
| 4301 | if testgrid |
---|
| 4302 | set(handles.browse_gridciv2,'Value',1) |
---|
| 4303 | set(handles.get_gridpatch1,'Value',1) |
---|
| 4304 | set(handles.get_gridpatch2,'Value',1) |
---|
| 4305 | set(handles.dx_civ1,'Visible','off'); |
---|
| 4306 | set(handles.dy_civ1,'Visible','off'); |
---|
| 4307 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4308 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4309 | set(handles.grid_civ1,'String',filegrid) |
---|
| 4310 | set(handles.grid_patch1,'String',filegrid) |
---|
| 4311 | set(handles.grid_civ2,'String',filegrid) |
---|
| 4312 | set(handles.grid_patch2,'String',filegrid) |
---|
| 4313 | else |
---|
| 4314 | set(handles.browse_gridciv1,'Value',0); |
---|
| 4315 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4316 | set(handles.get_gridpatch1,'Value',0) |
---|
| 4317 | set(handles.get_gridpatch2,'Value',0) |
---|
| 4318 | set(handles.dx_civ1,'Visible','on'); |
---|
| 4319 | set(handles.dy_civ1,'Visible','on'); |
---|
| 4320 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4321 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4322 | set(handles.grid_civ1,'String','') |
---|
| 4323 | set(handles.grid_patch1,'String','') |
---|
| 4324 | set(handles.grid_civ2,'String','') |
---|
| 4325 | set(handles.grid_patch2,'String','') |
---|
| 4326 | end |
---|
| 4327 | |
---|
[12] | 4328 | %------------------------------------------------------------------------ |
---|
[2] | 4329 | % --- Executes on button press in browse_gridciv1. |
---|
| 4330 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 4331 | %------------------------------------------------------------------------ |
---|
[2] | 4332 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 4333 | if value |
---|
[71] | 4334 | filebase=get(handles.RootName,'String'); |
---|
[39] | 4335 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4336 | if isequal(flag_grid,1) |
---|
| 4337 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 4338 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 4339 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4340 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4341 | else |
---|
| 4342 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4343 | {'*.grid', ' (*.grid)'; |
---|
| 4344 | '*.grid', '.grid files '; ... |
---|
| 4345 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4346 | 'Pick a file',filebase); |
---|
| 4347 | filegrid=fullfile(PathName,FileName); |
---|
| 4348 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 4349 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4350 | set(handles.grid_civ2,'string',''); |
---|
| 4351 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4352 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4353 | set(handles.grid_civ2,'string',''); |
---|
| 4354 | else |
---|
| 4355 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4356 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4357 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4358 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4359 | end |
---|
| 4360 | end |
---|
| 4361 | else |
---|
| 4362 | set(handles.grid_civ2,'string',''); |
---|
| 4363 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4364 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4365 | set(handles.grid_civ2,'string',''); |
---|
| 4366 | end |
---|
| 4367 | |
---|
| 4368 | % % --- Executes on button press in browse_gridciv2. |
---|
| 4369 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 4370 | % |
---|
[71] | 4371 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 4372 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4373 | % {'*.grid', ' (*.grid)'; |
---|
| 4374 | % '*.grid', '.grid files '; ... |
---|
| 4375 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 4376 | % 'Pick a file',filebase); |
---|
| 4377 | % filegrid=fullfile(PathName,FileName); |
---|
| 4378 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 4379 | % set(handles.dx_civ2,'String',' '); |
---|
| 4380 | % set(handles.dy_civ2,'String',' '); |
---|
| 4381 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 4382 | |
---|
| 4383 | % --- Executes on button press in get_gridpatch1. |
---|
| 4384 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 4385 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 4386 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4387 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4388 | |
---|
[71] | 4389 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4390 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4391 | {'*.grid', ' (*.grid)'; |
---|
| 4392 | '*.grid', '.grid files '; ... |
---|
| 4393 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4394 | 'Pick a file',filebase); |
---|
| 4395 | filegrid=fullfile(PathName,FileName); |
---|
| 4396 | set(handles.grid_patch1,'string',filegrid); |
---|
| 4397 | % set(handles.grid_patch2,'string',filegrid |
---|
| 4398 | |
---|
[12] | 4399 | %------------------------------------------------------------------------ |
---|
[2] | 4400 | % --- Executes on button press in get_gridpatch2. |
---|
| 4401 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 4402 | %------------------------------------------------------------------------ |
---|
[2] | 4403 | |
---|
[12] | 4404 | %------------------------------------------------------------------------ |
---|
[2] | 4405 | function enable_civ1(handles,state) |
---|
[12] | 4406 | %------------------------------------------------------------------------ |
---|
[2] | 4407 | if isequal(state,0) |
---|
| 4408 | state='off'; |
---|
| 4409 | end |
---|
| 4410 | if isequal(state,1) |
---|
| 4411 | state='on'; |
---|
| 4412 | end |
---|
| 4413 | if isequal(state,'on') |
---|
| 4414 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4415 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4416 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4417 | else |
---|
| 4418 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4419 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4420 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4421 | end |
---|
| 4422 | set(handles.ibx,'Visible',state) |
---|
| 4423 | set(handles.iby,'Visible',state) |
---|
| 4424 | set(handles.isx,'Visible',state) |
---|
| 4425 | set(handles.isy,'Visible',state) |
---|
| 4426 | set(handles.shiftx,'Visible',state) |
---|
| 4427 | set(handles.shifty,'Visible',state) |
---|
| 4428 | set(handles.rho,'Visible',state) |
---|
| 4429 | set(handles.dx_civ1,'Visible',state) |
---|
| 4430 | set(handles.dy_civ1,'Visible',state) |
---|
| 4431 | set(handles.calcul_search,'Visible',state) |
---|
| 4432 | set(handles.u_text,'Visible',state) |
---|
| 4433 | set(handles.v_text,'Visible',state) |
---|
| 4434 | set(handles.min,'Visible',state) |
---|
| 4435 | set(handles.max,'Visible',state) |
---|
| 4436 | set(handles.umin,'Visible',state) |
---|
| 4437 | set(handles.umax,'Visible',state) |
---|
| 4438 | set(handles.vmin,'Visible',state) |
---|
| 4439 | set(handles.vmax,'Visible',state) |
---|
| 4440 | set(handles.grid_civ1,'Visible',state) |
---|
| 4441 | set(handles.mask_civ1,'Visible',state) |
---|
| 4442 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 4443 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 4444 | set(handles.parameters,'Visible',state) |
---|
| 4445 | set(handles.grid,'Visible',state) |
---|
| 4446 | set(handles.dx_civ1,'Visible',state) |
---|
| 4447 | set(handles.dy_civ1,'Visible',state) |
---|
| 4448 | set(handles.ImaThreshold,'Visible',state) |
---|
| 4449 | if isequal(state,'off') |
---|
| 4450 | set(handles.MinIma,'Visible','off') |
---|
| 4451 | set(handles.MaxIma,'Visible','off') |
---|
| 4452 | set(handles.ImaThreshold,'Value',0) |
---|
| 4453 | end |
---|
| 4454 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 4455 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 4456 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 4457 | set(handles.ib_title,'Visible',state) |
---|
| 4458 | set(handles.is_title,'Visible',state) |
---|
| 4459 | set(handles.shift_title,'Visible',state) |
---|
| 4460 | set(handles.rho_title,'Visible',state) |
---|
| 4461 | |
---|
[12] | 4462 | %------------------------------------------------------------------------ |
---|
[2] | 4463 | function enable_fix1(handles,state) |
---|
[12] | 4464 | %------------------------------------------------------------------------ |
---|
[2] | 4465 | if isequal(state,0) |
---|
| 4466 | state='off'; |
---|
| 4467 | end |
---|
| 4468 | if isequal(state,1) |
---|
| 4469 | state='on'; |
---|
| 4470 | end |
---|
| 4471 | if isequal(state,'on') |
---|
| 4472 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 4473 | else |
---|
| 4474 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4475 | end |
---|
| 4476 | set(handles.REMOVE,'Visible',state) |
---|
| 4477 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 4478 | set(handles.vec_F2,'Visible',state) |
---|
| 4479 | set(handles.vec_F3,'Visible',state) |
---|
| 4480 | set(handles.thresh_vecC,'Visible',state) |
---|
| 4481 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 4482 | set(handles.thresh_vel,'Visible',state) |
---|
| 4483 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 4484 | set(handles.mask_fix1,'Visible',state) |
---|
| 4485 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 4486 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 4487 | set(handles.ref_fix1,'Visible',state) |
---|
| 4488 | set(handles.inf_sup1,'Visible',state) |
---|
| 4489 | set(handles.field_ref1,'Visible',state) |
---|
| 4490 | |
---|
[12] | 4491 | %------------------------------------------------------------------------ |
---|
[2] | 4492 | function enable_patch1(handles) |
---|
[12] | 4493 | %------------------------------------------------------------------------ |
---|
[67] | 4494 | global patch_newBin |
---|
[2] | 4495 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 4496 | set(handles.rho_patch1,'Visible','on') |
---|
| 4497 | set(handles.rho_text1,'Visible','on') |
---|
| 4498 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4499 | set(handles.thresh_text1,'Visible','on') |
---|
| 4500 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4501 | set(handles.subdomain_text1,'Visible','on') |
---|
| 4502 | set(handles.nx_patch1,'Visible','on') |
---|
| 4503 | set(handles.ny_patch1,'Visible','on') |
---|
| 4504 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 4505 | set(handles.ny_patch1_title,'Visible','on') |
---|
[100] | 4506 | % if ~isempty(patch_newBin) |
---|
| 4507 | % set(handles.test_interp,'Visible','on'); |
---|
| 4508 | % end |
---|
[2] | 4509 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 4510 | set(handles.grid_patch1,'string','none'); |
---|
| 4511 | set(handles.grid_patch1,'Visible','on') |
---|
| 4512 | |
---|
[12] | 4513 | %------------------------------------------------------------------------ |
---|
[2] | 4514 | function desable_patch1(handles) |
---|
[12] | 4515 | %------------------------------------------------------------------------ |
---|
[2] | 4516 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4517 | set(handles.rho_patch1,'Visible','off') |
---|
| 4518 | set(handles.rho_text1,'Visible','off') |
---|
| 4519 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4520 | set(handles.thresh_text1,'Visible','off') |
---|
| 4521 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4522 | set(handles.subdomain_text1,'Visible','off') |
---|
| 4523 | set(handles.nx_patch1,'Visible','off') |
---|
| 4524 | set(handles.ny_patch1,'Visible','off') |
---|
| 4525 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 4526 | set(handles.ny_patch1_title,'Visible','off') |
---|
[100] | 4527 | %set(handles.test_interp,'Visible','off') |
---|
[2] | 4528 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 4529 | set(handles.grid_patch1,'Visible','off') |
---|
| 4530 | |
---|
[12] | 4531 | %------------------------------------------------------------------------ |
---|
[2] | 4532 | function enable_civ2(handles,state) |
---|
[12] | 4533 | %------------------------------------------------------------------------ |
---|
[2] | 4534 | if isequal(state,0) |
---|
| 4535 | state='off'; |
---|
| 4536 | end |
---|
| 4537 | if isequal(state,1) |
---|
| 4538 | state='on'; |
---|
| 4539 | end |
---|
| 4540 | if isequal(state,'on') |
---|
| 4541 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4542 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4543 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4544 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4545 | else |
---|
| 4546 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4547 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4548 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4549 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4550 | end |
---|
| 4551 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4552 | set(handles.iby_civ2,'Visible',state) |
---|
| 4553 | set(handles.decimal,'Visible',state) |
---|
| 4554 | set(handles.deformation,'Visible',state) |
---|
| 4555 | set(handles.rho_civ2,'Visible',state) |
---|
| 4556 | set(handles.dx_civ2,'Visible',state) |
---|
| 4557 | set(handles.dy_civ2,'Visible',state) |
---|
| 4558 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4559 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4560 | set(handles.parameters,'Visible',state) |
---|
| 4561 | set(handles.grid,'Visible',state) |
---|
| 4562 | set(handles.parameters_text,'Visible',state) |
---|
| 4563 | set(handles.grid_text,'Visible',state) |
---|
| 4564 | set(handles.grid_civ2,'Visible',state) |
---|
| 4565 | set(handles.mask_civ2,'Visible',state) |
---|
| 4566 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4567 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4568 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4569 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4570 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4571 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4572 | if isequal(state,'off') |
---|
| 4573 | set(handles.MinIma2,'Visible','off') |
---|
| 4574 | set(handles.MaxIma2,'Visible','off') |
---|
| 4575 | set(handles.ImaThreshold2,'Value',0) |
---|
| 4576 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4577 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4578 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4579 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 4580 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 4581 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 4582 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 4583 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 4584 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 4585 | end |
---|
| 4586 | else |
---|
| 4587 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4588 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4589 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 4590 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 4591 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 4592 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 4593 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 4594 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 4595 | end |
---|
[71] | 4596 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 4597 | |
---|
[12] | 4598 | %------------------------------------------------------------------------ |
---|
[2] | 4599 | function enable_fix2(handles) |
---|
[12] | 4600 | %------------------------------------------------------------------------ |
---|
[2] | 4601 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4602 | set(handles.REMOVE2,'Visible','on') |
---|
| 4603 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4604 | set(handles.vec_F4,'Visible','on') |
---|
| 4605 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4606 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4607 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4608 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4609 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4610 | set(handles.mask_fix2,'Visible','on') |
---|
| 4611 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4612 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4613 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4614 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4615 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4616 | set(handles.ref_fix2,'Visible','on') |
---|
| 4617 | set(handles.inf_sup2,'Visible','on') |
---|
| 4618 | set(handles.field_ref2,'Visible','on') |
---|
| 4619 | |
---|
[12] | 4620 | %------------------------------------------------------------------------ |
---|
[2] | 4621 | function desable_fix2(handles) |
---|
[12] | 4622 | %------------------------------------------------------------------------ |
---|
[2] | 4623 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4624 | set(handles.REMOVE2,'Visible','off') |
---|
| 4625 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4626 | set(handles.vec_F4,'Visible','off') |
---|
| 4627 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4628 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4629 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4630 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4631 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4632 | set(handles.mask_fix2,'Visible','off') |
---|
| 4633 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4634 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4635 | set(handles.ref_fix2,'Visible','off') |
---|
| 4636 | set(handles.inf_sup2,'Visible','off') |
---|
| 4637 | set(handles.field_ref2,'Visible','off') |
---|
| 4638 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4639 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4640 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4641 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4642 | end |
---|
| 4643 | |
---|
[12] | 4644 | %------------------------------------------------------------------------ |
---|
[2] | 4645 | function enable_patch2(handles) |
---|
[12] | 4646 | %------------------------------------------------------------------------ |
---|
[2] | 4647 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 4648 | %set(handles.rho_patch2,'Visible','on') |
---|
| 4649 | set(handles.rho_text2,'Visible','on') |
---|
| 4650 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4651 | set(handles.thresh_text2,'Visible','on') |
---|
| 4652 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4653 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4654 | set(handles.nx_patch2,'Visible','on') |
---|
| 4655 | set(handles.ny_patch2,'Visible','on') |
---|
| 4656 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4657 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 4658 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 4659 | set(handles.grid_patch2,'Visible','on') |
---|
| 4660 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4661 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4662 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4663 | |
---|
[12] | 4664 | %------------------------------------------------------------------------ |
---|
[2] | 4665 | function desable_patch2(handles) |
---|
[12] | 4666 | %------------------------------------------------------------------------ |
---|
[2] | 4667 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4668 | set(handles.rho_patch2,'Visible','off') |
---|
| 4669 | set(handles.rho_text2,'Visible','off') |
---|
| 4670 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4671 | set(handles.thresh_text2,'Visible','off') |
---|
| 4672 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4673 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4674 | set(handles.nx_patch2,'Visible','off') |
---|
| 4675 | set(handles.ny_patch2,'Visible','off') |
---|
| 4676 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4677 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 4678 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 4679 | set(handles.grid_patch2,'Visible','off') |
---|
| 4680 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4681 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4682 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4683 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4684 | end |
---|
| 4685 | |
---|
[12] | 4686 | %------------------------------------------------------------------------ |
---|
[2] | 4687 | function enable_pair1(handles,state) |
---|
[12] | 4688 | %------------------------------------------------------------------------ |
---|
[2] | 4689 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4690 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4691 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4692 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4693 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4694 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 4695 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 4696 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4697 | |
---|
[12] | 4698 | %------------------------------------------------------------------------ |
---|
| 4699 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4700 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4701 | %------------------------------------------------------------------------ |
---|
[2] | 4702 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 4703 | par.ibx=num2str(ibx_val); |
---|
| 4704 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 4705 | par.iby=num2str(iby_val); |
---|
| 4706 | isx=get(handles.isx,'String'); |
---|
| 4707 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4708 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 4709 | isy=get(handles.isy,'String'); |
---|
| 4710 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4711 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 4712 | par.isx=get(handles.isx,'String'); |
---|
| 4713 | par.isy=get(handles.isy,'String'); |
---|
| 4714 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4715 | par.shifty=get(handles.shifty,'String'); |
---|
| 4716 | if isempty(str2num(par.isx)) |
---|
| 4717 | par.isx='41';%default |
---|
| 4718 | set(handles.isx,'String','41'); |
---|
| 4719 | end |
---|
| 4720 | if isempty(str2num(par.isy)) |
---|
| 4721 | par.isy='41'; %default |
---|
| 4722 | set(handles.isy,'String','41'); |
---|
[12] | 4723 | end |
---|
[2] | 4724 | if isempty(str2num(par.shiftx)) |
---|
| 4725 | par.shiftx='0';%default |
---|
| 4726 | set(handles.shiftx,'String','0'); |
---|
[12] | 4727 | end |
---|
[2] | 4728 | if isempty(str2num(par.shifty)) |
---|
| 4729 | par.shifty='0'; %default |
---|
| 4730 | set(handles.shifty,'String','0'); |
---|
[12] | 4731 | end |
---|
| 4732 | par.rho=get(handles.rho,'String'); |
---|
| 4733 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4734 | par.dy=get(handles.dy_civ1,'String'); |
---|
| 4735 | if isequal(str2num(par.dx),[]) |
---|
| 4736 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4737 | par.dx='0'; %just read by civ program, not used |
---|
| 4738 | else |
---|
| 4739 | par.dx='20';%default |
---|
| 4740 | set(handles.dx_civ1,'String','20'); |
---|
[2] | 4741 | end |
---|
[12] | 4742 | end |
---|
| 4743 | if isequal(str2num(par.dy),[]) |
---|
| 4744 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4745 | par.dy='0';%just read by civ program, not used |
---|
| 4746 | else |
---|
| 4747 | par.dy='20';%default |
---|
| 4748 | set(handles.dy_civ1_title,'String','20'); |
---|
[2] | 4749 | end |
---|
[12] | 4750 | end |
---|
| 4751 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4752 | par.pxcmy='1'; |
---|
[2] | 4753 | % end |
---|
[12] | 4754 | A=imread(file_ima);%read the first image to get the size |
---|
| 4755 | sizim=size(A); |
---|
| 4756 | par.npx=num2str(sizim(2)); |
---|
| 4757 | par.npy=num2str(sizim(1)); |
---|
[71] | 4758 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4759 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4760 | par.gridflag='y'; |
---|
| 4761 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4762 | par.gridname='nogrid'; |
---|
| 4763 | par.gridflag='n'; |
---|
| 4764 | end |
---|
| 4765 | |
---|
| 4766 | %------------------------------------------------------------------------ |
---|
[2] | 4767 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4768 | %------------------------------------------------------------------------ |
---|
| 4769 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4770 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4771 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4772 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4773 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4774 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4775 | par.dy=get(handles.dy_civ2,'String'); |
---|
| 4776 | if isequal(str2num(par.dx),[]) |
---|
| 4777 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4778 | par.dx='0'; %just read by civ program, not used |
---|
| 4779 | else |
---|
| 4780 | par.dx='20';%default |
---|
| 4781 | set(handles.dx_civ2,'String','20'); |
---|
[2] | 4782 | end |
---|
[12] | 4783 | end |
---|
| 4784 | if isequal(str2num(par.dy),[]) |
---|
| 4785 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4786 | par.dy='0';%just read by civ program, not used |
---|
| 4787 | else |
---|
| 4788 | par.dy='20';%default |
---|
| 4789 | set(handles.dy_civ2,'String','20'); |
---|
[2] | 4790 | end |
---|
[12] | 4791 | end |
---|
| 4792 | par.pxcmx='1'; |
---|
| 4793 | par.pxcmy='1'; |
---|
| 4794 | A=imread(file_ima);%read the first image to get the size |
---|
| 4795 | sizim=size(A); |
---|
| 4796 | par.npx=num2str(sizim(2)); |
---|
| 4797 | par.npy=num2str(sizim(1)); |
---|
[71] | 4798 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4799 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4800 | par.gridflag='y'; |
---|
| 4801 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4802 | par.gridname='nogrid'; |
---|
| 4803 | par.gridflag='n'; |
---|
| 4804 | end |
---|
[2] | 4805 | |
---|
[12] | 4806 | %------------------------------------------------------------------------ |
---|
| 4807 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4808 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4809 | %------------------------------------------------------------------------ |
---|
[2] | 4810 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4811 | |
---|
| 4812 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4813 | |
---|
| 4814 | if isequal(par.Dt,'0') |
---|
| 4815 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4816 | end |
---|
[12] | 4817 | % |
---|
| 4818 | % textcmx={'############## CMX file';... |
---|
| 4819 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4820 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4821 | % 'XX' ;... |
---|
| 4822 | % ['Mask ' par.maskflag] ;... |
---|
| 4823 | % ['MaskName ' par.maskname];... |
---|
| 4824 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4825 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4826 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4827 | % ['RO ' par.rho];... |
---|
| 4828 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4829 | % 'XX 1.0';... |
---|
| 4830 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4831 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4832 | % 'XX 1';... |
---|
| 4833 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4834 | % ['Grid ' par.gridflag];... |
---|
| 4835 | % ['GridName ' par.gridname] ;... |
---|
| 4836 | % 'XX 85';... |
---|
| 4837 | % 'XX 1.0';... |
---|
| 4838 | % 'XX 1.0';... |
---|
| 4839 | % 'Hart 1';... |
---|
| 4840 | % 'DecimalShift 0';... |
---|
| 4841 | % 'Deformation 0';... |
---|
| 4842 | % 'CorrelationMin 0';... |
---|
| 4843 | % 'IntensityMin 0';... |
---|
| 4844 | % 'SeuilImage n';... |
---|
| 4845 | % 'SeuilImageValues 0 4096';... |
---|
| 4846 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4847 | % 'ImageUsedBefore null null'}; |
---|
| 4848 | % |
---|
| 4849 | % textout=char(textcmx); |
---|
[90] | 4850 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4851 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
| 4852 | fid=fopen([filename '.cmx'],'w'); |
---|
[12] | 4853 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[91] | 4854 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4855 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[12] | 4856 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4857 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
[94] | 4858 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
[12] | 4859 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4860 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4861 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4862 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4863 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4864 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4865 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4866 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4867 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4868 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4869 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
[94] | 4870 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
[12] | 4871 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4872 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4873 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4874 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4875 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4876 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4877 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4878 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4879 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4880 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4881 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4882 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4883 | fclose(fid); |
---|
| 4884 | |
---|
[73] | 4885 | cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
[90] | 4886 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4887 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 4888 | |
---|
[12] | 4889 | if(isunix) |
---|
| 4890 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4891 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
[67] | 4892 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
[12] | 4893 | else |
---|
[67] | 4894 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log']; |
---|
[12] | 4895 | end |
---|
[2] | 4896 | |
---|
[12] | 4897 | %------------------------------------------------------------------------ |
---|
| 4898 | % --- CIV1 Unified |
---|
[94] | 4899 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4900 | %------------------------------------------------------------------------ |
---|
[2] | 4901 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4902 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4903 | |
---|
| 4904 | civ1.image1=par.filename_ima_a; |
---|
| 4905 | civ1.image2=par.filename_ima_b; |
---|
| 4906 | civ1.imageSize_X=par.npx; |
---|
| 4907 | civ1.imageSize_Y=par.npy; |
---|
| 4908 | civ1.outputFileName=[filename '.nc']; |
---|
| 4909 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4910 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4911 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4912 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4913 | civ1.globalShift_X=par.shiftx; |
---|
| 4914 | civ1.globalShift_Y=par.shifty; |
---|
| 4915 | civ1.ro=par.rho; |
---|
| 4916 | civ1.hart='y'; |
---|
| 4917 | if isequal(par.gridflag,'y') |
---|
| 4918 | civ1.grid=par.gridname; |
---|
| 4919 | else |
---|
| 4920 | civ1.grid='n'; |
---|
| 4921 | civ1.gridSpacing_X=par.dx; |
---|
| 4922 | civ1.gridSpacing_Y=par.dy; |
---|
| 4923 | end |
---|
| 4924 | if isequal(par.maskflag,'y') |
---|
| 4925 | civ1.mask=par.maskname; |
---|
| 4926 | end |
---|
| 4927 | civ1.dt=par.Dt; |
---|
| 4928 | civ1.unit='pixel'; |
---|
| 4929 | civ1.absolut_time_T0=par.T0; |
---|
| 4930 | civ1.pixcmx=par.pxcmx; |
---|
| 4931 | civ1.pixcmy=par.pxcmy; |
---|
| 4932 | civ1.convectFlow='n'; |
---|
| 4933 | |
---|
| 4934 | xml_civ1_parameters=civ1; |
---|
[12] | 4935 | |
---|
| 4936 | %------------------------------------------------------------------------ |
---|
| 4937 | % --- CIV2 Unified |
---|
[94] | 4938 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4939 | %------------------------------------------------------------------------ |
---|
[2] | 4940 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4941 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4942 | |
---|
| 4943 | civ2.image1=par.filename_ima_a; |
---|
| 4944 | civ2.image2=par.filename_ima_b; |
---|
| 4945 | civ2.imageSize_X=par.npx; |
---|
| 4946 | civ2.imageSize_Y=par.npy; |
---|
| 4947 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4948 | civ2.outputFileName=[filename '.nc']; |
---|
| 4949 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4950 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4951 | civ2.ro=par.rho; |
---|
| 4952 | %civ2.decimalShift=par.decimal; |
---|
| 4953 | %civ2.deformation=par.deformation; |
---|
| 4954 | if isequal(par.decimal,'1') |
---|
| 4955 | civ2.decimalShift='y'; |
---|
| 4956 | else |
---|
| 4957 | civ2.decimalShift='n'; |
---|
| 4958 | end |
---|
| 4959 | if isequal(par.deformation,'1') |
---|
| 4960 | civ2.deformation='y'; |
---|
| 4961 | else |
---|
| 4962 | civ2.deformation='n'; |
---|
| 4963 | end |
---|
| 4964 | if isequal(par.gridflag,'y') |
---|
| 4965 | civ2.grid=par.gridname; |
---|
| 4966 | else |
---|
| 4967 | civ2.grid='n'; |
---|
| 4968 | civ2.gridSpacing_X=par.dx; |
---|
| 4969 | civ2.gridSpacing_Y=par.dy; |
---|
| 4970 | end |
---|
| 4971 | civ2.gridSpacing_X='10'; |
---|
| 4972 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4973 | if isequal(par.maskflag,'y') |
---|
| 4974 | civ2.mask=par.maskname; |
---|
| 4975 | else |
---|
| 4976 | civ2.mask='n'; |
---|
| 4977 | end |
---|
| 4978 | civ2.dt=par.Dt; |
---|
| 4979 | civ2.unit='pixel'; |
---|
| 4980 | civ2.absolut_time_T0=par.T0; |
---|
| 4981 | civ2.pixcmx=par.pxcmx; |
---|
| 4982 | civ2.pixcmy=par.pxcmy; |
---|
| 4983 | civ2.convectFlow='n'; |
---|
| 4984 | civ2.pixcmx=par.pxcmx; |
---|
| 4985 | civ2.pixcmy=par.pxcmy; |
---|
| 4986 | civ2.convectFlow='n'; |
---|
| 4987 | |
---|
[12] | 4988 | %------------------------------------------------------------------------ |
---|
| 4989 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[94] | 4990 | function cmd_CIV2=CIV2_CMD(filename_cmx,namelog,par,sparam) |
---|
[12] | 4991 | %------------------------------------------------------------------------ |
---|
[2] | 4992 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4993 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[2] | 4994 | if isequal(par.Dt,'0') |
---|
| 4995 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4996 | end |
---|
[94] | 4997 | % textcmx=['############## CMX file' '\n'... |
---|
| 4998 | % ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 4999 | % ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 5000 | % 'XX' '\n'... |
---|
| 5001 | % ['Mask ' par.maskflag] '\n'... |
---|
| 5002 | % ['MaskName ' par.maskname] '\n'... |
---|
| 5003 | % ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
| 5004 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 5005 | % ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 5006 | % ['RO ' par.rho] '\n'... |
---|
| 5007 | % ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 5008 | % 'XX 1.0' '\n'... |
---|
| 5009 | % ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 5010 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 5011 | % 'XX 1' '\n'... |
---|
| 5012 | % ['ShiftXY 0 0'] '\n'... |
---|
| 5013 | % ['Grid ' par.gridflag] '\n'... |
---|
| 5014 | % ['GridName ' par.gridname] '\n'... |
---|
| 5015 | % 'XX 85' '\n'... |
---|
| 5016 | % 'XX 1.0' '\n'... |
---|
| 5017 | % 'XX 1.0' '\n'... |
---|
| 5018 | % 'Hart 1' '\n'... |
---|
| 5019 | % ['DecimalShift ' par.decimal] '\n'... |
---|
| 5020 | % ['Deformation ' par.deformation] '\n'... |
---|
| 5021 | % 'CorrelationMin 0' '\n'... |
---|
| 5022 | % 'IntensityMin 0' '\n'... |
---|
| 5023 | % 'SeuilImage n' '\n'... |
---|
| 5024 | % 'SeuilImageValues 0 4096' '\n'... |
---|
| 5025 | % ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 5026 | % ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 5027 | % textout=char(textcmx); |
---|
| 5028 | % fid=fopen([filename_cmx '2'],'w'); |
---|
| 5029 | % fprintf(fid,textout); |
---|
| 5030 | % fclose(fid) |
---|
[2] | 5031 | |
---|
[94] | 5032 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
| 5033 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
| 5034 | fid=fopen([filename_cmx '2'],'w'); |
---|
| 5035 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5036 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5037 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5038 | fprintf(fid, ['XX' '\n' ]); |
---|
| 5039 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 5040 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5041 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5042 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 5043 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
---|
| 5044 | fprintf(fid, ['RO ' par.rho '\n']); |
---|
| 5045 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
---|
| 5046 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5047 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 5048 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 5049 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5050 | fprintf(fid, ['ShiftXY 0 0\n']); |
---|
| 5051 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 5052 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
---|
| 5053 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5054 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5055 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5056 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5057 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
---|
| 5058 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
---|
| 5059 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5060 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5061 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5062 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5063 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 5064 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
---|
| 5065 | fclose(fid); |
---|
| 5066 | |
---|
| 5067 | cmd_CIV2=[sparam.Civ2Bin ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 5068 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
---|
| 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); |
---|
[85] | 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 | %------------------------------------------------------------------------ |
---|
[71] | 5132 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 5133 | %------------------------------------------------------------------------ |
---|
| 5134 | mode_list=get(handles.mode,'String'); |
---|
| 5135 | mode_value=get(handles.mode,'Value'); |
---|
| 5136 | mode=mode_list{mode_value}; |
---|
| 5137 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5138 | |
---|
| 5139 | %------------------------------------------------------------------------ |
---|
| 5140 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 5141 | %------------------------------------------------------------------------ |
---|
| 5142 | mode_list=get(handles.mode,'String'); |
---|
| 5143 | mode_value=get(handles.mode,'Value'); |
---|
| 5144 | mode=mode_list{mode_value}; |
---|
| 5145 | if isequal(mode,'series(Dj)') |
---|
| 5146 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5147 | end |
---|
| 5148 | |
---|
| 5149 | %------------------------------------------------------------------------ |
---|
[2] | 5150 | % --- Executes on button press in compare. |
---|
| 5151 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 5152 | %------------------------------------------------------------------------ |
---|
[2] | 5153 | test=get(handles.compare,'Value'); |
---|
| 5154 | if test==2 || test==3 |
---|
[71] | 5155 | filebase=get(handles.RootName,'String'); |
---|
[2] | 5156 | browse=get(handles.browse_root,'Userdata'); |
---|
| 5157 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 5158 | set(handles.browse_root,'UserData',browse); |
---|
| 5159 | set(handles.sub_txt,'Visible','on') |
---|
[71] | 5160 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[2] | 5161 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 5162 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 5163 | set(handles.mode,'Visible','off') |
---|
| 5164 | if test==2 |
---|
| 5165 | set(handles.mode,'Visible','off') |
---|
| 5166 | else |
---|
| 5167 | set(handles.mode,'Visible','on') |
---|
| 5168 | end |
---|
| 5169 | |
---|
| 5170 | % open an image file with the browser |
---|
| 5171 | ind_opening=1;%default |
---|
| 5172 | browse.incr_pair=[0 0]; %default |
---|
[71] | 5173 | oldfile=get(handles.RootName,'String'); |
---|
[2] | 5174 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 5175 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 5176 | '*.*', 'All Files (*.*)'}; |
---|
| 5177 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 5178 | fileinput=[PathName FileName];%complete file name |
---|
| 5179 | sizf=size(fileinput); |
---|
| 5180 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5181 | [path,name,ext]=fileparts(fileinput); |
---|
| 5182 | [path1]=fileparts(filebase); |
---|
| 5183 | if ~strcmp(path1,path) |
---|
| 5184 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
| 5185 | return |
---|
| 5186 | end |
---|
[71] | 5187 | set(handles.RootName_1,'String',name); |
---|
[2] | 5188 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 5189 | browse=get(handles.browse_root,'UserData'); |
---|
| 5190 | browse.nom_type_ima_1=nom_type; |
---|
| 5191 | set(handles.browse_root,'UserData',browse) |
---|
| 5192 | |
---|
| 5193 | %check image extension |
---|
[71] | 5194 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[2] | 5195 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 5196 | return |
---|
| 5197 | end |
---|
| 5198 | |
---|
| 5199 | %check image size |
---|
| 5200 | A=imread(fileinput); |
---|
[71] | 5201 | npxy=get(handles.ImaExt,'UserData'); |
---|
[2] | 5202 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 5203 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 5204 | return |
---|
| 5205 | end |
---|
| 5206 | else |
---|
| 5207 | set(handles.mode,'Visible','on') |
---|
[71] | 5208 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 5209 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 5210 | set(handles.RootName_1,'String',[]); |
---|
[2] | 5211 | mode_store=get(handles.compare,'UserData'); |
---|
| 5212 | set(handles.mode,'String',mode_store) |
---|
| 5213 | set(handles.test_stereo1,'Value',0) |
---|
| 5214 | set(handles.test_stereo2,'Value',0) |
---|
| 5215 | end |
---|
| 5216 | mode_Callback(hObject, eventdata, handles) |
---|
| 5217 | |
---|
[12] | 5218 | %------------------------------------------------------------------------ |
---|
[2] | 5219 | % --- Executes on button press in get_ref_fix1. |
---|
| 5220 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5221 | %------------------------------------------------------------------------ |
---|
[71] | 5222 | filebase=get(handles.RootName,'String'); |
---|
[2] | 5223 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5224 | {'*.nc', ' (*.nc)'; |
---|
| 5225 | '*.nc', 'netcdf files '; ... |
---|
| 5226 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5227 | 'Pick a file',filebase); |
---|
| 5228 | |
---|
| 5229 | fileinput=[PathName FileName]; |
---|
| 5230 | sizf=size(fileinput); |
---|
| 5231 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5232 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5233 | ref.filebase=fullfile(Path,File); |
---|
| 5234 | ref.num_a=stra2num(str_a); |
---|
| 5235 | ref.num_b=stra2num(str_b); |
---|
[89] | 5236 | ref.num1=str2double(field_count); |
---|
| 5237 | ref.num2=str2double(str2); |
---|
[2] | 5238 | browse=[];%initialisation |
---|
| 5239 | if ~isequal(ref.ext,'.nc') |
---|
| 5240 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5241 | return |
---|
| 5242 | end |
---|
| 5243 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5244 | set(handles.ref_fix1,'UserData',ref) |
---|
| 5245 | menu_field{1}='civ1'; |
---|
| 5246 | Data=nc2struct(fileinput,[]); |
---|
[45] | 5247 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 5248 | menu_field{2}='filter1'; |
---|
| 5249 | end |
---|
[45] | 5250 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 5251 | menu_field{3}='civ2'; |
---|
| 5252 | end |
---|
[45] | 5253 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 5254 | menu_field{4}='filter2'; |
---|
| 5255 | end |
---|
| 5256 | set(handles.field_ref1,'String',menu_field); |
---|
| 5257 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 5258 | set(handles.inf_sup1,'Value',2); |
---|
| 5259 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 5260 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 5261 | |
---|
| 5262 | %------------------------------------------------------------------------ |
---|
[2] | 5263 | % --- Executes on button press in get_ref_fix2. |
---|
| 5264 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5265 | %------------------------------------------------------------------------ |
---|
[2] | 5266 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 5267 | filebase=get(handles.RootName,'String'); |
---|
[2] | 5268 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5269 | {'*.nc', ' (*.nc)'; |
---|
| 5270 | '*.nc', 'netcdf files '; ... |
---|
| 5271 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5272 | 'Pick a file',filebase); |
---|
| 5273 | fileinput=[PathName FileName]; |
---|
| 5274 | sizf=size(fileinput); |
---|
[45] | 5275 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 5276 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5277 | ref.filebase=fullfile(Path,File); |
---|
| 5278 | ref.num_a=stra2num(str_a); |
---|
| 5279 | ref.num_b=stra2num(str_b); |
---|
| 5280 | ref.num1=str2num(field_count); |
---|
| 5281 | ref.num2=str2num(str2); |
---|
| 5282 | browse=[];%initialisation |
---|
| 5283 | if ~isequal(ref.ext,'.nc') |
---|
| 5284 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5285 | return |
---|
| 5286 | end |
---|
| 5287 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5288 | set(handles.ref_fix2,'UserData',ref) |
---|
| 5289 | menu_field{1}='civ1'; |
---|
| 5290 | Data=nc2struct(fileinput,[]); |
---|
| 5291 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5292 | menu_field{2}='filter1'; |
---|
| 5293 | end |
---|
| 5294 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5295 | menu_field{3}='civ2'; |
---|
| 5296 | end |
---|
| 5297 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5298 | menu_field{4}='filter2'; |
---|
| 5299 | end |
---|
| 5300 | set(handles.field_ref2,'String',menu_field); |
---|
| 5301 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 5302 | set(handles.inf_sup2,'Value',2); |
---|
| 5303 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 5304 | set(handles.ref_fix2,'Enable','on') |
---|
| 5305 | set(handles.ref_fix2,'Visible','on') |
---|
| 5306 | set(handles.field_ref2,'Visible','on') |
---|
| 5307 | else |
---|
| 5308 | set(handles.ref_fix2,'Visible','off') |
---|
| 5309 | set(handles.field_ref2,'Visible','off') |
---|
| 5310 | end |
---|
| 5311 | |
---|
[12] | 5312 | %------------------------------------------------------------------------ |
---|
[2] | 5313 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5314 | %------------------------------------------------------------------------ |
---|
| 5315 | set(handles.inf_sup1,'Value',1); |
---|
| 5316 | set(handles.field_ref1,'Value',1) |
---|
| 5317 | set(handles.field_ref1,'String',{' '}) |
---|
| 5318 | set(handles.ref_fix1,'UserData',[]); |
---|
| 5319 | set(handles.ref_fix1,'String',''); |
---|
| 5320 | set(handles.thresh_vel1,'String','0'); |
---|
[2] | 5321 | |
---|
[12] | 5322 | %------------------------------------------------------------------------ |
---|
[2] | 5323 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5324 | %------------------------------------------------------------------------ |
---|
| 5325 | set(handles.inf_sup2,'Value',1); |
---|
| 5326 | set(handles.field_ref2,'Value',1) |
---|
| 5327 | set(handles.field_ref2,'String',{' '}) |
---|
| 5328 | set(handles.ref_fix2,'UserData',[]); |
---|
| 5329 | set(handles.ref_fix2,'String',''); |
---|
| 5330 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 5331 | |
---|
[89] | 5332 | % %------------------------------------------------------------------------ |
---|
| 5333 | % % transform letters to numbers |
---|
| 5334 | % function numres=stra2num(str) |
---|
| 5335 | % %------------------------------------------------------------------------ |
---|
| 5336 | % numres=double(str)-96; |
---|
| 5337 | % if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 5338 | % numres=str2num(str); |
---|
| 5339 | % end |
---|
[2] | 5340 | |
---|
[12] | 5341 | %------------------------------------------------------------------------ |
---|
[2] | 5342 | % --- Executes on button press in test_stereo1. |
---|
| 5343 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 5344 | %------------------------------------------------------------------------ |
---|
[2] | 5345 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 5346 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 5347 | set(handles.rho_patch1,'Visible','on') |
---|
| 5348 | else |
---|
| 5349 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 5350 | set(handles.rho_patch1,'Visible','off') |
---|
| 5351 | end |
---|
| 5352 | |
---|
[12] | 5353 | %------------------------------------------------------------------------ |
---|
[2] | 5354 | % --- Executes on button press in test_stereo2. |
---|
| 5355 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 5356 | %------------------------------------------------------------------------ |
---|
[2] | 5357 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 5358 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 5359 | set(handles.rho_patch2,'Visible','on') |
---|
| 5360 | else |
---|
| 5361 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 5362 | set(handles.rho_patch2,'Visible','off') |
---|
| 5363 | end |
---|
| 5364 | |
---|
[12] | 5365 | %------------------------------------------------------------------------ |
---|
[2] | 5366 | % --- Executes on button press in ImaThreshold. |
---|
| 5367 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 5368 | %------------------------------------------------------------------------ |
---|
[2] | 5369 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 5370 | set(handles.MinIma,'Visible','on') |
---|
| 5371 | set(handles.MaxIma,'Visible','on') |
---|
| 5372 | else |
---|
| 5373 | set(handles.MinIma,'Visible','off') |
---|
| 5374 | set(handles.MaxIma,'Visible','off') |
---|
| 5375 | end |
---|
| 5376 | |
---|
[12] | 5377 | %------------------------------------------------------------------------ |
---|
[2] | 5378 | % --- Executes on button press in ImaThreshold2. |
---|
| 5379 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 5380 | %------------------------------------------------------------------------ |
---|
[2] | 5381 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 5382 | set(handles.MinIma2,'Visible','on') |
---|
| 5383 | set(handles.MaxIma2,'Visible','on') |
---|
| 5384 | else |
---|
| 5385 | set(handles.MinIma2,'Visible','off') |
---|
| 5386 | set(handles.MaxIma2,'Visible','off') |
---|
| 5387 | end |
---|
| 5388 | |
---|
[71] | 5389 | |
---|
| 5390 | |
---|
| 5391 | |
---|