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