[112] | 1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
[2] | 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 |
---|
[112] | 10 | % This file is part of the toolbox UVMAT. |
---|
| 11 | % |
---|
[2] | 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. |
---|
[112] | 16 | % |
---|
[2] | 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, ... |
---|
[112] | 28 | 'gui_Singleton', gui_Singleton, ... |
---|
| 29 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 30 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 31 | 'gui_LayoutFcn', [] , ... |
---|
| 32 | 'gui_Callback', []); |
---|
[2] | 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 |
---|
[112] | 54 | %filebase: root name |
---|
[2] | 55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
| 56 | %list of field numbers to process |
---|
[112] | 57 | %subdir: subdirectory of the opened netcdf file |
---|
[2] | 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=[]; |
---|
[112] | 68 | testall=0; |
---|
[71] | 69 | %default input parameters: |
---|
| 70 | num1=1; % set of field i numbers |
---|
[122] | 71 | num2=1; % set of field i numbers |
---|
[71] | 72 | num_a=1; % set of field j numbers (fields a) |
---|
| 73 | num_b=1; % second set of field j numbers (fields b) |
---|
| 74 | subdir='A'; % subdir for the netcdf result files |
---|
[112] | 75 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 76 | %load the initial parameters if the interface is started from uvmat |
---|
[71] | 77 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 78 | filebase=param.RootName; |
---|
| 79 | nom_type_read=param.NomType; |
---|
| 80 | num1=param.num1; |
---|
| 81 | num2=param.num2; |
---|
| 82 | num_a=param.num_a; |
---|
| 83 | num_b=param.num_b; |
---|
| 84 | subdir=param.SubDir; |
---|
| 85 | ind_opening=param.IndOpening; |
---|
| 86 | ext=param.ImaExt; |
---|
[2] | 87 | end |
---|
[122] | 88 | browse.num_i1=num1; |
---|
| 89 | browse.num_i2=num2; |
---|
| 90 | browse.num_j1=num_a; |
---|
| 91 | browse.num_j2=num_b; |
---|
| 92 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[112] | 93 | set(handles.ImaExt,'String',ext) |
---|
[128] | 94 | browse.ext_ima=ext; |
---|
[112] | 95 | if exist('nom_type_read','var') |
---|
| 96 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 97 | end |
---|
[2] | 98 | elseif isequal(ext,'.nc') |
---|
| 99 | if exist('nom_type_read','var') |
---|
| 100 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 101 | end |
---|
| 102 | end |
---|
[71] | 103 | set(handles.RootName,'String',filebase); |
---|
[2] | 104 | set(handles.ImaDoc,'UserData',testall); |
---|
| 105 | set(handles.ImaDoc,'String',ext) |
---|
| 106 | |
---|
[122] | 107 | %read names of the .exe file to adjust the interface according to available binaries |
---|
[2] | 108 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 109 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 110 | errormsg=[];%default error message |
---|
[111] | 111 | % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 112 | % if ~exist(xmlfile,'file') |
---|
[112] | 113 | xmlfile='PARAM.xml'; |
---|
[111] | 114 | % end |
---|
[54] | 115 | if exist(xmlfile,'file') |
---|
| 116 | try |
---|
[112] | 117 | t=xmltree(xmlfile); |
---|
| 118 | sparam=convert(t); |
---|
[54] | 119 | catch |
---|
[112] | 120 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
[2] | 121 | end |
---|
[54] | 122 | else |
---|
| 123 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[2] | 124 | end |
---|
[71] | 125 | |
---|
[110] | 126 | |
---|
[45] | 127 | if ~isempty(errormsg) |
---|
[112] | 128 | msgbox_uvmat('ERROR',errormsg); |
---|
[45] | 129 | end |
---|
[71] | 130 | % patch_newBin=''; |
---|
| 131 | test_batch=0;%default: ,no batch mode available |
---|
| 132 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 133 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
[2] | 134 | end |
---|
| 135 | if test_batch==0 |
---|
[84] | 136 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
[2] | 137 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 138 | end |
---|
[94] | 139 | if isfield(sparam.RunParam,'CivBin') |
---|
| 140 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[112] | 141 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
[94] | 142 | end |
---|
[97] | 143 | else |
---|
| 144 | sparam.RunParam.CivBin=''; |
---|
[94] | 145 | end |
---|
[96] | 146 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
[2] | 147 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 148 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 149 | |
---|
| 150 | %initiate advised operations |
---|
| 151 | if isequal(ind_opening,[]) |
---|
| 152 | ind_opening=1; % default |
---|
| 153 | end |
---|
| 154 | % set default operation options |
---|
[112] | 155 | enable_civ1(handles,'off') |
---|
| 156 | enable_civ2(handles,'off') |
---|
| 157 | enable_pair1(handles,'on') |
---|
| 158 | enable_fix1(handles,'off') |
---|
| 159 | desable_patch1(handles) |
---|
| 160 | desable_fix2(handles) |
---|
| 161 | desable_patch2(handles) |
---|
| 162 | set(handles.CIV1,'Value',0) |
---|
| 163 | set(handles.FIX1,'Value',0) |
---|
| 164 | set(handles.PATCH1,'Value',0) |
---|
| 165 | set(handles.CIV2,'Value',0) |
---|
| 166 | set(handles.FIX2,'Value',0) |
---|
| 167 | set(handles.PATCH2,'Value',0) |
---|
| 168 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 169 | if isequal(ind_opening,1) |
---|
| 170 | set(handles.CIV1,'Value',1) |
---|
| 171 | enable_civ1(handles,'on') |
---|
| 172 | elseif isequal(ind_opening,2) |
---|
| 173 | set(handles.FIX1,'Value',1) |
---|
| 174 | enable_fix1(handles,'on') |
---|
| 175 | elseif isequal(ind_opening,3) |
---|
| 176 | set(handles.PATCH1,'Value',1) |
---|
| 177 | enable_patch1(handles) |
---|
| 178 | elseif isequal(ind_opening,4) |
---|
| 179 | set(handles.CIV2,'Value',1) |
---|
| 180 | enable_civ2(handles,1) |
---|
| 181 | elseif isequal(ind_opening,5) |
---|
| 182 | set(handles.FIX2,'Value',1) |
---|
| 183 | enable_fix2(handles) |
---|
[112] | 184 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 185 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 186 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 187 | enable_pair1(handles,'off') |
---|
[2] | 188 | elseif isequal(ind_opening,6) |
---|
| 189 | set(handles.PATCH2,'Value',1) |
---|
| 190 | enable_patch2(handles) |
---|
| 191 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 192 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 193 | enable_pair1(handles,'off') |
---|
| 194 | end |
---|
| 195 | |
---|
| 196 | % set the range of fields (1:1 by default) and selected pair |
---|
[89] | 197 | if isnan(num2)||isequal(num2,num1) |
---|
[2] | 198 | num_ref_i=num1; |
---|
| 199 | else |
---|
| 200 | num_ref_i=floor((num1+num2)/2); |
---|
| 201 | browse.incr_pair(1)=num2-num1; |
---|
| 202 | browse.incr_pair(2)=0; |
---|
| 203 | end |
---|
[89] | 204 | if isnan(num_b)||isequal(num_a,num_b) |
---|
| 205 | if isnan(num_a) |
---|
[2] | 206 | num_ref_j=1; |
---|
| 207 | else |
---|
| 208 | num_ref_j=num_a; |
---|
| 209 | end |
---|
| 210 | else |
---|
| 211 | num_ref_j=floor((num_a+num_b)/2); |
---|
[112] | 212 | browse.incr_pair(2)=num_b-num_a; |
---|
[2] | 213 | end |
---|
| 214 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 215 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 216 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 217 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 218 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 219 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[71] | 220 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 221 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
[2] | 222 | set(handles.browse_root,'UserData',browse); |
---|
[71] | 223 | if exist('param','var')%varargin the interface is opened from uvmat |
---|
[112] | 224 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 225 | end |
---|
| 226 | |
---|
| 227 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 228 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 229 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 230 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 231 | |
---|
[12] | 232 | %------------------------------------------------------------------------ |
---|
[2] | 233 | % --- Outputs from this function are returned to the command line. |
---|
| 234 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 235 | %------------------------------------------------------------------------ |
---|
[2] | 236 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 237 | % hObject handle to figure |
---|
| 238 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 239 | % handles structure with handles and user data (see GUIDATA) |
---|
| 240 | % Get default command line output from handles structure |
---|
| 241 | varargout{1} = handles.output; |
---|
| 242 | |
---|
[12] | 243 | %------------------------------------------------------------------------ |
---|
[2] | 244 | % --- Executes on button press in browse_root. |
---|
| 245 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 246 | %------------------------------------------------------------------------ |
---|
[2] | 247 | %get the input file properties |
---|
[71] | 248 | filebase=get(handles.RootName,'String'); |
---|
[2] | 249 | oldfile=''; %default |
---|
[39] | 250 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 251 | dir_perso=prefdir; |
---|
| 252 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 253 | if exist(profil_perso,'file') |
---|
| 254 | h=load (profil_perso); |
---|
| 255 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 256 | oldfile=h.filebase; |
---|
| 257 | end |
---|
| 258 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 259 | oldfile=h.RootPath; |
---|
| 260 | end |
---|
| 261 | end |
---|
| 262 | else |
---|
| 263 | oldfile=filebase; |
---|
| 264 | end |
---|
[2] | 265 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 266 | ind_opening=1;%default |
---|
| 267 | browse.incr_pair=[0 0]; %default |
---|
[112] | 268 | if testall |
---|
[2] | 269 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 270 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 271 | else % menu selecting only .civ or .avi files |
---|
[112] | 272 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
[2] | 273 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 274 | '*.*', 'All Files (*.*)'}; |
---|
| 275 | end |
---|
| 276 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 277 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 278 | sizf=size(fileinput); |
---|
| 279 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 280 | [path,name,ext]=fileparts(fileinput); |
---|
| 281 | testeditxml=0; |
---|
| 282 | if isequal(ext,'.xml') |
---|
| 283 | testeditxml=1; |
---|
| 284 | t_browse=xmltree(fileinput); |
---|
| 285 | head_element=get(t_browse,1); |
---|
[45] | 286 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 287 | testeditxml=0; |
---|
| 288 | end |
---|
| 289 | end |
---|
[45] | 290 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 291 | heditxml=editxml({fileinput}); |
---|
| 292 | set(heditxml,'Tag','browser') |
---|
| 293 | waitfor(heditxml,'Tag','idle') |
---|
| 294 | if ~ishandle(heditxml) |
---|
| 295 | return |
---|
| 296 | end |
---|
| 297 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 298 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 299 | fileinput=get(attr,'UserData'); |
---|
| 300 | if ~exist(fileinput,'file') |
---|
| 301 | return |
---|
| 302 | end |
---|
[2] | 303 | end |
---|
[82] | 304 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 305 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 306 | num_i1=str2double(str1); |
---|
| 307 | if isnan(num_i1),num_i1=1;end |
---|
| 308 | num_i2=str2double(str2); |
---|
| 309 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 310 | num_j1=stra2num(str_a); |
---|
[89] | 311 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 312 | num_j2=stra2num(str_b); |
---|
[112] | 313 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 314 | if isequal(get(handles.compare,'Value'),1) |
---|
| 315 | browse=[];%initialisation |
---|
| 316 | else |
---|
| 317 | browse=get(handles.browse_root,'UserData'); |
---|
| 318 | end |
---|
[122] | 319 | browse.num_i1=num_i1; |
---|
| 320 | browse.num_i2=num_i2; |
---|
| 321 | browse.num_j1=num_j1; |
---|
| 322 | browse.num_j2=num_j2; |
---|
| 323 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
| 324 | % set(handles.ImaExt,'String',ext) |
---|
[2] | 325 | browse.nom_type_ima=nom_type; |
---|
[122] | 326 | browse.ext_ima=ext; |
---|
[2] | 327 | end |
---|
| 328 | set(handles.ImaDoc,'String',ext); |
---|
| 329 | |
---|
| 330 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 331 | if isequal(ext,'.nc') |
---|
| 332 | browse.nom_type_nc=nom_type; |
---|
[112] | 333 | ind_opening=2;% propose 'fix' as the default option |
---|
[2] | 334 | Data=nc2struct(fileinput,[]); |
---|
[112] | 335 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
[2] | 336 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 337 | ind_opening=3; |
---|
| 338 | end |
---|
| 339 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 340 | ind_opening=4; |
---|
| 341 | end |
---|
| 342 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 343 | ind_opening=5; |
---|
| 344 | end |
---|
| 345 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 346 | ind_opening=6; |
---|
| 347 | end |
---|
| 348 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 349 | else |
---|
[112] | 350 | ind_opening=3; %GUI used only for patch |
---|
[2] | 351 | testciv=0; |
---|
| 352 | end |
---|
| 353 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 354 | set(handles.subdir_civ2,'String',subdir); |
---|
| 355 | browse.testciv=testciv; |
---|
| 356 | browse.ind_opening=ind_opening; |
---|
| 357 | end |
---|
[71] | 358 | set(handles.RootName,'String',filebase); |
---|
[2] | 359 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 360 | if ~isempty(num_i1) |
---|
[82] | 361 | ref_i=num_i1; |
---|
[45] | 362 | if ~isempty(num_i2) |
---|
| 363 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 364 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 365 | browse.incr_pair(2)=0; |
---|
| 366 | end |
---|
| 367 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 368 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 369 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 370 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 371 | end |
---|
[45] | 372 | if isempty(num_j1) |
---|
[2] | 373 | set(handles.ref_j,'String','1'); |
---|
[71] | 374 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 375 | else |
---|
[45] | 376 | ref_j=num_j1; |
---|
| 377 | if ~isempty(num_j2) |
---|
| 378 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 379 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 380 | end |
---|
| 381 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 382 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 383 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[71] | 384 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 385 | end |
---|
| 386 | |
---|
| 387 | % set default operation options |
---|
| 388 | enable_civ1(handles,'off') |
---|
| 389 | enable_civ2(handles,'off') |
---|
| 390 | enable_pair1(handles,'on') |
---|
| 391 | enable_fix1(handles,'off') |
---|
| 392 | desable_patch1(handles) |
---|
| 393 | desable_fix2(handles) |
---|
| 394 | desable_patch2(handles) |
---|
| 395 | set(handles.CIV1,'Value',0) |
---|
| 396 | set(handles.FIX1,'Value',0) |
---|
| 397 | set(handles.PATCH1,'Value',0) |
---|
| 398 | set(handles.CIV2,'Value',0) |
---|
| 399 | set(handles.FIX2,'Value',0) |
---|
| 400 | set(handles.PATCH2,'Value',0) |
---|
| 401 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 402 | if isequal(ind_opening,1) |
---|
| 403 | set(handles.CIV1,'Value',1) |
---|
| 404 | enable_civ1(handles,'on') |
---|
| 405 | elseif isequal(ind_opening,2) |
---|
| 406 | set(handles.FIX1,'Value',1) |
---|
| 407 | enable_fix1(handles,'on') |
---|
| 408 | elseif isequal(ind_opening,3) |
---|
| 409 | set(handles.PATCH1,'Value',1) |
---|
| 410 | enable_patch1(handles) |
---|
| 411 | elseif isequal(ind_opening,4) |
---|
| 412 | set(handles.CIV2,'Value',1) |
---|
| 413 | enable_civ2(handles,1) |
---|
| 414 | elseif isequal(ind_opening,5) |
---|
| 415 | enable_pair1(handles,'off') |
---|
| 416 | set(handles.FIX2,'Value',1) |
---|
| 417 | enable_fix2(handles) |
---|
[112] | 418 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 419 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 420 | set(handles.list_pair_civ2,'Enable','On') |
---|
[2] | 421 | elseif isequal(ind_opening,6) |
---|
| 422 | enable_pair1(handles,'off') |
---|
| 423 | set(handles.PATCH2,'Value',1) |
---|
| 424 | enable_patch2(handles) |
---|
| 425 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 426 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 427 | end |
---|
| 428 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 429 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 430 | set(handles.ImaDoc,'UserData',testall); |
---|
| 431 | |
---|
[71] | 432 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 433 | |
---|
[12] | 434 | %------------------------------------------------------------------------ |
---|
[2] | 435 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 436 | %------------------------------------------------------------------------ |
---|
[71] | 437 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 438 | |
---|
[12] | 439 | %------------------------------------------------------------------------ |
---|
[54] | 440 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 441 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 442 | %------------------------------------------------------------------------ |
---|
[2] | 443 | set(handles.compare,'Visible','on') |
---|
[122] | 444 | %ext_ima=get(handles.ImaExt,'String'); |
---|
| 445 | ext_ima='';%default |
---|
[2] | 446 | nom_type_ima=[];%default |
---|
| 447 | field_count=1;%default |
---|
| 448 | nom_type_nc=[]; |
---|
| 449 | time=[]; |
---|
[71] | 450 | TimeUnit='frame'; %default |
---|
| 451 | CoordUnit='px';%default |
---|
[2] | 452 | pxcmx_search=[];%default |
---|
| 453 | pxcmy_search=[];%default |
---|
[71] | 454 | filebase=get(handles.RootName,'String'); |
---|
[128] | 455 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[135] | 456 | browse=get(handles.browse_root,'UserData');%default |
---|
[122] | 457 | if isfield(browse,'nom_type_ima') |
---|
| 458 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 459 | end |
---|
| 460 | if isfield(browse,'ext_ima') |
---|
[122] | 461 | ext_ima=browse.ext_ima; |
---|
[2] | 462 | end |
---|
[122] | 463 | if isfield(browse,'nom_type_nc') |
---|
| 464 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 465 | end |
---|
| 466 | if isfield(browse,'num_i1') |
---|
| 467 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 468 | end |
---|
[2] | 469 | |
---|
| 470 | %default first_i and j and increments |
---|
[137] | 471 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 472 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 473 | first_i=1; %default first_i |
---|
| 474 | end |
---|
[137] | 475 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 476 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 477 | last_i=first_i; %default last_i |
---|
| 478 | end |
---|
[137] | 479 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 480 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 481 | first_j=1; %default first_j |
---|
| 482 | end |
---|
[137] | 483 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 484 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 485 | last_j=first_j; %default last_j |
---|
| 486 | end |
---|
[137] | 487 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 488 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 489 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 490 | end |
---|
[137] | 491 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 492 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 493 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 494 | end |
---|
| 495 | dt=[];%default |
---|
| 496 | testmode=0;%default |
---|
| 497 | nbfield=[]; %default |
---|
| 498 | nburst=[];%default |
---|
| 499 | pxcmx=1; |
---|
[112] | 500 | pxcmy=1; |
---|
[2] | 501 | |
---|
[112] | 502 | %look for an image documentation file |
---|
[128] | 503 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 504 | if exist([filebase '.xml'],'file') |
---|
[128] | 505 | ext_imadoc='.xml'; |
---|
[2] | 506 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 507 | ext_imadoc='.civxml'; |
---|
[2] | 508 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 509 | ext_imadoc='.civ'; |
---|
[112] | 510 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 511 | ext_imadoc='.avi'; |
---|
[2] | 512 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 513 | ext_imadoc='.AVI'; |
---|
[2] | 514 | end |
---|
[128] | 515 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 516 | end |
---|
| 517 | |
---|
| 518 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 519 | mode=''; %default |
---|
| 520 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 521 | drawnow |
---|
[128] | 522 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 523 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 524 | set(handles.ref_j,'Visible','On') |
---|
[128] | 525 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 526 | set(handles.ref_j,'Visible','Off') |
---|
| 527 | else |
---|
| 528 | set(handles.ref_i,'Visible','Off') |
---|
| 529 | set(handles.ref_j,'Visible','Off') |
---|
| 530 | end |
---|
[12] | 531 | testima_xml=0; |
---|
[128] | 532 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 533 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 534 | mode='pair j1-j2'; |
---|
| 535 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 536 | nom_type_ima='_i_j'; |
---|
[2] | 537 | end |
---|
[128] | 538 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 539 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 540 | ext_ima_read=[]; |
---|
| 541 | nom_type_read=[]; |
---|
[12] | 542 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 543 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 544 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 545 | if ~exist(fullname,'file') |
---|
[12] | 546 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 547 | end |
---|
[2] | 548 | end |
---|
[84] | 549 | if isfield(XmlData,'Time') |
---|
[85] | 550 | time=XmlData.Time; |
---|
[84] | 551 | nbfield=size(time,1); |
---|
[122] | 552 | nbfield2=size(time,2); |
---|
[127] | 553 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 554 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 555 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 556 | time=time'; |
---|
[122] | 557 | nbfield=nbfield2; |
---|
| 558 | nbfield2=1; |
---|
[84] | 559 | end |
---|
| 560 | end |
---|
| 561 | end |
---|
[71] | 562 | if isfield(XmlData,'TimeUnit') |
---|
| 563 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 564 | end |
---|
[71] | 565 | if isfield(XmlData,'Npx') |
---|
| 566 | npx=XmlData.Npx; |
---|
| 567 | npy=XmlData.Npy; |
---|
| 568 | end |
---|
[2] | 569 | pxcmx_search=1; |
---|
| 570 | pxcmy_search=1; |
---|
| 571 | if isfield(XmlData,'GeometryCalib') |
---|
| 572 | tsai=XmlData.GeometryCalib; |
---|
[112] | 573 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 574 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 575 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 576 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 577 | end |
---|
[112] | 578 | if isfield(tsai,'CoordUnit') |
---|
| 579 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 580 | end |
---|
[112] | 581 | end |
---|
[128] | 582 | % if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
| 583 | % % if isempty(ext_ima) |
---|
| 584 | % % ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
| 585 | % % else %keep the image extension |
---|
| 586 | % % if ~strcmp(ext_ima_read,ext_ima) |
---|
| 587 | % % msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
| 588 | % % end |
---|
| 589 | % % end |
---|
| 590 | % nom_type_ima=nom_type_read; |
---|
| 591 | % end |
---|
| 592 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 593 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 594 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 595 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 596 | end |
---|
[128] | 597 | nom_type_ima='001a'; |
---|
| 598 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 599 | nom_type_ima='*'; |
---|
[128] | 600 | ext_ima=ext_imadoc; |
---|
[112] | 601 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 602 | dt=0.04;%default |
---|
[128] | 603 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 604 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 605 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 606 | nbfield=info.NumFrames;%number of frames |
---|
| 607 | end |
---|
| 608 | time=(dt*(0:nbfield-1))';%list of image times |
---|
| 609 | %set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
[2] | 610 | end |
---|
| 611 | if isempty(time) |
---|
| 612 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 613 | end |
---|
| 614 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 615 | |
---|
[122] | 616 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 617 | dirima=[];%default |
---|
[12] | 618 | if isempty(nom_type_ima) |
---|
| 619 | %look for double image series '_i_j' |
---|
| 620 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 621 | if isempty(dirima) |
---|
[112] | 622 | % look for images series with sub marker '_' |
---|
| 623 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 624 | if isempty(dirima) |
---|
| 625 | % look for other images series |
---|
| 626 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 627 | if isempty(dirima) |
---|
| 628 | % look for other images series witth letter appendix |
---|
| 629 | appendix=char(96+first_j); |
---|
| 630 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 631 | end |
---|
| 632 | end |
---|
[12] | 633 | end |
---|
[112] | 634 | end |
---|
[122] | 635 | for ilist=1:numel(dirima) |
---|
| 636 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 637 | form=imformats(ext_list(2:end)); |
---|
| 638 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 639 | ext_ima=ext_list; |
---|
| 640 | nom_type_ima=nom_type_list; |
---|
| 641 | break |
---|
| 642 | end |
---|
| 643 | end |
---|
| 644 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 645 | if isempty(nom_type_ima) |
---|
[128] | 646 | ext_search=ext_imadoc; |
---|
[122] | 647 | nom_type_search=nom_type_nc; |
---|
| 648 | else |
---|
| 649 | ext_search=ext_ima; |
---|
| 650 | nom_type_search=nom_type_ima; |
---|
| 651 | end |
---|
| 652 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[12] | 653 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 654 | incr_pair=[0 0];%default |
---|
| 655 | if isfield(browse,'incr_pair') |
---|
[112] | 656 | incr_pair=browse.incr_pair; |
---|
[12] | 657 | end |
---|
[112] | 658 | % nbdetect=0;%test of detected images |
---|
[122] | 659 | field_i=browse.num_i2; |
---|
[12] | 660 | idetect=1; |
---|
[112] | 661 | while idetect==1 %look for the maximum file number in the series |
---|
[122] | 662 | imagename=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
[81] | 663 | idetect=(exist(imagename,'file')==2); |
---|
| 664 | if idetect |
---|
[12] | 665 | field_i=field_i+1; |
---|
[81] | 666 | end |
---|
[112] | 667 | %SEE CASE OF NETCDF FILES |
---|
| 668 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 669 | end |
---|
[122] | 670 | nbfield=field_i;% last detected field number |
---|
| 671 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[12] | 672 | idetect=1; |
---|
[112] | 673 | while idetect==1 |
---|
[122] | 674 | imagename=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
[81] | 675 | idetect=(exist(imagename,'file')==2); |
---|
| 676 | if idetect |
---|
[112] | 677 | field_i=field_i-1; |
---|
[81] | 678 | end |
---|
[12] | 679 | end |
---|
[122] | 680 | first_i=max(field_i,1); |
---|
| 681 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 682 | field_i=browse.num_i1; |
---|
| 683 | field_j=browse.num_j2; |
---|
[89] | 684 | jdetect=1; |
---|
| 685 | while jdetect==1 %look for the maximum file number in the series |
---|
[122] | 686 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[89] | 687 | jdetect=(exist(imagename,'file')==2); |
---|
| 688 | if jdetect |
---|
| 689 | field_j=field_j+1; |
---|
| 690 | end |
---|
| 691 | %SEE CASE OF NETCDF FILES |
---|
| 692 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 693 | end |
---|
[122] | 694 | nbfield2=field_j;% last detected field number |
---|
[120] | 695 | end |
---|
[122] | 696 | |
---|
[89] | 697 | %determine the set of times and possible intervals for CIV |
---|
[137] | 698 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 699 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 700 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 701 | % switch nom_type_search |
---|
| 702 | % case {'_i_j','%01dA','%02dA','%03dA','%04dA'} |
---|
[112] | 703 | % time=[0:nb_field-1]'*ones(1,nb_field_j);% time=file index -1 by default |
---|
[122] | 704 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 705 | time=x+y; |
---|
| 706 | % time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1 by default |
---|
[89] | 707 | end |
---|
[122] | 708 | % set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 709 | end |
---|
[120] | 710 | |
---|
[2] | 711 | if exist('time','var') |
---|
| 712 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 713 | nbfield=size(time,1); |
---|
| 714 | nbfield2=size(time,2); |
---|
[71] | 715 | set(handles.RootName,'UserData',time); %store the set of times |
---|
| 716 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 717 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
| 718 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 719 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 720 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 721 | end |
---|
| 722 | end |
---|
[71] | 723 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[2] | 724 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 725 | % npxy=[npy npx]; |
---|
[71] | 726 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 727 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 728 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 729 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 730 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 731 | browse.nom_type_ima=nom_type_ima; |
---|
| 732 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 733 | |
---|
[112] | 734 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[122] | 735 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D'));%images with single indexing |
---|
| 736 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 737 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 738 | set(handles.mode,'Value',1) |
---|
| 739 | elseif (nbfield==1)% simple series in j |
---|
| 740 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 741 | set(handles.mode,'Value',1) |
---|
| 742 | else |
---|
| 743 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 744 | if nbfield2 <= 10 |
---|
[112] | 745 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 746 | end |
---|
| 747 | end |
---|
| 748 | |
---|
[112] | 749 | %update the subdir |
---|
[2] | 750 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 751 | listot=dir(pathdir); |
---|
| 752 | idir=0; |
---|
| 753 | listdir={''};%default |
---|
| 754 | for ilist=1:length(listot) |
---|
| 755 | if listot(ilist).isdir |
---|
| 756 | name=listot(ilist).name; |
---|
| 757 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 758 | idir=idir+1; |
---|
| 759 | listdir{idir,1}=listot(ilist).name; |
---|
| 760 | end |
---|
| 761 | end |
---|
| 762 | end |
---|
[112] | 763 | set(handles.list_subdir_civ1,'Value',1) |
---|
[2] | 764 | set(handles.list_subdir_civ2,'Value',1) |
---|
[107] | 765 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
---|
| 766 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
---|
[2] | 767 | %check wether the current subdir exists: |
---|
| 768 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 769 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 770 | |
---|
[112] | 771 | mode_Callback(hObject, eventdata, handles) |
---|
[2] | 772 | |
---|
| 773 | %%%%%% initialize waitbars and RUN button |
---|
| 774 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 775 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 776 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 777 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 778 | set(handles.RUN, 'Enable','On') |
---|
| 779 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 780 | set(handles.BATCH,'Enable','On') |
---|
| 781 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[112] | 782 | |
---|
[2] | 783 | %%%%% store the root input filename for future opening |
---|
| 784 | dir_perso=prefdir; |
---|
| 785 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 786 | RootPath=fileparts(filebase); |
---|
| 787 | if exist(profil_perso,'file') |
---|
| 788 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 789 | else |
---|
[147] | 790 | txt=ver('MATLAB'); |
---|
| 791 | Release=txt.Release; |
---|
[137] | 792 | relnumb=str2double(Release(3:4)); |
---|
[2] | 793 | if relnumb >= 14 |
---|
[112] | 794 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 795 | else |
---|
| 796 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 797 | end |
---|
| 798 | end |
---|
| 799 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 800 | set(gcf,'Pointer','arrow') |
---|
| 801 | |
---|
[12] | 802 | %------------------------------------------------------------------------ |
---|
[2] | 803 | % --- Executes on button press in mode. |
---|
| 804 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 805 | %------------------------------------------------------------------------ |
---|
[2] | 806 | browse=get(handles.browse_root,'UserData'); |
---|
| 807 | compare_list=get(handles.compare,'String'); |
---|
| 808 | val=get(handles.compare,'Value'); |
---|
| 809 | compare=compare_list{val}; |
---|
| 810 | if strcmp(compare,'displacement') |
---|
| 811 | mode='displacement'; |
---|
| 812 | else |
---|
| 813 | mode_list=get(handles.mode,'String'); |
---|
| 814 | mode_value=get(handles.mode,'Value'); |
---|
| 815 | mode=mode_list{mode_value}; |
---|
| 816 | end |
---|
| 817 | displ_num=[];%default |
---|
[137] | 818 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 819 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[71] | 820 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 821 | siztime=size(time); |
---|
| 822 | nbfield=siztime(1); |
---|
| 823 | nbfield2=siztime(2); |
---|
| 824 | indchosen=1; %%first pair selected by default |
---|
| 825 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 826 | dt=1; |
---|
| 827 | displ=''; |
---|
| 828 | index=0; |
---|
| 829 | numlist_a=[]; |
---|
| 830 | numlist_B=[]; |
---|
| 831 | %get all the time intervals in bursts |
---|
| 832 | displ_dt=1;%default |
---|
| 833 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 834 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 835 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 836 | index=index+1; |
---|
| 837 | numlist_a(index)=numod_a; |
---|
| 838 | numlist_b(index)=numod_b; |
---|
| 839 | if ~isempty(time) |
---|
[54] | 840 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 841 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 842 | else |
---|
| 843 | displ_dt(index)=1; |
---|
| 844 | end |
---|
| 845 | end |
---|
| 846 | end |
---|
| 847 | [dtsort,indsort]=sort(displ_dt); |
---|
| 848 | if ~isempty(numlist_a) |
---|
| 849 | displ_num(1,:)=numlist_a(indsort); |
---|
| 850 | displ_num(2,:)=numlist_b(indsort); |
---|
| 851 | end |
---|
| 852 | displ_num(3,:)=0; |
---|
| 853 | displ_num(4,:)=0; |
---|
| 854 | set(handles.jtext,'Visible','Off') |
---|
[2] | 855 | set(handles.first_j,'Visible','Off') |
---|
| 856 | set(handles.last_j,'Visible','Off') |
---|
| 857 | set(handles.incr_j,'Visible','Off') |
---|
| 858 | set(handles.nb_field2,'Visible','Off') |
---|
| 859 | set(handles.ref_j,'Visible','Off') |
---|
| 860 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 861 | for index=1:min(nbfield2-1,200) |
---|
| 862 | displ_num(1,index)=-floor(index/2); |
---|
| 863 | displ_num(2,index)=ceil(index/2); |
---|
| 864 | displ_num(3,index)=0; |
---|
| 865 | displ_num(4,index)=0; |
---|
| 866 | end |
---|
| 867 | set(handles.jtext,'Visible','On') |
---|
| 868 | set(handles.first_j,'Visible','On') |
---|
| 869 | set(handles.last_j,'Visible','On') |
---|
| 870 | set(handles.incr_j,'Visible','On') |
---|
| 871 | set(handles.nb_field2,'Visible','On') |
---|
| 872 | set(handles.ref_j,'Visible','On') |
---|
| 873 | if nbfield > 1 |
---|
[2] | 874 | set(handles.itext,'Visible','On') |
---|
| 875 | set(handles.first_i,'Visible','On') |
---|
| 876 | set(handles.last_i,'Visible','On') |
---|
| 877 | set(handles.incr_i,'Visible','On') |
---|
| 878 | set(handles.nb_field,'Visible','On') |
---|
| 879 | set(handles.ref_i,'Visible','On') |
---|
| 880 | else |
---|
| 881 | set(handles.itext,'Visible','Off') |
---|
| 882 | set(handles.first_i,'Visible','Off') |
---|
| 883 | set(handles.last_i,'Visible','Off') |
---|
| 884 | set(handles.incr_i,'Visible','Off') |
---|
| 885 | set(handles.nb_field,'Visible','Off') |
---|
| 886 | set(handles.ref_i,'Visible','Off') |
---|
| 887 | end |
---|
[112] | 888 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 889 | for index=1:200%min(nbfield-1,200) |
---|
| 890 | displ_num(1,index)=0; |
---|
| 891 | displ_num(2,index)=0; |
---|
| 892 | displ_num(3,index)=-floor(index/2); |
---|
| 893 | displ_num(4,index)=ceil(index/2); |
---|
| 894 | end |
---|
| 895 | set(handles.itext,'Visible','On') |
---|
| 896 | set(handles.first_i,'Visible','On') |
---|
| 897 | set(handles.last_i,'Visible','On') |
---|
| 898 | set(handles.incr_i,'Visible','On') |
---|
| 899 | set(handles.nb_field,'Visible','On') |
---|
| 900 | set(handles.ref_i,'Visible','On') |
---|
| 901 | if nbfield2 > 1 |
---|
[2] | 902 | set(handles.jtext,'Visible','On') |
---|
| 903 | set(handles.first_j,'Visible','On') |
---|
| 904 | set(handles.last_j,'Visible','On') |
---|
| 905 | set(handles.incr_j,'Visible','On') |
---|
| 906 | set(handles.nb_field2,'Visible','On') |
---|
| 907 | set(handles.ref_j,'Visible','On') |
---|
[112] | 908 | else |
---|
[2] | 909 | set(handles.jtext,'Visible','Off') |
---|
| 910 | set(handles.first_j,'Visible','Off') |
---|
| 911 | set(handles.last_j,'Visible','Off') |
---|
| 912 | set(handles.incr_j,'Visible','Off') |
---|
| 913 | set(handles.nb_field2,'Visible','Off') |
---|
| 914 | set(handles.ref_j,'Visible','Off') |
---|
| 915 | end |
---|
| 916 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 917 | displ_num(1,1)=0; |
---|
| 918 | displ_num(2,1)=0; |
---|
| 919 | displ_num(3,1)=0; |
---|
| 920 | displ_num(4,1)=0; |
---|
| 921 | if nbfield > 1 |
---|
[2] | 922 | set(handles.itext,'Visible','On') |
---|
| 923 | set(handles.first_i,'Visible','On') |
---|
| 924 | set(handles.last_i,'Visible','On') |
---|
| 925 | set(handles.incr_i,'Visible','On') |
---|
| 926 | set(handles.nb_field,'Visible','On') |
---|
| 927 | set(handles.ref_i,'Visible','On') |
---|
| 928 | else |
---|
| 929 | set(handles.itext,'Visible','Off') |
---|
| 930 | set(handles.first_i,'Visible','Off') |
---|
| 931 | set(handles.last_i,'Visible','Off') |
---|
| 932 | set(handles.incr_i,'Visible','Off') |
---|
| 933 | set(handles.nb_field,'Visible','Off') |
---|
| 934 | set(handles.ref_i,'Visible','Off') |
---|
| 935 | end |
---|
| 936 | if nbfield2 > 1 |
---|
[112] | 937 | set(handles.jtext,'Visible','On') |
---|
| 938 | set(handles.first_j,'Visible','On') |
---|
| 939 | set(handles.last_j,'Visible','On') |
---|
| 940 | set(handles.incr_j,'Visible','On') |
---|
| 941 | set(handles.nb_field2,'Visible','On') |
---|
| 942 | set(handles.ref_j,'Visible','On') |
---|
[2] | 943 | else |
---|
| 944 | set(handles.jtext,'Visible','Off') |
---|
| 945 | set(handles.first_j,'Visible','Off') |
---|
| 946 | set(handles.last_j,'Visible','Off') |
---|
| 947 | set(handles.incr_j,'Visible','Off') |
---|
| 948 | set(handles.nb_field2,'Visible','Off') |
---|
| 949 | set(handles.ref_j,'Visible','Off') |
---|
| 950 | end |
---|
[112] | 951 | end |
---|
[2] | 952 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 953 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 954 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 955 | |
---|
[12] | 956 | %------------------------------------------------------------------------ |
---|
[2] | 957 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 958 | % the field series set by first_i, incr, last_i |
---|
| 959 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 960 | %------------------------------------------------------------------------ |
---|
[2] | 961 | set(gcf,'Pointer','watch') |
---|
| 962 | %nomenclature types |
---|
[71] | 963 | filebase=get(handles.RootName,'String'); |
---|
[2] | 964 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 965 | browse=get(handles.browse_root,'UserData'); |
---|
| 966 | compare_list=get(handles.compare,'String'); |
---|
| 967 | val=get(handles.compare,'Value'); |
---|
| 968 | compare=compare_list{val}; |
---|
| 969 | if strcmp(compare,'displacement') |
---|
| 970 | mode='displacement'; |
---|
| 971 | else |
---|
| 972 | mode_list=get(handles.mode,'String'); |
---|
| 973 | mode_value=get(handles.mode,'Value'); |
---|
| 974 | mode=mode_list{mode_value}; |
---|
| 975 | end |
---|
| 976 | |
---|
| 977 | % nomenclature type of the .nc files |
---|
| 978 | nom_type_ima=[];%default |
---|
| 979 | if isfield(browse,'nom_type_ima') |
---|
| 980 | nom_type_ima=browse.nom_type_ima; |
---|
| 981 | end |
---|
| 982 | |
---|
[112] | 983 | %determine nom_type_nc: |
---|
[2] | 984 | nom_type_nc=[];%default |
---|
| 985 | if isfield(browse,'nom_type_nc') |
---|
| 986 | nom_type_nc=browse.nom_type_nc; |
---|
| 987 | end |
---|
| 988 | if isempty(nom_type_nc) |
---|
[112] | 989 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 990 | end |
---|
| 991 | browse.nom_type_nc=nom_type_nc; |
---|
| 992 | set(handles.browse_root,'UserData',browse) |
---|
| 993 | |
---|
| 994 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 995 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 996 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 997 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 998 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 999 | % num1=first_i:incr:last_i; |
---|
| 1000 | % if isempty(num1) |
---|
| 1001 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1002 | % return |
---|
| 1003 | % end |
---|
| 1004 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1005 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1006 | ref_j=0; |
---|
| 1007 | else |
---|
[45] | 1008 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1009 | end |
---|
[71] | 1010 | time=get(handles.RootName,'UserData');%get the set of times |
---|
[2] | 1011 | if isempty(time) |
---|
| 1012 | time=[0 1]; |
---|
[112] | 1013 | end |
---|
[71] | 1014 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1015 | dt_unit=1000;%default |
---|
[2] | 1016 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1017 | |
---|
[112] | 1018 | %eliminate the first pairs inconsistent with the position |
---|
| 1019 | if isempty(displ_num) |
---|
| 1020 | nbpair=0; |
---|
| 1021 | else |
---|
[2] | 1022 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1023 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1024 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1025 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1026 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1027 | end |
---|
[112] | 1028 | end |
---|
[2] | 1029 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1030 | |
---|
[112] | 1031 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1032 | % be performed, while the result is needed for next steps. |
---|
| 1033 | displ_pair={''}; |
---|
| 1034 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1035 | testpair=0; |
---|
| 1036 | if get(handles.CIV1,'Value')==0 % |
---|
[112] | 1037 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1038 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1039 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1040 | return |
---|
[2] | 1041 | end |
---|
[112] | 1042 | for ipair=1:nbpair |
---|
[2] | 1043 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1044 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1045 | select(ipair)=exist(filename,'file')==2; |
---|
| 1046 | end |
---|
| 1047 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1048 | if isfield(browse,'incr_pair') |
---|
[2] | 1049 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1050 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1051 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1052 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1053 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1054 | select(1)=exist(filename,'file')==2; |
---|
| 1055 | testpair=1; |
---|
| 1056 | else |
---|
[112] | 1057 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1058 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1059 | else |
---|
| 1060 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1061 | end |
---|
[112] | 1062 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1063 | %COMPLETER CAS STEREO |
---|
[2] | 1064 | return |
---|
| 1065 | end |
---|
| 1066 | end |
---|
| 1067 | end |
---|
| 1068 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1069 | if testpair |
---|
[73] | 1070 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1071 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
| 1072 | % for ipair=1:nbpair |
---|
| 1073 | % if select(ipair) |
---|
| 1074 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1075 | % 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 |
---|
| 1076 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1077 | % end |
---|
| 1078 | % else |
---|
| 1079 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1080 | % end |
---|
| 1081 | % end |
---|
[2] | 1082 | else |
---|
[73] | 1083 | for ipair=1:nbpair |
---|
| 1084 | if select(ipair) |
---|
| 1085 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1086 | 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 |
---|
| 1087 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1088 | else |
---|
| 1089 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1090 | end |
---|
| 1091 | end |
---|
| 1092 | end |
---|
[2] | 1093 | end |
---|
| 1094 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1095 | if testpair |
---|
[112] | 1096 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1097 | else |
---|
[112] | 1098 | for ipair=1:nbpair |
---|
| 1099 | if select(ipair) |
---|
| 1100 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1101 | 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 |
---|
| 1102 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1103 | end |
---|
| 1104 | elseif testpair |
---|
| 1105 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1106 | else |
---|
| 1107 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1108 | end |
---|
| 1109 | end |
---|
| 1110 | end |
---|
[2] | 1111 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1112 | for ipair=1:nbpair |
---|
| 1113 | if select(ipair) |
---|
[112] | 1114 | 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 |
---|
| 1115 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1116 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1117 | else |
---|
| 1118 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1119 | end |
---|
| 1120 | end |
---|
[2] | 1121 | elseif isequal(mode,'displacement') |
---|
[112] | 1122 | displ_pair={'Di=Dj=0'}; |
---|
| 1123 | end |
---|
[2] | 1124 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1125 | ichoice=min(find(select)); |
---|
[45] | 1126 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1127 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
[112] | 1128 | if initial>nbpair |
---|
| 1129 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1130 | end |
---|
| 1131 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1132 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1133 | end |
---|
[45] | 1134 | |
---|
[2] | 1135 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1136 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1137 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1138 | if ichoice <= length(displ_pair') |
---|
| 1139 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1140 | else |
---|
| 1141 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1142 | end |
---|
| 1143 | end |
---|
| 1144 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1145 | set(gcf,'Pointer','arrow') |
---|
[12] | 1146 | |
---|
| 1147 | %------------------------------------------------------------------------ |
---|
[112] | 1148 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1149 | %middle of the series set by first_i, incr, last_i |
---|
[2] | 1150 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1151 | %------------------------------------------------------------------------ |
---|
[2] | 1152 | set(gcf,'Pointer','watch') |
---|
| 1153 | %nomenclature types |
---|
[71] | 1154 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1155 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1156 | browse=get(handles.browse_root,'UserData'); |
---|
| 1157 | compare_list=get(handles.compare,'String'); |
---|
| 1158 | val=get(handles.compare,'Value'); |
---|
| 1159 | compare=compare_list{val}; |
---|
| 1160 | if strcmp(compare,'displacement') |
---|
| 1161 | mode='displacement'; |
---|
| 1162 | else |
---|
| 1163 | mode_list=get(handles.mode,'String'); |
---|
| 1164 | mode_value=get(handles.mode,'Value'); |
---|
| 1165 | mode=mode_list{mode_value}; |
---|
| 1166 | end |
---|
| 1167 | |
---|
| 1168 | % nomenclature type of the .nc files |
---|
| 1169 | nom_type_ima='ima_num';%default |
---|
| 1170 | if isfield(browse,'nom_type_ima') |
---|
| 1171 | nom_type_ima=browse.nom_type_ima; |
---|
| 1172 | end |
---|
| 1173 | nom_type_nc='_i1-i2';%default |
---|
| 1174 | if isfield(browse,'nom_type_nc') |
---|
| 1175 | nom_type_nc=browse.nom_type_nc; |
---|
| 1176 | end |
---|
[94] | 1177 | 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] | 1178 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1179 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1180 | nom_type_nc='none'; |
---|
[94] | 1181 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1182 | nom_type_nc='_i1-i2'; |
---|
[2] | 1183 | else |
---|
| 1184 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1185 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1186 | else |
---|
| 1187 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1188 | end |
---|
[2] | 1189 | end |
---|
| 1190 | browse.nom_type_nc=nom_type_nc; |
---|
| 1191 | set(handles.browse_root,'UserData',browse) |
---|
| 1192 | |
---|
| 1193 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1194 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1195 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1196 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1197 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1198 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1199 | % num1=first_i:incr:last_i; |
---|
| 1200 | % if isempty(num1) |
---|
| 1201 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1202 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1203 | % return |
---|
| 1204 | % end |
---|
[137] | 1205 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
---|
[2] | 1206 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1207 | ref_j=0; |
---|
| 1208 | else |
---|
[137] | 1209 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
---|
[2] | 1210 | end |
---|
[71] | 1211 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 1212 | if isempty(time) |
---|
| 1213 | time=[0 1];%default |
---|
| 1214 | end |
---|
[71] | 1215 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1216 | %dt_unit=1000; |
---|
[2] | 1217 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1218 | |
---|
| 1219 | |
---|
[112] | 1220 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1221 | if isempty(displ_num) |
---|
| 1222 | nbpair=0; |
---|
| 1223 | else |
---|
| 1224 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1225 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1226 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1227 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1228 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1229 | end |
---|
| 1230 | end |
---|
| 1231 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1232 | |
---|
[112] | 1233 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1234 | % be performed, while the result is needed for next steps. |
---|
| 1235 | displ_pair={''}; %default |
---|
| 1236 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1237 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
[112] | 1238 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1239 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1240 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1241 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1242 | return |
---|
[2] | 1243 | end |
---|
[112] | 1244 | for ipair=1:nbpair |
---|
[2] | 1245 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1246 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1247 | select(ipair)=exist(filename,'file')==2; |
---|
| 1248 | end |
---|
| 1249 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1250 | if isfield(browse,'incr_pair') |
---|
[2] | 1251 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1252 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1253 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1254 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1255 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1256 | select(1)=exist(filename,'file')==2; |
---|
| 1257 | else |
---|
[112] | 1258 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1259 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1260 | else |
---|
| 1261 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1262 | end |
---|
[112] | 1263 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1264 | set(handles.list_pair_civ2,'String',{''}); |
---|
[2] | 1265 | return |
---|
| 1266 | end |
---|
| 1267 | end |
---|
| 1268 | end |
---|
[112] | 1269 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1270 | for ipair=1:nbpair |
---|
| 1271 | if select(ipair) |
---|
| 1272 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1273 | 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 |
---|
| 1274 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1275 | end |
---|
| 1276 | else |
---|
| 1277 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1278 | end |
---|
| 1279 | end |
---|
[2] | 1280 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1281 | for ipair=1:nbpair |
---|
| 1282 | if select(ipair) |
---|
| 1283 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1284 | 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 |
---|
| 1285 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1286 | end |
---|
| 1287 | else |
---|
| 1288 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1289 | end |
---|
| 1290 | end |
---|
[2] | 1291 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1292 | for ipair=1:nbpair |
---|
| 1293 | if select(ipair) |
---|
[112] | 1294 | 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 |
---|
| 1295 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1296 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1297 | else |
---|
| 1298 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1299 | end |
---|
| 1300 | end |
---|
[2] | 1301 | elseif isequal(mode,'displacement') |
---|
[112] | 1302 | displ_pair={'Di=Dj=0'}; |
---|
| 1303 | end |
---|
[2] | 1304 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1305 | ichoice=min(find(select)); |
---|
[137] | 1306 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1307 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
[2] | 1308 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1309 | end |
---|
| 1310 | if val>length(displ_pair') |
---|
| 1311 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1312 | else |
---|
| 1313 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1314 | end |
---|
| 1315 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1316 | set(gcf,'Pointer','arrow') |
---|
[2] | 1317 | |
---|
[12] | 1318 | %------------------------------------------------------------------------ |
---|
[112] | 1319 | % determine the list of index pairs of processing file |
---|
[2] | 1320 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1321 | find_pair_indices(handles,mode) |
---|
[12] | 1322 | %------------------------------------------------------------------------ |
---|
[112] | 1323 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1324 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
[45] | 1325 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
[137] | 1326 | num_i=first_i:incr:last_i;% list of i indices (reference values for each pair) |
---|
[2] | 1327 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
[45] | 1328 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
[112] | 1329 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
[45] | 1330 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
[2] | 1331 | else |
---|
| 1332 | first_j=1; |
---|
| 1333 | last_j=1; |
---|
| 1334 | incr_j=1; |
---|
| 1335 | end |
---|
[36] | 1336 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
[2] | 1337 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1338 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
[36] | 1339 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
[2] | 1340 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1341 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1342 | return |
---|
| 1343 | end |
---|
| 1344 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1345 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1346 | if index_civ2>length(list_civ2) |
---|
| 1347 | list_civ2=list_civ1; |
---|
| 1348 | index_civ2=index_civ1; |
---|
| 1349 | end |
---|
[36] | 1350 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 1351 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
[112] | 1352 | return,end; |
---|
[39] | 1353 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[112] | 1354 | return,end; |
---|
[39] | 1355 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[112] | 1356 | return,end; |
---|
[39] | 1357 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[112] | 1358 | return,end; |
---|
| 1359 | if isequal (mode,'series(Di)') |
---|
| 1360 | %recognize the pair civ1 from the display |
---|
| 1361 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
[2] | 1362 | str_raw=str_civ1(indsel); |
---|
| 1363 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
[137] | 1364 | d1=str2double(str_civ1(indsel(indsepar-1)+1:indsel(indsepar)-1)); |
---|
[2] | 1365 | if indsepar==length(str_raw) |
---|
[137] | 1366 | d2=str2double(str_civ1(indsel(indsepar)+1:end)); |
---|
[2] | 1367 | else |
---|
[137] | 1368 | d2=str2double(str_civ1(indsel(indsepar)+1:indsel(indsepar+1)-1)); |
---|
[112] | 1369 | end |
---|
[39] | 1370 | num1_civ1=num_i-d1;% set of first image numbers |
---|
| 1371 | num2_civ1=num_i+d2; |
---|
[2] | 1372 | num_a_civ1=num_j; |
---|
| 1373 | num_b_civ1=num_j; |
---|
| 1374 | |
---|
| 1375 | %recognize the pair civ2 from the display |
---|
| 1376 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1377 | str_raw=str_civ2(indsel); |
---|
| 1378 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
[137] | 1379 | d1=str2double(str_civ2(indsel(indsepar-1)+1:indsel(indsepar)-1)); |
---|
[2] | 1380 | if indsepar==length(str_raw) |
---|
[137] | 1381 | d2=str2double(str_civ2(indsel(indsepar)+1:end)); |
---|
[2] | 1382 | else |
---|
[137] | 1383 | d2=str2double(str_civ2(indsel(indsepar)+1:indsel(indsepar+1)-1)); |
---|
[112] | 1384 | end |
---|
[137] | 1385 | if isnan(d1) |
---|
[39] | 1386 | num1_civ2=num_i; |
---|
[2] | 1387 | else |
---|
[39] | 1388 | num1_civ2=num_i-d1;% set of first image numbers |
---|
[2] | 1389 | end |
---|
[137] | 1390 | if isnan(d2) |
---|
[39] | 1391 | num2_civ2=num_i; |
---|
[2] | 1392 | else |
---|
[39] | 1393 | num2_civ2=num_i+d2; |
---|
[2] | 1394 | end |
---|
| 1395 | num_a_civ2=num_j; |
---|
| 1396 | num_b_civ2=num_j; |
---|
| 1397 | |
---|
| 1398 | % adjust the first and last field number |
---|
[137] | 1399 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
[2] | 1400 | if isequal(lastfield,[]) |
---|
| 1401 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1402 | else |
---|
| 1403 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1404 | end |
---|
| 1405 | if length(indsel)>=1 |
---|
| 1406 | firstind=indsel(1); |
---|
| 1407 | lastind=indsel(end); |
---|
[39] | 1408 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
| 1409 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
| 1410 | num_i=num_i(indsel); |
---|
[2] | 1411 | num1_civ1=num1_civ1(indsel); |
---|
| 1412 | num1_civ2=num1_civ2(indsel); |
---|
| 1413 | num2_civ1=num2_civ1(indsel); |
---|
| 1414 | num2_civ2=num2_civ2(indsel); |
---|
| 1415 | end |
---|
[36] | 1416 | elseif isequal (mode,'series(Dj)') |
---|
[137] | 1417 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
[39] | 1418 | num1_civ1=num_i;% set of first image numbers |
---|
| 1419 | num2_civ1=num_i; |
---|
[2] | 1420 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1421 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
[39] | 1422 | num1_civ2=num_i; |
---|
| 1423 | num2_civ2=num_i; |
---|
[2] | 1424 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1425 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1426 | % adjust the first and last field number |
---|
[137] | 1427 | if isnan(lastfield_j) |
---|
[2] | 1428 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1429 | else |
---|
| 1430 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1431 | end |
---|
| 1432 | if length(indsel)>=1 |
---|
| 1433 | firstind=indsel(1); |
---|
| 1434 | lastind=indsel(end); |
---|
| 1435 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1436 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1437 | num_j=num_j(indsel); |
---|
| 1438 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1439 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1440 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1441 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1442 | end |
---|
[36] | 1443 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[39] | 1444 | num1_civ1=num_i; |
---|
| 1445 | num1_civ2=num_i; |
---|
[2] | 1446 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[39] | 1447 | num2_civ1=num_i; |
---|
[2] | 1448 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1449 | num_b_civ1=displ_num(2,index_civ1); |
---|
[39] | 1450 | num2_civ2=num_i; |
---|
[2] | 1451 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1452 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1453 | elseif isequal(mode,'displacement') |
---|
[39] | 1454 | num1_civ1=num_i; |
---|
| 1455 | num2_civ1=num_i; |
---|
[2] | 1456 | num_a_civ1=num_j; |
---|
| 1457 | num_b_civ1=num_j; |
---|
[39] | 1458 | num1_civ2=num_i; |
---|
| 1459 | num2_civ2=num_i; |
---|
[2] | 1460 | num_a_civ2=num_j; |
---|
| 1461 | num_b_civ2=num_j; |
---|
| 1462 | end |
---|
| 1463 | |
---|
[41] | 1464 | |
---|
[12] | 1465 | %------------------------------------------------------------------------ |
---|
[2] | 1466 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1467 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1468 | %------------------------------------------------------------------------ |
---|
[2] | 1469 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1470 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1471 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1472 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[137] | 1473 | % num_a=displ_num(1,index_pair); |
---|
| 1474 | % num_b=displ_num(2,index_pair); |
---|
[2] | 1475 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1476 | if index_pair<=length(list_pair2) |
---|
| 1477 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1478 | end |
---|
| 1479 | |
---|
[112] | 1480 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1481 | mode_list=get(handles.mode,'String'); |
---|
| 1482 | mode_value=get(handles.mode,'Value'); |
---|
| 1483 | mode=mode_list{mode_value}; |
---|
| 1484 | if isequal(mode,'series(Di)') |
---|
[137] | 1485 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1486 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1487 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1488 | num1=first_i:incr_i:last_i; |
---|
[137] | 1489 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1490 | if ~isnan(lastfield) |
---|
[2] | 1491 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
[112] | 1492 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
[2] | 1493 | num1=num1(ind); |
---|
| 1494 | end |
---|
| 1495 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1496 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1497 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1498 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1499 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1500 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1501 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1502 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1503 | if ~isnan(lastfield2) |
---|
[2] | 1504 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
[112] | 1505 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
[2] | 1506 | num1=num_j(ind); |
---|
| 1507 | end |
---|
| 1508 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1509 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1510 | end |
---|
[2] | 1511 | |
---|
[12] | 1512 | %------------------------------------------------------------------------ |
---|
[2] | 1513 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1514 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1515 | %------------------------------------------------------------------------ |
---|
[112] | 1516 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
[2] | 1517 | |
---|
[112] | 1518 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1519 | mode_list=get(handles.mode,'String'); |
---|
| 1520 | mode_value=get(handles.mode,'Value'); |
---|
| 1521 | mode=mode_list{mode_value}; |
---|
| 1522 | if isequal(mode,'series(Di)') |
---|
[137] | 1523 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1524 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1525 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1526 | num1=first_i:incr_i:last_i; |
---|
[137] | 1527 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1528 | if ~isnan(lastfield) |
---|
[2] | 1529 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
[112] | 1530 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
[2] | 1531 | num1=num1(ind); |
---|
| 1532 | end |
---|
| 1533 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1534 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1535 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1536 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1537 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1538 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1539 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1540 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1541 | if ~isnan(lastfield2) |
---|
[2] | 1542 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
[112] | 1543 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
[2] | 1544 | num1=num_j(ind); |
---|
| 1545 | end |
---|
| 1546 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1547 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1548 | end |
---|
[2] | 1549 | |
---|
[67] | 1550 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1551 | %------------------------------------------------------------------------ |
---|
| 1552 | % global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
[73] | 1553 | set(handles.RUN, 'Enable','Off') |
---|
| 1554 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1555 | batch=0; |
---|
| 1556 | launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1557 | set(handles.RUN, 'Enable','On') |
---|
| 1558 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1559 | |
---|
[12] | 1560 | %------------------------------------------------------------------------ |
---|
[2] | 1561 | % --- Executes on button press in BATCH: remote processing |
---|
| 1562 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[133] | 1563 | %% ----------------------------------------------------------------------- |
---|
[67] | 1564 | %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove |
---|
[73] | 1565 | set(handles.BATCH, 'Enable','Off') |
---|
| 1566 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1567 | batch=1; |
---|
| 1568 | launch_jobs(hObject, eventdata, handles, batch) |
---|
[73] | 1569 | set(handles.BATCH, 'Enable','On') |
---|
| 1570 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1571 | |
---|
| 1572 | %------------------------------------------------------------------------ |
---|
[133] | 1573 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[67] | 1574 | function launch_jobs(hObject, eventdata, handles, batch) |
---|
| 1575 | %----------------------------------------------------------------------- |
---|
[133] | 1576 | %% check the selected list of operations: |
---|
[2] | 1577 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1578 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1579 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1580 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1581 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1582 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1583 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1584 | index=find(box_test==1); |
---|
| 1585 | if isempty(index) |
---|
| 1586 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 1587 | return |
---|
| 1588 | end |
---|
| 1589 | index_first=min(index); |
---|
| 1590 | index_last=max(index); |
---|
| 1591 | box_used=box_test([index_first : index_last]); |
---|
| 1592 | [box_missing,ind_missing]=min(box_used); |
---|
| 1593 | if isequal(box_missing,0) |
---|
| 1594 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1595 | return |
---|
| 1596 | end |
---|
| 1597 | |
---|
| 1598 | %check mask if selecetd |
---|
| 1599 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1600 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1601 | if ~exist(maskname,'file') |
---|
| 1602 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1603 | end |
---|
[2] | 1604 | end |
---|
| 1605 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1606 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1607 | if ~exist(maskname,'file') |
---|
| 1608 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1609 | end |
---|
[2] | 1610 | end |
---|
| 1611 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1612 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1613 | if ~exist(maskname,'file') |
---|
[112] | 1614 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1615 | end |
---|
[2] | 1616 | end |
---|
| 1617 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1618 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1619 | if ~exist(maskname,'file') |
---|
[112] | 1620 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1621 | end |
---|
[2] | 1622 | end |
---|
| 1623 | |
---|
[137] | 1624 | %% initialize the waitbars: TO suppress, waitbar not used |
---|
[133] | 1625 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 1626 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 1627 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 1628 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 1629 | drawnow |
---|
| 1630 | |
---|
| 1631 | %% set the list of files and check them |
---|
| 1632 | display('checking the files...') |
---|
| 1633 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1634 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=... |
---|
| 1635 | set_civ_filenames(handles,compare,box_test); |
---|
[137] | 1636 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1637 | return |
---|
| 1638 | end |
---|
| 1639 | nbfield=numel(num1_civ1); |
---|
| 1640 | nbslice=numel(num_a_civ1); |
---|
| 1641 | |
---|
| 1642 | %% choice of batch priority |
---|
| 1643 | ind_answer=2; |
---|
| 1644 | if batch |
---|
| 1645 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1646 | if isequal(s,0) |
---|
| 1647 | w(end)=[]; |
---|
| 1648 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 1649 | str={'urgent';'normal';'low'}; |
---|
| 1650 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1651 | 'SelectionMode','single',... |
---|
| 1652 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 1653 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 1654 | return % a better way should be create |
---|
| 1655 | end |
---|
| 1656 | else |
---|
| 1657 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 1658 | return |
---|
| 1659 | end |
---|
| 1660 | else |
---|
| 1661 | if isunix |
---|
| 1662 | [xx,w]=unix('ps faux |grep civ|wc -l'); |
---|
| 1663 | w(end)=[]; |
---|
| 1664 | if str2double(w)+numel(num1_civ1)> 50 |
---|
| 1665 | msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) |
---|
| 1666 | return |
---|
| 1667 | end |
---|
| 1668 | end |
---|
| 1669 | end |
---|
| 1670 | |
---|
| 1671 | |
---|
| 1672 | %% read names of the .exe files for PIV and patch |
---|
| 1673 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
[112] | 1674 | xmlfile='PARAM.xml'; |
---|
[133] | 1675 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1676 | t=xmltree(xmlfile); |
---|
[67] | 1677 | s=convert(t); |
---|
[2] | 1678 | end |
---|
[127] | 1679 | test_interp=0; |
---|
| 1680 | if batch |
---|
[67] | 1681 | if isfield(s,'BatchParam') |
---|
| 1682 | sparam=s.BatchParam; |
---|
| 1683 | if ~ismember(sparam.BatchMode,{'sge'}) |
---|
| 1684 | msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT']) |
---|
| 1685 | end |
---|
| 1686 | else |
---|
| 1687 | msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml') |
---|
| 1688 | return |
---|
| 1689 | end |
---|
| 1690 | else |
---|
| 1691 | if isfield(s,'RunParam') |
---|
| 1692 | sparam=s.RunParam; |
---|
| 1693 | else |
---|
| 1694 | msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml') |
---|
| 1695 | return |
---|
| 1696 | end |
---|
[112] | 1697 | if isfield(sparam,'CivBin') |
---|
| 1698 | if ~exist(sparam.CivBin,'file') |
---|
| 1699 | sparam.CivBin=fullfile(path_UVMAT,sparam.CivBin); |
---|
| 1700 | end |
---|
[94] | 1701 | end |
---|
[112] | 1702 | if isfield(sparam,'Civ1Bin') |
---|
| 1703 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 1704 | sparam.Civ1Bin=fullfile(path_UVMAT,sparam.Civ1Bin); |
---|
| 1705 | end |
---|
[94] | 1706 | end |
---|
[112] | 1707 | if isfield(sparam,'Civ2Bin') |
---|
| 1708 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 1709 | sparam.Civ2Bin=fullfile(path_UVMAT,sparam.Civ2Bin); |
---|
| 1710 | end |
---|
[94] | 1711 | end |
---|
[112] | 1712 | %test_interp=get(handles.test_interp,'Value'); |
---|
[116] | 1713 | |
---|
[112] | 1714 | if isfield(sparam,'PatchBin') |
---|
| 1715 | if ~exist(sparam.PatchBin,'file') |
---|
| 1716 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
| 1717 | end |
---|
[94] | 1718 | end |
---|
[112] | 1719 | % if test_interp && isfield(sparam,'PatchNewBin') |
---|
| 1720 | % if ~exist(sparam.PatchNewBin,'file') |
---|
| 1721 | % sparam.PatchNewBin=fullfile(path_UVMAT,sparam.PatchNewBin); |
---|
| 1722 | % end |
---|
| 1723 | % end |
---|
| 1724 | if isfield(sparam,'FixBin') |
---|
| 1725 | if ~exist(sparam.FixBin,'file') |
---|
| 1726 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
| 1727 | end |
---|
[94] | 1728 | end |
---|
[73] | 1729 | end |
---|
[67] | 1730 | if batch |
---|
| 1731 | if isfield(sparam,'BatchMode') |
---|
| 1732 | batch_mode=sparam.BatchMode; |
---|
[2] | 1733 | end |
---|
[67] | 1734 | else |
---|
[133] | 1735 | % MaxCivProcesses=50; |
---|
| 1736 | % if isfield(sparam,'MaxCivProcesses') |
---|
| 1737 | % MaxCivProcesses=str2double(sparam.MaxCivProcesses); |
---|
| 1738 | % end |
---|
[2] | 1739 | end |
---|
| 1740 | |
---|
| 1741 | |
---|
[133] | 1742 | %% get civ1 parameters: |
---|
[112] | 1743 | display('files OK, processing...') |
---|
| 1744 | %get civ parameters |
---|
[2] | 1745 | if box_test(1)==1 |
---|
| 1746 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
[112] | 1747 | end |
---|
[2] | 1748 | |
---|
[133] | 1749 | %% get fix1 parameters |
---|
[112] | 1750 | if box_test(2)==1 |
---|
[2] | 1751 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1752 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 1753 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
[127] | 1754 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1755 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1756 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1757 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 1758 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[112] | 1759 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 1760 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 1761 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 1762 | % fileref=fullfile(refpath,fileref); |
---|
[2] | 1763 | menu=get(handles.field_ref1,'String'); |
---|
| 1764 | index=get(handles.field_ref1,'Value'); |
---|
| 1765 | if isempty(menu) |
---|
| 1766 | fieldchoice=''; |
---|
| 1767 | else |
---|
| 1768 | fieldchoice=menu{index}; |
---|
[112] | 1769 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 1770 | end |
---|
[2] | 1771 | end |
---|
[112] | 1772 | |
---|
[133] | 1773 | %% get patch1 parameters |
---|
[67] | 1774 | if box_test(3)==1 |
---|
[127] | 1775 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
| 1776 | if isnan(rho_patch1) |
---|
[112] | 1777 | rho_patch1='1000'; |
---|
| 1778 | set(handles.rho_patch1,'String','1') |
---|
| 1779 | else |
---|
| 1780 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1781 | end |
---|
| 1782 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1783 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
[127] | 1784 | if isnan(str2double(nx_patch1)) |
---|
[112] | 1785 | nx_patch1='50' ;%default |
---|
| 1786 | set(handles.nx_patch1,'String','50'); |
---|
| 1787 | end |
---|
[127] | 1788 | if isnan(str2double(ny_patch1)) |
---|
[112] | 1789 | ny_patch1='50' ;%default |
---|
| 1790 | set(handles.ny_patch1,'String','50'); |
---|
| 1791 | end |
---|
| 1792 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1793 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1794 | end |
---|
| 1795 | |
---|
[133] | 1796 | %% get civ2 parameters: |
---|
[2] | 1797 | if box_test(4)==1 |
---|
| 1798 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 1799 | end |
---|
| 1800 | |
---|
[133] | 1801 | %% get fix2 parameters |
---|
[112] | 1802 | if box_test(5)==1 |
---|
[2] | 1803 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1804 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1805 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1806 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1807 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1808 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1809 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1810 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1811 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1812 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1813 | |
---|
[2] | 1814 | %%%%%%%%%%%%%%%%%%% |
---|
| 1815 | end |
---|
| 1816 | |
---|
[133] | 1817 | %% get patch2 parameters |
---|
[2] | 1818 | if box_test(6)==1 |
---|
[127] | 1819 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
| 1820 | if isnan(rho_patch2) |
---|
[2] | 1821 | rho_patch2='1000'; |
---|
| 1822 | set(handles.rho_patch2,'String','1') |
---|
| 1823 | else |
---|
| 1824 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1825 | end |
---|
| 1826 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1827 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
[127] | 1828 | if isnan(str2double(nx_patch2)) |
---|
[2] | 1829 | nx_patch2='50' ;%default |
---|
| 1830 | set(handles.nx_patch2,'String','50'); |
---|
| 1831 | end |
---|
[127] | 1832 | if isnan(str2double(ny_patch2)) |
---|
[2] | 1833 | ny_patch2='50' ;%default |
---|
| 1834 | set(handles.ny_patch2,'String','50'); |
---|
| 1835 | end |
---|
| 1836 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1837 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
[112] | 1838 | % test_interp=get(handles.test_interp,'Value'); |
---|
[2] | 1839 | end |
---|
| 1840 | |
---|
[133] | 1841 | %% MAIN LOOP |
---|
[71] | 1842 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 1843 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
[134] | 1844 | super_cmd=[]; |
---|
| 1845 | |
---|
[2] | 1846 | for ifile=1:nbfield |
---|
| 1847 | for j=1:nbslice |
---|
[112] | 1848 | i_cmd=0; |
---|
[2] | 1849 | cmd=''; |
---|
[73] | 1850 | if isunix % check: necessaire aussi en RUN? |
---|
[112] | 1851 | %fid=fopen([filename '.cmx'],'w') |
---|
| 1852 | cmd='#!/bin/bash \n'; |
---|
| 1853 | cmd=[cmd '#$ -cwd \n']; |
---|
| 1854 | cmd=[cmd 'hostname && date \n']; |
---|
[117] | 1855 | cmd=[cmd 'umask 002 \n']; |
---|
[2] | 1856 | end |
---|
| 1857 | if civAll |
---|
| 1858 | civAllxml=xmltree;% xml contents, all parameters |
---|
[73] | 1859 | civAllCmd=''; |
---|
[2] | 1860 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 1861 | end |
---|
[73] | 1862 | filename_cmx=filecell.nc.civ1{ifile,j};%output netcdf file |
---|
[127] | 1863 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
[2] | 1864 | |
---|
[112] | 1865 | %CIV1 |
---|
[2] | 1866 | if box_test(1)==1 |
---|
[41] | 1867 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[112] | 1868 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 1869 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 1870 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
[112] | 1871 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
[2] | 1872 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
[112] | 1873 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[2] | 1874 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
[112] | 1875 | if test_mask==0 |
---|
[2] | 1876 | par_civ1.maskname='noFile use default'; |
---|
| 1877 | par_civ1.maskflag='n'; |
---|
| 1878 | else |
---|
| 1879 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1880 | if exist(maskdispl,'file') |
---|
| 1881 | par_civ1.maskname=maskdispl; |
---|
[112] | 1882 | par_civ1.maskflag='y'; |
---|
[2] | 1883 | else |
---|
[136] | 1884 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1885 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1886 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1887 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1888 | if exist(par_civ1.maskname,'file') |
---|
[82] | 1889 | par_civ1.maskflag='y'; |
---|
[12] | 1890 | else |
---|
| 1891 | par_civ1.maskname='noFile use default'; |
---|
[112] | 1892 | par_civ1.maskflag='n'; |
---|
[12] | 1893 | end |
---|
[2] | 1894 | end |
---|
| 1895 | end |
---|
| 1896 | |
---|
| 1897 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 1898 | if test_grid |
---|
| 1899 | par_civ1.gridflag='y'; |
---|
| 1900 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1901 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1902 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1903 | if ~isnan(nbslice_grid) |
---|
[2] | 1904 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1905 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1906 | if ~exist(par_civ1.gridname,'file') |
---|
[112] | 1907 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1908 | end |
---|
| 1909 | elseif exist(gridname,'file') |
---|
[112] | 1910 | par_civ1.gridname=gridname; |
---|
[2] | 1911 | else |
---|
| 1912 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1913 | end |
---|
| 1914 | end |
---|
| 1915 | else |
---|
[112] | 1916 | par_civ1.gridname='noFile use default'; |
---|
| 1917 | par_civ1.gridflag='n'; |
---|
[2] | 1918 | end |
---|
[112] | 1919 | % |
---|
[2] | 1920 | i_cmd=i_cmd+1; |
---|
| 1921 | if isequal(civAll,0) |
---|
[94] | 1922 | cmd=[cmd CIV1_CMD(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam) '\n']; |
---|
[2] | 1923 | else |
---|
[112] | 1924 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
| 1925 | str=CIV1_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
| 1926 | fieldnames=fields(str); |
---|
[2] | 1927 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 1928 | for ilist=1:length(fieldnames) |
---|
[112] | 1929 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1930 | if ischar(val) |
---|
| 1931 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1932 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 1933 | end |
---|
| 1934 | end |
---|
[2] | 1935 | end |
---|
| 1936 | end |
---|
| 1937 | |
---|
[112] | 1938 | % FIX1 |
---|
| 1939 | if box_test(2)==1 |
---|
| 1940 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1941 | if test_mask==0 |
---|
[2] | 1942 | maskname=''; |
---|
[112] | 1943 | else |
---|
[2] | 1944 | maskdispl=get(handles.mask_fix1,'String'); |
---|
[137] | 1945 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1946 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[136] | 1947 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
[2] | 1948 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 1949 | end |
---|
| 1950 | if isequal(civAll,0) |
---|
[94] | 1951 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
[112] | 1952 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1953 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[94] | 1954 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 1955 | cmd=[cmd cmd_FIX '\n']; |
---|
[112] | 1956 | else |
---|
[2] | 1957 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1958 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 1959 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 1960 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 1961 | fix1.threshC=num2str(thresh_vecC1); |
---|
[112] | 1962 | fix1.threshV=num2str(thresh_vel1); |
---|
[2] | 1963 | fieldnames=fields(fix1); |
---|
| 1964 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 1965 | for ilist=1:length(fieldnames) |
---|
[112] | 1966 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1967 | if ischar(val) |
---|
| 1968 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1969 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 1970 | end |
---|
| 1971 | end |
---|
| 1972 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 1973 | end |
---|
| 1974 | end |
---|
| 1975 | |
---|
| 1976 | %PATCH1 |
---|
| 1977 | if box_test(3)==1 |
---|
| 1978 | if isequal(civAll,0) |
---|
| 1979 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 1980 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
| 1981 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1982 | else |
---|
| 1983 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1984 | patch1.nopt=subdomain_patch1; |
---|
| 1985 | patch1.maxdiff=thresh_patch1; |
---|
| 1986 | patch1.ro=rho_patch1; |
---|
| 1987 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1988 | if test_grid |
---|
| 1989 | patch1.gridflag='y'; |
---|
| 1990 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1991 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1992 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1993 | if ~isnan(nbslice_grid) |
---|
[112] | 1994 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1995 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[112] | 1996 | if ~exist(patch1.gridPatch,'file') |
---|
| 1997 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1998 | end |
---|
| 1999 | elseif exist(gridname,'file') |
---|
| 2000 | patch1.gridPatch=gridname; |
---|
| 2001 | else |
---|
| 2002 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
[2] | 2003 | end |
---|
| 2004 | end |
---|
[112] | 2005 | else |
---|
| 2006 | patch1.gridPatch='none'; |
---|
| 2007 | patch1.gridflag='n'; |
---|
| 2008 | patch1.m=nx_patch1; |
---|
| 2009 | patch1.n=ny_patch1; |
---|
[2] | 2010 | end |
---|
[112] | 2011 | patch1.convectFlow='n'; |
---|
| 2012 | fieldnames=fields(patch1); |
---|
[2] | 2013 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2014 | for ilist=1:length(fieldnames) |
---|
[112] | 2015 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2016 | if ischar(val) |
---|
| 2017 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2018 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2019 | end |
---|
| 2020 | end |
---|
| 2021 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2022 | end |
---|
[2] | 2023 | end |
---|
[112] | 2024 | |
---|
[127] | 2025 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
[112] | 2026 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
[127] | 2027 | filename_cmx([end-1:end+1])=[ 'cmx'];%name of cmx file |
---|
| 2028 | % filename_cmx=[filename_cmx 'x']; |
---|
[112] | 2029 | end |
---|
| 2030 | |
---|
| 2031 | if box_test(4)==1 |
---|
[2] | 2032 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2033 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2034 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2035 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2036 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2037 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
[112] | 2038 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
[2] | 2039 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
[112] | 2040 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
[2] | 2041 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2042 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2043 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 2044 | if test_mask==0 |
---|
[2] | 2045 | par_civ2.maskname='noFile use default'; |
---|
| 2046 | par_civ2.maskflag='n'; |
---|
| 2047 | else |
---|
| 2048 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2049 | if exist(maskdispl,'file') |
---|
| 2050 | par_civ2.maskname=maskdispl; |
---|
| 2051 | par_civ2.maskflag='y'; |
---|
[2] | 2052 | else |
---|
[136] | 2053 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2054 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 2055 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2056 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2057 | if exist(par_civ2.maskname,'file') |
---|
[112] | 2058 | par_civ2.maskflag='y'; |
---|
[12] | 2059 | else |
---|
| 2060 | par_civ2.maskname='noFile use default'; |
---|
[112] | 2061 | par_civ2.maskflag='n'; |
---|
[12] | 2062 | end |
---|
[2] | 2063 | end |
---|
| 2064 | end |
---|
| 2065 | %TESTgrid |
---|
[137] | 2066 | %test_grid=get(handles.browse_gridciv2,'Value'); |
---|
[2] | 2067 | gridname=get(handles.grid_civ2,'String'); |
---|
[137] | 2068 | %gridflag='y'; |
---|
[2] | 2069 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 2070 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2071 | if ~isnan(nbslice_grid) |
---|
[2] | 2072 | par_civ2.gridflag='y'; |
---|
| 2073 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 2074 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 2075 | if exist(par_civ2.gridname,'file') |
---|
[112] | 2076 | par_civ2.gridflag='y'; |
---|
[2] | 2077 | else |
---|
| 2078 | par_civ2.gridname='noFile use default'; |
---|
[112] | 2079 | par_civ2.gridflag='n'; |
---|
[2] | 2080 | end |
---|
| 2081 | elseif exist(gridname,'file') |
---|
[112] | 2082 | par_civ2.gridflag='y'; |
---|
[2] | 2083 | else |
---|
| 2084 | par_civ2.gridname='noFile use default'; |
---|
[112] | 2085 | par_civ2.gridflag='n'; |
---|
[2] | 2086 | end |
---|
| 2087 | end |
---|
| 2088 | %endTESTgrid |
---|
| 2089 | i_cmd=i_cmd+1; |
---|
[134] | 2090 | cmd_CIV2=CIV2_CMD(filename_cmx(1:end-4),namelog,par_civ2,sparam); |
---|
[2] | 2091 | if isequal(civAll,0) |
---|
| 2092 | if(isunix) |
---|
[90] | 2093 | cmd=[cmd 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2 '\n']; |
---|
[2] | 2094 | else |
---|
[94] | 2095 | filename_cmx=regexprep(filename_cmx,'\\','\\\\'); |
---|
[90] | 2096 | cmd=[cmd 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2 '\n']; |
---|
[2] | 2097 | end |
---|
| 2098 | else |
---|
[112] | 2099 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
| 2100 | str=CIV2_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
| 2101 | fieldnames=fields(str); |
---|
[2] | 2102 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2103 | for ilist=1:length(fieldnames) |
---|
| 2104 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2105 | if ischar(val) |
---|
[112] | 2106 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2107 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
[2] | 2108 | end |
---|
[112] | 2109 | end |
---|
[2] | 2110 | end |
---|
[112] | 2111 | end |
---|
| 2112 | |
---|
| 2113 | % FIX2 |
---|
| 2114 | if box_test(5)==1 |
---|
| 2115 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2116 | if test_mask==0 |
---|
| 2117 | maskname=''; %no mask used |
---|
[2] | 2118 | else |
---|
| 2119 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2120 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2121 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2122 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2123 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2124 | end |
---|
| 2125 | if isequal(civAll,0) |
---|
[94] | 2126 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[112] | 2127 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2128 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
| 2129 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 2130 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2131 | else |
---|
[2] | 2132 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2133 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2134 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2135 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2136 | fix2.threshC=num2str(thresh_vec2C); |
---|
[112] | 2137 | fix2.threshV=num2str(thresh_vel2); |
---|
[2] | 2138 | fieldnames=fields(fix2); |
---|
| 2139 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2140 | for ilist=1:length(fieldnames) |
---|
[112] | 2141 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2142 | if ischar(val) |
---|
| 2143 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2144 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2145 | end |
---|
| 2146 | end |
---|
| 2147 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2148 | end |
---|
| 2149 | end |
---|
| 2150 | |
---|
| 2151 | %PATCH2 |
---|
| 2152 | if box_test(6)==1 |
---|
[12] | 2153 | if isequal(civAll,0) |
---|
[94] | 2154 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
| 2155 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[90] | 2156 | cmd=[cmd cmd_PATCH '\n']; |
---|
[12] | 2157 | else |
---|
| 2158 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2159 | patch2.nopt=subdomain_patch1; |
---|
| 2160 | patch2.maxdiff=thresh_patch1; |
---|
| 2161 | patch2.ro=rho_patch1; |
---|
| 2162 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2163 | if test_grid |
---|
| 2164 | patch2.gridflag='y'; |
---|
| 2165 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2166 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 2167 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2168 | if ~isnan(nbslice_grid) |
---|
[12] | 2169 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 2170 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[12] | 2171 | if ~exist(patch2.gridPatch,'file') |
---|
[112] | 2172 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2173 | end |
---|
| 2174 | elseif exist(gridname,'file') |
---|
[112] | 2175 | patch2.gridPatch=gridname; |
---|
[12] | 2176 | else |
---|
| 2177 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2178 | end |
---|
| 2179 | end |
---|
[12] | 2180 | else |
---|
[112] | 2181 | patch2.gridPatch='none'; |
---|
| 2182 | patch2.gridflag='n'; |
---|
| 2183 | patch2.m=nx_patch2; |
---|
| 2184 | patch2.n=ny_patch2; |
---|
[2] | 2185 | end |
---|
[12] | 2186 | patch2.convectFlow='n'; |
---|
| 2187 | fieldnames=fields(patch2); |
---|
| 2188 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2189 | for ilist=1:length(fieldnames) |
---|
[112] | 2190 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2191 | if ischar(val) |
---|
| 2192 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2193 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2194 | end |
---|
| 2195 | end |
---|
[12] | 2196 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
[112] | 2197 | end |
---|
[12] | 2198 | end |
---|
| 2199 | if isequal(civAll,1) |
---|
| 2200 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
[73] | 2201 | %cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
[90] | 2202 | cmd=[cmd CivBin ' -f ' filename_cmx(1:end-4) '.xml ' civAllCmd '\n']; |
---|
[12] | 2203 | end |
---|
[112] | 2204 | % create the .bat file: |
---|
[67] | 2205 | if batch |
---|
[112] | 2206 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2207 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
[136] | 2208 | else |
---|
[12] | 2209 | filename_bat=filename_cmx; |
---|
| 2210 | end |
---|
| 2211 | filename_bat(end-2:end)='bat'; |
---|
| 2212 | fid=fopen(filename_bat,'w'); |
---|
[39] | 2213 | fprintf(fid,cmd); |
---|
| 2214 | fclose(fid); |
---|
[12] | 2215 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
[67] | 2216 | if batch |
---|
| 2217 | switch batch_mode |
---|
| 2218 | case 'sge' |
---|
| 2219 | pvalue=num2str((1-ind_answer)*500); |
---|
[133] | 2220 | %namelog=[filename_bat '.patch.log']; |
---|
[73] | 2221 | display(['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
[67] | 2222 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2223 | end |
---|
[12] | 2224 | else |
---|
[112] | 2225 | %% to lauch the jobs locally : |
---|
[12] | 2226 | if(isunix) |
---|
[135] | 2227 | cmd_str=['. ' filename_bat]; |
---|
| 2228 | % cmd_str=['!at -qb now -f ' filename_bat ' &']; %ou at -qb now -f bad idea... |
---|
[133] | 2229 | else %case of Windows |
---|
[135] | 2230 | cmd_str=['@call ' regexprep(filename_bat,'\\','\\\\')]; |
---|
[2] | 2231 | end |
---|
[135] | 2232 | super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2233 | % eval(cmd_str); |
---|
| 2234 | disp(cmd_str); |
---|
[12] | 2235 | end |
---|
[112] | 2236 | end |
---|
[2] | 2237 | end |
---|
[134] | 2238 | |
---|
[137] | 2239 | if ~batch |
---|
[134] | 2240 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
[135] | 2241 | filename_superbat=fullfile(Rootbat,['job_list.bat']); |
---|
[134] | 2242 | fid=fopen(filename_superbat,'w'); |
---|
| 2243 | fprintf(fid,super_cmd'); |
---|
| 2244 | fclose(fid); |
---|
[135] | 2245 | if(isunix) |
---|
| 2246 | eval(['!. ' filename_superbat ' &']); |
---|
| 2247 | else |
---|
| 2248 | eval(['!' filename_superbat ' &']); |
---|
| 2249 | end |
---|
[133] | 2250 | end |
---|
[2] | 2251 | |
---|
[137] | 2252 | %% save interface state |
---|
[2] | 2253 | if isfield(filecell,'nc') |
---|
| 2254 | if isfield(filecell.nc,'civ2') |
---|
| 2255 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2256 | else |
---|
| 2257 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2258 | end |
---|
| 2259 | end |
---|
| 2260 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2261 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2262 | detect=1; |
---|
[2] | 2263 | while detect==1 |
---|
| 2264 | namefigfull=[namedoc '.fig']; |
---|
| 2265 | hh=dir(namefigfull); |
---|
| 2266 | if ~isempty(hh) |
---|
| 2267 | detect=1; |
---|
| 2268 | namedoc=[namedoc '.0']; |
---|
| 2269 | else |
---|
| 2270 | detect=0; |
---|
| 2271 | end |
---|
| 2272 | end |
---|
| 2273 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2274 | |
---|
[134] | 2275 | |
---|
| 2276 | |
---|
[2] | 2277 | 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]=... |
---|
| 2278 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2279 | %------------------------------------------------------------------------ |
---|
[85] | 2280 | filecell=[];%default |
---|
[136] | 2281 | |
---|
| 2282 | %% get the root names nomenclature and numbers |
---|
[71] | 2283 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2284 | |
---|
| 2285 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2286 | msgbox_uvmat('ERROR','no input files') |
---|
| 2287 | return |
---|
| 2288 | end |
---|
| 2289 | |
---|
[137] | 2290 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2291 | filecell.filebase=filebase; |
---|
| 2292 | |
---|
[2] | 2293 | browse=get(handles.browse_root,'UserData'); |
---|
| 2294 | compare_list=get(handles.compare,'String'); |
---|
| 2295 | val=get(handles.compare,'Value'); |
---|
| 2296 | compare=compare_list{val}; |
---|
| 2297 | if strcmp(compare,'displacement') |
---|
| 2298 | mode='displacement'; |
---|
| 2299 | else |
---|
| 2300 | mode_list=get(handles.mode,'String'); |
---|
| 2301 | mode_value=get(handles.mode,'Value'); |
---|
| 2302 | mode=mode_list{mode_value}; |
---|
| 2303 | end |
---|
[137] | 2304 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2305 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2306 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2307 | if isfield(browse,'nom_type_ima') |
---|
| 2308 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2309 | end |
---|
| 2310 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2311 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2312 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2313 | find_pair_indices(handles,mode); |
---|
| 2314 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2315 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2316 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2317 | % test_disp=1; |
---|
[2] | 2318 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2319 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2320 | Path1=Path2; |
---|
[71] | 2321 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2322 | filebase_A=fullfile(Path1,Name1); |
---|
| 2323 | if length(Name1)>6 |
---|
| 2324 | Name1=Name1(end-5:end); |
---|
| 2325 | end |
---|
| 2326 | if length(Name2)>6 |
---|
| 2327 | Name2=Name2(end-5:end); |
---|
| 2328 | end |
---|
| 2329 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2330 | else |
---|
[127] | 2331 | % test_disp=0; |
---|
[2] | 2332 | filebase_A=filebase; |
---|
| 2333 | nom_type_ima1=nom_type_ima2; |
---|
| 2334 | filebase_AB=filebase; |
---|
| 2335 | end |
---|
| 2336 | if strcmp(compare,'displacement') |
---|
[112] | 2337 | filebase_ima1=filebase_A; |
---|
| 2338 | filebase_ima2=filebase_B; |
---|
| 2339 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2340 | else |
---|
[112] | 2341 | filebase_ima1=filebase_B; |
---|
| 2342 | filebase_ima2=filebase_B; |
---|
| 2343 | filebase_nc=filebase_B; |
---|
| 2344 | end |
---|
[2] | 2345 | |
---|
| 2346 | %determine reference files for fix: |
---|
| 2347 | file_ref_fix1={};%default |
---|
| 2348 | file_ref_fix2={}; |
---|
| 2349 | nbfield=length(num1_civ1); |
---|
| 2350 | nbslice=length(num_a_civ1); |
---|
| 2351 | if box_test(2)==1% fix1 performed |
---|
| 2352 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2353 | if ~isempty(ref) |
---|
[137] | 2354 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2355 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2356 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2357 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2358 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2359 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2360 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2361 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2362 | if isequal(mode,'displacement') |
---|
| 2363 | num_i1=num_i_ref; |
---|
| 2364 | num_i2=num_i_ref; |
---|
| 2365 | num_j1=num_j_ref; |
---|
| 2366 | num_j2=num_j_ref; |
---|
| 2367 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2368 | num_i1=num_i_ref; |
---|
| 2369 | num_i2=num_i1; |
---|
| 2370 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2371 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2372 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2373 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2374 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2375 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2376 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2377 | if isempty(ref.num_a) |
---|
| 2378 | ref.num_a=1; |
---|
| 2379 | end |
---|
| 2380 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2381 | num_j2=num_j1; |
---|
| 2382 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2383 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2384 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2385 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2386 | num_i2=num_i1; |
---|
| 2387 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2388 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2389 | end |
---|
| 2390 | for ifile=1:nbfield |
---|
| 2391 | for j=1:nbslice |
---|
| 2392 | 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);% |
---|
| 2393 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2394 | if ~exist(file_ref,'file') |
---|
| 2395 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2396 | filecell=[]; |
---|
[2] | 2397 | return |
---|
| 2398 | end |
---|
| 2399 | end |
---|
| 2400 | end |
---|
| 2401 | end |
---|
| 2402 | end |
---|
| 2403 | |
---|
| 2404 | %determine reference files for fix2: |
---|
| 2405 | if box_test(5)==1% fix2 performed |
---|
| 2406 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2407 | if ~isempty(ref) |
---|
[127] | 2408 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2409 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2410 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2411 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2412 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2413 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 2414 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2415 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2416 | if isequal(mode,'displacement') |
---|
| 2417 | num_i1=num_i_ref; |
---|
| 2418 | num_i2=num_i_ref; |
---|
| 2419 | num_j1=num_j_ref; |
---|
| 2420 | num_j2=num_j_ref; |
---|
| 2421 | elseif isequal(mode,'pair j1-j2') |
---|
| 2422 | num_i1=num_i_ref; |
---|
| 2423 | num_i2=num_i1; |
---|
| 2424 | num_j1=ref.num_a; |
---|
| 2425 | num_j2=ref.num_b; |
---|
| 2426 | elseif isequal(mode,'series(Di)') |
---|
| 2427 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2428 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2429 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2430 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2431 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2432 | num_j2=num_j1; |
---|
| 2433 | elseif isequal(mode,'series(Dj)') |
---|
| 2434 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2435 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2436 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2437 | num_i2=num_i1; |
---|
| 2438 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2439 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2440 | end |
---|
| 2441 | for ifile=1:nbfield |
---|
| 2442 | for j=1:nbslice |
---|
| 2443 | 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);% |
---|
| 2444 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2445 | if ~exist(file_ref,'file') |
---|
| 2446 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2447 | filecell={}; |
---|
[2] | 2448 | return |
---|
| 2449 | end |
---|
| 2450 | end |
---|
| 2451 | end |
---|
| 2452 | end |
---|
| 2453 | end |
---|
| 2454 | |
---|
| 2455 | %check dir |
---|
| 2456 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2457 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2458 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2459 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[135] | 2460 | currentdir=pwd;%store the current working directory |
---|
[2] | 2461 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2462 | if ~exist(Path_ima,'dir') |
---|
[12] | 2463 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2464 | filecell={}; |
---|
[2] | 2465 | return |
---|
| 2466 | end |
---|
[127] | 2467 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2468 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2469 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2470 | filecell={}; |
---|
[112] | 2471 | cd(currentdir); |
---|
| 2472 | return |
---|
[2] | 2473 | end |
---|
| 2474 | |
---|
| 2475 | %check the existence of the netcdf and image files involved |
---|
| 2476 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2477 | if box_test(1)==1; |
---|
[112] | 2478 | detect=1; |
---|
[127] | 2479 | vers=0; |
---|
| 2480 | subdir_civ1_new=subdir_civ1; |
---|
[137] | 2481 | ind_test=0; |
---|
| 2482 | while detect==1 && ind_test<10%create a new subdir if the netcdf files already exist |
---|
[122] | 2483 | for ifile=1:nbfield |
---|
[112] | 2484 | for j=1:nbslice |
---|
[122] | 2485 | 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_new); |
---|
[112] | 2486 | detect=exist(filename,'file')==2; |
---|
| 2487 | if detect% if a netcdf file already exists |
---|
[137] | 2488 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2489 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2490 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2491 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2492 | else |
---|
| 2493 | vers=vers+1; |
---|
[137] | 2494 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2495 | end |
---|
[137] | 2496 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2497 | break |
---|
| 2498 | end |
---|
| 2499 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2500 | end |
---|
| 2501 | if detect% if a netcdf file already exists |
---|
| 2502 | break |
---|
| 2503 | end |
---|
| 2504 | end |
---|
[134] | 2505 | |
---|
[112] | 2506 | %create the new subdir_civ1 |
---|
[127] | 2507 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[134] | 2508 | cd(Path_ima); |
---|
[128] | 2509 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2510 | |
---|
[128] | 2511 | if ~strcmp(msg1,'') |
---|
| 2512 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2513 | filecell={}; |
---|
| 2514 | return |
---|
[134] | 2515 | else |
---|
[128] | 2516 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2517 | if ~strcmp(msg2,'') |
---|
[134] | 2518 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[128] | 2519 | filecell={}; |
---|
| 2520 | return |
---|
| 2521 | end |
---|
[112] | 2522 | end |
---|
[134] | 2523 | cd(currentdir); |
---|
[112] | 2524 | end |
---|
| 2525 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2526 | for ifile=1:nbfield |
---|
| 2527 | for j=1:nbslice |
---|
[122] | 2528 | 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_new);% |
---|
[112] | 2529 | detect=exist(filename,'file')==2; |
---|
[2] | 2530 | if detect% if a netcdf file already exists |
---|
[137] | 2531 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2532 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2533 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2534 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2535 | else |
---|
| 2536 | vers=vers+1; |
---|
[137] | 2537 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2538 | end |
---|
| 2539 | subdir_civ2=subdir_civ1; |
---|
| 2540 | break |
---|
[2] | 2541 | end |
---|
[112] | 2542 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2543 | end |
---|
| 2544 | if detect% if a netcdf file already exists |
---|
| 2545 | break |
---|
| 2546 | end |
---|
| 2547 | end |
---|
| 2548 | %create the new subdir_civ1 |
---|
[134] | 2549 | if exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2550 | cd(Path_ima); |
---|
[128] | 2551 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2552 | cd(currentdir); |
---|
[128] | 2553 | if ~strcmpl(msg1,'') |
---|
| 2554 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[122] | 2555 | cd(currentdir) |
---|
| 2556 | filecell={}; |
---|
| 2557 | return |
---|
[128] | 2558 | else |
---|
| 2559 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2560 | if ~strcmp(msg2,'') |
---|
| 2561 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
| 2562 | cd(currentdir) |
---|
| 2563 | filecell={}; |
---|
| 2564 | return |
---|
| 2565 | end |
---|
[112] | 2566 | end |
---|
| 2567 | end |
---|
| 2568 | end |
---|
| 2569 | end |
---|
[127] | 2570 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2571 | % get image names |
---|
| 2572 | for ifile=1:nbfield |
---|
[112] | 2573 | for j=1:nbslice |
---|
[2] | 2574 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2575 | idetect(j)=exist(filename,'file')==2; |
---|
| 2576 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2577 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2578 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2579 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2580 | end |
---|
| 2581 | [idetectmin,indexj]=min(idetect); |
---|
| 2582 | if idetectmin==0, |
---|
| 2583 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2584 | filecell={}; |
---|
| 2585 | cd(currentdir) |
---|
[112] | 2586 | return |
---|
| 2587 | end |
---|
| 2588 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2589 | if idetectmin==0, |
---|
| 2590 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2591 | filecell={}; |
---|
[112] | 2592 | cd(currentdir) |
---|
| 2593 | return |
---|
| 2594 | end |
---|
| 2595 | end |
---|
| 2596 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2597 | for ifile=1:nbfield |
---|
| 2598 | for j=1:nbslice |
---|
| 2599 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2600 | idetect(j)=exist(filename,'file')==2; |
---|
| 2601 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2602 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2603 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2604 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2605 | end |
---|
[2] | 2606 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2607 | if idetectmin==0, |
---|
| 2608 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2609 | filecell={}; |
---|
[112] | 2610 | cd(currentdir) |
---|
[2] | 2611 | return |
---|
[112] | 2612 | end |
---|
[2] | 2613 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2614 | if idetectmin==0, |
---|
| 2615 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2616 | filecell={}; |
---|
[2] | 2617 | cd(currentdir) |
---|
| 2618 | return |
---|
[112] | 2619 | end |
---|
| 2620 | end |
---|
[2] | 2621 | end |
---|
[112] | 2622 | |
---|
| 2623 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2624 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2625 | for ifile=1:nbfield |
---|
| 2626 | for j=1:nbslice |
---|
| 2627 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2628 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2629 | detect=exist(filename,'file')==2; |
---|
[122] | 2630 | if detect==0 |
---|
| 2631 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2632 | filecell={}; |
---|
| 2633 | cd(currentdir) |
---|
| 2634 | return |
---|
| 2635 | end |
---|
[2] | 2636 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2637 | end |
---|
| 2638 | end |
---|
| 2639 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2640 | for ifile=1:nbfield |
---|
| 2641 | for j=1:nbslice |
---|
| 2642 | 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);% |
---|
| 2643 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2644 | if ~exist(filename,'file') |
---|
| 2645 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2646 | set(handles.RUN, 'Enable','On') |
---|
| 2647 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2648 | filecell={}; |
---|
[112] | 2649 | cd(currentdir) |
---|
| 2650 | return |
---|
[2] | 2651 | end |
---|
| 2652 | end |
---|
[112] | 2653 | end |
---|
[2] | 2654 | end |
---|
| 2655 | end |
---|
| 2656 | |
---|
| 2657 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2658 | testdiff=0; |
---|
| 2659 | if (box_test(4)==1)&&... |
---|
[127] | 2660 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2661 | testdiff=1; |
---|
[112] | 2662 | detect=1; |
---|
[127] | 2663 | vers=0; |
---|
| 2664 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2665 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2666 | for ifile=1:nbfield |
---|
| 2667 | for j=1:nbslice |
---|
[127] | 2668 | 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_new);% |
---|
[112] | 2669 | detect=exist(filename,'file')==2; |
---|
| 2670 | if detect% if a netcdf file already exists |
---|
[127] | 2671 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2672 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2673 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2674 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2675 | else |
---|
| 2676 | vers=vers+1; |
---|
| 2677 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2678 | end |
---|
[112] | 2679 | break |
---|
| 2680 | end |
---|
| 2681 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2682 | end |
---|
| 2683 | if detect% if a netcdf file already exists |
---|
| 2684 | break |
---|
| 2685 | end |
---|
| 2686 | end |
---|
[128] | 2687 | %create the new subdir_civ2_new |
---|
| 2688 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2689 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
| 2690 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2691 | if ~isequal(m2,'') |
---|
[128] | 2692 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
---|
[122] | 2693 | filecell={}; |
---|
| 2694 | cd(currentdir) |
---|
| 2695 | return |
---|
[112] | 2696 | end |
---|
| 2697 | end |
---|
| 2698 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2699 | for ifile=1:nbfield |
---|
| 2700 | for j=1:nbslice |
---|
| 2701 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2702 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2703 | detect=exist(filename,'file')==2; |
---|
[2] | 2704 | if detect% if a netcdf file already exists |
---|
[127] | 2705 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2706 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2707 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2708 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2709 | else |
---|
| 2710 | vers=vers+1; |
---|
| 2711 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2712 | end |
---|
[112] | 2713 | break |
---|
[2] | 2714 | end |
---|
[112] | 2715 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2716 | end |
---|
| 2717 | if detect% if a netcdf file already exists |
---|
| 2718 | break |
---|
| 2719 | end |
---|
| 2720 | end |
---|
[122] | 2721 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2722 | %create the new subdir_civ1 |
---|
[127] | 2723 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2724 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[128] | 2725 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2726 | if ~isequal(m2,'') |
---|
[128] | 2727 | msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation |
---|
[122] | 2728 | cd(currentdir) |
---|
| 2729 | filecell={}; |
---|
| 2730 | return |
---|
[112] | 2731 | end |
---|
| 2732 | end |
---|
| 2733 | end |
---|
| 2734 | end |
---|
[127] | 2735 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2736 | end |
---|
| 2737 | cd(currentdir);%come back to the current working directory |
---|
| 2738 | |
---|
| 2739 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2740 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2741 | %check source netcdf file of civ1 estimates |
---|
| 2742 | if box_test(1)==0; %no civ1 performed |
---|
| 2743 | for ifile=1:nbfield |
---|
| 2744 | for j=1:nbslice |
---|
| 2745 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2746 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2747 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2748 | if ~exist(filename,'file') |
---|
| 2749 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2750 | filecell={}; |
---|
[2] | 2751 | return |
---|
| 2752 | end |
---|
| 2753 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2754 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 2755 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 2756 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2757 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2758 | filecell=[]; |
---|
[2] | 2759 | return |
---|
[112] | 2760 | end |
---|
[2] | 2761 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 2762 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 2763 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 2764 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2765 | filecell=[]; |
---|
[2] | 2766 | return |
---|
| 2767 | end |
---|
[112] | 2768 | end |
---|
[2] | 2769 | end |
---|
| 2770 | end |
---|
| 2771 | end |
---|
| 2772 | if strcmp(compare,'stereo PIV') |
---|
| 2773 | for ifile=1:nbfield |
---|
| 2774 | for j=1:nbslice |
---|
| 2775 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2776 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2777 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2778 | if ~exist(filename,'file') |
---|
| 2779 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2780 | set(handles.RUN, 'Enable','On') |
---|
| 2781 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2782 | return |
---|
| 2783 | end |
---|
| 2784 | end |
---|
| 2785 | end |
---|
| 2786 | end |
---|
| 2787 | end |
---|
[112] | 2788 | |
---|
| 2789 | detect=1; |
---|
| 2790 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2791 | for ifile=1:nbfield |
---|
| 2792 | for j=1:nbslice |
---|
| 2793 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2794 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2795 | detect=exist(filename,'file')==2; |
---|
| 2796 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2797 | end |
---|
[112] | 2798 | end |
---|
[2] | 2799 | %get first image names for civ2 |
---|
| 2800 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2801 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2802 | elseif box_test(4)==1 |
---|
| 2803 | for ifile=1:nbfield |
---|
| 2804 | for j=1:nbslice |
---|
| 2805 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2806 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2807 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2808 | end |
---|
[112] | 2809 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2810 | if idetectmin==0, |
---|
[112] | 2811 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2812 | filecell=[]; |
---|
| 2813 | return |
---|
[2] | 2814 | end |
---|
| 2815 | end |
---|
| 2816 | end |
---|
| 2817 | |
---|
| 2818 | %get second image names for civ2 |
---|
| 2819 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2820 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2821 | elseif box_test(4)==1 |
---|
| 2822 | for ifile=1:nbfield |
---|
| 2823 | for j=1:nbslice |
---|
| 2824 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2825 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2826 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2827 | end |
---|
[112] | 2828 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2829 | if idetectmin==0, |
---|
[112] | 2830 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2831 | filecell=[]; |
---|
| 2832 | return |
---|
[2] | 2833 | end |
---|
| 2834 | end |
---|
| 2835 | end |
---|
| 2836 | end |
---|
| 2837 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2838 | if ~testdiff |
---|
| 2839 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2840 | else % check the civ2 files |
---|
[2] | 2841 | for ifile=1:nbfield |
---|
| 2842 | for j=1:nbslice |
---|
| 2843 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2844 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2845 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2846 | if ~exist(filename,'file') |
---|
| 2847 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2848 | filecell=[]; |
---|
[2] | 2849 | return |
---|
| 2850 | else |
---|
| 2851 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
[112] | 2852 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2853 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2854 | filecell=[]; |
---|
[2] | 2855 | return |
---|
| 2856 | end |
---|
| 2857 | end |
---|
| 2858 | end |
---|
| 2859 | end |
---|
| 2860 | end |
---|
| 2861 | end |
---|
| 2862 | |
---|
| 2863 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2864 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2865 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2866 | for ifile=1:nbfield |
---|
| 2867 | for j=1:nbslice |
---|
| 2868 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2869 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2870 | filecell.st(ifile,j)={filename}; |
---|
| 2871 | end |
---|
| 2872 | end |
---|
| 2873 | end |
---|
[127] | 2874 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
[2] | 2875 | for ifile=1:nbfield |
---|
| 2876 | for j=1:nbslice |
---|
| 2877 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2878 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2879 | filecell.st(ifile,j)={filename}; |
---|
| 2880 | end |
---|
| 2881 | end |
---|
[112] | 2882 | end |
---|
[2] | 2883 | end |
---|
| 2884 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 2885 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 2886 | browse.nom_type_nc=nom_type_nc; |
---|
| 2887 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 2888 | |
---|
| 2889 | |
---|
| 2890 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2891 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2892 | nom_type_imanew1='_i'; |
---|
[2] | 2893 | else |
---|
| 2894 | nom_type_imanew1=nom_type_ima1; |
---|
| 2895 | end |
---|
[45] | 2896 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2897 | nom_type_imanew2='_i'; |
---|
[2] | 2898 | else |
---|
| 2899 | nom_type_imanew2=nom_type_ima2; |
---|
| 2900 | end |
---|
| 2901 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2902 | %%type of image file |
---|
| 2903 | type_ima1='none';%default |
---|
| 2904 | movieobject1=[];%default |
---|
[133] | 2905 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2906 | hhh=which('mmreader'); |
---|
| 2907 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2908 | type_ima1='movie'; |
---|
| 2909 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2910 | else |
---|
| 2911 | type_ima1='avi'; |
---|
| 2912 | end |
---|
[133] | 2913 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2914 | form=imformats(ext_ima(2:end)); |
---|
| 2915 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2916 | if isequal(nom_type_ima1,'*'); |
---|
| 2917 | type_ima1='multimage';%image series in a single image file |
---|
| 2918 | else |
---|
| 2919 | type_ima1='image'; |
---|
| 2920 | end |
---|
| 2921 | end |
---|
[45] | 2922 | end |
---|
| 2923 | type_ima2='none';%default |
---|
| 2924 | movieobject2=[]; |
---|
[133] | 2925 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2926 | hhh=which('mmreader'); |
---|
| 2927 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2928 | type_ima2='movie'; |
---|
| 2929 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2930 | else |
---|
| 2931 | type_ima2='avi'; |
---|
| 2932 | end |
---|
[133] | 2933 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2934 | form=imformats(ext_ima(2:end)); |
---|
| 2935 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2936 | if isequal(nom_type_ima1,'*'); |
---|
| 2937 | type_ima2='multimage';%image series in a single image file |
---|
| 2938 | else |
---|
| 2939 | type_ima2='image'; |
---|
| 2940 | end |
---|
| 2941 | end |
---|
[45] | 2942 | end |
---|
[71] | 2943 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2944 | % % if numel(npxy)<2 |
---|
| 2945 | % |
---|
| 2946 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2947 | % A=imread(filename); |
---|
| 2948 | % npxy=size(A); |
---|
| 2949 | % % end |
---|
| 2950 | % npy=npxy(1); |
---|
| 2951 | % npx=npxy(2); |
---|
[2] | 2952 | if box_test(1)==1 %if civ1 is performed |
---|
[112] | 2953 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 2954 | for ifile=1:nbfield |
---|
[2] | 2955 | waitbar(ifile/nbfield); |
---|
| 2956 | for j=1:nbslice |
---|
[112] | 2957 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2958 | if ~exist(filename,'file') |
---|
| 2959 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2960 | imwrite(A,filename,'BitDepth',16); |
---|
| 2961 | end |
---|
| 2962 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2963 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2964 | if ~exist(filename,'file') |
---|
| 2965 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2966 | imwrite(A,filename,'BitDepth',16); |
---|
| 2967 | end |
---|
| 2968 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 2969 | end |
---|
| 2970 | end |
---|
| 2971 | close(h) |
---|
| 2972 | end |
---|
| 2973 | if box_test(4)==1 %if civ2 is performed |
---|
[112] | 2974 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
[2] | 2975 | for ifile=1:nbfield |
---|
| 2976 | waitbar(ifile/nbfield); |
---|
| 2977 | for j=1:nbslice |
---|
[112] | 2978 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 2979 | if ~exist(filename,'file') |
---|
| 2980 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 2981 | imwrite(A,filename,'BitDepth',16); |
---|
| 2982 | end |
---|
| 2983 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2984 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 2985 | if ~exist(filename,'file') |
---|
| 2986 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 2987 | imwrite(A,filename,'BitDepth',16); |
---|
| 2988 | end |
---|
| 2989 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 2990 | end |
---|
| 2991 | end |
---|
| 2992 | close(h); |
---|
| 2993 | end |
---|
| 2994 | end |
---|
| 2995 | |
---|
[12] | 2996 | %------------------------------------------------------------------------ |
---|
| 2997 | % --- PATCH |
---|
[94] | 2998 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 2999 | %------------------------------------------------------------------------ |
---|
[112] | 3000 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3001 | if test_interp==0 |
---|
| 3002 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3003 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3004 | else %nouveau programme patch |
---|
| 3005 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3006 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3007 | end |
---|
[12] | 3008 | |
---|
| 3009 | %------------------------------------------------------------------------ |
---|
| 3010 | % --- STEREO Interp |
---|
[67] | 3011 | 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] | 3012 | %------------------------------------------------------------------------ |
---|
[2] | 3013 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
[67] | 3014 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3015 | ' -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 |
---|
| 3016 | |
---|
[12] | 3017 | %------------------------------------------------------------------------ |
---|
[2] | 3018 | % --- Executes on button press in CIV1. |
---|
| 3019 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3020 | %------------------------------------------------------------------------ |
---|
[2] | 3021 | val=get(handles.CIV1,'Value'); |
---|
| 3022 | if isequal(val,1) |
---|
| 3023 | enable_civ1(handles,'on') |
---|
| 3024 | enable_pair1(handles,'on') |
---|
| 3025 | else |
---|
| 3026 | enable_civ1(handles,'off') |
---|
| 3027 | end |
---|
| 3028 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3029 | |
---|
[12] | 3030 | %------------------------------------------------------------------------ |
---|
[2] | 3031 | % --- Executes on button press in FIX1. |
---|
| 3032 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3033 | %------------------------------------------------------------------------ |
---|
[2] | 3034 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3035 | |
---|
[12] | 3036 | %------------------------------------------------------------------------ |
---|
[2] | 3037 | % --- Executes on button press in PATCH1. |
---|
| 3038 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3039 | %------------------------------------------------------------------------ |
---|
[2] | 3040 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3041 | enable_patch1(handles) |
---|
[2] | 3042 | else |
---|
[12] | 3043 | desable_patch1(handles) |
---|
[2] | 3044 | end |
---|
| 3045 | |
---|
[12] | 3046 | %------------------------------------------------------------------------ |
---|
[2] | 3047 | % --- Executes on button press in CIV2. |
---|
| 3048 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3049 | %------------------------------------------------------------------------ |
---|
[2] | 3050 | state=get(handles.CIV2,'Value'); |
---|
| 3051 | enable_civ2(handles,state) |
---|
| 3052 | if state |
---|
| 3053 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3054 | enable_pair1(handles,'on') |
---|
| 3055 | end |
---|
| 3056 | |
---|
[12] | 3057 | %------------------------------------------------------------------------ |
---|
[2] | 3058 | % --- Executes on button press in FIX2. |
---|
| 3059 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3060 | %------------------------------------------------------------------------ |
---|
[2] | 3061 | if get(handles.FIX2,'Value')==1 |
---|
| 3062 | enable_fix2(handles) |
---|
| 3063 | if get(handles.CIV2,'Value')==0 |
---|
| 3064 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3065 | end |
---|
| 3066 | else |
---|
| 3067 | desable_fix2(handles) |
---|
| 3068 | end |
---|
| 3069 | |
---|
[12] | 3070 | %------------------------------------------------------------------------ |
---|
[2] | 3071 | % --- Executes on button press in PATCH2. |
---|
| 3072 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3073 | %------------------------------------------------------------------------ |
---|
[2] | 3074 | if get(handles.PATCH2,'Value')==1 |
---|
| 3075 | enable_patch2(handles) |
---|
| 3076 | if get(handles.CIV2,'Value')==0 |
---|
| 3077 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3078 | end |
---|
| 3079 | else |
---|
| 3080 | desable_patch2(handles) |
---|
| 3081 | end |
---|
| 3082 | |
---|
[12] | 3083 | %------------------------------------------------------------------------ |
---|
| 3084 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3085 | %------------------------------------------------------------------------ |
---|
| 3086 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3087 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3088 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3089 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3090 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3091 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3092 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3093 | |
---|
[12] | 3094 | %------------------------------------------------------------------------ |
---|
| 3095 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3096 | %------------------------------------------------------------------------ |
---|
| 3097 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3098 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3099 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3100 | |
---|
[12] | 3101 | %------------------------------------------------------------------------ |
---|
[2] | 3102 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3103 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3104 | %------------------------------------------------------------------------ |
---|
[2] | 3105 | %determine pair numbers |
---|
| 3106 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3107 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3108 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3109 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3110 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3111 | pxcmx=pxcm_xy(1); |
---|
| 3112 | pxcmy=pxcm_xy(2); |
---|
| 3113 | mode_list=get(handles.mode,'String'); |
---|
| 3114 | mode_value=get(handles.mode,'Value'); |
---|
| 3115 | mode=mode_list{mode_value}; |
---|
| 3116 | if isequal (mode, 'series(Di)' ) |
---|
[137] | 3117 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3118 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3119 | num2=ref_i+ceil(index/2); |
---|
| 3120 | num_a=1; |
---|
| 3121 | num_b=1; |
---|
[112] | 3122 | elseif isequal (mode, 'series(Dj)') |
---|
[2] | 3123 | num1=1; |
---|
| 3124 | num2=1; |
---|
[137] | 3125 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 3126 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3127 | num_b=ref_j+ceil(index/2); |
---|
| 3128 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[137] | 3129 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3130 | num1=ref_i; |
---|
| 3131 | num2=ref_i; |
---|
| 3132 | num_a=displ_num(1,index); |
---|
| 3133 | num_b=displ_num(2,index); |
---|
| 3134 | end |
---|
| 3135 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[137] | 3136 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3137 | iby=str2double(get(handles.iby,'String')); |
---|
| 3138 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
| 3139 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
| 3140 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
| 3141 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
[2] | 3142 | shiftx=round((umin+umax)/2); |
---|
| 3143 | shifty=round((vmin+vmax)/2); |
---|
| 3144 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3145 | isx=2*ceil(isx/2)+1; |
---|
| 3146 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3147 | isy=2*ceil(isy/2)+1; |
---|
| 3148 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3149 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3150 | set(handles.isx,'String',num2str(isx)); |
---|
| 3151 | set(handles.isy,'String',num2str(isy)); |
---|
| 3152 | |
---|
[12] | 3153 | %------------------------------------------------------------------------ |
---|
| 3154 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3155 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3156 | %------------------------------------------------------------------------ |
---|
[2] | 3157 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3158 | set(handles.subdir_civ2,'String',subdir); |
---|
[112] | 3159 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3160 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3161 | end |
---|
| 3162 | |
---|
[12] | 3163 | %------------------------------------------------------------------------ |
---|
| 3164 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3165 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3166 | %------------------------------------------------------------------------ |
---|
[2] | 3167 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3168 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3169 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3170 | end |
---|
| 3171 | |
---|
[12] | 3172 | %------------------------------------------------------------------------ |
---|
[133] | 3173 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3174 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3175 | %------------------------------------------------------------------------ |
---|
[2] | 3176 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3177 | if isequal(maskval,0) |
---|
| 3178 | set(handles.mask_civ1,'String','') |
---|
| 3179 | else |
---|
| 3180 | mask_displ='no mask'; %default |
---|
[71] | 3181 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3182 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3183 | if isequal(flag_mask,1) |
---|
[112] | 3184 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3185 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3186 | common_path=fileparts(filebase); |
---|
| 3187 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3188 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3189 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3190 | mask_displ='no mask'; |
---|
| 3191 | end |
---|
[2] | 3192 | end |
---|
| 3193 | if isequal(mask_displ,'no mask') |
---|
[12] | 3194 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3195 | {'*.png', ' (*.png)'; |
---|
| 3196 | '*.png', '.png files '; ... |
---|
| 3197 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3198 | 'Pick a mask file *.png',filebase); |
---|
| 3199 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3200 | if ~exist(mask_displ,'file') |
---|
| 3201 | mask_displ='no mask'; |
---|
| 3202 | end |
---|
| 3203 | end |
---|
| 3204 | if isequal(mask_displ,'no mask') |
---|
[2] | 3205 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3206 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3207 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3208 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3209 | else |
---|
| 3210 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3211 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3212 | end |
---|
| 3213 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3214 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3215 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3216 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3217 | end |
---|
[133] | 3218 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3219 | |
---|
[12] | 3220 | %------------------------------------------------------------------------ |
---|
[2] | 3221 | % --- Executes on button press in get_mask_fix1. |
---|
| 3222 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3223 | %------------------------------------------------------------------------ |
---|
[2] | 3224 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3225 | if isequal(maskval,0) |
---|
| 3226 | set(handles.mask_fix1,'String','') |
---|
| 3227 | else |
---|
[112] | 3228 | mask_displ='no mask'; %default |
---|
| 3229 | filebase=get(handles.RootName,'String'); |
---|
| 3230 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3231 | if isequal(flag_mask,1) |
---|
| 3232 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3233 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3234 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3235 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3236 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 3237 | mask_displ='no mask'; |
---|
| 3238 | end |
---|
[112] | 3239 | end |
---|
| 3240 | if isequal(mask_displ,'no mask') |
---|
| 3241 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3242 | {'*.png', ' (*.png)'; |
---|
[12] | 3243 | '*.png', '.png files '; ... |
---|
| 3244 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3245 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3246 | mask_displ=fullfile(PathName,FileName); |
---|
| 3247 | if ~exist(mask_displ,'file') |
---|
| 3248 | mask_displ='no mask'; |
---|
| 3249 | end |
---|
[12] | 3250 | end |
---|
[112] | 3251 | if isequal(mask_displ,'no mask') |
---|
| 3252 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3253 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3254 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3255 | else |
---|
| 3256 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3257 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3258 | end |
---|
| 3259 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3260 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3261 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3262 | end |
---|
| 3263 | |
---|
| 3264 | %------------------------------------------------------------------------ |
---|
[133] | 3265 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3266 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3267 | %------------------------------------------------------------------------ |
---|
[2] | 3268 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3269 | if isequal(maskval,0) |
---|
| 3270 | set(handles.mask_civ2,'String','') |
---|
| 3271 | else |
---|
[112] | 3272 | mask_displ='no mask'; %default |
---|
| 3273 | filebase=get(handles.RootName,'String'); |
---|
| 3274 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3275 | if isequal(flag_mask,1) |
---|
| 3276 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3277 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3278 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3279 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3280 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 3281 | mask_displ='no mask'; |
---|
| 3282 | end |
---|
[112] | 3283 | end |
---|
| 3284 | if isequal(mask_displ,'no mask') |
---|
| 3285 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3286 | {'*.png', ' (*.png)'; |
---|
[12] | 3287 | '*.png', '.png files '; ... |
---|
| 3288 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3289 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3290 | mask_displ=fullfile(PathName,FileName); |
---|
| 3291 | if ~exist(mask_displ,'file') |
---|
| 3292 | mask_displ='no mask'; |
---|
| 3293 | end |
---|
[12] | 3294 | end |
---|
[112] | 3295 | if isequal(mask_displ,'no mask') |
---|
| 3296 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3297 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3298 | else |
---|
| 3299 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3300 | end |
---|
| 3301 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3302 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3303 | end |
---|
| 3304 | |
---|
| 3305 | %------------------------------------------------------------------------ |
---|
[2] | 3306 | % --- Executes on button press in get_mask_fix2. |
---|
| 3307 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3308 | %------------------------------------------------------------------------ |
---|
[2] | 3309 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3310 | if isequal(maskval,0) |
---|
| 3311 | set(handles.mask_fix2,'String','') |
---|
| 3312 | else |
---|
[12] | 3313 | mask_displ='no mask'; %default |
---|
[71] | 3314 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3315 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3316 | if isequal(flag_mask,1) |
---|
[112] | 3317 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3318 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3319 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3320 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3321 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 3322 | mask_displ='no mask'; |
---|
| 3323 | end |
---|
[12] | 3324 | end |
---|
| 3325 | if isequal(mask_displ,'no mask') |
---|
| 3326 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3327 | {'*.png', ' (*.png)'; |
---|
| 3328 | '*.png', '.png files '; ... |
---|
| 3329 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3330 | 'Pick a mask file *.png',filebase); |
---|
| 3331 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3332 | if ~exist(mask_displ,'file') |
---|
[2] | 3333 | mask_displ='no mask'; |
---|
| 3334 | end |
---|
[12] | 3335 | end |
---|
| 3336 | if isequal(mask_displ,'no mask') |
---|
| 3337 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3338 | end |
---|
[12] | 3339 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3340 | end |
---|
| 3341 | |
---|
[12] | 3342 | %------------------------------------------------------------------------ |
---|
| 3343 | % --- function called to look for mask files |
---|
[2] | 3344 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3345 | %------------------------------------------------------------------------ |
---|
[112] | 3346 | %detect mask files, images with appropriate file base |
---|
[2] | 3347 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3348 | %flag_mask=1 indicates detection |
---|
| 3349 | |
---|
| 3350 | flag_mask=0;%default |
---|
| 3351 | nbslice=1; |
---|
| 3352 | |
---|
| 3353 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3354 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3355 | if ~isdir(Path) |
---|
| 3356 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3357 | return |
---|
| 3358 | end |
---|
[2] | 3359 | currentdir=pwd; |
---|
| 3360 | cd(Path);%move in the dir of the root name filebase |
---|
| 3361 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 3362 | cd(currentdir);%come back to the current working directory |
---|
[12] | 3363 | if ~isempty(maskfiles) |
---|
[112] | 3364 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3365 | % else |
---|
[2] | 3366 | flag_mask=1; |
---|
| 3367 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3368 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3369 | Namedouble=double(Name); |
---|
| 3370 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3371 | ind_mask=findstr('mask',Name); |
---|
| 3372 | i=ind_mask-1; |
---|
[137] | 3373 | while val(i)==0 && i>0 |
---|
[112] | 3374 | i=i-1; |
---|
[2] | 3375 | end |
---|
[137] | 3376 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3377 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3378 | flag_mask=1; |
---|
[2] | 3379 | else |
---|
[112] | 3380 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3381 | return |
---|
| 3382 | nbslice=1; |
---|
[2] | 3383 | end |
---|
[112] | 3384 | end |
---|
[2] | 3385 | |
---|
[12] | 3386 | %------------------------------------------------------------------------ |
---|
| 3387 | % --- function called to look for grid files |
---|
[2] | 3388 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3389 | %------------------------------------------------------------------------ |
---|
[2] | 3390 | flag_mask=0;%default |
---|
| 3391 | nbslice=1; |
---|
| 3392 | [Path,Name]=fileparts(filebase); |
---|
| 3393 | currentdir=pwd; |
---|
| 3394 | cd(Path);%move in the dir of the root name filebase |
---|
| 3395 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3396 | cd(currentdir);%come back to the current working directory |
---|
| 3397 | if ~isempty(maskfiles) |
---|
| 3398 | flag_mask=1; |
---|
| 3399 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3400 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3401 | Namedouble=double(Name); |
---|
| 3402 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3403 | ind_mask=findstr('grid',Name); |
---|
| 3404 | i=ind_mask-1; |
---|
[137] | 3405 | while val(i)==0 && i>0 |
---|
[112] | 3406 | i=i-1; |
---|
[2] | 3407 | end |
---|
[137] | 3408 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3409 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3410 | flag_mask=1; |
---|
[2] | 3411 | else |
---|
[112] | 3412 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3413 | return |
---|
| 3414 | nbslice=1; |
---|
[2] | 3415 | end |
---|
[12] | 3416 | end |
---|
[2] | 3417 | |
---|
[12] | 3418 | %------------------------------------------------------------------------ |
---|
| 3419 | % --- transform numbers to letters |
---|
[122] | 3420 | function str=num2stra(num,nom_type) |
---|
[12] | 3421 | %------------------------------------------------------------------------ |
---|
[122] | 3422 | if isempty(nom_type) |
---|
| 3423 | str=''; |
---|
| 3424 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3425 | str=char(96+num); |
---|
[122] | 3426 | elseif strcmp(nom_type(end),'A') |
---|
| 3427 | str=char(96+num); |
---|
| 3428 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3429 | str=''; |
---|
| 3430 | else |
---|
| 3431 | str=num2str(num); |
---|
| 3432 | end |
---|
[12] | 3433 | |
---|
| 3434 | %------------------------------------------------------------------------ |
---|
[2] | 3435 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3436 | %------------------------------------------------------------------------ |
---|
[2] | 3437 | set(handles.mask_civ1,'UserData',[]) |
---|
| 3438 | set(handles.mask_civ1,'String','') |
---|
[12] | 3439 | |
---|
| 3440 | %------------------------------------------------------------------------ |
---|
[2] | 3441 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3442 | %------------------------------------------------------------------------ |
---|
[2] | 3443 | set(handles.mask_civ2,'UserData',[]) |
---|
| 3444 | set(handles.mask_civ2,'String','') |
---|
[12] | 3445 | |
---|
| 3446 | %------------------------------------------------------------------------ |
---|
[2] | 3447 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3448 | %------------------------------------------------------------------------ |
---|
[2] | 3449 | set(handles.mask_fix1,'UserData',[]) |
---|
| 3450 | set(handles.mask_fix1,'String','') |
---|
[12] | 3451 | |
---|
| 3452 | %------------------------------------------------------------------------ |
---|
[2] | 3453 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3454 | %------------------------------------------------------------------------ |
---|
[2] | 3455 | set(handles.mask_fix2,'UserData',[]) |
---|
| 3456 | set(handles.mask_fix2,'String','') |
---|
| 3457 | |
---|
[12] | 3458 | %------------------------------------------------------------------------ |
---|
[2] | 3459 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3460 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3461 | %------------------------------------------------------------------------ |
---|
[2] | 3462 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3463 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 3464 | if val>1 |
---|
| 3465 | subdir=list_subdir_civ1{val}; |
---|
| 3466 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3467 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 3468 | end |
---|
| 3469 | |
---|
[12] | 3470 | %------------------------------------------------------------------------ |
---|
[2] | 3471 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3472 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3473 | %------------------------------------------------------------------------ |
---|
[2] | 3474 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3475 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 3476 | if val>1 |
---|
| 3477 | subdir=list_subdir_civ2{val}; |
---|
| 3478 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3479 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 3480 | end |
---|
| 3481 | |
---|
[12] | 3482 | %------------------------------------------------------------------------ |
---|
[2] | 3483 | % --- Executes on button press in browse_gridciv1. |
---|
| 3484 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3485 | %------------------------------------------------------------------------ |
---|
[2] | 3486 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3487 | testgrid=0; |
---|
| 3488 | if value |
---|
[112] | 3489 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3490 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3491 | if isequal(flag_grid,1) |
---|
[112] | 3492 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3493 | testgrid=1; |
---|
| 3494 | else |
---|
[2] | 3495 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3496 | {'*.grid', ' (*.grid)'; |
---|
| 3497 | '*.grid', '.grid files '; ... |
---|
| 3498 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3499 | 'Pick a file',filebase); |
---|
[2] | 3500 | filegrid=fullfile(PathName,FileName); |
---|
| 3501 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3502 | testgrid=1; |
---|
| 3503 | end |
---|
[112] | 3504 | end |
---|
[2] | 3505 | end |
---|
| 3506 | if testgrid |
---|
[112] | 3507 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3508 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3509 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3510 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3511 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3512 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3513 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3514 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3515 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3516 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3517 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3518 | else |
---|
| 3519 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3520 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3521 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3522 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3523 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3524 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3525 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3526 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3527 | set(handles.grid_civ1,'String','') |
---|
| 3528 | set(handles.grid_patch1,'String','') |
---|
| 3529 | set(handles.grid_civ2,'String','') |
---|
| 3530 | set(handles.grid_patch2,'String','') |
---|
[2] | 3531 | end |
---|
| 3532 | |
---|
[12] | 3533 | %------------------------------------------------------------------------ |
---|
[2] | 3534 | % --- Executes on button press in browse_gridciv1. |
---|
| 3535 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3536 | %------------------------------------------------------------------------ |
---|
[2] | 3537 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3538 | if value |
---|
[112] | 3539 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3540 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3541 | if isequal(flag_grid,1) |
---|
| 3542 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3543 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3544 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3545 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3546 | else |
---|
[2] | 3547 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3548 | {'*.grid', ' (*.grid)'; |
---|
| 3549 | '*.grid', '.grid files '; ... |
---|
| 3550 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3551 | 'Pick a file',filebase); |
---|
[2] | 3552 | filegrid=fullfile(PathName,FileName); |
---|
| 3553 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 3554 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3555 | set(handles.grid_civ2,'string',''); |
---|
| 3556 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3557 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3558 | set(handles.grid_civ2,'string',''); |
---|
| 3559 | else |
---|
| 3560 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3561 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3562 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3563 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3564 | end |
---|
| 3565 | end |
---|
| 3566 | else |
---|
| 3567 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3568 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3569 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3570 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3571 | end |
---|
| 3572 | |
---|
| 3573 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3574 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3575 | % |
---|
[71] | 3576 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3577 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3578 | % {'*.grid', ' (*.grid)'; |
---|
| 3579 | % '*.grid', '.grid files '; ... |
---|
| 3580 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3581 | % 'Pick a file',filebase); |
---|
| 3582 | % filegrid=fullfile(PathName,FileName); |
---|
| 3583 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3584 | % set(handles.dx_civ2,'String',' '); |
---|
| 3585 | % set(handles.dy_civ2,'String',' '); |
---|
| 3586 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3587 | |
---|
| 3588 | % --- Executes on button press in get_gridpatch1. |
---|
| 3589 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3590 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3591 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3592 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3593 | |
---|
[71] | 3594 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3595 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3596 | {'*.grid', ' (*.grid)'; |
---|
| 3597 | '*.grid', '.grid files '; ... |
---|
| 3598 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3599 | 'Pick a file',filebase); |
---|
[2] | 3600 | filegrid=fullfile(PathName,FileName); |
---|
| 3601 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3602 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3603 | |
---|
[12] | 3604 | %------------------------------------------------------------------------ |
---|
[2] | 3605 | % --- Executes on button press in get_gridpatch2. |
---|
| 3606 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3607 | %------------------------------------------------------------------------ |
---|
[2] | 3608 | |
---|
[12] | 3609 | %------------------------------------------------------------------------ |
---|
[2] | 3610 | function enable_civ1(handles,state) |
---|
[12] | 3611 | %------------------------------------------------------------------------ |
---|
[2] | 3612 | if isequal(state,0) |
---|
| 3613 | state='off'; |
---|
| 3614 | end |
---|
| 3615 | if isequal(state,1) |
---|
| 3616 | state='on'; |
---|
| 3617 | end |
---|
| 3618 | if isequal(state,'on') |
---|
| 3619 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3620 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3621 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3622 | else |
---|
| 3623 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3624 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3625 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3626 | end |
---|
| 3627 | set(handles.ibx,'Visible',state) |
---|
| 3628 | set(handles.iby,'Visible',state) |
---|
| 3629 | set(handles.isx,'Visible',state) |
---|
| 3630 | set(handles.isy,'Visible',state) |
---|
| 3631 | set(handles.shiftx,'Visible',state) |
---|
| 3632 | set(handles.shifty,'Visible',state) |
---|
| 3633 | set(handles.rho,'Visible',state) |
---|
| 3634 | set(handles.dx_civ1,'Visible',state) |
---|
| 3635 | set(handles.dy_civ1,'Visible',state) |
---|
| 3636 | set(handles.calcul_search,'Visible',state) |
---|
| 3637 | set(handles.u_text,'Visible',state) |
---|
| 3638 | set(handles.v_text,'Visible',state) |
---|
| 3639 | set(handles.min,'Visible',state) |
---|
| 3640 | set(handles.max,'Visible',state) |
---|
| 3641 | set(handles.umin,'Visible',state) |
---|
| 3642 | set(handles.umax,'Visible',state) |
---|
| 3643 | set(handles.vmin,'Visible',state) |
---|
| 3644 | set(handles.vmax,'Visible',state) |
---|
| 3645 | set(handles.grid_civ1,'Visible',state) |
---|
| 3646 | set(handles.mask_civ1,'Visible',state) |
---|
| 3647 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3648 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3649 | set(handles.parameters,'Visible',state) |
---|
| 3650 | set(handles.grid,'Visible',state) |
---|
| 3651 | set(handles.dx_civ1,'Visible',state) |
---|
| 3652 | set(handles.dy_civ1,'Visible',state) |
---|
| 3653 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3654 | if isequal(state,'off') |
---|
| 3655 | set(handles.MinIma,'Visible','off') |
---|
| 3656 | set(handles.MaxIma,'Visible','off') |
---|
| 3657 | set(handles.ImaThreshold,'Value',0) |
---|
| 3658 | end |
---|
| 3659 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3660 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3661 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3662 | set(handles.ib_title,'Visible',state) |
---|
| 3663 | set(handles.is_title,'Visible',state) |
---|
| 3664 | set(handles.shift_title,'Visible',state) |
---|
| 3665 | set(handles.rho_title,'Visible',state) |
---|
| 3666 | |
---|
[12] | 3667 | %------------------------------------------------------------------------ |
---|
[2] | 3668 | function enable_fix1(handles,state) |
---|
[12] | 3669 | %------------------------------------------------------------------------ |
---|
[2] | 3670 | if isequal(state,0) |
---|
| 3671 | state='off'; |
---|
| 3672 | end |
---|
| 3673 | if isequal(state,1) |
---|
| 3674 | state='on'; |
---|
| 3675 | end |
---|
| 3676 | if isequal(state,'on') |
---|
| 3677 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 3678 | else |
---|
| 3679 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3680 | end |
---|
| 3681 | set(handles.REMOVE,'Visible',state) |
---|
| 3682 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3683 | set(handles.vec_F2,'Visible',state) |
---|
| 3684 | set(handles.vec_F3,'Visible',state) |
---|
| 3685 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3686 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3687 | set(handles.thresh_vel,'Visible',state) |
---|
| 3688 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3689 | set(handles.mask_fix1,'Visible',state) |
---|
| 3690 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3691 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3692 | set(handles.ref_fix1,'Visible',state) |
---|
| 3693 | set(handles.inf_sup1,'Visible',state) |
---|
| 3694 | set(handles.field_ref1,'Visible',state) |
---|
| 3695 | |
---|
[12] | 3696 | %------------------------------------------------------------------------ |
---|
[2] | 3697 | function enable_patch1(handles) |
---|
[12] | 3698 | %------------------------------------------------------------------------ |
---|
[67] | 3699 | global patch_newBin |
---|
[2] | 3700 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3701 | set(handles.rho_patch1,'Visible','on') |
---|
| 3702 | set(handles.rho_text1,'Visible','on') |
---|
| 3703 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3704 | set(handles.thresh_text1,'Visible','on') |
---|
| 3705 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3706 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3707 | set(handles.nx_patch1,'Visible','on') |
---|
| 3708 | set(handles.ny_patch1,'Visible','on') |
---|
| 3709 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3710 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3711 | % if ~isempty(patch_newBin) |
---|
[100] | 3712 | % set(handles.test_interp,'Visible','on'); |
---|
| 3713 | % end |
---|
[2] | 3714 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 3715 | set(handles.grid_patch1,'string','none'); |
---|
| 3716 | set(handles.grid_patch1,'Visible','on') |
---|
| 3717 | |
---|
[12] | 3718 | %------------------------------------------------------------------------ |
---|
[2] | 3719 | function desable_patch1(handles) |
---|
[12] | 3720 | %------------------------------------------------------------------------ |
---|
[2] | 3721 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3722 | set(handles.rho_patch1,'Visible','off') |
---|
| 3723 | set(handles.rho_text1,'Visible','off') |
---|
| 3724 | set(handles.thresh_patch1,'Visible','off') |
---|
| 3725 | set(handles.thresh_text1,'Visible','off') |
---|
| 3726 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 3727 | set(handles.subdomain_text1,'Visible','off') |
---|
| 3728 | set(handles.nx_patch1,'Visible','off') |
---|
| 3729 | set(handles.ny_patch1,'Visible','off') |
---|
| 3730 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 3731 | set(handles.ny_patch1_title,'Visible','off') |
---|
[100] | 3732 | %set(handles.test_interp,'Visible','off') |
---|
[2] | 3733 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 3734 | set(handles.grid_patch1,'Visible','off') |
---|
| 3735 | |
---|
[12] | 3736 | %------------------------------------------------------------------------ |
---|
[2] | 3737 | function enable_civ2(handles,state) |
---|
[12] | 3738 | %------------------------------------------------------------------------ |
---|
[2] | 3739 | if isequal(state,0) |
---|
| 3740 | state='off'; |
---|
| 3741 | end |
---|
| 3742 | if isequal(state,1) |
---|
| 3743 | state='on'; |
---|
| 3744 | end |
---|
| 3745 | if isequal(state,'on') |
---|
| 3746 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3747 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3748 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3749 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3750 | else |
---|
| 3751 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3752 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3753 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3754 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3755 | end |
---|
| 3756 | set(handles.ibx_civ2,'Visible',state) |
---|
| 3757 | set(handles.iby_civ2,'Visible',state) |
---|
| 3758 | set(handles.decimal,'Visible',state) |
---|
| 3759 | set(handles.deformation,'Visible',state) |
---|
| 3760 | set(handles.rho_civ2,'Visible',state) |
---|
| 3761 | set(handles.dx_civ2,'Visible',state) |
---|
| 3762 | set(handles.dy_civ2,'Visible',state) |
---|
| 3763 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 3764 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 3765 | set(handles.parameters,'Visible',state) |
---|
| 3766 | set(handles.grid,'Visible',state) |
---|
| 3767 | set(handles.parameters_text,'Visible',state) |
---|
| 3768 | set(handles.grid_text,'Visible',state) |
---|
| 3769 | set(handles.grid_civ2,'Visible',state) |
---|
| 3770 | set(handles.mask_civ2,'Visible',state) |
---|
| 3771 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 3772 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 3773 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3774 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 3775 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 3776 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3777 | if isequal(state,'off') |
---|
| 3778 | set(handles.MinIma2,'Visible','off') |
---|
| 3779 | set(handles.MaxIma2,'Visible','off') |
---|
| 3780 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 3781 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3782 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3783 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3784 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 3785 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3786 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 3787 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3788 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3789 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 3790 | end |
---|
| 3791 | else |
---|
| 3792 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3793 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3794 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 3795 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3796 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 3797 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3798 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3799 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 3800 | end |
---|
[71] | 3801 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3802 | |
---|
[12] | 3803 | %------------------------------------------------------------------------ |
---|
[2] | 3804 | function enable_fix2(handles) |
---|
[12] | 3805 | %------------------------------------------------------------------------ |
---|
[2] | 3806 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3807 | set(handles.REMOVE2,'Visible','on') |
---|
| 3808 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 3809 | set(handles.vec_F4,'Visible','on') |
---|
| 3810 | set(handles.vec_F3_2,'Visible','on') |
---|
| 3811 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 3812 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 3813 | set(handles.thresh_vel2,'Visible','on') |
---|
| 3814 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 3815 | set(handles.mask_fix2,'Visible','on') |
---|
| 3816 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 3817 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3818 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3819 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3820 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 3821 | set(handles.ref_fix2,'Visible','on') |
---|
| 3822 | set(handles.inf_sup2,'Visible','on') |
---|
| 3823 | set(handles.field_ref2,'Visible','on') |
---|
| 3824 | |
---|
[12] | 3825 | %------------------------------------------------------------------------ |
---|
[2] | 3826 | function desable_fix2(handles) |
---|
[12] | 3827 | %------------------------------------------------------------------------ |
---|
[2] | 3828 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3829 | set(handles.REMOVE2,'Visible','off') |
---|
| 3830 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 3831 | set(handles.vec_F4,'Visible','off') |
---|
| 3832 | set(handles.vec_F3_2,'Visible','off') |
---|
| 3833 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 3834 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 3835 | set(handles.thresh_vel2,'Visible','off') |
---|
| 3836 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 3837 | set(handles.mask_fix2,'Visible','off') |
---|
| 3838 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 3839 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 3840 | set(handles.ref_fix2,'Visible','off') |
---|
| 3841 | set(handles.inf_sup2,'Visible','off') |
---|
| 3842 | set(handles.field_ref2,'Visible','off') |
---|
[112] | 3843 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3844 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3845 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3846 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3847 | end |
---|
| 3848 | |
---|
[12] | 3849 | %------------------------------------------------------------------------ |
---|
[2] | 3850 | function enable_patch2(handles) |
---|
[12] | 3851 | %------------------------------------------------------------------------ |
---|
[2] | 3852 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[119] | 3853 | set(handles.rho_patch2,'Visible','on') |
---|
[2] | 3854 | set(handles.rho_text2,'Visible','on') |
---|
| 3855 | set(handles.thresh_patch2,'Visible','on') |
---|
| 3856 | set(handles.thresh_text2,'Visible','on') |
---|
| 3857 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 3858 | set(handles.subdomain_text2,'Visible','on') |
---|
| 3859 | set(handles.nx_patch2,'Visible','on') |
---|
| 3860 | set(handles.ny_patch2,'Visible','on') |
---|
| 3861 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 3862 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 3863 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 3864 | set(handles.grid_patch2,'Visible','on') |
---|
| 3865 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3866 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3867 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3868 | |
---|
[12] | 3869 | %------------------------------------------------------------------------ |
---|
[2] | 3870 | function desable_patch2(handles) |
---|
[12] | 3871 | %------------------------------------------------------------------------ |
---|
[2] | 3872 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3873 | set(handles.rho_patch2,'Visible','off') |
---|
| 3874 | set(handles.rho_text2,'Visible','off') |
---|
| 3875 | set(handles.thresh_patch2,'Visible','off') |
---|
| 3876 | set(handles.thresh_text2,'Visible','off') |
---|
| 3877 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 3878 | set(handles.subdomain_text2,'Visible','off') |
---|
| 3879 | set(handles.nx_patch2,'Visible','off') |
---|
| 3880 | set(handles.ny_patch2,'Visible','off') |
---|
| 3881 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 3882 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 3883 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 3884 | set(handles.grid_patch2,'Visible','off') |
---|
[112] | 3885 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
[2] | 3886 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3887 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3888 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3889 | end |
---|
| 3890 | |
---|
[12] | 3891 | %------------------------------------------------------------------------ |
---|
[2] | 3892 | function enable_pair1(handles,state) |
---|
[12] | 3893 | %------------------------------------------------------------------------ |
---|
[2] | 3894 | set(handles.subdir_civ1,'Visible',state) |
---|
| 3895 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 3896 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 3897 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 3898 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 3899 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 3900 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 3901 | set(handles.PAIR_frame,'Visible',state) |
---|
| 3902 | |
---|
[12] | 3903 | %------------------------------------------------------------------------ |
---|
| 3904 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 3905 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 3906 | %------------------------------------------------------------------------ |
---|
[127] | 3907 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 3908 | par.ibx=num2str(ibx_val); |
---|
[127] | 3909 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 3910 | par.iby=num2str(iby_val); |
---|
| 3911 | isx=get(handles.isx,'String'); |
---|
[127] | 3912 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3913 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 3914 | isy=get(handles.isy,'String'); |
---|
[127] | 3915 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3916 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 3917 | par.isx=get(handles.isx,'String'); |
---|
| 3918 | par.isy=get(handles.isy,'String'); |
---|
| 3919 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 3920 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 3921 | if isnan(str2double(par.isx)) |
---|
[112] | 3922 | par.isx='41';%default |
---|
| 3923 | set(handles.isx,'String','41'); |
---|
[2] | 3924 | end |
---|
[127] | 3925 | if isnan(str2double(par.isy)) |
---|
[112] | 3926 | par.isy='41'; %default |
---|
| 3927 | set(handles.isy,'String','41'); |
---|
[12] | 3928 | end |
---|
[127] | 3929 | if isnan(str2double(par.shiftx)) |
---|
[112] | 3930 | par.shiftx='0';%default |
---|
| 3931 | set(handles.shiftx,'String','0'); |
---|
| 3932 | end |
---|
[127] | 3933 | if isnan(str2double(par.shifty)) |
---|
[112] | 3934 | par.shifty='0'; %default |
---|
| 3935 | set(handles.shifty,'String','0'); |
---|
[12] | 3936 | end |
---|
[112] | 3937 | par.rho=get(handles.rho,'String'); |
---|
| 3938 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 3939 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 3940 | if isnan(str2double(par.dx)) |
---|
[112] | 3941 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 3942 | par.dx='0'; %just read by civ program, not used |
---|
| 3943 | else |
---|
[12] | 3944 | par.dx='20';%default |
---|
| 3945 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 3946 | end |
---|
| 3947 | end |
---|
[127] | 3948 | if isnan(str2double(par.dy)) |
---|
[112] | 3949 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 3950 | par.dy='0';%just read by civ program, not used |
---|
| 3951 | else |
---|
[12] | 3952 | par.dy='20';%default |
---|
| 3953 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 3954 | end |
---|
| 3955 | end |
---|
| 3956 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 3957 | par.pxcmy='1'; |
---|
[2] | 3958 | % end |
---|
[112] | 3959 | A=imread(file_ima);%read the first image to get the size |
---|
| 3960 | sizim=size(A); |
---|
| 3961 | par.npx=num2str(sizim(2)); |
---|
| 3962 | par.npy=num2str(sizim(1)); |
---|
[127] | 3963 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 3964 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 3965 | par.gridflag='y'; |
---|
[127] | 3966 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 3967 | par.gridname='nogrid'; |
---|
| 3968 | par.gridflag='n'; |
---|
| 3969 | end |
---|
[12] | 3970 | |
---|
| 3971 | %------------------------------------------------------------------------ |
---|
[2] | 3972 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 3973 | %------------------------------------------------------------------------ |
---|
| 3974 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 3975 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 3976 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 3977 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3978 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3979 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 3980 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 3981 | if isnan(str2double(par.dx)) |
---|
[112] | 3982 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 3983 | par.dx='0'; %just read by civ program, not used |
---|
| 3984 | else |
---|
[12] | 3985 | par.dx='20';%default |
---|
| 3986 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 3987 | end |
---|
| 3988 | end |
---|
[127] | 3989 | if isnan(str2double(par.dy)) |
---|
[112] | 3990 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 3991 | par.dy='0';%just read by civ program, not used |
---|
| 3992 | else |
---|
[12] | 3993 | par.dy='20';%default |
---|
| 3994 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 3995 | end |
---|
| 3996 | end |
---|
| 3997 | par.pxcmx='1'; |
---|
| 3998 | par.pxcmy='1'; |
---|
[12] | 3999 | A=imread(file_ima);%read the first image to get the size |
---|
| 4000 | sizim=size(A); |
---|
| 4001 | par.npx=num2str(sizim(2)); |
---|
| 4002 | par.npy=num2str(sizim(1)); |
---|
[127] | 4003 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4004 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4005 | par.gridflag='y'; |
---|
[127] | 4006 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4007 | par.gridname='nogrid'; |
---|
| 4008 | par.gridflag='n'; |
---|
| 4009 | end |
---|
[2] | 4010 | |
---|
[12] | 4011 | %------------------------------------------------------------------------ |
---|
| 4012 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4013 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4014 | %------------------------------------------------------------------------ |
---|
[2] | 4015 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4016 | |
---|
| 4017 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4018 | |
---|
[112] | 4019 | if isequal(par.Dt,'0') |
---|
| 4020 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4021 | end |
---|
| 4022 | % |
---|
[12] | 4023 | % textcmx={'############## CMX file';... |
---|
| 4024 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4025 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4026 | % 'XX' ;... |
---|
| 4027 | % ['Mask ' par.maskflag] ;... |
---|
| 4028 | % ['MaskName ' par.maskname];... |
---|
| 4029 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4030 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4031 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4032 | % ['RO ' par.rho];... |
---|
| 4033 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4034 | % 'XX 1.0';... |
---|
| 4035 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4036 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4037 | % 'XX 1';... |
---|
| 4038 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4039 | % ['Grid ' par.gridflag];... |
---|
| 4040 | % ['GridName ' par.gridname] ;... |
---|
| 4041 | % 'XX 85';... |
---|
| 4042 | % 'XX 1.0';... |
---|
| 4043 | % 'XX 1.0';... |
---|
| 4044 | % 'Hart 1';... |
---|
| 4045 | % 'DecimalShift 0';... |
---|
| 4046 | % 'Deformation 0';... |
---|
| 4047 | % 'CorrelationMin 0';... |
---|
| 4048 | % 'IntensityMin 0';... |
---|
| 4049 | % 'SeuilImage n';... |
---|
| 4050 | % 'SeuilImageValues 0 4096';... |
---|
| 4051 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4052 | % 'ImageUsedBefore null null'}; |
---|
[112] | 4053 | % |
---|
[12] | 4054 | % textout=char(textcmx); |
---|
[90] | 4055 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4056 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
| 4057 | fid=fopen([filename '.cmx'],'w'); |
---|
[12] | 4058 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[112] | 4059 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4060 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4061 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4062 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4063 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
| 4064 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4065 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4066 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4067 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4068 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4069 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4070 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4071 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4072 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4073 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4074 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4075 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
| 4076 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4077 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4078 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4079 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4080 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4081 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4082 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4083 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4084 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4085 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4086 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4087 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4088 | fclose(fid); |
---|
[112] | 4089 | |
---|
[120] | 4090 | cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
[90] | 4091 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4092 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 4093 | |
---|
[12] | 4094 | if(isunix) |
---|
| 4095 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4096 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
[67] | 4097 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
[12] | 4098 | else |
---|
[67] | 4099 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log']; |
---|
[12] | 4100 | end |
---|
[2] | 4101 | |
---|
[12] | 4102 | %------------------------------------------------------------------------ |
---|
| 4103 | % --- CIV1 Unified |
---|
[94] | 4104 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4105 | %------------------------------------------------------------------------ |
---|
[2] | 4106 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4107 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4108 | |
---|
[112] | 4109 | civ1.image1=par.filename_ima_a; |
---|
| 4110 | civ1.image2=par.filename_ima_b; |
---|
| 4111 | civ1.imageSize_X=par.npx; |
---|
| 4112 | civ1.imageSize_Y=par.npy; |
---|
| 4113 | civ1.outputFileName=[filename '.nc']; |
---|
| 4114 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4115 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4116 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4117 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4118 | civ1.globalShift_X=par.shiftx; |
---|
| 4119 | civ1.globalShift_Y=par.shifty; |
---|
| 4120 | civ1.ro=par.rho; |
---|
| 4121 | civ1.hart='y'; |
---|
| 4122 | if isequal(par.gridflag,'y') |
---|
| 4123 | civ1.grid=par.gridname; |
---|
| 4124 | else |
---|
| 4125 | civ1.grid='n'; |
---|
| 4126 | civ1.gridSpacing_X=par.dx; |
---|
| 4127 | civ1.gridSpacing_Y=par.dy; |
---|
| 4128 | end |
---|
| 4129 | if isequal(par.maskflag,'y') |
---|
| 4130 | civ1.mask=par.maskname; |
---|
| 4131 | end |
---|
| 4132 | civ1.dt=par.Dt; |
---|
| 4133 | civ1.unit='pixel'; |
---|
| 4134 | civ1.absolut_time_T0=par.T0; |
---|
| 4135 | civ1.pixcmx=par.pxcmx; |
---|
| 4136 | civ1.pixcmy=par.pxcmy; |
---|
| 4137 | civ1.convectFlow='n'; |
---|
[12] | 4138 | |
---|
[112] | 4139 | xml_civ1_parameters=civ1; |
---|
| 4140 | |
---|
[12] | 4141 | %------------------------------------------------------------------------ |
---|
| 4142 | % --- CIV2 Unified |
---|
[94] | 4143 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4144 | %------------------------------------------------------------------------ |
---|
[2] | 4145 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4146 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4147 | |
---|
| 4148 | civ2.image1=par.filename_ima_a; |
---|
| 4149 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4150 | civ2.imageSize_X=par.npx; |
---|
[2] | 4151 | civ2.imageSize_Y=par.npy; |
---|
| 4152 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4153 | civ2.outputFileName=[filename '.nc']; |
---|
| 4154 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4155 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4156 | civ2.ro=par.rho; |
---|
| 4157 | %civ2.decimalShift=par.decimal; |
---|
| 4158 | %civ2.deformation=par.deformation; |
---|
| 4159 | if isequal(par.decimal,'1') |
---|
| 4160 | civ2.decimalShift='y'; |
---|
| 4161 | else |
---|
| 4162 | civ2.decimalShift='n'; |
---|
| 4163 | end |
---|
| 4164 | if isequal(par.deformation,'1') |
---|
| 4165 | civ2.deformation='y'; |
---|
| 4166 | else |
---|
| 4167 | civ2.deformation='n'; |
---|
| 4168 | end |
---|
| 4169 | if isequal(par.gridflag,'y') |
---|
| 4170 | civ2.grid=par.gridname; |
---|
| 4171 | else |
---|
| 4172 | civ2.grid='n'; |
---|
| 4173 | civ2.gridSpacing_X=par.dx; |
---|
| 4174 | civ2.gridSpacing_Y=par.dy; |
---|
| 4175 | end |
---|
| 4176 | civ2.gridSpacing_X='10'; |
---|
| 4177 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4178 | if isequal(par.maskflag,'y') |
---|
| 4179 | civ2.mask=par.maskname; |
---|
| 4180 | else |
---|
| 4181 | civ2.mask='n'; |
---|
| 4182 | end |
---|
| 4183 | civ2.dt=par.Dt; |
---|
| 4184 | civ2.unit='pixel'; |
---|
| 4185 | civ2.absolut_time_T0=par.T0; |
---|
| 4186 | civ2.pixcmx=par.pxcmx; |
---|
| 4187 | civ2.pixcmy=par.pxcmy; |
---|
| 4188 | civ2.convectFlow='n'; |
---|
| 4189 | civ2.pixcmx=par.pxcmx; |
---|
| 4190 | civ2.pixcmy=par.pxcmy; |
---|
| 4191 | civ2.convectFlow='n'; |
---|
| 4192 | |
---|
[12] | 4193 | %------------------------------------------------------------------------ |
---|
| 4194 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[134] | 4195 | function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam) |
---|
[12] | 4196 | %------------------------------------------------------------------------ |
---|
[2] | 4197 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4198 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[112] | 4199 | if isequal(par.Dt,'0') |
---|
| 4200 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4201 | end |
---|
[94] | 4202 | % textcmx=['############## CMX file' '\n'... |
---|
| 4203 | % ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 4204 | % ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 4205 | % 'XX' '\n'... |
---|
| 4206 | % ['Mask ' par.maskflag] '\n'... |
---|
| 4207 | % ['MaskName ' par.maskname] '\n'... |
---|
[112] | 4208 | % ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
[94] | 4209 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4210 | % ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4211 | % ['RO ' par.rho] '\n'... |
---|
| 4212 | % ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 4213 | % 'XX 1.0' '\n'... |
---|
| 4214 | % ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 4215 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 4216 | % 'XX 1' '\n'... |
---|
| 4217 | % ['ShiftXY 0 0'] '\n'... |
---|
| 4218 | % ['Grid ' par.gridflag] '\n'... |
---|
| 4219 | % ['GridName ' par.gridname] '\n'... |
---|
| 4220 | % 'XX 85' '\n'... |
---|
| 4221 | % 'XX 1.0' '\n'... |
---|
| 4222 | % 'XX 1.0' '\n'... |
---|
| 4223 | % 'Hart 1' '\n'... |
---|
| 4224 | % ['DecimalShift ' par.decimal] '\n'... |
---|
| 4225 | % ['Deformation ' par.deformation] '\n'... |
---|
| 4226 | % 'CorrelationMin 0' '\n'... |
---|
| 4227 | % 'IntensityMin 0' '\n'... |
---|
| 4228 | % 'SeuilImage n' '\n'... |
---|
| 4229 | % 'SeuilImageValues 0 4096' '\n'... |
---|
| 4230 | % ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 4231 | % ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 4232 | % textout=char(textcmx); |
---|
| 4233 | % fid=fopen([filename_cmx '2'],'w'); |
---|
[112] | 4234 | % fprintf(fid,textout); |
---|
[94] | 4235 | % fclose(fid) |
---|
[2] | 4236 | |
---|
[94] | 4237 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
| 4238 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[134] | 4239 | fid=fopen([filename '.cmx2'],'w'); |
---|
[94] | 4240 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4241 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4242 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4243 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4244 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4245 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4246 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4247 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4248 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
---|
| 4249 | fprintf(fid, ['RO ' par.rho '\n']); |
---|
| 4250 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
---|
| 4251 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4252 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4253 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4254 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4255 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[94] | 4256 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4257 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
---|
| 4258 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4259 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4260 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4261 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4262 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
---|
| 4263 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
---|
| 4264 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4265 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4266 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4267 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4268 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4269 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
---|
| 4270 | fclose(fid); |
---|
| 4271 | |
---|
[134] | 4272 | cmd_CIV2=[sparam.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
[94] | 4273 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
---|
[134] | 4274 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
[94] | 4275 | |
---|
[134] | 4276 | if(isunix) |
---|
| 4277 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4278 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
| 4279 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ2.log' '\n' 'chmod g+w ' ncName]; |
---|
| 4280 | else |
---|
| 4281 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y ' namelog ' ' regexprep(namelog,'\.log','') '.civ2.log']; |
---|
| 4282 | end |
---|
| 4283 | |
---|
| 4284 | |
---|
| 4285 | |
---|
[12] | 4286 | %------------------------------------------------------------------------ |
---|
[2] | 4287 | % --- Executes on button press in HELP. |
---|
| 4288 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 4289 | %------------------------------------------------------------------------ |
---|
[2] | 4290 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4291 | pathelp=fileparts(path_to_uvmat); |
---|
[85] | 4292 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
[36] | 4293 | 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] | 4294 | else |
---|
[36] | 4295 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
[112] | 4296 | web([helpfile '#civ']) |
---|
[2] | 4297 | end |
---|
| 4298 | |
---|
[12] | 4299 | %------------------------------------------------------------------------ |
---|
[2] | 4300 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4301 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4302 | %------------------------------------------------------------------------ |
---|
[2] | 4303 | %num is the view number needed for an avi movie |
---|
[45] | 4304 | switch type_ima |
---|
| 4305 | case 'movie' |
---|
| 4306 | A=read(movieobject,num); |
---|
| 4307 | case 'avi' |
---|
[112] | 4308 | mov=aviread(filename,num); |
---|
| 4309 | A=frame2im(mov(1)); |
---|
[45] | 4310 | case 'multimage' |
---|
| 4311 | A=imread(filename,num); |
---|
[112] | 4312 | case 'image' |
---|
[45] | 4313 | A=imread(filename); |
---|
| 4314 | end |
---|
| 4315 | siz=size(A); |
---|
| 4316 | if length(siz)==3;%color images |
---|
[2] | 4317 | A=sum(double(A),3); |
---|
| 4318 | A=uint16(A); |
---|
| 4319 | end |
---|
| 4320 | |
---|
[12] | 4321 | %------------------------------------------------------------------------ |
---|
[2] | 4322 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4323 | %------------------------------------------------------------------------ |
---|
[2] | 4324 | mode_list=get(handles.mode,'String'); |
---|
| 4325 | mode_value=get(handles.mode,'Value'); |
---|
| 4326 | mode=mode_list{mode_value}; |
---|
[45] | 4327 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4328 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[112] | 4329 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4330 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4331 | end |
---|
| 4332 | |
---|
[12] | 4333 | %------------------------------------------------------------------------ |
---|
[2] | 4334 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4335 | %------------------------------------------------------------------------ |
---|
[2] | 4336 | mode_list=get(handles.mode,'String'); |
---|
| 4337 | mode_value=get(handles.mode,'Value'); |
---|
| 4338 | mode=mode_list{mode_value}; |
---|
[112] | 4339 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4340 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4341 | end |
---|
[45] | 4342 | if isequal(mode,'series(Dj)') || ... |
---|
[112] | 4343 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4344 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4345 | end |
---|
[12] | 4346 | |
---|
| 4347 | %------------------------------------------------------------------------ |
---|
[71] | 4348 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4349 | %------------------------------------------------------------------------ |
---|
| 4350 | mode_list=get(handles.mode,'String'); |
---|
| 4351 | mode_value=get(handles.mode,'Value'); |
---|
| 4352 | mode=mode_list{mode_value}; |
---|
| 4353 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4354 | |
---|
| 4355 | %------------------------------------------------------------------------ |
---|
| 4356 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4357 | %------------------------------------------------------------------------ |
---|
| 4358 | mode_list=get(handles.mode,'String'); |
---|
| 4359 | mode_value=get(handles.mode,'Value'); |
---|
| 4360 | mode=mode_list{mode_value}; |
---|
[112] | 4361 | if isequal(mode,'series(Dj)') |
---|
[71] | 4362 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4363 | end |
---|
| 4364 | |
---|
| 4365 | %------------------------------------------------------------------------ |
---|
[2] | 4366 | % --- Executes on button press in compare. |
---|
| 4367 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 4368 | %------------------------------------------------------------------------ |
---|
[2] | 4369 | test=get(handles.compare,'Value'); |
---|
[112] | 4370 | if test==2 || test==3 |
---|
[71] | 4371 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4372 | browse=get(handles.browse_root,'Userdata'); |
---|
| 4373 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 4374 | set(handles.browse_root,'UserData',browse); |
---|
| 4375 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4376 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[2] | 4377 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
[112] | 4378 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
[2] | 4379 | set(handles.mode,'Visible','off') |
---|
| 4380 | if test==2 |
---|
[112] | 4381 | set(handles.mode,'Visible','off') |
---|
[2] | 4382 | else |
---|
| 4383 | set(handles.mode,'Visible','on') |
---|
| 4384 | end |
---|
| 4385 | |
---|
| 4386 | % open an image file with the browser |
---|
| 4387 | ind_opening=1;%default |
---|
| 4388 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4389 | oldfile=get(handles.RootName,'String'); |
---|
[2] | 4390 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
[112] | 4391 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 4392 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 4393 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 4394 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4395 | sizf=size(fileinput); |
---|
| 4396 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 4397 | [path,name,ext]=fileparts(fileinput); |
---|
| 4398 | [path1]=fileparts(filebase); |
---|
| 4399 | if ~strcmp(path1,path) |
---|
[112] | 4400 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
[2] | 4401 | return |
---|
| 4402 | end |
---|
[71] | 4403 | set(handles.RootName_1,'String',name); |
---|
[2] | 4404 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 4405 | browse=get(handles.browse_root,'UserData'); |
---|
| 4406 | browse.nom_type_ima_1=nom_type; |
---|
[112] | 4407 | set(handles.browse_root,'UserData',browse) |
---|
[2] | 4408 | |
---|
| 4409 | %check image extension |
---|
[71] | 4410 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[2] | 4411 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 4412 | return |
---|
| 4413 | end |
---|
| 4414 | |
---|
| 4415 | %check image size |
---|
| 4416 | A=imread(fileinput); |
---|
[71] | 4417 | npxy=get(handles.ImaExt,'UserData'); |
---|
[2] | 4418 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 4419 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 4420 | return |
---|
| 4421 | end |
---|
| 4422 | else |
---|
| 4423 | set(handles.mode,'Visible','on') |
---|
[71] | 4424 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4425 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4426 | set(handles.RootName_1,'String',[]); |
---|
[2] | 4427 | mode_store=get(handles.compare,'UserData'); |
---|
| 4428 | set(handles.mode,'String',mode_store) |
---|
| 4429 | set(handles.test_stereo1,'Value',0) |
---|
| 4430 | set(handles.test_stereo2,'Value',0) |
---|
| 4431 | end |
---|
| 4432 | mode_Callback(hObject, eventdata, handles) |
---|
| 4433 | |
---|
[12] | 4434 | %------------------------------------------------------------------------ |
---|
[2] | 4435 | % --- Executes on button press in get_ref_fix1. |
---|
| 4436 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4437 | %------------------------------------------------------------------------ |
---|
[71] | 4438 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4439 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4440 | {'*.nc', ' (*.nc)'; |
---|
| 4441 | '*.nc', 'netcdf files '; ... |
---|
| 4442 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4443 | 'Pick a file',filebase); |
---|
| 4444 | |
---|
[2] | 4445 | fileinput=[PathName FileName]; |
---|
| 4446 | sizf=size(fileinput); |
---|
[122] | 4447 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4448 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4449 | ref.filebase=fullfile(Path,File); |
---|
| 4450 | ref.num_a=stra2num(str_a); |
---|
| 4451 | ref.num_b=stra2num(str_b); |
---|
[89] | 4452 | ref.num1=str2double(field_count); |
---|
| 4453 | ref.num2=str2double(str2); |
---|
[2] | 4454 | browse=[];%initialisation |
---|
| 4455 | if ~isequal(ref.ext,'.nc') |
---|
| 4456 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4457 | return |
---|
| 4458 | end |
---|
| 4459 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4460 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4461 | menu_field{1}='civ1'; |
---|
| 4462 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4463 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4464 | menu_field{2}='filter1'; |
---|
| 4465 | end |
---|
[45] | 4466 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4467 | menu_field{3}='civ2'; |
---|
| 4468 | end |
---|
[45] | 4469 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4470 | menu_field{4}='filter2'; |
---|
| 4471 | end |
---|
| 4472 | set(handles.field_ref1,'String',menu_field); |
---|
| 4473 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 4474 | set(handles.inf_sup1,'Value',2); |
---|
| 4475 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 4476 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4477 | |
---|
| 4478 | %------------------------------------------------------------------------ |
---|
[2] | 4479 | % --- Executes on button press in get_ref_fix2. |
---|
| 4480 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4481 | %------------------------------------------------------------------------ |
---|
[2] | 4482 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4483 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4484 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4485 | {'*.nc', ' (*.nc)'; |
---|
| 4486 | '*.nc', 'netcdf files '; ... |
---|
| 4487 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4488 | 'Pick a file',filebase); |
---|
[2] | 4489 | fileinput=[PathName FileName]; |
---|
| 4490 | sizf=size(fileinput); |
---|
[45] | 4491 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4492 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4493 | ref.filebase=fullfile(Path,File); |
---|
| 4494 | ref.num_a=stra2num(str_a); |
---|
| 4495 | ref.num_b=stra2num(str_b); |
---|
| 4496 | ref.num1=str2num(field_count); |
---|
| 4497 | ref.num2=str2num(str2); |
---|
| 4498 | browse=[];%initialisation |
---|
| 4499 | if ~isequal(ref.ext,'.nc') |
---|
| 4500 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4501 | return |
---|
| 4502 | end |
---|
| 4503 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4504 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4505 | menu_field{1}='civ1'; |
---|
| 4506 | Data=nc2struct(fileinput,[]); |
---|
| 4507 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4508 | menu_field{2}='filter1'; |
---|
| 4509 | end |
---|
| 4510 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4511 | menu_field{3}='civ2'; |
---|
| 4512 | end |
---|
| 4513 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4514 | menu_field{4}='filter2'; |
---|
| 4515 | end |
---|
| 4516 | set(handles.field_ref2,'String',menu_field); |
---|
| 4517 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 4518 | set(handles.inf_sup2,'Value',2); |
---|
| 4519 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 4520 | set(handles.ref_fix2,'Enable','on') |
---|
| 4521 | set(handles.ref_fix2,'Visible','on') |
---|
| 4522 | set(handles.field_ref2,'Visible','on') |
---|
| 4523 | else |
---|
| 4524 | set(handles.ref_fix2,'Visible','off') |
---|
| 4525 | set(handles.field_ref2,'Visible','off') |
---|
| 4526 | end |
---|
| 4527 | |
---|
[12] | 4528 | %------------------------------------------------------------------------ |
---|
[2] | 4529 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4530 | %------------------------------------------------------------------------ |
---|
| 4531 | set(handles.inf_sup1,'Value',1); |
---|
| 4532 | set(handles.field_ref1,'Value',1) |
---|
| 4533 | set(handles.field_ref1,'String',{' '}) |
---|
| 4534 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4535 | set(handles.ref_fix1,'String',''); |
---|
| 4536 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4537 | |
---|
[12] | 4538 | %------------------------------------------------------------------------ |
---|
[2] | 4539 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4540 | %------------------------------------------------------------------------ |
---|
| 4541 | set(handles.inf_sup2,'Value',1); |
---|
| 4542 | set(handles.field_ref2,'Value',1) |
---|
| 4543 | set(handles.field_ref2,'String',{' '}) |
---|
| 4544 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4545 | set(handles.ref_fix2,'String',''); |
---|
| 4546 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 4547 | |
---|
[12] | 4548 | %------------------------------------------------------------------------ |
---|
[2] | 4549 | % --- Executes on button press in test_stereo1. |
---|
| 4550 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4551 | %------------------------------------------------------------------------ |
---|
[2] | 4552 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4553 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4554 | set(handles.rho_patch1,'Visible','on') |
---|
| 4555 | else |
---|
| 4556 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4557 | set(handles.rho_patch1,'Visible','off') |
---|
| 4558 | end |
---|
| 4559 | |
---|
[12] | 4560 | %------------------------------------------------------------------------ |
---|
[2] | 4561 | % --- Executes on button press in test_stereo2. |
---|
| 4562 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 4563 | %------------------------------------------------------------------------ |
---|
[2] | 4564 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 4565 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4566 | set(handles.rho_patch2,'Visible','on') |
---|
| 4567 | else |
---|
| 4568 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4569 | set(handles.rho_patch2,'Visible','off') |
---|
| 4570 | end |
---|
| 4571 | |
---|
[12] | 4572 | %------------------------------------------------------------------------ |
---|
[2] | 4573 | % --- Executes on button press in ImaThreshold. |
---|
| 4574 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4575 | %------------------------------------------------------------------------ |
---|
[2] | 4576 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 4577 | set(handles.MinIma,'Visible','on') |
---|
| 4578 | set(handles.MaxIma,'Visible','on') |
---|
| 4579 | else |
---|
| 4580 | set(handles.MinIma,'Visible','off') |
---|
| 4581 | set(handles.MaxIma,'Visible','off') |
---|
| 4582 | end |
---|
| 4583 | |
---|
[12] | 4584 | %------------------------------------------------------------------------ |
---|
[2] | 4585 | % --- Executes on button press in ImaThreshold2. |
---|
| 4586 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4587 | %------------------------------------------------------------------------ |
---|
[2] | 4588 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 4589 | set(handles.MinIma2,'Visible','on') |
---|
| 4590 | set(handles.MaxIma2,'Visible','on') |
---|
| 4591 | else |
---|
| 4592 | set(handles.MinIma2,'Visible','off') |
---|
| 4593 | set(handles.MaxIma2,'Visible','off') |
---|
| 4594 | end |
---|
| 4595 | |
---|
[71] | 4596 | |
---|
| 4597 | |
---|
| 4598 | |
---|