[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 | |
---|
[220] | 24 | % Last Modified by GUIDE v2.5 11-Mar-2011 08:21:21 |
---|
[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); |
---|
[246] | 64 | set(hObject,'WindowButtonUpFcn',{'mouse_up_GUI',handles}) %set mouse action (zoom on uicontrols) |
---|
[2] | 65 | %default initial parameters |
---|
| 66 | filebase=''; % root file name ('filebase'.civ) |
---|
| 67 | ext=[]; |
---|
[238] | 68 | set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'}) |
---|
[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,'String',ext) |
---|
| 109 | |
---|
[122] | 110 | %read names of the .exe file to adjust the interface according to available binaries |
---|
[2] | 111 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 112 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 113 | errormsg=[];%default error message |
---|
[112] | 114 | xmlfile='PARAM.xml'; |
---|
[54] | 115 | if exist(xmlfile,'file') |
---|
| 116 | try |
---|
[112] | 117 | t=xmltree(xmlfile); |
---|
| 118 | sparam=convert(t); |
---|
[54] | 119 | catch |
---|
[112] | 120 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
[227] | 121 | return |
---|
[2] | 122 | end |
---|
[54] | 123 | else |
---|
| 124 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[227] | 125 | return |
---|
[2] | 126 | end |
---|
[71] | 127 | |
---|
[110] | 128 | |
---|
[45] | 129 | if ~isempty(errormsg) |
---|
[112] | 130 | msgbox_uvmat('ERROR',errormsg); |
---|
[45] | 131 | end |
---|
[71] | 132 | % patch_newBin=''; |
---|
| 133 | test_batch=0;%default: ,no batch mode available |
---|
| 134 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 135 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
[2] | 136 | end |
---|
| 137 | if test_batch==0 |
---|
[84] | 138 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
[2] | 139 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 140 | end |
---|
[94] | 141 | if isfield(sparam.RunParam,'CivBin') |
---|
| 142 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[112] | 143 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
[94] | 144 | end |
---|
[97] | 145 | else |
---|
| 146 | sparam.RunParam.CivBin=''; |
---|
[94] | 147 | end |
---|
[96] | 148 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
[2] | 149 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 150 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 151 | |
---|
| 152 | %initiate advised operations |
---|
| 153 | if isequal(ind_opening,[]) |
---|
| 154 | ind_opening=1; % default |
---|
| 155 | end |
---|
| 156 | % set default operation options |
---|
[112] | 157 | enable_civ1(handles,'off') |
---|
| 158 | enable_civ2(handles,'off') |
---|
| 159 | enable_pair1(handles,'on') |
---|
| 160 | enable_fix1(handles,'off') |
---|
| 161 | desable_patch1(handles) |
---|
| 162 | desable_fix2(handles) |
---|
| 163 | desable_patch2(handles) |
---|
| 164 | set(handles.CIV1,'Value',0) |
---|
| 165 | set(handles.FIX1,'Value',0) |
---|
| 166 | set(handles.PATCH1,'Value',0) |
---|
| 167 | set(handles.CIV2,'Value',0) |
---|
| 168 | set(handles.FIX2,'Value',0) |
---|
| 169 | set(handles.PATCH2,'Value',0) |
---|
| 170 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 171 | if isequal(ind_opening,1) |
---|
| 172 | set(handles.CIV1,'Value',1) |
---|
| 173 | enable_civ1(handles,'on') |
---|
| 174 | elseif isequal(ind_opening,2) |
---|
| 175 | set(handles.FIX1,'Value',1) |
---|
| 176 | enable_fix1(handles,'on') |
---|
| 177 | elseif isequal(ind_opening,3) |
---|
| 178 | set(handles.PATCH1,'Value',1) |
---|
| 179 | enable_patch1(handles) |
---|
| 180 | elseif isequal(ind_opening,4) |
---|
| 181 | set(handles.CIV2,'Value',1) |
---|
[224] | 182 | enable_civ2(handles,'on') |
---|
[2] | 183 | elseif isequal(ind_opening,5) |
---|
| 184 | set(handles.FIX2,'Value',1) |
---|
| 185 | enable_fix2(handles) |
---|
[112] | 186 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 187 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 188 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 189 | enable_pair1(handles,'off') |
---|
[2] | 190 | elseif isequal(ind_opening,6) |
---|
| 191 | set(handles.PATCH2,'Value',1) |
---|
| 192 | enable_patch2(handles) |
---|
| 193 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 194 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 195 | enable_pair1(handles,'off') |
---|
| 196 | end |
---|
| 197 | |
---|
| 198 | % set the range of fields (1:1 by default) and selected pair |
---|
[153] | 199 | if isequal(num_i2,num_i1) |
---|
| 200 | num_ref_i=num_i1; |
---|
[2] | 201 | else |
---|
[153] | 202 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 203 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 204 | browse.incr_pair(2)=0; |
---|
| 205 | end |
---|
[153] | 206 | if isequal(num_j1,num_j2) |
---|
| 207 | if isnan(num_j1) |
---|
[2] | 208 | num_ref_j=1; |
---|
| 209 | else |
---|
[153] | 210 | num_ref_j=num_j1; |
---|
[2] | 211 | end |
---|
| 212 | else |
---|
[153] | 213 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 214 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 215 | end |
---|
| 216 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 217 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 218 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 219 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 220 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 221 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[71] | 222 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 223 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
[2] | 224 | set(handles.browse_root,'UserData',browse); |
---|
[220] | 225 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
[112] | 226 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 227 | end |
---|
| 228 | |
---|
[150] | 229 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 230 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 231 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 232 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
[2] | 233 | |
---|
[12] | 234 | %------------------------------------------------------------------------ |
---|
[2] | 235 | % --- Outputs from this function are returned to the command line. |
---|
| 236 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 237 | %------------------------------------------------------------------------ |
---|
[2] | 238 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 239 | % hObject handle to figure |
---|
| 240 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 241 | % handles structure with handles and user data (see GUIDATA) |
---|
| 242 | % Get default command line output from handles structure |
---|
| 243 | varargout{1} = handles.output; |
---|
| 244 | |
---|
[12] | 245 | %------------------------------------------------------------------------ |
---|
[2] | 246 | % --- Executes on button press in browse_root. |
---|
| 247 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 248 | %------------------------------------------------------------------------ |
---|
[2] | 249 | %get the input file properties |
---|
[71] | 250 | filebase=get(handles.RootName,'String'); |
---|
[2] | 251 | oldfile=''; %default |
---|
[39] | 252 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 253 | dir_perso=prefdir; |
---|
| 254 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 255 | if exist(profil_perso,'file') |
---|
| 256 | h=load (profil_perso); |
---|
| 257 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 258 | oldfile=h.filebase; |
---|
| 259 | end |
---|
| 260 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 261 | oldfile=h.RootPath; |
---|
| 262 | end |
---|
| 263 | end |
---|
| 264 | else |
---|
| 265 | oldfile=filebase; |
---|
| 266 | end |
---|
[2] | 267 | ind_opening=1;%default |
---|
| 268 | browse.incr_pair=[0 0]; %default |
---|
[238] | 269 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[174] | 270 | '*.xml', '.xml files '; ... |
---|
| 271 | '*.civ', '.civ files '; ... |
---|
| 272 | '*.png','.png image files'; ... |
---|
| 273 | '*.jpg',' jpeg image files'; ... |
---|
| 274 | '*.tif','.tif image files'; ... |
---|
| 275 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 276 | '*.nc','.netcdf files'; ... |
---|
| 277 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 278 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 279 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 280 | sizf=size(fileinput); |
---|
| 281 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 282 | [path,name,ext]=fileparts(fileinput); |
---|
| 283 | testeditxml=0; |
---|
| 284 | if isequal(ext,'.xml') |
---|
| 285 | testeditxml=1; |
---|
| 286 | t_browse=xmltree(fileinput); |
---|
| 287 | head_element=get(t_browse,1); |
---|
[45] | 288 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 289 | testeditxml=0; |
---|
| 290 | end |
---|
| 291 | end |
---|
[45] | 292 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 293 | heditxml=editxml({fileinput}); |
---|
| 294 | set(heditxml,'Tag','browser') |
---|
| 295 | waitfor(heditxml,'Tag','idle') |
---|
| 296 | if ~ishandle(heditxml) |
---|
| 297 | return |
---|
| 298 | end |
---|
| 299 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 300 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 301 | fileinput=get(attr,'UserData'); |
---|
| 302 | if ~exist(fileinput,'file') |
---|
| 303 | return |
---|
| 304 | end |
---|
[2] | 305 | end |
---|
[82] | 306 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 307 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 308 | num_i1=str2double(str1); |
---|
| 309 | if isnan(num_i1),num_i1=1;end |
---|
| 310 | num_i2=str2double(str2); |
---|
| 311 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 312 | num_j1=stra2num(str_a); |
---|
[89] | 313 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 314 | num_j2=stra2num(str_b); |
---|
[112] | 315 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 316 | if isequal(get(handles.compare,'Value'),1) |
---|
| 317 | browse=[];%initialisation |
---|
| 318 | else |
---|
| 319 | browse=get(handles.browse_root,'UserData'); |
---|
| 320 | end |
---|
[122] | 321 | browse.num_i1=num_i1; |
---|
| 322 | browse.num_i2=num_i2; |
---|
| 323 | browse.num_j1=num_j1; |
---|
| 324 | browse.num_j2=num_j2; |
---|
| 325 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 326 | browse.nom_type_ima=nom_type; |
---|
[122] | 327 | browse.ext_ima=ext; |
---|
[177] | 328 | set(handles.ImaExt,'String',ext) |
---|
[2] | 329 | end |
---|
| 330 | set(handles.ImaDoc,'String',ext); |
---|
| 331 | |
---|
| 332 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 333 | if isequal(ext,'.nc') |
---|
| 334 | browse.nom_type_nc=nom_type; |
---|
[112] | 335 | ind_opening=2;% propose 'fix' as the default option |
---|
[246] | 336 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 337 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 338 | ind_opening=Data.CivStage; |
---|
| 339 | set(handles.CivAll,'Value',3) |
---|
| 340 | end |
---|
| 341 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
| 342 | set(handles.CivAll,'Value',1) |
---|
[2] | 343 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 344 | ind_opening=3; |
---|
| 345 | end |
---|
[246] | 346 | if isequal(Data.patch,1) |
---|
[2] | 347 | ind_opening=4; |
---|
| 348 | end |
---|
[246] | 349 | if isequal(Data.civ2,1) |
---|
[2] | 350 | ind_opening=5; |
---|
| 351 | end |
---|
[246] | 352 | if isequal(Data.fix2,1) |
---|
[2] | 353 | ind_opening=6; |
---|
| 354 | end |
---|
| 355 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 356 | else |
---|
[112] | 357 | ind_opening=3; %GUI used only for patch |
---|
[2] | 358 | testciv=0; |
---|
| 359 | end |
---|
| 360 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 361 | set(handles.subdir_civ2,'String',subdir); |
---|
| 362 | browse.testciv=testciv; |
---|
| 363 | browse.ind_opening=ind_opening; |
---|
| 364 | end |
---|
[71] | 365 | set(handles.RootName,'String',filebase); |
---|
[2] | 366 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 367 | if ~isempty(num_i1) |
---|
[82] | 368 | ref_i=num_i1; |
---|
[45] | 369 | if ~isempty(num_i2) |
---|
| 370 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 371 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 372 | browse.incr_pair(2)=0; |
---|
| 373 | end |
---|
| 374 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 375 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 376 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 377 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 378 | end |
---|
[45] | 379 | if isempty(num_j1) |
---|
[2] | 380 | set(handles.ref_j,'String','1'); |
---|
[71] | 381 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 382 | else |
---|
[45] | 383 | ref_j=num_j1; |
---|
| 384 | if ~isempty(num_j2) |
---|
| 385 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 386 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 387 | end |
---|
| 388 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 389 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 390 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[71] | 391 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 392 | end |
---|
| 393 | |
---|
| 394 | % set default operation options |
---|
| 395 | enable_civ1(handles,'off') |
---|
| 396 | enable_civ2(handles,'off') |
---|
| 397 | enable_pair1(handles,'on') |
---|
| 398 | enable_fix1(handles,'off') |
---|
| 399 | desable_patch1(handles) |
---|
| 400 | desable_fix2(handles) |
---|
| 401 | desable_patch2(handles) |
---|
| 402 | set(handles.CIV1,'Value',0) |
---|
| 403 | set(handles.FIX1,'Value',0) |
---|
| 404 | set(handles.PATCH1,'Value',0) |
---|
| 405 | set(handles.CIV2,'Value',0) |
---|
| 406 | set(handles.FIX2,'Value',0) |
---|
| 407 | set(handles.PATCH2,'Value',0) |
---|
| 408 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 409 | if isequal(ind_opening,1) |
---|
| 410 | set(handles.CIV1,'Value',1) |
---|
| 411 | enable_civ1(handles,'on') |
---|
| 412 | elseif isequal(ind_opening,2) |
---|
| 413 | set(handles.FIX1,'Value',1) |
---|
| 414 | enable_fix1(handles,'on') |
---|
| 415 | elseif isequal(ind_opening,3) |
---|
| 416 | set(handles.PATCH1,'Value',1) |
---|
| 417 | enable_patch1(handles) |
---|
| 418 | elseif isequal(ind_opening,4) |
---|
| 419 | set(handles.CIV2,'Value',1) |
---|
[224] | 420 | enable_civ2(handles,'on') |
---|
[2] | 421 | elseif isequal(ind_opening,5) |
---|
| 422 | enable_pair1(handles,'off') |
---|
| 423 | set(handles.FIX2,'Value',1) |
---|
| 424 | enable_fix2(handles) |
---|
[112] | 425 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 426 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 427 | set(handles.list_pair_civ2,'Enable','On') |
---|
[2] | 428 | elseif isequal(ind_opening,6) |
---|
| 429 | enable_pair1(handles,'off') |
---|
| 430 | set(handles.PATCH2,'Value',1) |
---|
| 431 | enable_patch2(handles) |
---|
| 432 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 433 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 434 | end |
---|
| 435 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 436 | |
---|
[71] | 437 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 438 | |
---|
[12] | 439 | %------------------------------------------------------------------------ |
---|
[2] | 440 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 441 | %------------------------------------------------------------------------ |
---|
[71] | 442 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 443 | |
---|
[12] | 444 | %------------------------------------------------------------------------ |
---|
[54] | 445 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 446 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 447 | %------------------------------------------------------------------------ |
---|
[2] | 448 | set(handles.compare,'Visible','on') |
---|
[122] | 449 | %ext_ima=get(handles.ImaExt,'String'); |
---|
| 450 | ext_ima='';%default |
---|
[2] | 451 | nom_type_ima=[];%default |
---|
| 452 | field_count=1;%default |
---|
| 453 | nom_type_nc=[]; |
---|
| 454 | time=[]; |
---|
[71] | 455 | TimeUnit='frame'; %default |
---|
| 456 | CoordUnit='px';%default |
---|
[2] | 457 | pxcmx_search=[];%default |
---|
| 458 | pxcmy_search=[];%default |
---|
[71] | 459 | filebase=get(handles.RootName,'String'); |
---|
[128] | 460 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[135] | 461 | browse=get(handles.browse_root,'UserData');%default |
---|
[122] | 462 | if isfield(browse,'nom_type_ima') |
---|
| 463 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 464 | end |
---|
| 465 | if isfield(browse,'ext_ima') |
---|
[122] | 466 | ext_ima=browse.ext_ima; |
---|
[2] | 467 | end |
---|
[122] | 468 | if isfield(browse,'nom_type_nc') |
---|
| 469 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 470 | end |
---|
| 471 | if isfield(browse,'num_i1') |
---|
| 472 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 473 | end |
---|
[2] | 474 | |
---|
| 475 | %default first_i and j and increments |
---|
[137] | 476 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 477 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 478 | first_i=1; %default first_i |
---|
| 479 | end |
---|
[137] | 480 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 481 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 482 | last_i=first_i; %default last_i |
---|
| 483 | end |
---|
[137] | 484 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 485 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 486 | first_j=1; %default first_j |
---|
| 487 | end |
---|
[137] | 488 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 489 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 490 | last_j=first_j; %default last_j |
---|
| 491 | end |
---|
[137] | 492 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 493 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 494 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 495 | end |
---|
[137] | 496 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 497 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 498 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 499 | end |
---|
| 500 | dt=[];%default |
---|
| 501 | testmode=0;%default |
---|
| 502 | nbfield=[]; %default |
---|
| 503 | nburst=[];%default |
---|
| 504 | pxcmx=1; |
---|
[112] | 505 | pxcmy=1; |
---|
[2] | 506 | |
---|
[112] | 507 | %look for an image documentation file |
---|
[128] | 508 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 509 | if exist([filebase '.xml'],'file') |
---|
[128] | 510 | ext_imadoc='.xml'; |
---|
[2] | 511 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 512 | ext_imadoc='.civxml'; |
---|
[2] | 513 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 514 | ext_imadoc='.civ'; |
---|
[112] | 515 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 516 | ext_imadoc='.avi'; |
---|
[2] | 517 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 518 | ext_imadoc='.AVI'; |
---|
[2] | 519 | end |
---|
[128] | 520 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 521 | end |
---|
| 522 | |
---|
| 523 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 524 | mode=''; %default |
---|
| 525 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 526 | drawnow |
---|
[128] | 527 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 528 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 529 | set(handles.ref_j,'Visible','On') |
---|
[128] | 530 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 531 | set(handles.ref_j,'Visible','Off') |
---|
| 532 | else |
---|
| 533 | set(handles.ref_i,'Visible','Off') |
---|
| 534 | set(handles.ref_j,'Visible','Off') |
---|
| 535 | end |
---|
[12] | 536 | testima_xml=0; |
---|
[128] | 537 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 538 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 539 | mode='pair j1-j2'; |
---|
| 540 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 541 | nom_type_ima='_i_j'; |
---|
[2] | 542 | end |
---|
[128] | 543 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 544 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 545 | ext_ima_read=[]; |
---|
| 546 | nom_type_read=[]; |
---|
[12] | 547 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 548 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 549 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 550 | if ~exist(fullname,'file') |
---|
[12] | 551 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 552 | end |
---|
[2] | 553 | end |
---|
[84] | 554 | if isfield(XmlData,'Time') |
---|
[85] | 555 | time=XmlData.Time; |
---|
[84] | 556 | nbfield=size(time,1); |
---|
[122] | 557 | nbfield2=size(time,2); |
---|
[127] | 558 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 559 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 560 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 561 | time=time'; |
---|
[122] | 562 | nbfield=nbfield2; |
---|
| 563 | nbfield2=1; |
---|
[84] | 564 | end |
---|
| 565 | end |
---|
| 566 | end |
---|
[71] | 567 | if isfield(XmlData,'TimeUnit') |
---|
| 568 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 569 | end |
---|
[71] | 570 | if isfield(XmlData,'Npx') |
---|
| 571 | npx=XmlData.Npx; |
---|
| 572 | npy=XmlData.Npy; |
---|
| 573 | end |
---|
[2] | 574 | pxcmx_search=1; |
---|
| 575 | pxcmy_search=1; |
---|
| 576 | if isfield(XmlData,'GeometryCalib') |
---|
| 577 | tsai=XmlData.GeometryCalib; |
---|
[112] | 578 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 579 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 580 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 581 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 582 | end |
---|
[112] | 583 | if isfield(tsai,'CoordUnit') |
---|
| 584 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 585 | end |
---|
[112] | 586 | end |
---|
[128] | 587 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 588 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 589 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 590 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 591 | end |
---|
[128] | 592 | nom_type_ima='001a'; |
---|
| 593 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 594 | nom_type_ima='*'; |
---|
[128] | 595 | ext_ima=ext_imadoc; |
---|
[177] | 596 | set(handles.mode,'Value',1); |
---|
[112] | 597 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 598 | dt=0.04;%default |
---|
[128] | 599 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 600 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 601 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 602 | nbfield=info.NumFrames;%number of frames |
---|
| 603 | end |
---|
| 604 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 605 | end |
---|
| 606 | if isempty(time) |
---|
| 607 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 608 | end |
---|
| 609 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 610 | |
---|
[122] | 611 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 612 | dirima=[];%default |
---|
[12] | 613 | if isempty(nom_type_ima) |
---|
| 614 | %look for double image series '_i_j' |
---|
| 615 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 616 | if isempty(dirima) |
---|
[112] | 617 | % look for images series with sub marker '_' |
---|
| 618 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 619 | if isempty(dirima) |
---|
| 620 | % look for other images series |
---|
| 621 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 622 | if isempty(dirima) |
---|
| 623 | % look for other images series witth letter appendix |
---|
| 624 | appendix=char(96+first_j); |
---|
| 625 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 626 | end |
---|
| 627 | end |
---|
[12] | 628 | end |
---|
[112] | 629 | end |
---|
[122] | 630 | for ilist=1:numel(dirima) |
---|
| 631 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 632 | form=imformats(ext_list(2:end)); |
---|
| 633 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 634 | ext_ima=ext_list; |
---|
| 635 | nom_type_ima=nom_type_list; |
---|
| 636 | break |
---|
| 637 | end |
---|
| 638 | end |
---|
| 639 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 640 | if isempty(nom_type_ima) |
---|
[128] | 641 | ext_search=ext_imadoc; |
---|
[122] | 642 | nom_type_search=nom_type_nc; |
---|
| 643 | else |
---|
| 644 | ext_search=ext_ima; |
---|
| 645 | nom_type_search=nom_type_ima; |
---|
| 646 | end |
---|
| 647 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[12] | 648 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 649 | incr_pair=[0 0];%default |
---|
| 650 | if isfield(browse,'incr_pair') |
---|
[112] | 651 | incr_pair=browse.incr_pair; |
---|
[12] | 652 | end |
---|
[112] | 653 | % nbdetect=0;%test of detected images |
---|
[122] | 654 | field_i=browse.num_i2; |
---|
[153] | 655 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
| 656 | imagename_plus=''; |
---|
[12] | 657 | idetect=1; |
---|
[153] | 658 | while idetect %look for the maximum file number in the series |
---|
| 659 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
| 660 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[81] | 661 | if idetect |
---|
[12] | 662 | field_i=field_i+1; |
---|
[81] | 663 | end |
---|
[112] | 664 | %SEE CASE OF NETCDF FILES |
---|
| 665 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 666 | end |
---|
[122] | 667 | nbfield=field_i;% last detected field number |
---|
| 668 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[153] | 669 | imagename_min=''; |
---|
[12] | 670 | idetect=1; |
---|
[112] | 671 | while idetect==1 |
---|
[153] | 672 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
| 673 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
[81] | 674 | if idetect |
---|
[112] | 675 | field_i=field_i-1; |
---|
[81] | 676 | end |
---|
[12] | 677 | end |
---|
[122] | 678 | first_i=max(field_i,1); |
---|
| 679 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 680 | field_i=browse.num_i1; |
---|
| 681 | field_j=browse.num_j2; |
---|
[177] | 682 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[153] | 683 | imagename_plus=''; |
---|
[89] | 684 | jdetect=1; |
---|
| 685 | while jdetect==1 %look for the maximum file number in the series |
---|
[153] | 686 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
| 687 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[89] | 688 | if jdetect |
---|
| 689 | field_j=field_j+1; |
---|
| 690 | end |
---|
| 691 | %SEE CASE OF NETCDF FILES |
---|
| 692 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 693 | end |
---|
[122] | 694 | nbfield2=field_j;% last detected field number |
---|
[120] | 695 | end |
---|
[122] | 696 | |
---|
[89] | 697 | %determine the set of times and possible intervals for CIV |
---|
[137] | 698 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 699 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 700 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 701 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 702 | time=x+y; |
---|
[89] | 703 | end |
---|
[2] | 704 | end |
---|
[120] | 705 | |
---|
[2] | 706 | if exist('time','var') |
---|
| 707 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 708 | nbfield=size(time,1); |
---|
| 709 | nbfield2=size(time,2); |
---|
[71] | 710 | set(handles.RootName,'UserData',time); %store the set of times |
---|
| 711 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 712 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
| 713 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 714 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 715 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 716 | end |
---|
| 717 | end |
---|
[71] | 718 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[2] | 719 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 720 | % npxy=[npy npx]; |
---|
[71] | 721 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 722 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 723 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 724 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 725 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 726 | browse.nom_type_ima=nom_type_ima; |
---|
| 727 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 728 | |
---|
[112] | 729 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 730 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 731 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 732 | set(handles.mode,'Value',1) |
---|
[177] | 733 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 734 | elseif (nbfield==1)% simple series in j |
---|
[177] | 735 | set(handles.mode,'Value',1) |
---|
[2] | 736 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 737 | else |
---|
| 738 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 739 | if nbfield2 <= 10 |
---|
[112] | 740 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 741 | end |
---|
| 742 | end |
---|
| 743 | |
---|
[112] | 744 | %update the subdir |
---|
[2] | 745 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 746 | listot=dir(pathdir); |
---|
| 747 | idir=0; |
---|
| 748 | listdir={''};%default |
---|
| 749 | for ilist=1:length(listot) |
---|
| 750 | if listot(ilist).isdir |
---|
| 751 | name=listot(ilist).name; |
---|
| 752 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 753 | idir=idir+1; |
---|
| 754 | listdir{idir,1}=listot(ilist).name; |
---|
| 755 | end |
---|
| 756 | end |
---|
| 757 | end |
---|
[112] | 758 | set(handles.list_subdir_civ1,'Value',1) |
---|
[2] | 759 | set(handles.list_subdir_civ2,'Value',1) |
---|
[107] | 760 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
---|
| 761 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
---|
[2] | 762 | %check wether the current subdir exists: |
---|
| 763 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 764 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 765 | |
---|
[112] | 766 | mode_Callback(hObject, eventdata, handles) |
---|
[2] | 767 | |
---|
[177] | 768 | %% desable status and RUN button |
---|
[150] | 769 | % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 770 | % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 771 | % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 772 | % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
[2] | 773 | set(handles.RUN, 'Enable','On') |
---|
| 774 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 775 | set(handles.BATCH,'Enable','On') |
---|
| 776 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[178] | 777 | if isfield(handles,'status') |
---|
[177] | 778 | set(handles.status,'Value',0);%suppress status display |
---|
| 779 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 780 | end |
---|
[112] | 781 | |
---|
[177] | 782 | %% store the root input filename for future opening |
---|
[2] | 783 | dir_perso=prefdir; |
---|
| 784 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 785 | RootPath=fileparts(filebase); |
---|
| 786 | if exist(profil_perso,'file') |
---|
| 787 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 788 | else |
---|
[147] | 789 | txt=ver('MATLAB'); |
---|
| 790 | Release=txt.Release; |
---|
[137] | 791 | relnumb=str2double(Release(3:4)); |
---|
[2] | 792 | if relnumb >= 14 |
---|
[112] | 793 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 794 | else |
---|
| 795 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 796 | end |
---|
| 797 | end |
---|
| 798 | |
---|
[12] | 799 | %------------------------------------------------------------------------ |
---|
[2] | 800 | % --- Executes on button press in mode. |
---|
| 801 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 802 | %------------------------------------------------------------------------ |
---|
[2] | 803 | browse=get(handles.browse_root,'UserData'); |
---|
| 804 | compare_list=get(handles.compare,'String'); |
---|
| 805 | val=get(handles.compare,'Value'); |
---|
| 806 | compare=compare_list{val}; |
---|
| 807 | if strcmp(compare,'displacement') |
---|
| 808 | mode='displacement'; |
---|
| 809 | else |
---|
| 810 | mode_list=get(handles.mode,'String'); |
---|
[236] | 811 | if ischar(mode_list) |
---|
| 812 | mode_list={mode_list}; |
---|
| 813 | end |
---|
[2] | 814 | mode_value=get(handles.mode,'Value'); |
---|
| 815 | mode=mode_list{mode_value}; |
---|
| 816 | end |
---|
| 817 | displ_num=[];%default |
---|
[137] | 818 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 819 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[71] | 820 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 821 | siztime=size(time); |
---|
| 822 | nbfield=siztime(1); |
---|
| 823 | nbfield2=siztime(2); |
---|
| 824 | indchosen=1; %%first pair selected by default |
---|
| 825 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 826 | dt=1; |
---|
| 827 | displ=''; |
---|
| 828 | index=0; |
---|
| 829 | numlist_a=[]; |
---|
| 830 | numlist_B=[]; |
---|
| 831 | %get all the time intervals in bursts |
---|
| 832 | displ_dt=1;%default |
---|
| 833 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 834 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 835 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 836 | index=index+1; |
---|
| 837 | numlist_a(index)=numod_a; |
---|
| 838 | numlist_b(index)=numod_b; |
---|
| 839 | if ~isempty(time) |
---|
[54] | 840 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 841 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 842 | else |
---|
| 843 | displ_dt(index)=1; |
---|
| 844 | end |
---|
| 845 | end |
---|
| 846 | end |
---|
| 847 | [dtsort,indsort]=sort(displ_dt); |
---|
| 848 | if ~isempty(numlist_a) |
---|
| 849 | displ_num(1,:)=numlist_a(indsort); |
---|
| 850 | displ_num(2,:)=numlist_b(indsort); |
---|
| 851 | end |
---|
| 852 | displ_num(3,:)=0; |
---|
| 853 | displ_num(4,:)=0; |
---|
| 854 | set(handles.jtext,'Visible','Off') |
---|
[2] | 855 | set(handles.first_j,'Visible','Off') |
---|
| 856 | set(handles.last_j,'Visible','Off') |
---|
| 857 | set(handles.incr_j,'Visible','Off') |
---|
| 858 | set(handles.nb_field2,'Visible','Off') |
---|
| 859 | set(handles.ref_j,'Visible','Off') |
---|
| 860 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 861 | for index=1:min(nbfield2-1,200) |
---|
| 862 | displ_num(1,index)=-floor(index/2); |
---|
| 863 | displ_num(2,index)=ceil(index/2); |
---|
| 864 | displ_num(3,index)=0; |
---|
| 865 | displ_num(4,index)=0; |
---|
| 866 | end |
---|
| 867 | set(handles.jtext,'Visible','On') |
---|
| 868 | set(handles.first_j,'Visible','On') |
---|
| 869 | set(handles.last_j,'Visible','On') |
---|
| 870 | set(handles.incr_j,'Visible','On') |
---|
| 871 | set(handles.nb_field2,'Visible','On') |
---|
| 872 | set(handles.ref_j,'Visible','On') |
---|
| 873 | if nbfield > 1 |
---|
[2] | 874 | set(handles.itext,'Visible','On') |
---|
| 875 | set(handles.first_i,'Visible','On') |
---|
| 876 | set(handles.last_i,'Visible','On') |
---|
| 877 | set(handles.incr_i,'Visible','On') |
---|
| 878 | set(handles.nb_field,'Visible','On') |
---|
| 879 | set(handles.ref_i,'Visible','On') |
---|
| 880 | else |
---|
| 881 | set(handles.itext,'Visible','Off') |
---|
| 882 | set(handles.first_i,'Visible','Off') |
---|
| 883 | set(handles.last_i,'Visible','Off') |
---|
| 884 | set(handles.incr_i,'Visible','Off') |
---|
| 885 | set(handles.nb_field,'Visible','Off') |
---|
| 886 | set(handles.ref_i,'Visible','Off') |
---|
| 887 | end |
---|
[112] | 888 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 889 | for index=1:200%min(nbfield-1,200) |
---|
| 890 | displ_num(1,index)=0; |
---|
| 891 | displ_num(2,index)=0; |
---|
| 892 | displ_num(3,index)=-floor(index/2); |
---|
| 893 | displ_num(4,index)=ceil(index/2); |
---|
| 894 | end |
---|
| 895 | set(handles.itext,'Visible','On') |
---|
| 896 | set(handles.first_i,'Visible','On') |
---|
| 897 | set(handles.last_i,'Visible','On') |
---|
| 898 | set(handles.incr_i,'Visible','On') |
---|
| 899 | set(handles.nb_field,'Visible','On') |
---|
| 900 | set(handles.ref_i,'Visible','On') |
---|
| 901 | if nbfield2 > 1 |
---|
[2] | 902 | set(handles.jtext,'Visible','On') |
---|
| 903 | set(handles.first_j,'Visible','On') |
---|
| 904 | set(handles.last_j,'Visible','On') |
---|
| 905 | set(handles.incr_j,'Visible','On') |
---|
| 906 | set(handles.nb_field2,'Visible','On') |
---|
| 907 | set(handles.ref_j,'Visible','On') |
---|
[112] | 908 | else |
---|
[2] | 909 | set(handles.jtext,'Visible','Off') |
---|
| 910 | set(handles.first_j,'Visible','Off') |
---|
| 911 | set(handles.last_j,'Visible','Off') |
---|
| 912 | set(handles.incr_j,'Visible','Off') |
---|
| 913 | set(handles.nb_field2,'Visible','Off') |
---|
| 914 | set(handles.ref_j,'Visible','Off') |
---|
| 915 | end |
---|
| 916 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 917 | displ_num(1,1)=0; |
---|
| 918 | displ_num(2,1)=0; |
---|
| 919 | displ_num(3,1)=0; |
---|
| 920 | displ_num(4,1)=0; |
---|
| 921 | if nbfield > 1 |
---|
[2] | 922 | set(handles.itext,'Visible','On') |
---|
| 923 | set(handles.first_i,'Visible','On') |
---|
| 924 | set(handles.last_i,'Visible','On') |
---|
| 925 | set(handles.incr_i,'Visible','On') |
---|
| 926 | set(handles.nb_field,'Visible','On') |
---|
| 927 | set(handles.ref_i,'Visible','On') |
---|
| 928 | else |
---|
| 929 | set(handles.itext,'Visible','Off') |
---|
| 930 | set(handles.first_i,'Visible','Off') |
---|
| 931 | set(handles.last_i,'Visible','Off') |
---|
| 932 | set(handles.incr_i,'Visible','Off') |
---|
| 933 | set(handles.nb_field,'Visible','Off') |
---|
| 934 | set(handles.ref_i,'Visible','Off') |
---|
| 935 | end |
---|
| 936 | if nbfield2 > 1 |
---|
[112] | 937 | set(handles.jtext,'Visible','On') |
---|
| 938 | set(handles.first_j,'Visible','On') |
---|
| 939 | set(handles.last_j,'Visible','On') |
---|
| 940 | set(handles.incr_j,'Visible','On') |
---|
| 941 | set(handles.nb_field2,'Visible','On') |
---|
| 942 | set(handles.ref_j,'Visible','On') |
---|
[2] | 943 | else |
---|
| 944 | set(handles.jtext,'Visible','Off') |
---|
| 945 | set(handles.first_j,'Visible','Off') |
---|
| 946 | set(handles.last_j,'Visible','Off') |
---|
| 947 | set(handles.incr_j,'Visible','Off') |
---|
| 948 | set(handles.nb_field2,'Visible','Off') |
---|
| 949 | set(handles.ref_j,'Visible','Off') |
---|
| 950 | end |
---|
[112] | 951 | end |
---|
[2] | 952 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 953 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 954 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 955 | |
---|
[12] | 956 | %------------------------------------------------------------------------ |
---|
[2] | 957 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 958 | % the field series set by first_i, incr, last_i |
---|
| 959 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 960 | %------------------------------------------------------------------------ |
---|
[2] | 961 | set(gcf,'Pointer','watch') |
---|
| 962 | %nomenclature types |
---|
[71] | 963 | filebase=get(handles.RootName,'String'); |
---|
[2] | 964 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 965 | browse=get(handles.browse_root,'UserData'); |
---|
| 966 | compare_list=get(handles.compare,'String'); |
---|
| 967 | val=get(handles.compare,'Value'); |
---|
| 968 | compare=compare_list{val}; |
---|
| 969 | if strcmp(compare,'displacement') |
---|
| 970 | mode='displacement'; |
---|
| 971 | else |
---|
| 972 | mode_list=get(handles.mode,'String'); |
---|
| 973 | mode_value=get(handles.mode,'Value'); |
---|
| 974 | mode=mode_list{mode_value}; |
---|
| 975 | end |
---|
| 976 | |
---|
| 977 | % nomenclature type of the .nc files |
---|
| 978 | nom_type_ima=[];%default |
---|
| 979 | if isfield(browse,'nom_type_ima') |
---|
| 980 | nom_type_ima=browse.nom_type_ima; |
---|
| 981 | end |
---|
| 982 | |
---|
[112] | 983 | %determine nom_type_nc: |
---|
[2] | 984 | nom_type_nc=[];%default |
---|
| 985 | if isfield(browse,'nom_type_nc') |
---|
| 986 | nom_type_nc=browse.nom_type_nc; |
---|
| 987 | end |
---|
| 988 | if isempty(nom_type_nc) |
---|
[112] | 989 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 990 | end |
---|
| 991 | browse.nom_type_nc=nom_type_nc; |
---|
| 992 | set(handles.browse_root,'UserData',browse) |
---|
| 993 | |
---|
| 994 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 995 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 996 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 997 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 998 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 999 | % num1=first_i:incr:last_i; |
---|
| 1000 | % if isempty(num1) |
---|
| 1001 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1002 | % return |
---|
| 1003 | % end |
---|
| 1004 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1005 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1006 | ref_j=0; |
---|
| 1007 | else |
---|
[45] | 1008 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1009 | end |
---|
[71] | 1010 | time=get(handles.RootName,'UserData');%get the set of times |
---|
[2] | 1011 | if isempty(time) |
---|
| 1012 | time=[0 1]; |
---|
[112] | 1013 | end |
---|
[71] | 1014 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1015 | dt_unit=1000;%default |
---|
[2] | 1016 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1017 | |
---|
[112] | 1018 | %eliminate the first pairs inconsistent with the position |
---|
| 1019 | if isempty(displ_num) |
---|
| 1020 | nbpair=0; |
---|
| 1021 | else |
---|
[2] | 1022 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1023 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1024 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1025 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1026 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1027 | end |
---|
[112] | 1028 | end |
---|
[2] | 1029 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1030 | |
---|
[112] | 1031 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1032 | % be performed, while the result is needed for next steps. |
---|
| 1033 | displ_pair={''}; |
---|
| 1034 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1035 | testpair=0; |
---|
| 1036 | if get(handles.CIV1,'Value')==0 % |
---|
[112] | 1037 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1038 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1039 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1040 | return |
---|
[2] | 1041 | end |
---|
[112] | 1042 | for ipair=1:nbpair |
---|
[2] | 1043 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1044 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1045 | select(ipair)=exist(filename,'file')==2; |
---|
| 1046 | end |
---|
| 1047 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1048 | if isfield(browse,'incr_pair') |
---|
[2] | 1049 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1050 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1051 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1052 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1053 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1054 | select(1)=exist(filename,'file')==2; |
---|
| 1055 | testpair=1; |
---|
| 1056 | else |
---|
[112] | 1057 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1058 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1059 | else |
---|
| 1060 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1061 | end |
---|
[112] | 1062 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1063 | %COMPLETER CAS STEREO |
---|
[2] | 1064 | return |
---|
| 1065 | end |
---|
| 1066 | end |
---|
| 1067 | end |
---|
| 1068 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1069 | if testpair |
---|
[73] | 1070 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1071 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
| 1072 | % for ipair=1:nbpair |
---|
| 1073 | % if select(ipair) |
---|
| 1074 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1075 | % dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1076 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1077 | % end |
---|
| 1078 | % else |
---|
| 1079 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1080 | % end |
---|
| 1081 | % end |
---|
[2] | 1082 | else |
---|
[73] | 1083 | for ipair=1:nbpair |
---|
| 1084 | if select(ipair) |
---|
| 1085 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1086 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1087 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1088 | else |
---|
| 1089 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1090 | end |
---|
| 1091 | end |
---|
| 1092 | end |
---|
[2] | 1093 | end |
---|
| 1094 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1095 | if testpair |
---|
[112] | 1096 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1097 | else |
---|
[112] | 1098 | for ipair=1:nbpair |
---|
| 1099 | if select(ipair) |
---|
| 1100 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1101 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1102 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1103 | end |
---|
| 1104 | elseif testpair |
---|
| 1105 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1106 | else |
---|
| 1107 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1108 | end |
---|
| 1109 | end |
---|
| 1110 | end |
---|
[2] | 1111 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1112 | for ipair=1:nbpair |
---|
| 1113 | if select(ipair) |
---|
[112] | 1114 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
| 1115 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1116 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1117 | else |
---|
| 1118 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1119 | end |
---|
| 1120 | end |
---|
[2] | 1121 | elseif isequal(mode,'displacement') |
---|
[112] | 1122 | displ_pair={'Di=Dj=0'}; |
---|
| 1123 | end |
---|
[2] | 1124 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
[229] | 1125 | ichoice=find(select,1); |
---|
[45] | 1126 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1127 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
[112] | 1128 | if initial>nbpair |
---|
| 1129 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1130 | end |
---|
| 1131 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1132 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1133 | end |
---|
[45] | 1134 | |
---|
[2] | 1135 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1136 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1137 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1138 | if ichoice <= length(displ_pair') |
---|
| 1139 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1140 | else |
---|
| 1141 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1142 | end |
---|
| 1143 | end |
---|
| 1144 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1145 | set(gcf,'Pointer','arrow') |
---|
[12] | 1146 | |
---|
| 1147 | %------------------------------------------------------------------------ |
---|
[112] | 1148 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1149 | %middle of the series set by first_i, incr, last_i |
---|
[2] | 1150 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1151 | %------------------------------------------------------------------------ |
---|
[2] | 1152 | set(gcf,'Pointer','watch') |
---|
| 1153 | %nomenclature types |
---|
[71] | 1154 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1155 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1156 | browse=get(handles.browse_root,'UserData'); |
---|
| 1157 | compare_list=get(handles.compare,'String'); |
---|
| 1158 | val=get(handles.compare,'Value'); |
---|
| 1159 | compare=compare_list{val}; |
---|
| 1160 | if strcmp(compare,'displacement') |
---|
| 1161 | mode='displacement'; |
---|
| 1162 | else |
---|
| 1163 | mode_list=get(handles.mode,'String'); |
---|
| 1164 | mode_value=get(handles.mode,'Value'); |
---|
| 1165 | mode=mode_list{mode_value}; |
---|
| 1166 | end |
---|
| 1167 | |
---|
| 1168 | % nomenclature type of the .nc files |
---|
| 1169 | nom_type_ima='ima_num';%default |
---|
| 1170 | if isfield(browse,'nom_type_ima') |
---|
| 1171 | nom_type_ima=browse.nom_type_ima; |
---|
| 1172 | end |
---|
| 1173 | nom_type_nc='_i1-i2';%default |
---|
| 1174 | if isfield(browse,'nom_type_nc') |
---|
| 1175 | nom_type_nc=browse.nom_type_nc; |
---|
| 1176 | end |
---|
[94] | 1177 | if isequal(nom_type_ima,'png_old') || isequal(nom_type_ima,'netc_old')|| isequal(nom_type_ima,'raw_SMD')|| isequal(nom_type_nc,'netc_old') |
---|
[2] | 1178 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1179 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1180 | nom_type_nc='none'; |
---|
[94] | 1181 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1182 | nom_type_nc='_i1-i2'; |
---|
[2] | 1183 | else |
---|
| 1184 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1185 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1186 | else |
---|
| 1187 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1188 | end |
---|
[2] | 1189 | end |
---|
| 1190 | browse.nom_type_nc=nom_type_nc; |
---|
| 1191 | set(handles.browse_root,'UserData',browse) |
---|
| 1192 | |
---|
| 1193 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1194 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1195 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1196 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1197 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1198 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1199 | % num1=first_i:incr:last_i; |
---|
| 1200 | % if isempty(num1) |
---|
| 1201 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1202 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1203 | % return |
---|
| 1204 | % end |
---|
[137] | 1205 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
---|
[2] | 1206 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1207 | ref_j=0; |
---|
| 1208 | else |
---|
[137] | 1209 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
---|
[2] | 1210 | end |
---|
[71] | 1211 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 1212 | if isempty(time) |
---|
| 1213 | time=[0 1];%default |
---|
| 1214 | end |
---|
[71] | 1215 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1216 | %dt_unit=1000; |
---|
[2] | 1217 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1218 | |
---|
| 1219 | |
---|
[112] | 1220 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1221 | if isempty(displ_num) |
---|
| 1222 | nbpair=0; |
---|
| 1223 | else |
---|
| 1224 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1225 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1226 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1227 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1228 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1229 | end |
---|
| 1230 | end |
---|
| 1231 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1232 | |
---|
[112] | 1233 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1234 | % be performed, while the result is needed for next steps. |
---|
| 1235 | displ_pair={''}; %default |
---|
| 1236 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1237 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
[112] | 1238 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1239 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1240 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1241 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1242 | return |
---|
[2] | 1243 | end |
---|
[112] | 1244 | for ipair=1:nbpair |
---|
[2] | 1245 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1246 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1247 | select(ipair)=exist(filename,'file')==2; |
---|
| 1248 | end |
---|
| 1249 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1250 | if isfield(browse,'incr_pair') |
---|
[2] | 1251 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1252 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1253 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1254 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1255 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1256 | select(1)=exist(filename,'file')==2; |
---|
| 1257 | else |
---|
[112] | 1258 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1259 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1260 | else |
---|
| 1261 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1262 | end |
---|
[112] | 1263 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1264 | set(handles.list_pair_civ2,'String',{''}); |
---|
[2] | 1265 | return |
---|
| 1266 | end |
---|
| 1267 | end |
---|
| 1268 | end |
---|
[112] | 1269 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1270 | for ipair=1:nbpair |
---|
| 1271 | if select(ipair) |
---|
| 1272 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1273 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1274 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1275 | end |
---|
| 1276 | else |
---|
| 1277 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1278 | end |
---|
| 1279 | end |
---|
[2] | 1280 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1281 | for ipair=1:nbpair |
---|
| 1282 | if select(ipair) |
---|
| 1283 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1284 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1285 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1286 | end |
---|
| 1287 | else |
---|
| 1288 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1289 | end |
---|
| 1290 | end |
---|
[2] | 1291 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1292 | for ipair=1:nbpair |
---|
| 1293 | if select(ipair) |
---|
[112] | 1294 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
| 1295 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1296 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1297 | else |
---|
| 1298 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1299 | end |
---|
| 1300 | end |
---|
[2] | 1301 | elseif isequal(mode,'displacement') |
---|
[112] | 1302 | displ_pair={'Di=Dj=0'}; |
---|
| 1303 | end |
---|
[2] | 1304 | val=get(handles.list_pair_civ2,'Value'); |
---|
[229] | 1305 | ichoice=find(select,1); |
---|
[137] | 1306 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1307 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
[2] | 1308 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1309 | end |
---|
| 1310 | if val>length(displ_pair') |
---|
| 1311 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1312 | else |
---|
| 1313 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1314 | end |
---|
| 1315 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1316 | set(gcf,'Pointer','arrow') |
---|
[2] | 1317 | |
---|
| 1318 | |
---|
[41] | 1319 | |
---|
[227] | 1320 | |
---|
[12] | 1321 | %------------------------------------------------------------------------ |
---|
[2] | 1322 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1323 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1324 | %------------------------------------------------------------------------ |
---|
[2] | 1325 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1326 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1327 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1328 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[137] | 1329 | % num_a=displ_num(1,index_pair); |
---|
| 1330 | % num_b=displ_num(2,index_pair); |
---|
[2] | 1331 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1332 | if index_pair<=length(list_pair2) |
---|
| 1333 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1334 | end |
---|
| 1335 | |
---|
[112] | 1336 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1337 | mode_list=get(handles.mode,'String'); |
---|
| 1338 | mode_value=get(handles.mode,'Value'); |
---|
| 1339 | mode=mode_list{mode_value}; |
---|
| 1340 | if isequal(mode,'series(Di)') |
---|
[137] | 1341 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1342 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1343 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1344 | num1=first_i:incr_i:last_i; |
---|
[137] | 1345 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1346 | if ~isnan(lastfield) |
---|
[229] | 1347 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1348 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1349 | num1=num1(test_find); |
---|
[2] | 1350 | end |
---|
| 1351 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1352 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1353 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1354 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1355 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1356 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1357 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1358 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1359 | if ~isnan(lastfield2) |
---|
[229] | 1360 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1361 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1362 | num1=num_j(test_find); |
---|
[2] | 1363 | end |
---|
| 1364 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1365 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1366 | end |
---|
[2] | 1367 | |
---|
[12] | 1368 | %------------------------------------------------------------------------ |
---|
[2] | 1369 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1370 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1371 | %------------------------------------------------------------------------ |
---|
[112] | 1372 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
[2] | 1373 | |
---|
[112] | 1374 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1375 | mode_list=get(handles.mode,'String'); |
---|
| 1376 | mode_value=get(handles.mode,'Value'); |
---|
| 1377 | mode=mode_list{mode_value}; |
---|
| 1378 | if isequal(mode,'series(Di)') |
---|
[137] | 1379 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1380 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1381 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1382 | num1=first_i:incr_i:last_i; |
---|
[137] | 1383 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1384 | if ~isnan(lastfield) |
---|
[229] | 1385 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1386 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1387 | num1=num1(test_find); |
---|
[2] | 1388 | end |
---|
| 1389 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1390 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1391 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1392 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1393 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1394 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1395 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1396 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1397 | if ~isnan(lastfield2) |
---|
[229] | 1398 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1399 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1400 | num1=num_j(test_find); |
---|
[2] | 1401 | end |
---|
| 1402 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1403 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1404 | end |
---|
[2] | 1405 | |
---|
[177] | 1406 | %------------------------------------------------------------------------ |
---|
| 1407 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1408 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1409 | %------------------------------------------------------------------------ |
---|
[73] | 1410 | set(handles.RUN, 'Enable','Off') |
---|
| 1411 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1412 | batch=0; |
---|
[229] | 1413 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1414 | set(handles.RUN, 'Enable','On') |
---|
| 1415 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1416 | |
---|
[177] | 1417 | % start status callback to visualise results |
---|
[229] | 1418 | if ~isempty(errormsg) |
---|
| 1419 | display(errormsg) |
---|
| 1420 | msgbox_uvmat('ERROR',errormsg) |
---|
[236] | 1421 | elseif isfield(handles,'status') %&& ~isequal(get(handles.CivAll,'Value'),3) |
---|
[225] | 1422 | set(handles.status,'Value',1);%suppress status display |
---|
| 1423 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1424 | end |
---|
[177] | 1425 | |
---|
[12] | 1426 | %------------------------------------------------------------------------ |
---|
[2] | 1427 | % --- Executes on button press in BATCH: remote processing |
---|
| 1428 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1429 | % ----------------------------------------------------------------------- |
---|
[73] | 1430 | set(handles.BATCH, 'Enable','Off') |
---|
| 1431 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1432 | batch=1; |
---|
[229] | 1433 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1434 | set(handles.BATCH, 'Enable','On') |
---|
| 1435 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1436 | |
---|
[177] | 1437 | % start status callback to visualise results |
---|
[229] | 1438 | if ~isempty(errormsg) |
---|
| 1439 | display(errormsg) |
---|
| 1440 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1441 | elseif isfield(handles,'status') |
---|
| 1442 | set(handles.status,'Value',1);%suppress status display |
---|
| 1443 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1444 | end |
---|
[227] | 1445 | |
---|
[67] | 1446 | %------------------------------------------------------------------------ |
---|
[133] | 1447 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1448 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1449 | %----------------------------------------------------------------------- |
---|
[229] | 1450 | errormsg='';%default |
---|
[133] | 1451 | %% check the selected list of operations: |
---|
[2] | 1452 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1453 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1454 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1455 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1456 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1457 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1458 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
[180] | 1459 | index_first=find(box_test==1,1); |
---|
| 1460 | if isempty(index_first) |
---|
[229] | 1461 | errormsg='no selected operation'; |
---|
[2] | 1462 | return |
---|
| 1463 | end |
---|
[180] | 1464 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1465 | box_used=box_test(index_first : index_last); |
---|
[2] | 1466 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1467 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1468 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1469 | return |
---|
| 1470 | end |
---|
| 1471 | |
---|
[177] | 1472 | %% check mask if selecetd |
---|
[2] | 1473 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1474 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1475 | if ~exist(maskname,'file') |
---|
| 1476 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1477 | end |
---|
[2] | 1478 | end |
---|
| 1479 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1480 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1481 | if ~exist(maskname,'file') |
---|
| 1482 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1483 | end |
---|
[2] | 1484 | end |
---|
| 1485 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1486 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1487 | if ~exist(maskname,'file') |
---|
[112] | 1488 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1489 | end |
---|
[2] | 1490 | end |
---|
| 1491 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1492 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1493 | if ~exist(maskname,'file') |
---|
[112] | 1494 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1495 | end |
---|
[2] | 1496 | end |
---|
| 1497 | |
---|
[177] | 1498 | %% reinitialise status callback |
---|
[178] | 1499 | if isfield(handles,'status') |
---|
[180] | 1500 | set(handles.status,'Value',0);%suppress status display |
---|
| 1501 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1502 | end |
---|
[133] | 1503 | |
---|
| 1504 | %% set the list of files and check them |
---|
| 1505 | display('checking the files...') |
---|
[227] | 1506 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1507 | if ~isempty(errormsg) |
---|
| 1508 | return |
---|
| 1509 | end |
---|
[133] | 1510 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=... |
---|
[227] | 1511 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[177] | 1512 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1513 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1514 | return |
---|
| 1515 | end |
---|
| 1516 | nbfield=numel(num1_civ1); |
---|
| 1517 | nbslice=numel(num_a_civ1); |
---|
| 1518 | |
---|
| 1519 | %% read names of the .exe files for PIV and patch |
---|
| 1520 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
[112] | 1521 | xmlfile='PARAM.xml'; |
---|
[133] | 1522 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1523 | t=xmltree(xmlfile); |
---|
[67] | 1524 | s=convert(t); |
---|
[2] | 1525 | end |
---|
[127] | 1526 | test_interp=0; |
---|
| 1527 | if batch |
---|
[67] | 1528 | if isfield(s,'BatchParam') |
---|
| 1529 | sparam=s.BatchParam; |
---|
| 1530 | if ~ismember(sparam.BatchMode,{'sge'}) |
---|
[229] | 1531 | errormsg=['batch mode ' sparam.BatchMode ' not supported by UVMAT']; |
---|
| 1532 | return |
---|
[67] | 1533 | end |
---|
| 1534 | else |
---|
[229] | 1535 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1536 | return |
---|
| 1537 | end |
---|
[225] | 1538 | if isfield(sparam,'BatchMode') |
---|
| 1539 | batch_mode=sparam.BatchMode; |
---|
| 1540 | end |
---|
| 1541 | % choice of batch priority: |
---|
| 1542 | ind_answer=2; |
---|
| 1543 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1544 | if isequal(s,0) |
---|
| 1545 | w(end)=[]; |
---|
[232] | 1546 | str_displ={[w ' jobs in the waiting list'];... |
---|
| 1547 | '***********************';... |
---|
| 1548 | 'JOBS PRIORITY POLICY';... |
---|
| 1549 | '- urgent = less than 100 images pairs';... |
---|
| 1550 | '- normal = during the experiments';... |
---|
| 1551 | '- low = post processing';... |
---|
| 1552 | '***********************';... |
---|
| 1553 | 'Select a priority:'}; |
---|
| 1554 | ' ';... |
---|
| 1555 | str={'urgent';'normal';'low'}; |
---|
[225] | 1556 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1557 | 'SelectionMode','single',... |
---|
[232] | 1558 | 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); |
---|
[225] | 1559 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
[229] | 1560 | errormsg='job cancelled'; |
---|
[225] | 1561 | return % a better way should be create |
---|
| 1562 | end |
---|
| 1563 | else |
---|
| 1564 | msgbox_uvmat('ERROR','sge batch system not available') |
---|
| 1565 | return |
---|
| 1566 | end |
---|
[67] | 1567 | else |
---|
| 1568 | if isfield(s,'RunParam') |
---|
| 1569 | sparam=s.RunParam; |
---|
| 1570 | else |
---|
[225] | 1571 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1572 | return |
---|
| 1573 | end |
---|
[225] | 1574 | end |
---|
[238] | 1575 | |
---|
| 1576 | %% choose the civ program |
---|
| 1577 | ProgList=get(handles.CivAll,'String'); |
---|
| 1578 | index=get(handles.CivAll,'Value'); |
---|
| 1579 | CivX=isequal(ProgList{index},'CivX'); |
---|
| 1580 | CivAll=isequal(ProgList{index},'CivAll'); |
---|
| 1581 | CivUvmat=isequal(ProgList{index},'CivUvmat'); |
---|
| 1582 | %CivAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs |
---|
| 1583 | if CivAll && isfield(sparam,'CivBin') |
---|
[225] | 1584 | CivBin=sparam.CivBin; |
---|
| 1585 | if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat |
---|
| 1586 | sparam.CivBin=fullfile(path_UVMAT,CivBin); |
---|
| 1587 | if ~exist(sparam.CivBin,'file') |
---|
| 1588 | msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) |
---|
| 1589 | return |
---|
[112] | 1590 | end |
---|
[94] | 1591 | end |
---|
[225] | 1592 | end |
---|
| 1593 | if isfield(sparam,'Civ1Bin') |
---|
| 1594 | Civ1Bin=sparam.Civ1Bin; |
---|
| 1595 | if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat |
---|
| 1596 | sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); |
---|
| 1597 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 1598 | msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) |
---|
| 1599 | return |
---|
[112] | 1600 | end |
---|
[94] | 1601 | end |
---|
[225] | 1602 | end |
---|
| 1603 | if isfield(sparam,'Civ2Bin') |
---|
| 1604 | Civ2Bin=sparam.Civ2Bin; |
---|
| 1605 | if ~exist(Civ2Bin,'file')||~isempty(which(Civ2Bin))% if path defined as relative to uvmat |
---|
| 1606 | sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); |
---|
| 1607 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 1608 | msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) |
---|
| 1609 | return |
---|
[112] | 1610 | end |
---|
[94] | 1611 | end |
---|
[225] | 1612 | end |
---|
| 1613 | if isfield(sparam,'PatchBin') |
---|
| 1614 | if ~exist(sparam.PatchBin,'file')||~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat |
---|
| 1615 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
[94] | 1616 | end |
---|
[73] | 1617 | end |
---|
[225] | 1618 | if isfield(sparam,'FixBin') |
---|
| 1619 | if ~exist(sparam.FixBin,'file')||~isempty(which(sparam.FixBin))% if path defined as relative to uvmat |
---|
| 1620 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
[2] | 1621 | end |
---|
| 1622 | end |
---|
| 1623 | |
---|
| 1624 | |
---|
[225] | 1625 | |
---|
[133] | 1626 | %% get civ1 parameters: |
---|
[112] | 1627 | display('files OK, processing...') |
---|
[2] | 1628 | if box_test(1)==1 |
---|
| 1629 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
[112] | 1630 | end |
---|
[2] | 1631 | |
---|
[133] | 1632 | %% get fix1 parameters |
---|
[112] | 1633 | if box_test(2)==1 |
---|
[2] | 1634 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1635 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 1636 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
[127] | 1637 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1638 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1639 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1640 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 1641 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[112] | 1642 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 1643 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 1644 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 1645 | % fileref=fullfile(refpath,fileref); |
---|
[2] | 1646 | menu=get(handles.field_ref1,'String'); |
---|
| 1647 | index=get(handles.field_ref1,'Value'); |
---|
| 1648 | if isempty(menu) |
---|
| 1649 | fieldchoice=''; |
---|
| 1650 | else |
---|
| 1651 | fieldchoice=menu{index}; |
---|
[112] | 1652 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 1653 | end |
---|
[2] | 1654 | end |
---|
[112] | 1655 | |
---|
[133] | 1656 | %% get patch1 parameters |
---|
[67] | 1657 | if box_test(3)==1 |
---|
[127] | 1658 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
| 1659 | if isnan(rho_patch1) |
---|
[112] | 1660 | rho_patch1='1000'; |
---|
| 1661 | set(handles.rho_patch1,'String','1') |
---|
| 1662 | else |
---|
| 1663 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1664 | end |
---|
| 1665 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1666 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
[127] | 1667 | if isnan(str2double(nx_patch1)) |
---|
[112] | 1668 | nx_patch1='50' ;%default |
---|
| 1669 | set(handles.nx_patch1,'String','50'); |
---|
| 1670 | end |
---|
[127] | 1671 | if isnan(str2double(ny_patch1)) |
---|
[112] | 1672 | ny_patch1='50' ;%default |
---|
| 1673 | set(handles.ny_patch1,'String','50'); |
---|
| 1674 | end |
---|
| 1675 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1676 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1677 | end |
---|
| 1678 | |
---|
[133] | 1679 | %% get civ2 parameters: |
---|
[2] | 1680 | if box_test(4)==1 |
---|
| 1681 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 1682 | end |
---|
| 1683 | |
---|
[133] | 1684 | %% get fix2 parameters |
---|
[112] | 1685 | if box_test(5)==1 |
---|
[2] | 1686 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1687 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1688 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1689 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1690 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1691 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1692 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1693 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1694 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1695 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1696 | |
---|
[2] | 1697 | %%%%%%%%%%%%%%%%%%% |
---|
| 1698 | end |
---|
| 1699 | |
---|
[133] | 1700 | %% get patch2 parameters |
---|
[2] | 1701 | if box_test(6)==1 |
---|
[127] | 1702 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
| 1703 | if isnan(rho_patch2) |
---|
[2] | 1704 | rho_patch2='1000'; |
---|
| 1705 | set(handles.rho_patch2,'String','1') |
---|
| 1706 | else |
---|
| 1707 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1708 | end |
---|
| 1709 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1710 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
[127] | 1711 | if isnan(str2double(nx_patch2)) |
---|
[2] | 1712 | nx_patch2='50' ;%default |
---|
| 1713 | set(handles.nx_patch2,'String','50'); |
---|
| 1714 | end |
---|
[127] | 1715 | if isnan(str2double(ny_patch2)) |
---|
[2] | 1716 | ny_patch2='50' ;%default |
---|
| 1717 | set(handles.ny_patch2,'String','50'); |
---|
| 1718 | end |
---|
| 1719 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1720 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
[112] | 1721 | % test_interp=get(handles.test_interp,'Value'); |
---|
[2] | 1722 | end |
---|
| 1723 | |
---|
[133] | 1724 | %% MAIN LOOP |
---|
[71] | 1725 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[134] | 1726 | super_cmd=[]; |
---|
| 1727 | |
---|
[2] | 1728 | for ifile=1:nbfield |
---|
| 1729 | for j=1:nbslice |
---|
[112] | 1730 | i_cmd=0; |
---|
[2] | 1731 | cmd=''; |
---|
[73] | 1732 | if isunix % check: necessaire aussi en RUN? |
---|
[112] | 1733 | cmd='#!/bin/bash \n'; |
---|
| 1734 | cmd=[cmd '#$ -cwd \n']; |
---|
| 1735 | cmd=[cmd 'hostname && date \n']; |
---|
[220] | 1736 | cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group |
---|
[2] | 1737 | end |
---|
[238] | 1738 | if CivAll |
---|
| 1739 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1740 | CivAllCmd=''; |
---|
| 1741 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1742 | end |
---|
[174] | 1743 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) |
---|
[177] | 1744 | flname=fullfile(Rootbat,Filebat); |
---|
[159] | 1745 | if batch |
---|
[174] | 1746 | filename_bat=fullfile(Rootbat,['job_' Filebat]); |
---|
[159] | 1747 | else |
---|
[177] | 1748 | filename_bat=flname; |
---|
[159] | 1749 | end |
---|
[174] | 1750 | filename_bat=[filename_bat '.bat']; |
---|
[2] | 1751 | |
---|
[112] | 1752 | %CIV1 |
---|
[2] | 1753 | if box_test(1)==1 |
---|
[41] | 1754 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[112] | 1755 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 1756 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
[112] | 1757 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
[2] | 1758 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
[112] | 1759 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[2] | 1760 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
[112] | 1761 | if test_mask==0 |
---|
[2] | 1762 | par_civ1.maskname='noFile use default'; |
---|
| 1763 | par_civ1.maskflag='n'; |
---|
| 1764 | else |
---|
| 1765 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1766 | if exist(maskdispl,'file') |
---|
| 1767 | par_civ1.maskname=maskdispl; |
---|
[112] | 1768 | par_civ1.maskflag='y'; |
---|
[2] | 1769 | else |
---|
[136] | 1770 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1771 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1772 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1773 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1774 | if exist(par_civ1.maskname,'file') |
---|
[82] | 1775 | par_civ1.maskflag='y'; |
---|
[12] | 1776 | else |
---|
| 1777 | par_civ1.maskname='noFile use default'; |
---|
[112] | 1778 | par_civ1.maskflag='n'; |
---|
[12] | 1779 | end |
---|
[2] | 1780 | end |
---|
| 1781 | end |
---|
| 1782 | |
---|
| 1783 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 1784 | if test_grid |
---|
| 1785 | par_civ1.gridflag='y'; |
---|
| 1786 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1787 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1788 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1789 | if ~isnan(nbslice_grid) |
---|
[2] | 1790 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1791 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1792 | if ~exist(par_civ1.gridname,'file') |
---|
[112] | 1793 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1794 | end |
---|
| 1795 | elseif exist(gridname,'file') |
---|
[112] | 1796 | par_civ1.gridname=gridname; |
---|
[2] | 1797 | else |
---|
| 1798 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1799 | end |
---|
| 1800 | end |
---|
| 1801 | else |
---|
[112] | 1802 | par_civ1.gridname='noFile use default'; |
---|
| 1803 | par_civ1.gridflag='n'; |
---|
[2] | 1804 | end |
---|
[112] | 1805 | % |
---|
[2] | 1806 | i_cmd=i_cmd+1; |
---|
[238] | 1807 | if isequal(CivAll,0) |
---|
[230] | 1808 | civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe |
---|
[229] | 1809 | % if(isunix) |
---|
| 1810 | % cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n']; |
---|
| 1811 | % else |
---|
| 1812 | % flname=regexprep(flname,'\\','\\\\'); |
---|
| 1813 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
| 1814 | % end |
---|
[230] | 1815 | cmd=[cmd civ1_exe '\n']; |
---|
[2] | 1816 | else |
---|
[238] | 1817 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
[174] | 1818 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
---|
[112] | 1819 | fieldnames=fields(str); |
---|
[238] | 1820 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
[2] | 1821 | for ilist=1:length(fieldnames) |
---|
[112] | 1822 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1823 | if ischar(val) |
---|
[238] | 1824 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1825 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 1826 | end |
---|
| 1827 | end |
---|
[2] | 1828 | end |
---|
| 1829 | end |
---|
| 1830 | |
---|
[112] | 1831 | % FIX1 |
---|
| 1832 | if box_test(2)==1 |
---|
| 1833 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1834 | if test_mask==0 |
---|
[2] | 1835 | maskname=''; |
---|
[112] | 1836 | else |
---|
[2] | 1837 | maskdispl=get(handles.mask_fix1,'String'); |
---|
[137] | 1838 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1839 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[136] | 1840 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
[2] | 1841 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 1842 | end |
---|
[238] | 1843 | if CivX |
---|
[163] | 1844 | if isunix %unix system |
---|
[94] | 1845 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
[112] | 1846 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1847 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[163] | 1848 | else %windows system |
---|
| 1849 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1850 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1851 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
---|
| 1852 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 1853 | end |
---|
[94] | 1854 | cmd=[cmd cmd_FIX '\n']; |
---|
[238] | 1855 | elseif CivAll |
---|
[2] | 1856 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1857 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 1858 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 1859 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 1860 | fix1.threshC=num2str(thresh_vecC1); |
---|
[112] | 1861 | fix1.threshV=num2str(thresh_vel1); |
---|
[2] | 1862 | fieldnames=fields(fix1); |
---|
[238] | 1863 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
[2] | 1864 | for ilist=1:length(fieldnames) |
---|
[112] | 1865 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1866 | if ischar(val) |
---|
[238] | 1867 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1868 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 1869 | end |
---|
| 1870 | end |
---|
[238] | 1871 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1872 | end |
---|
| 1873 | end |
---|
| 1874 | |
---|
| 1875 | %PATCH1 |
---|
| 1876 | if box_test(3)==1 |
---|
[238] | 1877 | if isequal(CivAll,0) |
---|
[112] | 1878 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 1879 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1880 | else |
---|
| 1881 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1882 | patch1.nopt=subdomain_patch1; |
---|
| 1883 | patch1.maxdiff=thresh_patch1; |
---|
| 1884 | patch1.ro=rho_patch1; |
---|
| 1885 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1886 | if test_grid |
---|
| 1887 | patch1.gridflag='y'; |
---|
| 1888 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1889 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1890 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1891 | if ~isnan(nbslice_grid) |
---|
[112] | 1892 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1893 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[112] | 1894 | if ~exist(patch1.gridPatch,'file') |
---|
| 1895 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1896 | end |
---|
| 1897 | elseif exist(gridname,'file') |
---|
| 1898 | patch1.gridPatch=gridname; |
---|
| 1899 | else |
---|
| 1900 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
[2] | 1901 | end |
---|
| 1902 | end |
---|
[112] | 1903 | else |
---|
| 1904 | patch1.gridPatch='none'; |
---|
| 1905 | patch1.gridflag='n'; |
---|
| 1906 | patch1.m=nx_patch1; |
---|
| 1907 | patch1.n=ny_patch1; |
---|
[2] | 1908 | end |
---|
[112] | 1909 | patch1.convectFlow='n'; |
---|
| 1910 | fieldnames=fields(patch1); |
---|
[238] | 1911 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
[2] | 1912 | for ilist=1:length(fieldnames) |
---|
[112] | 1913 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1914 | if ischar(val) |
---|
[238] | 1915 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1916 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 1917 | end |
---|
| 1918 | end |
---|
[238] | 1919 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1920 | end |
---|
[2] | 1921 | end |
---|
[112] | 1922 | |
---|
[127] | 1923 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
[112] | 1924 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
[229] | 1925 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
[112] | 1926 | end |
---|
| 1927 | |
---|
| 1928 | if box_test(4)==1 |
---|
[2] | 1929 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1930 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
[174] | 1931 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
---|
[2] | 1932 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
[112] | 1933 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
[2] | 1934 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
[112] | 1935 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
[2] | 1936 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
[229] | 1937 | par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[2] | 1938 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 1939 | if test_mask==0 |
---|
[2] | 1940 | par_civ2.maskname='noFile use default'; |
---|
| 1941 | par_civ2.maskflag='n'; |
---|
| 1942 | else |
---|
| 1943 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 1944 | if exist(maskdispl,'file') |
---|
| 1945 | par_civ2.maskname=maskdispl; |
---|
| 1946 | par_civ2.maskflag='y'; |
---|
[2] | 1947 | else |
---|
[136] | 1948 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1949 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1950 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1951 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1952 | if exist(par_civ2.maskname,'file') |
---|
[112] | 1953 | par_civ2.maskflag='y'; |
---|
[12] | 1954 | else |
---|
| 1955 | par_civ2.maskname='noFile use default'; |
---|
[112] | 1956 | par_civ2.maskflag='n'; |
---|
[12] | 1957 | end |
---|
[2] | 1958 | end |
---|
| 1959 | end |
---|
| 1960 | %TESTgrid |
---|
[137] | 1961 | %test_grid=get(handles.browse_gridciv2,'Value'); |
---|
[2] | 1962 | gridname=get(handles.grid_civ2,'String'); |
---|
[137] | 1963 | %gridflag='y'; |
---|
[2] | 1964 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1965 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1966 | if ~isnan(nbslice_grid) |
---|
[2] | 1967 | par_civ2.gridflag='y'; |
---|
| 1968 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1969 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1970 | if exist(par_civ2.gridname,'file') |
---|
[112] | 1971 | par_civ2.gridflag='y'; |
---|
[2] | 1972 | else |
---|
| 1973 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1974 | par_civ2.gridflag='n'; |
---|
[2] | 1975 | end |
---|
| 1976 | elseif exist(gridname,'file') |
---|
[112] | 1977 | par_civ2.gridflag='y'; |
---|
[2] | 1978 | else |
---|
| 1979 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1980 | par_civ2.gridflag='n'; |
---|
[2] | 1981 | end |
---|
| 1982 | end |
---|
| 1983 | i_cmd=i_cmd+1; |
---|
[177] | 1984 | flname=fullfile(Rootbat,Filebat); |
---|
[230] | 1985 | |
---|
[238] | 1986 | if isequal(CivAll,0) |
---|
[230] | 1987 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
| 1988 | % if(isunix) |
---|
| 1989 | cmd=[cmd cmd_CIV2 '\n']; |
---|
| 1990 | % else |
---|
| 1991 | % flname=regexprep(flname,'\\','\\\\'); |
---|
| 1992 | % cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n']; |
---|
| 1993 | % end |
---|
[2] | 1994 | else |
---|
[238] | 1995 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
[220] | 1996 | str=CIV2_CMD_Unified(flname,'',par_civ2); |
---|
[112] | 1997 | fieldnames=fields(str); |
---|
[238] | 1998 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
[2] | 1999 | for ilist=1:length(fieldnames) |
---|
| 2000 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2001 | if ischar(val) |
---|
[238] | 2002 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2003 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[2] | 2004 | end |
---|
[112] | 2005 | end |
---|
[2] | 2006 | end |
---|
[112] | 2007 | end |
---|
| 2008 | |
---|
| 2009 | % FIX2 |
---|
| 2010 | if box_test(5)==1 |
---|
| 2011 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2012 | if test_mask==0 |
---|
| 2013 | maskname=''; %no mask used |
---|
[2] | 2014 | else |
---|
| 2015 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2016 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2017 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2018 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2019 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2020 | end |
---|
[238] | 2021 | if isequal(CivAll,0) |
---|
[163] | 2022 | if isunix |
---|
[94] | 2023 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[112] | 2024 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2025 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[163] | 2026 | else |
---|
| 2027 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2028 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2029 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
| 2030 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 2031 | end |
---|
[112] | 2032 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2033 | else |
---|
[2] | 2034 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2035 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2036 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2037 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2038 | fix2.threshC=num2str(thresh_vec2C); |
---|
[112] | 2039 | fix2.threshV=num2str(thresh_vel2); |
---|
[2] | 2040 | fieldnames=fields(fix2); |
---|
[238] | 2041 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
[2] | 2042 | for ilist=1:length(fieldnames) |
---|
[112] | 2043 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2044 | if ischar(val) |
---|
[238] | 2045 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2046 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 2047 | end |
---|
| 2048 | end |
---|
[238] | 2049 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 2050 | end |
---|
| 2051 | end |
---|
| 2052 | |
---|
| 2053 | %PATCH2 |
---|
| 2054 | if box_test(6)==1 |
---|
[238] | 2055 | if isequal(CivAll,0) |
---|
[94] | 2056 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
[90] | 2057 | cmd=[cmd cmd_PATCH '\n']; |
---|
[12] | 2058 | else |
---|
| 2059 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[220] | 2060 | patch2.nopt=subdomain_patch2; |
---|
| 2061 | patch2.maxdiff=thresh_patch2; |
---|
| 2062 | patch2.ro=rho_patch2; |
---|
[12] | 2063 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2064 | if test_grid |
---|
| 2065 | patch2.gridflag='y'; |
---|
| 2066 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2067 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 2068 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2069 | if ~isnan(nbslice_grid) |
---|
[12] | 2070 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 2071 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[12] | 2072 | if ~exist(patch2.gridPatch,'file') |
---|
[112] | 2073 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2074 | end |
---|
| 2075 | elseif exist(gridname,'file') |
---|
[112] | 2076 | patch2.gridPatch=gridname; |
---|
[12] | 2077 | else |
---|
| 2078 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2079 | end |
---|
| 2080 | end |
---|
[12] | 2081 | else |
---|
[112] | 2082 | patch2.gridPatch='none'; |
---|
| 2083 | patch2.gridflag='n'; |
---|
| 2084 | patch2.m=nx_patch2; |
---|
| 2085 | patch2.n=ny_patch2; |
---|
[2] | 2086 | end |
---|
[12] | 2087 | patch2.convectFlow='n'; |
---|
| 2088 | fieldnames=fields(patch2); |
---|
[238] | 2089 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
[12] | 2090 | for ilist=1:length(fieldnames) |
---|
[112] | 2091 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2092 | if ischar(val) |
---|
[238] | 2093 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2094 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 2095 | end |
---|
| 2096 | end |
---|
[238] | 2097 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 2098 | end |
---|
[12] | 2099 | end |
---|
[238] | 2100 | if CivAll |
---|
| 2101 | save(CivAllxml,[flname '.xml']); |
---|
| 2102 | cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; |
---|
[12] | 2103 | end |
---|
[112] | 2104 | % create the .bat file: |
---|
[159] | 2105 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2106 | if isequal(fid,-1) |
---|
| 2107 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2108 | return |
---|
[12] | 2109 | end |
---|
[39] | 2110 | fprintf(fid,cmd); |
---|
| 2111 | fclose(fid); |
---|
[67] | 2112 | if batch |
---|
| 2113 | switch batch_mode |
---|
| 2114 | case 'sge' |
---|
| 2115 | pvalue=num2str((1-ind_answer)*500); |
---|
[177] | 2116 | display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2117 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
[67] | 2118 | end |
---|
[238] | 2119 | elseif ~CivUvmat |
---|
[112] | 2120 | %% to lauch the jobs locally : |
---|
[12] | 2121 | if(isunix) |
---|
[135] | 2122 | cmd_str=['. ' filename_bat]; |
---|
[133] | 2123 | else %case of Windows |
---|
[163] | 2124 | cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
[2] | 2125 | end |
---|
[135] | 2126 | super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2127 | disp(cmd_str); |
---|
[225] | 2128 | else %run PIVlab if selected |
---|
[244] | 2129 | drawnow |
---|
[238] | 2130 | if box_test(1)==1 |
---|
| 2131 | Param.Civ1=par_civ1; |
---|
| 2132 | end |
---|
| 2133 | if box_test(2)==1 |
---|
| 2134 | fix1.WarnFlags=[]; |
---|
| 2135 | if get(handles.vec_Fmin2,'Value') |
---|
| 2136 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 2137 | end |
---|
| 2138 | if get(handles.vec_F3,'Value') |
---|
| 2139 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 2140 | end |
---|
| 2141 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
| 2142 | if get(handles.inf_sup1,'Value') |
---|
| 2143 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 2144 | else |
---|
| 2145 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 2146 | end |
---|
| 2147 | Param.Fix1=fix1; |
---|
| 2148 | end |
---|
| 2149 | if box_test(3)==1 |
---|
| 2150 | Param.Patch1.Rho=rho_patch1; |
---|
| 2151 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 2152 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 2153 | end |
---|
| 2154 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
[225] | 2155 | if isempty(errormsg) |
---|
| 2156 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2157 | else |
---|
| 2158 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2159 | end |
---|
| 2160 | end |
---|
[112] | 2161 | end |
---|
[2] | 2162 | end |
---|
[134] | 2163 | |
---|
[238] | 2164 | if ~batch && ~CivUvmat |
---|
[159] | 2165 | [Rootbat,Filebat,extbat]=fileparts(filename_bat); |
---|
[229] | 2166 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
[134] | 2167 | fid=fopen(filename_superbat,'w'); |
---|
| 2168 | fprintf(fid,super_cmd'); |
---|
| 2169 | fclose(fid); |
---|
[219] | 2170 | if(isunix) |
---|
| 2171 | system(['chmod +x ' filename_superbat]) |
---|
| 2172 | end |
---|
[192] | 2173 | system([filename_superbat ' &'])% execute main commmand |
---|
[133] | 2174 | end |
---|
[2] | 2175 | |
---|
[137] | 2176 | %% save interface state |
---|
[2] | 2177 | if isfield(filecell,'nc') |
---|
| 2178 | if isfield(filecell.nc,'civ2') |
---|
| 2179 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2180 | else |
---|
| 2181 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2182 | end |
---|
| 2183 | end |
---|
| 2184 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2185 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2186 | detect=1; |
---|
[2] | 2187 | while detect==1 |
---|
| 2188 | namefigfull=[namedoc '.fig']; |
---|
| 2189 | hh=dir(namefigfull); |
---|
| 2190 | if ~isempty(hh) |
---|
| 2191 | detect=1; |
---|
| 2192 | namedoc=[namedoc '.0']; |
---|
| 2193 | else |
---|
| 2194 | detect=0; |
---|
| 2195 | end |
---|
| 2196 | end |
---|
| 2197 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2198 | |
---|
[227] | 2199 | %------------------------------------------------------------------------ |
---|
| 2200 | % --- determine the list of reference indices of processing file |
---|
| 2201 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2202 | %------------------------------------------------------------------------ |
---|
| 2203 | errormsg=''; %default error message |
---|
| 2204 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2205 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2206 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2207 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2208 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2209 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2210 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2211 | else |
---|
| 2212 | first_j=1; |
---|
| 2213 | last_j=1; |
---|
| 2214 | incr_j=1; |
---|
| 2215 | end |
---|
| 2216 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2217 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2218 | if isnan(first_i)||isnan(first_j) |
---|
| 2219 | errormsg='first field number not defined'; |
---|
| 2220 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2221 | errormsg='last field number not defined'; |
---|
| 2222 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2223 | errormsg='increment in field number not defined'; |
---|
| 2224 | elseif last_i < first_i || last_j < first_j |
---|
| 2225 | errormsg='last field number must be larger than the first one'; |
---|
| 2226 | end |
---|
[134] | 2227 | |
---|
[227] | 2228 | %------------------------------------------------------------------------ |
---|
| 2229 | % --- determine the list of filenames and indices needed for launch_job |
---|
[2] | 2230 | 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]=... |
---|
[227] | 2231 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
[12] | 2232 | %------------------------------------------------------------------------ |
---|
[85] | 2233 | filecell=[];%default |
---|
[136] | 2234 | |
---|
| 2235 | %% get the root names nomenclature and numbers |
---|
[71] | 2236 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2237 | |
---|
| 2238 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2239 | msgbox_uvmat('ERROR','no input files') |
---|
| 2240 | return |
---|
| 2241 | end |
---|
| 2242 | |
---|
[137] | 2243 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2244 | filecell.filebase=filebase; |
---|
| 2245 | |
---|
[2] | 2246 | browse=get(handles.browse_root,'UserData'); |
---|
| 2247 | compare_list=get(handles.compare,'String'); |
---|
| 2248 | val=get(handles.compare,'Value'); |
---|
| 2249 | compare=compare_list{val}; |
---|
| 2250 | if strcmp(compare,'displacement') |
---|
| 2251 | mode='displacement'; |
---|
| 2252 | else |
---|
| 2253 | mode_list=get(handles.mode,'String'); |
---|
| 2254 | mode_value=get(handles.mode,'Value'); |
---|
| 2255 | mode=mode_list{mode_value}; |
---|
| 2256 | end |
---|
[137] | 2257 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2258 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2259 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2260 | if isfield(browse,'nom_type_ima') |
---|
| 2261 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2262 | end |
---|
| 2263 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2264 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2265 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2266 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[2] | 2267 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2268 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2269 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2270 | % test_disp=1; |
---|
[2] | 2271 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2272 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2273 | Path1=Path2; |
---|
[71] | 2274 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2275 | filebase_A=fullfile(Path1,Name1); |
---|
| 2276 | if length(Name1)>6 |
---|
| 2277 | Name1=Name1(end-5:end); |
---|
| 2278 | end |
---|
| 2279 | if length(Name2)>6 |
---|
| 2280 | Name2=Name2(end-5:end); |
---|
| 2281 | end |
---|
| 2282 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2283 | else |
---|
[127] | 2284 | % test_disp=0; |
---|
[2] | 2285 | filebase_A=filebase; |
---|
| 2286 | nom_type_ima1=nom_type_ima2; |
---|
| 2287 | filebase_AB=filebase; |
---|
| 2288 | end |
---|
| 2289 | if strcmp(compare,'displacement') |
---|
[112] | 2290 | filebase_ima1=filebase_A; |
---|
| 2291 | filebase_ima2=filebase_B; |
---|
| 2292 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2293 | else |
---|
[112] | 2294 | filebase_ima1=filebase_B; |
---|
| 2295 | filebase_ima2=filebase_B; |
---|
| 2296 | filebase_nc=filebase_B; |
---|
| 2297 | end |
---|
[2] | 2298 | |
---|
| 2299 | %determine reference files for fix: |
---|
| 2300 | file_ref_fix1={};%default |
---|
| 2301 | file_ref_fix2={}; |
---|
| 2302 | nbfield=length(num1_civ1); |
---|
| 2303 | nbslice=length(num_a_civ1); |
---|
| 2304 | if box_test(2)==1% fix1 performed |
---|
| 2305 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2306 | if ~isempty(ref) |
---|
[137] | 2307 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2308 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2309 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2310 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2311 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2312 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2313 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2314 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2315 | if isequal(mode,'displacement') |
---|
| 2316 | num_i1=num_i_ref; |
---|
| 2317 | num_i2=num_i_ref; |
---|
| 2318 | num_j1=num_j_ref; |
---|
| 2319 | num_j2=num_j_ref; |
---|
| 2320 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2321 | num_i1=num_i_ref; |
---|
| 2322 | num_i2=num_i1; |
---|
| 2323 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2324 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2325 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2326 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2327 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2328 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2329 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2330 | if isempty(ref.num_a) |
---|
| 2331 | ref.num_a=1; |
---|
| 2332 | end |
---|
| 2333 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2334 | num_j2=num_j1; |
---|
| 2335 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2336 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2337 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2338 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2339 | num_i2=num_i1; |
---|
| 2340 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2341 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2342 | end |
---|
| 2343 | for ifile=1:nbfield |
---|
| 2344 | for j=1:nbslice |
---|
| 2345 | 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);% |
---|
| 2346 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2347 | if ~exist(file_ref,'file') |
---|
| 2348 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2349 | filecell=[]; |
---|
[2] | 2350 | return |
---|
| 2351 | end |
---|
| 2352 | end |
---|
| 2353 | end |
---|
| 2354 | end |
---|
| 2355 | end |
---|
| 2356 | |
---|
| 2357 | %determine reference files for fix2: |
---|
| 2358 | if box_test(5)==1% fix2 performed |
---|
| 2359 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2360 | if ~isempty(ref) |
---|
[127] | 2361 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2362 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2363 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2364 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2365 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2366 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2367 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2368 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2369 | if isequal(mode,'displacement') |
---|
| 2370 | num_i1=num_i_ref; |
---|
| 2371 | num_i2=num_i_ref; |
---|
| 2372 | num_j1=num_j_ref; |
---|
| 2373 | num_j2=num_j_ref; |
---|
| 2374 | elseif isequal(mode,'pair j1-j2') |
---|
| 2375 | num_i1=num_i_ref; |
---|
| 2376 | num_i2=num_i1; |
---|
| 2377 | num_j1=ref.num_a; |
---|
| 2378 | num_j2=ref.num_b; |
---|
| 2379 | elseif isequal(mode,'series(Di)') |
---|
| 2380 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2381 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2382 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2383 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2384 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2385 | num_j2=num_j1; |
---|
| 2386 | elseif isequal(mode,'series(Dj)') |
---|
| 2387 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2388 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2389 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2390 | num_i2=num_i1; |
---|
| 2391 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2392 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2393 | end |
---|
| 2394 | for ifile=1:nbfield |
---|
| 2395 | for j=1:nbslice |
---|
| 2396 | 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);% |
---|
| 2397 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2398 | if ~exist(file_ref,'file') |
---|
| 2399 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2400 | filecell={}; |
---|
[2] | 2401 | return |
---|
| 2402 | end |
---|
| 2403 | end |
---|
| 2404 | end |
---|
| 2405 | end |
---|
| 2406 | end |
---|
| 2407 | |
---|
| 2408 | %check dir |
---|
| 2409 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2410 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
[174] | 2411 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2412 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[135] | 2413 | currentdir=pwd;%store the current working directory |
---|
[2] | 2414 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2415 | if ~exist(Path_ima,'dir') |
---|
[12] | 2416 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2417 | filecell={}; |
---|
[2] | 2418 | return |
---|
| 2419 | end |
---|
[127] | 2420 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2421 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2422 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2423 | filecell={}; |
---|
[112] | 2424 | cd(currentdir); |
---|
| 2425 | return |
---|
[2] | 2426 | end |
---|
| 2427 | |
---|
| 2428 | %check the existence of the netcdf and image files involved |
---|
| 2429 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2430 | if box_test(1)==1; |
---|
[112] | 2431 | detect=1; |
---|
[127] | 2432 | vers=0; |
---|
| 2433 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2434 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2435 | for ifile=1:nbfield |
---|
[112] | 2436 | for j=1:nbslice |
---|
[122] | 2437 | 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] | 2438 | detect=exist(filename,'file')==2; |
---|
| 2439 | if detect% if a netcdf file already exists |
---|
[137] | 2440 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2441 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2442 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2443 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2444 | else |
---|
| 2445 | vers=vers+1; |
---|
[137] | 2446 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2447 | end |
---|
[137] | 2448 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2449 | break |
---|
| 2450 | end |
---|
| 2451 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2452 | end |
---|
| 2453 | if detect% if a netcdf file already exists |
---|
| 2454 | break |
---|
| 2455 | end |
---|
| 2456 | end |
---|
[134] | 2457 | |
---|
[112] | 2458 | %create the new subdir_civ1 |
---|
[127] | 2459 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[134] | 2460 | cd(Path_ima); |
---|
[128] | 2461 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2462 | |
---|
[128] | 2463 | if ~strcmp(msg1,'') |
---|
| 2464 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2465 | filecell={}; |
---|
| 2466 | return |
---|
[163] | 2467 | elseif isunix |
---|
[128] | 2468 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2469 | if ~strcmp(msg2,'') |
---|
[134] | 2470 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[128] | 2471 | filecell={}; |
---|
| 2472 | return |
---|
| 2473 | end |
---|
[112] | 2474 | end |
---|
[134] | 2475 | cd(currentdir); |
---|
[112] | 2476 | end |
---|
| 2477 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2478 | for ifile=1:nbfield |
---|
| 2479 | for j=1:nbslice |
---|
[122] | 2480 | 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] | 2481 | detect=exist(filename,'file')==2; |
---|
[2] | 2482 | if detect% if a netcdf file already exists |
---|
[137] | 2483 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2484 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2485 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2486 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2487 | else |
---|
| 2488 | vers=vers+1; |
---|
[137] | 2489 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2490 | end |
---|
| 2491 | subdir_civ2=subdir_civ1; |
---|
| 2492 | break |
---|
[2] | 2493 | end |
---|
[112] | 2494 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2495 | end |
---|
| 2496 | if detect% if a netcdf file already exists |
---|
| 2497 | break |
---|
| 2498 | end |
---|
| 2499 | end |
---|
| 2500 | %create the new subdir_civ1 |
---|
[134] | 2501 | if exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2502 | cd(Path_ima); |
---|
[128] | 2503 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2504 | cd(currentdir); |
---|
[128] | 2505 | if ~strcmpl(msg1,'') |
---|
| 2506 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[122] | 2507 | cd(currentdir) |
---|
| 2508 | filecell={}; |
---|
| 2509 | return |
---|
[128] | 2510 | else |
---|
| 2511 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2512 | if ~strcmp(msg2,'') |
---|
| 2513 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
| 2514 | cd(currentdir) |
---|
| 2515 | filecell={}; |
---|
| 2516 | return |
---|
| 2517 | end |
---|
[112] | 2518 | end |
---|
| 2519 | end |
---|
| 2520 | end |
---|
| 2521 | end |
---|
[127] | 2522 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2523 | % get image names |
---|
| 2524 | for ifile=1:nbfield |
---|
[112] | 2525 | for j=1:nbslice |
---|
[2] | 2526 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2527 | idetect(j)=exist(filename,'file')==2; |
---|
| 2528 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2529 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2530 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2531 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2532 | end |
---|
| 2533 | [idetectmin,indexj]=min(idetect); |
---|
| 2534 | if idetectmin==0, |
---|
| 2535 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2536 | filecell={}; |
---|
| 2537 | cd(currentdir) |
---|
[112] | 2538 | return |
---|
| 2539 | end |
---|
| 2540 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2541 | if idetectmin==0, |
---|
| 2542 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2543 | filecell={}; |
---|
[112] | 2544 | cd(currentdir) |
---|
| 2545 | return |
---|
| 2546 | end |
---|
| 2547 | end |
---|
| 2548 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2549 | for ifile=1:nbfield |
---|
| 2550 | for j=1:nbslice |
---|
| 2551 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2552 | idetect(j)=exist(filename,'file')==2; |
---|
| 2553 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2554 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2555 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2556 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2557 | end |
---|
[2] | 2558 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2559 | if idetectmin==0, |
---|
| 2560 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2561 | filecell={}; |
---|
[112] | 2562 | cd(currentdir) |
---|
[2] | 2563 | return |
---|
[112] | 2564 | end |
---|
[2] | 2565 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2566 | if idetectmin==0, |
---|
| 2567 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2568 | filecell={}; |
---|
[2] | 2569 | cd(currentdir) |
---|
| 2570 | return |
---|
[112] | 2571 | end |
---|
| 2572 | end |
---|
[2] | 2573 | end |
---|
[112] | 2574 | |
---|
| 2575 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2576 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2577 | for ifile=1:nbfield |
---|
| 2578 | for j=1:nbslice |
---|
| 2579 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2580 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2581 | detect=exist(filename,'file')==2; |
---|
[122] | 2582 | if detect==0 |
---|
| 2583 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2584 | filecell={}; |
---|
| 2585 | cd(currentdir) |
---|
| 2586 | return |
---|
| 2587 | end |
---|
[2] | 2588 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2589 | end |
---|
| 2590 | end |
---|
| 2591 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2592 | for ifile=1:nbfield |
---|
| 2593 | for j=1:nbslice |
---|
| 2594 | 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);% |
---|
| 2595 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2596 | if ~exist(filename,'file') |
---|
| 2597 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2598 | set(handles.RUN, 'Enable','On') |
---|
| 2599 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2600 | filecell={}; |
---|
[112] | 2601 | cd(currentdir) |
---|
| 2602 | return |
---|
[2] | 2603 | end |
---|
| 2604 | end |
---|
[112] | 2605 | end |
---|
[2] | 2606 | end |
---|
| 2607 | end |
---|
| 2608 | |
---|
| 2609 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2610 | testdiff=0; |
---|
| 2611 | if (box_test(4)==1)&&... |
---|
[127] | 2612 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2613 | testdiff=1; |
---|
[112] | 2614 | detect=1; |
---|
[127] | 2615 | vers=0; |
---|
| 2616 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2617 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2618 | for ifile=1:nbfield |
---|
| 2619 | for j=1:nbslice |
---|
[127] | 2620 | 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] | 2621 | detect=exist(filename,'file')==2; |
---|
| 2622 | if detect% if a netcdf file already exists |
---|
[127] | 2623 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2624 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2625 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2626 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2627 | else |
---|
| 2628 | vers=vers+1; |
---|
| 2629 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2630 | end |
---|
[112] | 2631 | break |
---|
| 2632 | end |
---|
| 2633 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2634 | end |
---|
| 2635 | if detect% if a netcdf file already exists |
---|
| 2636 | break |
---|
| 2637 | end |
---|
| 2638 | end |
---|
[128] | 2639 | %create the new subdir_civ2_new |
---|
| 2640 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2641 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[128] | 2642 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2643 | if ~isequal(m2,'') |
---|
[128] | 2644 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
---|
[122] | 2645 | filecell={}; |
---|
| 2646 | cd(currentdir) |
---|
| 2647 | return |
---|
[112] | 2648 | end |
---|
| 2649 | end |
---|
| 2650 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2651 | for ifile=1:nbfield |
---|
| 2652 | for j=1:nbslice |
---|
| 2653 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2654 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2655 | detect=exist(filename,'file')==2; |
---|
[2] | 2656 | if detect% if a netcdf file already exists |
---|
[127] | 2657 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2658 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2659 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2660 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2661 | else |
---|
| 2662 | vers=vers+1; |
---|
| 2663 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2664 | end |
---|
[112] | 2665 | break |
---|
[2] | 2666 | end |
---|
[112] | 2667 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2668 | end |
---|
| 2669 | if detect% if a netcdf file already exists |
---|
| 2670 | break |
---|
| 2671 | end |
---|
| 2672 | end |
---|
[122] | 2673 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2674 | %create the new subdir_civ1 |
---|
[127] | 2675 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2676 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[128] | 2677 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2678 | if ~isequal(m2,'') |
---|
[128] | 2679 | msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation |
---|
[122] | 2680 | cd(currentdir) |
---|
| 2681 | filecell={}; |
---|
| 2682 | return |
---|
[112] | 2683 | end |
---|
| 2684 | end |
---|
| 2685 | end |
---|
| 2686 | end |
---|
[127] | 2687 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2688 | end |
---|
| 2689 | cd(currentdir);%come back to the current working directory |
---|
| 2690 | |
---|
| 2691 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2692 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2693 | %check source netcdf file of civ1 estimates |
---|
| 2694 | if box_test(1)==0; %no civ1 performed |
---|
| 2695 | for ifile=1:nbfield |
---|
| 2696 | for j=1:nbslice |
---|
| 2697 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2698 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2699 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2700 | if ~exist(filename,'file') |
---|
| 2701 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2702 | filecell={}; |
---|
[2] | 2703 | return |
---|
| 2704 | end |
---|
| 2705 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2706 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 2707 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 2708 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2709 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2710 | filecell=[]; |
---|
[2] | 2711 | return |
---|
[112] | 2712 | end |
---|
[2] | 2713 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 2714 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 2715 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 2716 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2717 | filecell=[]; |
---|
[2] | 2718 | return |
---|
| 2719 | end |
---|
[112] | 2720 | end |
---|
[2] | 2721 | end |
---|
| 2722 | end |
---|
| 2723 | end |
---|
| 2724 | if strcmp(compare,'stereo PIV') |
---|
| 2725 | for ifile=1:nbfield |
---|
| 2726 | for j=1:nbslice |
---|
| 2727 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2728 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2729 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2730 | if ~exist(filename,'file') |
---|
| 2731 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2732 | set(handles.RUN, 'Enable','On') |
---|
| 2733 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2734 | return |
---|
| 2735 | end |
---|
| 2736 | end |
---|
| 2737 | end |
---|
| 2738 | end |
---|
| 2739 | end |
---|
[112] | 2740 | |
---|
| 2741 | detect=1; |
---|
| 2742 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2743 | for ifile=1:nbfield |
---|
| 2744 | for j=1:nbslice |
---|
| 2745 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2746 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2747 | detect=exist(filename,'file')==2; |
---|
| 2748 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2749 | end |
---|
[112] | 2750 | end |
---|
[2] | 2751 | %get first image names for civ2 |
---|
| 2752 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2753 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2754 | elseif box_test(4)==1 |
---|
| 2755 | for ifile=1:nbfield |
---|
| 2756 | for j=1:nbslice |
---|
| 2757 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2758 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2759 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2760 | end |
---|
[112] | 2761 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2762 | if idetectmin==0, |
---|
[112] | 2763 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2764 | filecell=[]; |
---|
| 2765 | return |
---|
[2] | 2766 | end |
---|
| 2767 | end |
---|
| 2768 | end |
---|
| 2769 | |
---|
| 2770 | %get second image names for civ2 |
---|
| 2771 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2772 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2773 | elseif box_test(4)==1 |
---|
| 2774 | for ifile=1:nbfield |
---|
| 2775 | for j=1:nbslice |
---|
| 2776 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2777 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2778 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2779 | end |
---|
[112] | 2780 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2781 | if idetectmin==0, |
---|
[112] | 2782 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2783 | filecell=[]; |
---|
| 2784 | return |
---|
[2] | 2785 | end |
---|
| 2786 | end |
---|
| 2787 | end |
---|
| 2788 | end |
---|
| 2789 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2790 | if ~testdiff |
---|
| 2791 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2792 | else % check the civ2 files |
---|
[2] | 2793 | for ifile=1:nbfield |
---|
| 2794 | for j=1:nbslice |
---|
| 2795 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2796 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2797 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2798 | if ~exist(filename,'file') |
---|
| 2799 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2800 | filecell=[]; |
---|
[2] | 2801 | return |
---|
| 2802 | else |
---|
| 2803 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
[112] | 2804 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2805 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2806 | filecell=[]; |
---|
[2] | 2807 | return |
---|
| 2808 | end |
---|
| 2809 | end |
---|
| 2810 | end |
---|
| 2811 | end |
---|
| 2812 | end |
---|
| 2813 | end |
---|
| 2814 | |
---|
| 2815 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2816 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2817 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2818 | for ifile=1:nbfield |
---|
| 2819 | for j=1:nbslice |
---|
| 2820 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2821 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2822 | filecell.st(ifile,j)={filename}; |
---|
| 2823 | end |
---|
| 2824 | end |
---|
| 2825 | end |
---|
[127] | 2826 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
[2] | 2827 | for ifile=1:nbfield |
---|
| 2828 | for j=1:nbslice |
---|
| 2829 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2830 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2831 | filecell.st(ifile,j)={filename}; |
---|
| 2832 | end |
---|
| 2833 | end |
---|
[112] | 2834 | end |
---|
[2] | 2835 | end |
---|
| 2836 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 2837 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 2838 | browse.nom_type_nc=nom_type_nc; |
---|
| 2839 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 2840 | |
---|
| 2841 | |
---|
| 2842 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2843 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2844 | nom_type_imanew1='_i'; |
---|
[2] | 2845 | else |
---|
| 2846 | nom_type_imanew1=nom_type_ima1; |
---|
| 2847 | end |
---|
[45] | 2848 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2849 | nom_type_imanew2='_i'; |
---|
[2] | 2850 | else |
---|
| 2851 | nom_type_imanew2=nom_type_ima2; |
---|
| 2852 | end |
---|
| 2853 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2854 | %%type of image file |
---|
| 2855 | type_ima1='none';%default |
---|
| 2856 | movieobject1=[];%default |
---|
[133] | 2857 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2858 | hhh=which('mmreader'); |
---|
| 2859 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2860 | type_ima1='movie'; |
---|
| 2861 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2862 | else |
---|
| 2863 | type_ima1='avi'; |
---|
| 2864 | end |
---|
[133] | 2865 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2866 | form=imformats(ext_ima(2:end)); |
---|
| 2867 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2868 | if isequal(nom_type_ima1,'*'); |
---|
| 2869 | type_ima1='multimage';%image series in a single image file |
---|
| 2870 | else |
---|
| 2871 | type_ima1='image'; |
---|
| 2872 | end |
---|
| 2873 | end |
---|
[45] | 2874 | end |
---|
| 2875 | type_ima2='none';%default |
---|
| 2876 | movieobject2=[]; |
---|
[133] | 2877 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2878 | hhh=which('mmreader'); |
---|
| 2879 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2880 | type_ima2='movie'; |
---|
| 2881 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2882 | else |
---|
| 2883 | type_ima2='avi'; |
---|
| 2884 | end |
---|
[133] | 2885 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2886 | form=imformats(ext_ima(2:end)); |
---|
| 2887 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2888 | if isequal(nom_type_ima1,'*'); |
---|
| 2889 | type_ima2='multimage';%image series in a single image file |
---|
| 2890 | else |
---|
| 2891 | type_ima2='image'; |
---|
| 2892 | end |
---|
| 2893 | end |
---|
[45] | 2894 | end |
---|
[71] | 2895 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2896 | % % if numel(npxy)<2 |
---|
| 2897 | % |
---|
| 2898 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2899 | % A=imread(filename); |
---|
| 2900 | % npxy=size(A); |
---|
| 2901 | % % end |
---|
| 2902 | % npy=npxy(1); |
---|
| 2903 | % npx=npxy(2); |
---|
[2] | 2904 | if box_test(1)==1 %if civ1 is performed |
---|
[224] | 2905 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2906 | for ifile=1:nbfield |
---|
[2] | 2907 | waitbar(ifile/nbfield); |
---|
| 2908 | for j=1:nbslice |
---|
[112] | 2909 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2910 | if ~exist(filename,'file') |
---|
| 2911 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2912 | imwrite(A,filename,'BitDepth',16); |
---|
| 2913 | end |
---|
| 2914 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2915 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2916 | if ~exist(filename,'file') |
---|
| 2917 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2918 | imwrite(A,filename,'BitDepth',16); |
---|
| 2919 | end |
---|
| 2920 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 2921 | end |
---|
| 2922 | end |
---|
| 2923 | close(h) |
---|
| 2924 | end |
---|
| 2925 | if box_test(4)==1 %if civ2 is performed |
---|
[229] | 2926 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 2927 | for ifile=1:nbfield |
---|
| 2928 | waitbar(ifile/nbfield); |
---|
| 2929 | for j=1:nbslice |
---|
[112] | 2930 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 2931 | if ~exist(filename,'file') |
---|
| 2932 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 2933 | imwrite(A,filename,'BitDepth',16); |
---|
| 2934 | end |
---|
| 2935 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2936 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 2937 | if ~exist(filename,'file') |
---|
| 2938 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 2939 | imwrite(A,filename,'BitDepth',16); |
---|
| 2940 | end |
---|
| 2941 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 2942 | end |
---|
| 2943 | end |
---|
| 2944 | close(h); |
---|
| 2945 | end |
---|
| 2946 | end |
---|
| 2947 | |
---|
[12] | 2948 | %------------------------------------------------------------------------ |
---|
[227] | 2949 | % --- determine the list of index pairs of processing file |
---|
| 2950 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2951 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2952 | %------------------------------------------------------------------------ |
---|
| 2953 | |
---|
| 2954 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 2955 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 2956 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2957 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2958 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2959 | return |
---|
| 2960 | end |
---|
| 2961 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 2962 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 2963 | if index_civ2>length(list_civ2) |
---|
| 2964 | list_civ2=list_civ1; |
---|
| 2965 | index_civ2=index_civ1; |
---|
| 2966 | end |
---|
| 2967 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2968 | |
---|
| 2969 | if isequal (mode,'series(Di)') |
---|
| 2970 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2971 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2972 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2973 | num_a_civ1=ref_j; |
---|
| 2974 | num_b_civ1=ref_j; |
---|
[229] | 2975 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 2976 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2977 | num_a_civ2=ref_j; |
---|
| 2978 | num_b_civ2=ref_j; |
---|
| 2979 | |
---|
| 2980 | % adjust the first and last field number |
---|
| 2981 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2982 | if isnan(lastfield) |
---|
| 2983 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2984 | else |
---|
| 2985 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2986 | end |
---|
| 2987 | if length(indsel)>=1 |
---|
| 2988 | firstind=indsel(1); |
---|
| 2989 | lastind=indsel(end); |
---|
| 2990 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2991 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2992 | ref_i=ref_i(indsel); |
---|
| 2993 | num1_civ1=num1_civ1(indsel); |
---|
| 2994 | num1_civ2=num1_civ2(indsel); |
---|
| 2995 | num2_civ1=num2_civ1(indsel); |
---|
| 2996 | num2_civ2=num2_civ2(indsel); |
---|
| 2997 | end |
---|
| 2998 | elseif isequal (mode,'series(Dj)') |
---|
| 2999 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3000 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3001 | num2_civ1=ref_i; |
---|
| 3002 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3003 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3004 | num1_civ2=ref_i; |
---|
| 3005 | num2_civ2=ref_i; |
---|
| 3006 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3007 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3008 | % adjust the first and last field number |
---|
| 3009 | if isnan(lastfield_j) |
---|
| 3010 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3011 | else |
---|
| 3012 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3013 | end |
---|
| 3014 | if length(indsel)>=1 |
---|
| 3015 | firstind=indsel(1); |
---|
| 3016 | lastind=indsel(end); |
---|
| 3017 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3018 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3019 | ref_j=ref_j(indsel); |
---|
| 3020 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3021 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3022 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3023 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3024 | end |
---|
| 3025 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3026 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3027 | num1_civ1=ref_i; |
---|
| 3028 | num2_civ1=ref_i; |
---|
| 3029 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3030 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3031 | num1_civ2=ref_i; |
---|
| 3032 | num2_civ2=ref_i; |
---|
| 3033 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3034 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3035 | elseif isequal(mode,'displacement') |
---|
| 3036 | num1_civ1=ref_i; |
---|
| 3037 | num2_civ1=ref_i; |
---|
| 3038 | num_a_civ1=ref_j; |
---|
| 3039 | num_b_civ1=ref_j; |
---|
| 3040 | num1_civ2=ref_i; |
---|
| 3041 | num2_civ2=ref_i; |
---|
| 3042 | num_a_civ2=ref_j; |
---|
| 3043 | num_b_civ2=ref_j; |
---|
| 3044 | end |
---|
| 3045 | |
---|
| 3046 | |
---|
| 3047 | %------------------------------------------------------------------------ |
---|
[12] | 3048 | % --- PATCH |
---|
[94] | 3049 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 3050 | %------------------------------------------------------------------------ |
---|
[224] | 3051 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
[112] | 3052 | if test_interp==0 |
---|
[163] | 3053 | if isunix |
---|
[112] | 3054 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3055 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[163] | 3056 | else |
---|
| 3057 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3058 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
| 3059 | end |
---|
[112] | 3060 | else %nouveau programme patch |
---|
| 3061 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3062 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3063 | end |
---|
[163] | 3064 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[12] | 3065 | %------------------------------------------------------------------------ |
---|
| 3066 | % --- STEREO Interp |
---|
[67] | 3067 | 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] | 3068 | %------------------------------------------------------------------------ |
---|
[224] | 3069 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3070 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3071 | ' -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 |
---|
| 3072 | |
---|
[12] | 3073 | %------------------------------------------------------------------------ |
---|
[2] | 3074 | % --- Executes on button press in CIV1. |
---|
| 3075 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3076 | %------------------------------------------------------------------------ |
---|
[2] | 3077 | val=get(handles.CIV1,'Value'); |
---|
| 3078 | if isequal(val,1) |
---|
| 3079 | enable_civ1(handles,'on') |
---|
| 3080 | enable_pair1(handles,'on') |
---|
| 3081 | else |
---|
| 3082 | enable_civ1(handles,'off') |
---|
| 3083 | end |
---|
| 3084 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3085 | |
---|
[12] | 3086 | %------------------------------------------------------------------------ |
---|
[2] | 3087 | % --- Executes on button press in FIX1. |
---|
| 3088 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3089 | %------------------------------------------------------------------------ |
---|
[2] | 3090 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3091 | |
---|
[12] | 3092 | %------------------------------------------------------------------------ |
---|
[2] | 3093 | % --- Executes on button press in PATCH1. |
---|
| 3094 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3095 | %------------------------------------------------------------------------ |
---|
[2] | 3096 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3097 | enable_patch1(handles) |
---|
[2] | 3098 | else |
---|
[12] | 3099 | desable_patch1(handles) |
---|
[2] | 3100 | end |
---|
| 3101 | |
---|
[12] | 3102 | %------------------------------------------------------------------------ |
---|
[2] | 3103 | % --- Executes on button press in CIV2. |
---|
| 3104 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3105 | %------------------------------------------------------------------------ |
---|
[2] | 3106 | state=get(handles.CIV2,'Value'); |
---|
| 3107 | enable_civ2(handles,state) |
---|
| 3108 | if state |
---|
| 3109 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3110 | enable_pair1(handles,'on') |
---|
| 3111 | end |
---|
| 3112 | |
---|
[12] | 3113 | %------------------------------------------------------------------------ |
---|
[2] | 3114 | % --- Executes on button press in FIX2. |
---|
| 3115 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3116 | %------------------------------------------------------------------------ |
---|
[2] | 3117 | if get(handles.FIX2,'Value')==1 |
---|
| 3118 | enable_fix2(handles) |
---|
| 3119 | if get(handles.CIV2,'Value')==0 |
---|
| 3120 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3121 | end |
---|
| 3122 | else |
---|
| 3123 | desable_fix2(handles) |
---|
| 3124 | end |
---|
| 3125 | |
---|
[12] | 3126 | %------------------------------------------------------------------------ |
---|
[2] | 3127 | % --- Executes on button press in PATCH2. |
---|
| 3128 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3129 | %------------------------------------------------------------------------ |
---|
[2] | 3130 | if get(handles.PATCH2,'Value')==1 |
---|
| 3131 | enable_patch2(handles) |
---|
| 3132 | if get(handles.CIV2,'Value')==0 |
---|
| 3133 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3134 | end |
---|
| 3135 | else |
---|
| 3136 | desable_patch2(handles) |
---|
| 3137 | end |
---|
| 3138 | |
---|
[12] | 3139 | %------------------------------------------------------------------------ |
---|
| 3140 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3141 | %------------------------------------------------------------------------ |
---|
| 3142 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3143 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3144 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3145 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3146 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3147 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3148 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3149 | |
---|
[12] | 3150 | %------------------------------------------------------------------------ |
---|
| 3151 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3152 | %------------------------------------------------------------------------ |
---|
| 3153 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3154 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3155 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3156 | |
---|
[12] | 3157 | %------------------------------------------------------------------------ |
---|
[2] | 3158 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3159 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3160 | %------------------------------------------------------------------------ |
---|
[2] | 3161 | %determine pair numbers |
---|
| 3162 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3163 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3164 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3165 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3166 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3167 | pxcmx=pxcm_xy(1); |
---|
| 3168 | pxcmy=pxcm_xy(2); |
---|
| 3169 | mode_list=get(handles.mode,'String'); |
---|
| 3170 | mode_value=get(handles.mode,'Value'); |
---|
| 3171 | mode=mode_list{mode_value}; |
---|
| 3172 | if isequal (mode, 'series(Di)' ) |
---|
[137] | 3173 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3174 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3175 | num2=ref_i+ceil(index/2); |
---|
| 3176 | num_a=1; |
---|
| 3177 | num_b=1; |
---|
[112] | 3178 | elseif isequal (mode, 'series(Dj)') |
---|
[2] | 3179 | num1=1; |
---|
| 3180 | num2=1; |
---|
[137] | 3181 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 3182 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3183 | num_b=ref_j+ceil(index/2); |
---|
| 3184 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[137] | 3185 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3186 | num1=ref_i; |
---|
| 3187 | num2=ref_i; |
---|
| 3188 | num_a=displ_num(1,index); |
---|
| 3189 | num_b=displ_num(2,index); |
---|
| 3190 | end |
---|
| 3191 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[137] | 3192 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3193 | iby=str2double(get(handles.iby,'String')); |
---|
| 3194 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
| 3195 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
| 3196 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
| 3197 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
[2] | 3198 | shiftx=round((umin+umax)/2); |
---|
| 3199 | shifty=round((vmin+vmax)/2); |
---|
| 3200 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3201 | isx=2*ceil(isx/2)+1; |
---|
| 3202 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3203 | isy=2*ceil(isy/2)+1; |
---|
| 3204 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3205 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3206 | set(handles.isx,'String',num2str(isx)); |
---|
| 3207 | set(handles.isy,'String',num2str(isy)); |
---|
| 3208 | |
---|
[12] | 3209 | %------------------------------------------------------------------------ |
---|
| 3210 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3211 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3212 | %------------------------------------------------------------------------ |
---|
[2] | 3213 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3214 | set(handles.subdir_civ2,'String',subdir); |
---|
[112] | 3215 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3216 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3217 | end |
---|
| 3218 | |
---|
[12] | 3219 | %------------------------------------------------------------------------ |
---|
| 3220 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3221 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3222 | %------------------------------------------------------------------------ |
---|
[2] | 3223 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3224 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3225 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3226 | end |
---|
| 3227 | |
---|
[12] | 3228 | %------------------------------------------------------------------------ |
---|
[133] | 3229 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3230 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3231 | %------------------------------------------------------------------------ |
---|
[2] | 3232 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3233 | if isequal(maskval,0) |
---|
| 3234 | set(handles.mask_civ1,'String','') |
---|
| 3235 | else |
---|
| 3236 | mask_displ='no mask'; %default |
---|
[71] | 3237 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3238 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3239 | if isequal(flag_mask,1) |
---|
[112] | 3240 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3241 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3242 | common_path=fileparts(filebase); |
---|
| 3243 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3244 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3245 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3246 | mask_displ='no mask'; |
---|
| 3247 | end |
---|
[2] | 3248 | end |
---|
| 3249 | if isequal(mask_displ,'no mask') |
---|
[12] | 3250 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3251 | {'*.png', ' (*.png)'; |
---|
| 3252 | '*.png', '.png files '; ... |
---|
| 3253 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3254 | 'Pick a mask file *.png',filebase); |
---|
| 3255 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3256 | if ~exist(mask_displ,'file') |
---|
| 3257 | mask_displ='no mask'; |
---|
| 3258 | end |
---|
| 3259 | end |
---|
| 3260 | if isequal(mask_displ,'no mask') |
---|
[2] | 3261 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3262 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3263 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3264 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3265 | else |
---|
| 3266 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3267 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3268 | end |
---|
| 3269 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3270 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3271 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3272 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3273 | end |
---|
[133] | 3274 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3275 | |
---|
[12] | 3276 | %------------------------------------------------------------------------ |
---|
[2] | 3277 | % --- Executes on button press in get_mask_fix1. |
---|
| 3278 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3279 | %------------------------------------------------------------------------ |
---|
[2] | 3280 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3281 | if isequal(maskval,0) |
---|
| 3282 | set(handles.mask_fix1,'String','') |
---|
| 3283 | else |
---|
[112] | 3284 | mask_displ='no mask'; %default |
---|
| 3285 | filebase=get(handles.RootName,'String'); |
---|
| 3286 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3287 | if isequal(flag_mask,1) |
---|
| 3288 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3289 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3290 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3291 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3292 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3293 | mask_displ='no mask'; |
---|
| 3294 | end |
---|
[112] | 3295 | end |
---|
| 3296 | if isequal(mask_displ,'no mask') |
---|
| 3297 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3298 | {'*.png', ' (*.png)'; |
---|
[12] | 3299 | '*.png', '.png files '; ... |
---|
| 3300 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3301 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3302 | mask_displ=fullfile(PathName,FileName); |
---|
| 3303 | if ~exist(mask_displ,'file') |
---|
| 3304 | mask_displ='no mask'; |
---|
| 3305 | end |
---|
[12] | 3306 | end |
---|
[112] | 3307 | if isequal(mask_displ,'no mask') |
---|
| 3308 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3309 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3310 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3311 | else |
---|
| 3312 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3313 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3314 | end |
---|
| 3315 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3316 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3317 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3318 | end |
---|
| 3319 | |
---|
| 3320 | %------------------------------------------------------------------------ |
---|
[133] | 3321 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3322 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3323 | %------------------------------------------------------------------------ |
---|
[2] | 3324 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3325 | if isequal(maskval,0) |
---|
| 3326 | set(handles.mask_civ2,'String','') |
---|
| 3327 | else |
---|
[112] | 3328 | mask_displ='no mask'; %default |
---|
| 3329 | filebase=get(handles.RootName,'String'); |
---|
| 3330 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3331 | if isequal(flag_mask,1) |
---|
| 3332 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3333 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3334 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3335 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3336 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3337 | mask_displ='no mask'; |
---|
| 3338 | end |
---|
[112] | 3339 | end |
---|
| 3340 | if isequal(mask_displ,'no mask') |
---|
| 3341 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3342 | {'*.png', ' (*.png)'; |
---|
[12] | 3343 | '*.png', '.png files '; ... |
---|
| 3344 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3345 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3346 | mask_displ=fullfile(PathName,FileName); |
---|
| 3347 | if ~exist(mask_displ,'file') |
---|
| 3348 | mask_displ='no mask'; |
---|
| 3349 | end |
---|
[12] | 3350 | end |
---|
[112] | 3351 | if isequal(mask_displ,'no mask') |
---|
| 3352 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3353 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3354 | else |
---|
| 3355 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3356 | end |
---|
| 3357 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3358 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3359 | end |
---|
| 3360 | |
---|
| 3361 | %------------------------------------------------------------------------ |
---|
[2] | 3362 | % --- Executes on button press in get_mask_fix2. |
---|
| 3363 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3364 | %------------------------------------------------------------------------ |
---|
[2] | 3365 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3366 | if isequal(maskval,0) |
---|
| 3367 | set(handles.mask_fix2,'String','') |
---|
| 3368 | else |
---|
[12] | 3369 | mask_displ='no mask'; %default |
---|
[71] | 3370 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3371 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3372 | if isequal(flag_mask,1) |
---|
[112] | 3373 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3374 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3375 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3376 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3377 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3378 | mask_displ='no mask'; |
---|
| 3379 | end |
---|
[12] | 3380 | end |
---|
| 3381 | if isequal(mask_displ,'no mask') |
---|
| 3382 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3383 | {'*.png', ' (*.png)'; |
---|
| 3384 | '*.png', '.png files '; ... |
---|
| 3385 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3386 | 'Pick a mask file *.png',filebase); |
---|
| 3387 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3388 | if ~exist(mask_displ,'file') |
---|
[2] | 3389 | mask_displ='no mask'; |
---|
| 3390 | end |
---|
[12] | 3391 | end |
---|
| 3392 | if isequal(mask_displ,'no mask') |
---|
| 3393 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3394 | end |
---|
[12] | 3395 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3396 | end |
---|
| 3397 | |
---|
[12] | 3398 | %------------------------------------------------------------------------ |
---|
| 3399 | % --- function called to look for mask files |
---|
[2] | 3400 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3401 | %------------------------------------------------------------------------ |
---|
[112] | 3402 | %detect mask files, images with appropriate file base |
---|
[2] | 3403 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3404 | %flag_mask=1 indicates detection |
---|
| 3405 | |
---|
| 3406 | flag_mask=0;%default |
---|
| 3407 | nbslice=1; |
---|
| 3408 | |
---|
| 3409 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3410 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3411 | if ~isdir(Path) |
---|
| 3412 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3413 | return |
---|
| 3414 | end |
---|
[2] | 3415 | currentdir=pwd; |
---|
| 3416 | cd(Path);%move in the dir of the root name filebase |
---|
| 3417 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 3418 | cd(currentdir);%come back to the current working directory |
---|
[12] | 3419 | if ~isempty(maskfiles) |
---|
[112] | 3420 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3421 | % else |
---|
[2] | 3422 | flag_mask=1; |
---|
| 3423 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3424 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3425 | Namedouble=double(Name); |
---|
| 3426 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3427 | ind_mask=findstr('mask',Name); |
---|
| 3428 | i=ind_mask-1; |
---|
[137] | 3429 | while val(i)==0 && i>0 |
---|
[112] | 3430 | i=i-1; |
---|
[2] | 3431 | end |
---|
[137] | 3432 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3433 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3434 | flag_mask=1; |
---|
[2] | 3435 | else |
---|
[112] | 3436 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3437 | return |
---|
| 3438 | nbslice=1; |
---|
[2] | 3439 | end |
---|
[112] | 3440 | end |
---|
[2] | 3441 | |
---|
[12] | 3442 | %------------------------------------------------------------------------ |
---|
| 3443 | % --- function called to look for grid files |
---|
[2] | 3444 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3445 | %------------------------------------------------------------------------ |
---|
[2] | 3446 | flag_mask=0;%default |
---|
| 3447 | nbslice=1; |
---|
| 3448 | [Path,Name]=fileparts(filebase); |
---|
| 3449 | currentdir=pwd; |
---|
| 3450 | cd(Path);%move in the dir of the root name filebase |
---|
| 3451 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3452 | cd(currentdir);%come back to the current working directory |
---|
| 3453 | if ~isempty(maskfiles) |
---|
| 3454 | flag_mask=1; |
---|
| 3455 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3456 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3457 | Namedouble=double(Name); |
---|
| 3458 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3459 | ind_mask=findstr('grid',Name); |
---|
| 3460 | i=ind_mask-1; |
---|
[137] | 3461 | while val(i)==0 && i>0 |
---|
[112] | 3462 | i=i-1; |
---|
[2] | 3463 | end |
---|
[137] | 3464 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3465 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3466 | flag_mask=1; |
---|
[2] | 3467 | else |
---|
[112] | 3468 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3469 | return |
---|
| 3470 | nbslice=1; |
---|
[2] | 3471 | end |
---|
[12] | 3472 | end |
---|
[2] | 3473 | |
---|
[12] | 3474 | %------------------------------------------------------------------------ |
---|
| 3475 | % --- transform numbers to letters |
---|
[122] | 3476 | function str=num2stra(num,nom_type) |
---|
[12] | 3477 | %------------------------------------------------------------------------ |
---|
[122] | 3478 | if isempty(nom_type) |
---|
| 3479 | str=''; |
---|
| 3480 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3481 | str=char(96+num); |
---|
[122] | 3482 | elseif strcmp(nom_type(end),'A') |
---|
| 3483 | str=char(96+num); |
---|
| 3484 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3485 | str=''; |
---|
| 3486 | else |
---|
| 3487 | str=num2str(num); |
---|
| 3488 | end |
---|
[12] | 3489 | |
---|
[173] | 3490 | % %------------------------------------------------------------------------ |
---|
| 3491 | % function mask_civ1_Callback(hObject, eventdata, handles) |
---|
| 3492 | % %------------------------------------------------------------------------ |
---|
| 3493 | % set(handles.mask_civ1,'UserData',[]) |
---|
| 3494 | % set(handles.mask_civ1,'String','') |
---|
| 3495 | % |
---|
| 3496 | % %------------------------------------------------------------------------ |
---|
| 3497 | % function mask_civ2_Callback(hObject, eventdata, handles) |
---|
| 3498 | % %------------------------------------------------------------------------ |
---|
| 3499 | % set(handles.mask_civ2,'UserData',[]) |
---|
| 3500 | % set(handles.mask_civ2,'String','') |
---|
| 3501 | % |
---|
| 3502 | % %------------------------------------------------------------------------ |
---|
| 3503 | % function mask_fix1_Callback(hObject, eventdata, handles) |
---|
| 3504 | % %------------------------------------------------------------------------ |
---|
| 3505 | % set(handles.mask_fix1,'UserData',[]) |
---|
| 3506 | % set(handles.mask_fix1,'String','') |
---|
| 3507 | % |
---|
| 3508 | % %------------------------------------------------------------------------ |
---|
| 3509 | % function mask_fix2_Callback(hObject, eventdata, handles) |
---|
| 3510 | % %------------------------------------------------------------------------ |
---|
| 3511 | % set(handles.mask_fix2,'UserData',[]) |
---|
| 3512 | % set(handles.mask_fix2,'String','') |
---|
[12] | 3513 | |
---|
| 3514 | %------------------------------------------------------------------------ |
---|
[2] | 3515 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3516 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3517 | %------------------------------------------------------------------------ |
---|
[2] | 3518 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3519 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 3520 | if val>1 |
---|
| 3521 | subdir=list_subdir_civ1{val}; |
---|
| 3522 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3523 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 3524 | end |
---|
| 3525 | |
---|
[12] | 3526 | %------------------------------------------------------------------------ |
---|
[2] | 3527 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3528 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3529 | %------------------------------------------------------------------------ |
---|
[2] | 3530 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3531 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 3532 | if val>1 |
---|
| 3533 | subdir=list_subdir_civ2{val}; |
---|
| 3534 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3535 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 3536 | end |
---|
| 3537 | |
---|
[12] | 3538 | %------------------------------------------------------------------------ |
---|
[2] | 3539 | % --- Executes on button press in browse_gridciv1. |
---|
| 3540 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3541 | %------------------------------------------------------------------------ |
---|
[2] | 3542 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3543 | testgrid=0; |
---|
| 3544 | if value |
---|
[112] | 3545 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3546 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3547 | if isequal(flag_grid,1) |
---|
[112] | 3548 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3549 | testgrid=1; |
---|
| 3550 | else |
---|
[2] | 3551 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3552 | {'*.grid', ' (*.grid)'; |
---|
| 3553 | '*.grid', '.grid files '; ... |
---|
| 3554 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3555 | 'Pick a file',filebase); |
---|
[2] | 3556 | filegrid=fullfile(PathName,FileName); |
---|
| 3557 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3558 | testgrid=1; |
---|
| 3559 | end |
---|
[112] | 3560 | end |
---|
[2] | 3561 | end |
---|
| 3562 | if testgrid |
---|
[112] | 3563 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3564 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3565 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3566 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3567 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3568 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3569 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3570 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3571 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3572 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3573 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3574 | else |
---|
| 3575 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3576 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3577 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3578 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3579 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3580 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3581 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3582 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3583 | set(handles.grid_civ1,'String','') |
---|
| 3584 | set(handles.grid_patch1,'String','') |
---|
| 3585 | set(handles.grid_civ2,'String','') |
---|
| 3586 | set(handles.grid_patch2,'String','') |
---|
[2] | 3587 | end |
---|
| 3588 | |
---|
[12] | 3589 | %------------------------------------------------------------------------ |
---|
[2] | 3590 | % --- Executes on button press in browse_gridciv1. |
---|
| 3591 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3592 | %------------------------------------------------------------------------ |
---|
[2] | 3593 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3594 | if value |
---|
[112] | 3595 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3596 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3597 | if isequal(flag_grid,1) |
---|
| 3598 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3599 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3600 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3601 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3602 | else |
---|
[2] | 3603 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3604 | {'*.grid', ' (*.grid)'; |
---|
| 3605 | '*.grid', '.grid files '; ... |
---|
| 3606 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3607 | 'Pick a file',filebase); |
---|
[2] | 3608 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3609 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[2] | 3610 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3611 | set(handles.grid_civ2,'string',''); |
---|
| 3612 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3613 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3614 | set(handles.grid_civ2,'string',''); |
---|
| 3615 | else |
---|
| 3616 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3617 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3618 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3619 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3620 | end |
---|
| 3621 | end |
---|
| 3622 | else |
---|
| 3623 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3624 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3625 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3626 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3627 | end |
---|
| 3628 | |
---|
| 3629 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3630 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3631 | % |
---|
[71] | 3632 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3633 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3634 | % {'*.grid', ' (*.grid)'; |
---|
| 3635 | % '*.grid', '.grid files '; ... |
---|
| 3636 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3637 | % 'Pick a file',filebase); |
---|
| 3638 | % filegrid=fullfile(PathName,FileName); |
---|
| 3639 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3640 | % set(handles.dx_civ2,'String',' '); |
---|
| 3641 | % set(handles.dy_civ2,'String',' '); |
---|
| 3642 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3643 | |
---|
| 3644 | % --- Executes on button press in get_gridpatch1. |
---|
| 3645 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3646 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3647 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3648 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3649 | |
---|
[71] | 3650 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3651 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3652 | {'*.grid', ' (*.grid)'; |
---|
| 3653 | '*.grid', '.grid files '; ... |
---|
| 3654 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3655 | 'Pick a file',filebase); |
---|
[2] | 3656 | filegrid=fullfile(PathName,FileName); |
---|
| 3657 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3658 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3659 | |
---|
[12] | 3660 | %------------------------------------------------------------------------ |
---|
[2] | 3661 | % --- Executes on button press in get_gridpatch2. |
---|
| 3662 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3663 | %------------------------------------------------------------------------ |
---|
[2] | 3664 | |
---|
[12] | 3665 | %------------------------------------------------------------------------ |
---|
[2] | 3666 | function enable_civ1(handles,state) |
---|
[12] | 3667 | %------------------------------------------------------------------------ |
---|
[2] | 3668 | if isequal(state,'on') |
---|
| 3669 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3670 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3671 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3672 | else |
---|
| 3673 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3674 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3675 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3676 | end |
---|
| 3677 | set(handles.ibx,'Visible',state) |
---|
| 3678 | set(handles.iby,'Visible',state) |
---|
| 3679 | set(handles.isx,'Visible',state) |
---|
| 3680 | set(handles.isy,'Visible',state) |
---|
| 3681 | set(handles.shiftx,'Visible',state) |
---|
| 3682 | set(handles.shifty,'Visible',state) |
---|
| 3683 | set(handles.rho,'Visible',state) |
---|
| 3684 | set(handles.dx_civ1,'Visible',state) |
---|
| 3685 | set(handles.dy_civ1,'Visible',state) |
---|
| 3686 | set(handles.calcul_search,'Visible',state) |
---|
| 3687 | set(handles.u_text,'Visible',state) |
---|
| 3688 | set(handles.v_text,'Visible',state) |
---|
| 3689 | set(handles.min,'Visible',state) |
---|
| 3690 | set(handles.max,'Visible',state) |
---|
| 3691 | set(handles.umin,'Visible',state) |
---|
| 3692 | set(handles.umax,'Visible',state) |
---|
| 3693 | set(handles.vmin,'Visible',state) |
---|
| 3694 | set(handles.vmax,'Visible',state) |
---|
| 3695 | set(handles.grid_civ1,'Visible',state) |
---|
| 3696 | set(handles.mask_civ1,'Visible',state) |
---|
| 3697 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3698 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3699 | set(handles.parameters,'Visible',state) |
---|
| 3700 | set(handles.grid,'Visible',state) |
---|
| 3701 | set(handles.dx_civ1,'Visible',state) |
---|
| 3702 | set(handles.dy_civ1,'Visible',state) |
---|
| 3703 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3704 | if isequal(state,'off') |
---|
| 3705 | set(handles.MinIma,'Visible','off') |
---|
| 3706 | set(handles.MaxIma,'Visible','off') |
---|
| 3707 | set(handles.ImaThreshold,'Value',0) |
---|
| 3708 | end |
---|
| 3709 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3710 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3711 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3712 | set(handles.ib_title,'Visible',state) |
---|
| 3713 | set(handles.is_title,'Visible',state) |
---|
| 3714 | set(handles.shift_title,'Visible',state) |
---|
| 3715 | set(handles.rho_title,'Visible',state) |
---|
[224] | 3716 | set(handles.TestCiv1,'Visible',state) |
---|
| 3717 | %set(handles.CivAll,'Visible',state) |
---|
[2] | 3718 | |
---|
[12] | 3719 | %------------------------------------------------------------------------ |
---|
[2] | 3720 | function enable_fix1(handles,state) |
---|
[12] | 3721 | %------------------------------------------------------------------------ |
---|
[2] | 3722 | if isequal(state,0) |
---|
| 3723 | state='off'; |
---|
| 3724 | end |
---|
| 3725 | if isequal(state,1) |
---|
| 3726 | state='on'; |
---|
| 3727 | end |
---|
| 3728 | if isequal(state,'on') |
---|
| 3729 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 3730 | else |
---|
| 3731 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3732 | end |
---|
| 3733 | set(handles.REMOVE,'Visible',state) |
---|
| 3734 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3735 | set(handles.vec_F2,'Visible',state) |
---|
| 3736 | set(handles.vec_F3,'Visible',state) |
---|
| 3737 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3738 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3739 | set(handles.thresh_vel,'Visible',state) |
---|
| 3740 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3741 | set(handles.mask_fix1,'Visible',state) |
---|
| 3742 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3743 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3744 | set(handles.ref_fix1,'Visible',state) |
---|
| 3745 | set(handles.inf_sup1,'Visible',state) |
---|
| 3746 | set(handles.field_ref1,'Visible',state) |
---|
| 3747 | |
---|
[12] | 3748 | %------------------------------------------------------------------------ |
---|
[2] | 3749 | function enable_patch1(handles) |
---|
[12] | 3750 | %------------------------------------------------------------------------ |
---|
[2] | 3751 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3752 | set(handles.rho_patch1,'Visible','on') |
---|
| 3753 | set(handles.rho_text1,'Visible','on') |
---|
[225] | 3754 | if get(handles.CivAll,'Value')==2 |
---|
[224] | 3755 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3756 | set(handles.thresh_text1,'Visible','on') |
---|
| 3757 | end |
---|
[2] | 3758 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3759 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3760 | set(handles.nx_patch1,'Visible','on') |
---|
| 3761 | set(handles.ny_patch1,'Visible','on') |
---|
| 3762 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3763 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3764 | % if ~isempty(patch_newBin) |
---|
[224] | 3765 | set(handles.test_interp,'Visible','off'); |
---|
[100] | 3766 | % end |
---|
[2] | 3767 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 3768 | set(handles.grid_patch1,'string','none'); |
---|
| 3769 | set(handles.grid_patch1,'Visible','on') |
---|
| 3770 | |
---|
[12] | 3771 | %------------------------------------------------------------------------ |
---|
[2] | 3772 | function desable_patch1(handles) |
---|
[12] | 3773 | %------------------------------------------------------------------------ |
---|
[2] | 3774 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3775 | set(handles.rho_patch1,'Visible','off') |
---|
| 3776 | set(handles.rho_text1,'Visible','off') |
---|
| 3777 | set(handles.thresh_patch1,'Visible','off') |
---|
| 3778 | set(handles.thresh_text1,'Visible','off') |
---|
| 3779 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 3780 | set(handles.subdomain_text1,'Visible','off') |
---|
| 3781 | set(handles.nx_patch1,'Visible','off') |
---|
| 3782 | set(handles.ny_patch1,'Visible','off') |
---|
| 3783 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 3784 | set(handles.ny_patch1_title,'Visible','off') |
---|
[100] | 3785 | %set(handles.test_interp,'Visible','off') |
---|
[2] | 3786 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 3787 | set(handles.grid_patch1,'Visible','off') |
---|
| 3788 | |
---|
[12] | 3789 | %------------------------------------------------------------------------ |
---|
[2] | 3790 | function enable_civ2(handles,state) |
---|
[12] | 3791 | %------------------------------------------------------------------------ |
---|
[2] | 3792 | if isequal(state,0) |
---|
| 3793 | state='off'; |
---|
| 3794 | end |
---|
| 3795 | if isequal(state,1) |
---|
| 3796 | state='on'; |
---|
| 3797 | end |
---|
| 3798 | if isequal(state,'on') |
---|
| 3799 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3800 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3801 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3802 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3803 | else |
---|
| 3804 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3805 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3806 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3807 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3808 | end |
---|
| 3809 | set(handles.ibx_civ2,'Visible',state) |
---|
| 3810 | set(handles.iby_civ2,'Visible',state) |
---|
| 3811 | set(handles.decimal,'Visible',state) |
---|
| 3812 | set(handles.deformation,'Visible',state) |
---|
| 3813 | set(handles.rho_civ2,'Visible',state) |
---|
| 3814 | set(handles.dx_civ2,'Visible',state) |
---|
| 3815 | set(handles.dy_civ2,'Visible',state) |
---|
| 3816 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 3817 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 3818 | set(handles.parameters,'Visible',state) |
---|
| 3819 | set(handles.grid,'Visible',state) |
---|
| 3820 | set(handles.parameters_text,'Visible',state) |
---|
| 3821 | set(handles.grid_text,'Visible',state) |
---|
| 3822 | set(handles.grid_civ2,'Visible',state) |
---|
| 3823 | set(handles.mask_civ2,'Visible',state) |
---|
| 3824 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 3825 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 3826 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3827 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 3828 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 3829 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3830 | if isequal(state,'off') |
---|
| 3831 | set(handles.MinIma2,'Visible','off') |
---|
| 3832 | set(handles.MaxIma2,'Visible','off') |
---|
| 3833 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 3834 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3835 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3836 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3837 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 3838 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3839 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 3840 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3841 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3842 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 3843 | end |
---|
| 3844 | else |
---|
| 3845 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3846 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3847 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 3848 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3849 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 3850 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3851 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3852 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 3853 | end |
---|
[71] | 3854 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3855 | |
---|
[12] | 3856 | %------------------------------------------------------------------------ |
---|
[2] | 3857 | function enable_fix2(handles) |
---|
[12] | 3858 | %------------------------------------------------------------------------ |
---|
[2] | 3859 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3860 | set(handles.REMOVE2,'Visible','on') |
---|
| 3861 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 3862 | set(handles.vec_F4,'Visible','on') |
---|
| 3863 | set(handles.vec_F3_2,'Visible','on') |
---|
| 3864 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 3865 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 3866 | set(handles.thresh_vel2,'Visible','on') |
---|
| 3867 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 3868 | set(handles.mask_fix2,'Visible','on') |
---|
| 3869 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 3870 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3871 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3872 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3873 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 3874 | set(handles.ref_fix2,'Visible','on') |
---|
| 3875 | set(handles.inf_sup2,'Visible','on') |
---|
| 3876 | set(handles.field_ref2,'Visible','on') |
---|
| 3877 | |
---|
[12] | 3878 | %------------------------------------------------------------------------ |
---|
[2] | 3879 | function desable_fix2(handles) |
---|
[12] | 3880 | %------------------------------------------------------------------------ |
---|
[2] | 3881 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3882 | set(handles.REMOVE2,'Visible','off') |
---|
| 3883 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 3884 | set(handles.vec_F4,'Visible','off') |
---|
| 3885 | set(handles.vec_F3_2,'Visible','off') |
---|
| 3886 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 3887 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 3888 | set(handles.thresh_vel2,'Visible','off') |
---|
| 3889 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 3890 | set(handles.mask_fix2,'Visible','off') |
---|
| 3891 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 3892 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 3893 | set(handles.ref_fix2,'Visible','off') |
---|
| 3894 | set(handles.inf_sup2,'Visible','off') |
---|
| 3895 | set(handles.field_ref2,'Visible','off') |
---|
[112] | 3896 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3897 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3898 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3899 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3900 | end |
---|
| 3901 | |
---|
[12] | 3902 | %------------------------------------------------------------------------ |
---|
[2] | 3903 | function enable_patch2(handles) |
---|
[12] | 3904 | %------------------------------------------------------------------------ |
---|
[2] | 3905 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[119] | 3906 | set(handles.rho_patch2,'Visible','on') |
---|
[2] | 3907 | set(handles.rho_text2,'Visible','on') |
---|
| 3908 | set(handles.thresh_patch2,'Visible','on') |
---|
| 3909 | set(handles.thresh_text2,'Visible','on') |
---|
| 3910 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 3911 | set(handles.subdomain_text2,'Visible','on') |
---|
| 3912 | set(handles.nx_patch2,'Visible','on') |
---|
| 3913 | set(handles.ny_patch2,'Visible','on') |
---|
| 3914 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 3915 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 3916 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 3917 | set(handles.grid_patch2,'Visible','on') |
---|
| 3918 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3919 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3920 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3921 | |
---|
[12] | 3922 | %------------------------------------------------------------------------ |
---|
[2] | 3923 | function desable_patch2(handles) |
---|
[12] | 3924 | %------------------------------------------------------------------------ |
---|
[2] | 3925 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3926 | set(handles.rho_patch2,'Visible','off') |
---|
| 3927 | set(handles.rho_text2,'Visible','off') |
---|
| 3928 | set(handles.thresh_patch2,'Visible','off') |
---|
| 3929 | set(handles.thresh_text2,'Visible','off') |
---|
| 3930 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 3931 | set(handles.subdomain_text2,'Visible','off') |
---|
| 3932 | set(handles.nx_patch2,'Visible','off') |
---|
| 3933 | set(handles.ny_patch2,'Visible','off') |
---|
| 3934 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 3935 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 3936 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 3937 | set(handles.grid_patch2,'Visible','off') |
---|
[112] | 3938 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
[2] | 3939 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3940 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3941 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3942 | end |
---|
| 3943 | |
---|
[12] | 3944 | %------------------------------------------------------------------------ |
---|
[2] | 3945 | function enable_pair1(handles,state) |
---|
[12] | 3946 | %------------------------------------------------------------------------ |
---|
[2] | 3947 | set(handles.subdir_civ1,'Visible',state) |
---|
| 3948 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 3949 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 3950 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 3951 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 3952 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 3953 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 3954 | set(handles.PAIR_frame,'Visible',state) |
---|
| 3955 | |
---|
[12] | 3956 | %------------------------------------------------------------------------ |
---|
| 3957 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 3958 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 3959 | %------------------------------------------------------------------------ |
---|
[127] | 3960 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 3961 | par.ibx=num2str(ibx_val); |
---|
[127] | 3962 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 3963 | par.iby=num2str(iby_val); |
---|
| 3964 | isx=get(handles.isx,'String'); |
---|
[127] | 3965 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3966 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 3967 | isy=get(handles.isy,'String'); |
---|
[127] | 3968 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3969 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 3970 | par.isx=get(handles.isx,'String'); |
---|
| 3971 | par.isy=get(handles.isy,'String'); |
---|
| 3972 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 3973 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 3974 | if isnan(str2double(par.isx)) |
---|
[112] | 3975 | par.isx='41';%default |
---|
| 3976 | set(handles.isx,'String','41'); |
---|
[2] | 3977 | end |
---|
[127] | 3978 | if isnan(str2double(par.isy)) |
---|
[112] | 3979 | par.isy='41'; %default |
---|
| 3980 | set(handles.isy,'String','41'); |
---|
[12] | 3981 | end |
---|
[127] | 3982 | if isnan(str2double(par.shiftx)) |
---|
[112] | 3983 | par.shiftx='0';%default |
---|
| 3984 | set(handles.shiftx,'String','0'); |
---|
| 3985 | end |
---|
[127] | 3986 | if isnan(str2double(par.shifty)) |
---|
[112] | 3987 | par.shifty='0'; %default |
---|
| 3988 | set(handles.shifty,'String','0'); |
---|
[12] | 3989 | end |
---|
[112] | 3990 | par.rho=get(handles.rho,'String'); |
---|
[238] | 3991 | if isequal(get(handles.rho,'Style'),'popupmenu') |
---|
| 3992 | index=get(handles.rho,'Value'); |
---|
| 3993 | par.rho=par.rho{index}; |
---|
| 3994 | end |
---|
[112] | 3995 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 3996 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 3997 | if isnan(str2double(par.dx)) |
---|
[112] | 3998 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 3999 | par.dx='0'; %just read by civ program, not used |
---|
| 4000 | else |
---|
[12] | 4001 | par.dx='20';%default |
---|
| 4002 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 4003 | end |
---|
| 4004 | end |
---|
[127] | 4005 | if isnan(str2double(par.dy)) |
---|
[112] | 4006 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4007 | par.dy='0';%just read by civ program, not used |
---|
| 4008 | else |
---|
[12] | 4009 | par.dy='20';%default |
---|
| 4010 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 4011 | end |
---|
| 4012 | end |
---|
| 4013 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4014 | par.pxcmy='1'; |
---|
[150] | 4015 | if exist('file_ima','var') |
---|
[112] | 4016 | A=imread(file_ima);%read the first image to get the size |
---|
| 4017 | sizim=size(A); |
---|
| 4018 | par.npx=num2str(sizim(2)); |
---|
| 4019 | par.npy=num2str(sizim(1)); |
---|
[150] | 4020 | end |
---|
[127] | 4021 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 4022 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4023 | par.gridflag='y'; |
---|
[127] | 4024 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 4025 | par.gridname='nogrid'; |
---|
| 4026 | par.gridflag='n'; |
---|
| 4027 | end |
---|
[12] | 4028 | |
---|
| 4029 | %------------------------------------------------------------------------ |
---|
[2] | 4030 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4031 | %------------------------------------------------------------------------ |
---|
| 4032 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4033 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4034 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4035 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4036 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4037 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4038 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 4039 | if isnan(str2double(par.dx)) |
---|
[112] | 4040 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4041 | par.dx='0'; %just read by civ program, not used |
---|
| 4042 | else |
---|
[12] | 4043 | par.dx='20';%default |
---|
| 4044 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 4045 | end |
---|
| 4046 | end |
---|
[127] | 4047 | if isnan(str2double(par.dy)) |
---|
[112] | 4048 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4049 | par.dy='0';%just read by civ program, not used |
---|
| 4050 | else |
---|
[12] | 4051 | par.dy='20';%default |
---|
| 4052 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 4053 | end |
---|
| 4054 | end |
---|
| 4055 | par.pxcmx='1'; |
---|
| 4056 | par.pxcmy='1'; |
---|
[12] | 4057 | A=imread(file_ima);%read the first image to get the size |
---|
| 4058 | sizim=size(A); |
---|
| 4059 | par.npx=num2str(sizim(2)); |
---|
| 4060 | par.npy=num2str(sizim(1)); |
---|
[127] | 4061 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4062 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4063 | par.gridflag='y'; |
---|
[127] | 4064 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4065 | par.gridname='nogrid'; |
---|
| 4066 | par.gridflag='n'; |
---|
| 4067 | end |
---|
[2] | 4068 | |
---|
[12] | 4069 | %------------------------------------------------------------------------ |
---|
| 4070 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4071 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4072 | %------------------------------------------------------------------------ |
---|
[2] | 4073 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4074 | |
---|
| 4075 | %changes : filename_cmx -> filename ( no extension ) |
---|
[174] | 4076 | % input namelog not used |
---|
[112] | 4077 | if isequal(par.Dt,'0') |
---|
| 4078 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4079 | end |
---|
[90] | 4080 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4081 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
[230] | 4082 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4083 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[112] | 4084 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4085 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4086 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4087 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4088 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
| 4089 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4090 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4091 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4092 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4093 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4094 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4095 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4096 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4097 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4098 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4099 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4100 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
| 4101 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4102 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4103 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4104 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4105 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4106 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4107 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4108 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4109 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4110 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4111 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4112 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4113 | fclose(fid); |
---|
[112] | 4114 | |
---|
[163] | 4115 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4116 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4117 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4118 | if(isunix) |
---|
[230] | 4119 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; |
---|
| 4120 | cmd_CIV1=[cmd_CIV1 sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[219] | 4121 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
[230] | 4122 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
[163] | 4123 | else %Windows system |
---|
[230] | 4124 | flname=regexprep(flname,'\\','\\\\'); |
---|
| 4125 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
[174] | 4126 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4127 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx |
---|
[163] | 4128 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4129 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4130 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
[230] | 4131 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4132 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
[12] | 4133 | end |
---|
[2] | 4134 | |
---|
[12] | 4135 | %------------------------------------------------------------------------ |
---|
| 4136 | % --- CIV1 Unified |
---|
[94] | 4137 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4138 | %------------------------------------------------------------------------ |
---|
[2] | 4139 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4140 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4141 | |
---|
[112] | 4142 | civ1.image1=par.filename_ima_a; |
---|
| 4143 | civ1.image2=par.filename_ima_b; |
---|
| 4144 | civ1.imageSize_X=par.npx; |
---|
| 4145 | civ1.imageSize_Y=par.npy; |
---|
| 4146 | civ1.outputFileName=[filename '.nc']; |
---|
| 4147 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4148 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4149 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4150 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4151 | civ1.globalShift_X=par.shiftx; |
---|
| 4152 | civ1.globalShift_Y=par.shifty; |
---|
| 4153 | civ1.ro=par.rho; |
---|
| 4154 | civ1.hart='y'; |
---|
| 4155 | if isequal(par.gridflag,'y') |
---|
| 4156 | civ1.grid=par.gridname; |
---|
| 4157 | else |
---|
| 4158 | civ1.grid='n'; |
---|
| 4159 | civ1.gridSpacing_X=par.dx; |
---|
| 4160 | civ1.gridSpacing_Y=par.dy; |
---|
| 4161 | end |
---|
| 4162 | if isequal(par.maskflag,'y') |
---|
| 4163 | civ1.mask=par.maskname; |
---|
| 4164 | end |
---|
[229] | 4165 | civ1.dt=par.Dt; |
---|
[112] | 4166 | civ1.unit='pixel'; |
---|
| 4167 | civ1.absolut_time_T0=par.T0; |
---|
| 4168 | civ1.pixcmx=par.pxcmx; |
---|
| 4169 | civ1.pixcmy=par.pxcmy; |
---|
| 4170 | civ1.convectFlow='n'; |
---|
[12] | 4171 | |
---|
[112] | 4172 | xml_civ1_parameters=civ1; |
---|
| 4173 | |
---|
[12] | 4174 | %------------------------------------------------------------------------ |
---|
| 4175 | % --- CIV2 Unified |
---|
[94] | 4176 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4177 | %------------------------------------------------------------------------ |
---|
[2] | 4178 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4179 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4180 | |
---|
| 4181 | civ2.image1=par.filename_ima_a; |
---|
| 4182 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4183 | civ2.imageSize_X=par.npx; |
---|
[2] | 4184 | civ2.imageSize_Y=par.npy; |
---|
| 4185 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4186 | civ2.outputFileName=[filename '.nc']; |
---|
| 4187 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4188 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4189 | civ2.ro=par.rho; |
---|
| 4190 | %civ2.decimalShift=par.decimal; |
---|
| 4191 | %civ2.deformation=par.deformation; |
---|
| 4192 | if isequal(par.decimal,'1') |
---|
| 4193 | civ2.decimalShift='y'; |
---|
| 4194 | else |
---|
| 4195 | civ2.decimalShift='n'; |
---|
| 4196 | end |
---|
| 4197 | if isequal(par.deformation,'1') |
---|
| 4198 | civ2.deformation='y'; |
---|
| 4199 | else |
---|
| 4200 | civ2.deformation='n'; |
---|
| 4201 | end |
---|
| 4202 | if isequal(par.gridflag,'y') |
---|
| 4203 | civ2.grid=par.gridname; |
---|
| 4204 | else |
---|
| 4205 | civ2.grid='n'; |
---|
| 4206 | civ2.gridSpacing_X=par.dx; |
---|
| 4207 | civ2.gridSpacing_Y=par.dy; |
---|
| 4208 | end |
---|
| 4209 | civ2.gridSpacing_X='10'; |
---|
| 4210 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4211 | if isequal(par.maskflag,'y') |
---|
| 4212 | civ2.mask=par.maskname; |
---|
| 4213 | else |
---|
| 4214 | civ2.mask='n'; |
---|
| 4215 | end |
---|
| 4216 | civ2.dt=par.Dt; |
---|
| 4217 | civ2.unit='pixel'; |
---|
| 4218 | civ2.absolut_time_T0=par.T0; |
---|
| 4219 | civ2.pixcmx=par.pxcmx; |
---|
| 4220 | civ2.pixcmy=par.pxcmy; |
---|
| 4221 | civ2.convectFlow='n'; |
---|
| 4222 | civ2.pixcmx=par.pxcmx; |
---|
| 4223 | civ2.pixcmy=par.pxcmy; |
---|
| 4224 | civ2.convectFlow='n'; |
---|
| 4225 | |
---|
[12] | 4226 | %------------------------------------------------------------------------ |
---|
| 4227 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[134] | 4228 | function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam) |
---|
[12] | 4229 | %------------------------------------------------------------------------ |
---|
[2] | 4230 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4231 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[112] | 4232 | if isequal(par.Dt,'0') |
---|
| 4233 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4234 | end |
---|
[94] | 4235 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
| 4236 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4237 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4238 | if isequal(fid,-1) |
---|
| 4239 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4240 | cmd_CIV2=''; |
---|
| 4241 | return |
---|
| 4242 | end |
---|
[94] | 4243 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4244 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4245 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4246 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4247 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4248 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4249 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4250 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4251 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
---|
| 4252 | fprintf(fid, ['RO ' par.rho '\n']); |
---|
| 4253 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
---|
| 4254 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4255 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4256 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4257 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4258 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[94] | 4259 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4260 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
---|
| 4261 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4262 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4263 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4264 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4265 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
---|
| 4266 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
---|
| 4267 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4268 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4269 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4270 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4271 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4272 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
---|
| 4273 | fclose(fid); |
---|
| 4274 | |
---|
[134] | 4275 | if(isunix) |
---|
[230] | 4276 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
| 4277 | cmd_CIV2=[cmd_CIV2 sparam.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 4278 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
| 4279 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 4280 | |
---|
[163] | 4281 | else |
---|
[174] | 4282 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4283 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"\n']; |
---|
| 4284 | cmd_CIV2=[cmd_CIV2 '"' sparam.Civ2Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[163] | 4285 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
---|
[174] | 4286 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[230] | 4287 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; |
---|
[134] | 4288 | end |
---|
| 4289 | |
---|
[238] | 4290 | % %------------------------------------------------------------------------ |
---|
| 4291 | % % --- civ using pivlab |
---|
| 4292 | % function Data=civ_uvmat(par_civ1) |
---|
| 4293 | % %------------------------------------------------------------------------ |
---|
| 4294 | % image1=imread(par_civ1.filename_ima_a); |
---|
| 4295 | % image2=imread(par_civ1.filename_ima_b); |
---|
| 4296 | % stepx=str2num(par_civ1.dx); |
---|
| 4297 | % stepy=str2num(par_civ1.dy); |
---|
| 4298 | % ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
| 4299 | % iby2=ceil(str2num(par_civ1.iby)/2); |
---|
| 4300 | % isx2=ceil(str2num(par_civ1.isx)/2); |
---|
| 4301 | % isy2=ceil(str2num(par_civ1.isy)/2); |
---|
| 4302 | % shiftx=str2num(par_civ1.shiftx); |
---|
| 4303 | % shifty=str2num(par_civ1.shifty); |
---|
| 4304 | % miniy=max(1+isy2-shifty,1+iby2); |
---|
| 4305 | % minix=max(1+isx2-shiftx,1+ibx2); |
---|
| 4306 | % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); |
---|
| 4307 | % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); |
---|
| 4308 | % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
| 4309 | % PointCoord(:,1)=reshape(GridX,[],1); |
---|
| 4310 | % PointCoord(:,2)=reshape(GridY,[],1); |
---|
| 4311 | % % caluclate velocity data (y and v in indices, reverse to y component) |
---|
| 4312 | % [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); |
---|
| 4313 | % Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}]; |
---|
| 4314 | % Data.Conventions='uvmat/civdata'; |
---|
| 4315 | % Data.Program='civ_uvmat'; |
---|
| 4316 | % Data.CivStage=1; |
---|
| 4317 | % % list_param=fieldnames(Param.Civ1); |
---|
| 4318 | % % for ilist=1:length(list_param) |
---|
| 4319 | % % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';']) |
---|
| 4320 | % % end |
---|
| 4321 | % Data.Time=str2double(par_civ1.T0); |
---|
| 4322 | % Data.Dt=str2double(par_civ1.Dt); |
---|
| 4323 | % Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record |
---|
| 4324 | % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; |
---|
| 4325 | % Data.VarAttribute{1}.Role='coord_x'; |
---|
| 4326 | % Data.VarAttribute{2}.Role='coord_y'; |
---|
| 4327 | % Data.VarAttribute{3}.Role='vector_x'; |
---|
| 4328 | % Data.VarAttribute{4}.Role='vector_y'; |
---|
| 4329 | % Data.VarAttribute{5}.Role='warnflag'; |
---|
| 4330 | % Data.Civ1_X=reshape(xtable,[],1); |
---|
| 4331 | % Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1); |
---|
| 4332 | % Data.Civ1_U=reshape(utable,[],1); |
---|
| 4333 | % Data.Civ1_V=reshape(-vtable,[],1); |
---|
| 4334 | % Data.Civ1_C=reshape(ctable,[],1); |
---|
| 4335 | % Data.Civ1_F=reshape(F,[],1); |
---|
[134] | 4336 | |
---|
[12] | 4337 | %------------------------------------------------------------------------ |
---|
[2] | 4338 | % --- Executes on button press in HELP. |
---|
| 4339 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 4340 | %------------------------------------------------------------------------ |
---|
[2] | 4341 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4342 | pathelp=fileparts(path_to_uvmat); |
---|
[85] | 4343 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
[36] | 4344 | 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] | 4345 | else |
---|
[36] | 4346 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
[112] | 4347 | web([helpfile '#civ']) |
---|
[2] | 4348 | end |
---|
| 4349 | |
---|
[12] | 4350 | %------------------------------------------------------------------------ |
---|
[2] | 4351 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4352 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4353 | %------------------------------------------------------------------------ |
---|
[2] | 4354 | %num is the view number needed for an avi movie |
---|
[45] | 4355 | switch type_ima |
---|
| 4356 | case 'movie' |
---|
| 4357 | A=read(movieobject,num); |
---|
| 4358 | case 'avi' |
---|
[112] | 4359 | mov=aviread(filename,num); |
---|
| 4360 | A=frame2im(mov(1)); |
---|
[45] | 4361 | case 'multimage' |
---|
| 4362 | A=imread(filename,num); |
---|
[112] | 4363 | case 'image' |
---|
[45] | 4364 | A=imread(filename); |
---|
| 4365 | end |
---|
| 4366 | siz=size(A); |
---|
| 4367 | if length(siz)==3;%color images |
---|
[2] | 4368 | A=sum(double(A),3); |
---|
| 4369 | A=uint16(A); |
---|
| 4370 | end |
---|
| 4371 | |
---|
[12] | 4372 | %------------------------------------------------------------------------ |
---|
[2] | 4373 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4374 | %------------------------------------------------------------------------ |
---|
[2] | 4375 | mode_list=get(handles.mode,'String'); |
---|
| 4376 | mode_value=get(handles.mode,'Value'); |
---|
| 4377 | mode=mode_list{mode_value}; |
---|
[45] | 4378 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4379 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[112] | 4380 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4381 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4382 | end |
---|
| 4383 | |
---|
[12] | 4384 | %------------------------------------------------------------------------ |
---|
[2] | 4385 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4386 | %------------------------------------------------------------------------ |
---|
[2] | 4387 | mode_list=get(handles.mode,'String'); |
---|
| 4388 | mode_value=get(handles.mode,'Value'); |
---|
| 4389 | mode=mode_list{mode_value}; |
---|
[112] | 4390 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4391 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4392 | end |
---|
[45] | 4393 | if isequal(mode,'series(Dj)') || ... |
---|
[112] | 4394 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4395 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4396 | end |
---|
[12] | 4397 | |
---|
| 4398 | %------------------------------------------------------------------------ |
---|
[71] | 4399 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4400 | %------------------------------------------------------------------------ |
---|
| 4401 | mode_list=get(handles.mode,'String'); |
---|
| 4402 | mode_value=get(handles.mode,'Value'); |
---|
| 4403 | mode=mode_list{mode_value}; |
---|
| 4404 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4405 | |
---|
| 4406 | %------------------------------------------------------------------------ |
---|
| 4407 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4408 | %------------------------------------------------------------------------ |
---|
| 4409 | mode_list=get(handles.mode,'String'); |
---|
| 4410 | mode_value=get(handles.mode,'Value'); |
---|
| 4411 | mode=mode_list{mode_value}; |
---|
[112] | 4412 | if isequal(mode,'series(Dj)') |
---|
[71] | 4413 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4414 | end |
---|
| 4415 | |
---|
| 4416 | %------------------------------------------------------------------------ |
---|
[2] | 4417 | % --- Executes on button press in compare. |
---|
| 4418 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 4419 | %------------------------------------------------------------------------ |
---|
[2] | 4420 | test=get(handles.compare,'Value'); |
---|
[112] | 4421 | if test==2 || test==3 |
---|
[71] | 4422 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4423 | browse=get(handles.browse_root,'Userdata'); |
---|
| 4424 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 4425 | set(handles.browse_root,'UserData',browse); |
---|
| 4426 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4427 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[2] | 4428 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
[112] | 4429 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
[2] | 4430 | set(handles.mode,'Visible','off') |
---|
| 4431 | if test==2 |
---|
[112] | 4432 | set(handles.mode,'Visible','off') |
---|
[2] | 4433 | else |
---|
| 4434 | set(handles.mode,'Visible','on') |
---|
| 4435 | end |
---|
| 4436 | |
---|
[229] | 4437 | %% open an image file with the browser |
---|
[2] | 4438 | ind_opening=1;%default |
---|
| 4439 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4440 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4441 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4442 | '*.xml', '.xml files '; ... |
---|
| 4443 | '*.civ', '.civ files '; ... |
---|
| 4444 | '*.png','.png image files'; ... |
---|
| 4445 | '*.jpg',' jpeg image files'; ... |
---|
| 4446 | '*.tif','.tif image files'; ... |
---|
| 4447 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4448 | '*.nc','.netcdf files'; ... |
---|
| 4449 | '*.*', 'All Files (*.*)'}; |
---|
| 4450 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4451 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4452 | sizf=size(fileinput); |
---|
[229] | 4453 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4454 | [path,name,ext]=fileparts(fileinput); |
---|
| 4455 | [path1]=fileparts(filebase); |
---|
[229] | 4456 | % if isunix |
---|
| 4457 | % ['readlink ' path] |
---|
| 4458 | % [status,path]=system(['readlink ' path]) |
---|
| 4459 | % [status,path1]=system(['readlink ' path1])% look for the true path in case of symbolic paths |
---|
| 4460 | % end |
---|
[2] | 4461 | if ~strcmp(path1,path) |
---|
[112] | 4462 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
[2] | 4463 | return |
---|
| 4464 | end |
---|
[71] | 4465 | set(handles.RootName_1,'String',name); |
---|
[2] | 4466 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 4467 | browse=get(handles.browse_root,'UserData'); |
---|
| 4468 | browse.nom_type_ima_1=nom_type; |
---|
[112] | 4469 | set(handles.browse_root,'UserData',browse) |
---|
[2] | 4470 | |
---|
| 4471 | %check image extension |
---|
[71] | 4472 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[229] | 4473 | msgbox_uvmat('ERROR','The two input image series must have the same extension name') |
---|
[2] | 4474 | return |
---|
| 4475 | end |
---|
| 4476 | |
---|
[229] | 4477 | %% check coincidence of image sizes |
---|
| 4478 | ref_i=get(handles.ref_i,'string'); |
---|
| 4479 | ref_j=get(handles.ref_j,'string'); |
---|
| 4480 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
| 4481 | A=imread(filecell.ima1.civ1{1}); |
---|
| 4482 | A_1=imread(fileinput); |
---|
| 4483 | npxy=size(A); |
---|
| 4484 | npxy_1=size(A_1); |
---|
| 4485 | if ~isequal(size(A),size(A_1)) |
---|
| 4486 | msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
[2] | 4487 | return |
---|
| 4488 | end |
---|
| 4489 | else |
---|
| 4490 | set(handles.mode,'Visible','on') |
---|
[71] | 4491 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4492 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4493 | set(handles.RootName_1,'String',[]); |
---|
[2] | 4494 | mode_store=get(handles.compare,'UserData'); |
---|
[177] | 4495 | set(handles.mode,'Value',1) |
---|
[2] | 4496 | set(handles.mode,'String',mode_store) |
---|
| 4497 | set(handles.test_stereo1,'Value',0) |
---|
| 4498 | set(handles.test_stereo2,'Value',0) |
---|
| 4499 | end |
---|
| 4500 | mode_Callback(hObject, eventdata, handles) |
---|
| 4501 | |
---|
[12] | 4502 | %------------------------------------------------------------------------ |
---|
[2] | 4503 | % --- Executes on button press in get_ref_fix1. |
---|
| 4504 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4505 | %------------------------------------------------------------------------ |
---|
[71] | 4506 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4507 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4508 | {'*.nc', ' (*.nc)'; |
---|
| 4509 | '*.nc', 'netcdf files '; ... |
---|
| 4510 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4511 | 'Pick a file',filebase); |
---|
| 4512 | |
---|
[2] | 4513 | fileinput=[PathName FileName]; |
---|
| 4514 | sizf=size(fileinput); |
---|
[122] | 4515 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4516 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4517 | ref.filebase=fullfile(Path,File); |
---|
| 4518 | ref.num_a=stra2num(str_a); |
---|
| 4519 | ref.num_b=stra2num(str_b); |
---|
[89] | 4520 | ref.num1=str2double(field_count); |
---|
| 4521 | ref.num2=str2double(str2); |
---|
[2] | 4522 | browse=[];%initialisation |
---|
| 4523 | if ~isequal(ref.ext,'.nc') |
---|
| 4524 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4525 | return |
---|
| 4526 | end |
---|
| 4527 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4528 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4529 | menu_field{1}='civ1'; |
---|
| 4530 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4531 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4532 | menu_field{2}='filter1'; |
---|
| 4533 | end |
---|
[45] | 4534 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4535 | menu_field{3}='civ2'; |
---|
| 4536 | end |
---|
[45] | 4537 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4538 | menu_field{4}='filter2'; |
---|
| 4539 | end |
---|
| 4540 | set(handles.field_ref1,'String',menu_field); |
---|
| 4541 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 4542 | set(handles.inf_sup1,'Value',2); |
---|
| 4543 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 4544 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4545 | |
---|
| 4546 | %------------------------------------------------------------------------ |
---|
[2] | 4547 | % --- Executes on button press in get_ref_fix2. |
---|
| 4548 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4549 | %------------------------------------------------------------------------ |
---|
[2] | 4550 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4551 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4552 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4553 | {'*.nc', ' (*.nc)'; |
---|
| 4554 | '*.nc', 'netcdf files '; ... |
---|
| 4555 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4556 | 'Pick a file',filebase); |
---|
[2] | 4557 | fileinput=[PathName FileName]; |
---|
| 4558 | sizf=size(fileinput); |
---|
[45] | 4559 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4560 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4561 | ref.filebase=fullfile(Path,File); |
---|
| 4562 | ref.num_a=stra2num(str_a); |
---|
| 4563 | ref.num_b=stra2num(str_b); |
---|
| 4564 | ref.num1=str2num(field_count); |
---|
| 4565 | ref.num2=str2num(str2); |
---|
| 4566 | browse=[];%initialisation |
---|
| 4567 | if ~isequal(ref.ext,'.nc') |
---|
| 4568 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4569 | return |
---|
| 4570 | end |
---|
| 4571 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4572 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4573 | menu_field{1}='civ1'; |
---|
| 4574 | Data=nc2struct(fileinput,[]); |
---|
| 4575 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4576 | menu_field{2}='filter1'; |
---|
| 4577 | end |
---|
| 4578 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4579 | menu_field{3}='civ2'; |
---|
| 4580 | end |
---|
| 4581 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4582 | menu_field{4}='filter2'; |
---|
| 4583 | end |
---|
| 4584 | set(handles.field_ref2,'String',menu_field); |
---|
| 4585 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 4586 | set(handles.inf_sup2,'Value',2); |
---|
| 4587 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 4588 | set(handles.ref_fix2,'Enable','on') |
---|
| 4589 | set(handles.ref_fix2,'Visible','on') |
---|
| 4590 | set(handles.field_ref2,'Visible','on') |
---|
| 4591 | else |
---|
| 4592 | set(handles.ref_fix2,'Visible','off') |
---|
| 4593 | set(handles.field_ref2,'Visible','off') |
---|
| 4594 | end |
---|
| 4595 | |
---|
[12] | 4596 | %------------------------------------------------------------------------ |
---|
[2] | 4597 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4598 | %------------------------------------------------------------------------ |
---|
| 4599 | set(handles.inf_sup1,'Value',1); |
---|
| 4600 | set(handles.field_ref1,'Value',1) |
---|
| 4601 | set(handles.field_ref1,'String',{' '}) |
---|
| 4602 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4603 | set(handles.ref_fix1,'String',''); |
---|
| 4604 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4605 | |
---|
[12] | 4606 | %------------------------------------------------------------------------ |
---|
[2] | 4607 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4608 | %------------------------------------------------------------------------ |
---|
| 4609 | set(handles.inf_sup2,'Value',1); |
---|
| 4610 | set(handles.field_ref2,'Value',1) |
---|
| 4611 | set(handles.field_ref2,'String',{' '}) |
---|
| 4612 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4613 | set(handles.ref_fix2,'String',''); |
---|
| 4614 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 4615 | |
---|
[12] | 4616 | %------------------------------------------------------------------------ |
---|
[2] | 4617 | % --- Executes on button press in test_stereo1. |
---|
| 4618 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4619 | %------------------------------------------------------------------------ |
---|
[2] | 4620 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4621 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4622 | set(handles.rho_patch1,'Visible','on') |
---|
| 4623 | else |
---|
| 4624 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4625 | set(handles.rho_patch1,'Visible','off') |
---|
| 4626 | end |
---|
| 4627 | |
---|
[12] | 4628 | %------------------------------------------------------------------------ |
---|
[2] | 4629 | % --- Executes on button press in test_stereo2. |
---|
| 4630 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 4631 | %------------------------------------------------------------------------ |
---|
[2] | 4632 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 4633 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4634 | set(handles.rho_patch2,'Visible','on') |
---|
| 4635 | else |
---|
| 4636 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4637 | set(handles.rho_patch2,'Visible','off') |
---|
| 4638 | end |
---|
| 4639 | |
---|
[12] | 4640 | %------------------------------------------------------------------------ |
---|
[2] | 4641 | % --- Executes on button press in ImaThreshold. |
---|
| 4642 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4643 | %------------------------------------------------------------------------ |
---|
[2] | 4644 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 4645 | set(handles.MinIma,'Visible','on') |
---|
| 4646 | set(handles.MaxIma,'Visible','on') |
---|
| 4647 | else |
---|
| 4648 | set(handles.MinIma,'Visible','off') |
---|
| 4649 | set(handles.MaxIma,'Visible','off') |
---|
| 4650 | end |
---|
| 4651 | |
---|
[12] | 4652 | %------------------------------------------------------------------------ |
---|
[2] | 4653 | % --- Executes on button press in ImaThreshold2. |
---|
| 4654 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4655 | %------------------------------------------------------------------------ |
---|
[2] | 4656 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 4657 | set(handles.MinIma2,'Visible','on') |
---|
| 4658 | set(handles.MaxIma2,'Visible','on') |
---|
| 4659 | else |
---|
| 4660 | set(handles.MinIma2,'Visible','off') |
---|
| 4661 | set(handles.MaxIma2,'Visible','off') |
---|
| 4662 | end |
---|
| 4663 | |
---|
[224] | 4664 | %------------------------------------------------------------------------ |
---|
[225] | 4665 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4666 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4667 | %------------------------------------------------------------------------ |
---|
[233] | 4668 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
| 4669 | drawnow |
---|
[150] | 4670 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4671 | if test_civ1 |
---|
[227] | 4672 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4673 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4674 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4675 | else |
---|
| 4676 | ref_j=1;%default |
---|
| 4677 | end |
---|
[224] | 4678 | [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]=... |
---|
[227] | 4679 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[224] | 4680 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4681 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4682 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4683 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4684 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4685 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4686 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4687 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4688 | par_civ1.T0=0; |
---|
| 4689 | par_civ1.Dt=1; |
---|
[246] | 4690 | Param.Civ1=par_civ1; |
---|
| 4691 | Data=civ_uvmat(Param); |
---|
[231] | 4692 | % stepx=str2num(par_civ1.dx); |
---|
| 4693 | % stepy=str2num(par_civ1.dy); |
---|
| 4694 | % ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
| 4695 | % iby2=ceil(str2num(par_civ1.iby)/2); |
---|
| 4696 | % isx2=ceil(str2num(par_civ1.isx)/2); |
---|
| 4697 | % isy2=ceil(str2num(par_civ1.isy)/2); |
---|
| 4698 | % shiftx=str2num(par_civ1.shiftx); |
---|
| 4699 | % shifty=str2num(par_civ1.shifty); |
---|
| 4700 | % % ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even |
---|
| 4701 | % % iby=2*iby2-1; |
---|
| 4702 | % miniy=max(1+isy2-shifty,1+iby2) |
---|
| 4703 | % minix=max(1+isx2-shiftx,1+ibx2) |
---|
| 4704 | % maxiy=min(size(Data.A,1)-isy2-shifty,size(Data.A,1)-iby2) |
---|
| 4705 | % maxix=min(size(Data.A,2)-isx2-shiftx,size(Data.A,2)-ibx2) |
---|
| 4706 | % % maxix=stepx*(floor(size(image1_roi,2)/stepx))-(2*ibx2-2)+ibx2; |
---|
| 4707 | % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
| 4708 | % PointCoord(:,1)=reshape(GridX,[],1); |
---|
| 4709 | % PointCoord(:,2)=reshape(GridY,[],1); |
---|
| 4710 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4711 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4712 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4713 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4714 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4715 | hview_field=view_field(Data); |
---|
| 4716 | set(0,'CurrentFigure',hview_field) |
---|
| 4717 | hhview_field=guihandles(hview_field); |
---|
| 4718 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4719 | %hpoints=line(PointCoord(:,1),PointCoord(:,2),'Color','y','LineStyle','.','Marker','*','LineWidth',4,'Tag','grid_points'); |
---|
| 4720 | ViewData=get(hview_field,'UserData'); |
---|
| 4721 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4722 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[236] | 4723 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
| 4724 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
[231] | 4725 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4726 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4727 | if isempty(corrfig) |
---|
| 4728 | corrfig=figure; |
---|
| 4729 | set(corrfig,'tag','corrfig') |
---|
| 4730 | set(corrfig,'name','image correlation') |
---|
| 4731 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4732 | end |
---|
[233] | 4733 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 4734 | else |
---|
| 4735 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4736 | if ~isempty(corrfig) |
---|
| 4737 | delete(corrfig) |
---|
| 4738 | end |
---|
| 4739 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4740 | if ~isempty(hview_field) |
---|
| 4741 | delete(hview_field) |
---|
| 4742 | end |
---|
[150] | 4743 | end |
---|
[71] | 4744 | |
---|
[224] | 4745 | function closeview_field(gcbo,eventdata) |
---|
| 4746 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4747 | if ~isempty(hview_field) |
---|
| 4748 | delete(hview_field) |
---|
| 4749 | end |
---|
[177] | 4750 | %------------------------------------------------------------------- |
---|
| 4751 | % --- Executes on button press in status. |
---|
| 4752 | function status_Callback(hObject, eventdata, handles) |
---|
| 4753 | %------------------------------------------------------------------- |
---|
| 4754 | val=get(handles.status,'Value'); |
---|
| 4755 | if val==0 |
---|
| 4756 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4757 | if ~isempty(hfig) |
---|
| 4758 | delete(hfig) |
---|
| 4759 | end |
---|
| 4760 | return |
---|
| 4761 | end |
---|
| 4762 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 4763 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 4764 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 4765 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 4766 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 4767 | box_test(5)=get(handles.FIX2,'Value'); |
---|
[180] | 4768 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 4769 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[177] | 4770 | filecell=get(handles.civ,'UserData'); |
---|
| 4771 | if ~isfield(filecell,'nc') |
---|
[227] | 4772 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 4773 | if ~isempty(errormsg) |
---|
| 4774 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4775 | return |
---|
| 4776 | end |
---|
| 4777 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the list of output files expected from the GUI status |
---|
[177] | 4778 | end |
---|
[71] | 4779 | |
---|
[177] | 4780 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
| 4781 | civ_files=filecell.nc.civ2; |
---|
| 4782 | else |
---|
| 4783 | civ_files=filecell.nc.civ1; |
---|
| 4784 | end |
---|
| 4785 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 4786 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 4787 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4788 | if isempty(hfig) |
---|
| 4789 | hfig=figure; |
---|
| 4790 | set(hfig,'name','civ_status') |
---|
[182] | 4791 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[177] | 4792 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox'); |
---|
| 4793 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 4794 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
[177] | 4795 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 4796 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
| 4797 | end |
---|
[188] | 4798 | % datnum=[]; |
---|
[177] | 4799 | Tabchar={}; |
---|
| 4800 | nbfiles=numel(civ_files); |
---|
| 4801 | count=0; |
---|
[188] | 4802 | testrecent=0; |
---|
[177] | 4803 | while count<nbfiles |
---|
| 4804 | count=0; |
---|
[188] | 4805 | datnum=zeros(1,nbfiles); |
---|
[177] | 4806 | for ifile=1:nbfiles |
---|
| 4807 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 4808 | option=0; |
---|
[177] | 4809 | if detect==0 |
---|
[179] | 4810 | option_str='not created'; |
---|
[177] | 4811 | else |
---|
[219] | 4812 | datfile=dir(civ_files{ifile}); |
---|
[188] | 4813 | if isfield(datfile,'datenum') |
---|
| 4814 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 4815 | testrecent=1; |
---|
| 4816 | end |
---|
[177] | 4817 | filefound(ifile)={datfile.name}; |
---|
| 4818 | lastfield=''; |
---|
| 4819 | % check the content netcdf file |
---|
| 4820 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 4821 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 4822 | option=6; |
---|
| 4823 | option_str='patch2'; |
---|
[177] | 4824 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 4825 | option=5; |
---|
| 4826 | option_str='fix2'; |
---|
[177] | 4827 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 4828 | option=4; |
---|
| 4829 | option_str='civ2'; |
---|
[177] | 4830 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 4831 | option=3; |
---|
| 4832 | option_str='patch1'; |
---|
[177] | 4833 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 4834 | option=2; |
---|
| 4835 | option_str='fix1'; |
---|
[177] | 4836 | else |
---|
[179] | 4837 | option=1; |
---|
| 4838 | option_str='civ1'; |
---|
[177] | 4839 | end |
---|
| 4840 | end |
---|
[179] | 4841 | if option >= option_civ |
---|
[177] | 4842 | count=count+1; |
---|
| 4843 | end |
---|
| 4844 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 4845 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 4846 | end |
---|
[219] | 4847 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 4848 | if isempty(datnum) |
---|
| 4849 | if testrecent |
---|
| 4850 | message='no civ result created yet'; |
---|
| 4851 | else |
---|
| 4852 | message=''; |
---|
| 4853 | end |
---|
[177] | 4854 | else |
---|
[219] | 4855 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 4856 | [first,ind]=min(datnum); |
---|
| 4857 | [last,indlast]=max(datnum); |
---|
| 4858 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 4859 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
| 4860 | end |
---|
| 4861 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4862 | if isempty(hfig) |
---|
| 4863 | set(handles.status,'Value',0)%stop program if the figure has been suppressed |
---|
| 4864 | return |
---|
| 4865 | else |
---|
| 4866 | hlist=findobj(hfig,'tag','list'); |
---|
| 4867 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 4868 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 4869 | set(hlist,'String',Tabchar) |
---|
| 4870 | set(hmsgbox,'String', message) |
---|
| 4871 | if count>0 |
---|
| 4872 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 4873 | set(hwaitbar,'Position',BarPosition) |
---|
| 4874 | end |
---|
| 4875 | end |
---|
| 4876 | set(hlist,'UserData',rootroot) |
---|
| 4877 | pause(5)% wait 5 seconds for next check |
---|
| 4878 | end |
---|
[150] | 4879 | |
---|
[177] | 4880 | |
---|
| 4881 | %------------------------------------------------------------------- |
---|
| 4882 | % call 'view_field.fig' to display the selected field |
---|
| 4883 | function open_view_field(hObject, eventdata) |
---|
| 4884 | %------------------------------------------------------------------- |
---|
[246] | 4885 | list=get(hObject,'String'); |
---|
| 4886 | index=get(hObject,'Value'); |
---|
| 4887 | rootroot=get(hObject,'UserData'); |
---|
[177] | 4888 | filename=list{index}; |
---|
| 4889 | ind_dot=findstr(filename,'...'); |
---|
| 4890 | filename=filename(1:ind_dot-1); |
---|
[188] | 4891 | filename=fullfile(rootroot,filename); |
---|
[246] | 4892 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
[177] | 4893 | if exist(filename,'file')%visualise the vel field if it exists |
---|
[178] | 4894 | uvmat(filename) |
---|
| 4895 | set(gcbo,'Value',1) |
---|
[177] | 4896 | end |
---|
[150] | 4897 | |
---|
[182] | 4898 | %------------------------------------------------------------------- |
---|
| 4899 | % call 'view_field.fig' to display the selected field |
---|
| 4900 | function close_GUI(hObject, eventdata) |
---|
| 4901 | %------------------------------------------------------------------- |
---|
[220] | 4902 | delete(gcbf) |
---|
| 4903 | |
---|
| 4904 | |
---|
| 4905 | % --- Executes on button press in CivAll. |
---|
| 4906 | function CivAll_Callback(hObject, eventdata, handles) |
---|
[238] | 4907 | Listprog=get(handles.CivAll,'String'); |
---|
| 4908 | index=get(handles.CivAll,'Value'); |
---|
| 4909 | prog=Listprog{index}; |
---|
| 4910 | switch prog |
---|
| 4911 | case 'CivX' |
---|
| 4912 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4913 | set(handles.thresh_text1,'Visible','off') |
---|
| 4914 | set(handles.rho,'Style','edit') |
---|
| 4915 | set(handles.rho,'String','1') |
---|
| 4916 | case 'CivAll' |
---|
| 4917 | if get(handles.PATCH1,'Value') |
---|
| 4918 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4919 | set(handles.thresh_text1,'Visible','on') |
---|
| 4920 | end |
---|
| 4921 | set(handles.rho,'Style','edit') |
---|
| 4922 | set(handles.rho,'String','1') |
---|
| 4923 | case 'CivUvmat' |
---|
| 4924 | if get(handles.PATCH1,'Value') |
---|
| 4925 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4926 | set(handles.thresh_text1,'Visible','on') |
---|
| 4927 | end |
---|
| 4928 | set(handles.rho,'Style','popupmenu') |
---|
| 4929 | set(handles.rho,'Value',1) |
---|
| 4930 | set(handles.rho,'String',{'1';'2'}) |
---|
[224] | 4931 | end |
---|
[220] | 4932 | |
---|