[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 |
---|
[282] | 8 | % Copyright Joel Sommeria, 2011, LEGI / CNRS-UJF-INPG, sommeria@legi.grenoble-inp.fr |
---|
[2] | 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) |
---|
[273] | 23 | %TODO: search range |
---|
[2] | 24 | |
---|
[292] | 25 | % Last Modified by GUIDE v2.5 21-Nov-2011 10:58:28 |
---|
[2] | 26 | % Begin initialization code - DO NOT EDIT |
---|
| 27 | gui_Singleton = 1; |
---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
[2] | 34 | if nargin && ischar(varargin{1}) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
[12] | 45 | %------------------------------------------------------------------------ |
---|
[2] | 46 | % --- Executes just before civ is made visible. |
---|
[298] | 47 | function civ_OpeningFcn(hObject, eventdata, handles, fileinput) |
---|
[12] | 48 | %------------------------------------------------------------------------ |
---|
[2] | 49 | % This function has no output args, see OutputFcn. |
---|
[298] | 50 | |
---|
| 51 | %% General settings |
---|
[2] | 52 | handles.output = hObject; |
---|
[298] | 53 | guidata(hObject, handles); % Update handles structure |
---|
| 54 | set(hObject,'WindowButtonDownFcn',{'mouse_down',handles}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[252] | 55 | |
---|
[298] | 56 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
[276] | 57 | path_civ=fileparts(which('civ')); %path to civ |
---|
[298] | 58 | addpath (path_civ) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
[273] | 59 | errormsg=[];%default error message |
---|
| 60 | xmlfile='PARAM.xml'; |
---|
| 61 | if exist(xmlfile,'file') |
---|
| 62 | try |
---|
| 63 | t=xmltree(xmlfile); |
---|
| 64 | sparam=convert(t); |
---|
| 65 | catch |
---|
| 66 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
| 67 | return |
---|
| 68 | end |
---|
| 69 | else |
---|
| 70 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
| 71 | return |
---|
| 72 | end |
---|
| 73 | if ~isempty(errormsg) |
---|
| 74 | msgbox_uvmat('ERROR',errormsg); |
---|
| 75 | end |
---|
| 76 | test_batch=0;%default: ,no batch mode available |
---|
| 77 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 78 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
| 79 | end |
---|
| 80 | if test_batch==0 |
---|
| 81 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
| 82 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 83 | end |
---|
| 84 | if isfield(sparam.RunParam,'CivBin') |
---|
| 85 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[276] | 86 | sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin); |
---|
[273] | 87 | end |
---|
| 88 | else |
---|
| 89 | sparam.RunParam.CivBin=''; |
---|
| 90 | end |
---|
| 91 | |
---|
[298] | 92 | %% load the list of previously browsed files in the upper bar menu Open/ |
---|
[296] | 93 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 94 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 95 | if exist(profil_perso,'file') |
---|
| 96 | h=load (profil_perso); |
---|
| 97 | if isfield(h,'MenuFile') |
---|
| 98 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 99 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 100 | end |
---|
| 101 | end |
---|
[273] | 102 | end |
---|
| 103 | |
---|
[298] | 104 | %% input parameters: |
---|
| 105 | % param |
---|
| 106 | % filebase=''; % root file name ('filebase'.civ) |
---|
| 107 | % ext=[]; |
---|
| 108 | % num_i1=1; % set of field i numbers |
---|
| 109 | % num_i2=1; % set of field i numbers |
---|
| 110 | % num_j1=1; % set of field j numbers (fields a) |
---|
| 111 | % num_j2=1; % second set of field j numbers (fields b) |
---|
| 112 | % %subdir='A'; % subdir for the netcdf result files |
---|
| 113 | % ind_opening=0; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 114 | % %load the initial parameters if the interface is started from uvmat |
---|
| 115 | % if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 116 | % filebase=param.RootName; |
---|
| 117 | % nom_type_read=param.NomType; |
---|
| 118 | % num_i1=param.num1; |
---|
| 119 | % if isnan(num_i1),num_i1=1;end |
---|
| 120 | % num_i2=param.num2; |
---|
| 121 | % if isnan(num_i2),num_i2=num_i1;end |
---|
| 122 | % num_j1=param.num_a; |
---|
| 123 | % if isnan(num_j1),num_j1=1;end |
---|
| 124 | % num_j2=param.num_b; |
---|
| 125 | % if isnan(num_j2),num_j2=num_j1;end |
---|
| 126 | % subdir=param.SubDir; |
---|
| 127 | % ind_opening=param.IndOpening; |
---|
| 128 | % ext=param.ImaExt; |
---|
| 129 | % end |
---|
| 130 | % browse.num_i1=num_i1; |
---|
| 131 | % browse.num_i2=num_i2; |
---|
| 132 | % browse.num_j1=num_j1; |
---|
| 133 | % browse.num_j2=num_j2; |
---|
| 134 | % if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
| 135 | % set(handles.ImaExt,'String',ext) |
---|
| 136 | % % browse.ext_ima=ext; |
---|
| 137 | % % if exist('nom_type_read','var') |
---|
| 138 | % % browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 139 | % % end |
---|
| 140 | % % elseif isequal(ext,'.nc') |
---|
| 141 | % % if exist('nom_type_read','var') |
---|
| 142 | % % browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 143 | % % end |
---|
| 144 | % end |
---|
| 145 | % set(handles.RootName,'String',filebase); |
---|
| 146 | % set(handles.ImaDoc,'String',ext) |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | %% prepare the GUI with parameters from the input file if opened from uvmat |
---|
| 150 | if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName) |
---|
| 151 | errormsg=display_file_name(handles,fileinput); |
---|
| 152 | if ~isempty(errormsg) |
---|
| 153 | msgbox_uvmat('ERROR',errormsg) |
---|
[112] | 154 | end |
---|
[2] | 155 | end |
---|
| 156 | |
---|
[298] | 157 | % %initiate advised operations |
---|
| 158 | % enable_civ1(handles,0) |
---|
| 159 | % enable_civ2(handles,0) |
---|
| 160 | % %enable_pair1(handles,'on') |
---|
| 161 | % enable_fix1(handles,0) |
---|
| 162 | % enable_patch1(handles,0) |
---|
| 163 | % enable_fix2(handles,0) |
---|
| 164 | % enable_patch2(handles,0) |
---|
| 165 | % set(handles.CheckCiv1,'Value',0) |
---|
| 166 | % set(handles.CheckFix1,'Value',0) |
---|
| 167 | % set(handles.CheckPatch1,'Value',0) |
---|
| 168 | % set(handles.CheckCiv2,'Value',0) |
---|
| 169 | % set(handles.CheckFix2,'Value',0) |
---|
| 170 | % set(handles.CheckPatch2,'Value',0) |
---|
| 171 | % |
---|
| 172 | % if isequal(ind_opening,1) |
---|
| 173 | % set(handles.CheckCiv1,'Value',1) |
---|
| 174 | % enable_civ1(handles,1) |
---|
| 175 | % elseif isequal(ind_opening,2) |
---|
| 176 | % set(handles.CheckFix1,'Value',1) |
---|
| 177 | % enable_fix1(handles,1) |
---|
| 178 | % elseif isequal(ind_opening,3) |
---|
| 179 | % set(handles.CheckPatch1,'Value',1) |
---|
| 180 | % enable_patch1(handles,1) |
---|
| 181 | % elseif isequal(ind_opening,4) |
---|
| 182 | % set(handles.CheckCiv2,'Value',1) |
---|
| 183 | % enable_civ2(handles,1) |
---|
| 184 | % elseif isequal(ind_opening,5) |
---|
| 185 | % set(handles.CheckFix2,'Value',1) |
---|
| 186 | % enable_fix2(handles,1) |
---|
[296] | 187 | % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
[298] | 188 | % set(handles.ListPairCiv2,'Enable','On') |
---|
| 189 | % set(handles.ListPairCiv2,'Enable','On') |
---|
| 190 | % enable_pair1(handles,'off') |
---|
| 191 | % elseif isequal(ind_opening,6) |
---|
| 192 | % set(handles.CheckPatch2,'Value',1) |
---|
| 193 | % enable_patch2(handles,1) |
---|
| 194 | % set(handles.ListPairCiv2,'Enable','On') |
---|
| 195 | % enable_pair1(handles,'off') |
---|
| 196 | % end |
---|
| 197 | % |
---|
| 198 | % % set the range of fields (1:1 by default) and selected pair |
---|
| 199 | % if isequal(num_i2,num_i1) |
---|
| 200 | % num_ref_i=num_i1; |
---|
| 201 | % else |
---|
| 202 | % num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 203 | % browse.incr_pair(1)=num_i2-num_i1; |
---|
| 204 | % browse.incr_pair(2)=0; |
---|
| 205 | % end |
---|
| 206 | % if isequal(num_j1,num_j2) |
---|
| 207 | % if isnan(num_j1) |
---|
| 208 | % num_ref_j=1; |
---|
| 209 | % else |
---|
| 210 | % num_ref_j=num_j1; |
---|
| 211 | % end |
---|
| 212 | % else |
---|
| 213 | % num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 214 | % browse.incr_pair(2)=num_j2-num_j1; |
---|
| 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)); |
---|
| 222 | % set(handles.RootName,'UserData',browse); |
---|
[2] | 223 | |
---|
[12] | 224 | %------------------------------------------------------------------------ |
---|
[2] | 225 | % --- Outputs from this function are returned to the command line. |
---|
| 226 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 227 | %------------------------------------------------------------------------ |
---|
[2] | 228 | % Get default command line output from handles structure |
---|
| 229 | varargout{1} = handles.output; |
---|
| 230 | |
---|
[298] | 231 | %------------------------------------------------------------------------ |
---|
| 232 | % --- function activated by the Open/Browse... option in the upper menu bar. |
---|
[273] | 233 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
[298] | 234 | %------------------------------------------------------------------------ |
---|
| 235 | %get the current input root file name to initiate the browser |
---|
[71] | 236 | filebase=get(handles.RootName,'String'); |
---|
[2] | 237 | oldfile=''; %default |
---|
[298] | 238 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name |
---|
[112] | 239 | dir_perso=prefdir; |
---|
| 240 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 241 | if exist(profil_perso,'file') |
---|
| 242 | h=load (profil_perso); |
---|
| 243 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 244 | oldfile=h.filebase; |
---|
| 245 | end |
---|
| 246 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 247 | oldfile=h.RootPath; |
---|
| 248 | end |
---|
| 249 | end |
---|
| 250 | else |
---|
| 251 | oldfile=filebase; |
---|
| 252 | end |
---|
[2] | 253 | ind_opening=1;%default |
---|
| 254 | browse.incr_pair=[0 0]; %default |
---|
[238] | 255 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[174] | 256 | '*.xml', '.xml files '; ... |
---|
| 257 | '*.civ', '.civ files '; ... |
---|
| 258 | '*.png','.png image files'; ... |
---|
| 259 | '*.jpg',' jpeg image files'; ... |
---|
| 260 | '*.tif','.tif image files'; ... |
---|
| 261 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 262 | '*.nc','.netcdf files'; ... |
---|
| 263 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 264 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 265 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 266 | sizf=size(fileinput); |
---|
| 267 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 268 | |
---|
[298] | 269 | %% prepare the GUI with parameters from the input file if opened from uvmat |
---|
| 270 | errormsg=display_file_name(handles,fileinput); |
---|
| 271 | if ~isempty(errormsg) |
---|
| 272 | msgbox_uvmat('ERROR',erromsg) |
---|
[246] | 273 | end |
---|
[2] | 274 | |
---|
[298] | 275 | % |
---|
| 276 | % [path,name,ext]=fileparts(fileinput); |
---|
| 277 | % testeditxml=0; |
---|
| 278 | % if isequal(ext,'.xml') |
---|
| 279 | % testeditxml=1; |
---|
| 280 | % t_browse=xmltree(fileinput); |
---|
| 281 | % head_element=get(t_browse,1); |
---|
| 282 | % if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
| 283 | % testeditxml=0; |
---|
| 284 | % end |
---|
| 285 | % end |
---|
| 286 | % if testeditxml==1 || isequal(ext,'.xls') |
---|
| 287 | % heditxml=editxml({fileinput}); |
---|
| 288 | % set(heditxml,'Tag','browser') |
---|
| 289 | % waitfor(heditxml,'Tag','idle') |
---|
| 290 | % if ~ishandle(heditxml) |
---|
| 291 | % return |
---|
| 292 | % end |
---|
| 293 | % attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 294 | % set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 295 | % fileinput=get(attr,'UserData'); |
---|
| 296 | % if ~exist(fileinput,'file') |
---|
| 297 | % return |
---|
| 298 | % end |
---|
| 299 | % end |
---|
| 300 | % [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
| 301 | % filebase=fullfile(RootPath,RootFile); |
---|
| 302 | % num_i1=str2double(str1); |
---|
| 303 | % if isnan(num_i1),num_i1=1;end |
---|
| 304 | % num_i2=str2double(str2); |
---|
| 305 | % if isnan(num_i2),num_i2=num_i1;end |
---|
| 306 | % num_j1=stra2num(str_a); |
---|
| 307 | % if isnan(num_j1),num_j1=1;end |
---|
| 308 | % num_j2=stra2num(str_b); |
---|
| 309 | % if isnan(num_j2),num_j2=num_j1;end |
---|
| 310 | % if isequal(get(handles.ListCompareMode,'Value'),1) |
---|
| 311 | % browse=[];%initialisation |
---|
| 312 | % else |
---|
| 313 | % browse=get(handlesRootName,'UserData'); |
---|
| 314 | % end |
---|
| 315 | % browse.num_i1=num_i1; |
---|
| 316 | % browse.num_i2=num_i2; |
---|
| 317 | % browse.num_j1=num_j1; |
---|
| 318 | % browse.num_j2=num_j2; |
---|
| 319 | % if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
| 320 | % browse.nom_type_ima=nom_type; |
---|
| 321 | % browse.ext_ima=ext; |
---|
| 322 | % set(handles.ImaExt,'String',ext) |
---|
| 323 | % end |
---|
| 324 | % set(handles.ImaDoc,'String',ext); |
---|
| 325 | % |
---|
| 326 | % |
---|
| 327 | % set(handles.RootName,'UserData',browse);% store information from browser |
---|
| 328 | % RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 329 | |
---|
[273] | 330 | % ----------------------------------------------------------------------- |
---|
| 331 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 332 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
[12] | 333 | %------------------------------------------------------------------------ |
---|
[273] | 334 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[298] | 335 | errormsg=display_file_name(handles,fileinput); |
---|
| 336 | if ~isempty(errormsg) |
---|
| 337 | msgbox_uvmat('ERROR',erromsg) |
---|
| 338 | end |
---|
[273] | 339 | |
---|
| 340 | % ----------------------------------------------------------------------- |
---|
| 341 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 342 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 343 | %------------------------------------------------------------------------ |
---|
| 344 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[298] | 345 | errormsg=display_file_name(handles,fileinput); |
---|
| 346 | if ~isempty(errormsg) |
---|
| 347 | msgbox_uvmat('ERROR',erromsg) |
---|
| 348 | end |
---|
[273] | 349 | % ----------------------------------------------------------------------- |
---|
| 350 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 351 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 352 | %------------------------------------------------------------------------ |
---|
| 353 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[298] | 354 | errormsg=display_file_name(handles,fileinput); |
---|
| 355 | if ~isempty(errormsg) |
---|
| 356 | msgbox_uvmat('ERROR',erromsg) |
---|
| 357 | end |
---|
[273] | 358 | % ----------------------------------------------------------------------- |
---|
| 359 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 360 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 361 | %------------------------------------------------------------------------ |
---|
| 362 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[298] | 363 | errormsg=display_file_name(handles,fileinput); |
---|
| 364 | if ~isempty(errormsg) |
---|
| 365 | msgbox_uvmat('ERROR',erromsg) |
---|
| 366 | end |
---|
[273] | 367 | % ----------------------------------------------------------------------- |
---|
| 368 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 369 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 370 | %------------------------------------------------------------------------ |
---|
| 371 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[298] | 372 | errormsg=display_file_name(handles,fileinput); |
---|
| 373 | if ~isempty(errormsg) |
---|
| 374 | msgbox_uvmat('ERROR',erromsg) |
---|
| 375 | end |
---|
[273] | 376 | %------------------------------------------------------------------------ |
---|
[2] | 377 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 378 | %------------------------------------------------------------------------ |
---|
[71] | 379 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 380 | |
---|
[12] | 381 | %------------------------------------------------------------------------ |
---|
[54] | 382 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 383 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 384 | %------------------------------------------------------------------------ |
---|
[273] | 385 | filebase=get(handles.RootName,'String'); |
---|
[298] | 386 | errormsg=display_file_name(handles,filebase); |
---|
| 387 | if ~isempty(errormsg) |
---|
| 388 | msgbox_uvmat('ERROR',erromsg) |
---|
| 389 | end |
---|
[273] | 390 | %------------------------------------------------------------------------ |
---|
[298] | 391 | function errormsg=display_file_name(handles,fileinput) |
---|
[273] | 392 | %------------------------------------------------------------------------ |
---|
[282] | 393 | set(handles.ListCompareMode,'Visible','on') |
---|
[298] | 394 | errormsg='';%default empty error message |
---|
[273] | 395 | |
---|
[298] | 396 | %% enable RUN, BATCH button and 'status' display |
---|
| 397 | set(handles.RUN, 'Enable','On') |
---|
| 398 | set(handles.RUN,'BackgroundColor',[1 0 0])%set RUN button to red color |
---|
| 399 | set(handles.BATCH,'Enable','On') |
---|
| 400 | set(handles.BATCH,'BackgroundColor',[1 0 0])%set BATCH button to red color |
---|
| 401 | if isfield(handles,'status') |
---|
| 402 | set(handles.status,'Value',0); %suppress the 'status' display |
---|
| 403 | status_Callback([], [], handles) |
---|
[2] | 404 | end |
---|
| 405 | |
---|
[298] | 406 | %% determine nomenclature types and extension of the input files |
---|
| 407 | ext_ima='';%default |
---|
| 408 | nom_type_ima='';%default |
---|
| 409 | nom_type_nc=''; |
---|
| 410 | [RootPath,FileName,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,subdir]=name2display(fileinput); |
---|
| 411 | RootName=fullfile(RootPath,FileName); |
---|
| 412 | set(handles.RootName,'String',RootName) |
---|
[300] | 413 | num_i1=str2double(i1_str); |
---|
| 414 | num_i2=str2double(i2_str); |
---|
| 415 | num_j1=str2double(j1_str); |
---|
| 416 | num_j2=str2double(i2_str); |
---|
| 417 | ref_i=num_i1;%efaulmt ref index |
---|
| 418 | ref_j=num_j1; |
---|
| 419 | browse.incr_pair=[0 0];%default |
---|
[298] | 420 | if ~isempty(imformats(ext_input(2:end)))||strcmp(lower(ext_input),'.avi')% if the extension corresponds to an image or movie format recognized by Matlab |
---|
| 421 | ext_ima=ext_input; |
---|
| 422 | nom_type_ima=nom_type_input; |
---|
| 423 | else %case of netcdf input file, look for corresponding images |
---|
| 424 | nom_type_nc=nom_type_input; |
---|
[300] | 425 | if ~isempty(num_i2) |
---|
| 426 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 427 | browse.incr_pair(1)=num_i2-num_i1; |
---|
| 428 | browse.incr_pair(2)=0; |
---|
| 429 | end |
---|
[298] | 430 | %TODO: read the image name in the netcdf file (if documented) |
---|
| 431 | dirima='';%default |
---|
| 432 | %look for double image series '_i_j' |
---|
| 433 | dirima=dir([RootName '_' i1_str '_' j1_str '.*']); |
---|
| 434 | if isempty(dirima) |
---|
| 435 | % look for images series with sub marker '_' |
---|
| 436 | dirima=dir([RootName '_*' i1_str '.*']); |
---|
| 437 | if isempty(dirima) |
---|
| 438 | % look for other images series |
---|
| 439 | dirima=dir([RootName '*' i1_str '.*']); |
---|
| 440 | if isempty(dirima) |
---|
| 441 | % look for other images series witth letter appendix |
---|
| 442 | appendix=char(96+j1_str); |
---|
| 443 | dirima=dir([RootName '*' i1_str appendix '.*']); |
---|
| 444 | end |
---|
| 445 | end |
---|
[2] | 446 | end |
---|
[298] | 447 | for ilist=1:numel(dirima) |
---|
| 448 | [pp,ff,i1,i2,j1,j2,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 449 | form=imformats(ext_list(2:end)); |
---|
| 450 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 451 | ext_ima=ext_list; |
---|
| 452 | nom_type_ima=nom_type_list; |
---|
| 453 | num_i1=str2double(i1); |
---|
| 454 | num_j1=str2double(j1); |
---|
| 455 | num_i2=str2double(i2); |
---|
| 456 | num_j2=str2double(j2); |
---|
| 457 | |
---|
| 458 | % set the range of fields (1:1 by default) and selected pair |
---|
| 459 | if isequal(num_i2,num_i1)||isnan(num_i2) |
---|
| 460 | num_ref_i=num_i1; |
---|
| 461 | else |
---|
| 462 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 463 | browse.incr_pair(1)=num_i2-num_i1; |
---|
| 464 | browse.incr_pair(2)=0; |
---|
| 465 | end |
---|
| 466 | if isequal(num_j1,num_j2)||isnan(num_j2) |
---|
| 467 | if isnan(num_j1) |
---|
| 468 | num_ref_j=1; |
---|
| 469 | else |
---|
| 470 | num_ref_j=num_j1; |
---|
| 471 | end |
---|
| 472 | else |
---|
| 473 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 474 | browse.incr_pair(2)=num_j2-num_j1; |
---|
| 475 | end |
---|
| 476 | break |
---|
| 477 | end |
---|
| 478 | end |
---|
[2] | 479 | end |
---|
[300] | 480 | |
---|
[298] | 481 | % ext_imadoc=get(handles.ImaDoc,'String'); |
---|
| 482 | % browse=get(handles.RootName,'UserData');%default |
---|
| 483 | % if isfield(browse,'nom_type_ima') |
---|
| 484 | % nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
| 485 | % end |
---|
| 486 | % if isfield(browse,'ext_ima') |
---|
| 487 | % ext_ima=browse.ext_ima; |
---|
| 488 | % end |
---|
| 489 | % if isfield(browse,'nom_type_nc') |
---|
| 490 | % nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 491 | % end |
---|
| 492 | % if isfield(browse,'num_i1') |
---|
| 493 | % field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 494 | % end |
---|
| 495 | %set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
[2] | 496 | |
---|
[298] | 497 | |
---|
| 498 | %% look for an image documentation file |
---|
| 499 | ext_imadoc='';%default |
---|
| 500 | if exist([RootName '.xml'],'file') |
---|
| 501 | ext_imadoc='.xml'; |
---|
| 502 | elseif exist([RootName '.civxml'],'file') |
---|
| 503 | ext_imadoc='.civxml'; |
---|
| 504 | elseif exist([RootName '.civ'],'file') |
---|
| 505 | ext_imadoc='.civ'; |
---|
| 506 | elseif exist([RootName '.avi'],'file') |
---|
| 507 | ext_imadoc='.avi'; |
---|
| 508 | elseif exist([RootName '.AVI'],'file') |
---|
| 509 | ext_imadoc='.AVI'; |
---|
| 510 | end |
---|
| 511 | set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used |
---|
| 512 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 513 | drawnow |
---|
[2] | 514 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 515 | mode=''; %default |
---|
[298] | 516 | time=[]; |
---|
| 517 | TimeUnit='frame'; %default |
---|
| 518 | CoordUnit='px';%default |
---|
| 519 | pxcmx_search=[];%default |
---|
| 520 | pxcmy_search=[];%default |
---|
| 521 | % first_i=1;%default |
---|
| 522 | % last_i=1;%default |
---|
[128] | 523 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[298] | 524 | [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']); |
---|
[2] | 525 | mode='pair j1-j2'; |
---|
| 526 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 527 | nom_type_ima='_i_j'; |
---|
[2] | 528 | end |
---|
[128] | 529 | elseif isequal(ext_imadoc,'.xml') |
---|
[298] | 530 | [XmlData,warntext]=imadoc2struct([RootName '.xml']); |
---|
[2] | 531 | ext_ima_read=[]; |
---|
| 532 | nom_type_read=[]; |
---|
[12] | 533 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 534 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[298] | 535 | fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 536 | if ~exist(fullname,'file') |
---|
[12] | 537 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 538 | end |
---|
[2] | 539 | end |
---|
[84] | 540 | if isfield(XmlData,'Time') |
---|
[85] | 541 | time=XmlData.Time; |
---|
[84] | 542 | nbfield=size(time,1); |
---|
[122] | 543 | nbfield2=size(time,2); |
---|
[127] | 544 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 545 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 546 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 547 | time=time'; |
---|
[122] | 548 | nbfield=nbfield2; |
---|
| 549 | nbfield2=1; |
---|
[84] | 550 | end |
---|
| 551 | end |
---|
| 552 | end |
---|
[71] | 553 | if isfield(XmlData,'TimeUnit') |
---|
| 554 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 555 | end |
---|
| 556 | pxcmx_search=1; |
---|
| 557 | pxcmy_search=1; |
---|
| 558 | if isfield(XmlData,'GeometryCalib') |
---|
| 559 | tsai=XmlData.GeometryCalib; |
---|
[112] | 560 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 561 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 562 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 563 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 564 | end |
---|
[112] | 565 | if isfield(tsai,'CoordUnit') |
---|
| 566 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 567 | end |
---|
[112] | 568 | end |
---|
[128] | 569 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[298] | 570 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']); |
---|
| 571 | if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']); |
---|
[112] | 572 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 573 | end |
---|
[128] | 574 | nom_type_ima='001a'; |
---|
| 575 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 576 | nom_type_ima='*'; |
---|
[128] | 577 | ext_ima=ext_imadoc; |
---|
[282] | 578 | set(handles.ListPairMode,'Value',1); |
---|
| 579 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[112] | 580 | dt=0.04;%default |
---|
[298] | 581 | if exist([RootName ext_imadoc],'file')==2 |
---|
| 582 | info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie |
---|
[112] | 583 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 584 | nbfield=info.NumFrames;%number of frames |
---|
| 585 | end |
---|
| 586 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 587 | end |
---|
| 588 | if isempty(time) |
---|
| 589 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 590 | end |
---|
[298] | 591 | set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box to yellow color |
---|
[2] | 592 | |
---|
[120] | 593 | |
---|
[298] | 594 | %% timing display |
---|
| 595 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
| 596 | % if isempty(time)|| strcmp(nom_type_ima,'*')||strcmp(nom_type_ima,'') |
---|
| 597 | % % set(handles.ref_i,'Visible','Off')% do not use a reference index to display time intervals |
---|
| 598 | % % set(handles.ref_j,'Visible','Off') |
---|
| 599 | % first_i=1; |
---|
| 600 | % last_i=1; |
---|
| 601 | % else |
---|
| 602 | % % set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 603 | % % set(handles.ref_j,'Visible','On') |
---|
| 604 | % set(handles.ref_i,'String',i1_str) |
---|
| 605 | % set(handles.ref_j,'String',j1_str) |
---|
| 606 | % end |
---|
| 607 | if ~isempty(time) |
---|
[2] | 608 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 609 | nbfield=size(time,1); |
---|
| 610 | nbfield2=size(time,2); |
---|
[273] | 611 | set(handles.ImaDoc,'UserData',time); %store the set of times |
---|
[71] | 612 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 613 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 614 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 615 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 616 | end |
---|
| 617 | end |
---|
[71] | 618 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[273] | 619 | set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); |
---|
[71] | 620 | set(handles.ImaExt,'String',ext_ima) |
---|
[298] | 621 | set(handles.ref_i,'String',num2str(num_ref_i)) |
---|
| 622 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 623 | set(handles.last_i,'String',num2str(num_ref_i));% |
---|
| 624 | set(handles.ref_j,'String',num2str(num_ref_j)) |
---|
| 625 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 626 | set(handles.last_j,'String',num2str(num_ref_j));% |
---|
[2] | 627 | |
---|
[298] | 628 | %% set the civ options depending on the input file content |
---|
| 629 | ind_opening=0;%default |
---|
| 630 | if isequal(ext_input,'.nc') |
---|
| 631 | browse.nom_type_nc=nom_type_input; |
---|
| 632 | ind_opening=2;% propose 'fix' as the default option |
---|
| 633 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 634 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 635 | ind_opening=Data.CivStage; |
---|
| 636 | set(handles.ListPairMode,'Value',3) |
---|
| 637 | end |
---|
| 638 | end |
---|
| 639 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
| 640 | for index = 1:ind_opening |
---|
| 641 | set(handles.(ListOptions{index}),'value',0) |
---|
| 642 | end |
---|
[300] | 643 | for index = ind_opening+1 |
---|
[298] | 644 | set(handles.(ListOptions{index}),'value',1) |
---|
| 645 | end |
---|
| 646 | update_CivOptions(handles) |
---|
| 647 | |
---|
| 648 | |
---|
[273] | 649 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 650 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 651 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[282] | 652 | set(handles.ListPairMode,'Value',1) |
---|
| 653 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[2] | 654 | elseif (nbfield==1)% simple series in j |
---|
[282] | 655 | set(handles.ListPairMode,'Value',1) |
---|
| 656 | set(handles.ListPairMode,'String',{'series(Dj)'}) |
---|
[2] | 657 | else |
---|
[282] | 658 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 659 | if nbfield2 <= 10 |
---|
[282] | 660 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 661 | end |
---|
| 662 | end |
---|
| 663 | |
---|
[298] | 664 | %% update the subdirectory display |
---|
[300] | 665 | listot=dir(RootPath);%directory of RootPath |
---|
[273] | 666 | idir=0; |
---|
| 667 | listdir={''};%default |
---|
[300] | 668 | % get the list of existing civ subdirectories in the path of theinput root file |
---|
[273] | 669 | for ilist=1:length(listot) |
---|
| 670 | if listot(ilist).isdir |
---|
| 671 | name=listot(ilist).name; |
---|
| 672 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 673 | idir=idir+1; |
---|
| 674 | listdir{idir,1}=listot(ilist).name; |
---|
| 675 | end |
---|
| 676 | end |
---|
| 677 | end |
---|
[298] | 678 | Value=find(strcmp(subdir,listdir));%search the index of subdir in the cell listdir |
---|
[300] | 679 | if isempty(Value)% if the input subdir is not found |
---|
| 680 | ValueCiv1=get(handles.ListSubdirCiv1,'Value');%read the currrently selected dir name |
---|
[298] | 681 | if ValueCiv1>numel(listdir) |
---|
| 682 | ValueCiv1=1; |
---|
| 683 | end |
---|
| 684 | set(handles.ListSubdirCiv1,'Value',ValueCiv1) |
---|
[300] | 685 | set(handles.txt_SubdirCiv1,'String',listdir{ValueCiv1}) |
---|
[298] | 686 | ValueCiv2=get(handles.ListSubdirCiv2,'Value'); |
---|
| 687 | if ValueCiv2>numel(listdir) |
---|
| 688 | ValueCiv2=1; |
---|
| 689 | end |
---|
| 690 | set(handles.ListSubdirCiv2,'Value',ValueCiv2) |
---|
[300] | 691 | set(handles.txt_SubdirCiv2,'String',listdir{ValueCiv2}) |
---|
[298] | 692 | else |
---|
[300] | 693 | set(handles.txt_SubdirCiv1,'String',listdir{Value}) |
---|
| 694 | set(handles.txt_SubdirCiv2,'String',listdir{Value}) |
---|
[298] | 695 | end |
---|
[300] | 696 | set(handles.ListSubdirCiv1,'Value',Value) |
---|
| 697 | set(handles.ListSubdirCiv2,'Value',Value) |
---|
[282] | 698 | set(handles.ListSubdirCiv1,'String',[listdir;'new...']) |
---|
[289] | 699 | set(handles.ListSubdirCiv2,'String',[listdir;'new...']) |
---|
[273] | 700 | if isempty(listdir) |
---|
[300] | 701 | set(handles.txt_SubdirCiv1,'String','CIV') |
---|
| 702 | set(handles.txt_SubdirCiv2,'String','CIV') |
---|
[273] | 703 | end |
---|
| 704 | |
---|
[300] | 705 | %% store info |
---|
| 706 | browse.nom_type_ima=nom_type_ima; |
---|
| 707 | set(handles.RootName,'UserData',browse)% store the nomenclature type |
---|
[273] | 708 | |
---|
[298] | 709 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
| 710 | ListPairMode_Callback([], [], handles) |
---|
| 711 | |
---|
| 712 | %% store the root input filename for future opening |
---|
| 713 | dir_perso=prefdir; |
---|
| 714 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 715 | % RootPath=fileparts(RootName); |
---|
| 716 | if exist(profil_perso,'file') |
---|
| 717 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 718 | else |
---|
| 719 | txt=ver('MATLAB'); |
---|
| 720 | Release=txt.Release; |
---|
| 721 | relnumb=str2double(Release(3:4)); |
---|
| 722 | if relnumb >= 14 |
---|
| 723 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 724 | else |
---|
| 725 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 726 | end |
---|
| 727 | end |
---|
| 728 | |
---|
[12] | 729 | %------------------------------------------------------------------------ |
---|
[282] | 730 | % --- Executes on button press in ListPairMode. |
---|
| 731 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
[12] | 732 | %------------------------------------------------------------------------ |
---|
[273] | 733 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 734 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 735 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 736 | compare=compare_list{val}; |
---|
| 737 | if strcmp(compare,'displacement') |
---|
| 738 | mode='displacement'; |
---|
| 739 | else |
---|
[282] | 740 | mode_list=get(handles.ListPairMode,'String'); |
---|
[236] | 741 | if ischar(mode_list) |
---|
| 742 | mode_list={mode_list}; |
---|
| 743 | end |
---|
[282] | 744 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 745 | mode=mode_list{mode_value}; |
---|
| 746 | end |
---|
| 747 | displ_num=[];%default |
---|
[137] | 748 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 749 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[273] | 750 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 751 | siztime=size(time); |
---|
| 752 | nbfield=siztime(1); |
---|
| 753 | nbfield2=siztime(2); |
---|
| 754 | indchosen=1; %%first pair selected by default |
---|
| 755 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 756 | dt=1; |
---|
| 757 | displ=''; |
---|
| 758 | index=0; |
---|
| 759 | numlist_a=[]; |
---|
| 760 | numlist_B=[]; |
---|
| 761 | %get all the time intervals in bursts |
---|
| 762 | displ_dt=1;%default |
---|
| 763 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 764 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 765 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 766 | index=index+1; |
---|
| 767 | numlist_a(index)=numod_a; |
---|
| 768 | numlist_b(index)=numod_b; |
---|
| 769 | if ~isempty(time) |
---|
[54] | 770 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 771 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 772 | else |
---|
| 773 | displ_dt(index)=1; |
---|
| 774 | end |
---|
| 775 | end |
---|
| 776 | end |
---|
| 777 | [dtsort,indsort]=sort(displ_dt); |
---|
| 778 | if ~isempty(numlist_a) |
---|
| 779 | displ_num(1,:)=numlist_a(indsort); |
---|
| 780 | displ_num(2,:)=numlist_b(indsort); |
---|
| 781 | end |
---|
| 782 | displ_num(3,:)=0; |
---|
| 783 | displ_num(4,:)=0; |
---|
| 784 | set(handles.jtext,'Visible','Off') |
---|
[2] | 785 | set(handles.first_j,'Visible','Off') |
---|
| 786 | set(handles.last_j,'Visible','Off') |
---|
| 787 | set(handles.incr_j,'Visible','Off') |
---|
| 788 | set(handles.nb_field2,'Visible','Off') |
---|
| 789 | set(handles.ref_j,'Visible','Off') |
---|
| 790 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 791 | for index=1:min(nbfield2-1,200) |
---|
| 792 | displ_num(1,index)=-floor(index/2); |
---|
| 793 | displ_num(2,index)=ceil(index/2); |
---|
| 794 | displ_num(3,index)=0; |
---|
| 795 | displ_num(4,index)=0; |
---|
| 796 | end |
---|
| 797 | set(handles.jtext,'Visible','On') |
---|
| 798 | set(handles.first_j,'Visible','On') |
---|
| 799 | set(handles.last_j,'Visible','On') |
---|
| 800 | set(handles.incr_j,'Visible','On') |
---|
| 801 | set(handles.nb_field2,'Visible','On') |
---|
| 802 | set(handles.ref_j,'Visible','On') |
---|
| 803 | if nbfield > 1 |
---|
[2] | 804 | set(handles.itext,'Visible','On') |
---|
| 805 | set(handles.first_i,'Visible','On') |
---|
| 806 | set(handles.last_i,'Visible','On') |
---|
| 807 | set(handles.incr_i,'Visible','On') |
---|
| 808 | set(handles.nb_field,'Visible','On') |
---|
| 809 | set(handles.ref_i,'Visible','On') |
---|
| 810 | else |
---|
| 811 | set(handles.itext,'Visible','Off') |
---|
| 812 | set(handles.first_i,'Visible','Off') |
---|
| 813 | set(handles.last_i,'Visible','Off') |
---|
| 814 | set(handles.incr_i,'Visible','Off') |
---|
| 815 | set(handles.nb_field,'Visible','Off') |
---|
| 816 | set(handles.ref_i,'Visible','Off') |
---|
| 817 | end |
---|
[112] | 818 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 819 | for index=1:200%min(nbfield-1,200) |
---|
| 820 | displ_num(1,index)=0; |
---|
| 821 | displ_num(2,index)=0; |
---|
| 822 | displ_num(3,index)=-floor(index/2); |
---|
| 823 | displ_num(4,index)=ceil(index/2); |
---|
| 824 | end |
---|
| 825 | set(handles.itext,'Visible','On') |
---|
| 826 | set(handles.first_i,'Visible','On') |
---|
| 827 | set(handles.last_i,'Visible','On') |
---|
| 828 | set(handles.incr_i,'Visible','On') |
---|
| 829 | set(handles.nb_field,'Visible','On') |
---|
| 830 | set(handles.ref_i,'Visible','On') |
---|
| 831 | if nbfield2 > 1 |
---|
[2] | 832 | set(handles.jtext,'Visible','On') |
---|
| 833 | set(handles.first_j,'Visible','On') |
---|
| 834 | set(handles.last_j,'Visible','On') |
---|
| 835 | set(handles.incr_j,'Visible','On') |
---|
| 836 | set(handles.nb_field2,'Visible','On') |
---|
| 837 | set(handles.ref_j,'Visible','On') |
---|
[112] | 838 | else |
---|
[2] | 839 | set(handles.jtext,'Visible','Off') |
---|
| 840 | set(handles.first_j,'Visible','Off') |
---|
| 841 | set(handles.last_j,'Visible','Off') |
---|
| 842 | set(handles.incr_j,'Visible','Off') |
---|
| 843 | set(handles.nb_field2,'Visible','Off') |
---|
| 844 | set(handles.ref_j,'Visible','Off') |
---|
| 845 | end |
---|
| 846 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 847 | displ_num(1,1)=0; |
---|
| 848 | displ_num(2,1)=0; |
---|
| 849 | displ_num(3,1)=0; |
---|
| 850 | displ_num(4,1)=0; |
---|
| 851 | if nbfield > 1 |
---|
[2] | 852 | set(handles.itext,'Visible','On') |
---|
| 853 | set(handles.first_i,'Visible','On') |
---|
| 854 | set(handles.last_i,'Visible','On') |
---|
| 855 | set(handles.incr_i,'Visible','On') |
---|
| 856 | set(handles.nb_field,'Visible','On') |
---|
| 857 | set(handles.ref_i,'Visible','On') |
---|
| 858 | else |
---|
| 859 | set(handles.itext,'Visible','Off') |
---|
| 860 | set(handles.first_i,'Visible','Off') |
---|
| 861 | set(handles.last_i,'Visible','Off') |
---|
| 862 | set(handles.incr_i,'Visible','Off') |
---|
| 863 | set(handles.nb_field,'Visible','Off') |
---|
| 864 | set(handles.ref_i,'Visible','Off') |
---|
| 865 | end |
---|
| 866 | if nbfield2 > 1 |
---|
[112] | 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') |
---|
[2] | 873 | else |
---|
| 874 | set(handles.jtext,'Visible','Off') |
---|
| 875 | set(handles.first_j,'Visible','Off') |
---|
| 876 | set(handles.last_j,'Visible','Off') |
---|
| 877 | set(handles.incr_j,'Visible','Off') |
---|
| 878 | set(handles.nb_field2,'Visible','Off') |
---|
| 879 | set(handles.ref_j,'Visible','Off') |
---|
| 880 | end |
---|
[112] | 881 | end |
---|
[282] | 882 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
[296] | 883 | find_netcpair_civ1( handles) |
---|
| 884 | find_netcpair_civ2(handles) |
---|
[2] | 885 | |
---|
[12] | 886 | %------------------------------------------------------------------------ |
---|
[282] | 887 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
[2] | 888 | % the field series set by first_i, incr, last_i |
---|
[289] | 889 | function find_netcpair_civ1(handles) |
---|
[12] | 890 | %------------------------------------------------------------------------ |
---|
[2] | 891 | set(gcf,'Pointer','watch') |
---|
| 892 | %nomenclature types |
---|
[71] | 893 | filebase=get(handles.RootName,'String'); |
---|
[2] | 894 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 895 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 896 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 897 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 898 | compare=compare_list{val}; |
---|
| 899 | if strcmp(compare,'displacement') |
---|
| 900 | mode='displacement'; |
---|
| 901 | else |
---|
[282] | 902 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 903 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[273] | 904 | if isempty(mode_list) |
---|
| 905 | return |
---|
| 906 | end |
---|
[2] | 907 | mode=mode_list{mode_value}; |
---|
| 908 | end |
---|
| 909 | |
---|
| 910 | % nomenclature type of the .nc files |
---|
| 911 | nom_type_ima=[];%default |
---|
| 912 | if isfield(browse,'nom_type_ima') |
---|
| 913 | nom_type_ima=browse.nom_type_ima; |
---|
| 914 | end |
---|
| 915 | |
---|
[112] | 916 | %determine nom_type_nc: |
---|
[2] | 917 | nom_type_nc=[];%default |
---|
| 918 | if isfield(browse,'nom_type_nc') |
---|
| 919 | nom_type_nc=browse.nom_type_nc; |
---|
| 920 | end |
---|
| 921 | if isempty(nom_type_nc) |
---|
[112] | 922 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 923 | end |
---|
| 924 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 925 | set(handles.RootName,'UserData',browse) |
---|
[2] | 926 | |
---|
| 927 | %reads .nc subdirectoy and image numbers from the interface |
---|
[289] | 928 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 929 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 930 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 931 | ref_j=0; |
---|
| 932 | else |
---|
[45] | 933 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 934 | end |
---|
[273] | 935 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[2] | 936 | if isempty(time) |
---|
| 937 | time=[0 1]; |
---|
[112] | 938 | end |
---|
[71] | 939 | dt_unit=1000;%default |
---|
[282] | 940 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[2] | 941 | |
---|
[112] | 942 | %eliminate the first pairs inconsistent with the position |
---|
| 943 | if isempty(displ_num) |
---|
| 944 | nbpair=0; |
---|
| 945 | else |
---|
[2] | 946 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 947 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 948 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 949 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 950 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 951 | end |
---|
[112] | 952 | end |
---|
[2] | 953 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 954 | |
---|
[282] | 955 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
[2] | 956 | % be performed, while the result is needed for next steps. |
---|
| 957 | displ_pair={''}; |
---|
[300] | 958 | select=ones(size(1:nbpair))%flag for displayed pairs =1 for display |
---|
[2] | 959 | testpair=0; |
---|
[282] | 960 | % case with no checkciv1 operation, netcdf files need to exist for reading |
---|
[298] | 961 | if ~get(handles.CheckCiv1,'Value') % |
---|
[112] | 962 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 963 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
[282] | 964 | set(handles.ListPairCiv1,'String',{}); |
---|
[112] | 965 | return |
---|
[2] | 966 | end |
---|
[112] | 967 | for ipair=1:nbpair |
---|
[2] | 968 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 969 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[273] | 970 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 971 | end |
---|
| 972 | % case of no displayed pair |
---|
| 973 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 974 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
[2] | 975 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 976 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 977 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 978 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 979 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 980 | select(1)=exist(filename,'file')==2; |
---|
| 981 | testpair=1; |
---|
| 982 | else |
---|
[112] | 983 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 984 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 985 | else |
---|
| 986 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 987 | end |
---|
[282] | 988 | set(handles.ListPairCiv1,'String',{''}); |
---|
[112] | 989 | %COMPLETER CAS STEREO |
---|
[2] | 990 | return |
---|
| 991 | end |
---|
| 992 | end |
---|
| 993 | end |
---|
| 994 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 995 | if testpair |
---|
[73] | 996 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 997 | else |
---|
[73] | 998 | for ipair=1:nbpair |
---|
| 999 | if select(ipair) |
---|
| 1000 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1001 | 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 |
---|
| 1002 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1003 | else |
---|
| 1004 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1005 | end |
---|
| 1006 | end |
---|
| 1007 | end |
---|
[2] | 1008 | end |
---|
| 1009 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1010 | if testpair |
---|
[112] | 1011 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1012 | else |
---|
[112] | 1013 | for ipair=1:nbpair |
---|
| 1014 | if select(ipair) |
---|
| 1015 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1016 | 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 |
---|
| 1017 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1018 | end |
---|
| 1019 | elseif testpair |
---|
| 1020 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1021 | else |
---|
| 1022 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1023 | end |
---|
| 1024 | end |
---|
| 1025 | end |
---|
[2] | 1026 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1027 | for ipair=1:nbpair |
---|
| 1028 | if select(ipair) |
---|
[112] | 1029 | 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 |
---|
| 1030 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1031 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1032 | else |
---|
| 1033 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1034 | end |
---|
| 1035 | end |
---|
[2] | 1036 | elseif isequal(mode,'displacement') |
---|
[112] | 1037 | displ_pair={'Di=Dj=0'}; |
---|
| 1038 | end |
---|
[282] | 1039 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
[300] | 1040 | |
---|
| 1041 | %% determine the default selection in the pair menu |
---|
| 1042 | ichoice=find(select,1)% index of selected pair |
---|
[45] | 1043 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[300] | 1044 | initial=get(handles.ListPairCiv1,'Value')%initial choice of pair |
---|
| 1045 | if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) |
---|
[282] | 1046 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1047 | end |
---|
[300] | 1048 | % if numel(select)>=initial && ~isequal(select(initial),1) |
---|
| 1049 | % set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1050 | % end |
---|
[45] | 1051 | |
---|
[282] | 1052 | %set(handles.ListPairCiv2,'String',displ_pair'); |
---|
| 1053 | initial=get(handles.ListPairCiv2,'Value'); |
---|
[2] | 1054 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1055 | if ichoice <= length(displ_pair') |
---|
[282] | 1056 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
[2] | 1057 | else |
---|
[282] | 1058 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
[2] | 1059 | end |
---|
| 1060 | end |
---|
[282] | 1061 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
[2] | 1062 | set(gcf,'Pointer','arrow') |
---|
[12] | 1063 | |
---|
| 1064 | %------------------------------------------------------------------------ |
---|
[282] | 1065 | % determine the menu for checkciv2 pairs depending on the existing netcdf file at the |
---|
[112] | 1066 | %middle of the series set by first_i, incr, last_i |
---|
[289] | 1067 | function find_netcpair_civ2(handles) |
---|
[12] | 1068 | %------------------------------------------------------------------------ |
---|
[2] | 1069 | set(gcf,'Pointer','watch') |
---|
| 1070 | %nomenclature types |
---|
[71] | 1071 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1072 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 1073 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 1074 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 1075 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 1076 | compare=compare_list{val}; |
---|
| 1077 | if strcmp(compare,'displacement') |
---|
| 1078 | mode='displacement'; |
---|
| 1079 | else |
---|
[282] | 1080 | mode_list=get(handles.ListPairMode,'String'); |
---|
[270] | 1081 | if isempty(mode_list) |
---|
| 1082 | msgbox_uvmat('ERROR','please enter an input image or netcdf file') |
---|
| 1083 | return |
---|
| 1084 | end |
---|
[282] | 1085 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1086 | mode=mode_list{mode_value}; |
---|
| 1087 | end |
---|
| 1088 | |
---|
| 1089 | % nomenclature type of the .nc files |
---|
| 1090 | nom_type_ima='ima_num';%default |
---|
| 1091 | if isfield(browse,'nom_type_ima') |
---|
| 1092 | nom_type_ima=browse.nom_type_ima; |
---|
| 1093 | end |
---|
| 1094 | nom_type_nc='_i1-i2';%default |
---|
| 1095 | if isfield(browse,'nom_type_nc') |
---|
| 1096 | nom_type_nc=browse.nom_type_nc; |
---|
| 1097 | end |
---|
[94] | 1098 | 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] | 1099 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1100 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1101 | nom_type_nc='none'; |
---|
[94] | 1102 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1103 | nom_type_nc='_i1-i2'; |
---|
[2] | 1104 | else |
---|
| 1105 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1106 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1107 | else |
---|
| 1108 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1109 | end |
---|
[2] | 1110 | end |
---|
| 1111 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 1112 | set(handles.RootName,'UserData',browse) |
---|
[2] | 1113 | |
---|
| 1114 | %reads .nc subdirectory and image numbers from the interface |
---|
[289] | 1115 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1116 | subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[273] | 1117 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1118 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1119 | ref_j=0; |
---|
| 1120 | else |
---|
[273] | 1121 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1122 | end |
---|
[273] | 1123 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 1124 | if isempty(time) |
---|
| 1125 | time=[0 1];%default |
---|
| 1126 | end |
---|
[282] | 1127 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[2] | 1128 | |
---|
[112] | 1129 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1130 | if isempty(displ_num) |
---|
| 1131 | nbpair=0; |
---|
| 1132 | else |
---|
| 1133 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1134 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1135 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1136 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1137 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1138 | end |
---|
| 1139 | end |
---|
| 1140 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1141 | |
---|
[282] | 1142 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
[2] | 1143 | % be performed, while the result is needed for next steps. |
---|
| 1144 | displ_pair={''}; %default |
---|
| 1145 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
[298] | 1146 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[112] | 1147 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1148 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
[282] | 1149 | set(handles.ListPairCiv2,'Value',1); |
---|
| 1150 | set(handles.ListPairCiv2,'String',{''}); |
---|
[112] | 1151 | return |
---|
[2] | 1152 | end |
---|
[112] | 1153 | for ipair=1:nbpair |
---|
[2] | 1154 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1155 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1156 | select(ipair)=exist(filename,'file')==2; |
---|
| 1157 | end |
---|
| 1158 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1159 | if isfield(browse,'incr_pair') |
---|
[2] | 1160 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1161 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1162 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1163 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1164 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1165 | select(1)=exist(filename,'file')==2; |
---|
| 1166 | else |
---|
[112] | 1167 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1168 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1169 | else |
---|
| 1170 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1171 | end |
---|
[282] | 1172 | set(handles.ListPairCiv2,'Value',1); |
---|
| 1173 | set(handles.ListPairCiv2,'String',{''}); |
---|
[2] | 1174 | return |
---|
| 1175 | end |
---|
| 1176 | end |
---|
| 1177 | end |
---|
[112] | 1178 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1179 | for ipair=1:nbpair |
---|
| 1180 | if select(ipair) |
---|
| 1181 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1182 | 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 |
---|
| 1183 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1184 | end |
---|
| 1185 | else |
---|
| 1186 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1187 | end |
---|
| 1188 | end |
---|
[2] | 1189 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1190 | for ipair=1:nbpair |
---|
| 1191 | if select(ipair) |
---|
| 1192 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1193 | 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 |
---|
| 1194 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1195 | end |
---|
| 1196 | else |
---|
| 1197 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1198 | end |
---|
| 1199 | end |
---|
[2] | 1200 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1201 | for ipair=1:nbpair |
---|
| 1202 | if select(ipair) |
---|
[112] | 1203 | 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 |
---|
| 1204 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1205 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1206 | else |
---|
| 1207 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1208 | end |
---|
| 1209 | end |
---|
[2] | 1210 | elseif isequal(mode,'displacement') |
---|
[112] | 1211 | displ_pair={'Di=Dj=0'}; |
---|
| 1212 | end |
---|
[282] | 1213 | val=get(handles.ListPairCiv2,'Value'); |
---|
[229] | 1214 | ichoice=find(select,1); |
---|
[137] | 1215 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[282] | 1216 | if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 |
---|
[2] | 1217 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1218 | end |
---|
| 1219 | if val>length(displ_pair') |
---|
[282] | 1220 | set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu |
---|
[2] | 1221 | else |
---|
[282] | 1222 | set(handles.ListPairCiv2,'Value',val); |
---|
[2] | 1223 | end |
---|
[282] | 1224 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
[12] | 1225 | set(gcf,'Pointer','arrow') |
---|
[2] | 1226 | |
---|
| 1227 | |
---|
[41] | 1228 | |
---|
[227] | 1229 | |
---|
[12] | 1230 | %------------------------------------------------------------------------ |
---|
[282] | 1231 | % --- Executes on selection change in ListPairCiv1. |
---|
| 1232 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 1233 | %------------------------------------------------------------------------ |
---|
[282] | 1234 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
| 1235 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 1236 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
| 1237 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[137] | 1238 | % num_a=displ_num(1,index_pair); |
---|
| 1239 | % num_b=displ_num(2,index_pair); |
---|
[282] | 1240 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
[2] | 1241 | if index_pair<=length(list_pair2) |
---|
[282] | 1242 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
[2] | 1243 | end |
---|
| 1244 | |
---|
[112] | 1245 | %update first_i and last_i according to the chosen image pairs |
---|
[282] | 1246 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1247 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1248 | mode=mode_list{mode_value}; |
---|
| 1249 | if isequal(mode,'series(Di)') |
---|
[137] | 1250 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1251 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1252 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1253 | num1=first_i:incr_i:last_i; |
---|
[137] | 1254 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1255 | if ~isnan(lastfield) |
---|
[229] | 1256 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1257 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1258 | num1=num1(test_find); |
---|
[2] | 1259 | end |
---|
| 1260 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1261 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1262 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1263 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1264 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1265 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1266 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1267 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1268 | if ~isnan(lastfield2) |
---|
[229] | 1269 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1270 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1271 | num1=num_j(test_find); |
---|
[2] | 1272 | end |
---|
| 1273 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1274 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1275 | end |
---|
[2] | 1276 | |
---|
[12] | 1277 | %------------------------------------------------------------------------ |
---|
[282] | 1278 | % --- Executes on selection change in ListPairCiv2. |
---|
| 1279 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 1280 | %------------------------------------------------------------------------ |
---|
[282] | 1281 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
[2] | 1282 | |
---|
[112] | 1283 | %update first_i and last_i according to the chosen image pairs |
---|
[282] | 1284 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1285 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1286 | mode=mode_list{mode_value}; |
---|
| 1287 | if isequal(mode,'series(Di)') |
---|
[137] | 1288 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1289 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1290 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1291 | num1=first_i:incr_i:last_i; |
---|
[137] | 1292 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1293 | if ~isnan(lastfield) |
---|
[229] | 1294 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1295 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1296 | num1=num1(test_find); |
---|
[2] | 1297 | end |
---|
| 1298 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1299 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1300 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1301 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1302 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1303 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1304 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1305 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1306 | if ~isnan(lastfield2) |
---|
[229] | 1307 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1308 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1309 | num1=num_j(test_find); |
---|
[2] | 1310 | end |
---|
| 1311 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1312 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1313 | end |
---|
[2] | 1314 | |
---|
[177] | 1315 | %------------------------------------------------------------------------ |
---|
| 1316 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1317 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1318 | %------------------------------------------------------------------------ |
---|
[73] | 1319 | set(handles.RUN, 'Enable','Off') |
---|
| 1320 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1321 | batch=0; |
---|
[229] | 1322 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1323 | set(handles.RUN, 'Enable','On') |
---|
| 1324 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1325 | |
---|
[177] | 1326 | % start status callback to visualise results |
---|
[229] | 1327 | if ~isempty(errormsg) |
---|
| 1328 | display(errormsg) |
---|
| 1329 | msgbox_uvmat('ERROR',errormsg) |
---|
[282] | 1330 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
[225] | 1331 | set(handles.status,'Value',1);%suppress status display |
---|
| 1332 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1333 | end |
---|
[177] | 1334 | |
---|
[12] | 1335 | %------------------------------------------------------------------------ |
---|
[2] | 1336 | % --- Executes on button press in BATCH: remote processing |
---|
| 1337 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1338 | % ----------------------------------------------------------------------- |
---|
[73] | 1339 | set(handles.BATCH, 'Enable','Off') |
---|
| 1340 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1341 | batch=1; |
---|
[229] | 1342 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1343 | set(handles.BATCH, 'Enable','On') |
---|
| 1344 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1345 | |
---|
[177] | 1346 | % start status callback to visualise results |
---|
[229] | 1347 | if ~isempty(errormsg) |
---|
| 1348 | display(errormsg) |
---|
| 1349 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1350 | elseif isfield(handles,'status') |
---|
| 1351 | set(handles.status,'Value',1);%suppress status display |
---|
| 1352 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1353 | end |
---|
[227] | 1354 | |
---|
[67] | 1355 | %------------------------------------------------------------------------ |
---|
[133] | 1356 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1357 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1358 | %----------------------------------------------------------------------- |
---|
[229] | 1359 | errormsg='';%default |
---|
[272] | 1360 | |
---|
[282] | 1361 | %%read the civ GUI |
---|
[289] | 1362 | Param=read_GUI(handles.civ); |
---|
[133] | 1363 | %% check the selected list of operations: |
---|
[289] | 1364 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
[282] | 1365 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
[284] | 1366 | |
---|
[180] | 1367 | index_first=find(box_test==1,1); |
---|
| 1368 | if isempty(index_first) |
---|
[229] | 1369 | errormsg='no selected operation'; |
---|
[2] | 1370 | return |
---|
| 1371 | end |
---|
[180] | 1372 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1373 | box_used=box_test(index_first : index_last); |
---|
[2] | 1374 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1375 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1376 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1377 | return |
---|
| 1378 | end |
---|
| 1379 | |
---|
[272] | 1380 | %% check mask if selecetd |
---|
| 1381 | %could be included in get_mask callback ? |
---|
[282] | 1382 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[276] | 1383 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1384 | if ~exist(maskname,'file') |
---|
| 1385 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1386 | end |
---|
[2] | 1387 | end |
---|
[282] | 1388 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1389 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1390 | if ~exist(maskname,'file') |
---|
| 1391 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1392 | end |
---|
[2] | 1393 | end |
---|
[282] | 1394 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[276] | 1395 | maskname=get(handles.txt_Mask,'String'); |
---|
[12] | 1396 | if ~exist(maskname,'file') |
---|
[112] | 1397 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1398 | end |
---|
[2] | 1399 | end |
---|
[282] | 1400 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[287] | 1401 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1402 | if ~exist(maskname,'file') |
---|
[112] | 1403 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1404 | end |
---|
[2] | 1405 | end |
---|
| 1406 | |
---|
[177] | 1407 | %% reinitialise status callback |
---|
[178] | 1408 | if isfield(handles,'status') |
---|
[180] | 1409 | set(handles.status,'Value',0);%suppress status display |
---|
| 1410 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1411 | end |
---|
[133] | 1412 | |
---|
| 1413 | %% set the list of files and check them |
---|
| 1414 | display('checking the files...') |
---|
[227] | 1415 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1416 | if ~isempty(errormsg) |
---|
| 1417 | return |
---|
| 1418 | end |
---|
[263] | 1419 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=... |
---|
[273] | 1420 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[274] | 1421 | % ADDED |
---|
| 1422 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) |
---|
| 1423 | %ADDED |
---|
[177] | 1424 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1425 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1426 | return |
---|
| 1427 | end |
---|
| 1428 | nbfield=numel(num1_civ1); |
---|
| 1429 | nbslice=numel(num_a_civ1); |
---|
| 1430 | |
---|
[272] | 1431 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[276] | 1432 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
[112] | 1433 | xmlfile='PARAM.xml'; |
---|
[133] | 1434 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1435 | t=xmltree(xmlfile); |
---|
[67] | 1436 | s=convert(t); |
---|
[272] | 1437 | else |
---|
| 1438 | errormsg=['no file ' xmlfile]; |
---|
| 1439 | return |
---|
[2] | 1440 | end |
---|
[272] | 1441 | |
---|
| 1442 | test_interp=0; %eviter les variables test_ (LG) |
---|
| 1443 | |
---|
[127] | 1444 | if batch |
---|
[67] | 1445 | if isfield(s,'BatchParam') |
---|
[284] | 1446 | Param.xml=s.BatchParam; |
---|
| 1447 | if isfield(Param.xml,'BatchMode') |
---|
| 1448 | batch_mode=Param.xml.BatchMode; |
---|
[257] | 1449 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1450 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1451 | return |
---|
| 1452 | end |
---|
[67] | 1453 | end |
---|
| 1454 | else |
---|
[229] | 1455 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1456 | return |
---|
| 1457 | end |
---|
[257] | 1458 | else % run |
---|
[67] | 1459 | if isfield(s,'RunParam') |
---|
[284] | 1460 | Param.xml=s.RunParam; |
---|
[67] | 1461 | else |
---|
[225] | 1462 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1463 | return |
---|
| 1464 | end |
---|
[225] | 1465 | end |
---|
[238] | 1466 | |
---|
[272] | 1467 | %% check batch mode supported |
---|
| 1468 | if batch |
---|
| 1469 | switch batch_mode |
---|
| 1470 | case 'sge' |
---|
| 1471 | test_command='qstat'; |
---|
| 1472 | case 'oar' |
---|
[290] | 1473 | test_command='oarstat'; |
---|
[272] | 1474 | end |
---|
| 1475 | [s,w]=system(test_command); |
---|
| 1476 | if ~isequal(s,0) |
---|
| 1477 | msgbox_uvmat('ERROR',[batch_mode ' batch system not available']) |
---|
| 1478 | return |
---|
| 1479 | end |
---|
| 1480 | end |
---|
| 1481 | |
---|
| 1482 | %% check if the binaries exist |
---|
[273] | 1483 | if isequal(get(handles.Matlab,'checked'),'on') |
---|
| 1484 | CivMode='Matlab'; |
---|
| 1485 | else |
---|
| 1486 | CivMode='CivX'; |
---|
| 1487 | end |
---|
[280] | 1488 | binary_list={}; |
---|
[257] | 1489 | switch CivMode |
---|
[280] | 1490 | case 'CivX' |
---|
| 1491 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
| 1492 | case 'CivAll' |
---|
[289] | 1493 | binary_list={'Civ'}; |
---|
[257] | 1494 | case 'Matlab' |
---|
| 1495 | if batch |
---|
[272] | 1496 | % vérifier Matlab installé sur le cluster |
---|
| 1497 | % difficile a faire a priori |
---|
[257] | 1498 | end |
---|
[225] | 1499 | end |
---|
[280] | 1500 | for bin_name=binary_list |
---|
[284] | 1501 | if isfield(Param.xml,bin_name{1}) |
---|
| 1502 | if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml |
---|
[289] | 1503 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
[280] | 1504 | if exist(fullname,'file') |
---|
[284] | 1505 | Param.xml.(bin_name{1})=fullname; |
---|
[280] | 1506 | else |
---|
[284] | 1507 | msgbox_uvmat('ERROR',['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist']) |
---|
[280] | 1508 | return |
---|
| 1509 | end |
---|
| 1510 | else |
---|
[284] | 1511 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
[280] | 1512 | currentdir=pwd; |
---|
| 1513 | cd(path); |
---|
| 1514 | binpath=pwd;%path of the binary |
---|
[284] | 1515 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
| 1516 | % display(Param.xml.(bin_name{1})); |
---|
[280] | 1517 | cd(currentdir); |
---|
| 1518 | end |
---|
| 1519 | |
---|
| 1520 | end |
---|
| 1521 | end |
---|
[2] | 1522 | |
---|
[272] | 1523 | display('files OK, processing...') |
---|
[2] | 1524 | |
---|
| 1525 | |
---|
[133] | 1526 | %% MAIN LOOP |
---|
[273] | 1527 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[265] | 1528 | |
---|
[134] | 1529 | super_cmd=[]; |
---|
[269] | 1530 | batch_file_list=[]; |
---|
[265] | 1531 | |
---|
[2] | 1532 | for ifile=1:nbfield |
---|
| 1533 | for j=1:nbslice |
---|
[257] | 1534 | % initiate system command |
---|
| 1535 | switch CivMode |
---|
| 1536 | case 'CivX' |
---|
| 1537 | if isunix % check: necessaire aussi en RUN? |
---|
[272] | 1538 | cmd=['#!/bin/bash \n '... |
---|
| 1539 | '#$ -cwd \n '... |
---|
| 1540 | 'hostname && date \n '... |
---|
| 1541 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 1542 | else |
---|
| 1543 | cmd=[]; |
---|
[257] | 1544 | end |
---|
| 1545 | case 'CivAll' |
---|
| 1546 | % if CivAll |
---|
| 1547 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1548 | CivAllCmd=''; |
---|
| 1549 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1550 | end |
---|
[272] | 1551 | |
---|
| 1552 | |
---|
| 1553 | % define output file name |
---|
[282] | 1554 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
[272] | 1555 | OutputFile=filecell.nc.civ2{ifile,j}; |
---|
| 1556 | else |
---|
| 1557 | OutputFile=filecell.nc.civ1{ifile,j}; |
---|
| 1558 | end |
---|
| 1559 | OutputFile=regexprep(OutputFile,'.nc',''); |
---|
[269] | 1560 | |
---|
[282] | 1561 | if Param.CheckCiv1 |
---|
[272] | 1562 | % read image-dependent parameters |
---|
[284] | 1563 | Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
| 1564 | Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
| 1565 | Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 1566 | Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 1567 | Param.Civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1568 | Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[285] | 1569 | Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
| 1570 | Param.Civ1.pxcmy=1; |
---|
[284] | 1571 | |
---|
[285] | 1572 | A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 1573 | sizim=size(A); |
---|
| 1574 | Param.Civ1.npx=(sizim(2)); |
---|
| 1575 | Param.Civ1.npy=(sizim(1)); |
---|
| 1576 | %TODO : civ should not need npx and npy |
---|
[284] | 1577 | |
---|
[272] | 1578 | % read mask parameters |
---|
[284] | 1579 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
| 1580 | %matbe they when check_mask the Maskname is read |
---|
[285] | 1581 | if exist(Param.Civ1.MaskName,'file') |
---|
| 1582 | Param.Civ1.MaskFlag='y'; |
---|
[2] | 1583 | else |
---|
[285] | 1584 | maskbase=[filecell.filebase '_' Param.Civ1.MaskName]; % |
---|
[137] | 1585 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1586 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[285] | 1587 | Param.Civ1.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1588 | if exist(Param.Civ1.MaskName,'file') |
---|
[284] | 1589 | Param.Civ1.maskflag='y'; |
---|
[12] | 1590 | else |
---|
[285] | 1591 | Param.Civ1.MaskName='noFile use default'; |
---|
| 1592 | Param.Civ1.MaskFlag='n'; |
---|
[12] | 1593 | end |
---|
[2] | 1594 | end |
---|
[272] | 1595 | else |
---|
[285] | 1596 | Param.Civ1.MaskName='noFile use default'; |
---|
| 1597 | Param.Civ1.MaskFlag='n'; |
---|
[2] | 1598 | end |
---|
[272] | 1599 | |
---|
[282] | 1600 | % read grid parameters= |
---|
[284] | 1601 | if Param.Civ1.CheckGrid |
---|
[285] | 1602 | Param.Civ1.GridFlag='y'; |
---|
| 1603 | if isequal(Param.Civ1.GridName(end-3:end),'grid') |
---|
| 1604 | nbslice_grid=str2double(Param.Civ1.GridName(1:end-4)); % |
---|
[137] | 1605 | if ~isnan(nbslice_grid) |
---|
[2] | 1606 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[285] | 1607 | Param.Civ1.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1608 | if ~exist(Param.Civ1.GridName,'file') |
---|
[112] | 1609 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1610 | end |
---|
[285] | 1611 | elseif ~exist(Param.Civ1.GridName,'file') |
---|
[2] | 1612 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1613 | end |
---|
| 1614 | end |
---|
| 1615 | else |
---|
[285] | 1616 | Param.Civ1.GridName='noFile use default'; |
---|
| 1617 | Param.Civ1.GridFlag='n'; |
---|
[2] | 1618 | end |
---|
[257] | 1619 | |
---|
[285] | 1620 | % send command |
---|
[257] | 1621 | switch CivMode |
---|
| 1622 | case 'CivX' |
---|
[284] | 1623 | cmd=[cmd... |
---|
| 1624 | cmd_civ1(filecell.nc.civ1{ifile,j},Param) '\n']; |
---|
[257] | 1625 | case 'CivAll' |
---|
| 1626 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
[284] | 1627 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',Param.Civ1); |
---|
[257] | 1628 | fieldnames=fields(str); |
---|
| 1629 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 1630 | for ilist=1:length(fieldnames) |
---|
| 1631 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1632 | if ischar(val) |
---|
| 1633 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1634 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1635 | end |
---|
[112] | 1636 | end |
---|
[2] | 1637 | end |
---|
| 1638 | end |
---|
| 1639 | |
---|
[282] | 1640 | if Param.CheckFix1 |
---|
[272] | 1641 | switch CivMode |
---|
[257] | 1642 | case 'CivX' |
---|
[285] | 1643 | cmd=[cmd... |
---|
| 1644 | cmd_fix(filecell.nc.civ1{ifile,j},Param,'Fix1') '\n']; |
---|
[257] | 1645 | case 'CivAll' |
---|
| 1646 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[272] | 1647 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
| 1648 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
| 1649 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
| 1650 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
| 1651 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
[257] | 1652 | fieldnames=fields(fix1); |
---|
| 1653 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 1654 | for ilist=1:length(fieldnames) |
---|
| 1655 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1656 | if ischar(val) |
---|
| 1657 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1658 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1659 | end |
---|
| 1660 | end |
---|
| 1661 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1662 | end |
---|
| 1663 | end |
---|
| 1664 | |
---|
[282] | 1665 | %CheckPatch1 |
---|
| 1666 | if Param.CheckPatch1==1 |
---|
[257] | 1667 | switch CivMode |
---|
| 1668 | case 'CivX' |
---|
[286] | 1669 | cmd=[cmd... |
---|
| 1670 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch1') '\n']; |
---|
[257] | 1671 | case 'CivAll' |
---|
| 1672 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1673 | patch1.nopt=subdomain_patch1; |
---|
| 1674 | patch1.maxdiff=thresh_patch1; |
---|
| 1675 | patch1.ro=rho_patch1; |
---|
| 1676 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1677 | if test_grid |
---|
| 1678 | patch1.gridflag='y'; |
---|
| 1679 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1680 | if isequal(gridname(end-3:end),'grid') |
---|
| 1681 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1682 | if ~isnan(nbslice_grid) |
---|
| 1683 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 1684 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1685 | if ~exist(patch1.gridPatch,'file') |
---|
| 1686 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1687 | end |
---|
| 1688 | elseif exist(gridname,'file') |
---|
| 1689 | patch1.gridPatch=gridname; |
---|
| 1690 | else |
---|
[112] | 1691 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1692 | end |
---|
[2] | 1693 | end |
---|
[257] | 1694 | else |
---|
| 1695 | patch1.gridPatch='none'; |
---|
| 1696 | patch1.gridflag='n'; |
---|
| 1697 | patch1.m=nx_patch1; |
---|
| 1698 | patch1.n=ny_patch1; |
---|
[2] | 1699 | end |
---|
[257] | 1700 | patch1.convectFlow='n'; |
---|
| 1701 | fieldnames=fields(patch1); |
---|
| 1702 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 1703 | for ilist=1:length(fieldnames) |
---|
| 1704 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1705 | if ischar(val) |
---|
| 1706 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1707 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1708 | end |
---|
[112] | 1709 | end |
---|
[257] | 1710 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1711 | end |
---|
[2] | 1712 | end |
---|
[282] | 1713 | if Param.CheckCiv2==1 |
---|
[290] | 1714 | Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1715 | Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 1716 | Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 1717 | Param.Civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 1718 | Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 1719 | Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 1720 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1721 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
| 1722 | Param.Civ2.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
| 1723 | Param.Civ2.pxcmy=1; |
---|
[287] | 1724 | if Param.Civ2.CheckMask |
---|
[276] | 1725 | maskdispl=get(handles.txt_Mask,'String'); |
---|
[12] | 1726 | if exist(maskdispl,'file') |
---|
[290] | 1727 | Param.Civ2.MaskName=maskdispl; |
---|
| 1728 | Param.Civ2.MaskFlag='y'; |
---|
[2] | 1729 | else |
---|
[136] | 1730 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1731 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1732 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[290] | 1733 | Param.Civ2.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1734 | if exist(Param.Civ2.MaskName,'file') |
---|
| 1735 | Param.Civ2.MaskFlag='y'; |
---|
[12] | 1736 | else |
---|
[290] | 1737 | Param.Civ2.MaskName='noFile use default'; |
---|
| 1738 | Param.Civ2.MaskFlag='n'; |
---|
[12] | 1739 | end |
---|
[2] | 1740 | end |
---|
[287] | 1741 | else |
---|
[290] | 1742 | Param.Civ2.MaskName='noFile use default'; |
---|
| 1743 | Param.Civ2.MaskFlag='n'; |
---|
[2] | 1744 | end |
---|
[276] | 1745 | gridname=get(handles.txt_GridName,'String'); |
---|
[2] | 1746 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1747 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1748 | if ~isnan(nbslice_grid) |
---|
[290] | 1749 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1750 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[290] | 1751 | Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1752 | if exist(Param.Civ2.GridName,'file') |
---|
| 1753 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1754 | else |
---|
[290] | 1755 | Param.Civ2.GridName='noFile use default'; |
---|
| 1756 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1757 | end |
---|
| 1758 | elseif exist(gridname,'file') |
---|
[290] | 1759 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1760 | else |
---|
[290] | 1761 | Param.Civ2.GridName='noFile use default'; |
---|
| 1762 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1763 | end |
---|
[290] | 1764 | else |
---|
| 1765 | Param.Civ2.GridName='noFile use default'; |
---|
| 1766 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1767 | end |
---|
[290] | 1768 | A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size |
---|
| 1769 | sizim=size(A); |
---|
| 1770 | Param.Civ2.npx=(sizim(2)); |
---|
| 1771 | Param.Civ2.npy=(sizim(1)); |
---|
| 1772 | |
---|
[257] | 1773 | switch CivMode |
---|
| 1774 | case 'CivX' |
---|
[290] | 1775 | cmd=[cmd... |
---|
| 1776 | cmd_civ2(filecell.nc.civ2{ifile,j},Param) '\n']; |
---|
[257] | 1777 | case 'CivAll' |
---|
| 1778 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
[290] | 1779 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',Param.Civ2); |
---|
[257] | 1780 | fieldnames=fields(str); |
---|
| 1781 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 1782 | for ilist=1:length(fieldnames) |
---|
| 1783 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1784 | if ischar(val) |
---|
| 1785 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 1786 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1787 | end |
---|
[2] | 1788 | end |
---|
| 1789 | end |
---|
[112] | 1790 | end |
---|
| 1791 | |
---|
[282] | 1792 | % CheckFix2 |
---|
| 1793 | if Param.CheckFix2==1 |
---|
[257] | 1794 | switch CivMode |
---|
| 1795 | case 'CivX' |
---|
[291] | 1796 | cmd=[cmd... |
---|
| 1797 | cmd_fix(filecell.nc.civ2{ifile,j},Param,'Fix2') '\n']; |
---|
[257] | 1798 | case 'CivAll' |
---|
| 1799 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 1800 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 1801 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 1802 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 1803 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 1804 | fix2.threshV=num2str(thresh_vel2); |
---|
| 1805 | fieldnames=fields(fix2); |
---|
| 1806 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 1807 | for ilist=1:length(fieldnames) |
---|
| 1808 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 1809 | if ischar(val) |
---|
| 1810 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 1811 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1812 | end |
---|
| 1813 | end |
---|
| 1814 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 1815 | end |
---|
| 1816 | end |
---|
| 1817 | |
---|
[282] | 1818 | %CheckPatch2 |
---|
| 1819 | if Param.CheckPatch2==1 |
---|
[257] | 1820 | switch CivMode |
---|
| 1821 | case 'CivX' |
---|
[291] | 1822 | cmd=[cmd... |
---|
| 1823 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch2') '\n']; |
---|
[257] | 1824 | case 'CivAll' |
---|
| 1825 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1826 | patch2.nopt=subdomain_patch2; |
---|
| 1827 | patch2.maxdiff=thresh_patch2; |
---|
| 1828 | patch2.ro=rho_patch2; |
---|
| 1829 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 1830 | if test_grid |
---|
| 1831 | patch2.gridflag='y'; |
---|
| 1832 | gridname=get(handles.grid_patch2,'String'); |
---|
| 1833 | if isequal(gridname(end-3:end),'grid') |
---|
| 1834 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1835 | if ~isnan(nbslice_grid) |
---|
| 1836 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 1837 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1838 | if ~exist(patch2.gridPatch,'file') |
---|
| 1839 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 1840 | end |
---|
| 1841 | elseif exist(gridname,'file') |
---|
| 1842 | patch2.gridPatch=gridname; |
---|
| 1843 | else |
---|
[112] | 1844 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 1845 | end |
---|
[2] | 1846 | end |
---|
[257] | 1847 | else |
---|
| 1848 | patch2.gridPatch='none'; |
---|
| 1849 | patch2.gridflag='n'; |
---|
| 1850 | patch2.m=nx_patch2; |
---|
| 1851 | patch2.n=ny_patch2; |
---|
[2] | 1852 | end |
---|
[257] | 1853 | patch2.convectFlow='n'; |
---|
| 1854 | fieldnames=fields(patch2); |
---|
| 1855 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 1856 | for ilist=1:length(fieldnames) |
---|
| 1857 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 1858 | if ischar(val) |
---|
| 1859 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 1860 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1861 | end |
---|
[112] | 1862 | end |
---|
[257] | 1863 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 1864 | end |
---|
[12] | 1865 | end |
---|
[257] | 1866 | |
---|
| 1867 | switch CivMode |
---|
| 1868 | case {'CivX','CivAll'} |
---|
| 1869 | if isequal(CivMode,'CivAll') |
---|
[272] | 1870 | save(CivAllxml,[OutputFile '.xml']); |
---|
| 1871 | cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; |
---|
[238] | 1872 | end |
---|
[272] | 1873 | |
---|
| 1874 | % create the .bat file used in run or batch |
---|
| 1875 | filename_bat=[OutputFile '.bat']; |
---|
[257] | 1876 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1877 | if isequal(fid,-1) |
---|
| 1878 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 1879 | return |
---|
[238] | 1880 | end |
---|
[257] | 1881 | fprintf(fid,cmd); |
---|
| 1882 | fclose(fid); |
---|
[269] | 1883 | |
---|
[279] | 1884 | if isunix |
---|
| 1885 | system(['chmod +x ' filename_bat]); |
---|
| 1886 | end |
---|
| 1887 | |
---|
[269] | 1888 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
| 1889 | |
---|
| 1890 | % if batch |
---|
| 1891 | % switch batch_mode |
---|
| 1892 | % case 'sge' |
---|
| 1893 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 1894 | % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 1895 | % case 'oar' |
---|
| 1896 | % % eval( ['!chmod +x ' filename_bat]); |
---|
| 1897 | % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
| 1898 | % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]); |
---|
| 1899 | % |
---|
| 1900 | % cmd_str=['sh ' filename_bat]; |
---|
| 1901 | % super_cmd{length(super_cmd)+1}=cmd_str; |
---|
| 1902 | % |
---|
| 1903 | % end |
---|
| 1904 | % else |
---|
| 1905 | % %% to lauch the jobs locally : |
---|
| 1906 | % if(isunix) |
---|
| 1907 | % cmd_str=['. ' filename_bat]; |
---|
| 1908 | % else %case of Windows |
---|
| 1909 | % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
| 1910 | % end |
---|
| 1911 | % super_cmd=[super_cmd cmd_str '\n']; |
---|
| 1912 | % disp(cmd_str); |
---|
| 1913 | % end |
---|
[257] | 1914 | case 'Matlab' |
---|
| 1915 | drawnow |
---|
[282] | 1916 | if Param.CheckCiv1==1 |
---|
[284] | 1917 | Param.Civ1=Param.Civ1; |
---|
[252] | 1918 | end |
---|
[282] | 1919 | if Param.CheckFix1==1 |
---|
[257] | 1920 | fix1.WarnFlags=[]; |
---|
[282] | 1921 | if get(handles.CheckFmin2,'Value') |
---|
[257] | 1922 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 1923 | end |
---|
[282] | 1924 | if get(handles.CheckF3,'Value') |
---|
[257] | 1925 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 1926 | end |
---|
| 1927 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
[287] | 1928 | if get(handles.num_MinVel,'Value') |
---|
[257] | 1929 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 1930 | else |
---|
| 1931 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 1932 | end |
---|
[282] | 1933 | if get(handles.CheckMask,'Value') |
---|
[257] | 1934 | fix1.MaskName=maskname; |
---|
| 1935 | end |
---|
| 1936 | Param.Fix1=fix1; |
---|
[252] | 1937 | end |
---|
[282] | 1938 | if Param.CheckPatch1==1 |
---|
[263] | 1939 | if strcmp(compare,'stereo PIV') |
---|
| 1940 | filebase_A=filecell.filebase; |
---|
| 1941 | [pp,ff]=fileparts(filebase_A); |
---|
| 1942 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 1943 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1944 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1945 | else |
---|
| 1946 | Param.Patch1.Rho=rho_patch1; |
---|
| 1947 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 1948 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 1949 | end |
---|
[257] | 1950 | end |
---|
[282] | 1951 | if Param.CheckCiv2==1 |
---|
[290] | 1952 | Param.Civ2=Param.Civ2; |
---|
[257] | 1953 | end |
---|
[282] | 1954 | if Param.CheckFix2==1 |
---|
[257] | 1955 | fix2.WarnFlags=[]; |
---|
[287] | 1956 | if get(handles.CheckFmin2,'Value') |
---|
[257] | 1957 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 1958 | end |
---|
[287] | 1959 | if get(handles.CheckF4,'Value') |
---|
[257] | 1960 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 1961 | end |
---|
[287] | 1962 | if get(handles.CheckF3,'Value') |
---|
[257] | 1963 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 1964 | end |
---|
| 1965 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
[287] | 1966 | if get(handles.num_MinVel,'Value') |
---|
[257] | 1967 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 1968 | else |
---|
| 1969 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 1970 | end |
---|
[282] | 1971 | if get(handles.CheckMask,'Value') |
---|
[257] | 1972 | fix2.MaskName=maskname; |
---|
| 1973 | end |
---|
| 1974 | Param.Fix2=fix2; |
---|
| 1975 | end |
---|
[282] | 1976 | if Param.CheckPatch2==1 |
---|
[263] | 1977 | if strcmp(compare,'stereo PIV') |
---|
| 1978 | filebase_A=filecell.filebase; |
---|
| 1979 | [pp,ff]=fileparts(filebase_A); |
---|
| 1980 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 1981 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 1982 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
[270] | 1983 | else |
---|
| 1984 | Param.Patch2.Rho=rho_patch2; |
---|
| 1985 | Param.Patch2.Threshold=thresh_patch2; |
---|
| 1986 | Param.Patch2.SubDomain=subdomain_patch2; |
---|
[263] | 1987 | end |
---|
[257] | 1988 | end |
---|
[263] | 1989 | if ~strcmp(compare,'stereo PIV') |
---|
| 1990 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
| 1991 | if isempty(errormsg) |
---|
| 1992 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 1993 | else |
---|
| 1994 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1995 | end |
---|
[270] | 1996 | |
---|
[263] | 1997 | end |
---|
[257] | 1998 | end |
---|
[112] | 1999 | end |
---|
[2] | 2000 | end |
---|
[134] | 2001 | |
---|
[265] | 2002 | if batch |
---|
[269] | 2003 | switch batch_mode |
---|
| 2004 | case 'sge' |
---|
| 2005 | for p=1:length(batch_file_list) |
---|
| 2006 | cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 2007 | display(cmd);eval(cmd); |
---|
| 2008 | end |
---|
[279] | 2009 | case 'oar_old' |
---|
| 2010 | for p=1:length(batch_file_list) |
---|
| 2011 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
| 2012 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 2013 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
| 2014 | display(oar_command);eval(oar_command); |
---|
[290] | 2015 | end |
---|
| 2016 | case 'oar' %oar-dispatch.pl |
---|
[279] | 2017 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2018 | fid=fopen(filename_joblist,'w'); |
---|
| 2019 | |
---|
| 2020 | for p=1:length(batch_file_list) |
---|
| 2021 | oar_command=['oarsub -n CIVX '... |
---|
[297] | 2022 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
[279] | 2023 | '-l "/core=1,walltime=00:10:00" ' batch_file_list{p}]; |
---|
| 2024 | fprintf(fid,[oar_command '\n']); |
---|
[265] | 2025 | end |
---|
[290] | 2026 | fclose(fid); |
---|
[297] | 2027 | ncores=36; |
---|
| 2028 | walltime=datestr(length(batch_file_list)*10/24/60/ncores,13); |
---|
| 2029 | oar_command=['oarsub -t container -n civx-container '... |
---|
| 2030 | '-l /core=' num2str(ncores) ',walltime=' walltime... |
---|
| 2031 | ' "oar-dispatch -f ' filename_joblist '"']; |
---|
[279] | 2032 | filename_oarcommand=fullfile(Rootbat,'oar_command'); |
---|
| 2033 | fid=fopen(filename_oarcommand,'w'); |
---|
| 2034 | fprintf(fid,[oar_command '\n']); |
---|
| 2035 | fclose(fid); |
---|
[290] | 2036 | display(oar_command); |
---|
| 2037 | eval(['! . ' filename_oarcommand]) |
---|
| 2038 | case 'oar_mpi' |
---|
[279] | 2039 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2040 | fid=fopen(filename_joblist,'w'); |
---|
| 2041 | |
---|
| 2042 | for p=1:length(batch_file_list) |
---|
| 2043 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
[265] | 2044 | end |
---|
[279] | 2045 | fclose(fid) |
---|
| 2046 | |
---|
| 2047 | |
---|
| 2048 | % oarsub -S ./oar.sub |
---|
| 2049 | |
---|
| 2050 | |
---|
| 2051 | |
---|
| 2052 | |
---|
| 2053 | |
---|
[269] | 2054 | case 'oar_new' % to be develloped with Patrick Begou |
---|
| 2055 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2056 | fid=fopen(filename_superbat,'w'); |
---|
| 2057 | if fid==-1 |
---|
| 2058 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2059 | return |
---|
[265] | 2060 | end |
---|
[269] | 2061 | for p=1:length(batch_file_list) |
---|
| 2062 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 2063 | end |
---|
| 2064 | fclose(fid); |
---|
| 2065 | walltime=datestr(length(super_cmd)*10/24/60,13); |
---|
| 2066 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); |
---|
| 2067 | end |
---|
| 2068 | else |
---|
| 2069 | if ~isequal(CivMode,'Matlab') |
---|
| 2070 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
| 2071 | fid=fopen(filename_superbat,'w'); |
---|
| 2072 | if fid==-1 |
---|
| 2073 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2074 | return |
---|
| 2075 | end |
---|
| 2076 | for p=1:length(batch_file_list) |
---|
| 2077 | if isunix |
---|
| 2078 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 2079 | else |
---|
| 2080 | fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']); |
---|
[265] | 2081 | end |
---|
[269] | 2082 | end |
---|
| 2083 | fclose(fid); |
---|
| 2084 | if(isunix) |
---|
| 2085 | system(['chmod +x ' filename_superbat]); |
---|
| 2086 | end |
---|
| 2087 | system([filename_superbat ' &']);% execute main commmand |
---|
[265] | 2088 | end |
---|
[269] | 2089 | |
---|
[265] | 2090 | end |
---|
| 2091 | |
---|
[2] | 2092 | |
---|
[137] | 2093 | %% save interface state |
---|
[2] | 2094 | if isfield(filecell,'nc') |
---|
| 2095 | if isfield(filecell.nc,'civ2') |
---|
| 2096 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2097 | else |
---|
| 2098 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2099 | end |
---|
| 2100 | end |
---|
| 2101 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2102 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2103 | detect=1; |
---|
[2] | 2104 | while detect==1 |
---|
| 2105 | namefigfull=[namedoc '.fig']; |
---|
| 2106 | hh=dir(namefigfull); |
---|
| 2107 | if ~isempty(hh) |
---|
| 2108 | detect=1; |
---|
| 2109 | namedoc=[namedoc '.0']; |
---|
| 2110 | else |
---|
| 2111 | detect=0; |
---|
| 2112 | end |
---|
| 2113 | end |
---|
| 2114 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2115 | |
---|
[273] | 2116 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 2117 | MenuFile={}; |
---|
| 2118 | dir_perso=prefdir; |
---|
| 2119 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 2120 | if exist(profil_perso,'file') |
---|
| 2121 | hh=load (profil_perso); |
---|
| 2122 | if isfield(hh,'MenuFile') |
---|
| 2123 | MenuFile=hh.MenuFile; |
---|
| 2124 | end |
---|
[289] | 2125 | if isfield(filecell.nc,'civ2') |
---|
| 2126 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
| 2127 | else |
---|
| 2128 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
| 2129 | end |
---|
[273] | 2130 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 2131 | else |
---|
| 2132 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 2133 | save (profil_perso,'MenuFile') |
---|
| 2134 | end |
---|
| 2135 | |
---|
| 2136 | |
---|
[227] | 2137 | %------------------------------------------------------------------------ |
---|
| 2138 | % --- determine the list of reference indices of processing file |
---|
| 2139 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2140 | %------------------------------------------------------------------------ |
---|
| 2141 | errormsg=''; %default error message |
---|
| 2142 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2143 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2144 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2145 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2146 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2147 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2148 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2149 | else |
---|
| 2150 | first_j=1; |
---|
| 2151 | last_j=1; |
---|
| 2152 | incr_j=1; |
---|
| 2153 | end |
---|
| 2154 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2155 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2156 | if isnan(first_i)||isnan(first_j) |
---|
| 2157 | errormsg='first field number not defined'; |
---|
| 2158 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2159 | errormsg='last field number not defined'; |
---|
| 2160 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2161 | errormsg='increment in field number not defined'; |
---|
| 2162 | elseif last_i < first_i || last_j < first_j |
---|
| 2163 | errormsg='last field number must be larger than the first one'; |
---|
| 2164 | end |
---|
[134] | 2165 | |
---|
[227] | 2166 | %------------------------------------------------------------------------ |
---|
| 2167 | % --- determine the list of filenames and indices needed for launch_job |
---|
[263] | 2168 | 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,compare]=... |
---|
[282] | 2169 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
[12] | 2170 | %------------------------------------------------------------------------ |
---|
[85] | 2171 | filecell=[];%default |
---|
[136] | 2172 | |
---|
| 2173 | %% get the root names nomenclature and numbers |
---|
[71] | 2174 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2175 | |
---|
| 2176 | if isempty(filebase)||isequal(filebase,'') |
---|
[298] | 2177 | msgbox_uvmat('ERROR','please open an image with the upper menu option Open/Browse...') |
---|
[136] | 2178 | return |
---|
| 2179 | end |
---|
| 2180 | |
---|
[137] | 2181 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2182 | filecell.filebase=filebase; |
---|
| 2183 | |
---|
[273] | 2184 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 2185 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2186 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 2187 | compare=compare_list{val}; |
---|
| 2188 | if strcmp(compare,'displacement') |
---|
| 2189 | mode='displacement'; |
---|
| 2190 | else |
---|
[282] | 2191 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2192 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 2193 | mode=mode_list{mode_value}; |
---|
| 2194 | end |
---|
[137] | 2195 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2196 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2197 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2198 | if isfield(browse,'nom_type_ima') |
---|
| 2199 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2200 | end |
---|
| 2201 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2202 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2203 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2204 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[282] | 2205 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
[2] | 2206 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2207 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2208 | % test_disp=1; |
---|
[2] | 2209 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2210 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2211 | Path1=Path2; |
---|
[71] | 2212 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2213 | filebase_A=fullfile(Path1,Name1); |
---|
| 2214 | if length(Name1)>6 |
---|
| 2215 | Name1=Name1(end-5:end); |
---|
| 2216 | end |
---|
| 2217 | if length(Name2)>6 |
---|
| 2218 | Name2=Name2(end-5:end); |
---|
| 2219 | end |
---|
| 2220 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2221 | else |
---|
[127] | 2222 | % test_disp=0; |
---|
[2] | 2223 | filebase_A=filebase; |
---|
| 2224 | nom_type_ima1=nom_type_ima2; |
---|
| 2225 | filebase_AB=filebase; |
---|
| 2226 | end |
---|
| 2227 | if strcmp(compare,'displacement') |
---|
[112] | 2228 | filebase_ima1=filebase_A; |
---|
| 2229 | filebase_ima2=filebase_B; |
---|
| 2230 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2231 | else |
---|
[112] | 2232 | filebase_ima1=filebase_B; |
---|
| 2233 | filebase_ima2=filebase_B; |
---|
| 2234 | filebase_nc=filebase_B; |
---|
| 2235 | end |
---|
[2] | 2236 | |
---|
| 2237 | %determine reference files for fix: |
---|
| 2238 | file_ref_fix1={};%default |
---|
| 2239 | file_ref_fix2={}; |
---|
| 2240 | nbfield=length(num1_civ1); |
---|
| 2241 | nbslice=length(num_a_civ1); |
---|
[282] | 2242 | if checkbox(2)==1% fix1 performed |
---|
[2] | 2243 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2244 | if ~isempty(ref) |
---|
[137] | 2245 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2246 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2247 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2248 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2249 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2250 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2251 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2252 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2253 | if isequal(mode,'displacement') |
---|
| 2254 | num_i1=num_i_ref; |
---|
| 2255 | num_i2=num_i_ref; |
---|
| 2256 | num_j1=num_j_ref; |
---|
| 2257 | num_j2=num_j_ref; |
---|
| 2258 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2259 | num_i1=num_i_ref; |
---|
| 2260 | num_i2=num_i1; |
---|
| 2261 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2262 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2263 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2264 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2265 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2266 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2267 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2268 | if isempty(ref.num_a) |
---|
| 2269 | ref.num_a=1; |
---|
| 2270 | end |
---|
| 2271 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2272 | num_j2=num_j1; |
---|
| 2273 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2274 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2275 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2276 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2277 | num_i2=num_i1; |
---|
| 2278 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2279 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2280 | end |
---|
| 2281 | for ifile=1:nbfield |
---|
| 2282 | for j=1:nbslice |
---|
| 2283 | 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);% |
---|
| 2284 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2285 | if ~exist(file_ref,'file') |
---|
| 2286 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2287 | filecell=[]; |
---|
[2] | 2288 | return |
---|
| 2289 | end |
---|
| 2290 | end |
---|
| 2291 | end |
---|
| 2292 | end |
---|
| 2293 | end |
---|
| 2294 | |
---|
[282] | 2295 | %determine reference files for checkfix2: |
---|
| 2296 | if checkbox(5)==1% fix2 performed |
---|
[2] | 2297 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2298 | if ~isempty(ref) |
---|
[127] | 2299 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2300 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2301 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2302 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2303 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2304 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2305 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2306 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2307 | if isequal(mode,'displacement') |
---|
| 2308 | num_i1=num_i_ref; |
---|
| 2309 | num_i2=num_i_ref; |
---|
| 2310 | num_j1=num_j_ref; |
---|
| 2311 | num_j2=num_j_ref; |
---|
| 2312 | elseif isequal(mode,'pair j1-j2') |
---|
| 2313 | num_i1=num_i_ref; |
---|
| 2314 | num_i2=num_i1; |
---|
| 2315 | num_j1=ref.num_a; |
---|
| 2316 | num_j2=ref.num_b; |
---|
| 2317 | elseif isequal(mode,'series(Di)') |
---|
| 2318 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2319 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2320 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2321 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2322 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2323 | num_j2=num_j1; |
---|
| 2324 | elseif isequal(mode,'series(Dj)') |
---|
| 2325 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2326 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2327 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2328 | num_i2=num_i1; |
---|
| 2329 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2330 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2331 | end |
---|
| 2332 | for ifile=1:nbfield |
---|
| 2333 | for j=1:nbslice |
---|
| 2334 | 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);% |
---|
| 2335 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2336 | if ~exist(file_ref,'file') |
---|
| 2337 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2338 | filecell={}; |
---|
[2] | 2339 | return |
---|
| 2340 | end |
---|
| 2341 | end |
---|
| 2342 | end |
---|
| 2343 | end |
---|
| 2344 | end |
---|
| 2345 | |
---|
| 2346 | %check dir |
---|
[289] | 2347 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2348 | subdir_civ2=get(handles.txt_SubdirCiv2,'String'); |
---|
[174] | 2349 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2350 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[266] | 2351 | % currentdir=pwd;%store the current working directory |
---|
[2] | 2352 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2353 | if ~exist(Path_ima,'dir') |
---|
[12] | 2354 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2355 | filecell={}; |
---|
[2] | 2356 | return |
---|
| 2357 | end |
---|
[127] | 2358 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2359 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2360 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2361 | filecell={}; |
---|
[266] | 2362 | % cd(currentdir); |
---|
[112] | 2363 | return |
---|
[2] | 2364 | end |
---|
| 2365 | |
---|
| 2366 | %check the existence of the netcdf and image files involved |
---|
[282] | 2367 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
| 2368 | if checkbox(1)==1; |
---|
[112] | 2369 | detect=1; |
---|
[127] | 2370 | vers=0; |
---|
| 2371 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2372 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2373 | for ifile=1:nbfield |
---|
[112] | 2374 | for j=1:nbslice |
---|
[122] | 2375 | 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] | 2376 | detect=exist(filename,'file')==2; |
---|
| 2377 | if detect% if a netcdf file already exists |
---|
[137] | 2378 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2379 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2380 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2381 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2382 | else |
---|
| 2383 | vers=vers+1; |
---|
[137] | 2384 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2385 | end |
---|
[137] | 2386 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2387 | break |
---|
| 2388 | end |
---|
| 2389 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2390 | end |
---|
| 2391 | if detect% if a netcdf file already exists |
---|
| 2392 | break |
---|
| 2393 | end |
---|
| 2394 | end |
---|
[134] | 2395 | |
---|
[289] | 2396 | %create the new txt_SubdirCiv1 |
---|
[127] | 2397 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[263] | 2398 | % cd(Path_ima); |
---|
| 2399 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
[134] | 2400 | |
---|
[128] | 2401 | if ~strcmp(msg1,'') |
---|
| 2402 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2403 | filecell={}; |
---|
| 2404 | return |
---|
[163] | 2405 | elseif isunix |
---|
[266] | 2406 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2407 | if ~strcmp(msg2,'') |
---|
[266] | 2408 | msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation |
---|
[128] | 2409 | filecell={}; |
---|
| 2410 | return |
---|
| 2411 | end |
---|
[112] | 2412 | end |
---|
[263] | 2413 | % cd(currentdir); |
---|
[112] | 2414 | end |
---|
| 2415 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2416 | for ifile=1:nbfield |
---|
| 2417 | for j=1:nbslice |
---|
[122] | 2418 | 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] | 2419 | detect=exist(filename,'file')==2; |
---|
[2] | 2420 | if detect% if a netcdf file already exists |
---|
[137] | 2421 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2422 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2423 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2424 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2425 | else |
---|
| 2426 | vers=vers+1; |
---|
[137] | 2427 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2428 | end |
---|
| 2429 | subdir_civ2=subdir_civ1; |
---|
| 2430 | break |
---|
[2] | 2431 | end |
---|
[112] | 2432 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2433 | end |
---|
| 2434 | if detect% if a netcdf file already exists |
---|
| 2435 | break |
---|
| 2436 | end |
---|
| 2437 | end |
---|
[289] | 2438 | %create the new txt_SubdirCiv1 |
---|
[263] | 2439 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2440 | % cd(Path_ima); |
---|
| 2441 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
| 2442 | % cd(currentdir); |
---|
[252] | 2443 | if ~strcmp(msg1,'') |
---|
[128] | 2444 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[263] | 2445 | % cd(currentdir) |
---|
[122] | 2446 | filecell={}; |
---|
| 2447 | return |
---|
[128] | 2448 | else |
---|
[266] | 2449 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2450 | if ~strcmp(msg2,'') |
---|
| 2451 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[263] | 2452 | % cd(currentdir) |
---|
[128] | 2453 | filecell={}; |
---|
| 2454 | return |
---|
| 2455 | end |
---|
[112] | 2456 | end |
---|
| 2457 | end |
---|
| 2458 | end |
---|
| 2459 | end |
---|
[127] | 2460 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2461 | % get image names |
---|
| 2462 | for ifile=1:nbfield |
---|
[112] | 2463 | for j=1:nbslice |
---|
[2] | 2464 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2465 | idetect(j)=exist(filename,'file')==2; |
---|
| 2466 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2467 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2468 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2469 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2470 | end |
---|
| 2471 | [idetectmin,indexj]=min(idetect); |
---|
| 2472 | if idetectmin==0, |
---|
| 2473 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2474 | filecell={}; |
---|
[266] | 2475 | % cd(currentdir) |
---|
[112] | 2476 | return |
---|
| 2477 | end |
---|
| 2478 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2479 | if idetectmin==0, |
---|
| 2480 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2481 | filecell={}; |
---|
[266] | 2482 | %cd(currentdir) |
---|
[112] | 2483 | return |
---|
| 2484 | end |
---|
| 2485 | end |
---|
| 2486 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2487 | for ifile=1:nbfield |
---|
| 2488 | for j=1:nbslice |
---|
| 2489 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2490 | idetect(j)=exist(filename,'file')==2; |
---|
| 2491 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2492 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2493 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2494 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2495 | end |
---|
[2] | 2496 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2497 | if idetectmin==0, |
---|
| 2498 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2499 | filecell={}; |
---|
[266] | 2500 | % cd(currentdir) |
---|
[2] | 2501 | return |
---|
[112] | 2502 | end |
---|
[2] | 2503 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2504 | if idetectmin==0, |
---|
| 2505 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2506 | filecell={}; |
---|
[266] | 2507 | % cd(currentdir) |
---|
[2] | 2508 | return |
---|
[112] | 2509 | end |
---|
| 2510 | end |
---|
[2] | 2511 | end |
---|
[112] | 2512 | |
---|
[282] | 2513 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
| 2514 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
[2] | 2515 | for ifile=1:nbfield |
---|
| 2516 | for j=1:nbslice |
---|
| 2517 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2518 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2519 | detect=exist(filename,'file')==2; |
---|
[122] | 2520 | if detect==0 |
---|
| 2521 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2522 | filecell={}; |
---|
[266] | 2523 | % cd(currentdir) |
---|
[122] | 2524 | return |
---|
| 2525 | end |
---|
[2] | 2526 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2527 | end |
---|
| 2528 | end |
---|
| 2529 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2530 | for ifile=1:nbfield |
---|
| 2531 | for j=1:nbslice |
---|
| 2532 | 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);% |
---|
| 2533 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2534 | if ~exist(filename,'file') |
---|
| 2535 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2536 | set(handles.RUN, 'Enable','On') |
---|
| 2537 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2538 | filecell={}; |
---|
[266] | 2539 | %cd(currentdir) |
---|
[112] | 2540 | return |
---|
[2] | 2541 | end |
---|
| 2542 | end |
---|
[112] | 2543 | end |
---|
[2] | 2544 | end |
---|
| 2545 | end |
---|
| 2546 | |
---|
[282] | 2547 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
[2] | 2548 | testdiff=0; |
---|
[282] | 2549 | if (checkbox(4)==1)&&... |
---|
| 2550 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2551 | testdiff=1; |
---|
[112] | 2552 | detect=1; |
---|
[127] | 2553 | vers=0; |
---|
| 2554 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2555 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2556 | for ifile=1:nbfield |
---|
| 2557 | for j=1:nbslice |
---|
[127] | 2558 | 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] | 2559 | detect=exist(filename,'file')==2; |
---|
| 2560 | if detect% if a netcdf file already exists |
---|
[127] | 2561 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2562 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2563 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2564 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2565 | else |
---|
| 2566 | vers=vers+1; |
---|
| 2567 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2568 | end |
---|
[112] | 2569 | break |
---|
| 2570 | end |
---|
| 2571 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2572 | end |
---|
| 2573 | if detect% if a netcdf file already exists |
---|
| 2574 | break |
---|
| 2575 | end |
---|
| 2576 | end |
---|
[128] | 2577 | %create the new subdir_civ2_new |
---|
| 2578 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2579 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[266] | 2580 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2581 | if ~isequal(m2,'') |
---|
[266] | 2582 | msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2]) |
---|
[122] | 2583 | filecell={}; |
---|
[266] | 2584 | % cd(currentdir) |
---|
[122] | 2585 | return |
---|
[112] | 2586 | end |
---|
| 2587 | end |
---|
| 2588 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2589 | for ifile=1:nbfield |
---|
| 2590 | for j=1:nbslice |
---|
| 2591 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2592 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2593 | detect=exist(filename,'file')==2; |
---|
[2] | 2594 | if detect% if a netcdf file already exists |
---|
[127] | 2595 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2596 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2597 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2598 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2599 | else |
---|
| 2600 | vers=vers+1; |
---|
| 2601 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2602 | end |
---|
[112] | 2603 | break |
---|
[2] | 2604 | end |
---|
[112] | 2605 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2606 | end |
---|
| 2607 | if detect% if a netcdf file already exists |
---|
| 2608 | break |
---|
| 2609 | end |
---|
| 2610 | end |
---|
[122] | 2611 | subdir_civ2=subdir_civ2_new; |
---|
[289] | 2612 | %create the new txt_SubdirCiv1 |
---|
[127] | 2613 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2614 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[266] | 2615 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2616 | if ~isequal(m2,'') |
---|
[266] | 2617 | msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation |
---|
| 2618 | % cd(currentdir) |
---|
[122] | 2619 | filecell={}; |
---|
| 2620 | return |
---|
[112] | 2621 | end |
---|
| 2622 | end |
---|
| 2623 | end |
---|
| 2624 | end |
---|
[127] | 2625 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2626 | end |
---|
[266] | 2627 | %cd(currentdir);%come back to the current working directory |
---|
[2] | 2628 | |
---|
[282] | 2629 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2630 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
| 2631 | %check source netcdf file of checkciv1 estimates |
---|
| 2632 | if checkbox(1)==0; %no civ1 performed |
---|
[2] | 2633 | for ifile=1:nbfield |
---|
| 2634 | for j=1:nbslice |
---|
| 2635 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2636 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2637 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2638 | if ~exist(filename,'file') |
---|
| 2639 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2640 | filecell={}; |
---|
[2] | 2641 | return |
---|
| 2642 | end |
---|
| 2643 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
[282] | 2644 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2645 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2646 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2647 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2648 | filecell=[]; |
---|
[2] | 2649 | return |
---|
[248] | 2650 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2651 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2652 | filecell=[]; |
---|
| 2653 | return |
---|
[112] | 2654 | end |
---|
[282] | 2655 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
[275] | 2656 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
[248] | 2657 | if ~isempty(Data.CivStage) |
---|
| 2658 | if Data.CivStage<3 %test for civ files |
---|
| 2659 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2660 | filecell=[]; |
---|
| 2661 | return |
---|
| 2662 | end |
---|
| 2663 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2664 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2665 | filecell=[]; |
---|
[2] | 2666 | return |
---|
| 2667 | end |
---|
[112] | 2668 | end |
---|
[2] | 2669 | end |
---|
| 2670 | end |
---|
| 2671 | end |
---|
| 2672 | if strcmp(compare,'stereo PIV') |
---|
| 2673 | for ifile=1:nbfield |
---|
| 2674 | for j=1:nbslice |
---|
| 2675 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2676 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2677 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2678 | if ~exist(filename,'file') |
---|
| 2679 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2680 | set(handles.RUN, 'Enable','On') |
---|
| 2681 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2682 | return |
---|
| 2683 | end |
---|
| 2684 | end |
---|
| 2685 | end |
---|
| 2686 | end |
---|
| 2687 | end |
---|
[112] | 2688 | |
---|
| 2689 | detect=1; |
---|
[282] | 2690 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
[112] | 2691 | for ifile=1:nbfield |
---|
| 2692 | for j=1:nbslice |
---|
| 2693 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2694 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2695 | detect=exist(filename,'file')==2; |
---|
| 2696 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2697 | end |
---|
[112] | 2698 | end |
---|
[282] | 2699 | %get first image names for checkciv2 |
---|
| 2700 | if checkbox(1)==1 && isequal(num1_civ1,num1_civ2) && isequal(num_a_civ1,num_a_civ2) |
---|
[2] | 2701 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
[282] | 2702 | elseif checkbox(4)==1 |
---|
[2] | 2703 | for ifile=1:nbfield |
---|
| 2704 | for j=1:nbslice |
---|
| 2705 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2706 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2707 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2708 | end |
---|
[112] | 2709 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2710 | if idetectmin==0, |
---|
[112] | 2711 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2712 | filecell=[]; |
---|
| 2713 | return |
---|
[2] | 2714 | end |
---|
| 2715 | end |
---|
| 2716 | end |
---|
| 2717 | |
---|
[282] | 2718 | %get second image names for checkciv2 |
---|
| 2719 | if checkbox(1)==1 && isequal(num2_civ1,num2_civ2) && isequal(num_b_civ1,num_b_civ2) |
---|
[2] | 2720 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
[282] | 2721 | elseif checkbox(4)==1 |
---|
[2] | 2722 | for ifile=1:nbfield |
---|
| 2723 | for j=1:nbslice |
---|
| 2724 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2725 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2726 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2727 | end |
---|
[112] | 2728 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2729 | if idetectmin==0, |
---|
[112] | 2730 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2731 | filecell=[]; |
---|
| 2732 | return |
---|
[2] | 2733 | end |
---|
| 2734 | end |
---|
| 2735 | end |
---|
| 2736 | end |
---|
[282] | 2737 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
[2] | 2738 | if ~testdiff |
---|
| 2739 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2740 | else % check the civ2 files |
---|
[2] | 2741 | for ifile=1:nbfield |
---|
| 2742 | for j=1:nbslice |
---|
| 2743 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2744 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2745 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2746 | if ~exist(filename,'file') |
---|
| 2747 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2748 | filecell=[]; |
---|
[2] | 2749 | return |
---|
| 2750 | else |
---|
[248] | 2751 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2752 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2753 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2754 | filecell=[]; |
---|
| 2755 | return |
---|
| 2756 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2757 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2758 | filecell=[]; |
---|
[2] | 2759 | return |
---|
| 2760 | end |
---|
| 2761 | end |
---|
| 2762 | end |
---|
| 2763 | end |
---|
| 2764 | end |
---|
| 2765 | end |
---|
| 2766 | |
---|
| 2767 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2768 | if strcmp(compare,'stereo PIV') |
---|
[282] | 2769 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2770 | for ifile=1:nbfield |
---|
| 2771 | for j=1:nbslice |
---|
| 2772 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2773 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2774 | filecell.st(ifile,j)={filename}; |
---|
| 2775 | end |
---|
| 2776 | end |
---|
| 2777 | end |
---|
[282] | 2778 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
[2] | 2779 | for ifile=1:nbfield |
---|
| 2780 | for j=1:nbslice |
---|
| 2781 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2782 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2783 | filecell.st(ifile,j)={filename}; |
---|
| 2784 | end |
---|
| 2785 | end |
---|
[112] | 2786 | end |
---|
[2] | 2787 | end |
---|
[289] | 2788 | set(handles.txt_SubdirCiv1,'String',subdir_civ1);%update the edit box |
---|
| 2789 | set(handles.txt_SubdirCiv2,'String',subdir_civ2);%update the edit box |
---|
[2] | 2790 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 2791 | set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat |
---|
[2] | 2792 | |
---|
| 2793 | |
---|
| 2794 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2795 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2796 | nom_type_imanew1='_i'; |
---|
[2] | 2797 | else |
---|
| 2798 | nom_type_imanew1=nom_type_ima1; |
---|
| 2799 | end |
---|
[45] | 2800 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2801 | nom_type_imanew2='_i'; |
---|
[2] | 2802 | else |
---|
| 2803 | nom_type_imanew2=nom_type_ima2; |
---|
| 2804 | end |
---|
| 2805 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2806 | %%type of image file |
---|
| 2807 | type_ima1='none';%default |
---|
| 2808 | movieobject1=[];%default |
---|
[133] | 2809 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2810 | hhh=which('mmreader'); |
---|
| 2811 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2812 | type_ima1='movie'; |
---|
| 2813 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2814 | else |
---|
| 2815 | type_ima1='avi'; |
---|
| 2816 | end |
---|
[133] | 2817 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2818 | form=imformats(ext_ima(2:end)); |
---|
| 2819 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2820 | if isequal(nom_type_ima1,'*'); |
---|
| 2821 | type_ima1='multimage';%image series in a single image file |
---|
| 2822 | else |
---|
| 2823 | type_ima1='image'; |
---|
| 2824 | end |
---|
| 2825 | end |
---|
[45] | 2826 | end |
---|
| 2827 | type_ima2='none';%default |
---|
| 2828 | movieobject2=[]; |
---|
[133] | 2829 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2830 | hhh=which('mmreader'); |
---|
| 2831 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2832 | type_ima2='movie'; |
---|
| 2833 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2834 | else |
---|
| 2835 | type_ima2='avi'; |
---|
| 2836 | end |
---|
[133] | 2837 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2838 | form=imformats(ext_ima(2:end)); |
---|
| 2839 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2840 | if isequal(nom_type_ima1,'*'); |
---|
| 2841 | type_ima2='multimage';%image series in a single image file |
---|
| 2842 | else |
---|
| 2843 | type_ima2='image'; |
---|
| 2844 | end |
---|
| 2845 | end |
---|
[45] | 2846 | end |
---|
[71] | 2847 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2848 | % % if numel(npxy)<2 |
---|
| 2849 | % |
---|
| 2850 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2851 | % A=imread(filename); |
---|
| 2852 | % npxy=size(A); |
---|
| 2853 | % % end |
---|
| 2854 | % npy=npxy(1); |
---|
| 2855 | % npx=npxy(2); |
---|
[282] | 2856 | if checkbox(1) %if civ1 is performed |
---|
[224] | 2857 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2858 | for ifile=1:nbfield |
---|
[2] | 2859 | waitbar(ifile/nbfield); |
---|
| 2860 | for j=1:nbslice |
---|
[112] | 2861 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2862 | if ~exist(filename,'file') |
---|
| 2863 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2864 | imwrite(A,filename,'BitDepth',16); |
---|
| 2865 | end |
---|
| 2866 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2867 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2868 | if ~exist(filename,'file') |
---|
| 2869 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2870 | imwrite(A,filename,'BitDepth',16); |
---|
| 2871 | end |
---|
| 2872 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 2873 | end |
---|
| 2874 | end |
---|
| 2875 | close(h) |
---|
| 2876 | end |
---|
[282] | 2877 | if checkbox(4) %if civ2 is performed |
---|
[229] | 2878 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 2879 | for ifile=1:nbfield |
---|
| 2880 | waitbar(ifile/nbfield); |
---|
| 2881 | for j=1:nbslice |
---|
[112] | 2882 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 2883 | if ~exist(filename,'file') |
---|
| 2884 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 2885 | imwrite(A,filename,'BitDepth',16); |
---|
| 2886 | end |
---|
| 2887 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2888 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 2889 | if ~exist(filename,'file') |
---|
| 2890 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 2891 | imwrite(A,filename,'BitDepth',16); |
---|
| 2892 | end |
---|
| 2893 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 2894 | end |
---|
| 2895 | end |
---|
| 2896 | close(h); |
---|
| 2897 | end |
---|
| 2898 | end |
---|
| 2899 | |
---|
[12] | 2900 | %------------------------------------------------------------------------ |
---|
[227] | 2901 | % --- determine the list of index pairs of processing file |
---|
| 2902 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2903 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2904 | %------------------------------------------------------------------------ |
---|
| 2905 | |
---|
[282] | 2906 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
| 2907 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
[227] | 2908 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2909 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2910 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2911 | return |
---|
| 2912 | end |
---|
[282] | 2913 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
| 2914 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
[227] | 2915 | if index_civ2>length(list_civ2) |
---|
| 2916 | list_civ2=list_civ1; |
---|
| 2917 | index_civ2=index_civ1; |
---|
| 2918 | end |
---|
| 2919 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2920 | |
---|
| 2921 | if isequal (mode,'series(Di)') |
---|
| 2922 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2923 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2924 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2925 | num_a_civ1=ref_j; |
---|
| 2926 | num_b_civ1=ref_j; |
---|
[229] | 2927 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 2928 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2929 | num_a_civ2=ref_j; |
---|
| 2930 | num_b_civ2=ref_j; |
---|
| 2931 | |
---|
| 2932 | % adjust the first and last field number |
---|
| 2933 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2934 | if isnan(lastfield) |
---|
| 2935 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2936 | else |
---|
| 2937 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2938 | end |
---|
| 2939 | if length(indsel)>=1 |
---|
| 2940 | firstind=indsel(1); |
---|
| 2941 | lastind=indsel(end); |
---|
| 2942 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2943 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2944 | ref_i=ref_i(indsel); |
---|
| 2945 | num1_civ1=num1_civ1(indsel); |
---|
| 2946 | num1_civ2=num1_civ2(indsel); |
---|
| 2947 | num2_civ1=num2_civ1(indsel); |
---|
| 2948 | num2_civ2=num2_civ2(indsel); |
---|
| 2949 | end |
---|
| 2950 | elseif isequal (mode,'series(Dj)') |
---|
| 2951 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 2952 | num1_civ1=ref_i;% set of first image numbers |
---|
| 2953 | num2_civ1=ref_i; |
---|
| 2954 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 2955 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 2956 | num1_civ2=ref_i; |
---|
| 2957 | num2_civ2=ref_i; |
---|
| 2958 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 2959 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 2960 | % adjust the first and last field number |
---|
| 2961 | if isnan(lastfield_j) |
---|
| 2962 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 2963 | else |
---|
| 2964 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 2965 | end |
---|
| 2966 | if length(indsel)>=1 |
---|
| 2967 | firstind=indsel(1); |
---|
| 2968 | lastind=indsel(end); |
---|
| 2969 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 2970 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 2971 | ref_j=ref_j(indsel); |
---|
| 2972 | num_a_civ1=num_a_civ1(indsel); |
---|
| 2973 | num_b_civ1=num_b_civ1(indsel); |
---|
| 2974 | num_a_civ2=num_a_civ2(indsel); |
---|
| 2975 | num_b_civ2=num_b_civ2(indsel); |
---|
| 2976 | end |
---|
| 2977 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[282] | 2978 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[227] | 2979 | num1_civ1=ref_i; |
---|
| 2980 | num2_civ1=ref_i; |
---|
| 2981 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 2982 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 2983 | num1_civ2=ref_i; |
---|
| 2984 | num2_civ2=ref_i; |
---|
| 2985 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 2986 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 2987 | elseif isequal(mode,'displacement') |
---|
| 2988 | num1_civ1=ref_i; |
---|
| 2989 | num2_civ1=ref_i; |
---|
| 2990 | num_a_civ1=ref_j; |
---|
| 2991 | num_b_civ1=ref_j; |
---|
| 2992 | num1_civ2=ref_i; |
---|
| 2993 | num2_civ2=ref_i; |
---|
| 2994 | num_a_civ2=ref_j; |
---|
| 2995 | num_b_civ2=ref_j; |
---|
| 2996 | end |
---|
| 2997 | |
---|
| 2998 | |
---|
| 2999 | %------------------------------------------------------------------------ |
---|
[12] | 3000 | % --- STEREO Interp |
---|
[67] | 3001 | 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] | 3002 | %------------------------------------------------------------------------ |
---|
[224] | 3003 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3004 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3005 | ' -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 |
---|
| 3006 | |
---|
[12] | 3007 | %------------------------------------------------------------------------ |
---|
[282] | 3008 | % --- Executes on button press in CheckCiv1. |
---|
| 3009 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3010 | %------------------------------------------------------------------------ |
---|
[289] | 3011 | update_CivOptions(handles) |
---|
[2] | 3012 | |
---|
[12] | 3013 | %------------------------------------------------------------------------ |
---|
[282] | 3014 | % --- Executes on button press in CheckFix1. |
---|
| 3015 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3016 | %------------------------------------------------------------------------ |
---|
[289] | 3017 | update_CivOptions(handles) |
---|
[2] | 3018 | |
---|
[12] | 3019 | %------------------------------------------------------------------------ |
---|
[282] | 3020 | % --- Executes on button press in CheckPatch1. |
---|
| 3021 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
[12] | 3022 | %------------------------------------------------------------------------ |
---|
[289] | 3023 | update_CivOptions(handles) |
---|
[2] | 3024 | |
---|
[12] | 3025 | %------------------------------------------------------------------------ |
---|
[282] | 3026 | % --- Executes on button press in CheckCiv2. |
---|
| 3027 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3028 | %------------------------------------------------------------------------ |
---|
[289] | 3029 | update_CivOptions(handles) |
---|
[2] | 3030 | |
---|
[12] | 3031 | %------------------------------------------------------------------------ |
---|
[282] | 3032 | % --- Executes on button press in CheckFix2. |
---|
| 3033 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3034 | %------------------------------------------------------------------------ |
---|
[289] | 3035 | update_CivOptions(handles) |
---|
[2] | 3036 | |
---|
[12] | 3037 | %------------------------------------------------------------------------ |
---|
[282] | 3038 | % --- Executes on button press in CheckPatch2. |
---|
| 3039 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3040 | %------------------------------------------------------------------------ |
---|
[289] | 3041 | update_CivOptions(handles) |
---|
| 3042 | |
---|
| 3043 | %------------------------------------------------------------------------ |
---|
| 3044 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
| 3045 | function update_CivOptions(handles) |
---|
| 3046 | %------------------------------------------------------------------------ |
---|
| 3047 | checkbox=zeros(1,6); |
---|
| 3048 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 3049 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 3050 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 3051 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 3052 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
[300] | 3053 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
| 3054 | ind_selected=find(checkbox,1); |
---|
[289] | 3055 | if ~isempty(ind_selected) |
---|
| 3056 | RootName=get(handles.RootName,'String'); |
---|
| 3057 | if isempty(RootName) |
---|
| 3058 | msgbox_uvmat('ERROR','No input file') |
---|
| 3059 | return |
---|
| 3060 | end |
---|
[2] | 3061 | end |
---|
[289] | 3062 | set(handles.PairIndices,'Visible','on') |
---|
| 3063 | set(handles.txt_SubdirCiv1,'Visible','on') |
---|
| 3064 | set(handles.ListSubdirCiv1,'Visible','on') |
---|
| 3065 | find_netcpair_civ1(handles) % select the available netcdf files |
---|
| 3066 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
| 3067 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 3068 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
| 3069 | set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 3070 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
| 3071 | set(handles.ListPairCiv2,'Visible','on') |
---|
| 3072 | find_netcpair_civ2(handles) % select the available netcdf files |
---|
| 3073 | else |
---|
| 3074 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
| 3075 | set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 3076 | set(handles.ListSubdirCiv2,'Visible','off') |
---|
| 3077 | set(handles.ListPairCiv2,'Visible','off') |
---|
| 3078 | end |
---|
| 3079 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 3080 | for ilist=1:length(options) |
---|
| 3081 | if checkbox(ilist) |
---|
| 3082 | set(handles.(options{ilist}),'Visible','on') |
---|
| 3083 | else |
---|
| 3084 | set(handles.(options{ilist}),'Visible','off') |
---|
| 3085 | end |
---|
| 3086 | end |
---|
[2] | 3087 | |
---|
[12] | 3088 | %------------------------------------------------------------------------ |
---|
| 3089 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3090 | %------------------------------------------------------------------------ |
---|
[137] | 3091 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3092 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3093 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3094 | |
---|
[12] | 3095 | %------------------------------------------------------------------------ |
---|
| 3096 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3097 | %------------------------------------------------------------------------ |
---|
| 3098 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3099 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3100 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3101 | |
---|
[12] | 3102 | %------------------------------------------------------------------------ |
---|
[287] | 3103 | % --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy |
---|
[273] | 3104 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3105 | %------------------------------------------------------------------------ |
---|
[2] | 3106 | %determine pair numbers |
---|
[273] | 3107 | if strcmp(get(handles.umin,'Visible'),'off') |
---|
| 3108 | set(handles.u_title,'Visible','on') |
---|
| 3109 | set(handles.v_title,'Visible','on') |
---|
| 3110 | set(handles.umin,'Visible','on') |
---|
| 3111 | set(handles.umax,'Visible','on') |
---|
| 3112 | set(handles.vmin,'Visible','on') |
---|
| 3113 | set(handles.vmax,'Visible','on') |
---|
| 3114 | set(handles.CoordUnit,'Visible','on') |
---|
| 3115 | set(handles.TimeUnit,'Visible','on') |
---|
| 3116 | set(handles.slash_title,'Visible','on') |
---|
| 3117 | set(handles.min_title,'Visible','on') |
---|
| 3118 | set(handles.max_title,'Visible','on') |
---|
| 3119 | set(handles.unit_title,'Visible','on') |
---|
| 3120 | else |
---|
| 3121 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3122 | end |
---|
| 3123 | |
---|
[12] | 3124 | %------------------------------------------------------------------------ |
---|
[287] | 3125 | % --- determine the search range num_Searchx,num_Searchy and shift |
---|
[273] | 3126 | function get_search_range(hObject, eventdata, handles) |
---|
| 3127 | umin=str2double(get(handles.umin,'String')); |
---|
| 3128 | umax=str2double(get(handles.umax,'String')); |
---|
| 3129 | vmin=str2double(get(handles.umin,'String')); |
---|
| 3130 | vmax=str2double(get(handles.vmax,'String')); |
---|
| 3131 | %switch min_title and max_title in case of error |
---|
| 3132 | if umax<=umin |
---|
| 3133 | umin_old=umin; |
---|
| 3134 | umin=umax; |
---|
| 3135 | umax=umin_old; |
---|
| 3136 | set(handles.umin,'String', num2str(umin)) |
---|
| 3137 | set(handles.umax,'String', num2str(umax)) |
---|
| 3138 | end |
---|
| 3139 | if vmax<=vmin |
---|
| 3140 | vmin_old=vmin; |
---|
| 3141 | vmin=vmax; |
---|
| 3142 | vmax=vmin_old; |
---|
| 3143 | set(handles.vmin,'String', num2str(vmin)) |
---|
| 3144 | set(handles.vmax,'String', num2str(vmax)) |
---|
| 3145 | end |
---|
| 3146 | if ~(isnan(umin)||isnan(umax)||isnan(vmin)||isnan(vmax)) |
---|
[282] | 3147 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 3148 | index=get(handles.ListPairCiv1,'Value'); |
---|
| 3149 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[273] | 3150 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
| 3151 | pxcm_xy=get(handles.SearchRange,'UserData'); |
---|
| 3152 | pxcmx=pxcm_xy(1); |
---|
| 3153 | pxcmy=pxcm_xy(2); |
---|
[282] | 3154 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 3155 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[273] | 3156 | mode=mode_list{mode_value}; |
---|
| 3157 | if isequal (mode, 'series(Di)' ) |
---|
| 3158 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3159 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3160 | num2=ref_i+ceil(index/2); |
---|
| 3161 | num_a=1; |
---|
| 3162 | num_b=1; |
---|
| 3163 | elseif isequal (mode, 'series(Dj)') |
---|
| 3164 | num1=1; |
---|
| 3165 | num2=1; |
---|
| 3166 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3167 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3168 | num_b=ref_j+ceil(index/2); |
---|
| 3169 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3170 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3171 | num1=ref_i; |
---|
| 3172 | num2=ref_i; |
---|
| 3173 | num_a=displ_num(1,index); |
---|
| 3174 | num_b=displ_num(2,index); |
---|
| 3175 | end |
---|
| 3176 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[282] | 3177 | ibx=str2double(get(handles.num_Bx,'String')); |
---|
| 3178 | iby=str2double(get(handles.num_By,'String')); |
---|
[273] | 3179 | umin=dt*pxcmx*umin; |
---|
| 3180 | umax=dt*pxcmx*umax; |
---|
| 3181 | vmin=dt*pxcmy*vmin; |
---|
| 3182 | vmax=dt*pxcmy*vmax; |
---|
| 3183 | shiftx=round((umin+umax)/2); |
---|
| 3184 | shifty=round((vmin+vmax)/2); |
---|
| 3185 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3186 | isx=2*ceil(isx/2)+1; |
---|
| 3187 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3188 | isy=2*ceil(isy/2)+1; |
---|
[282] | 3189 | set(handles.num_Shiftx,'String',num2str(shiftx)); |
---|
| 3190 | set(handles.num_Shifty,'String',num2str(shifty)); |
---|
[287] | 3191 | set(handles.num_Searchx,'String',num2str(isx)); |
---|
| 3192 | set(handles.num_Searchy,'String',num2str(isy)); |
---|
[273] | 3193 | end |
---|
| 3194 | |
---|
| 3195 | %------------------------------------------------------------------------ |
---|
[282] | 3196 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[289] | 3197 | function txt_SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3198 | %------------------------------------------------------------------------ |
---|
[289] | 3199 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
| 3200 | set(handles.txt_SubdirCiv2,'String',subdir);% set civ2 directory the same as civ1 by default |
---|
[282] | 3201 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
[273] | 3202 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3203 | if isempty(ichoice) |
---|
| 3204 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3205 | else |
---|
| 3206 | ilist=ichoice; |
---|
| 3207 | end |
---|
[282] | 3208 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 3209 | if get(handles.CheckCiv1,'Value')==0 |
---|
[2] | 3210 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3211 | end |
---|
| 3212 | |
---|
[12] | 3213 | %------------------------------------------------------------------------ |
---|
[282] | 3214 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[289] | 3215 | function txt_SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3216 | %------------------------------------------------------------------------ |
---|
[289] | 3217 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
| 3218 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
[273] | 3219 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3220 | if isempty(ichoice) |
---|
| 3221 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3222 | else |
---|
| 3223 | ilist=ichoice; |
---|
| 3224 | end |
---|
[289] | 3225 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
[2] | 3226 | %update the list of available pairs from netcdf files in the new directory |
---|
[282] | 3227 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[2] | 3228 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3229 | end |
---|
| 3230 | |
---|
[276] | 3231 | % %------------------------------------------------------------------------ |
---|
[282] | 3232 | % % --- Executes on button press in CheckMask: select box for mask option |
---|
[276] | 3233 | % function check_Mask_Callback(hObject, eventdata, handles) |
---|
| 3234 | % %------------------------------------------------------------------------ |
---|
[282] | 3235 | % maskval=get(handles.CheckMask,'Value'); |
---|
[276] | 3236 | % if isequal(maskval,0) |
---|
| 3237 | % set(handles.txt_MaskName,'Visible','off') |
---|
| 3238 | % % set(handles.txt_MaskName,'String','') |
---|
| 3239 | % else |
---|
| 3240 | % mask_displ='no mask'; %default |
---|
| 3241 | % filebase=get(handles.RootName,'String'); |
---|
| 3242 | % [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3243 | % if isequal(flag_mask,1) |
---|
| 3244 | % mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[282] | 3245 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[276] | 3246 | % common_path=fileparts(filebase); |
---|
| 3247 | % filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3248 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3249 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3250 | % mask_displ='no mask'; |
---|
| 3251 | % end |
---|
| 3252 | % end |
---|
| 3253 | % if isequal(mask_displ,'no mask') |
---|
| 3254 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3255 | % {'*.png', ' (*.png)'; |
---|
| 3256 | % '*.png', '.png files '; ... |
---|
| 3257 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3258 | % 'Pick a mask file *.png',filebase); |
---|
| 3259 | % mask_displ=fullfile(PathName,FileName); |
---|
| 3260 | % if exist(mask_displ,'file') |
---|
| 3261 | % set(handles.txt_MaskName,'Visible','on') |
---|
| 3262 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
| 3263 | % % mask_displ='no mask'; |
---|
| 3264 | % end |
---|
| 3265 | % end |
---|
| 3266 | % if isequal(mask_displ,'no mask') |
---|
[282] | 3267 | % set(handles.CheckMask,'Value',0) |
---|
| 3268 | % set(handles.CheckMask,'Value',0) |
---|
| 3269 | % set(handles.CheckMask,'Value',0) |
---|
| 3270 | % set(handles.CheckMask,'Value',0) |
---|
[276] | 3271 | % else |
---|
[282] | 3272 | % set(handles.CheckMask,'Value',1) |
---|
| 3273 | % set(handles.CheckMask,'Value',1) |
---|
[276] | 3274 | % end |
---|
| 3275 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[282] | 3276 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3277 | % set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3278 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3279 | % end |
---|
[282] | 3280 | % set(handles.CheckMask,'Value',maskval)%update the checkciv2 mask with the same option as checkciv1 |
---|
[2] | 3281 | |
---|
[12] | 3282 | %------------------------------------------------------------------------ |
---|
[282] | 3283 | % --- Executes on button press in CheckMask. |
---|
[2] | 3284 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3285 | %------------------------------------------------------------------------ |
---|
[282] | 3286 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3287 | if isequal(maskval,0) |
---|
[282] | 3288 | set(handles.txt_MaskName,'String','') |
---|
[2] | 3289 | else |
---|
[112] | 3290 | mask_displ='no mask'; %default |
---|
| 3291 | filebase=get(handles.RootName,'String'); |
---|
| 3292 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3293 | if isequal(flag_mask,1) |
---|
| 3294 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3295 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3296 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3297 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3298 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3299 | mask_displ='no mask'; |
---|
| 3300 | end |
---|
[112] | 3301 | end |
---|
| 3302 | if isequal(mask_displ,'no mask') |
---|
| 3303 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3304 | {'*.png', ' (*.png)'; |
---|
[12] | 3305 | '*.png', '.png files '; ... |
---|
| 3306 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3307 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3308 | mask_displ=fullfile(PathName,FileName); |
---|
| 3309 | if ~exist(mask_displ,'file') |
---|
| 3310 | mask_displ='no mask'; |
---|
| 3311 | end |
---|
[12] | 3312 | end |
---|
[112] | 3313 | if isequal(mask_displ,'no mask') |
---|
[282] | 3314 | set(handles.CheckMask,'Value',0) |
---|
| 3315 | set(handles.CheckMask,'Value',0) |
---|
| 3316 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3317 | else |
---|
[282] | 3318 | %set(handles.CheckMask,'Value',1) |
---|
| 3319 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3320 | end |
---|
[282] | 3321 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3322 | set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3323 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[12] | 3324 | end |
---|
| 3325 | |
---|
| 3326 | %------------------------------------------------------------------------ |
---|
[282] | 3327 | % --- Executes on button press in CheckMask: select box for mask option |
---|
[2] | 3328 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3329 | %------------------------------------------------------------------------ |
---|
[282] | 3330 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3331 | if isequal(maskval,0) |
---|
[276] | 3332 | set(handles.txt_Mask,'String','') |
---|
[2] | 3333 | else |
---|
[112] | 3334 | mask_displ='no mask'; %default |
---|
| 3335 | filebase=get(handles.RootName,'String'); |
---|
| 3336 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3337 | if isequal(flag_mask,1) |
---|
| 3338 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3339 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3340 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3341 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3342 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3343 | mask_displ='no mask'; |
---|
| 3344 | end |
---|
[112] | 3345 | end |
---|
| 3346 | if isequal(mask_displ,'no mask') |
---|
| 3347 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3348 | {'*.png', ' (*.png)'; |
---|
[12] | 3349 | '*.png', '.png files '; ... |
---|
| 3350 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3351 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3352 | mask_displ=fullfile(PathName,FileName); |
---|
| 3353 | if ~exist(mask_displ,'file') |
---|
| 3354 | mask_displ='no mask'; |
---|
| 3355 | end |
---|
[12] | 3356 | end |
---|
[112] | 3357 | if isequal(mask_displ,'no mask') |
---|
[282] | 3358 | set(handles.CheckMask,'Value',0) |
---|
| 3359 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3360 | else |
---|
[282] | 3361 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3362 | end |
---|
[276] | 3363 | set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3364 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[12] | 3365 | end |
---|
| 3366 | |
---|
| 3367 | %------------------------------------------------------------------------ |
---|
[282] | 3368 | % --- Executes on button press in CheckMask. |
---|
[2] | 3369 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3370 | %------------------------------------------------------------------------ |
---|
[282] | 3371 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3372 | if isequal(maskval,0) |
---|
[287] | 3373 | set(handles.txt_MaskName,'String','') |
---|
[2] | 3374 | else |
---|
[12] | 3375 | mask_displ='no mask'; %default |
---|
[71] | 3376 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3377 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3378 | if isequal(flag_mask,1) |
---|
[112] | 3379 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3380 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3381 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3382 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3383 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3384 | mask_displ='no mask'; |
---|
| 3385 | end |
---|
[12] | 3386 | end |
---|
| 3387 | if isequal(mask_displ,'no mask') |
---|
| 3388 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3389 | {'*.png', ' (*.png)'; |
---|
| 3390 | '*.png', '.png files '; ... |
---|
| 3391 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3392 | 'Pick a mask file *.png',filebase); |
---|
| 3393 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3394 | if ~exist(mask_displ,'file') |
---|
[2] | 3395 | mask_displ='no mask'; |
---|
| 3396 | end |
---|
[12] | 3397 | end |
---|
| 3398 | if isequal(mask_displ,'no mask') |
---|
[282] | 3399 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3400 | end |
---|
[287] | 3401 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[2] | 3402 | end |
---|
| 3403 | |
---|
[12] | 3404 | %------------------------------------------------------------------------ |
---|
| 3405 | % --- function called to look for mask files |
---|
[2] | 3406 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3407 | %------------------------------------------------------------------------ |
---|
[112] | 3408 | %detect mask files, images with appropriate file base |
---|
[2] | 3409 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3410 | %flag_mask=1 indicates detection |
---|
| 3411 | |
---|
| 3412 | flag_mask=0;%default |
---|
| 3413 | nbslice=1; |
---|
| 3414 | |
---|
[289] | 3415 | % subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
[2] | 3416 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3417 | if ~isdir(Path) |
---|
| 3418 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3419 | return |
---|
| 3420 | end |
---|
[272] | 3421 | % currentdir=pwd; |
---|
| 3422 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3423 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3424 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3425 | if ~isempty(maskfiles) |
---|
[112] | 3426 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3427 | % else |
---|
[2] | 3428 | flag_mask=1; |
---|
| 3429 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3430 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3431 | Namedouble=double(Name); |
---|
| 3432 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3433 | ind_mask=findstr('mask',Name); |
---|
| 3434 | i=ind_mask-1; |
---|
[137] | 3435 | while val(i)==0 && i>0 |
---|
[112] | 3436 | i=i-1; |
---|
[2] | 3437 | end |
---|
[137] | 3438 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3439 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3440 | flag_mask=1; |
---|
[2] | 3441 | else |
---|
[112] | 3442 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3443 | return |
---|
| 3444 | nbslice=1; |
---|
[2] | 3445 | end |
---|
[112] | 3446 | end |
---|
[2] | 3447 | |
---|
[12] | 3448 | %------------------------------------------------------------------------ |
---|
| 3449 | % --- function called to look for grid files |
---|
[2] | 3450 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3451 | %------------------------------------------------------------------------ |
---|
[2] | 3452 | flag_mask=0;%default |
---|
| 3453 | nbslice=1; |
---|
| 3454 | [Path,Name]=fileparts(filebase); |
---|
| 3455 | currentdir=pwd; |
---|
| 3456 | cd(Path);%move in the dir of the root name filebase |
---|
| 3457 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3458 | cd(currentdir);%come back to the current working directory |
---|
| 3459 | if ~isempty(maskfiles) |
---|
| 3460 | flag_mask=1; |
---|
| 3461 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3462 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3463 | Namedouble=double(Name); |
---|
| 3464 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3465 | ind_mask=findstr('grid',Name); |
---|
| 3466 | i=ind_mask-1; |
---|
[137] | 3467 | while val(i)==0 && i>0 |
---|
[112] | 3468 | i=i-1; |
---|
[2] | 3469 | end |
---|
[137] | 3470 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3471 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3472 | flag_mask=1; |
---|
[2] | 3473 | else |
---|
[112] | 3474 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3475 | return |
---|
| 3476 | nbslice=1; |
---|
[2] | 3477 | end |
---|
[12] | 3478 | end |
---|
[2] | 3479 | |
---|
[12] | 3480 | %------------------------------------------------------------------------ |
---|
| 3481 | % --- transform numbers to letters |
---|
[122] | 3482 | function str=num2stra(num,nom_type) |
---|
[12] | 3483 | %------------------------------------------------------------------------ |
---|
[122] | 3484 | if isempty(nom_type) |
---|
| 3485 | str=''; |
---|
| 3486 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3487 | str=char(96+num); |
---|
[122] | 3488 | elseif strcmp(nom_type(end),'A') |
---|
| 3489 | str=char(96+num); |
---|
| 3490 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3491 | str=''; |
---|
| 3492 | else |
---|
| 3493 | str=num2str(num); |
---|
| 3494 | end |
---|
[12] | 3495 | |
---|
| 3496 | %------------------------------------------------------------------------ |
---|
[282] | 3497 | % --- Executes on button press in ListSubdirCiv1. |
---|
| 3498 | function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3499 | %------------------------------------------------------------------------ |
---|
[282] | 3500 | list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 3501 | val=get(handles.ListSubdirCiv1,'Value'); |
---|
[273] | 3502 | subdir=list_subdir_civ1{val}; |
---|
| 3503 | if strcmp(subdir,'new...') |
---|
| 3504 | subdir='CIV'; %default subdirectory |
---|
[2] | 3505 | end |
---|
[289] | 3506 | set(handles.txt_SubdirCiv1,'String',subdir); |
---|
[273] | 3507 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 3508 | % end |
---|
[2] | 3509 | |
---|
[12] | 3510 | %------------------------------------------------------------------------ |
---|
[289] | 3511 | % --- Executes on button press in ListSubdirCiv2. |
---|
| 3512 | function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3513 | %------------------------------------------------------------------------ |
---|
[289] | 3514 | list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 3515 | val=get(handles.ListSubdirCiv2,'Value'); |
---|
[273] | 3516 | subdir=list_subdir_civ2{val}; |
---|
| 3517 | if strcmp(subdir,'new...') |
---|
| 3518 | subdir='CIV'; %default subdirectory |
---|
[2] | 3519 | end |
---|
[289] | 3520 | set(handles.txt_SubdirCiv2,'String',subdir); |
---|
| 3521 | % set(handles.ListSubdirCiv2,'Value',1); |
---|
[2] | 3522 | |
---|
[273] | 3523 | |
---|
[12] | 3524 | %------------------------------------------------------------------------ |
---|
[282] | 3525 | % --- Executes on button press in CheckGrid. |
---|
| 3526 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
[12] | 3527 | %------------------------------------------------------------------------ |
---|
[276] | 3528 | value=get(hObject,'Value'); |
---|
| 3529 | hparent=get(hObject,'parent'); |
---|
| 3530 | hchildren=get(hparent,'children'); |
---|
| 3531 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
| 3532 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3533 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[2] | 3534 | testgrid=0; |
---|
[276] | 3535 | filegrid=''; |
---|
[2] | 3536 | if value |
---|
[112] | 3537 | filebase=get(handles.RootName,'String'); |
---|
[276] | 3538 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
[2] | 3539 | if isequal(flag_grid,1) |
---|
[112] | 3540 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3541 | testgrid=1; |
---|
[276] | 3542 | else % browse for a grid |
---|
| 3543 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 3544 | if exist(filegrid,'file') |
---|
| 3545 | filebase=filegrid; |
---|
| 3546 | end |
---|
[2] | 3547 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3548 | {'*.grid', ' (*.grid)'; |
---|
| 3549 | '*.grid', '.grid files '; ... |
---|
| 3550 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3551 | 'Pick a file',filebase); |
---|
[2] | 3552 | filegrid=fullfile(PathName,FileName); |
---|
[276] | 3553 | set(hObject,'UserData',filegrid);%store for future use |
---|
[2] | 3554 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3555 | testgrid=1; |
---|
| 3556 | end |
---|
[112] | 3557 | end |
---|
[2] | 3558 | end |
---|
| 3559 | if testgrid |
---|
[276] | 3560 | set(handle_dx,'Visible','off'); |
---|
| 3561 | set(handle_dy,'Visible','off'); |
---|
| 3562 | set(handle_txtbox,'Visible','on') |
---|
| 3563 | set(handle_txtbox,'String',filegrid) |
---|
[112] | 3564 | else |
---|
[276] | 3565 | set(hObject,'Value',0); |
---|
| 3566 | set(handle_dx,'Visible','on'); |
---|
| 3567 | set(handle_dy,'Visible','on'); |
---|
| 3568 | set(handle_txtbox,'Visible','off') |
---|
[2] | 3569 | end |
---|
| 3570 | |
---|
[282] | 3571 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
[276] | 3572 | PanelName=get(hparent,'tag'); |
---|
| 3573 | if strcmp(PanelName,'panel_Civ1') |
---|
[282] | 3574 | hchildren=get(handles.Civ2,'children'); |
---|
[276] | 3575 | handle_checkbox=findobj(hchildren,'tag','check_Grid'); |
---|
| 3576 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
| 3577 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3578 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
| 3579 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 3580 | if testgrid |
---|
| 3581 | set(handle_checkbox,'Value',1); |
---|
| 3582 | set(handle_dx,'Visible','off'); |
---|
| 3583 | set(handle_dy,'Visible','off'); |
---|
| 3584 | set(handle_txtbox,'Visible','on') |
---|
| 3585 | set(handle_txtbox,'String',filegrid) |
---|
| 3586 | else |
---|
| 3587 | set(handle_checkbox,'Value',0); |
---|
[282] | 3588 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3589 | set(handle_dx,'Visible','on'); |
---|
| 3590 | set(handle_dy,'Visible','on'); |
---|
| 3591 | set(handle_txtbox,'Visible','off') |
---|
| 3592 | end |
---|
| 3593 | end |
---|
[12] | 3594 | %------------------------------------------------------------------------ |
---|
[282] | 3595 | % --- Executes on button press in CheckMask. |
---|
| 3596 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
[276] | 3597 | %------------------------------------------------------------------------ |
---|
| 3598 | value=get(hObject,'Value'); |
---|
| 3599 | testmask=0; |
---|
| 3600 | if value |
---|
| 3601 | filebase=get(handles.RootName,'String'); |
---|
| 3602 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
| 3603 | if isequal(flag_mask,1) |
---|
| 3604 | filemask=[num2str(nbslice) 'mask']; |
---|
| 3605 | testmask=1; |
---|
| 3606 | else % browse for a mask |
---|
[282] | 3607 | filemask=get(handles.CheckMask,'UserData');%look for previous mask name stored as UserData |
---|
[276] | 3608 | if exist(filemask,'file') |
---|
| 3609 | filebase=filemask; |
---|
| 3610 | end |
---|
| 3611 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3612 | {'*.png', ' (*.png)'; |
---|
| 3613 | '*.png', '.png files '; ... |
---|
| 3614 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3615 | 'Pick a mask file *.png',filebase); |
---|
| 3616 | filemask=fullfile(PathName,FileName); |
---|
[282] | 3617 | set(handles.CheckMask,'UserData',filemask);%store for future use |
---|
[276] | 3618 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
| 3619 | testmask=1; |
---|
| 3620 | end |
---|
| 3621 | end |
---|
| 3622 | end |
---|
| 3623 | if testmask |
---|
| 3624 | set(handles.num_Dx,'Visible','off'); |
---|
| 3625 | set(handles.num_Dy,'Visible','off'); |
---|
| 3626 | set(handles.num_Dx,'Visible','off'); |
---|
| 3627 | set(handles.num_Dy,'Visible','off'); |
---|
| 3628 | set(handles.txt_MaskName,'Visible','on') |
---|
| 3629 | set(handles.txt_MaskName,'String',filemask) |
---|
| 3630 | else |
---|
[282] | 3631 | set(handles.CheckMask,'Value',0); |
---|
| 3632 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3633 | set(handles.num_Dx,'Visible','on'); |
---|
| 3634 | set(handles.num_Dy,'Visible','on'); |
---|
| 3635 | set(handles.num_Dx,'Visible','on'); |
---|
| 3636 | set(handles.num_Dy,'Visible','on'); |
---|
| 3637 | set(handles.txt_MaskName,'Visible','off') |
---|
| 3638 | end |
---|
| 3639 | |
---|
| 3640 | %------------------------------------------------------------------------ |
---|
[282] | 3641 | % --- Executes on button press in CheckGrid. |
---|
[2] | 3642 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3643 | %------------------------------------------------------------------------ |
---|
[282] | 3644 | value=get(handles.CheckGrid,'Value'); |
---|
[2] | 3645 | if value |
---|
[112] | 3646 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3647 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3648 | if isequal(flag_grid,1) |
---|
| 3649 | mask_displ=[num2str(nbslice) 'grid']; |
---|
[276] | 3650 | set(handles.txt_GridName,'String',mask_displ) |
---|
| 3651 | set(handles.num_Dx,'Visible','off'); |
---|
| 3652 | set(handles.num_Dy,'Visible','off'); |
---|
[112] | 3653 | else |
---|
[2] | 3654 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3655 | {'*.grid', ' (*.grid)'; |
---|
| 3656 | '*.grid', '.grid files '; ... |
---|
| 3657 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3658 | 'Pick a file',filebase); |
---|
[2] | 3659 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3660 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[282] | 3661 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3662 | set(handles.txt_GridName,'string',''); |
---|
| 3663 | set(handles.num_Dx,'Visible','on'); |
---|
| 3664 | set(handles.num_Dy,'Visible','on'); |
---|
| 3665 | set(handles.txt_GridName,'string',''); |
---|
[2] | 3666 | else |
---|
[276] | 3667 | set(handles.txt_GridName,'string',filegrid); |
---|
| 3668 | set(handles.num_Dx,'Visible','off'); |
---|
| 3669 | set(handles.num_Dy,'Visible','off'); |
---|
| 3670 | set(handles.txt_GridName,'string',filegrid); |
---|
[2] | 3671 | end |
---|
| 3672 | end |
---|
| 3673 | else |
---|
[276] | 3674 | set(handles.txt_GridName,'string',''); |
---|
| 3675 | set(handles.num_Dx,'Visible','on'); |
---|
| 3676 | set(handles.num_Dy,'Visible','on'); |
---|
| 3677 | set(handles.txt_GridName,'string',''); |
---|
[2] | 3678 | end |
---|
| 3679 | |
---|
[282] | 3680 | % % --- Executes on button press in CheckGrid. |
---|
[2] | 3681 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3682 | % |
---|
[71] | 3683 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3684 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3685 | % {'*.grid', ' (*.grid)'; |
---|
| 3686 | % '*.grid', '.grid files '; ... |
---|
| 3687 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3688 | % 'Pick a file',filebase); |
---|
| 3689 | % filegrid=fullfile(PathName,FileName); |
---|
[276] | 3690 | % set(handles.txt_GridName,'string',filegrid); |
---|
| 3691 | % set(handles.num_Dx,'String',' '); |
---|
| 3692 | % set(handles.num_Dy,'String',' '); |
---|
[2] | 3693 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3694 | |
---|
| 3695 | % --- Executes on button press in get_gridpatch1. |
---|
| 3696 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3697 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3698 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3699 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3700 | |
---|
[71] | 3701 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3702 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3703 | {'*.grid', ' (*.grid)'; |
---|
| 3704 | '*.grid', '.grid files '; ... |
---|
| 3705 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3706 | 'Pick a file',filebase); |
---|
[2] | 3707 | filegrid=fullfile(PathName,FileName); |
---|
| 3708 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3709 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3710 | |
---|
[12] | 3711 | %------------------------------------------------------------------------ |
---|
[2] | 3712 | % --- Executes on button press in get_gridpatch2. |
---|
| 3713 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3714 | %------------------------------------------------------------------------ |
---|
[2] | 3715 | |
---|
[12] | 3716 | %------------------------------------------------------------------------ |
---|
[2] | 3717 | function enable_civ1(handles,state) |
---|
[12] | 3718 | %------------------------------------------------------------------------ |
---|
[273] | 3719 | if state |
---|
| 3720 | RootName=get(handles.RootName,'String'); |
---|
| 3721 | if isempty(RootName) |
---|
| 3722 | msgbox_uvmat('ERROR','No input file') |
---|
| 3723 | return |
---|
| 3724 | end |
---|
[282] | 3725 | set(handles.Civ1,'Visible','on') |
---|
| 3726 | set(handles.PairIndices,'Visible','on') |
---|
[273] | 3727 | % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3728 | % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3729 | % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3730 | else |
---|
[282] | 3731 | set(handles.Civ1,'Visible','off') |
---|
[273] | 3732 | % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3733 | % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3734 | % set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 3735 | end |
---|
| 3736 | |
---|
[282] | 3737 | % set(handles.num_Bx,'Visible',state) |
---|
| 3738 | % set(handles.num_By,'Visible',state) |
---|
[287] | 3739 | % set(handles.num_Searchx,'Visible',state) |
---|
| 3740 | % set(handles.num_Searchy,'Visible',state) |
---|
[282] | 3741 | % set(handles.num_Shiftx,'Visible',state) |
---|
| 3742 | % set(handles.num_Shifty,'Visible',state) |
---|
| 3743 | % set(handles.num_Rho,'Visible',state) |
---|
| 3744 | % set(handles.num_Dx,'Visible',state) |
---|
| 3745 | % set(handles.num_Dy,'Visible',state) |
---|
| 3746 | % set(handles.SearchRange,'Visible',state) |
---|
| 3747 | % set(handles.u_title,'Visible',state) |
---|
| 3748 | % set(handles.v_title,'Visible',state) |
---|
| 3749 | % set(handles.min_title,'Visible',state) |
---|
| 3750 | % set(handles.max_title,'Visible',state) |
---|
| 3751 | % set(handles.umin,'Visible',state) |
---|
| 3752 | % set(handles.umax,'Visible',state) |
---|
| 3753 | % set(handles.vmin,'Visible',state) |
---|
| 3754 | % set(handles.vmax,'Visible',state) |
---|
| 3755 | % set(handles.txt_GridName,'Visible',state) |
---|
| 3756 | % set(handles.txt_MaskName,'Visible',state) |
---|
| 3757 | % set(handles.CheckGrid,'Visible',state) |
---|
| 3758 | % set(handles.CheckMask,'Visible',state) |
---|
| 3759 | % set(handles.parameters,'Visible',state) |
---|
| 3760 | % set(handles.grid,'Visible',state) |
---|
| 3761 | % set(handles.num_Dx,'Visible',state) |
---|
| 3762 | % set(handles.num_Dy,'Visible',state) |
---|
| 3763 | % set(handles.check_Threshold,'Visible',state) |
---|
| 3764 | % if isequal(state,'off') |
---|
| 3765 | % set(handles.num_MinIma,'Visible','off') |
---|
| 3766 | % set(handles.num_MaxIma,'Visible','off') |
---|
| 3767 | % set(handles.check_Threshold,'Value',0) |
---|
| 3768 | % end |
---|
| 3769 | % set(handles.dx_civ1_title,'Visible',state) |
---|
| 3770 | % set(handles.dy_civ1_title,'Visible',state) |
---|
| 3771 | % set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3772 | % set(handles.ib_title,'Visible',state) |
---|
| 3773 | % set(handles.is_title,'Visible',state) |
---|
| 3774 | % set(handles.shift_title,'Visible',state) |
---|
| 3775 | % set(handles.rho_title,'Visible',state) |
---|
| 3776 | % set(handles.TestCiv1,'Visible',state) |
---|
| 3777 | %set(handles.ListPairMode,'Visible',state) |
---|
| 3778 | |
---|
[12] | 3779 | %------------------------------------------------------------------------ |
---|
[2] | 3780 | function enable_fix1(handles,state) |
---|
[12] | 3781 | %------------------------------------------------------------------------ |
---|
[273] | 3782 | |
---|
[2] | 3783 | if isequal(state,0) |
---|
| 3784 | state='off'; |
---|
| 3785 | end |
---|
| 3786 | if isequal(state,1) |
---|
| 3787 | state='on'; |
---|
[273] | 3788 | RootName=get(handles.RootName,'String'); |
---|
| 3789 | if isempty(RootName) |
---|
| 3790 | msgbox_uvmat('ERROR','No input file') |
---|
| 3791 | return |
---|
| 3792 | end |
---|
[2] | 3793 | end |
---|
| 3794 | if isequal(state,'on') |
---|
[282] | 3795 | set(handles.Fix1,'Visible','on') |
---|
[273] | 3796 | % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3797 | else |
---|
[282] | 3798 | set(handles.Fix1,'Visible','off') |
---|
[273] | 3799 | %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[2] | 3800 | end |
---|
[282] | 3801 | % % set(handles.REMOVE,'Visible',state) |
---|
| 3802 | % set(handles.CheckFmin2,'Visible',state) |
---|
| 3803 | % set(handles.CheckF2,'Visible',state) |
---|
| 3804 | % set(handles.CheckF3,'Visible',state) |
---|
| 3805 | % set(handles.num_MinCorr,'Visible',state) |
---|
| 3806 | % set(handles.thresh_vecC_title,'Visible',state) |
---|
[287] | 3807 | % set(handles.num_MinVel,'Visible',state) |
---|
| 3808 | % set(handles.TitleMinVel,'Visible',state) |
---|
[282] | 3809 | % set(handles.txt_MaskName,'Visible',state) |
---|
| 3810 | % set(handles.CheckMask,'Visible',state) |
---|
| 3811 | % set(handles.get_ref_fix1,'Visible',state) |
---|
| 3812 | % set(handles.ref_fix1,'Visible',state) |
---|
[287] | 3813 | % set(handles.num_MinVel,'Visible',state) |
---|
[282] | 3814 | % set(handles.field_ref1,'Visible',state) |
---|
[2] | 3815 | |
---|
[12] | 3816 | %------------------------------------------------------------------------ |
---|
[273] | 3817 | function enable_patch1(handles,state) |
---|
[12] | 3818 | %------------------------------------------------------------------------ |
---|
[273] | 3819 | if state |
---|
| 3820 | RootName=get(handles.RootName,'String'); |
---|
| 3821 | if isempty(RootName) |
---|
| 3822 | msgbox_uvmat('ERROR','No input file') |
---|
| 3823 | return |
---|
| 3824 | end |
---|
[282] | 3825 | set(handles.Patch1,'Visible','on') |
---|
[273] | 3826 | else |
---|
[282] | 3827 | set(handles.Patch1,'Visible','off') |
---|
[273] | 3828 | end |
---|
| 3829 | return |
---|
[2] | 3830 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3831 | set(handles.rho_patch1,'Visible','on') |
---|
| 3832 | set(handles.rho_text1,'Visible','on') |
---|
[282] | 3833 | if get(handles.ListPairMode,'Value')==2 |
---|
[224] | 3834 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3835 | set(handles.thresh_text1,'Visible','on') |
---|
| 3836 | end |
---|
[2] | 3837 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3838 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3839 | set(handles.nx_patch1,'Visible','on') |
---|
[274] | 3840 | set(handles.num_Ny,'Visible','on') |
---|
[2] | 3841 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3842 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3843 | % if ~isempty(patch_newBin) |
---|
[224] | 3844 | set(handles.test_interp,'Visible','off'); |
---|
[282] | 3845 | stereo_test=get(handles.ListCompareMode,'Value'); |
---|
[252] | 3846 | if stereo_test==3 |
---|
| 3847 | set(handles.test_stereo1,'Visible','on') |
---|
| 3848 | end |
---|
[100] | 3849 | % end |
---|
[252] | 3850 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 3851 | %set(handles.grid_patch1,'string','none'); |
---|
| 3852 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 3853 | |
---|
[273] | 3854 | % %------------------------------------------------------------------------ |
---|
| 3855 | % function desable_patch1(handles) |
---|
| 3856 | % %------------------------------------------------------------------------ |
---|
| 3857 | % return |
---|
| 3858 | % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3859 | % set(handles.rho_patch1,'Visible','off') |
---|
| 3860 | % set(handles.rho_text1,'Visible','off') |
---|
| 3861 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 3862 | % set(handles.thresh_text1,'Visible','off') |
---|
| 3863 | % set(handles.subdomain_patch1,'Visible','off') |
---|
| 3864 | % set(handles.subdomain_text1,'Visible','off') |
---|
| 3865 | % set(handles.nx_patch1,'Visible','off') |
---|
[274] | 3866 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 3867 | % set(handles.nx_patch1_title,'Visible','off') |
---|
| 3868 | % set(handles.ny_patch1_title,'Visible','off') |
---|
| 3869 | % set(handles.test_stereo1,'Visible','off') |
---|
| 3870 | % %set(handles.test_interp,'Visible','off') |
---|
| 3871 | % %set(handles.get_gridpatch1,'Visible','off') |
---|
| 3872 | % %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 3873 | |
---|
[12] | 3874 | %------------------------------------------------------------------------ |
---|
[2] | 3875 | function enable_civ2(handles,state) |
---|
[12] | 3876 | %------------------------------------------------------------------------ |
---|
[273] | 3877 | if state |
---|
| 3878 | RootName=get(handles.RootName,'String'); |
---|
| 3879 | if isempty(RootName) |
---|
| 3880 | msgbox_uvmat('ERROR','No input file') |
---|
| 3881 | return |
---|
| 3882 | end |
---|
[282] | 3883 | set(handles.Civ2,'Visible','on') |
---|
[289] | 3884 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
| 3885 | set(handles.SubdirCiv2,'Visible','on') |
---|
| 3886 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[2] | 3887 | else |
---|
[282] | 3888 | set(handles.Civ2,'Visible','off') |
---|
[2] | 3889 | end |
---|
[273] | 3890 | |
---|
[282] | 3891 | % |
---|
[287] | 3892 | % set(handles.num_Bx,'Visible',state) |
---|
| 3893 | % set(handles.num_By,'Visible',state) |
---|
| 3894 | % set(handles.CheckDecimal,'Visible',state) |
---|
| 3895 | % set(handles.CheckDeformation,'Visible',state) |
---|
| 3896 | % set(handles.num_Rho,'Visible',state) |
---|
[282] | 3897 | % set(handles.num_Dx,'Visible',state) |
---|
| 3898 | % set(handles.num_Dy,'Visible',state) |
---|
| 3899 | % set(handles.CheckGrid,'Visible',state) |
---|
| 3900 | % set(handles.CheckMask,'Visible',state) |
---|
| 3901 | % set(handles.parameters,'Visible',state) |
---|
| 3902 | % set(handles.grid,'Visible',state) |
---|
| 3903 | % set(handles.parameters_text,'Visible',state) |
---|
| 3904 | % set(handles.grid_text,'Visible',state) |
---|
| 3905 | % set(handles.txt_GridName,'Visible',state) |
---|
| 3906 | % set(handles.txt_Mask,'Visible',state) |
---|
| 3907 | % set(handles.dx_civ2_title,'Visible',state) |
---|
| 3908 | % set(handles.dy_civ2_title,'Visible',state) |
---|
| 3909 | % set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3910 | % set(handles.rho_civ2_title,'Visible',state) |
---|
| 3911 | % set(handles.ImaThreshold2,'Visible',state) |
---|
| 3912 | % set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3913 | % if isequal(state,'off') |
---|
[287] | 3914 | % set(handles.num_MinIma,'Visible','off') |
---|
| 3915 | % set(handles.num_MaxIma,'Visible','off') |
---|
[282] | 3916 | % set(handles.ImaThreshold2,'Value',0) |
---|
| 3917 | % if isequal(get(handles.CheckFix2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
| 3918 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 3919 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 3920 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[282] | 3921 | % set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3922 | % %set(handles.ref_i_civ2,'Visible','off') |
---|
| 3923 | % set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3924 | % set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3925 | % set(handles.ref_j_civ2,'Visible','off') |
---|
| 3926 | % end |
---|
| 3927 | % else |
---|
| 3928 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 3929 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 3930 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 3931 | % set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3932 | % % set(handles.ref_i_civ2,'Visible','on') |
---|
| 3933 | % set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3934 | % set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3935 | % set(handles.ref_j_civ2,'Visible','on') |
---|
| 3936 | % end |
---|
| 3937 | % set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3938 | |
---|
[12] | 3939 | %------------------------------------------------------------------------ |
---|
[273] | 3940 | function enable_fix2(handles,state) |
---|
[12] | 3941 | %------------------------------------------------------------------------ |
---|
[273] | 3942 | % if isequal(state,'on') |
---|
[282] | 3943 | % set(handles.Fix2,'Visible','on') |
---|
[273] | 3944 | % |
---|
| 3945 | % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3946 | % % set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3947 | % % set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3948 | % % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3949 | % else |
---|
| 3950 | if state |
---|
| 3951 | RootName=get(handles.RootName,'String'); |
---|
| 3952 | if isempty(RootName) |
---|
| 3953 | msgbox_uvmat('ERROR','No input file') |
---|
| 3954 | return |
---|
| 3955 | end |
---|
[282] | 3956 | set(handles.Fix2,'Visible','on') |
---|
[273] | 3957 | else |
---|
[282] | 3958 | set(handles.Fix2,'Visible','off') |
---|
[273] | 3959 | end |
---|
[2] | 3960 | |
---|
[282] | 3961 | % set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3962 | % set(handles.REMOVE2,'Visible','on') |
---|
[287] | 3963 | % set(handles.CheckFmin2,'Visible','on') |
---|
| 3964 | % set(handles.CheckF4,'Visible','on') |
---|
| 3965 | % set(handles.CheckF3,'Visible','on') |
---|
| 3966 | % set(handles.num_MinCorr,'Visible','on') |
---|
[282] | 3967 | % set(handles.thresh_vec2C_text,'Visible','on') |
---|
[287] | 3968 | % set(handles.num_MinVel,'Visible','on') |
---|
| 3969 | % set(handles.TitleMinVel,'Visible','on') |
---|
| 3970 | % set(handles.txt_MaskName,'Visible','on') |
---|
[282] | 3971 | % set(handles.CheckMask,'Visible','on') |
---|
| 3972 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 3973 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 3974 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 3975 | % set(handles.get_ref_fix2,'Visible','on') |
---|
| 3976 | % set(handles.ref_fix2,'Visible','on') |
---|
[287] | 3977 | % set(handles.num_MinVel,'Visible','on') |
---|
[282] | 3978 | % set(handles.field_ref2,'Visible','on') |
---|
| 3979 | |
---|
[273] | 3980 | % %------------------------------------------------------------------------ |
---|
| 3981 | % function desable_fix2(handles) |
---|
| 3982 | % %------------------------------------------------------------------------ |
---|
| 3983 | % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3984 | % set(handles.REMOVE2,'Visible','off') |
---|
[287] | 3985 | % set(handles.CheckFmin2,'Visible','off') |
---|
| 3986 | % set(handles.CheckF4,'Visible','off') |
---|
| 3987 | % set(handles.CheckF3,'Visible','off') |
---|
| 3988 | % set(handles.num_MinCorr,'Visible','off') |
---|
[273] | 3989 | % set(handles.thresh_vec2C_text,'Visible','off') |
---|
[287] | 3990 | % set(handles.num_MinVel,'Visible','off') |
---|
| 3991 | % set(handles.TitleMinVel,'Visible','off') |
---|
| 3992 | % set(handles.txt_MaskName,'Visible','off') |
---|
[282] | 3993 | % set(handles.CheckMask,'Visible','off') |
---|
[273] | 3994 | % set(handles.get_ref_fix2,'Visible','off') |
---|
| 3995 | % set(handles.ref_fix2,'Visible','off') |
---|
[287] | 3996 | % set(handles.num_MinVel,'Visible','off') |
---|
[273] | 3997 | % set(handles.field_ref2,'Visible','off') |
---|
[282] | 3998 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
| 3999 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4000 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4001 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[273] | 4002 | % end |
---|
[2] | 4003 | |
---|
[12] | 4004 | %------------------------------------------------------------------------ |
---|
[273] | 4005 | function enable_patch2(handles,state) |
---|
[12] | 4006 | %------------------------------------------------------------------------ |
---|
[273] | 4007 | if state |
---|
| 4008 | RootName=get(handles.RootName,'String'); |
---|
| 4009 | if isempty(RootName) |
---|
| 4010 | msgbox_uvmat('ERROR','No input file') |
---|
| 4011 | return |
---|
| 4012 | end |
---|
[282] | 4013 | set(handles.Patch2,'Visible','on') |
---|
[273] | 4014 | else |
---|
[282] | 4015 | set(handles.Patch2,'Visible','off') |
---|
[252] | 4016 | end |
---|
[273] | 4017 | % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[274] | 4018 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
[292] | 4019 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
[274] | 4020 | % set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 4021 | % set(handles.thresh_text2,'Visible','on') |
---|
[274] | 4022 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
[273] | 4023 | % set(handles.subdomain_text2,'Visible','on') |
---|
[274] | 4024 | % set(handles.num_Nx,'Visible','on') |
---|
| 4025 | % set(handles.num_Ny,'Visible','on') |
---|
[273] | 4026 | % set(handles.nx_patch2_title,'Visible','on') |
---|
| 4027 | % set(handles.ny_patch2_title,'Visible','on') |
---|
| 4028 | % % set(handles.get_gridpatch2,'Visible','on') |
---|
| 4029 | % % set(handles.grid_patch2,'Visible','on') |
---|
[282] | 4030 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 4031 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 4032 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 4033 | % stereo_test=get(handles.ListCompareMode,'Value'); |
---|
[273] | 4034 | % if stereo_test==3 |
---|
[282] | 4035 | % set(handles.CheckStereo,'Visible','on') |
---|
[273] | 4036 | % end |
---|
[2] | 4037 | |
---|
[273] | 4038 | % %------------------------------------------------------------------------ |
---|
| 4039 | % function desable_patch2(handles) |
---|
| 4040 | % %------------------------------------------------------------------------ |
---|
[282] | 4041 | % %set(handles.checkpatch2,'Visible','off') |
---|
[273] | 4042 | % return |
---|
| 4043 | % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[274] | 4044 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
[292] | 4045 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
[274] | 4046 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 4047 | % set(handles.thresh_text2,'Visible','off') |
---|
[274] | 4048 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
[273] | 4049 | % set(handles.subdomain_text2,'Visible','off') |
---|
[274] | 4050 | % set(handles.num_Nx,'Visible','off') |
---|
| 4051 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 4052 | % set(handles.nx_patch2_title,'Visible','off') |
---|
| 4053 | % set(handles.ny_patch2_title,'Visible','off') |
---|
| 4054 | % % set(handles.get_gridpatch2,'Visible','off') |
---|
| 4055 | % % set(handles.grid_patch2,'Visible','off') |
---|
[282] | 4056 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckFix2,'Value'),0) |
---|
| 4057 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4058 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4059 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[273] | 4060 | % end |
---|
[282] | 4061 | % set(handles.CheckStereo,'Visible','off') |
---|
[12] | 4062 | %------------------------------------------------------------------------ |
---|
[2] | 4063 | function enable_pair1(handles,state) |
---|
[12] | 4064 | %------------------------------------------------------------------------ |
---|
[289] | 4065 | set(handles.txt_SubdirCiv1,'Visible',state) |
---|
[282] | 4066 | set(handles.ListSubdirCiv1,'Visible',state) |
---|
[289] | 4067 | set(handles.TitleSubdirCiv1,'Visible',state) |
---|
[273] | 4068 | %set(handles.frame_subdirciv1,'Visible',state) |
---|
[282] | 4069 | set(handles.ListPairCiv1,'Visible',state) |
---|
[289] | 4070 | set(handles.TitlePairCiv1,'Visible',state) |
---|
[71] | 4071 | %set(handles.dt_unit,'Visible',state) |
---|
[273] | 4072 | %set(handles.PAIR_frame,'Visible',state) |
---|
[2] | 4073 | |
---|
[12] | 4074 | %------------------------------------------------------------------------ |
---|
[282] | 4075 | % --- Read the parameters for checkciv1 on the interface |
---|
[285] | 4076 | % function par=read_param_civ1(handles,filecell) |
---|
| 4077 | % % not deeden anymore |
---|
| 4078 | % %------------------------------------------------------------------------ |
---|
| 4079 | % ibx_val=str2double(get(handles.num_Bx,'String')); |
---|
| 4080 | % par.ibx=num2str(ibx_val); |
---|
| 4081 | % iby_val=str2double(get(handles.num_By,'String')); |
---|
| 4082 | % par.iby=num2str(iby_val); |
---|
[287] | 4083 | % isx=get(handles.num_Searchx,'String'); |
---|
| 4084 | % if isnan(str2double(isx)), isx='41'; set(handles.num_Searchx,'String','41'), end; %default |
---|
| 4085 | % if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.num_Searchx,'String',num2str(ibx_val+8)); end |
---|
| 4086 | % isy=get(handles.num_Searchy,'String'); |
---|
| 4087 | % if isnan(str2double(isy)), isy='41'; set(handles.num_Searchy,'String','41'), end;%default |
---|
| 4088 | % if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.num_Searchy,'String',num2str(iby_val+8)); end |
---|
| 4089 | % par.isx=get(handles.num_Searchx,'String'); |
---|
| 4090 | % par.isy=get(handles.num_Searchy,'String'); |
---|
[285] | 4091 | % par.shiftx=get(handles.num_Shiftx,'String'); |
---|
| 4092 | % par.shifty=get(handles.num_Shifty,'String'); |
---|
| 4093 | % if isnan(str2double(par.isx)) |
---|
| 4094 | % par.isx='41';%default |
---|
[287] | 4095 | % set(handles.num_Searchx,'String','41'); |
---|
[272] | 4096 | % end |
---|
[285] | 4097 | % if isnan(str2double(par.isy)) |
---|
| 4098 | % par.isy='41'; %default |
---|
[287] | 4099 | % set(handles.num_Searchy,'String','41'); |
---|
[285] | 4100 | % end |
---|
| 4101 | % if isnan(str2double(par.shiftx)) |
---|
| 4102 | % par.shiftx='0';%default |
---|
| 4103 | % set(handles.num_Shiftx,'String','0'); |
---|
| 4104 | % end |
---|
| 4105 | % if isnan(str2double(par.shifty)) |
---|
| 4106 | % par.shifty='0'; %default |
---|
| 4107 | % set(handles.num_Shifty,'String','0'); |
---|
| 4108 | % end |
---|
| 4109 | % par.rho=get(handles.num_Rho,'String'); |
---|
| 4110 | % if isequal(get(handles.num_Rho,'Style'),'popupmenu') |
---|
| 4111 | % index=get(handles.num_Rho,'Value'); |
---|
| 4112 | % par.rho=par.rho{index}; |
---|
| 4113 | % end |
---|
| 4114 | % dummy=get(handles.num_Dx,'String'); |
---|
| 4115 | % par.dx=dummy{1}; |
---|
| 4116 | % dummy=get(handles.num_Dy,'String'); |
---|
| 4117 | % par.dy=dummy{1}; |
---|
| 4118 | % if isnan(str2double(par.dx)) |
---|
| 4119 | % if isempty(get(handles.txt_GridName,'String')); |
---|
| 4120 | % par.dx='0'; %just read by civ program, not used |
---|
| 4121 | % else |
---|
| 4122 | % par.dx='20';%default |
---|
| 4123 | % set(handles.num_Dx,'String','20'); |
---|
| 4124 | % end |
---|
| 4125 | % end |
---|
| 4126 | % if isnan(str2double(par.dy)) |
---|
| 4127 | % if isempty(get(handles.txt_GridName,'String')); |
---|
| 4128 | % par.dy='0';%just read by civ program, not used |
---|
| 4129 | % else |
---|
| 4130 | % par.dy='20';%default |
---|
| 4131 | % set(handles.dy_civ1_title,'String','20'); |
---|
| 4132 | % end |
---|
| 4133 | % end |
---|
| 4134 | % par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4135 | % par.pxcmy='1'; |
---|
| 4136 | % % if exist('file_ima','var') |
---|
| 4137 | % A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 4138 | % sizim=size(A); |
---|
| 4139 | % par.npx=num2str(sizim(2)); |
---|
| 4140 | % par.npy=num2str(sizim(1)); |
---|
| 4141 | % %TODO : civ should not need npx and npy |
---|
| 4142 | % |
---|
| 4143 | % |
---|
| 4144 | % % end |
---|
| 4145 | % %time=get(handles.RootName,'UserData'); %get the set of times |
---|
| 4146 | % dummy=get(handles.txt_GridName,'String'); |
---|
| 4147 | % par.gridname=dummy{1}; |
---|
| 4148 | % par.gridflag='y'; |
---|
| 4149 | % if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
| 4150 | % par.gridname='nogrid'; |
---|
| 4151 | % par.gridflag='n'; |
---|
| 4152 | % end |
---|
| 4153 | % |
---|
[272] | 4154 | |
---|
| 4155 | |
---|
| 4156 | %------------------------------------------------------------------------ |
---|
[2] | 4157 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4158 | %------------------------------------------------------------------------ |
---|
[287] | 4159 | par.ibx=get(handles.num_Bx,'String'); |
---|
| 4160 | par.iby=get(handles.num_By,'String'); |
---|
| 4161 | par.rho=get(handles.num_Rho,'String'); |
---|
| 4162 | par.decimal=int2str(get(handles.CheckDecimal,'Value')); |
---|
| 4163 | par.deformation=int2str(get(handles.CheckDeformation,'Value')); |
---|
[276] | 4164 | par.dx=get(handles.num_Dx,'String'); |
---|
| 4165 | par.dy=get(handles.num_Dy,'String'); |
---|
[127] | 4166 | if isnan(str2double(par.dx)) |
---|
[276] | 4167 | if isempty(get(handles.txt_GridName,'String')); |
---|
[112] | 4168 | par.dx='0'; %just read by civ program, not used |
---|
| 4169 | else |
---|
[12] | 4170 | par.dx='20';%default |
---|
[276] | 4171 | set(handles.num_Dx,'String','20'); |
---|
[112] | 4172 | end |
---|
| 4173 | end |
---|
[127] | 4174 | if isnan(str2double(par.dy)) |
---|
[276] | 4175 | if isempty(get(handles.txt_GridName,'String')); |
---|
[112] | 4176 | par.dy='0';%just read by civ program, not used |
---|
| 4177 | else |
---|
[12] | 4178 | par.dy='20';%default |
---|
[276] | 4179 | set(handles.num_Dy,'String','20'); |
---|
[112] | 4180 | end |
---|
| 4181 | end |
---|
| 4182 | par.pxcmx='1'; |
---|
| 4183 | par.pxcmy='1'; |
---|
[12] | 4184 | A=imread(file_ima);%read the first image to get the size |
---|
| 4185 | sizim=size(A); |
---|
| 4186 | par.npx=num2str(sizim(2)); |
---|
| 4187 | par.npy=num2str(sizim(1)); |
---|
[127] | 4188 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[276] | 4189 | par.gridname=get(handles.txt_GridName,'String'); |
---|
[12] | 4190 | par.gridflag='y'; |
---|
[127] | 4191 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4192 | par.gridname='nogrid'; |
---|
| 4193 | par.gridflag='n'; |
---|
| 4194 | end |
---|
[2] | 4195 | |
---|
[272] | 4196 | function cmd_CIV1=CIV1_CMD(filename,param) |
---|
| 4197 | %TODO : include filename in par_civ1 |
---|
[12] | 4198 | %------------------------------------------------------------------------ |
---|
[2] | 4199 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4200 | |
---|
| 4201 | %changes : filename_cmx -> filename ( no extension ) |
---|
[272] | 4202 | |
---|
[275] | 4203 | filename=regexprep(filename,'.nc',''); |
---|
[272] | 4204 | |
---|
[284] | 4205 | if isequal(Param.Civ1.Dt,'0') |
---|
| 4206 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4207 | end |
---|
[284] | 4208 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
| 4209 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
[230] | 4210 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4211 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[284] | 4212 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4213 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[112] | 4214 | fprintf(fid, ['XX' '\n' ]); |
---|
[284] | 4215 | fprintf(fid, ['Mask ' Param.Civ1.maskflag '\n' ]); |
---|
| 4216 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.maskname,'\\','\\\\') '\n' ]); |
---|
| 4217 | fprintf(fid, ['ImageSize ' Param.Civ1.npx ' ' Param.Civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4218 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ1.ibx ' ' Param.Civ1.iby '\n' ]); |
---|
| 4219 | fprintf(fid, ['SearchBoxeSize ' Param.Civ1.isx ' ' Param.Civ1.isy '\n' ]); |
---|
| 4220 | fprintf(fid, ['RO ' Param.Civ1.rho '\n' ]); |
---|
| 4221 | fprintf(fid, ['GridSpacing ' Param.Civ1.dx ' ' Param.Civ1.dy '\n' ]); |
---|
[112] | 4222 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[284] | 4223 | fprintf(fid, ['Dt_TO ' Param.Civ1.Dt ' ' Param.Civ1.T0 '\n' ]); |
---|
| 4224 | fprintf(fid, ['PixCmXY ' Param.Civ1.pxcmx ' ' Param.Civ1.pxcmy '\n' ]); |
---|
[112] | 4225 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[284] | 4226 | fprintf(fid, ['ShiftXY ' Param.Civ1.shiftx ' ' Param.Civ1.shifty '\n' ]); |
---|
| 4227 | fprintf(fid, ['Grid ' Param.Civ1.gridflag '\n' ]); |
---|
| 4228 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.gridname,'\\','\\\\') '\n' ]); |
---|
[112] | 4229 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4230 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4231 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4232 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4233 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4234 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4235 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4236 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4237 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4238 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[284] | 4239 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
[112] | 4240 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4241 | fclose(fid); |
---|
[112] | 4242 | |
---|
[163] | 4243 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4244 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4245 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4246 | if(isunix) |
---|
[272] | 4247 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; |
---|
| 4248 | cmd_CIV1=[cmd_CIV1 '\n'... |
---|
[284] | 4249 | Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[219] | 4250 | 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 |
---|
[282] | 4251 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv1.cmx' '\n'];%rename .cmx as .checkciv1.cmx |
---|
[163] | 4252 | else %Windows system |
---|
[269] | 4253 | % flname=regexprep(flname,'\\','\\\\'); |
---|
[282] | 4254 | % cmd=[cmd 'copy /Y "' flname '.checkciv1.cmx" "' flname '.cmx"\n']; |
---|
[269] | 4255 | % filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4256 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx |
---|
[284] | 4257 | cmd_CIV1=[cmd_CIV1 '\n "' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[272] | 4258 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 4259 | cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4260 | |
---|
[282] | 4261 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv1.cmx"']; |
---|
[12] | 4262 | end |
---|
[2] | 4263 | |
---|
[12] | 4264 | %------------------------------------------------------------------------ |
---|
[282] | 4265 | % --- CheckCiv1 Unified |
---|
[94] | 4266 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4267 | %------------------------------------------------------------------------ |
---|
[2] | 4268 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4269 | %global CivBin%name of the executable for checkciv1 calculation |
---|
[2] | 4270 | |
---|
[112] | 4271 | civ1.image1=par.filename_ima_a; |
---|
| 4272 | civ1.image2=par.filename_ima_b; |
---|
| 4273 | civ1.imageSize_X=par.npx; |
---|
| 4274 | civ1.imageSize_Y=par.npy; |
---|
| 4275 | civ1.outputFileName=[filename '.nc']; |
---|
| 4276 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4277 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4278 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4279 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4280 | civ1.globalShift_X=par.shiftx; |
---|
| 4281 | civ1.globalShift_Y=par.shifty; |
---|
| 4282 | civ1.ro=par.rho; |
---|
| 4283 | civ1.hart='y'; |
---|
| 4284 | if isequal(par.gridflag,'y') |
---|
| 4285 | civ1.grid=par.gridname; |
---|
| 4286 | else |
---|
| 4287 | civ1.grid='n'; |
---|
| 4288 | civ1.gridSpacing_X=par.dx; |
---|
| 4289 | civ1.gridSpacing_Y=par.dy; |
---|
| 4290 | end |
---|
| 4291 | if isequal(par.maskflag,'y') |
---|
| 4292 | civ1.mask=par.maskname; |
---|
| 4293 | end |
---|
[229] | 4294 | civ1.dt=par.Dt; |
---|
[112] | 4295 | civ1.unit='pixel'; |
---|
| 4296 | civ1.absolut_time_T0=par.T0; |
---|
| 4297 | civ1.pixcmx=par.pxcmx; |
---|
| 4298 | civ1.pixcmy=par.pxcmy; |
---|
| 4299 | civ1.convectFlow='n'; |
---|
[12] | 4300 | |
---|
[112] | 4301 | xml_civ1_parameters=civ1; |
---|
| 4302 | |
---|
[12] | 4303 | %------------------------------------------------------------------------ |
---|
[282] | 4304 | % --- CheckCiv2 Unified |
---|
[94] | 4305 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4306 | %------------------------------------------------------------------------ |
---|
[2] | 4307 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4308 | %global CivBin%name of the executable for checkciv1 calculation |
---|
[275] | 4309 | |
---|
[272] | 4310 | filename=regexprep(filename,'.nc',''); |
---|
[2] | 4311 | |
---|
| 4312 | civ2.image1=par.filename_ima_a; |
---|
| 4313 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4314 | civ2.imageSize_X=par.npx; |
---|
[2] | 4315 | civ2.imageSize_Y=par.npy; |
---|
| 4316 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4317 | civ2.outputFileName=[filename '.nc']; |
---|
| 4318 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4319 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4320 | civ2.ro=par.rho; |
---|
[287] | 4321 | %checkciv2.decimalShift=par.CheckDecimal; |
---|
| 4322 | %checkciv2.CheckDeformation=par.CheckDeformation; |
---|
[2] | 4323 | if isequal(par.decimal,'1') |
---|
| 4324 | civ2.decimalShift='y'; |
---|
| 4325 | else |
---|
| 4326 | civ2.decimalShift='n'; |
---|
| 4327 | end |
---|
| 4328 | if isequal(par.deformation,'1') |
---|
| 4329 | civ2.deformation='y'; |
---|
| 4330 | else |
---|
| 4331 | civ2.deformation='n'; |
---|
| 4332 | end |
---|
| 4333 | if isequal(par.gridflag,'y') |
---|
| 4334 | civ2.grid=par.gridname; |
---|
| 4335 | else |
---|
| 4336 | civ2.grid='n'; |
---|
| 4337 | civ2.gridSpacing_X=par.dx; |
---|
| 4338 | civ2.gridSpacing_Y=par.dy; |
---|
| 4339 | end |
---|
| 4340 | civ2.gridSpacing_X='10'; |
---|
| 4341 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4342 | if isequal(par.maskflag,'y') |
---|
| 4343 | civ2.mask=par.maskname; |
---|
| 4344 | else |
---|
| 4345 | civ2.mask='n'; |
---|
| 4346 | end |
---|
| 4347 | civ2.dt=par.Dt; |
---|
| 4348 | civ2.unit='pixel'; |
---|
| 4349 | civ2.absolut_time_T0=par.T0; |
---|
| 4350 | civ2.pixcmx=par.pxcmx; |
---|
| 4351 | civ2.pixcmy=par.pxcmy; |
---|
| 4352 | civ2.convectFlow='n'; |
---|
| 4353 | civ2.pixcmx=par.pxcmx; |
---|
| 4354 | civ2.pixcmy=par.pxcmy; |
---|
| 4355 | civ2.convectFlow='n'; |
---|
| 4356 | |
---|
[12] | 4357 | %------------------------------------------------------------------------ |
---|
[282] | 4358 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
[272] | 4359 | function cmd_CIV2=CIV2_CMD(filename,param) |
---|
[12] | 4360 | %------------------------------------------------------------------------ |
---|
[2] | 4361 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4362 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
[275] | 4363 | filename=regexprep(filename,'.nc',''); |
---|
[290] | 4364 | if isequal(Param.Civ2.Dt,'0') |
---|
| 4365 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4366 | end |
---|
[290] | 4367 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
| 4368 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4369 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4370 | if isequal(fid,-1) |
---|
| 4371 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4372 | cmd_CIV2=''; |
---|
| 4373 | return |
---|
| 4374 | end |
---|
[94] | 4375 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[290] | 4376 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4377 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[94] | 4378 | fprintf(fid, ['XX' '\n' ]); |
---|
[290] | 4379 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 4380 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4381 | fprintf(fid, ['ImageSize ' Param.Civ2.npx ' ' Param.Civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4382 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n' ]); |
---|
| 4383 | fprintf(fid, ['SearchBoxeSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n']); |
---|
| 4384 | fprintf(fid, ['RO ' Param.Civ2.rho '\n']); |
---|
| 4385 | fprintf(fid, ['GridSpacing ' Param.Civ2.dx ' ' Param.Civ2.dy '\n']); |
---|
[94] | 4386 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[290] | 4387 | fprintf(fid, ['Dt_TO ' Param.Civ2.Dt ' ' Param.Civ2.T0 '\n' ]); |
---|
| 4388 | fprintf(fid, ['PixCmXY ' Param.Civ2.pxcmx ' ' Param.Civ2.pxcmy '\n' ]); |
---|
[94] | 4389 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4390 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[290] | 4391 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 4392 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
[94] | 4393 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4394 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4395 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4396 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
[290] | 4397 | fprintf(fid, ['DecimalShift ' Param.Civ2.decimal '\n']); |
---|
| 4398 | fprintf(fid, ['Deformation ' Param.Civ2.deformation '\n']); |
---|
[94] | 4399 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4400 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4401 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4402 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[290] | 4403 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 4404 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
[94] | 4405 | fclose(fid); |
---|
| 4406 | |
---|
[134] | 4407 | if(isunix) |
---|
[230] | 4408 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
[284] | 4409 | cmd_CIV2=[cmd_CIV2 Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[230] | 4410 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
[282] | 4411 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv2.cmx' '\n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
[230] | 4412 | |
---|
[163] | 4413 | else |
---|
[174] | 4414 | filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4415 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; |
---|
[284] | 4416 | cmd_CIV2=[cmd_CIV2 '\n "' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[272] | 4417 | cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[282] | 4418 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv2.cmx"']; |
---|
[134] | 4419 | end |
---|
| 4420 | |
---|
| 4421 | |
---|
[12] | 4422 | %------------------------------------------------------------------------ |
---|
[2] | 4423 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4424 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4425 | %------------------------------------------------------------------------ |
---|
[2] | 4426 | %num is the view number needed for an avi movie |
---|
[45] | 4427 | switch type_ima |
---|
| 4428 | case 'movie' |
---|
| 4429 | A=read(movieobject,num); |
---|
| 4430 | case 'avi' |
---|
[112] | 4431 | mov=aviread(filename,num); |
---|
| 4432 | A=frame2im(mov(1)); |
---|
[45] | 4433 | case 'multimage' |
---|
| 4434 | A=imread(filename,num); |
---|
[112] | 4435 | case 'image' |
---|
[45] | 4436 | A=imread(filename); |
---|
| 4437 | end |
---|
| 4438 | siz=size(A); |
---|
| 4439 | if length(siz)==3;%color images |
---|
[2] | 4440 | A=sum(double(A),3); |
---|
| 4441 | A=uint16(A); |
---|
| 4442 | end |
---|
| 4443 | |
---|
[12] | 4444 | %------------------------------------------------------------------------ |
---|
[2] | 4445 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4446 | %------------------------------------------------------------------------ |
---|
[282] | 4447 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4448 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 4449 | mode=mode_list{mode_value}; |
---|
[45] | 4450 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4451 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[282] | 4452 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[2] | 4453 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4454 | end |
---|
| 4455 | |
---|
[12] | 4456 | %------------------------------------------------------------------------ |
---|
[2] | 4457 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4458 | %------------------------------------------------------------------------ |
---|
[282] | 4459 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4460 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 4461 | mode=mode_list{mode_value}; |
---|
[282] | 4462 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4463 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4464 | end |
---|
[45] | 4465 | if isequal(mode,'series(Dj)') || ... |
---|
[282] | 4466 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[2] | 4467 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4468 | end |
---|
[12] | 4469 | |
---|
| 4470 | %------------------------------------------------------------------------ |
---|
[71] | 4471 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4472 | %------------------------------------------------------------------------ |
---|
[282] | 4473 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4474 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[71] | 4475 | mode=mode_list{mode_value}; |
---|
| 4476 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4477 | |
---|
| 4478 | %------------------------------------------------------------------------ |
---|
| 4479 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4480 | %------------------------------------------------------------------------ |
---|
[282] | 4481 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4482 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[71] | 4483 | mode=mode_list{mode_value}; |
---|
[112] | 4484 | if isequal(mode,'series(Dj)') |
---|
[71] | 4485 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4486 | end |
---|
| 4487 | |
---|
| 4488 | %------------------------------------------------------------------------ |
---|
[282] | 4489 | % --- Executes on button press in ListCompareMode. |
---|
| 4490 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
[12] | 4491 | %------------------------------------------------------------------------ |
---|
[282] | 4492 | test=get(handles.ListCompareMode,'Value'); |
---|
[263] | 4493 | if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' |
---|
[71] | 4494 | filebase=get(handles.RootName,'String'); |
---|
[273] | 4495 | browse=get(handlesRootName,'Userdata'); |
---|
[2] | 4496 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
[273] | 4497 | set(handlesRootName,'UserData',browse); |
---|
[2] | 4498 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4499 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[282] | 4500 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
| 4501 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
| 4502 | set(handles.ListPairMode,'Visible','off') |
---|
[2] | 4503 | if test==2 |
---|
[282] | 4504 | set(handles.ListPairMode,'Visible','off') |
---|
| 4505 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4506 | else |
---|
[282] | 4507 | set(handles.ListPairMode,'Visible','on') |
---|
| 4508 | set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo |
---|
[2] | 4509 | end |
---|
| 4510 | |
---|
[273] | 4511 | %% menuopen an image file with the browser |
---|
[2] | 4512 | ind_opening=1;%default |
---|
| 4513 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4514 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4515 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4516 | '*.xml', '.xml files '; ... |
---|
| 4517 | '*.civ', '.civ files '; ... |
---|
| 4518 | '*.png','.png image files'; ... |
---|
| 4519 | '*.jpg',' jpeg image files'; ... |
---|
| 4520 | '*.tif','.tif image files'; ... |
---|
| 4521 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4522 | '*.nc','.netcdf files'; ... |
---|
| 4523 | '*.*', 'All Files (*.*)'}; |
---|
| 4524 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4525 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4526 | sizf=size(fileinput); |
---|
[229] | 4527 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[275] | 4528 | [path,name,ext]=fileparts(fileinput); |
---|
[2] | 4529 | [path1]=fileparts(filebase); |
---|
[263] | 4530 | if isunix |
---|
[289] | 4531 | [status,path]=system(['readlink ' path]); |
---|
| 4532 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
[263] | 4533 | end |
---|
[2] | 4534 | if ~strcmp(path1,path) |
---|
[263] | 4535 | msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') |
---|
[2] | 4536 | return |
---|
[263] | 4537 | end |
---|
| 4538 | % set(handles.RootName_1,'String',name); |
---|
[2] | 4539 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
[263] | 4540 | set(handles.RootName_1,'String',RootFile); |
---|
[273] | 4541 | browse=get(handlesRootName,'UserData'); |
---|
[2] | 4542 | browse.nom_type_ima_1=nom_type; |
---|
[273] | 4543 | set(handlesRootName,'UserData',browse) |
---|
[2] | 4544 | |
---|
| 4545 | %check image extension |
---|
[71] | 4546 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[263] | 4547 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
[2] | 4548 | return |
---|
| 4549 | end |
---|
| 4550 | |
---|
[229] | 4551 | %% check coincidence of image sizes |
---|
[263] | 4552 | % ref_i=get(handles.ref_i,'string'); |
---|
| 4553 | % ref_j=get(handles.ref_j,'string'); |
---|
| 4554 | % [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]); |
---|
[282] | 4555 | % A=imread(filecell.ima1.checkciv1{1}); |
---|
[263] | 4556 | % A_1=imread(fileinput); |
---|
| 4557 | % npxy=size(A); |
---|
| 4558 | % npxy_1=size(A_1); |
---|
| 4559 | % if ~isequal(size(A),size(A_1)) |
---|
| 4560 | % msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
| 4561 | % return |
---|
| 4562 | % end |
---|
[2] | 4563 | else |
---|
[282] | 4564 | set(handles.ListPairMode,'Visible','on') |
---|
[71] | 4565 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4566 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4567 | set(handles.RootName_1,'String',[]); |
---|
[282] | 4568 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 4569 | set(handles.ListPairMode,'Value',1) |
---|
| 4570 | set(handles.ListPairMode,'String',mode_store) |
---|
[2] | 4571 | set(handles.test_stereo1,'Value',0) |
---|
[282] | 4572 | set(handles.CheckStereo,'Value',0) |
---|
| 4573 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4574 | end |
---|
[282] | 4575 | if test==3 && get(handles.CheckPatch1,'Value') |
---|
[263] | 4576 | set(handles.test_stereo1,'Visible','on') |
---|
[252] | 4577 | else |
---|
[263] | 4578 | set(handles.test_stereo1,'Visible','off') |
---|
[252] | 4579 | end |
---|
[282] | 4580 | if test==3 && get(handles.CheckPatch2,'Value') |
---|
| 4581 | set(handles.CheckStereo,'Visible','on') |
---|
[252] | 4582 | else |
---|
[282] | 4583 | set(handles.CheckStereo,'Visible','off') |
---|
[252] | 4584 | end |
---|
[2] | 4585 | mode_Callback(hObject, eventdata, handles) |
---|
| 4586 | |
---|
[12] | 4587 | %------------------------------------------------------------------------ |
---|
[2] | 4588 | % --- Executes on button press in get_ref_fix1. |
---|
| 4589 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4590 | %------------------------------------------------------------------------ |
---|
[71] | 4591 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4592 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4593 | {'*.nc', ' (*.nc)'; |
---|
| 4594 | '*.nc', 'netcdf files '; ... |
---|
| 4595 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4596 | 'Pick a file',filebase); |
---|
| 4597 | |
---|
[2] | 4598 | fileinput=[PathName FileName]; |
---|
| 4599 | sizf=size(fileinput); |
---|
[122] | 4600 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4601 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4602 | ref.filebase=fullfile(Path,File); |
---|
| 4603 | ref.num_a=stra2num(str_a); |
---|
| 4604 | ref.num_b=stra2num(str_b); |
---|
[89] | 4605 | ref.num1=str2double(field_count); |
---|
| 4606 | ref.num2=str2double(str2); |
---|
[2] | 4607 | browse=[];%initialisation |
---|
| 4608 | if ~isequal(ref.ext,'.nc') |
---|
| 4609 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4610 | return |
---|
| 4611 | end |
---|
| 4612 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4613 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4614 | menu_field{1}='civ1'; |
---|
| 4615 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4616 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4617 | menu_field{2}='filter1'; |
---|
| 4618 | end |
---|
[45] | 4619 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4620 | menu_field{3}='civ2'; |
---|
| 4621 | end |
---|
[45] | 4622 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4623 | menu_field{4}='filter2'; |
---|
| 4624 | end |
---|
| 4625 | set(handles.field_ref1,'String',menu_field); |
---|
| 4626 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
[287] | 4627 | set(handles.num_MinVel,'Value',2); |
---|
| 4628 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 4629 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4630 | |
---|
| 4631 | %------------------------------------------------------------------------ |
---|
[2] | 4632 | % --- Executes on button press in get_ref_fix2. |
---|
| 4633 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4634 | %------------------------------------------------------------------------ |
---|
[2] | 4635 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4636 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4637 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4638 | {'*.nc', ' (*.nc)'; |
---|
| 4639 | '*.nc', 'netcdf files '; ... |
---|
| 4640 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4641 | 'Pick a file',filebase); |
---|
[2] | 4642 | fileinput=[PathName FileName]; |
---|
| 4643 | sizf=size(fileinput); |
---|
[45] | 4644 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4645 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4646 | ref.filebase=fullfile(Path,File); |
---|
| 4647 | ref.num_a=stra2num(str_a); |
---|
| 4648 | ref.num_b=stra2num(str_b); |
---|
| 4649 | ref.num1=str2num(field_count); |
---|
| 4650 | ref.num2=str2num(str2); |
---|
| 4651 | browse=[];%initialisation |
---|
| 4652 | if ~isequal(ref.ext,'.nc') |
---|
| 4653 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4654 | return |
---|
| 4655 | end |
---|
| 4656 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4657 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4658 | menu_field{1}='civ1'; |
---|
| 4659 | Data=nc2struct(fileinput,[]); |
---|
| 4660 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4661 | menu_field{2}='filter1'; |
---|
| 4662 | end |
---|
| 4663 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4664 | menu_field{3}='civ2'; |
---|
| 4665 | end |
---|
| 4666 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4667 | menu_field{4}='filter2'; |
---|
| 4668 | end |
---|
| 4669 | set(handles.field_ref2,'String',menu_field); |
---|
| 4670 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
[287] | 4671 | set(handles.num_MinVel,'Value',2); |
---|
| 4672 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 4673 | set(handles.ref_fix2,'Enable','on') |
---|
| 4674 | set(handles.ref_fix2,'Visible','on') |
---|
| 4675 | set(handles.field_ref2,'Visible','on') |
---|
| 4676 | else |
---|
| 4677 | set(handles.ref_fix2,'Visible','off') |
---|
| 4678 | set(handles.field_ref2,'Visible','off') |
---|
| 4679 | end |
---|
| 4680 | |
---|
[12] | 4681 | %------------------------------------------------------------------------ |
---|
[2] | 4682 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4683 | %------------------------------------------------------------------------ |
---|
[287] | 4684 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 4685 | set(handles.field_ref1,'Value',1) |
---|
| 4686 | set(handles.field_ref1,'String',{' '}) |
---|
| 4687 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4688 | set(handles.ref_fix1,'String',''); |
---|
| 4689 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4690 | |
---|
[12] | 4691 | %------------------------------------------------------------------------ |
---|
[2] | 4692 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4693 | %------------------------------------------------------------------------ |
---|
[287] | 4694 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 4695 | set(handles.field_ref2,'Value',1) |
---|
| 4696 | set(handles.field_ref2,'String',{' '}) |
---|
| 4697 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4698 | set(handles.ref_fix2,'String',''); |
---|
[287] | 4699 | set(handles.num_MinVel,'String','0'); |
---|
[2] | 4700 | |
---|
[12] | 4701 | %------------------------------------------------------------------------ |
---|
[2] | 4702 | % --- Executes on button press in test_stereo1. |
---|
| 4703 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4704 | %------------------------------------------------------------------------ |
---|
[2] | 4705 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4706 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4707 | set(handles.rho_patch1,'Visible','on') |
---|
| 4708 | else |
---|
| 4709 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4710 | set(handles.rho_patch1,'Visible','off') |
---|
| 4711 | end |
---|
| 4712 | |
---|
[12] | 4713 | %------------------------------------------------------------------------ |
---|
[282] | 4714 | % --- Executes on button press in CheckStereo. |
---|
[273] | 4715 | function StereoCheck_Callback(hObject, eventdata, handles) |
---|
[12] | 4716 | %------------------------------------------------------------------------ |
---|
[282] | 4717 | if isequal(get(handles.CheckStereo,'Value'),0) |
---|
[274] | 4718 | set(handles.num_SubdomainSize,'Visible','on') |
---|
[292] | 4719 | set(handles.num_SmoothingParam,'Visible','on') |
---|
[2] | 4720 | else |
---|
[274] | 4721 | set(handles.num_SubdomainSize,'Visible','off') |
---|
[292] | 4722 | set(handles.num_SmoothingParam,'Visible','off') |
---|
[2] | 4723 | end |
---|
| 4724 | |
---|
[12] | 4725 | %------------------------------------------------------------------------ |
---|
[276] | 4726 | % --- Executes on button press in check_Threshold. |
---|
[2] | 4727 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4728 | %------------------------------------------------------------------------ |
---|
[276] | 4729 | if isequal(get(handles.check_Threshold,'Value'),1) |
---|
[282] | 4730 | set(handles.num_MinIma,'Visible','on') |
---|
| 4731 | set(handles.num_MaxIma,'Visible','on') |
---|
[2] | 4732 | else |
---|
[282] | 4733 | set(handles.num_MinIma,'Visible','off') |
---|
| 4734 | set(handles.num_MaxIma,'Visible','off') |
---|
[2] | 4735 | end |
---|
| 4736 | |
---|
[12] | 4737 | %------------------------------------------------------------------------ |
---|
[2] | 4738 | % --- Executes on button press in ImaThreshold2. |
---|
| 4739 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4740 | %------------------------------------------------------------------------ |
---|
[2] | 4741 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
[287] | 4742 | set(handles.num_MinIma,'Visible','on') |
---|
| 4743 | set(handles.num_MaxIma,'Visible','on') |
---|
[2] | 4744 | else |
---|
[287] | 4745 | set(handles.num_MinIma,'Visible','off') |
---|
| 4746 | set(handles.num_MaxIma,'Visible','off') |
---|
[2] | 4747 | end |
---|
| 4748 | |
---|
[224] | 4749 | %------------------------------------------------------------------------ |
---|
[225] | 4750 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4751 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4752 | %------------------------------------------------------------------------ |
---|
[233] | 4753 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
| 4754 | drawnow |
---|
[150] | 4755 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4756 | if test_civ1 |
---|
[227] | 4757 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4758 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4759 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4760 | else |
---|
| 4761 | ref_j=1;%default |
---|
| 4762 | end |
---|
[224] | 4763 | [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]=... |
---|
[273] | 4764 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[224] | 4765 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4766 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4767 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4768 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4769 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4770 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4771 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4772 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4773 | par_civ1.T0=0; |
---|
| 4774 | par_civ1.Dt=1; |
---|
[246] | 4775 | Param.Civ1=par_civ1; |
---|
| 4776 | Data=civ_uvmat(Param); |
---|
[231] | 4777 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4778 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4779 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4780 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4781 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4782 | hview_field=view_field(Data); |
---|
| 4783 | set(0,'CurrentFigure',hview_field) |
---|
| 4784 | hhview_field=guihandles(hview_field); |
---|
| 4785 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4786 | ViewData=get(hview_field,'UserData'); |
---|
| 4787 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4788 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[236] | 4789 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
| 4790 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
[231] | 4791 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4792 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4793 | if isempty(corrfig) |
---|
| 4794 | corrfig=figure; |
---|
| 4795 | set(corrfig,'tag','corrfig') |
---|
| 4796 | set(corrfig,'name','image correlation') |
---|
| 4797 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4798 | end |
---|
[233] | 4799 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 4800 | else |
---|
| 4801 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4802 | if ~isempty(corrfig) |
---|
| 4803 | delete(corrfig) |
---|
| 4804 | end |
---|
| 4805 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4806 | if ~isempty(hview_field) |
---|
| 4807 | delete(hview_field) |
---|
| 4808 | end |
---|
[150] | 4809 | end |
---|
[71] | 4810 | |
---|
[224] | 4811 | function closeview_field(gcbo,eventdata) |
---|
| 4812 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4813 | if ~isempty(hview_field) |
---|
| 4814 | delete(hview_field) |
---|
| 4815 | end |
---|
[177] | 4816 | %------------------------------------------------------------------- |
---|
| 4817 | % --- Executes on button press in status. |
---|
| 4818 | function status_Callback(hObject, eventdata, handles) |
---|
| 4819 | %------------------------------------------------------------------- |
---|
| 4820 | val=get(handles.status,'Value'); |
---|
| 4821 | if val==0 |
---|
[252] | 4822 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
[177] | 4823 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4824 | if ~isempty(hfig) |
---|
| 4825 | delete(hfig) |
---|
| 4826 | end |
---|
| 4827 | return |
---|
| 4828 | end |
---|
[252] | 4829 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 4830 | drawnow |
---|
[177] | 4831 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
[282] | 4832 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
| 4833 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
| 4834 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
| 4835 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
| 4836 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
| 4837 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
[284] | 4838 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
| 4839 | |
---|
[180] | 4840 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[252] | 4841 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 4842 | test_new=0; |
---|
[177] | 4843 | if ~isfield(filecell,'nc') |
---|
[252] | 4844 | test_new=1; |
---|
[227] | 4845 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 4846 | if ~isempty(errormsg) |
---|
| 4847 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4848 | return |
---|
| 4849 | end |
---|
[252] | 4850 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
[177] | 4851 | end |
---|
| 4852 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
[252] | 4853 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
[177] | 4854 | else |
---|
| 4855 | civ_files=filecell.nc.civ1; |
---|
| 4856 | end |
---|
| 4857 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 4858 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 4859 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4860 | if isempty(hfig) |
---|
[252] | 4861 | hfig=figure('DeleteFcn',@stop_status); |
---|
[177] | 4862 | set(hfig,'name','civ_status') |
---|
[182] | 4863 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[252] | 4864 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
[177] | 4865 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 4866 | 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] | 4867 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 4868 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
[252] | 4869 | drawnow |
---|
[177] | 4870 | end |
---|
[188] | 4871 | % datnum=[]; |
---|
[177] | 4872 | Tabchar={}; |
---|
| 4873 | nbfiles=numel(civ_files); |
---|
| 4874 | count=0; |
---|
[188] | 4875 | testrecent=0; |
---|
[177] | 4876 | while count<nbfiles |
---|
| 4877 | count=0; |
---|
[188] | 4878 | datnum=zeros(1,nbfiles); |
---|
[177] | 4879 | for ifile=1:nbfiles |
---|
| 4880 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 4881 | option=0; |
---|
[177] | 4882 | if detect==0 |
---|
[179] | 4883 | option_str='not created'; |
---|
[177] | 4884 | else |
---|
[219] | 4885 | datfile=dir(civ_files{ifile}); |
---|
[188] | 4886 | if isfield(datfile,'datenum') |
---|
| 4887 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 4888 | testrecent=1; |
---|
| 4889 | end |
---|
[177] | 4890 | filefound(ifile)={datfile.name}; |
---|
| 4891 | lastfield=''; |
---|
| 4892 | % check the content netcdf file |
---|
| 4893 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 4894 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 4895 | option=6; |
---|
| 4896 | option_str='patch2'; |
---|
[177] | 4897 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 4898 | option=5; |
---|
| 4899 | option_str='fix2'; |
---|
[177] | 4900 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 4901 | option=4; |
---|
| 4902 | option_str='civ2'; |
---|
[177] | 4903 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 4904 | option=3; |
---|
| 4905 | option_str='patch1'; |
---|
[177] | 4906 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 4907 | option=2; |
---|
| 4908 | option_str='fix1'; |
---|
[177] | 4909 | else |
---|
[179] | 4910 | option=1; |
---|
| 4911 | option_str='civ1'; |
---|
[177] | 4912 | end |
---|
| 4913 | end |
---|
[179] | 4914 | if option >= option_civ |
---|
[177] | 4915 | count=count+1; |
---|
| 4916 | end |
---|
| 4917 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 4918 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 4919 | end |
---|
[219] | 4920 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 4921 | if isempty(datnum) |
---|
| 4922 | if testrecent |
---|
| 4923 | message='no civ result created yet'; |
---|
| 4924 | else |
---|
| 4925 | message=''; |
---|
| 4926 | end |
---|
[177] | 4927 | else |
---|
[219] | 4928 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 4929 | [first,ind]=min(datnum); |
---|
| 4930 | [last,indlast]=max(datnum); |
---|
[252] | 4931 | if test_new |
---|
| 4932 | message='existing file status, no processing launched yet'; |
---|
| 4933 | else |
---|
[177] | 4934 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 4935 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
[252] | 4936 | end |
---|
[177] | 4937 | end |
---|
| 4938 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
[252] | 4939 | if isempty(hfig)% the status list has been deleted |
---|
[177] | 4940 | return |
---|
| 4941 | else |
---|
| 4942 | hlist=findobj(hfig,'tag','list'); |
---|
| 4943 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 4944 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 4945 | set(hlist,'String',Tabchar) |
---|
| 4946 | set(hmsgbox,'String', message) |
---|
[252] | 4947 | if count>0 && ~test_new |
---|
[177] | 4948 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 4949 | set(hwaitbar,'Position',BarPosition) |
---|
| 4950 | end |
---|
| 4951 | end |
---|
| 4952 | set(hlist,'UserData',rootroot) |
---|
[252] | 4953 | pause(10)% wait 10 seconds for next check |
---|
[177] | 4954 | end |
---|
[150] | 4955 | |
---|
[177] | 4956 | |
---|
[252] | 4957 | %------------------------------------------------------------------------ |
---|
| 4958 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
[177] | 4959 | function open_view_field(hObject, eventdata) |
---|
[252] | 4960 | %------------------------------------------------------------------------ |
---|
| 4961 | list=get(hObject,'String'); |
---|
| 4962 | index=get(hObject,'Value'); |
---|
| 4963 | rootroot=get(hObject,'UserData'); |
---|
| 4964 | filename=list{index}; |
---|
| 4965 | ind_dot=findstr(filename,'...'); |
---|
| 4966 | filename=filename(1:ind_dot-1); |
---|
| 4967 | filename=fullfile(rootroot,filename); |
---|
| 4968 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 4969 | if exist(filename,'file')%visualise the vel field if it exists |
---|
| 4970 | uvmat(filename) |
---|
| 4971 | set(gcbo,'Value',1) |
---|
| 4972 | end |
---|
[150] | 4973 | |
---|
[252] | 4974 | %------------------------------------------------------------------------ |
---|
| 4975 | % launched by pressing OK on the status figure |
---|
[182] | 4976 | function close_GUI(hObject, eventdata) |
---|
[252] | 4977 | %------------------------------------------------------------------------ |
---|
| 4978 | delete(gcbf) |
---|
| 4979 | |
---|
| 4980 | %------------------------------------------------------------------------ |
---|
| 4981 | % launched by deleting the status figure |
---|
| 4982 | function stop_status(hObject, eventdata) |
---|
| 4983 | %------------------------------------------------------------------------ |
---|
| 4984 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 4985 | hhciv=guidata(hciv); |
---|
| 4986 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 4987 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
[220] | 4988 | |
---|
[252] | 4989 | %------------------------------------------------------------------------ |
---|
[282] | 4990 | % % --- Executes on button press in ListPairMode. |
---|
[273] | 4991 | % function CivMode_Callback(hObject, eventdata, handles) |
---|
| 4992 | % %------------------------------------------------------------------------ |
---|
[282] | 4993 | % Listprog=get(handles.ListPairMode,'String'); |
---|
| 4994 | % index=get(handles.ListPairMode,'Value'); |
---|
[273] | 4995 | % prog=Listprog{index}; |
---|
| 4996 | % switch prog |
---|
| 4997 | % case 'CivX' |
---|
| 4998 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 4999 | % set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5000 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5001 | % set(handles.thresh_text2,'Visible','off') |
---|
[282] | 5002 | % set(handles.num_Rho,'Style','edit') |
---|
| 5003 | % set(handles.num_Rho,'String','1') |
---|
[273] | 5004 | % set(handles.BATCH,'Enable','on') |
---|
| 5005 | % case 'CivAll' |
---|
[282] | 5006 | % if get(handles.CheckPatch1,'Value') |
---|
[273] | 5007 | % set(handles.thresh_patch1,'Visible','on') |
---|
| 5008 | % set(handles.thresh_text1,'Visible','on') |
---|
| 5009 | % end |
---|
[282] | 5010 | % set(handles.num_Rho,'Style','edit') |
---|
| 5011 | % set(handles.num_Rho,'String','1') |
---|
[273] | 5012 | % set(handles.BATCH,'Enable','on') |
---|
| 5013 | % case 'CivUvmat' |
---|
| 5014 | % |
---|
| 5015 | % end |
---|
| 5016 | |
---|
| 5017 | |
---|
| 5018 | % -------------------------------------------------------------------- |
---|
| 5019 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[276] | 5020 | path_civ=fileparts(which ('civ')); |
---|
| 5021 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
| 5022 | if isempty(dir(helpfile)) |
---|
| 5023 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
[273] | 5024 | else |
---|
[276] | 5025 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
[273] | 5026 | web([helpfile '#civ']) |
---|
[224] | 5027 | end |
---|
[273] | 5028 | |
---|
| 5029 | % -------------------------------------------------------------------- |
---|
| 5030 | function CivX_Callback(hObject, eventdata, handles) |
---|
| 5031 | %set(handles.thresh_patch1,'Visible','off') |
---|
| 5032 | set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5033 | set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5034 | set(handles.thresh_text2,'Visible','off') |
---|
[282] | 5035 | set(handles.num_Rho,'Style','edit') |
---|
| 5036 | set(handles.num_Rho,'String','1') |
---|
[273] | 5037 | set(handles.BATCH,'Enable','on') |
---|
| 5038 | |
---|
| 5039 | % -------------------------------------------------------------------- |
---|
| 5040 | function Matlab_Callback(hObject, eventdata, handles) |
---|
| 5041 | set(handles.Matlab,'checked','on') |
---|
| 5042 | set(handles.CivX,'checked','off') |
---|
[282] | 5043 | if get(handles.CheckPatch1,'Value') |
---|
[273] | 5044 | set(handles.thresh_patch1,'Visible','on') |
---|
| 5045 | set(handles.thresh_text1,'Visible','on') |
---|
| 5046 | end |
---|
[282] | 5047 | if get(handles.CheckPatch2,'Value') |
---|
[274] | 5048 | set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 5049 | set(handles.thresh_text2,'Visible','on') |
---|
| 5050 | end |
---|
[282] | 5051 | set(handles.num_Rho,'Style','popupmenu') |
---|
| 5052 | set(handles.num_Rho,'Value',1) |
---|
| 5053 | set(handles.num_Rho,'String',{'1';'2'}) |
---|
[273] | 5054 | set(handles.BATCH,'Enable','off') |
---|
| 5055 | |
---|
| 5056 | % -------------------------------------------------------------------- |
---|
| 5057 | % --- read a panel with handle 'handle' producing a structure 'struct' |
---|
| 5058 | function struct=read_panel(handle) |
---|
| 5059 | hchild=get(handle,'children'); |
---|
| 5060 | for ichild=1:numel(hchild) |
---|
[282] | 5061 | if strcmp(get(hchild(ichild),'Visible'),'on') |
---|
| 5062 | object_style=get(hchild(ichild),'Style'); |
---|
| 5063 | tag=get(hchild(ichild),'tag'); |
---|
| 5064 | check_input=1;%default |
---|
| 5065 | switch object_style |
---|
| 5066 | case 'edit' |
---|
| 5067 | switch(tag(1:4)) |
---|
| 5068 | case 'num_' |
---|
| 5069 | input=str2double(get(hchild(ichild),'String')); |
---|
| 5070 | %deal with undefined input: retrieve the default value stored as UserData |
---|
| 5071 | if isnan(input) |
---|
| 5072 | input=get(hchild(ichild),'UserData'); |
---|
| 5073 | set(hchild(ichild),'String',num2str(input)) |
---|
| 5074 | end |
---|
| 5075 | case 'txt_' |
---|
| 5076 | input=get(hchild(ichild),'String'); |
---|
| 5077 | end |
---|
| 5078 | key=tag(5:end); |
---|
| 5079 | case 'checkbox' |
---|
| 5080 | input=get(hchild(ichild),'Value'); |
---|
| 5081 | key=tag(7:end); |
---|
| 5082 | otherwise |
---|
| 5083 | check_input=0; |
---|
| 5084 | end |
---|
| 5085 | if check_input |
---|
| 5086 | eval(['struct.' key '=input;']) |
---|
| 5087 | end |
---|
[273] | 5088 | end |
---|
| 5089 | end |
---|
[284] | 5090 | |
---|
| 5091 | |
---|
| 5092 | |
---|
| 5093 | function cmd=cmd_civ1(filename,Param) |
---|
| 5094 | %TODO : include filename in par_civ1 |
---|
| 5095 | %------------------------------------------------------------------------ |
---|
| 5096 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 5097 | |
---|
| 5098 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 5099 | |
---|
[285] | 5100 | filename=regexprep(filename,'.nc',''); |
---|
[284] | 5101 | |
---|
| 5102 | if isequal(Param.Civ1.Dt,'0') |
---|
| 5103 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
| 5104 | end |
---|
| 5105 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
| 5106 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
| 5107 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
| 5108 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5109 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5110 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5111 | fprintf(fid, ['XX' '\n' ]); |
---|
[285] | 5112 | fprintf(fid, ['Mask ' Param.Civ1.MaskFlag '\n' ]); |
---|
| 5113 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.MaskName,'\\','\\\\') '\n' ]); |
---|
[284] | 5114 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.npx) ' ' num2str(Param.Civ1.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5115 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]); |
---|
[287] | 5116 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]); |
---|
[284] | 5117 | fprintf(fid, ['RO ' num2str(Param.Civ1.Rho) '\n' ]); |
---|
| 5118 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
| 5119 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5120 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.T0) '\n' ]); |
---|
| 5121 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ1.pxcmx) ' ' num2str(Param.Civ1.pxcmy) '\n' ]); |
---|
| 5122 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5123 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' ' num2str(Param.Civ1.Shifty) '\n' ]); |
---|
[285] | 5124 | fprintf(fid, ['Grid ' Param.Civ1.GridFlag '\n' ]); |
---|
| 5125 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]); |
---|
[284] | 5126 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5127 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5128 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5129 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5130 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 5131 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 5132 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5133 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5134 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5135 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5136 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
| 5137 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 5138 | fclose(fid); |
---|
| 5139 | |
---|
| 5140 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 5141 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 5142 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 5143 | if(isunix) |
---|
| 5144 | cmd=['cp -f ' filename '.civ1.cmx ' filename '.cmx \n '];% the cmx file gives the name to the nc file |
---|
| 5145 | cmd=[cmd Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.civ1.log \n ' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 5146 | % cmd=[cmd '\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 |
---|
| 5147 | % cmd=[cmd '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
| 5148 | cmd=[cmd 'rm ' filename '.cmx']; |
---|
| 5149 | else %Windows system |
---|
| 5150 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 5151 | cmd=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx" \n ']; |
---|
| 5152 | cmd=[cmd '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\')... |
---|
| 5153 | '" -f "' filename '.cmx" >"' filename '.civ1.log" \n ' ]; % redirect standard output to the log file |
---|
| 5154 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 5155 | % cmd=[cmd '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
[290] | 5156 | cmd=[cmd 'del "' filename '.cmx"']; |
---|
[284] | 5157 | end |
---|
[285] | 5158 | |
---|
| 5159 | |
---|
| 5160 | function cmd=cmd_fix(filename,Param,fixname) |
---|
| 5161 | %% |
---|
[291] | 5162 | switch fixname |
---|
| 5163 | case 'Fix1' |
---|
| 5164 | fi2_value=num2str(Param.(fixname).CheckF2); |
---|
| 5165 | case 'Fix2' |
---|
| 5166 | fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... |
---|
| 5167 | end |
---|
| 5168 | |
---|
| 5169 | |
---|
| 5170 | |
---|
[285] | 5171 | filename=regexprep(filename,'.nc',''); |
---|
[287] | 5172 | MaskName_string='';%default |
---|
| 5173 | if Param.(fixname).CheckMask |
---|
[288] | 5174 | MaskName_string=[' -maskName "' Param.(fixname).MaskName '"']; |
---|
[287] | 5175 | end |
---|
| 5176 | MaxVel_string='';%default |
---|
| 5177 | if ~isempty(Param.(fixname).MaxVel) |
---|
[289] | 5178 | MaxVel_string=[' -threshV ' num2str(Param.(fixname).MaxVel)]; |
---|
[287] | 5179 | end |
---|
[285] | 5180 | if isunix |
---|
[287] | 5181 | cmd=[Param.xml.FixBin ' -f ' filename '.nc -fi1 ' num2str(Param.(fixname).CheckFmin2) ... |
---|
[291] | 5182 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[287] | 5183 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
| 5184 | ' >' filename '.' lower(fixname) '.log 2>&1']; |
---|
[285] | 5185 | else |
---|
| 5186 | cmd=['"' Param.xml.FixBin '" -f "' filename '.nc" -fi1 ' num2str(Param.(fixname).CheckFmin2)... |
---|
[291] | 5187 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[288] | 5188 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
| 5189 | ' > "' filename '.' lower(fixname) '.log"']; |
---|
[285] | 5190 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 5191 | end |
---|
[286] | 5192 | |
---|
| 5193 | |
---|
| 5194 | function cmd=cmd_patch(filename,Param,patchname) |
---|
| 5195 | %% ------------------------------------------------------------------------ |
---|
| 5196 | filename=regexprep(filename,'.nc',''); |
---|
| 5197 | % if test_interp==0 |
---|
| 5198 | if isunix |
---|
| 5199 | cmd=[Param.xml.PatchBin... |
---|
| 5200 | ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)... |
---|
[292] | 5201 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
[286] | 5202 | ' -nopt ' num2str(Param.(patchname).SubdomainSize) ... |
---|
| 5203 | ' > ' filename '.' lower(patchname) '.log 2>&1']; % redirect standard output to the log file |
---|
| 5204 | else |
---|
| 5205 | cmd=['"' Param.xml.PatchBin... |
---|
| 5206 | '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)... |
---|
[292] | 5207 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
[286] | 5208 | ' -nopt ' num2str(Param.(patchname).SubdomainSize)... |
---|
| 5209 | ' > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file |
---|
| 5210 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 5211 | end |
---|
| 5212 | % else %nouveau programme patch |
---|
| 5213 | % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 5214 | % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 5215 | % end |
---|
[290] | 5216 | |
---|
| 5217 | |
---|
| 5218 | %------------------------------------------------------------------------ |
---|
| 5219 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
| 5220 | function cmd=cmd_civ2(filename,Param) |
---|
| 5221 | %------------------------------------------------------------------------ |
---|
| 5222 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 5223 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
| 5224 | filename=regexprep(filename,'.nc',''); |
---|
| 5225 | if isequal(Param.Civ2.Dt,'0') |
---|
| 5226 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
| 5227 | end |
---|
| 5228 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
| 5229 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
| 5230 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 5231 | if isequal(fid,-1) |
---|
| 5232 | msgbox_uvmat('ERROR',errormsg) |
---|
| 5233 | cmd=''; |
---|
| 5234 | return |
---|
| 5235 | end |
---|
| 5236 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5237 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5238 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5239 | fprintf(fid, ['XX' '\n' ]); |
---|
| 5240 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 5241 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5242 | fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5243 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]); |
---|
| 5244 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']); |
---|
| 5245 | fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']); |
---|
| 5246 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); |
---|
| 5247 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5248 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.T0) '\n' ]); |
---|
| 5249 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ2.pxcmx) ' ' num2str(Param.Civ2.pxcmy) '\n' ]); |
---|
| 5250 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5251 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
| 5252 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 5253 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
| 5254 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5255 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5256 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5257 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5258 | fprintf(fid, ['DecimalShift ' num2str(Param.Civ2.CheckDecimal) '\n']); |
---|
| 5259 | fprintf(fid, ['Deformation ' num2str(Param.Civ2.CheckDeformation) '\n']); |
---|
| 5260 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5261 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5262 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5263 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5264 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 5265 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
| 5266 | fclose(fid); |
---|
| 5267 | |
---|
| 5268 | if(isunix) |
---|
| 5269 | cmd=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n'... |
---|
| 5270 | Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.civ2.log \n '... % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 5271 | 'rm ' filename '.cmx \n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 5272 | else |
---|
| 5273 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 5274 | cmd=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx" \n'... |
---|
| 5275 | '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.civ2.log" \n'... |
---|
| 5276 | 'del "' filename '.cmx" \n']; |
---|
| 5277 | end |
---|