[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 | % %% default first_i and j and increments |
---|
| 407 | % first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 408 | % if isnan(first_i)|| first_i < 1 |
---|
| 409 | % first_i=1; %default first_i |
---|
| 410 | % end |
---|
| 411 | % last_i=str2double(get(handles.last_i,'String')); |
---|
| 412 | % if isnan(last_i)|| last_i < first_i |
---|
| 413 | % last_i=first_i; %default last_i |
---|
| 414 | % end |
---|
| 415 | % first_j=str2double(get(handles.first_j,'String')); |
---|
| 416 | % if isnan(first_j)|| first_j < 1 |
---|
| 417 | % first_j=1; %default first_j |
---|
| 418 | % end |
---|
| 419 | % last_j=str2double(get(handles.last_j,'String')); |
---|
| 420 | % if isnan(last_j)|| last_j < first_j |
---|
| 421 | % last_j=first_j; %default last_j |
---|
| 422 | % end |
---|
| 423 | % incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 424 | % if isnan(incr_i) || incr_i < 1; |
---|
| 425 | % set(handles.incr_i,'String','1') %default incr_i |
---|
| 426 | % end |
---|
| 427 | % incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 428 | % if isnan(incr_j) || incr_j < 1; |
---|
| 429 | % set(handles.incr_j,'String','1') %default incr_j |
---|
| 430 | % end |
---|
[2] | 431 | |
---|
[298] | 432 | %% determine nomenclature types and extension of the input files |
---|
| 433 | ext_ima='';%default |
---|
| 434 | nom_type_ima='';%default |
---|
| 435 | nom_type_nc=''; |
---|
| 436 | [RootPath,FileName,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,subdir]=name2display(fileinput); |
---|
| 437 | RootName=fullfile(RootPath,FileName); |
---|
| 438 | set(handles.RootName,'String',RootName) |
---|
| 439 | num_ref_i=str2double(i1_str); |
---|
| 440 | num_ref_j=str2double(j1_str); |
---|
| 441 | browse=[];%default |
---|
| 442 | 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 |
---|
| 443 | ext_ima=ext_input; |
---|
| 444 | nom_type_ima=nom_type_input; |
---|
| 445 | else %case of netcdf input file, look for corresponding images |
---|
| 446 | nom_type_nc=nom_type_input; |
---|
| 447 | %TODO: read the image name in the netcdf file (if documented) |
---|
| 448 | dirima='';%default |
---|
| 449 | %look for double image series '_i_j' |
---|
| 450 | dirima=dir([RootName '_' i1_str '_' j1_str '.*']); |
---|
| 451 | if isempty(dirima) |
---|
| 452 | % look for images series with sub marker '_' |
---|
| 453 | dirima=dir([RootName '_*' i1_str '.*']); |
---|
| 454 | if isempty(dirima) |
---|
| 455 | % look for other images series |
---|
| 456 | dirima=dir([RootName '*' i1_str '.*']); |
---|
| 457 | if isempty(dirima) |
---|
| 458 | % look for other images series witth letter appendix |
---|
| 459 | appendix=char(96+j1_str); |
---|
| 460 | dirima=dir([RootName '*' i1_str appendix '.*']); |
---|
| 461 | end |
---|
| 462 | end |
---|
[2] | 463 | end |
---|
[298] | 464 | for ilist=1:numel(dirima) |
---|
| 465 | [pp,ff,i1,i2,j1,j2,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 466 | form=imformats(ext_list(2:end)); |
---|
| 467 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 468 | ext_ima=ext_list; |
---|
| 469 | nom_type_ima=nom_type_list; |
---|
| 470 | num_i1=str2double(i1); |
---|
| 471 | num_j1=str2double(j1); |
---|
| 472 | num_i2=str2double(i2); |
---|
| 473 | num_j2=str2double(j2); |
---|
| 474 | |
---|
| 475 | % set the range of fields (1:1 by default) and selected pair |
---|
| 476 | if isequal(num_i2,num_i1)||isnan(num_i2) |
---|
| 477 | num_ref_i=num_i1; |
---|
| 478 | else |
---|
| 479 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 480 | browse.incr_pair(1)=num_i2-num_i1; |
---|
| 481 | browse.incr_pair(2)=0; |
---|
| 482 | end |
---|
| 483 | if isequal(num_j1,num_j2)||isnan(num_j2) |
---|
| 484 | if isnan(num_j1) |
---|
| 485 | num_ref_j=1; |
---|
| 486 | else |
---|
| 487 | num_ref_j=num_j1; |
---|
| 488 | end |
---|
| 489 | else |
---|
| 490 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 491 | browse.incr_pair(2)=num_j2-num_j1; |
---|
| 492 | end |
---|
| 493 | break |
---|
| 494 | end |
---|
| 495 | end |
---|
[2] | 496 | end |
---|
[298] | 497 | set(handles.RootName,'UserData',browse); |
---|
| 498 | % ext_imadoc=get(handles.ImaDoc,'String'); |
---|
| 499 | % browse=get(handles.RootName,'UserData');%default |
---|
| 500 | % if isfield(browse,'nom_type_ima') |
---|
| 501 | % nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
| 502 | % end |
---|
| 503 | % if isfield(browse,'ext_ima') |
---|
| 504 | % ext_ima=browse.ext_ima; |
---|
| 505 | % end |
---|
| 506 | % if isfield(browse,'nom_type_nc') |
---|
| 507 | % nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 508 | % end |
---|
| 509 | % if isfield(browse,'num_i1') |
---|
| 510 | % field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 511 | % end |
---|
| 512 | %set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
[2] | 513 | |
---|
[298] | 514 | |
---|
| 515 | %% look for an image documentation file |
---|
| 516 | ext_imadoc='';%default |
---|
| 517 | if exist([RootName '.xml'],'file') |
---|
| 518 | ext_imadoc='.xml'; |
---|
| 519 | elseif exist([RootName '.civxml'],'file') |
---|
| 520 | ext_imadoc='.civxml'; |
---|
| 521 | elseif exist([RootName '.civ'],'file') |
---|
| 522 | ext_imadoc='.civ'; |
---|
| 523 | elseif exist([RootName '.avi'],'file') |
---|
| 524 | ext_imadoc='.avi'; |
---|
| 525 | elseif exist([RootName '.AVI'],'file') |
---|
| 526 | ext_imadoc='.AVI'; |
---|
| 527 | end |
---|
| 528 | set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used |
---|
| 529 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 530 | drawnow |
---|
[2] | 531 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 532 | mode=''; %default |
---|
[298] | 533 | time=[]; |
---|
| 534 | TimeUnit='frame'; %default |
---|
| 535 | CoordUnit='px';%default |
---|
| 536 | pxcmx_search=[];%default |
---|
| 537 | pxcmy_search=[];%default |
---|
| 538 | % first_i=1;%default |
---|
| 539 | % last_i=1;%default |
---|
[128] | 540 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[298] | 541 | [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']); |
---|
[2] | 542 | mode='pair j1-j2'; |
---|
| 543 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 544 | nom_type_ima='_i_j'; |
---|
[2] | 545 | end |
---|
[128] | 546 | elseif isequal(ext_imadoc,'.xml') |
---|
[298] | 547 | [XmlData,warntext]=imadoc2struct([RootName '.xml']); |
---|
[2] | 548 | ext_ima_read=[]; |
---|
| 549 | nom_type_read=[]; |
---|
[12] | 550 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 551 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[298] | 552 | fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 553 | if ~exist(fullname,'file') |
---|
[12] | 554 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 555 | end |
---|
[2] | 556 | end |
---|
[84] | 557 | if isfield(XmlData,'Time') |
---|
[85] | 558 | time=XmlData.Time; |
---|
[84] | 559 | nbfield=size(time,1); |
---|
[122] | 560 | nbfield2=size(time,2); |
---|
[127] | 561 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 562 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 563 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 564 | time=time'; |
---|
[122] | 565 | nbfield=nbfield2; |
---|
| 566 | nbfield2=1; |
---|
[84] | 567 | end |
---|
| 568 | end |
---|
| 569 | end |
---|
[71] | 570 | if isfield(XmlData,'TimeUnit') |
---|
| 571 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 572 | end |
---|
| 573 | pxcmx_search=1; |
---|
| 574 | pxcmy_search=1; |
---|
| 575 | if isfield(XmlData,'GeometryCalib') |
---|
| 576 | tsai=XmlData.GeometryCalib; |
---|
[112] | 577 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 578 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 579 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 580 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 581 | end |
---|
[112] | 582 | if isfield(tsai,'CoordUnit') |
---|
| 583 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 584 | end |
---|
[112] | 585 | end |
---|
[128] | 586 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[298] | 587 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']); |
---|
| 588 | if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']); |
---|
[112] | 589 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 590 | end |
---|
[128] | 591 | nom_type_ima='001a'; |
---|
| 592 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 593 | nom_type_ima='*'; |
---|
[128] | 594 | ext_ima=ext_imadoc; |
---|
[282] | 595 | set(handles.ListPairMode,'Value',1); |
---|
| 596 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[112] | 597 | dt=0.04;%default |
---|
[298] | 598 | if exist([RootName ext_imadoc],'file')==2 |
---|
| 599 | info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie |
---|
[112] | 600 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 601 | nbfield=info.NumFrames;%number of frames |
---|
| 602 | end |
---|
| 603 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 604 | end |
---|
| 605 | if isempty(time) |
---|
| 606 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 607 | end |
---|
[298] | 608 | set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box to yellow color |
---|
[2] | 609 | |
---|
[120] | 610 | |
---|
[298] | 611 | %% timing display |
---|
| 612 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
| 613 | % if isempty(time)|| strcmp(nom_type_ima,'*')||strcmp(nom_type_ima,'') |
---|
| 614 | % % set(handles.ref_i,'Visible','Off')% do not use a reference index to display time intervals |
---|
| 615 | % % set(handles.ref_j,'Visible','Off') |
---|
| 616 | % first_i=1; |
---|
| 617 | % last_i=1; |
---|
| 618 | % else |
---|
| 619 | % % set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 620 | % % set(handles.ref_j,'Visible','On') |
---|
| 621 | % set(handles.ref_i,'String',i1_str) |
---|
| 622 | % set(handles.ref_j,'String',j1_str) |
---|
| 623 | % end |
---|
| 624 | if ~isempty(time) |
---|
[2] | 625 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 626 | nbfield=size(time,1); |
---|
| 627 | nbfield2=size(time,2); |
---|
[273] | 628 | set(handles.ImaDoc,'UserData',time); %store the set of times |
---|
[71] | 629 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 630 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 631 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 632 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 633 | end |
---|
| 634 | end |
---|
[71] | 635 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[273] | 636 | set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); |
---|
[71] | 637 | set(handles.ImaExt,'String',ext_ima) |
---|
[298] | 638 | set(handles.ref_i,'String',num2str(num_ref_i)) |
---|
| 639 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 640 | set(handles.last_i,'String',num2str(num_ref_i));% |
---|
| 641 | set(handles.ref_j,'String',num2str(num_ref_j)) |
---|
| 642 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 643 | set(handles.last_j,'String',num2str(num_ref_j));% |
---|
[2] | 644 | browse.nom_type_ima=nom_type_ima; |
---|
[273] | 645 | set(handles.RootName,'UserData',browse)% store the nomenclature type |
---|
[2] | 646 | |
---|
[298] | 647 | %% set the civ options depending on the input file content |
---|
| 648 | ind_opening=0;%default |
---|
| 649 | if isequal(ext_input,'.nc') |
---|
| 650 | browse.nom_type_nc=nom_type_input; |
---|
| 651 | ind_opening=2;% propose 'fix' as the default option |
---|
| 652 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 653 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 654 | ind_opening=Data.CivStage; |
---|
| 655 | set(handles.ListPairMode,'Value',3) |
---|
| 656 | end |
---|
| 657 | end |
---|
| 658 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
| 659 | for index = 1:ind_opening |
---|
| 660 | set(handles.(ListOptions{index}),'value',0) |
---|
| 661 | end |
---|
| 662 | for index = ind_opening+1:length(ListOptions) |
---|
| 663 | set(handles.(ListOptions{index}),'value',1) |
---|
| 664 | end |
---|
| 665 | update_CivOptions(handles) |
---|
| 666 | |
---|
| 667 | |
---|
[273] | 668 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 669 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 670 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[282] | 671 | set(handles.ListPairMode,'Value',1) |
---|
| 672 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[2] | 673 | elseif (nbfield==1)% simple series in j |
---|
[282] | 674 | set(handles.ListPairMode,'Value',1) |
---|
| 675 | set(handles.ListPairMode,'String',{'series(Dj)'}) |
---|
[2] | 676 | else |
---|
[282] | 677 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 678 | if nbfield2 <= 10 |
---|
[282] | 679 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 680 | end |
---|
| 681 | end |
---|
| 682 | |
---|
[298] | 683 | %% update the subdirectory display |
---|
| 684 | listot=dir(RootPath); |
---|
[273] | 685 | idir=0; |
---|
| 686 | listdir={''};%default |
---|
| 687 | for ilist=1:length(listot) |
---|
| 688 | if listot(ilist).isdir |
---|
| 689 | name=listot(ilist).name; |
---|
| 690 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 691 | idir=idir+1; |
---|
| 692 | listdir{idir,1}=listot(ilist).name; |
---|
| 693 | end |
---|
| 694 | end |
---|
| 695 | end |
---|
[298] | 696 | Value=find(strcmp(subdir,listdir));%search the index of subdir in the cell listdir |
---|
| 697 | if isempty(Value) |
---|
| 698 | ValueCiv1=get(handles.ListSubdirCiv1,'Value'); |
---|
| 699 | if ValueCiv1>numel(listdir) |
---|
| 700 | ValueCiv1=1; |
---|
| 701 | end |
---|
| 702 | set(handles.ListSubdirCiv1,'Value',ValueCiv1) |
---|
| 703 | ValueCiv2=get(handles.ListSubdirCiv2,'Value'); |
---|
| 704 | if ValueCiv2>numel(listdir) |
---|
| 705 | ValueCiv2=1; |
---|
| 706 | end |
---|
| 707 | set(handles.ListSubdirCiv2,'Value',ValueCiv2) |
---|
| 708 | else |
---|
| 709 | set(handles.ListSubdirCiv1,'Value',Value) |
---|
| 710 | set(handles.ListSubdirCiv2,'Value',Value) |
---|
| 711 | end |
---|
[282] | 712 | set(handles.ListSubdirCiv1,'Value',1) |
---|
[289] | 713 | set(handles.ListSubdirCiv2,'Value',1) |
---|
[282] | 714 | set(handles.ListSubdirCiv1,'String',[listdir;'new...']) |
---|
[289] | 715 | set(handles.ListSubdirCiv2,'String',[listdir;'new...']) |
---|
[273] | 716 | if isempty(listdir) |
---|
[298] | 717 | dirname='CIV'; |
---|
[273] | 718 | else |
---|
[298] | 719 | dirname=listdir{1}; %default civ directory name |
---|
[273] | 720 | end |
---|
[289] | 721 | set(handles.txt_SubdirCiv1,'String',dirname) |
---|
| 722 | set(handles.txt_SubdirCiv2,'String',dirname) |
---|
[273] | 723 | |
---|
| 724 | |
---|
[298] | 725 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
| 726 | ListPairMode_Callback([], [], handles) |
---|
| 727 | |
---|
| 728 | %% store the root input filename for future opening |
---|
| 729 | dir_perso=prefdir; |
---|
| 730 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 731 | % RootPath=fileparts(RootName); |
---|
| 732 | if exist(profil_perso,'file') |
---|
| 733 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 734 | else |
---|
| 735 | txt=ver('MATLAB'); |
---|
| 736 | Release=txt.Release; |
---|
| 737 | relnumb=str2double(Release(3:4)); |
---|
| 738 | if relnumb >= 14 |
---|
| 739 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 740 | else |
---|
| 741 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 742 | end |
---|
| 743 | end |
---|
| 744 | |
---|
[12] | 745 | %------------------------------------------------------------------------ |
---|
[282] | 746 | % --- Executes on button press in ListPairMode. |
---|
| 747 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
[12] | 748 | %------------------------------------------------------------------------ |
---|
[273] | 749 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 750 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 751 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 752 | compare=compare_list{val}; |
---|
| 753 | if strcmp(compare,'displacement') |
---|
| 754 | mode='displacement'; |
---|
| 755 | else |
---|
[282] | 756 | mode_list=get(handles.ListPairMode,'String'); |
---|
[236] | 757 | if ischar(mode_list) |
---|
| 758 | mode_list={mode_list}; |
---|
| 759 | end |
---|
[282] | 760 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 761 | mode=mode_list{mode_value}; |
---|
| 762 | end |
---|
| 763 | displ_num=[];%default |
---|
[137] | 764 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 765 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[273] | 766 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 767 | siztime=size(time); |
---|
| 768 | nbfield=siztime(1); |
---|
| 769 | nbfield2=siztime(2); |
---|
| 770 | indchosen=1; %%first pair selected by default |
---|
| 771 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 772 | dt=1; |
---|
| 773 | displ=''; |
---|
| 774 | index=0; |
---|
| 775 | numlist_a=[]; |
---|
| 776 | numlist_B=[]; |
---|
| 777 | %get all the time intervals in bursts |
---|
| 778 | displ_dt=1;%default |
---|
| 779 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 780 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 781 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 782 | index=index+1; |
---|
| 783 | numlist_a(index)=numod_a; |
---|
| 784 | numlist_b(index)=numod_b; |
---|
| 785 | if ~isempty(time) |
---|
[54] | 786 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 787 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 788 | else |
---|
| 789 | displ_dt(index)=1; |
---|
| 790 | end |
---|
| 791 | end |
---|
| 792 | end |
---|
| 793 | [dtsort,indsort]=sort(displ_dt); |
---|
| 794 | if ~isempty(numlist_a) |
---|
| 795 | displ_num(1,:)=numlist_a(indsort); |
---|
| 796 | displ_num(2,:)=numlist_b(indsort); |
---|
| 797 | end |
---|
| 798 | displ_num(3,:)=0; |
---|
| 799 | displ_num(4,:)=0; |
---|
| 800 | set(handles.jtext,'Visible','Off') |
---|
[2] | 801 | set(handles.first_j,'Visible','Off') |
---|
| 802 | set(handles.last_j,'Visible','Off') |
---|
| 803 | set(handles.incr_j,'Visible','Off') |
---|
| 804 | set(handles.nb_field2,'Visible','Off') |
---|
| 805 | set(handles.ref_j,'Visible','Off') |
---|
| 806 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 807 | for index=1:min(nbfield2-1,200) |
---|
| 808 | displ_num(1,index)=-floor(index/2); |
---|
| 809 | displ_num(2,index)=ceil(index/2); |
---|
| 810 | displ_num(3,index)=0; |
---|
| 811 | displ_num(4,index)=0; |
---|
| 812 | end |
---|
| 813 | set(handles.jtext,'Visible','On') |
---|
| 814 | set(handles.first_j,'Visible','On') |
---|
| 815 | set(handles.last_j,'Visible','On') |
---|
| 816 | set(handles.incr_j,'Visible','On') |
---|
| 817 | set(handles.nb_field2,'Visible','On') |
---|
| 818 | set(handles.ref_j,'Visible','On') |
---|
| 819 | if nbfield > 1 |
---|
[2] | 820 | set(handles.itext,'Visible','On') |
---|
| 821 | set(handles.first_i,'Visible','On') |
---|
| 822 | set(handles.last_i,'Visible','On') |
---|
| 823 | set(handles.incr_i,'Visible','On') |
---|
| 824 | set(handles.nb_field,'Visible','On') |
---|
| 825 | set(handles.ref_i,'Visible','On') |
---|
| 826 | else |
---|
| 827 | set(handles.itext,'Visible','Off') |
---|
| 828 | set(handles.first_i,'Visible','Off') |
---|
| 829 | set(handles.last_i,'Visible','Off') |
---|
| 830 | set(handles.incr_i,'Visible','Off') |
---|
| 831 | set(handles.nb_field,'Visible','Off') |
---|
| 832 | set(handles.ref_i,'Visible','Off') |
---|
| 833 | end |
---|
[112] | 834 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 835 | for index=1:200%min(nbfield-1,200) |
---|
| 836 | displ_num(1,index)=0; |
---|
| 837 | displ_num(2,index)=0; |
---|
| 838 | displ_num(3,index)=-floor(index/2); |
---|
| 839 | displ_num(4,index)=ceil(index/2); |
---|
| 840 | end |
---|
| 841 | set(handles.itext,'Visible','On') |
---|
| 842 | set(handles.first_i,'Visible','On') |
---|
| 843 | set(handles.last_i,'Visible','On') |
---|
| 844 | set(handles.incr_i,'Visible','On') |
---|
| 845 | set(handles.nb_field,'Visible','On') |
---|
| 846 | set(handles.ref_i,'Visible','On') |
---|
| 847 | if nbfield2 > 1 |
---|
[2] | 848 | set(handles.jtext,'Visible','On') |
---|
| 849 | set(handles.first_j,'Visible','On') |
---|
| 850 | set(handles.last_j,'Visible','On') |
---|
| 851 | set(handles.incr_j,'Visible','On') |
---|
| 852 | set(handles.nb_field2,'Visible','On') |
---|
| 853 | set(handles.ref_j,'Visible','On') |
---|
[112] | 854 | else |
---|
[2] | 855 | set(handles.jtext,'Visible','Off') |
---|
| 856 | set(handles.first_j,'Visible','Off') |
---|
| 857 | set(handles.last_j,'Visible','Off') |
---|
| 858 | set(handles.incr_j,'Visible','Off') |
---|
| 859 | set(handles.nb_field2,'Visible','Off') |
---|
| 860 | set(handles.ref_j,'Visible','Off') |
---|
| 861 | end |
---|
| 862 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 863 | displ_num(1,1)=0; |
---|
| 864 | displ_num(2,1)=0; |
---|
| 865 | displ_num(3,1)=0; |
---|
| 866 | displ_num(4,1)=0; |
---|
| 867 | if nbfield > 1 |
---|
[2] | 868 | set(handles.itext,'Visible','On') |
---|
| 869 | set(handles.first_i,'Visible','On') |
---|
| 870 | set(handles.last_i,'Visible','On') |
---|
| 871 | set(handles.incr_i,'Visible','On') |
---|
| 872 | set(handles.nb_field,'Visible','On') |
---|
| 873 | set(handles.ref_i,'Visible','On') |
---|
| 874 | else |
---|
| 875 | set(handles.itext,'Visible','Off') |
---|
| 876 | set(handles.first_i,'Visible','Off') |
---|
| 877 | set(handles.last_i,'Visible','Off') |
---|
| 878 | set(handles.incr_i,'Visible','Off') |
---|
| 879 | set(handles.nb_field,'Visible','Off') |
---|
| 880 | set(handles.ref_i,'Visible','Off') |
---|
| 881 | end |
---|
| 882 | if nbfield2 > 1 |
---|
[112] | 883 | set(handles.jtext,'Visible','On') |
---|
| 884 | set(handles.first_j,'Visible','On') |
---|
| 885 | set(handles.last_j,'Visible','On') |
---|
| 886 | set(handles.incr_j,'Visible','On') |
---|
| 887 | set(handles.nb_field2,'Visible','On') |
---|
| 888 | set(handles.ref_j,'Visible','On') |
---|
[2] | 889 | else |
---|
| 890 | set(handles.jtext,'Visible','Off') |
---|
| 891 | set(handles.first_j,'Visible','Off') |
---|
| 892 | set(handles.last_j,'Visible','Off') |
---|
| 893 | set(handles.incr_j,'Visible','Off') |
---|
| 894 | set(handles.nb_field2,'Visible','Off') |
---|
| 895 | set(handles.ref_j,'Visible','Off') |
---|
| 896 | end |
---|
[112] | 897 | end |
---|
[282] | 898 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
[296] | 899 | find_netcpair_civ1( handles) |
---|
| 900 | find_netcpair_civ2(handles) |
---|
[2] | 901 | |
---|
[12] | 902 | %------------------------------------------------------------------------ |
---|
[282] | 903 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
[2] | 904 | % the field series set by first_i, incr, last_i |
---|
[289] | 905 | function find_netcpair_civ1(handles) |
---|
[12] | 906 | %------------------------------------------------------------------------ |
---|
[2] | 907 | set(gcf,'Pointer','watch') |
---|
| 908 | %nomenclature types |
---|
[71] | 909 | filebase=get(handles.RootName,'String'); |
---|
[2] | 910 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 911 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 912 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 913 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 914 | compare=compare_list{val}; |
---|
| 915 | if strcmp(compare,'displacement') |
---|
| 916 | mode='displacement'; |
---|
| 917 | else |
---|
[282] | 918 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 919 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[273] | 920 | if isempty(mode_list) |
---|
| 921 | return |
---|
| 922 | end |
---|
[2] | 923 | mode=mode_list{mode_value}; |
---|
| 924 | end |
---|
| 925 | |
---|
| 926 | % nomenclature type of the .nc files |
---|
| 927 | nom_type_ima=[];%default |
---|
| 928 | if isfield(browse,'nom_type_ima') |
---|
| 929 | nom_type_ima=browse.nom_type_ima; |
---|
| 930 | end |
---|
| 931 | |
---|
[112] | 932 | %determine nom_type_nc: |
---|
[2] | 933 | nom_type_nc=[];%default |
---|
| 934 | if isfield(browse,'nom_type_nc') |
---|
| 935 | nom_type_nc=browse.nom_type_nc; |
---|
| 936 | end |
---|
| 937 | if isempty(nom_type_nc) |
---|
[112] | 938 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 939 | end |
---|
| 940 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 941 | set(handles.RootName,'UserData',browse) |
---|
[2] | 942 | |
---|
| 943 | %reads .nc subdirectoy and image numbers from the interface |
---|
[289] | 944 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 945 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 946 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 947 | ref_j=0; |
---|
| 948 | else |
---|
[45] | 949 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 950 | end |
---|
[273] | 951 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[2] | 952 | if isempty(time) |
---|
| 953 | time=[0 1]; |
---|
[112] | 954 | end |
---|
[71] | 955 | dt_unit=1000;%default |
---|
[282] | 956 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[2] | 957 | |
---|
[112] | 958 | %eliminate the first pairs inconsistent with the position |
---|
| 959 | if isempty(displ_num) |
---|
| 960 | nbpair=0; |
---|
| 961 | else |
---|
[2] | 962 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 963 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 964 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 965 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 966 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 967 | end |
---|
[112] | 968 | end |
---|
[2] | 969 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 970 | |
---|
[282] | 971 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
[2] | 972 | % be performed, while the result is needed for next steps. |
---|
| 973 | displ_pair={''}; |
---|
[273] | 974 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
[2] | 975 | testpair=0; |
---|
[282] | 976 | % case with no checkciv1 operation, netcdf files need to exist for reading |
---|
[298] | 977 | if ~get(handles.CheckCiv1,'Value') % |
---|
[112] | 978 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 979 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
[282] | 980 | set(handles.ListPairCiv1,'String',{}); |
---|
[112] | 981 | return |
---|
[2] | 982 | end |
---|
[112] | 983 | for ipair=1:nbpair |
---|
[2] | 984 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 985 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[273] | 986 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 987 | end |
---|
| 988 | % case of no displayed pair |
---|
| 989 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 990 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
[2] | 991 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 992 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 993 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 994 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 995 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 996 | select(1)=exist(filename,'file')==2; |
---|
| 997 | testpair=1; |
---|
| 998 | else |
---|
[112] | 999 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1000 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1001 | else |
---|
| 1002 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1003 | end |
---|
[282] | 1004 | set(handles.ListPairCiv1,'String',{''}); |
---|
[112] | 1005 | %COMPLETER CAS STEREO |
---|
[2] | 1006 | return |
---|
| 1007 | end |
---|
| 1008 | end |
---|
| 1009 | end |
---|
| 1010 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1011 | if testpair |
---|
[73] | 1012 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1013 | else |
---|
[73] | 1014 | for ipair=1:nbpair |
---|
| 1015 | if select(ipair) |
---|
| 1016 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1017 | 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 |
---|
| 1018 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1019 | else |
---|
| 1020 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1021 | end |
---|
| 1022 | end |
---|
| 1023 | end |
---|
[2] | 1024 | end |
---|
| 1025 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1026 | if testpair |
---|
[112] | 1027 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1028 | else |
---|
[112] | 1029 | for ipair=1:nbpair |
---|
| 1030 | if select(ipair) |
---|
| 1031 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1032 | 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 |
---|
| 1033 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1034 | end |
---|
| 1035 | elseif testpair |
---|
| 1036 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1037 | else |
---|
| 1038 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1039 | end |
---|
| 1040 | end |
---|
| 1041 | end |
---|
[2] | 1042 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1043 | for ipair=1:nbpair |
---|
| 1044 | if select(ipair) |
---|
[112] | 1045 | 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 |
---|
| 1046 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1047 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1048 | else |
---|
| 1049 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1050 | end |
---|
| 1051 | end |
---|
[2] | 1052 | elseif isequal(mode,'displacement') |
---|
[112] | 1053 | displ_pair={'Di=Dj=0'}; |
---|
| 1054 | end |
---|
[282] | 1055 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
[229] | 1056 | ichoice=find(select,1); |
---|
[45] | 1057 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[282] | 1058 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
[112] | 1059 | if initial>nbpair |
---|
[282] | 1060 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1061 | end |
---|
| 1062 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[282] | 1063 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[2] | 1064 | end |
---|
[45] | 1065 | |
---|
[282] | 1066 | %set(handles.ListPairCiv2,'String',displ_pair'); |
---|
| 1067 | initial=get(handles.ListPairCiv2,'Value'); |
---|
[2] | 1068 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1069 | if ichoice <= length(displ_pair') |
---|
[282] | 1070 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
[2] | 1071 | else |
---|
[282] | 1072 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
[2] | 1073 | end |
---|
| 1074 | end |
---|
[282] | 1075 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
[2] | 1076 | set(gcf,'Pointer','arrow') |
---|
[12] | 1077 | |
---|
| 1078 | %------------------------------------------------------------------------ |
---|
[282] | 1079 | % determine the menu for checkciv2 pairs depending on the existing netcdf file at the |
---|
[112] | 1080 | %middle of the series set by first_i, incr, last_i |
---|
[289] | 1081 | function find_netcpair_civ2(handles) |
---|
[12] | 1082 | %------------------------------------------------------------------------ |
---|
[2] | 1083 | set(gcf,'Pointer','watch') |
---|
| 1084 | %nomenclature types |
---|
[71] | 1085 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1086 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 1087 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 1088 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 1089 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 1090 | compare=compare_list{val}; |
---|
| 1091 | if strcmp(compare,'displacement') |
---|
| 1092 | mode='displacement'; |
---|
| 1093 | else |
---|
[282] | 1094 | mode_list=get(handles.ListPairMode,'String'); |
---|
[270] | 1095 | if isempty(mode_list) |
---|
| 1096 | msgbox_uvmat('ERROR','please enter an input image or netcdf file') |
---|
| 1097 | return |
---|
| 1098 | end |
---|
[282] | 1099 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1100 | mode=mode_list{mode_value}; |
---|
| 1101 | end |
---|
| 1102 | |
---|
| 1103 | % nomenclature type of the .nc files |
---|
| 1104 | nom_type_ima='ima_num';%default |
---|
| 1105 | if isfield(browse,'nom_type_ima') |
---|
| 1106 | nom_type_ima=browse.nom_type_ima; |
---|
| 1107 | end |
---|
| 1108 | nom_type_nc='_i1-i2';%default |
---|
| 1109 | if isfield(browse,'nom_type_nc') |
---|
| 1110 | nom_type_nc=browse.nom_type_nc; |
---|
| 1111 | end |
---|
[94] | 1112 | 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] | 1113 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1114 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1115 | nom_type_nc='none'; |
---|
[94] | 1116 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1117 | nom_type_nc='_i1-i2'; |
---|
[2] | 1118 | else |
---|
| 1119 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1120 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1121 | else |
---|
| 1122 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1123 | end |
---|
[2] | 1124 | end |
---|
| 1125 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 1126 | set(handles.RootName,'UserData',browse) |
---|
[2] | 1127 | |
---|
| 1128 | %reads .nc subdirectory and image numbers from the interface |
---|
[289] | 1129 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1130 | subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1131 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1132 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1133 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1134 | % num1=first_i:incr:last_i; |
---|
| 1135 | % if isempty(num1) |
---|
[282] | 1136 | % set(handles.ListPairCiv2,'Value',1); |
---|
| 1137 | % set(handles.ListPairCiv2,'String',{''}); |
---|
[45] | 1138 | % return |
---|
| 1139 | % end |
---|
[273] | 1140 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1141 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1142 | ref_j=0; |
---|
| 1143 | else |
---|
[273] | 1144 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1145 | end |
---|
[273] | 1146 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 1147 | if isempty(time) |
---|
| 1148 | time=[0 1];%default |
---|
| 1149 | end |
---|
[71] | 1150 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1151 | %dt_unit=1000; |
---|
[282] | 1152 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[2] | 1153 | |
---|
| 1154 | |
---|
[112] | 1155 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1156 | if isempty(displ_num) |
---|
| 1157 | nbpair=0; |
---|
| 1158 | else |
---|
| 1159 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1160 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1161 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1162 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1163 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1164 | end |
---|
| 1165 | end |
---|
| 1166 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1167 | |
---|
[282] | 1168 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
[2] | 1169 | % be performed, while the result is needed for next steps. |
---|
| 1170 | displ_pair={''}; %default |
---|
| 1171 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
[298] | 1172 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[112] | 1173 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1174 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
[282] | 1175 | set(handles.ListPairCiv2,'Value',1); |
---|
| 1176 | set(handles.ListPairCiv2,'String',{''}); |
---|
[112] | 1177 | return |
---|
[2] | 1178 | end |
---|
[112] | 1179 | for ipair=1:nbpair |
---|
[2] | 1180 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1181 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1182 | select(ipair)=exist(filename,'file')==2; |
---|
| 1183 | end |
---|
| 1184 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1185 | if isfield(browse,'incr_pair') |
---|
[2] | 1186 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1187 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1188 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1189 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1190 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1191 | select(1)=exist(filename,'file')==2; |
---|
| 1192 | else |
---|
[112] | 1193 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1194 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1195 | else |
---|
| 1196 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1197 | end |
---|
[282] | 1198 | set(handles.ListPairCiv2,'Value',1); |
---|
| 1199 | set(handles.ListPairCiv2,'String',{''}); |
---|
[2] | 1200 | return |
---|
| 1201 | end |
---|
| 1202 | end |
---|
| 1203 | end |
---|
[112] | 1204 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1205 | for ipair=1:nbpair |
---|
| 1206 | if select(ipair) |
---|
| 1207 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1208 | 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 |
---|
| 1209 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1210 | end |
---|
| 1211 | else |
---|
| 1212 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1213 | end |
---|
| 1214 | end |
---|
[2] | 1215 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1216 | for ipair=1:nbpair |
---|
| 1217 | if select(ipair) |
---|
| 1218 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1219 | 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 |
---|
| 1220 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1221 | end |
---|
| 1222 | else |
---|
| 1223 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1224 | end |
---|
| 1225 | end |
---|
[2] | 1226 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1227 | for ipair=1:nbpair |
---|
| 1228 | if select(ipair) |
---|
[112] | 1229 | 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 |
---|
| 1230 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1231 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1232 | else |
---|
| 1233 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1234 | end |
---|
| 1235 | end |
---|
[2] | 1236 | elseif isequal(mode,'displacement') |
---|
[112] | 1237 | displ_pair={'Di=Dj=0'}; |
---|
| 1238 | end |
---|
[282] | 1239 | val=get(handles.ListPairCiv2,'Value'); |
---|
[229] | 1240 | ichoice=find(select,1); |
---|
[137] | 1241 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[282] | 1242 | if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 |
---|
[2] | 1243 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1244 | end |
---|
| 1245 | if val>length(displ_pair') |
---|
[282] | 1246 | set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu |
---|
[2] | 1247 | else |
---|
[282] | 1248 | set(handles.ListPairCiv2,'Value',val); |
---|
[2] | 1249 | end |
---|
[282] | 1250 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
[12] | 1251 | set(gcf,'Pointer','arrow') |
---|
[2] | 1252 | |
---|
| 1253 | |
---|
[41] | 1254 | |
---|
[227] | 1255 | |
---|
[12] | 1256 | %------------------------------------------------------------------------ |
---|
[282] | 1257 | % --- Executes on selection change in ListPairCiv1. |
---|
| 1258 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 1259 | %------------------------------------------------------------------------ |
---|
[282] | 1260 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
| 1261 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 1262 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
| 1263 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[137] | 1264 | % num_a=displ_num(1,index_pair); |
---|
| 1265 | % num_b=displ_num(2,index_pair); |
---|
[282] | 1266 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
[2] | 1267 | if index_pair<=length(list_pair2) |
---|
[282] | 1268 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
[2] | 1269 | end |
---|
| 1270 | |
---|
[112] | 1271 | %update first_i and last_i according to the chosen image pairs |
---|
[282] | 1272 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1273 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1274 | mode=mode_list{mode_value}; |
---|
| 1275 | if isequal(mode,'series(Di)') |
---|
[137] | 1276 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1277 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1278 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1279 | num1=first_i:incr_i:last_i; |
---|
[137] | 1280 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1281 | if ~isnan(lastfield) |
---|
[229] | 1282 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1283 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1284 | num1=num1(test_find); |
---|
[2] | 1285 | end |
---|
| 1286 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1287 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1288 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1289 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1290 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1291 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1292 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1293 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1294 | if ~isnan(lastfield2) |
---|
[229] | 1295 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1296 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1297 | num1=num_j(test_find); |
---|
[2] | 1298 | end |
---|
| 1299 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1300 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1301 | end |
---|
[2] | 1302 | |
---|
[12] | 1303 | %------------------------------------------------------------------------ |
---|
[282] | 1304 | % --- Executes on selection change in ListPairCiv2. |
---|
| 1305 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 1306 | %------------------------------------------------------------------------ |
---|
[282] | 1307 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
[2] | 1308 | |
---|
[112] | 1309 | %update first_i and last_i according to the chosen image pairs |
---|
[282] | 1310 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1311 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1312 | mode=mode_list{mode_value}; |
---|
| 1313 | if isequal(mode,'series(Di)') |
---|
[137] | 1314 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1315 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1316 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1317 | num1=first_i:incr_i:last_i; |
---|
[137] | 1318 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1319 | if ~isnan(lastfield) |
---|
[229] | 1320 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1321 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1322 | num1=num1(test_find); |
---|
[2] | 1323 | end |
---|
| 1324 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1325 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1326 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1327 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1328 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1329 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1330 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1331 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1332 | if ~isnan(lastfield2) |
---|
[229] | 1333 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1334 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1335 | num1=num_j(test_find); |
---|
[2] | 1336 | end |
---|
| 1337 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1338 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1339 | end |
---|
[2] | 1340 | |
---|
[177] | 1341 | %------------------------------------------------------------------------ |
---|
| 1342 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1343 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1344 | %------------------------------------------------------------------------ |
---|
[73] | 1345 | set(handles.RUN, 'Enable','Off') |
---|
| 1346 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1347 | batch=0; |
---|
[229] | 1348 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1349 | set(handles.RUN, 'Enable','On') |
---|
| 1350 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1351 | |
---|
[177] | 1352 | % start status callback to visualise results |
---|
[229] | 1353 | if ~isempty(errormsg) |
---|
| 1354 | display(errormsg) |
---|
| 1355 | msgbox_uvmat('ERROR',errormsg) |
---|
[282] | 1356 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
[225] | 1357 | set(handles.status,'Value',1);%suppress status display |
---|
| 1358 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1359 | end |
---|
[177] | 1360 | |
---|
[12] | 1361 | %------------------------------------------------------------------------ |
---|
[2] | 1362 | % --- Executes on button press in BATCH: remote processing |
---|
| 1363 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1364 | % ----------------------------------------------------------------------- |
---|
[73] | 1365 | set(handles.BATCH, 'Enable','Off') |
---|
| 1366 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1367 | batch=1; |
---|
[229] | 1368 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1369 | set(handles.BATCH, 'Enable','On') |
---|
| 1370 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1371 | |
---|
[177] | 1372 | % start status callback to visualise results |
---|
[229] | 1373 | if ~isempty(errormsg) |
---|
| 1374 | display(errormsg) |
---|
| 1375 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1376 | elseif isfield(handles,'status') |
---|
| 1377 | set(handles.status,'Value',1);%suppress status display |
---|
| 1378 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1379 | end |
---|
[227] | 1380 | |
---|
[67] | 1381 | %------------------------------------------------------------------------ |
---|
[133] | 1382 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1383 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1384 | %----------------------------------------------------------------------- |
---|
[229] | 1385 | errormsg='';%default |
---|
[272] | 1386 | |
---|
[282] | 1387 | %%read the civ GUI |
---|
[289] | 1388 | Param=read_GUI(handles.civ); |
---|
[133] | 1389 | %% check the selected list of operations: |
---|
[289] | 1390 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
[282] | 1391 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
[284] | 1392 | |
---|
[180] | 1393 | index_first=find(box_test==1,1); |
---|
| 1394 | if isempty(index_first) |
---|
[229] | 1395 | errormsg='no selected operation'; |
---|
[2] | 1396 | return |
---|
| 1397 | end |
---|
[180] | 1398 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1399 | box_used=box_test(index_first : index_last); |
---|
[2] | 1400 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1401 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1402 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1403 | return |
---|
| 1404 | end |
---|
| 1405 | |
---|
[272] | 1406 | %% check mask if selecetd |
---|
| 1407 | %could be included in get_mask callback ? |
---|
[282] | 1408 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[276] | 1409 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1410 | if ~exist(maskname,'file') |
---|
| 1411 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1412 | end |
---|
[2] | 1413 | end |
---|
[282] | 1414 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1415 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1416 | if ~exist(maskname,'file') |
---|
| 1417 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1418 | end |
---|
[2] | 1419 | end |
---|
[282] | 1420 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[276] | 1421 | maskname=get(handles.txt_Mask,'String'); |
---|
[12] | 1422 | if ~exist(maskname,'file') |
---|
[112] | 1423 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1424 | end |
---|
[2] | 1425 | end |
---|
[282] | 1426 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[287] | 1427 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1428 | if ~exist(maskname,'file') |
---|
[112] | 1429 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1430 | end |
---|
[2] | 1431 | end |
---|
| 1432 | |
---|
[177] | 1433 | %% reinitialise status callback |
---|
[178] | 1434 | if isfield(handles,'status') |
---|
[180] | 1435 | set(handles.status,'Value',0);%suppress status display |
---|
| 1436 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1437 | end |
---|
[133] | 1438 | |
---|
| 1439 | %% set the list of files and check them |
---|
| 1440 | display('checking the files...') |
---|
[227] | 1441 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1442 | if ~isempty(errormsg) |
---|
| 1443 | return |
---|
| 1444 | end |
---|
[263] | 1445 | [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] | 1446 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[274] | 1447 | % ADDED |
---|
| 1448 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) |
---|
| 1449 | %ADDED |
---|
[177] | 1450 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1451 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1452 | return |
---|
| 1453 | end |
---|
| 1454 | nbfield=numel(num1_civ1); |
---|
| 1455 | nbslice=numel(num_a_civ1); |
---|
| 1456 | |
---|
[272] | 1457 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[276] | 1458 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
[112] | 1459 | xmlfile='PARAM.xml'; |
---|
[133] | 1460 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1461 | t=xmltree(xmlfile); |
---|
[67] | 1462 | s=convert(t); |
---|
[272] | 1463 | else |
---|
| 1464 | errormsg=['no file ' xmlfile]; |
---|
| 1465 | return |
---|
[2] | 1466 | end |
---|
[272] | 1467 | |
---|
| 1468 | test_interp=0; %eviter les variables test_ (LG) |
---|
| 1469 | |
---|
[127] | 1470 | if batch |
---|
[67] | 1471 | if isfield(s,'BatchParam') |
---|
[284] | 1472 | Param.xml=s.BatchParam; |
---|
| 1473 | if isfield(Param.xml,'BatchMode') |
---|
| 1474 | batch_mode=Param.xml.BatchMode; |
---|
[257] | 1475 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1476 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1477 | return |
---|
| 1478 | end |
---|
[67] | 1479 | end |
---|
| 1480 | else |
---|
[229] | 1481 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1482 | return |
---|
| 1483 | end |
---|
[257] | 1484 | else % run |
---|
[67] | 1485 | if isfield(s,'RunParam') |
---|
[284] | 1486 | Param.xml=s.RunParam; |
---|
[67] | 1487 | else |
---|
[225] | 1488 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1489 | return |
---|
| 1490 | end |
---|
[225] | 1491 | end |
---|
[238] | 1492 | |
---|
[272] | 1493 | %% check batch mode supported |
---|
| 1494 | if batch |
---|
| 1495 | switch batch_mode |
---|
| 1496 | case 'sge' |
---|
| 1497 | test_command='qstat'; |
---|
| 1498 | case 'oar' |
---|
[290] | 1499 | test_command='oarstat'; |
---|
[272] | 1500 | end |
---|
| 1501 | [s,w]=system(test_command); |
---|
| 1502 | if ~isequal(s,0) |
---|
| 1503 | msgbox_uvmat('ERROR',[batch_mode ' batch system not available']) |
---|
| 1504 | return |
---|
| 1505 | end |
---|
| 1506 | end |
---|
| 1507 | |
---|
| 1508 | %% check if the binaries exist |
---|
[273] | 1509 | if isequal(get(handles.Matlab,'checked'),'on') |
---|
| 1510 | CivMode='Matlab'; |
---|
| 1511 | else |
---|
| 1512 | CivMode='CivX'; |
---|
| 1513 | end |
---|
[280] | 1514 | binary_list={}; |
---|
[257] | 1515 | switch CivMode |
---|
[280] | 1516 | case 'CivX' |
---|
| 1517 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
| 1518 | case 'CivAll' |
---|
[289] | 1519 | binary_list={'Civ'}; |
---|
[257] | 1520 | case 'Matlab' |
---|
| 1521 | if batch |
---|
[272] | 1522 | % vérifier Matlab installé sur le cluster |
---|
| 1523 | % difficile a faire a priori |
---|
[257] | 1524 | end |
---|
[225] | 1525 | end |
---|
[280] | 1526 | for bin_name=binary_list |
---|
[284] | 1527 | if isfield(Param.xml,bin_name{1}) |
---|
| 1528 | 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] | 1529 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
[280] | 1530 | if exist(fullname,'file') |
---|
[284] | 1531 | Param.xml.(bin_name{1})=fullname; |
---|
[280] | 1532 | else |
---|
[284] | 1533 | msgbox_uvmat('ERROR',['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist']) |
---|
[280] | 1534 | return |
---|
| 1535 | end |
---|
| 1536 | else |
---|
[284] | 1537 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
[280] | 1538 | currentdir=pwd; |
---|
| 1539 | cd(path); |
---|
| 1540 | binpath=pwd;%path of the binary |
---|
[284] | 1541 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
| 1542 | % display(Param.xml.(bin_name{1})); |
---|
[280] | 1543 | cd(currentdir); |
---|
| 1544 | end |
---|
| 1545 | |
---|
| 1546 | end |
---|
| 1547 | end |
---|
[2] | 1548 | |
---|
[272] | 1549 | display('files OK, processing...') |
---|
[2] | 1550 | |
---|
| 1551 | |
---|
[133] | 1552 | %% MAIN LOOP |
---|
[273] | 1553 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[265] | 1554 | |
---|
[134] | 1555 | super_cmd=[]; |
---|
[269] | 1556 | batch_file_list=[]; |
---|
[265] | 1557 | |
---|
[2] | 1558 | for ifile=1:nbfield |
---|
| 1559 | for j=1:nbslice |
---|
[257] | 1560 | % initiate system command |
---|
| 1561 | switch CivMode |
---|
| 1562 | case 'CivX' |
---|
| 1563 | if isunix % check: necessaire aussi en RUN? |
---|
[272] | 1564 | cmd=['#!/bin/bash \n '... |
---|
| 1565 | '#$ -cwd \n '... |
---|
| 1566 | 'hostname && date \n '... |
---|
| 1567 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 1568 | else |
---|
| 1569 | cmd=[]; |
---|
[257] | 1570 | end |
---|
| 1571 | case 'CivAll' |
---|
| 1572 | % if CivAll |
---|
| 1573 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1574 | CivAllCmd=''; |
---|
| 1575 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1576 | end |
---|
[272] | 1577 | |
---|
| 1578 | |
---|
| 1579 | % define output file name |
---|
[282] | 1580 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
[272] | 1581 | OutputFile=filecell.nc.civ2{ifile,j}; |
---|
| 1582 | else |
---|
| 1583 | OutputFile=filecell.nc.civ1{ifile,j}; |
---|
| 1584 | end |
---|
| 1585 | OutputFile=regexprep(OutputFile,'.nc',''); |
---|
[269] | 1586 | |
---|
[282] | 1587 | if Param.CheckCiv1 |
---|
[272] | 1588 | % read image-dependent parameters |
---|
[284] | 1589 | Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
| 1590 | Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
| 1591 | Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 1592 | Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 1593 | Param.Civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1594 | Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[285] | 1595 | Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
| 1596 | Param.Civ1.pxcmy=1; |
---|
[284] | 1597 | |
---|
[285] | 1598 | A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 1599 | sizim=size(A); |
---|
| 1600 | Param.Civ1.npx=(sizim(2)); |
---|
| 1601 | Param.Civ1.npy=(sizim(1)); |
---|
| 1602 | %TODO : civ should not need npx and npy |
---|
[284] | 1603 | |
---|
[272] | 1604 | % read mask parameters |
---|
[284] | 1605 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
| 1606 | %matbe they when check_mask the Maskname is read |
---|
[285] | 1607 | if exist(Param.Civ1.MaskName,'file') |
---|
| 1608 | Param.Civ1.MaskFlag='y'; |
---|
[2] | 1609 | else |
---|
[285] | 1610 | maskbase=[filecell.filebase '_' Param.Civ1.MaskName]; % |
---|
[137] | 1611 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1612 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[285] | 1613 | Param.Civ1.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1614 | if exist(Param.Civ1.MaskName,'file') |
---|
[284] | 1615 | Param.Civ1.maskflag='y'; |
---|
[12] | 1616 | else |
---|
[285] | 1617 | Param.Civ1.MaskName='noFile use default'; |
---|
| 1618 | Param.Civ1.MaskFlag='n'; |
---|
[12] | 1619 | end |
---|
[2] | 1620 | end |
---|
[272] | 1621 | else |
---|
[285] | 1622 | Param.Civ1.MaskName='noFile use default'; |
---|
| 1623 | Param.Civ1.MaskFlag='n'; |
---|
[2] | 1624 | end |
---|
[272] | 1625 | |
---|
[282] | 1626 | % read grid parameters= |
---|
[284] | 1627 | if Param.Civ1.CheckGrid |
---|
[285] | 1628 | Param.Civ1.GridFlag='y'; |
---|
| 1629 | if isequal(Param.Civ1.GridName(end-3:end),'grid') |
---|
| 1630 | nbslice_grid=str2double(Param.Civ1.GridName(1:end-4)); % |
---|
[137] | 1631 | if ~isnan(nbslice_grid) |
---|
[2] | 1632 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[285] | 1633 | Param.Civ1.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1634 | if ~exist(Param.Civ1.GridName,'file') |
---|
[112] | 1635 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1636 | end |
---|
[285] | 1637 | elseif ~exist(Param.Civ1.GridName,'file') |
---|
[2] | 1638 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1639 | end |
---|
| 1640 | end |
---|
| 1641 | else |
---|
[285] | 1642 | Param.Civ1.GridName='noFile use default'; |
---|
| 1643 | Param.Civ1.GridFlag='n'; |
---|
[2] | 1644 | end |
---|
[257] | 1645 | |
---|
[285] | 1646 | % send command |
---|
[257] | 1647 | switch CivMode |
---|
| 1648 | case 'CivX' |
---|
[284] | 1649 | cmd=[cmd... |
---|
| 1650 | cmd_civ1(filecell.nc.civ1{ifile,j},Param) '\n']; |
---|
[257] | 1651 | case 'CivAll' |
---|
| 1652 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
[284] | 1653 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',Param.Civ1); |
---|
[257] | 1654 | fieldnames=fields(str); |
---|
| 1655 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 1656 | for ilist=1:length(fieldnames) |
---|
| 1657 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1658 | if ischar(val) |
---|
| 1659 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1660 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1661 | end |
---|
[112] | 1662 | end |
---|
[2] | 1663 | end |
---|
| 1664 | end |
---|
| 1665 | |
---|
[282] | 1666 | if Param.CheckFix1 |
---|
[272] | 1667 | switch CivMode |
---|
[257] | 1668 | case 'CivX' |
---|
[285] | 1669 | cmd=[cmd... |
---|
| 1670 | cmd_fix(filecell.nc.civ1{ifile,j},Param,'Fix1') '\n']; |
---|
[257] | 1671 | case 'CivAll' |
---|
| 1672 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[272] | 1673 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
| 1674 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
| 1675 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
| 1676 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
| 1677 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
[257] | 1678 | fieldnames=fields(fix1); |
---|
| 1679 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 1680 | for ilist=1:length(fieldnames) |
---|
| 1681 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1682 | if ischar(val) |
---|
| 1683 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1684 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1685 | end |
---|
| 1686 | end |
---|
| 1687 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1688 | end |
---|
| 1689 | end |
---|
| 1690 | |
---|
[282] | 1691 | %CheckPatch1 |
---|
| 1692 | if Param.CheckPatch1==1 |
---|
[257] | 1693 | switch CivMode |
---|
| 1694 | case 'CivX' |
---|
[286] | 1695 | cmd=[cmd... |
---|
| 1696 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch1') '\n']; |
---|
[257] | 1697 | case 'CivAll' |
---|
| 1698 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1699 | patch1.nopt=subdomain_patch1; |
---|
| 1700 | patch1.maxdiff=thresh_patch1; |
---|
| 1701 | patch1.ro=rho_patch1; |
---|
| 1702 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1703 | if test_grid |
---|
| 1704 | patch1.gridflag='y'; |
---|
| 1705 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1706 | if isequal(gridname(end-3:end),'grid') |
---|
| 1707 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1708 | if ~isnan(nbslice_grid) |
---|
| 1709 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 1710 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1711 | if ~exist(patch1.gridPatch,'file') |
---|
| 1712 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1713 | end |
---|
| 1714 | elseif exist(gridname,'file') |
---|
| 1715 | patch1.gridPatch=gridname; |
---|
| 1716 | else |
---|
[112] | 1717 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1718 | end |
---|
[2] | 1719 | end |
---|
[257] | 1720 | else |
---|
| 1721 | patch1.gridPatch='none'; |
---|
| 1722 | patch1.gridflag='n'; |
---|
| 1723 | patch1.m=nx_patch1; |
---|
| 1724 | patch1.n=ny_patch1; |
---|
[2] | 1725 | end |
---|
[257] | 1726 | patch1.convectFlow='n'; |
---|
| 1727 | fieldnames=fields(patch1); |
---|
| 1728 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 1729 | for ilist=1:length(fieldnames) |
---|
| 1730 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1731 | if ischar(val) |
---|
| 1732 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1733 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1734 | end |
---|
[112] | 1735 | end |
---|
[257] | 1736 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1737 | end |
---|
[2] | 1738 | end |
---|
[282] | 1739 | if Param.CheckCiv2==1 |
---|
[290] | 1740 | Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1741 | Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 1742 | Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 1743 | Param.Civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 1744 | Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 1745 | Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 1746 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1747 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
| 1748 | Param.Civ2.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
| 1749 | Param.Civ2.pxcmy=1; |
---|
[287] | 1750 | if Param.Civ2.CheckMask |
---|
[276] | 1751 | maskdispl=get(handles.txt_Mask,'String'); |
---|
[12] | 1752 | if exist(maskdispl,'file') |
---|
[290] | 1753 | Param.Civ2.MaskName=maskdispl; |
---|
| 1754 | Param.Civ2.MaskFlag='y'; |
---|
[2] | 1755 | else |
---|
[136] | 1756 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1757 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1758 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[290] | 1759 | Param.Civ2.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1760 | if exist(Param.Civ2.MaskName,'file') |
---|
| 1761 | Param.Civ2.MaskFlag='y'; |
---|
[12] | 1762 | else |
---|
[290] | 1763 | Param.Civ2.MaskName='noFile use default'; |
---|
| 1764 | Param.Civ2.MaskFlag='n'; |
---|
[12] | 1765 | end |
---|
[2] | 1766 | end |
---|
[287] | 1767 | else |
---|
[290] | 1768 | Param.Civ2.MaskName='noFile use default'; |
---|
| 1769 | Param.Civ2.MaskFlag='n'; |
---|
[2] | 1770 | end |
---|
[276] | 1771 | gridname=get(handles.txt_GridName,'String'); |
---|
[2] | 1772 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1773 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1774 | if ~isnan(nbslice_grid) |
---|
[290] | 1775 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1776 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[290] | 1777 | Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1778 | if exist(Param.Civ2.GridName,'file') |
---|
| 1779 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1780 | else |
---|
[290] | 1781 | Param.Civ2.GridName='noFile use default'; |
---|
| 1782 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1783 | end |
---|
| 1784 | elseif exist(gridname,'file') |
---|
[290] | 1785 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1786 | else |
---|
[290] | 1787 | Param.Civ2.GridName='noFile use default'; |
---|
| 1788 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1789 | end |
---|
[290] | 1790 | else |
---|
| 1791 | Param.Civ2.GridName='noFile use default'; |
---|
| 1792 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1793 | end |
---|
[290] | 1794 | A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size |
---|
| 1795 | sizim=size(A); |
---|
| 1796 | Param.Civ2.npx=(sizim(2)); |
---|
| 1797 | Param.Civ2.npy=(sizim(1)); |
---|
| 1798 | |
---|
[257] | 1799 | switch CivMode |
---|
| 1800 | case 'CivX' |
---|
[290] | 1801 | cmd=[cmd... |
---|
| 1802 | cmd_civ2(filecell.nc.civ2{ifile,j},Param) '\n']; |
---|
[257] | 1803 | case 'CivAll' |
---|
| 1804 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
[290] | 1805 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',Param.Civ2); |
---|
[257] | 1806 | fieldnames=fields(str); |
---|
| 1807 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 1808 | for ilist=1:length(fieldnames) |
---|
| 1809 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1810 | if ischar(val) |
---|
| 1811 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 1812 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1813 | end |
---|
[2] | 1814 | end |
---|
| 1815 | end |
---|
[112] | 1816 | end |
---|
| 1817 | |
---|
[282] | 1818 | % CheckFix2 |
---|
| 1819 | if Param.CheckFix2==1 |
---|
[257] | 1820 | switch CivMode |
---|
| 1821 | case 'CivX' |
---|
[291] | 1822 | cmd=[cmd... |
---|
| 1823 | cmd_fix(filecell.nc.civ2{ifile,j},Param,'Fix2') '\n']; |
---|
[257] | 1824 | case 'CivAll' |
---|
| 1825 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 1826 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 1827 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 1828 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 1829 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 1830 | fix2.threshV=num2str(thresh_vel2); |
---|
| 1831 | fieldnames=fields(fix2); |
---|
| 1832 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 1833 | for ilist=1:length(fieldnames) |
---|
| 1834 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 1835 | if ischar(val) |
---|
| 1836 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 1837 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1838 | end |
---|
| 1839 | end |
---|
| 1840 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 1841 | end |
---|
| 1842 | end |
---|
| 1843 | |
---|
[282] | 1844 | %CheckPatch2 |
---|
| 1845 | if Param.CheckPatch2==1 |
---|
[257] | 1846 | switch CivMode |
---|
| 1847 | case 'CivX' |
---|
[291] | 1848 | cmd=[cmd... |
---|
| 1849 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch2') '\n']; |
---|
[257] | 1850 | case 'CivAll' |
---|
| 1851 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1852 | patch2.nopt=subdomain_patch2; |
---|
| 1853 | patch2.maxdiff=thresh_patch2; |
---|
| 1854 | patch2.ro=rho_patch2; |
---|
| 1855 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 1856 | if test_grid |
---|
| 1857 | patch2.gridflag='y'; |
---|
| 1858 | gridname=get(handles.grid_patch2,'String'); |
---|
| 1859 | if isequal(gridname(end-3:end),'grid') |
---|
| 1860 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1861 | if ~isnan(nbslice_grid) |
---|
| 1862 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 1863 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1864 | if ~exist(patch2.gridPatch,'file') |
---|
| 1865 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 1866 | end |
---|
| 1867 | elseif exist(gridname,'file') |
---|
| 1868 | patch2.gridPatch=gridname; |
---|
| 1869 | else |
---|
[112] | 1870 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 1871 | end |
---|
[2] | 1872 | end |
---|
[257] | 1873 | else |
---|
| 1874 | patch2.gridPatch='none'; |
---|
| 1875 | patch2.gridflag='n'; |
---|
| 1876 | patch2.m=nx_patch2; |
---|
| 1877 | patch2.n=ny_patch2; |
---|
[2] | 1878 | end |
---|
[257] | 1879 | patch2.convectFlow='n'; |
---|
| 1880 | fieldnames=fields(patch2); |
---|
| 1881 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 1882 | for ilist=1:length(fieldnames) |
---|
| 1883 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 1884 | if ischar(val) |
---|
| 1885 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 1886 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1887 | end |
---|
[112] | 1888 | end |
---|
[257] | 1889 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 1890 | end |
---|
[12] | 1891 | end |
---|
[257] | 1892 | |
---|
| 1893 | switch CivMode |
---|
| 1894 | case {'CivX','CivAll'} |
---|
| 1895 | if isequal(CivMode,'CivAll') |
---|
[272] | 1896 | save(CivAllxml,[OutputFile '.xml']); |
---|
| 1897 | cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; |
---|
[238] | 1898 | end |
---|
[272] | 1899 | |
---|
| 1900 | % create the .bat file used in run or batch |
---|
| 1901 | filename_bat=[OutputFile '.bat']; |
---|
[257] | 1902 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1903 | if isequal(fid,-1) |
---|
| 1904 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 1905 | return |
---|
[238] | 1906 | end |
---|
[257] | 1907 | fprintf(fid,cmd); |
---|
| 1908 | fclose(fid); |
---|
[269] | 1909 | |
---|
[279] | 1910 | if isunix |
---|
| 1911 | system(['chmod +x ' filename_bat]); |
---|
| 1912 | end |
---|
| 1913 | |
---|
[269] | 1914 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
| 1915 | |
---|
| 1916 | % if batch |
---|
| 1917 | % switch batch_mode |
---|
| 1918 | % case 'sge' |
---|
| 1919 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 1920 | % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 1921 | % case 'oar' |
---|
| 1922 | % % eval( ['!chmod +x ' filename_bat]); |
---|
| 1923 | % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
| 1924 | % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]); |
---|
| 1925 | % |
---|
| 1926 | % cmd_str=['sh ' filename_bat]; |
---|
| 1927 | % super_cmd{length(super_cmd)+1}=cmd_str; |
---|
| 1928 | % |
---|
| 1929 | % end |
---|
| 1930 | % else |
---|
| 1931 | % %% to lauch the jobs locally : |
---|
| 1932 | % if(isunix) |
---|
| 1933 | % cmd_str=['. ' filename_bat]; |
---|
| 1934 | % else %case of Windows |
---|
| 1935 | % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
| 1936 | % end |
---|
| 1937 | % super_cmd=[super_cmd cmd_str '\n']; |
---|
| 1938 | % disp(cmd_str); |
---|
| 1939 | % end |
---|
[257] | 1940 | case 'Matlab' |
---|
| 1941 | drawnow |
---|
[282] | 1942 | if Param.CheckCiv1==1 |
---|
[284] | 1943 | Param.Civ1=Param.Civ1; |
---|
[252] | 1944 | end |
---|
[282] | 1945 | if Param.CheckFix1==1 |
---|
[257] | 1946 | fix1.WarnFlags=[]; |
---|
[282] | 1947 | if get(handles.CheckFmin2,'Value') |
---|
[257] | 1948 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 1949 | end |
---|
[282] | 1950 | if get(handles.CheckF3,'Value') |
---|
[257] | 1951 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 1952 | end |
---|
| 1953 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
[287] | 1954 | if get(handles.num_MinVel,'Value') |
---|
[257] | 1955 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 1956 | else |
---|
| 1957 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 1958 | end |
---|
[282] | 1959 | if get(handles.CheckMask,'Value') |
---|
[257] | 1960 | fix1.MaskName=maskname; |
---|
| 1961 | end |
---|
| 1962 | Param.Fix1=fix1; |
---|
[252] | 1963 | end |
---|
[282] | 1964 | if Param.CheckPatch1==1 |
---|
[263] | 1965 | if strcmp(compare,'stereo PIV') |
---|
| 1966 | filebase_A=filecell.filebase; |
---|
| 1967 | [pp,ff]=fileparts(filebase_A); |
---|
| 1968 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 1969 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1970 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1971 | else |
---|
| 1972 | Param.Patch1.Rho=rho_patch1; |
---|
| 1973 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 1974 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 1975 | end |
---|
[257] | 1976 | end |
---|
[282] | 1977 | if Param.CheckCiv2==1 |
---|
[290] | 1978 | Param.Civ2=Param.Civ2; |
---|
[257] | 1979 | end |
---|
[282] | 1980 | if Param.CheckFix2==1 |
---|
[257] | 1981 | fix2.WarnFlags=[]; |
---|
[287] | 1982 | if get(handles.CheckFmin2,'Value') |
---|
[257] | 1983 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 1984 | end |
---|
[287] | 1985 | if get(handles.CheckF4,'Value') |
---|
[257] | 1986 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 1987 | end |
---|
[287] | 1988 | if get(handles.CheckF3,'Value') |
---|
[257] | 1989 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 1990 | end |
---|
| 1991 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
[287] | 1992 | if get(handles.num_MinVel,'Value') |
---|
[257] | 1993 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 1994 | else |
---|
| 1995 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 1996 | end |
---|
[282] | 1997 | if get(handles.CheckMask,'Value') |
---|
[257] | 1998 | fix2.MaskName=maskname; |
---|
| 1999 | end |
---|
| 2000 | Param.Fix2=fix2; |
---|
| 2001 | end |
---|
[282] | 2002 | if Param.CheckPatch2==1 |
---|
[263] | 2003 | if strcmp(compare,'stereo PIV') |
---|
| 2004 | filebase_A=filecell.filebase; |
---|
| 2005 | [pp,ff]=fileparts(filebase_A); |
---|
| 2006 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2007 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 2008 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
[270] | 2009 | else |
---|
| 2010 | Param.Patch2.Rho=rho_patch2; |
---|
| 2011 | Param.Patch2.Threshold=thresh_patch2; |
---|
| 2012 | Param.Patch2.SubDomain=subdomain_patch2; |
---|
[263] | 2013 | end |
---|
[257] | 2014 | end |
---|
[263] | 2015 | if ~strcmp(compare,'stereo PIV') |
---|
| 2016 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
| 2017 | if isempty(errormsg) |
---|
| 2018 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2019 | else |
---|
| 2020 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2021 | end |
---|
[270] | 2022 | |
---|
[263] | 2023 | end |
---|
[257] | 2024 | end |
---|
[112] | 2025 | end |
---|
[2] | 2026 | end |
---|
[134] | 2027 | |
---|
[265] | 2028 | if batch |
---|
[269] | 2029 | switch batch_mode |
---|
| 2030 | case 'sge' |
---|
| 2031 | for p=1:length(batch_file_list) |
---|
| 2032 | cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 2033 | display(cmd);eval(cmd); |
---|
| 2034 | end |
---|
[279] | 2035 | case 'oar_old' |
---|
| 2036 | for p=1:length(batch_file_list) |
---|
| 2037 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
| 2038 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 2039 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
| 2040 | display(oar_command);eval(oar_command); |
---|
[290] | 2041 | end |
---|
| 2042 | case 'oar' %oar-dispatch.pl |
---|
[279] | 2043 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2044 | fid=fopen(filename_joblist,'w'); |
---|
| 2045 | |
---|
| 2046 | for p=1:length(batch_file_list) |
---|
| 2047 | oar_command=['oarsub -n CIVX '... |
---|
[297] | 2048 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
[279] | 2049 | '-l "/core=1,walltime=00:10:00" ' batch_file_list{p}]; |
---|
| 2050 | fprintf(fid,[oar_command '\n']); |
---|
[265] | 2051 | end |
---|
[290] | 2052 | fclose(fid); |
---|
[297] | 2053 | ncores=36; |
---|
| 2054 | walltime=datestr(length(batch_file_list)*10/24/60/ncores,13); |
---|
| 2055 | oar_command=['oarsub -t container -n civx-container '... |
---|
| 2056 | '-l /core=' num2str(ncores) ',walltime=' walltime... |
---|
| 2057 | ' "oar-dispatch -f ' filename_joblist '"']; |
---|
[279] | 2058 | filename_oarcommand=fullfile(Rootbat,'oar_command'); |
---|
| 2059 | fid=fopen(filename_oarcommand,'w'); |
---|
| 2060 | fprintf(fid,[oar_command '\n']); |
---|
| 2061 | fclose(fid); |
---|
[290] | 2062 | display(oar_command); |
---|
| 2063 | eval(['! . ' filename_oarcommand]) |
---|
| 2064 | case 'oar_mpi' |
---|
[279] | 2065 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2066 | fid=fopen(filename_joblist,'w'); |
---|
| 2067 | |
---|
| 2068 | for p=1:length(batch_file_list) |
---|
| 2069 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
[265] | 2070 | end |
---|
[279] | 2071 | fclose(fid) |
---|
| 2072 | |
---|
| 2073 | |
---|
| 2074 | % oarsub -S ./oar.sub |
---|
| 2075 | |
---|
| 2076 | |
---|
| 2077 | |
---|
| 2078 | |
---|
| 2079 | |
---|
[269] | 2080 | case 'oar_new' % to be develloped with Patrick Begou |
---|
| 2081 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2082 | fid=fopen(filename_superbat,'w'); |
---|
| 2083 | if fid==-1 |
---|
| 2084 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2085 | return |
---|
[265] | 2086 | end |
---|
[269] | 2087 | for p=1:length(batch_file_list) |
---|
| 2088 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 2089 | end |
---|
| 2090 | fclose(fid); |
---|
| 2091 | walltime=datestr(length(super_cmd)*10/24/60,13); |
---|
| 2092 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); |
---|
| 2093 | end |
---|
| 2094 | else |
---|
| 2095 | if ~isequal(CivMode,'Matlab') |
---|
| 2096 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
| 2097 | fid=fopen(filename_superbat,'w'); |
---|
| 2098 | if fid==-1 |
---|
| 2099 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2100 | return |
---|
| 2101 | end |
---|
| 2102 | for p=1:length(batch_file_list) |
---|
| 2103 | if isunix |
---|
| 2104 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 2105 | else |
---|
| 2106 | fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']); |
---|
[265] | 2107 | end |
---|
[269] | 2108 | end |
---|
| 2109 | fclose(fid); |
---|
| 2110 | if(isunix) |
---|
| 2111 | system(['chmod +x ' filename_superbat]); |
---|
| 2112 | end |
---|
| 2113 | system([filename_superbat ' &']);% execute main commmand |
---|
[265] | 2114 | end |
---|
[269] | 2115 | |
---|
[265] | 2116 | end |
---|
| 2117 | |
---|
[2] | 2118 | |
---|
[137] | 2119 | %% save interface state |
---|
[2] | 2120 | if isfield(filecell,'nc') |
---|
| 2121 | if isfield(filecell.nc,'civ2') |
---|
| 2122 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2123 | else |
---|
| 2124 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2125 | end |
---|
| 2126 | end |
---|
| 2127 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2128 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2129 | detect=1; |
---|
[2] | 2130 | while detect==1 |
---|
| 2131 | namefigfull=[namedoc '.fig']; |
---|
| 2132 | hh=dir(namefigfull); |
---|
| 2133 | if ~isempty(hh) |
---|
| 2134 | detect=1; |
---|
| 2135 | namedoc=[namedoc '.0']; |
---|
| 2136 | else |
---|
| 2137 | detect=0; |
---|
| 2138 | end |
---|
| 2139 | end |
---|
| 2140 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2141 | |
---|
[273] | 2142 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 2143 | MenuFile={}; |
---|
| 2144 | dir_perso=prefdir; |
---|
| 2145 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 2146 | if exist(profil_perso,'file') |
---|
| 2147 | hh=load (profil_perso); |
---|
| 2148 | if isfield(hh,'MenuFile') |
---|
| 2149 | MenuFile=hh.MenuFile; |
---|
| 2150 | end |
---|
[289] | 2151 | if isfield(filecell.nc,'civ2') |
---|
| 2152 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
| 2153 | else |
---|
| 2154 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
| 2155 | end |
---|
[273] | 2156 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 2157 | else |
---|
| 2158 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 2159 | save (profil_perso,'MenuFile') |
---|
| 2160 | end |
---|
| 2161 | |
---|
| 2162 | |
---|
[227] | 2163 | %------------------------------------------------------------------------ |
---|
| 2164 | % --- determine the list of reference indices of processing file |
---|
| 2165 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2166 | %------------------------------------------------------------------------ |
---|
| 2167 | errormsg=''; %default error message |
---|
| 2168 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2169 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2170 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2171 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2172 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2173 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2174 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2175 | else |
---|
| 2176 | first_j=1; |
---|
| 2177 | last_j=1; |
---|
| 2178 | incr_j=1; |
---|
| 2179 | end |
---|
| 2180 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2181 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2182 | if isnan(first_i)||isnan(first_j) |
---|
| 2183 | errormsg='first field number not defined'; |
---|
| 2184 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2185 | errormsg='last field number not defined'; |
---|
| 2186 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2187 | errormsg='increment in field number not defined'; |
---|
| 2188 | elseif last_i < first_i || last_j < first_j |
---|
| 2189 | errormsg='last field number must be larger than the first one'; |
---|
| 2190 | end |
---|
[134] | 2191 | |
---|
[227] | 2192 | %------------------------------------------------------------------------ |
---|
| 2193 | % --- determine the list of filenames and indices needed for launch_job |
---|
[263] | 2194 | 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] | 2195 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
[12] | 2196 | %------------------------------------------------------------------------ |
---|
[85] | 2197 | filecell=[];%default |
---|
[136] | 2198 | |
---|
| 2199 | %% get the root names nomenclature and numbers |
---|
[71] | 2200 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2201 | |
---|
| 2202 | if isempty(filebase)||isequal(filebase,'') |
---|
[298] | 2203 | msgbox_uvmat('ERROR','please open an image with the upper menu option Open/Browse...') |
---|
[136] | 2204 | return |
---|
| 2205 | end |
---|
| 2206 | |
---|
[137] | 2207 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2208 | filecell.filebase=filebase; |
---|
| 2209 | |
---|
[273] | 2210 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 2211 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2212 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 2213 | compare=compare_list{val}; |
---|
| 2214 | if strcmp(compare,'displacement') |
---|
| 2215 | mode='displacement'; |
---|
| 2216 | else |
---|
[282] | 2217 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2218 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 2219 | mode=mode_list{mode_value}; |
---|
| 2220 | end |
---|
[137] | 2221 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2222 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2223 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2224 | if isfield(browse,'nom_type_ima') |
---|
| 2225 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2226 | end |
---|
| 2227 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2228 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2229 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2230 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[282] | 2231 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
[2] | 2232 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2233 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2234 | % test_disp=1; |
---|
[2] | 2235 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2236 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2237 | Path1=Path2; |
---|
[71] | 2238 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2239 | filebase_A=fullfile(Path1,Name1); |
---|
| 2240 | if length(Name1)>6 |
---|
| 2241 | Name1=Name1(end-5:end); |
---|
| 2242 | end |
---|
| 2243 | if length(Name2)>6 |
---|
| 2244 | Name2=Name2(end-5:end); |
---|
| 2245 | end |
---|
| 2246 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2247 | else |
---|
[127] | 2248 | % test_disp=0; |
---|
[2] | 2249 | filebase_A=filebase; |
---|
| 2250 | nom_type_ima1=nom_type_ima2; |
---|
| 2251 | filebase_AB=filebase; |
---|
| 2252 | end |
---|
| 2253 | if strcmp(compare,'displacement') |
---|
[112] | 2254 | filebase_ima1=filebase_A; |
---|
| 2255 | filebase_ima2=filebase_B; |
---|
| 2256 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2257 | else |
---|
[112] | 2258 | filebase_ima1=filebase_B; |
---|
| 2259 | filebase_ima2=filebase_B; |
---|
| 2260 | filebase_nc=filebase_B; |
---|
| 2261 | end |
---|
[2] | 2262 | |
---|
| 2263 | %determine reference files for fix: |
---|
| 2264 | file_ref_fix1={};%default |
---|
| 2265 | file_ref_fix2={}; |
---|
| 2266 | nbfield=length(num1_civ1); |
---|
| 2267 | nbslice=length(num_a_civ1); |
---|
[282] | 2268 | if checkbox(2)==1% fix1 performed |
---|
[2] | 2269 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2270 | if ~isempty(ref) |
---|
[137] | 2271 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2272 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2273 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2274 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2275 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2276 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2277 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2278 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2279 | if isequal(mode,'displacement') |
---|
| 2280 | num_i1=num_i_ref; |
---|
| 2281 | num_i2=num_i_ref; |
---|
| 2282 | num_j1=num_j_ref; |
---|
| 2283 | num_j2=num_j_ref; |
---|
| 2284 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2285 | num_i1=num_i_ref; |
---|
| 2286 | num_i2=num_i1; |
---|
| 2287 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2288 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2289 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2290 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2291 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2292 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2293 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2294 | if isempty(ref.num_a) |
---|
| 2295 | ref.num_a=1; |
---|
| 2296 | end |
---|
| 2297 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2298 | num_j2=num_j1; |
---|
| 2299 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2300 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2301 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2302 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2303 | num_i2=num_i1; |
---|
| 2304 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2305 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2306 | end |
---|
| 2307 | for ifile=1:nbfield |
---|
| 2308 | for j=1:nbslice |
---|
| 2309 | 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);% |
---|
| 2310 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2311 | if ~exist(file_ref,'file') |
---|
| 2312 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2313 | filecell=[]; |
---|
[2] | 2314 | return |
---|
| 2315 | end |
---|
| 2316 | end |
---|
| 2317 | end |
---|
| 2318 | end |
---|
| 2319 | end |
---|
| 2320 | |
---|
[282] | 2321 | %determine reference files for checkfix2: |
---|
| 2322 | if checkbox(5)==1% fix2 performed |
---|
[2] | 2323 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2324 | if ~isempty(ref) |
---|
[127] | 2325 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2326 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2327 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2328 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2329 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2330 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2331 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2332 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2333 | if isequal(mode,'displacement') |
---|
| 2334 | num_i1=num_i_ref; |
---|
| 2335 | num_i2=num_i_ref; |
---|
| 2336 | num_j1=num_j_ref; |
---|
| 2337 | num_j2=num_j_ref; |
---|
| 2338 | elseif isequal(mode,'pair j1-j2') |
---|
| 2339 | num_i1=num_i_ref; |
---|
| 2340 | num_i2=num_i1; |
---|
| 2341 | num_j1=ref.num_a; |
---|
| 2342 | num_j2=ref.num_b; |
---|
| 2343 | elseif isequal(mode,'series(Di)') |
---|
| 2344 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2345 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2346 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2347 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2348 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2349 | num_j2=num_j1; |
---|
| 2350 | elseif isequal(mode,'series(Dj)') |
---|
| 2351 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2352 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2353 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2354 | num_i2=num_i1; |
---|
| 2355 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2356 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2357 | end |
---|
| 2358 | for ifile=1:nbfield |
---|
| 2359 | for j=1:nbslice |
---|
| 2360 | 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);% |
---|
| 2361 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2362 | if ~exist(file_ref,'file') |
---|
| 2363 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2364 | filecell={}; |
---|
[2] | 2365 | return |
---|
| 2366 | end |
---|
| 2367 | end |
---|
| 2368 | end |
---|
| 2369 | end |
---|
| 2370 | end |
---|
| 2371 | |
---|
| 2372 | %check dir |
---|
[289] | 2373 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2374 | subdir_civ2=get(handles.txt_SubdirCiv2,'String'); |
---|
[174] | 2375 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2376 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[266] | 2377 | % currentdir=pwd;%store the current working directory |
---|
[2] | 2378 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2379 | if ~exist(Path_ima,'dir') |
---|
[12] | 2380 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2381 | filecell={}; |
---|
[2] | 2382 | return |
---|
| 2383 | end |
---|
[127] | 2384 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2385 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2386 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2387 | filecell={}; |
---|
[266] | 2388 | % cd(currentdir); |
---|
[112] | 2389 | return |
---|
[2] | 2390 | end |
---|
| 2391 | |
---|
| 2392 | %check the existence of the netcdf and image files involved |
---|
[282] | 2393 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
| 2394 | if checkbox(1)==1; |
---|
[112] | 2395 | detect=1; |
---|
[127] | 2396 | vers=0; |
---|
| 2397 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2398 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2399 | for ifile=1:nbfield |
---|
[112] | 2400 | for j=1:nbslice |
---|
[122] | 2401 | 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] | 2402 | detect=exist(filename,'file')==2; |
---|
| 2403 | if detect% if a netcdf file already exists |
---|
[137] | 2404 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2405 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2406 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2407 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2408 | else |
---|
| 2409 | vers=vers+1; |
---|
[137] | 2410 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2411 | end |
---|
[137] | 2412 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2413 | break |
---|
| 2414 | end |
---|
| 2415 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2416 | end |
---|
| 2417 | if detect% if a netcdf file already exists |
---|
| 2418 | break |
---|
| 2419 | end |
---|
| 2420 | end |
---|
[134] | 2421 | |
---|
[289] | 2422 | %create the new txt_SubdirCiv1 |
---|
[127] | 2423 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[263] | 2424 | % cd(Path_ima); |
---|
| 2425 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
[134] | 2426 | |
---|
[128] | 2427 | if ~strcmp(msg1,'') |
---|
| 2428 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2429 | filecell={}; |
---|
| 2430 | return |
---|
[163] | 2431 | elseif isunix |
---|
[266] | 2432 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2433 | if ~strcmp(msg2,'') |
---|
[266] | 2434 | msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation |
---|
[128] | 2435 | filecell={}; |
---|
| 2436 | return |
---|
| 2437 | end |
---|
[112] | 2438 | end |
---|
[263] | 2439 | % cd(currentdir); |
---|
[112] | 2440 | end |
---|
| 2441 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2442 | for ifile=1:nbfield |
---|
| 2443 | for j=1:nbslice |
---|
[122] | 2444 | 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] | 2445 | detect=exist(filename,'file')==2; |
---|
[2] | 2446 | if detect% if a netcdf file already exists |
---|
[137] | 2447 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2448 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2449 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2450 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2451 | else |
---|
| 2452 | vers=vers+1; |
---|
[137] | 2453 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2454 | end |
---|
| 2455 | subdir_civ2=subdir_civ1; |
---|
| 2456 | break |
---|
[2] | 2457 | end |
---|
[112] | 2458 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2459 | end |
---|
| 2460 | if detect% if a netcdf file already exists |
---|
| 2461 | break |
---|
| 2462 | end |
---|
| 2463 | end |
---|
[289] | 2464 | %create the new txt_SubdirCiv1 |
---|
[263] | 2465 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2466 | % cd(Path_ima); |
---|
| 2467 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
| 2468 | % cd(currentdir); |
---|
[252] | 2469 | if ~strcmp(msg1,'') |
---|
[128] | 2470 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[263] | 2471 | % cd(currentdir) |
---|
[122] | 2472 | filecell={}; |
---|
| 2473 | return |
---|
[128] | 2474 | else |
---|
[266] | 2475 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2476 | if ~strcmp(msg2,'') |
---|
| 2477 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[263] | 2478 | % cd(currentdir) |
---|
[128] | 2479 | filecell={}; |
---|
| 2480 | return |
---|
| 2481 | end |
---|
[112] | 2482 | end |
---|
| 2483 | end |
---|
| 2484 | end |
---|
| 2485 | end |
---|
[127] | 2486 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2487 | % get image names |
---|
| 2488 | for ifile=1:nbfield |
---|
[112] | 2489 | for j=1:nbslice |
---|
[2] | 2490 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2491 | idetect(j)=exist(filename,'file')==2; |
---|
| 2492 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2493 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2494 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2495 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2496 | end |
---|
| 2497 | [idetectmin,indexj]=min(idetect); |
---|
| 2498 | if idetectmin==0, |
---|
| 2499 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2500 | filecell={}; |
---|
[266] | 2501 | % cd(currentdir) |
---|
[112] | 2502 | return |
---|
| 2503 | end |
---|
| 2504 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2505 | if idetectmin==0, |
---|
| 2506 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2507 | filecell={}; |
---|
[266] | 2508 | %cd(currentdir) |
---|
[112] | 2509 | return |
---|
| 2510 | end |
---|
| 2511 | end |
---|
| 2512 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2513 | for ifile=1:nbfield |
---|
| 2514 | for j=1:nbslice |
---|
| 2515 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2516 | idetect(j)=exist(filename,'file')==2; |
---|
| 2517 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2518 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2519 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2520 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2521 | end |
---|
[2] | 2522 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2523 | if idetectmin==0, |
---|
| 2524 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2525 | filecell={}; |
---|
[266] | 2526 | % cd(currentdir) |
---|
[2] | 2527 | return |
---|
[112] | 2528 | end |
---|
[2] | 2529 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2530 | if idetectmin==0, |
---|
| 2531 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2532 | filecell={}; |
---|
[266] | 2533 | % cd(currentdir) |
---|
[2] | 2534 | return |
---|
[112] | 2535 | end |
---|
| 2536 | end |
---|
[2] | 2537 | end |
---|
[112] | 2538 | |
---|
[282] | 2539 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
| 2540 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
[2] | 2541 | for ifile=1:nbfield |
---|
| 2542 | for j=1:nbslice |
---|
| 2543 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2544 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2545 | detect=exist(filename,'file')==2; |
---|
[122] | 2546 | if detect==0 |
---|
| 2547 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2548 | filecell={}; |
---|
[266] | 2549 | % cd(currentdir) |
---|
[122] | 2550 | return |
---|
| 2551 | end |
---|
[2] | 2552 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2553 | end |
---|
| 2554 | end |
---|
| 2555 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2556 | for ifile=1:nbfield |
---|
| 2557 | for j=1:nbslice |
---|
| 2558 | 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);% |
---|
| 2559 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2560 | if ~exist(filename,'file') |
---|
| 2561 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2562 | set(handles.RUN, 'Enable','On') |
---|
| 2563 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2564 | filecell={}; |
---|
[266] | 2565 | %cd(currentdir) |
---|
[112] | 2566 | return |
---|
[2] | 2567 | end |
---|
| 2568 | end |
---|
[112] | 2569 | end |
---|
[2] | 2570 | end |
---|
| 2571 | end |
---|
| 2572 | |
---|
[282] | 2573 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
[2] | 2574 | testdiff=0; |
---|
[282] | 2575 | if (checkbox(4)==1)&&... |
---|
| 2576 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2577 | testdiff=1; |
---|
[112] | 2578 | detect=1; |
---|
[127] | 2579 | vers=0; |
---|
| 2580 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2581 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2582 | for ifile=1:nbfield |
---|
| 2583 | for j=1:nbslice |
---|
[127] | 2584 | 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] | 2585 | detect=exist(filename,'file')==2; |
---|
| 2586 | if detect% if a netcdf file already exists |
---|
[127] | 2587 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2588 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2589 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2590 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2591 | else |
---|
| 2592 | vers=vers+1; |
---|
| 2593 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2594 | end |
---|
[112] | 2595 | break |
---|
| 2596 | end |
---|
| 2597 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2598 | end |
---|
| 2599 | if detect% if a netcdf file already exists |
---|
| 2600 | break |
---|
| 2601 | end |
---|
| 2602 | end |
---|
[128] | 2603 | %create the new subdir_civ2_new |
---|
| 2604 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2605 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[266] | 2606 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2607 | if ~isequal(m2,'') |
---|
[266] | 2608 | msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2]) |
---|
[122] | 2609 | filecell={}; |
---|
[266] | 2610 | % cd(currentdir) |
---|
[122] | 2611 | return |
---|
[112] | 2612 | end |
---|
| 2613 | end |
---|
| 2614 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2615 | for ifile=1:nbfield |
---|
| 2616 | for j=1:nbslice |
---|
| 2617 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2618 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2619 | detect=exist(filename,'file')==2; |
---|
[2] | 2620 | if detect% if a netcdf file already exists |
---|
[127] | 2621 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2622 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2623 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2624 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2625 | else |
---|
| 2626 | vers=vers+1; |
---|
| 2627 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2628 | end |
---|
[112] | 2629 | break |
---|
[2] | 2630 | end |
---|
[112] | 2631 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2632 | end |
---|
| 2633 | if detect% if a netcdf file already exists |
---|
| 2634 | break |
---|
| 2635 | end |
---|
| 2636 | end |
---|
[122] | 2637 | subdir_civ2=subdir_civ2_new; |
---|
[289] | 2638 | %create the new txt_SubdirCiv1 |
---|
[127] | 2639 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2640 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[266] | 2641 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2642 | if ~isequal(m2,'') |
---|
[266] | 2643 | msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation |
---|
| 2644 | % cd(currentdir) |
---|
[122] | 2645 | filecell={}; |
---|
| 2646 | return |
---|
[112] | 2647 | end |
---|
| 2648 | end |
---|
| 2649 | end |
---|
| 2650 | end |
---|
[127] | 2651 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2652 | end |
---|
[266] | 2653 | %cd(currentdir);%come back to the current working directory |
---|
[2] | 2654 | |
---|
[282] | 2655 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2656 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
| 2657 | %check source netcdf file of checkciv1 estimates |
---|
| 2658 | if checkbox(1)==0; %no civ1 performed |
---|
[2] | 2659 | for ifile=1:nbfield |
---|
| 2660 | for j=1:nbslice |
---|
| 2661 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2662 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2663 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2664 | if ~exist(filename,'file') |
---|
| 2665 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2666 | filecell={}; |
---|
[2] | 2667 | return |
---|
| 2668 | end |
---|
| 2669 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
[282] | 2670 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2671 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2672 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2673 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2674 | filecell=[]; |
---|
[2] | 2675 | return |
---|
[248] | 2676 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2677 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2678 | filecell=[]; |
---|
| 2679 | return |
---|
[112] | 2680 | end |
---|
[282] | 2681 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
[275] | 2682 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
[248] | 2683 | if ~isempty(Data.CivStage) |
---|
| 2684 | if Data.CivStage<3 %test for civ files |
---|
| 2685 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2686 | filecell=[]; |
---|
| 2687 | return |
---|
| 2688 | end |
---|
| 2689 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2690 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2691 | filecell=[]; |
---|
[2] | 2692 | return |
---|
| 2693 | end |
---|
[112] | 2694 | end |
---|
[2] | 2695 | end |
---|
| 2696 | end |
---|
| 2697 | end |
---|
| 2698 | if strcmp(compare,'stereo PIV') |
---|
| 2699 | for ifile=1:nbfield |
---|
| 2700 | for j=1:nbslice |
---|
| 2701 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2702 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2703 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2704 | if ~exist(filename,'file') |
---|
| 2705 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2706 | set(handles.RUN, 'Enable','On') |
---|
| 2707 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2708 | return |
---|
| 2709 | end |
---|
| 2710 | end |
---|
| 2711 | end |
---|
| 2712 | end |
---|
| 2713 | end |
---|
[112] | 2714 | |
---|
| 2715 | detect=1; |
---|
[282] | 2716 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
[112] | 2717 | for ifile=1:nbfield |
---|
| 2718 | for j=1:nbslice |
---|
| 2719 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2720 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2721 | detect=exist(filename,'file')==2; |
---|
| 2722 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2723 | end |
---|
[112] | 2724 | end |
---|
[282] | 2725 | %get first image names for checkciv2 |
---|
| 2726 | if checkbox(1)==1 && isequal(num1_civ1,num1_civ2) && isequal(num_a_civ1,num_a_civ2) |
---|
[2] | 2727 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
[282] | 2728 | elseif checkbox(4)==1 |
---|
[2] | 2729 | for ifile=1:nbfield |
---|
| 2730 | for j=1:nbslice |
---|
| 2731 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2732 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2733 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2734 | end |
---|
[112] | 2735 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2736 | if idetectmin==0, |
---|
[112] | 2737 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2738 | filecell=[]; |
---|
| 2739 | return |
---|
[2] | 2740 | end |
---|
| 2741 | end |
---|
| 2742 | end |
---|
| 2743 | |
---|
[282] | 2744 | %get second image names for checkciv2 |
---|
| 2745 | if checkbox(1)==1 && isequal(num2_civ1,num2_civ2) && isequal(num_b_civ1,num_b_civ2) |
---|
[2] | 2746 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
[282] | 2747 | elseif checkbox(4)==1 |
---|
[2] | 2748 | for ifile=1:nbfield |
---|
| 2749 | for j=1:nbslice |
---|
| 2750 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2751 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2752 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2753 | end |
---|
[112] | 2754 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2755 | if idetectmin==0, |
---|
[112] | 2756 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2757 | filecell=[]; |
---|
| 2758 | return |
---|
[2] | 2759 | end |
---|
| 2760 | end |
---|
| 2761 | end |
---|
| 2762 | end |
---|
[282] | 2763 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
[2] | 2764 | if ~testdiff |
---|
| 2765 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2766 | else % check the civ2 files |
---|
[2] | 2767 | for ifile=1:nbfield |
---|
| 2768 | for j=1:nbslice |
---|
| 2769 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2770 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2771 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2772 | if ~exist(filename,'file') |
---|
| 2773 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2774 | filecell=[]; |
---|
[2] | 2775 | return |
---|
| 2776 | else |
---|
[248] | 2777 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2778 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2779 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2780 | filecell=[]; |
---|
| 2781 | return |
---|
| 2782 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2783 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2784 | filecell=[]; |
---|
[2] | 2785 | return |
---|
| 2786 | end |
---|
| 2787 | end |
---|
| 2788 | end |
---|
| 2789 | end |
---|
| 2790 | end |
---|
| 2791 | end |
---|
| 2792 | |
---|
| 2793 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2794 | if strcmp(compare,'stereo PIV') |
---|
[282] | 2795 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2796 | for ifile=1:nbfield |
---|
| 2797 | for j=1:nbslice |
---|
| 2798 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2799 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2800 | filecell.st(ifile,j)={filename}; |
---|
| 2801 | end |
---|
| 2802 | end |
---|
| 2803 | end |
---|
[282] | 2804 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
[2] | 2805 | for ifile=1:nbfield |
---|
| 2806 | for j=1:nbslice |
---|
| 2807 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2808 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2809 | filecell.st(ifile,j)={filename}; |
---|
| 2810 | end |
---|
| 2811 | end |
---|
[112] | 2812 | end |
---|
[2] | 2813 | end |
---|
[289] | 2814 | set(handles.txt_SubdirCiv1,'String',subdir_civ1);%update the edit box |
---|
| 2815 | set(handles.txt_SubdirCiv2,'String',subdir_civ2);%update the edit box |
---|
[2] | 2816 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 2817 | set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat |
---|
[2] | 2818 | |
---|
| 2819 | |
---|
| 2820 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2821 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2822 | nom_type_imanew1='_i'; |
---|
[2] | 2823 | else |
---|
| 2824 | nom_type_imanew1=nom_type_ima1; |
---|
| 2825 | end |
---|
[45] | 2826 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2827 | nom_type_imanew2='_i'; |
---|
[2] | 2828 | else |
---|
| 2829 | nom_type_imanew2=nom_type_ima2; |
---|
| 2830 | end |
---|
| 2831 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2832 | %%type of image file |
---|
| 2833 | type_ima1='none';%default |
---|
| 2834 | movieobject1=[];%default |
---|
[133] | 2835 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2836 | hhh=which('mmreader'); |
---|
| 2837 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2838 | type_ima1='movie'; |
---|
| 2839 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2840 | else |
---|
| 2841 | type_ima1='avi'; |
---|
| 2842 | end |
---|
[133] | 2843 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2844 | form=imformats(ext_ima(2:end)); |
---|
| 2845 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2846 | if isequal(nom_type_ima1,'*'); |
---|
| 2847 | type_ima1='multimage';%image series in a single image file |
---|
| 2848 | else |
---|
| 2849 | type_ima1='image'; |
---|
| 2850 | end |
---|
| 2851 | end |
---|
[45] | 2852 | end |
---|
| 2853 | type_ima2='none';%default |
---|
| 2854 | movieobject2=[]; |
---|
[133] | 2855 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2856 | hhh=which('mmreader'); |
---|
| 2857 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2858 | type_ima2='movie'; |
---|
| 2859 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2860 | else |
---|
| 2861 | type_ima2='avi'; |
---|
| 2862 | end |
---|
[133] | 2863 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2864 | form=imformats(ext_ima(2:end)); |
---|
| 2865 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2866 | if isequal(nom_type_ima1,'*'); |
---|
| 2867 | type_ima2='multimage';%image series in a single image file |
---|
| 2868 | else |
---|
| 2869 | type_ima2='image'; |
---|
| 2870 | end |
---|
| 2871 | end |
---|
[45] | 2872 | end |
---|
[71] | 2873 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2874 | % % if numel(npxy)<2 |
---|
| 2875 | % |
---|
| 2876 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2877 | % A=imread(filename); |
---|
| 2878 | % npxy=size(A); |
---|
| 2879 | % % end |
---|
| 2880 | % npy=npxy(1); |
---|
| 2881 | % npx=npxy(2); |
---|
[282] | 2882 | if checkbox(1) %if civ1 is performed |
---|
[224] | 2883 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2884 | for ifile=1:nbfield |
---|
[2] | 2885 | waitbar(ifile/nbfield); |
---|
| 2886 | for j=1:nbslice |
---|
[112] | 2887 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2888 | if ~exist(filename,'file') |
---|
| 2889 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2890 | imwrite(A,filename,'BitDepth',16); |
---|
| 2891 | end |
---|
| 2892 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2893 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2894 | if ~exist(filename,'file') |
---|
| 2895 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2896 | imwrite(A,filename,'BitDepth',16); |
---|
| 2897 | end |
---|
| 2898 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 2899 | end |
---|
| 2900 | end |
---|
| 2901 | close(h) |
---|
| 2902 | end |
---|
[282] | 2903 | if checkbox(4) %if civ2 is performed |
---|
[229] | 2904 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 2905 | for ifile=1:nbfield |
---|
| 2906 | waitbar(ifile/nbfield); |
---|
| 2907 | for j=1:nbslice |
---|
[112] | 2908 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 2909 | if ~exist(filename,'file') |
---|
| 2910 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 2911 | imwrite(A,filename,'BitDepth',16); |
---|
| 2912 | end |
---|
| 2913 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2914 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 2915 | if ~exist(filename,'file') |
---|
| 2916 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 2917 | imwrite(A,filename,'BitDepth',16); |
---|
| 2918 | end |
---|
| 2919 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 2920 | end |
---|
| 2921 | end |
---|
| 2922 | close(h); |
---|
| 2923 | end |
---|
| 2924 | end |
---|
| 2925 | |
---|
[12] | 2926 | %------------------------------------------------------------------------ |
---|
[227] | 2927 | % --- determine the list of index pairs of processing file |
---|
| 2928 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2929 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2930 | %------------------------------------------------------------------------ |
---|
| 2931 | |
---|
[282] | 2932 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
| 2933 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
[227] | 2934 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2935 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2936 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2937 | return |
---|
| 2938 | end |
---|
[282] | 2939 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
| 2940 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
[227] | 2941 | if index_civ2>length(list_civ2) |
---|
| 2942 | list_civ2=list_civ1; |
---|
| 2943 | index_civ2=index_civ1; |
---|
| 2944 | end |
---|
| 2945 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2946 | |
---|
| 2947 | if isequal (mode,'series(Di)') |
---|
| 2948 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2949 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2950 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2951 | num_a_civ1=ref_j; |
---|
| 2952 | num_b_civ1=ref_j; |
---|
[229] | 2953 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 2954 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2955 | num_a_civ2=ref_j; |
---|
| 2956 | num_b_civ2=ref_j; |
---|
| 2957 | |
---|
| 2958 | % adjust the first and last field number |
---|
| 2959 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2960 | if isnan(lastfield) |
---|
| 2961 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2962 | else |
---|
| 2963 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2964 | end |
---|
| 2965 | if length(indsel)>=1 |
---|
| 2966 | firstind=indsel(1); |
---|
| 2967 | lastind=indsel(end); |
---|
| 2968 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2969 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2970 | ref_i=ref_i(indsel); |
---|
| 2971 | num1_civ1=num1_civ1(indsel); |
---|
| 2972 | num1_civ2=num1_civ2(indsel); |
---|
| 2973 | num2_civ1=num2_civ1(indsel); |
---|
| 2974 | num2_civ2=num2_civ2(indsel); |
---|
| 2975 | end |
---|
| 2976 | elseif isequal (mode,'series(Dj)') |
---|
| 2977 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 2978 | num1_civ1=ref_i;% set of first image numbers |
---|
| 2979 | num2_civ1=ref_i; |
---|
| 2980 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 2981 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 2982 | num1_civ2=ref_i; |
---|
| 2983 | num2_civ2=ref_i; |
---|
| 2984 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 2985 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 2986 | % adjust the first and last field number |
---|
| 2987 | if isnan(lastfield_j) |
---|
| 2988 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 2989 | else |
---|
| 2990 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 2991 | end |
---|
| 2992 | if length(indsel)>=1 |
---|
| 2993 | firstind=indsel(1); |
---|
| 2994 | lastind=indsel(end); |
---|
| 2995 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 2996 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 2997 | ref_j=ref_j(indsel); |
---|
| 2998 | num_a_civ1=num_a_civ1(indsel); |
---|
| 2999 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3000 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3001 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3002 | end |
---|
| 3003 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[282] | 3004 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[227] | 3005 | num1_civ1=ref_i; |
---|
| 3006 | num2_civ1=ref_i; |
---|
| 3007 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3008 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3009 | num1_civ2=ref_i; |
---|
| 3010 | num2_civ2=ref_i; |
---|
| 3011 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3012 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3013 | elseif isequal(mode,'displacement') |
---|
| 3014 | num1_civ1=ref_i; |
---|
| 3015 | num2_civ1=ref_i; |
---|
| 3016 | num_a_civ1=ref_j; |
---|
| 3017 | num_b_civ1=ref_j; |
---|
| 3018 | num1_civ2=ref_i; |
---|
| 3019 | num2_civ2=ref_i; |
---|
| 3020 | num_a_civ2=ref_j; |
---|
| 3021 | num_b_civ2=ref_j; |
---|
| 3022 | end |
---|
| 3023 | |
---|
| 3024 | |
---|
| 3025 | %------------------------------------------------------------------------ |
---|
[12] | 3026 | % --- STEREO Interp |
---|
[67] | 3027 | 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] | 3028 | %------------------------------------------------------------------------ |
---|
[224] | 3029 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3030 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3031 | ' -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 |
---|
| 3032 | |
---|
[12] | 3033 | %------------------------------------------------------------------------ |
---|
[282] | 3034 | % --- Executes on button press in CheckCiv1. |
---|
| 3035 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3036 | %------------------------------------------------------------------------ |
---|
[289] | 3037 | update_CivOptions(handles) |
---|
[2] | 3038 | |
---|
[12] | 3039 | %------------------------------------------------------------------------ |
---|
[282] | 3040 | % --- Executes on button press in CheckFix1. |
---|
| 3041 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3042 | %------------------------------------------------------------------------ |
---|
[289] | 3043 | update_CivOptions(handles) |
---|
[2] | 3044 | |
---|
[12] | 3045 | %------------------------------------------------------------------------ |
---|
[282] | 3046 | % --- Executes on button press in CheckPatch1. |
---|
| 3047 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
[12] | 3048 | %------------------------------------------------------------------------ |
---|
[289] | 3049 | update_CivOptions(handles) |
---|
[2] | 3050 | |
---|
[12] | 3051 | %------------------------------------------------------------------------ |
---|
[282] | 3052 | % --- Executes on button press in CheckCiv2. |
---|
| 3053 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3054 | %------------------------------------------------------------------------ |
---|
[289] | 3055 | update_CivOptions(handles) |
---|
[2] | 3056 | |
---|
[12] | 3057 | %------------------------------------------------------------------------ |
---|
[282] | 3058 | % --- Executes on button press in CheckFix2. |
---|
| 3059 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3060 | %------------------------------------------------------------------------ |
---|
[289] | 3061 | update_CivOptions(handles) |
---|
[2] | 3062 | |
---|
[12] | 3063 | %------------------------------------------------------------------------ |
---|
[282] | 3064 | % --- Executes on button press in CheckPatch2. |
---|
| 3065 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3066 | %------------------------------------------------------------------------ |
---|
[289] | 3067 | update_CivOptions(handles) |
---|
| 3068 | |
---|
| 3069 | %------------------------------------------------------------------------ |
---|
| 3070 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
| 3071 | function update_CivOptions(handles) |
---|
| 3072 | %------------------------------------------------------------------------ |
---|
| 3073 | checkbox=zeros(1,6); |
---|
| 3074 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 3075 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 3076 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 3077 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 3078 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
[298] | 3079 | checkbox(6)=get(handles.CheckPatch2,'Value') |
---|
[289] | 3080 | ind_selected=find(checkbox); |
---|
| 3081 | if ~isempty(ind_selected) |
---|
| 3082 | RootName=get(handles.RootName,'String'); |
---|
| 3083 | if isempty(RootName) |
---|
| 3084 | msgbox_uvmat('ERROR','No input file') |
---|
| 3085 | return |
---|
| 3086 | end |
---|
[2] | 3087 | end |
---|
[289] | 3088 | set(handles.PairIndices,'Visible','on') |
---|
| 3089 | set(handles.txt_SubdirCiv1,'Visible','on') |
---|
| 3090 | set(handles.ListSubdirCiv1,'Visible','on') |
---|
| 3091 | find_netcpair_civ1(handles) % select the available netcdf files |
---|
| 3092 | % check_civ2pair=ind_selected(4;6); |
---|
| 3093 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
| 3094 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 3095 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
| 3096 | set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 3097 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
| 3098 | set(handles.ListPairCiv2,'Visible','on') |
---|
| 3099 | find_netcpair_civ2(handles) % select the available netcdf files |
---|
| 3100 | else |
---|
| 3101 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
| 3102 | set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 3103 | set(handles.ListSubdirCiv2,'Visible','off') |
---|
| 3104 | set(handles.ListPairCiv2,'Visible','off') |
---|
| 3105 | end |
---|
| 3106 | %index_last=find(checkbox,1,'last');%last selected button |
---|
| 3107 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 3108 | for ilist=1:length(options) |
---|
| 3109 | if checkbox(ilist) |
---|
| 3110 | set(handles.(options{ilist}),'Visible','on') |
---|
| 3111 | else |
---|
| 3112 | set(handles.(options{ilist}),'Visible','off') |
---|
| 3113 | end |
---|
| 3114 | end |
---|
[2] | 3115 | |
---|
[12] | 3116 | %------------------------------------------------------------------------ |
---|
| 3117 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3118 | %------------------------------------------------------------------------ |
---|
[137] | 3119 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3120 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3121 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3122 | |
---|
[12] | 3123 | %------------------------------------------------------------------------ |
---|
| 3124 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3125 | %------------------------------------------------------------------------ |
---|
| 3126 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3127 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3128 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3129 | |
---|
[12] | 3130 | %------------------------------------------------------------------------ |
---|
[287] | 3131 | % --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy |
---|
[273] | 3132 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3133 | %------------------------------------------------------------------------ |
---|
[2] | 3134 | %determine pair numbers |
---|
[273] | 3135 | if strcmp(get(handles.umin,'Visible'),'off') |
---|
| 3136 | set(handles.u_title,'Visible','on') |
---|
| 3137 | set(handles.v_title,'Visible','on') |
---|
| 3138 | set(handles.umin,'Visible','on') |
---|
| 3139 | set(handles.umax,'Visible','on') |
---|
| 3140 | set(handles.vmin,'Visible','on') |
---|
| 3141 | set(handles.vmax,'Visible','on') |
---|
| 3142 | set(handles.CoordUnit,'Visible','on') |
---|
| 3143 | set(handles.TimeUnit,'Visible','on') |
---|
| 3144 | set(handles.slash_title,'Visible','on') |
---|
| 3145 | set(handles.min_title,'Visible','on') |
---|
| 3146 | set(handles.max_title,'Visible','on') |
---|
| 3147 | set(handles.unit_title,'Visible','on') |
---|
| 3148 | else |
---|
| 3149 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3150 | end |
---|
| 3151 | |
---|
[12] | 3152 | %------------------------------------------------------------------------ |
---|
[287] | 3153 | % --- determine the search range num_Searchx,num_Searchy and shift |
---|
[273] | 3154 | function get_search_range(hObject, eventdata, handles) |
---|
| 3155 | umin=str2double(get(handles.umin,'String')); |
---|
| 3156 | umax=str2double(get(handles.umax,'String')); |
---|
| 3157 | vmin=str2double(get(handles.umin,'String')); |
---|
| 3158 | vmax=str2double(get(handles.vmax,'String')); |
---|
| 3159 | %switch min_title and max_title in case of error |
---|
| 3160 | if umax<=umin |
---|
| 3161 | umin_old=umin; |
---|
| 3162 | umin=umax; |
---|
| 3163 | umax=umin_old; |
---|
| 3164 | set(handles.umin,'String', num2str(umin)) |
---|
| 3165 | set(handles.umax,'String', num2str(umax)) |
---|
| 3166 | end |
---|
| 3167 | if vmax<=vmin |
---|
| 3168 | vmin_old=vmin; |
---|
| 3169 | vmin=vmax; |
---|
| 3170 | vmax=vmin_old; |
---|
| 3171 | set(handles.vmin,'String', num2str(vmin)) |
---|
| 3172 | set(handles.vmax,'String', num2str(vmax)) |
---|
| 3173 | end |
---|
| 3174 | if ~(isnan(umin)||isnan(umax)||isnan(vmin)||isnan(vmax)) |
---|
[282] | 3175 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 3176 | index=get(handles.ListPairCiv1,'Value'); |
---|
| 3177 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[273] | 3178 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
| 3179 | pxcm_xy=get(handles.SearchRange,'UserData'); |
---|
| 3180 | pxcmx=pxcm_xy(1); |
---|
| 3181 | pxcmy=pxcm_xy(2); |
---|
[282] | 3182 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 3183 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[273] | 3184 | mode=mode_list{mode_value}; |
---|
| 3185 | if isequal (mode, 'series(Di)' ) |
---|
| 3186 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3187 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3188 | num2=ref_i+ceil(index/2); |
---|
| 3189 | num_a=1; |
---|
| 3190 | num_b=1; |
---|
| 3191 | elseif isequal (mode, 'series(Dj)') |
---|
| 3192 | num1=1; |
---|
| 3193 | num2=1; |
---|
| 3194 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3195 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3196 | num_b=ref_j+ceil(index/2); |
---|
| 3197 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3198 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3199 | num1=ref_i; |
---|
| 3200 | num2=ref_i; |
---|
| 3201 | num_a=displ_num(1,index); |
---|
| 3202 | num_b=displ_num(2,index); |
---|
| 3203 | end |
---|
| 3204 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[282] | 3205 | ibx=str2double(get(handles.num_Bx,'String')); |
---|
| 3206 | iby=str2double(get(handles.num_By,'String')); |
---|
[273] | 3207 | umin=dt*pxcmx*umin; |
---|
| 3208 | umax=dt*pxcmx*umax; |
---|
| 3209 | vmin=dt*pxcmy*vmin; |
---|
| 3210 | vmax=dt*pxcmy*vmax; |
---|
| 3211 | shiftx=round((umin+umax)/2); |
---|
| 3212 | shifty=round((vmin+vmax)/2); |
---|
| 3213 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3214 | isx=2*ceil(isx/2)+1; |
---|
| 3215 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3216 | isy=2*ceil(isy/2)+1; |
---|
[282] | 3217 | set(handles.num_Shiftx,'String',num2str(shiftx)); |
---|
| 3218 | set(handles.num_Shifty,'String',num2str(shifty)); |
---|
[287] | 3219 | set(handles.num_Searchx,'String',num2str(isx)); |
---|
| 3220 | set(handles.num_Searchy,'String',num2str(isy)); |
---|
[273] | 3221 | end |
---|
| 3222 | |
---|
| 3223 | %------------------------------------------------------------------------ |
---|
[282] | 3224 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[289] | 3225 | function txt_SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3226 | %------------------------------------------------------------------------ |
---|
[289] | 3227 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
| 3228 | set(handles.txt_SubdirCiv2,'String',subdir);% set civ2 directory the same as civ1 by default |
---|
[282] | 3229 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
[273] | 3230 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3231 | if isempty(ichoice) |
---|
| 3232 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3233 | else |
---|
| 3234 | ilist=ichoice; |
---|
| 3235 | end |
---|
[282] | 3236 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 3237 | if get(handles.CheckCiv1,'Value')==0 |
---|
[2] | 3238 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3239 | end |
---|
| 3240 | |
---|
[12] | 3241 | %------------------------------------------------------------------------ |
---|
[282] | 3242 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[289] | 3243 | function txt_SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3244 | %------------------------------------------------------------------------ |
---|
[289] | 3245 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
| 3246 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
[273] | 3247 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3248 | if isempty(ichoice) |
---|
| 3249 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3250 | else |
---|
| 3251 | ilist=ichoice; |
---|
| 3252 | end |
---|
[289] | 3253 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
[2] | 3254 | %update the list of available pairs from netcdf files in the new directory |
---|
[282] | 3255 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[2] | 3256 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3257 | end |
---|
| 3258 | |
---|
[276] | 3259 | % %------------------------------------------------------------------------ |
---|
[282] | 3260 | % % --- Executes on button press in CheckMask: select box for mask option |
---|
[276] | 3261 | % function check_Mask_Callback(hObject, eventdata, handles) |
---|
| 3262 | % %------------------------------------------------------------------------ |
---|
[282] | 3263 | % maskval=get(handles.CheckMask,'Value'); |
---|
[276] | 3264 | % if isequal(maskval,0) |
---|
| 3265 | % set(handles.txt_MaskName,'Visible','off') |
---|
| 3266 | % % set(handles.txt_MaskName,'String','') |
---|
| 3267 | % else |
---|
| 3268 | % mask_displ='no mask'; %default |
---|
| 3269 | % filebase=get(handles.RootName,'String'); |
---|
| 3270 | % [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3271 | % if isequal(flag_mask,1) |
---|
| 3272 | % mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[282] | 3273 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[276] | 3274 | % common_path=fileparts(filebase); |
---|
| 3275 | % filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3276 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3277 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3278 | % mask_displ='no mask'; |
---|
| 3279 | % end |
---|
| 3280 | % end |
---|
| 3281 | % if isequal(mask_displ,'no mask') |
---|
| 3282 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3283 | % {'*.png', ' (*.png)'; |
---|
| 3284 | % '*.png', '.png files '; ... |
---|
| 3285 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3286 | % 'Pick a mask file *.png',filebase); |
---|
| 3287 | % mask_displ=fullfile(PathName,FileName); |
---|
| 3288 | % if exist(mask_displ,'file') |
---|
| 3289 | % set(handles.txt_MaskName,'Visible','on') |
---|
| 3290 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
| 3291 | % % mask_displ='no mask'; |
---|
| 3292 | % end |
---|
| 3293 | % end |
---|
| 3294 | % if isequal(mask_displ,'no mask') |
---|
[282] | 3295 | % set(handles.CheckMask,'Value',0) |
---|
| 3296 | % set(handles.CheckMask,'Value',0) |
---|
| 3297 | % set(handles.CheckMask,'Value',0) |
---|
| 3298 | % set(handles.CheckMask,'Value',0) |
---|
[276] | 3299 | % else |
---|
[282] | 3300 | % set(handles.CheckMask,'Value',1) |
---|
| 3301 | % set(handles.CheckMask,'Value',1) |
---|
[276] | 3302 | % end |
---|
| 3303 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[282] | 3304 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3305 | % set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3306 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3307 | % end |
---|
[282] | 3308 | % set(handles.CheckMask,'Value',maskval)%update the checkciv2 mask with the same option as checkciv1 |
---|
[2] | 3309 | |
---|
[12] | 3310 | %------------------------------------------------------------------------ |
---|
[282] | 3311 | % --- Executes on button press in CheckMask. |
---|
[2] | 3312 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3313 | %------------------------------------------------------------------------ |
---|
[282] | 3314 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3315 | if isequal(maskval,0) |
---|
[282] | 3316 | set(handles.txt_MaskName,'String','') |
---|
[2] | 3317 | else |
---|
[112] | 3318 | mask_displ='no mask'; %default |
---|
| 3319 | filebase=get(handles.RootName,'String'); |
---|
| 3320 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3321 | if isequal(flag_mask,1) |
---|
| 3322 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3323 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3324 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3325 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3326 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3327 | mask_displ='no mask'; |
---|
| 3328 | end |
---|
[112] | 3329 | end |
---|
| 3330 | if isequal(mask_displ,'no mask') |
---|
| 3331 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3332 | {'*.png', ' (*.png)'; |
---|
[12] | 3333 | '*.png', '.png files '; ... |
---|
| 3334 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3335 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3336 | mask_displ=fullfile(PathName,FileName); |
---|
| 3337 | if ~exist(mask_displ,'file') |
---|
| 3338 | mask_displ='no mask'; |
---|
| 3339 | end |
---|
[12] | 3340 | end |
---|
[112] | 3341 | if isequal(mask_displ,'no mask') |
---|
[282] | 3342 | set(handles.CheckMask,'Value',0) |
---|
| 3343 | set(handles.CheckMask,'Value',0) |
---|
| 3344 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3345 | else |
---|
[282] | 3346 | %set(handles.CheckMask,'Value',1) |
---|
| 3347 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3348 | end |
---|
[282] | 3349 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3350 | set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3351 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[12] | 3352 | end |
---|
| 3353 | |
---|
| 3354 | %------------------------------------------------------------------------ |
---|
[282] | 3355 | % --- Executes on button press in CheckMask: select box for mask option |
---|
[2] | 3356 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3357 | %------------------------------------------------------------------------ |
---|
[282] | 3358 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3359 | if isequal(maskval,0) |
---|
[276] | 3360 | set(handles.txt_Mask,'String','') |
---|
[2] | 3361 | else |
---|
[112] | 3362 | mask_displ='no mask'; %default |
---|
| 3363 | filebase=get(handles.RootName,'String'); |
---|
| 3364 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3365 | if isequal(flag_mask,1) |
---|
| 3366 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3367 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3368 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3369 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3370 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3371 | mask_displ='no mask'; |
---|
| 3372 | end |
---|
[112] | 3373 | end |
---|
| 3374 | if isequal(mask_displ,'no mask') |
---|
| 3375 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3376 | {'*.png', ' (*.png)'; |
---|
[12] | 3377 | '*.png', '.png files '; ... |
---|
| 3378 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3379 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3380 | mask_displ=fullfile(PathName,FileName); |
---|
| 3381 | if ~exist(mask_displ,'file') |
---|
| 3382 | mask_displ='no mask'; |
---|
| 3383 | end |
---|
[12] | 3384 | end |
---|
[112] | 3385 | if isequal(mask_displ,'no mask') |
---|
[282] | 3386 | set(handles.CheckMask,'Value',0) |
---|
| 3387 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3388 | else |
---|
[282] | 3389 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3390 | end |
---|
[276] | 3391 | set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3392 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[12] | 3393 | end |
---|
| 3394 | |
---|
| 3395 | %------------------------------------------------------------------------ |
---|
[282] | 3396 | % --- Executes on button press in CheckMask. |
---|
[2] | 3397 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3398 | %------------------------------------------------------------------------ |
---|
[282] | 3399 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3400 | if isequal(maskval,0) |
---|
[287] | 3401 | set(handles.txt_MaskName,'String','') |
---|
[2] | 3402 | else |
---|
[12] | 3403 | mask_displ='no mask'; %default |
---|
[71] | 3404 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3405 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3406 | if isequal(flag_mask,1) |
---|
[112] | 3407 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3408 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3409 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3410 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3411 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3412 | mask_displ='no mask'; |
---|
| 3413 | end |
---|
[12] | 3414 | end |
---|
| 3415 | if isequal(mask_displ,'no mask') |
---|
| 3416 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3417 | {'*.png', ' (*.png)'; |
---|
| 3418 | '*.png', '.png files '; ... |
---|
| 3419 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3420 | 'Pick a mask file *.png',filebase); |
---|
| 3421 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3422 | if ~exist(mask_displ,'file') |
---|
[2] | 3423 | mask_displ='no mask'; |
---|
| 3424 | end |
---|
[12] | 3425 | end |
---|
| 3426 | if isequal(mask_displ,'no mask') |
---|
[282] | 3427 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3428 | end |
---|
[287] | 3429 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[2] | 3430 | end |
---|
| 3431 | |
---|
[12] | 3432 | %------------------------------------------------------------------------ |
---|
| 3433 | % --- function called to look for mask files |
---|
[2] | 3434 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3435 | %------------------------------------------------------------------------ |
---|
[112] | 3436 | %detect mask files, images with appropriate file base |
---|
[2] | 3437 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3438 | %flag_mask=1 indicates detection |
---|
| 3439 | |
---|
| 3440 | flag_mask=0;%default |
---|
| 3441 | nbslice=1; |
---|
| 3442 | |
---|
[289] | 3443 | % subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
[2] | 3444 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3445 | if ~isdir(Path) |
---|
| 3446 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3447 | return |
---|
| 3448 | end |
---|
[272] | 3449 | % currentdir=pwd; |
---|
| 3450 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3451 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3452 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3453 | if ~isempty(maskfiles) |
---|
[112] | 3454 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3455 | % else |
---|
[2] | 3456 | flag_mask=1; |
---|
| 3457 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3458 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3459 | Namedouble=double(Name); |
---|
| 3460 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3461 | ind_mask=findstr('mask',Name); |
---|
| 3462 | i=ind_mask-1; |
---|
[137] | 3463 | while val(i)==0 && i>0 |
---|
[112] | 3464 | i=i-1; |
---|
[2] | 3465 | end |
---|
[137] | 3466 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3467 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3468 | flag_mask=1; |
---|
[2] | 3469 | else |
---|
[112] | 3470 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3471 | return |
---|
| 3472 | nbslice=1; |
---|
[2] | 3473 | end |
---|
[112] | 3474 | end |
---|
[2] | 3475 | |
---|
[12] | 3476 | %------------------------------------------------------------------------ |
---|
| 3477 | % --- function called to look for grid files |
---|
[2] | 3478 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3479 | %------------------------------------------------------------------------ |
---|
[2] | 3480 | flag_mask=0;%default |
---|
| 3481 | nbslice=1; |
---|
| 3482 | [Path,Name]=fileparts(filebase); |
---|
| 3483 | currentdir=pwd; |
---|
| 3484 | cd(Path);%move in the dir of the root name filebase |
---|
| 3485 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3486 | cd(currentdir);%come back to the current working directory |
---|
| 3487 | if ~isempty(maskfiles) |
---|
| 3488 | flag_mask=1; |
---|
| 3489 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3490 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3491 | Namedouble=double(Name); |
---|
| 3492 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3493 | ind_mask=findstr('grid',Name); |
---|
| 3494 | i=ind_mask-1; |
---|
[137] | 3495 | while val(i)==0 && i>0 |
---|
[112] | 3496 | i=i-1; |
---|
[2] | 3497 | end |
---|
[137] | 3498 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3499 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3500 | flag_mask=1; |
---|
[2] | 3501 | else |
---|
[112] | 3502 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3503 | return |
---|
| 3504 | nbslice=1; |
---|
[2] | 3505 | end |
---|
[12] | 3506 | end |
---|
[2] | 3507 | |
---|
[12] | 3508 | %------------------------------------------------------------------------ |
---|
| 3509 | % --- transform numbers to letters |
---|
[122] | 3510 | function str=num2stra(num,nom_type) |
---|
[12] | 3511 | %------------------------------------------------------------------------ |
---|
[122] | 3512 | if isempty(nom_type) |
---|
| 3513 | str=''; |
---|
| 3514 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3515 | str=char(96+num); |
---|
[122] | 3516 | elseif strcmp(nom_type(end),'A') |
---|
| 3517 | str=char(96+num); |
---|
| 3518 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3519 | str=''; |
---|
| 3520 | else |
---|
| 3521 | str=num2str(num); |
---|
| 3522 | end |
---|
[12] | 3523 | |
---|
| 3524 | %------------------------------------------------------------------------ |
---|
[282] | 3525 | % --- Executes on button press in ListSubdirCiv1. |
---|
| 3526 | function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3527 | %------------------------------------------------------------------------ |
---|
[282] | 3528 | list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 3529 | val=get(handles.ListSubdirCiv1,'Value'); |
---|
[273] | 3530 | subdir=list_subdir_civ1{val}; |
---|
| 3531 | if strcmp(subdir,'new...') |
---|
| 3532 | subdir='CIV'; %default subdirectory |
---|
[2] | 3533 | end |
---|
[289] | 3534 | set(handles.txt_SubdirCiv1,'String',subdir); |
---|
[273] | 3535 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 3536 | % end |
---|
[2] | 3537 | |
---|
[12] | 3538 | %------------------------------------------------------------------------ |
---|
[289] | 3539 | % --- Executes on button press in ListSubdirCiv2. |
---|
| 3540 | function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3541 | %------------------------------------------------------------------------ |
---|
[289] | 3542 | list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 3543 | val=get(handles.ListSubdirCiv2,'Value'); |
---|
[273] | 3544 | subdir=list_subdir_civ2{val}; |
---|
| 3545 | if strcmp(subdir,'new...') |
---|
| 3546 | subdir='CIV'; %default subdirectory |
---|
[2] | 3547 | end |
---|
[289] | 3548 | set(handles.txt_SubdirCiv2,'String',subdir); |
---|
| 3549 | % set(handles.ListSubdirCiv2,'Value',1); |
---|
[2] | 3550 | |
---|
[273] | 3551 | |
---|
[12] | 3552 | %------------------------------------------------------------------------ |
---|
[282] | 3553 | % --- Executes on button press in CheckGrid. |
---|
| 3554 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
[12] | 3555 | %------------------------------------------------------------------------ |
---|
[276] | 3556 | value=get(hObject,'Value'); |
---|
| 3557 | hparent=get(hObject,'parent'); |
---|
| 3558 | hchildren=get(hparent,'children'); |
---|
| 3559 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
| 3560 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3561 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[2] | 3562 | testgrid=0; |
---|
[276] | 3563 | filegrid=''; |
---|
[2] | 3564 | if value |
---|
[112] | 3565 | filebase=get(handles.RootName,'String'); |
---|
[276] | 3566 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
[2] | 3567 | if isequal(flag_grid,1) |
---|
[112] | 3568 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3569 | testgrid=1; |
---|
[276] | 3570 | else % browse for a grid |
---|
| 3571 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 3572 | if exist(filegrid,'file') |
---|
| 3573 | filebase=filegrid; |
---|
| 3574 | end |
---|
[2] | 3575 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3576 | {'*.grid', ' (*.grid)'; |
---|
| 3577 | '*.grid', '.grid files '; ... |
---|
| 3578 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3579 | 'Pick a file',filebase); |
---|
[2] | 3580 | filegrid=fullfile(PathName,FileName); |
---|
[276] | 3581 | set(hObject,'UserData',filegrid);%store for future use |
---|
[2] | 3582 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3583 | testgrid=1; |
---|
| 3584 | end |
---|
[112] | 3585 | end |
---|
[2] | 3586 | end |
---|
| 3587 | if testgrid |
---|
[276] | 3588 | set(handle_dx,'Visible','off'); |
---|
| 3589 | set(handle_dy,'Visible','off'); |
---|
| 3590 | set(handle_txtbox,'Visible','on') |
---|
| 3591 | set(handle_txtbox,'String',filegrid) |
---|
[112] | 3592 | else |
---|
[276] | 3593 | set(hObject,'Value',0); |
---|
| 3594 | set(handle_dx,'Visible','on'); |
---|
| 3595 | set(handle_dy,'Visible','on'); |
---|
| 3596 | set(handle_txtbox,'Visible','off') |
---|
[2] | 3597 | end |
---|
| 3598 | |
---|
[282] | 3599 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
[276] | 3600 | PanelName=get(hparent,'tag'); |
---|
| 3601 | if strcmp(PanelName,'panel_Civ1') |
---|
[282] | 3602 | hchildren=get(handles.Civ2,'children'); |
---|
[276] | 3603 | handle_checkbox=findobj(hchildren,'tag','check_Grid'); |
---|
| 3604 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
| 3605 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3606 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
| 3607 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 3608 | if testgrid |
---|
| 3609 | set(handle_checkbox,'Value',1); |
---|
| 3610 | set(handle_dx,'Visible','off'); |
---|
| 3611 | set(handle_dy,'Visible','off'); |
---|
| 3612 | set(handle_txtbox,'Visible','on') |
---|
| 3613 | set(handle_txtbox,'String',filegrid) |
---|
| 3614 | else |
---|
| 3615 | set(handle_checkbox,'Value',0); |
---|
[282] | 3616 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3617 | set(handle_dx,'Visible','on'); |
---|
| 3618 | set(handle_dy,'Visible','on'); |
---|
| 3619 | set(handle_txtbox,'Visible','off') |
---|
| 3620 | end |
---|
| 3621 | end |
---|
[12] | 3622 | %------------------------------------------------------------------------ |
---|
[282] | 3623 | % --- Executes on button press in CheckMask. |
---|
| 3624 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
[276] | 3625 | %------------------------------------------------------------------------ |
---|
| 3626 | value=get(hObject,'Value'); |
---|
| 3627 | testmask=0; |
---|
| 3628 | if value |
---|
| 3629 | filebase=get(handles.RootName,'String'); |
---|
| 3630 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
| 3631 | if isequal(flag_mask,1) |
---|
| 3632 | filemask=[num2str(nbslice) 'mask']; |
---|
| 3633 | testmask=1; |
---|
| 3634 | else % browse for a mask |
---|
[282] | 3635 | filemask=get(handles.CheckMask,'UserData');%look for previous mask name stored as UserData |
---|
[276] | 3636 | if exist(filemask,'file') |
---|
| 3637 | filebase=filemask; |
---|
| 3638 | end |
---|
| 3639 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3640 | {'*.png', ' (*.png)'; |
---|
| 3641 | '*.png', '.png files '; ... |
---|
| 3642 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3643 | 'Pick a mask file *.png',filebase); |
---|
| 3644 | filemask=fullfile(PathName,FileName); |
---|
[282] | 3645 | set(handles.CheckMask,'UserData',filemask);%store for future use |
---|
[276] | 3646 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
| 3647 | testmask=1; |
---|
| 3648 | end |
---|
| 3649 | end |
---|
| 3650 | end |
---|
| 3651 | if testmask |
---|
| 3652 | set(handles.num_Dx,'Visible','off'); |
---|
| 3653 | set(handles.num_Dy,'Visible','off'); |
---|
| 3654 | set(handles.num_Dx,'Visible','off'); |
---|
| 3655 | set(handles.num_Dy,'Visible','off'); |
---|
| 3656 | set(handles.txt_MaskName,'Visible','on') |
---|
| 3657 | set(handles.txt_MaskName,'String',filemask) |
---|
| 3658 | else |
---|
[282] | 3659 | set(handles.CheckMask,'Value',0); |
---|
| 3660 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3661 | set(handles.num_Dx,'Visible','on'); |
---|
| 3662 | set(handles.num_Dy,'Visible','on'); |
---|
| 3663 | set(handles.num_Dx,'Visible','on'); |
---|
| 3664 | set(handles.num_Dy,'Visible','on'); |
---|
| 3665 | set(handles.txt_MaskName,'Visible','off') |
---|
| 3666 | end |
---|
| 3667 | |
---|
| 3668 | %------------------------------------------------------------------------ |
---|
[282] | 3669 | % --- Executes on button press in CheckGrid. |
---|
[2] | 3670 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3671 | %------------------------------------------------------------------------ |
---|
[282] | 3672 | value=get(handles.CheckGrid,'Value'); |
---|
[2] | 3673 | if value |
---|
[112] | 3674 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3675 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3676 | if isequal(flag_grid,1) |
---|
| 3677 | mask_displ=[num2str(nbslice) 'grid']; |
---|
[276] | 3678 | set(handles.txt_GridName,'String',mask_displ) |
---|
| 3679 | set(handles.num_Dx,'Visible','off'); |
---|
| 3680 | set(handles.num_Dy,'Visible','off'); |
---|
[112] | 3681 | else |
---|
[2] | 3682 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3683 | {'*.grid', ' (*.grid)'; |
---|
| 3684 | '*.grid', '.grid files '; ... |
---|
| 3685 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3686 | 'Pick a file',filebase); |
---|
[2] | 3687 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3688 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[282] | 3689 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3690 | set(handles.txt_GridName,'string',''); |
---|
| 3691 | set(handles.num_Dx,'Visible','on'); |
---|
| 3692 | set(handles.num_Dy,'Visible','on'); |
---|
| 3693 | set(handles.txt_GridName,'string',''); |
---|
[2] | 3694 | else |
---|
[276] | 3695 | set(handles.txt_GridName,'string',filegrid); |
---|
| 3696 | set(handles.num_Dx,'Visible','off'); |
---|
| 3697 | set(handles.num_Dy,'Visible','off'); |
---|
| 3698 | set(handles.txt_GridName,'string',filegrid); |
---|
[2] | 3699 | end |
---|
| 3700 | end |
---|
| 3701 | else |
---|
[276] | 3702 | set(handles.txt_GridName,'string',''); |
---|
| 3703 | set(handles.num_Dx,'Visible','on'); |
---|
| 3704 | set(handles.num_Dy,'Visible','on'); |
---|
| 3705 | set(handles.txt_GridName,'string',''); |
---|
[2] | 3706 | end |
---|
| 3707 | |
---|
[282] | 3708 | % % --- Executes on button press in CheckGrid. |
---|
[2] | 3709 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3710 | % |
---|
[71] | 3711 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3712 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3713 | % {'*.grid', ' (*.grid)'; |
---|
| 3714 | % '*.grid', '.grid files '; ... |
---|
| 3715 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3716 | % 'Pick a file',filebase); |
---|
| 3717 | % filegrid=fullfile(PathName,FileName); |
---|
[276] | 3718 | % set(handles.txt_GridName,'string',filegrid); |
---|
| 3719 | % set(handles.num_Dx,'String',' '); |
---|
| 3720 | % set(handles.num_Dy,'String',' '); |
---|
[2] | 3721 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3722 | |
---|
| 3723 | % --- Executes on button press in get_gridpatch1. |
---|
| 3724 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3725 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3726 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3727 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3728 | |
---|
[71] | 3729 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3730 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3731 | {'*.grid', ' (*.grid)'; |
---|
| 3732 | '*.grid', '.grid files '; ... |
---|
| 3733 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3734 | 'Pick a file',filebase); |
---|
[2] | 3735 | filegrid=fullfile(PathName,FileName); |
---|
| 3736 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3737 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3738 | |
---|
[12] | 3739 | %------------------------------------------------------------------------ |
---|
[2] | 3740 | % --- Executes on button press in get_gridpatch2. |
---|
| 3741 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3742 | %------------------------------------------------------------------------ |
---|
[2] | 3743 | |
---|
[12] | 3744 | %------------------------------------------------------------------------ |
---|
[2] | 3745 | function enable_civ1(handles,state) |
---|
[12] | 3746 | %------------------------------------------------------------------------ |
---|
[273] | 3747 | if state |
---|
| 3748 | RootName=get(handles.RootName,'String'); |
---|
| 3749 | if isempty(RootName) |
---|
| 3750 | msgbox_uvmat('ERROR','No input file') |
---|
| 3751 | return |
---|
| 3752 | end |
---|
[282] | 3753 | set(handles.Civ1,'Visible','on') |
---|
| 3754 | set(handles.PairIndices,'Visible','on') |
---|
[273] | 3755 | % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3756 | % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3757 | % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3758 | else |
---|
[282] | 3759 | set(handles.Civ1,'Visible','off') |
---|
[273] | 3760 | % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3761 | % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3762 | % set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 3763 | end |
---|
| 3764 | |
---|
[282] | 3765 | % set(handles.num_Bx,'Visible',state) |
---|
| 3766 | % set(handles.num_By,'Visible',state) |
---|
[287] | 3767 | % set(handles.num_Searchx,'Visible',state) |
---|
| 3768 | % set(handles.num_Searchy,'Visible',state) |
---|
[282] | 3769 | % set(handles.num_Shiftx,'Visible',state) |
---|
| 3770 | % set(handles.num_Shifty,'Visible',state) |
---|
| 3771 | % set(handles.num_Rho,'Visible',state) |
---|
| 3772 | % set(handles.num_Dx,'Visible',state) |
---|
| 3773 | % set(handles.num_Dy,'Visible',state) |
---|
| 3774 | % set(handles.SearchRange,'Visible',state) |
---|
| 3775 | % set(handles.u_title,'Visible',state) |
---|
| 3776 | % set(handles.v_title,'Visible',state) |
---|
| 3777 | % set(handles.min_title,'Visible',state) |
---|
| 3778 | % set(handles.max_title,'Visible',state) |
---|
| 3779 | % set(handles.umin,'Visible',state) |
---|
| 3780 | % set(handles.umax,'Visible',state) |
---|
| 3781 | % set(handles.vmin,'Visible',state) |
---|
| 3782 | % set(handles.vmax,'Visible',state) |
---|
| 3783 | % set(handles.txt_GridName,'Visible',state) |
---|
| 3784 | % set(handles.txt_MaskName,'Visible',state) |
---|
| 3785 | % set(handles.CheckGrid,'Visible',state) |
---|
| 3786 | % set(handles.CheckMask,'Visible',state) |
---|
| 3787 | % set(handles.parameters,'Visible',state) |
---|
| 3788 | % set(handles.grid,'Visible',state) |
---|
| 3789 | % set(handles.num_Dx,'Visible',state) |
---|
| 3790 | % set(handles.num_Dy,'Visible',state) |
---|
| 3791 | % set(handles.check_Threshold,'Visible',state) |
---|
| 3792 | % if isequal(state,'off') |
---|
| 3793 | % set(handles.num_MinIma,'Visible','off') |
---|
| 3794 | % set(handles.num_MaxIma,'Visible','off') |
---|
| 3795 | % set(handles.check_Threshold,'Value',0) |
---|
| 3796 | % end |
---|
| 3797 | % set(handles.dx_civ1_title,'Visible',state) |
---|
| 3798 | % set(handles.dy_civ1_title,'Visible',state) |
---|
| 3799 | % set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3800 | % set(handles.ib_title,'Visible',state) |
---|
| 3801 | % set(handles.is_title,'Visible',state) |
---|
| 3802 | % set(handles.shift_title,'Visible',state) |
---|
| 3803 | % set(handles.rho_title,'Visible',state) |
---|
| 3804 | % set(handles.TestCiv1,'Visible',state) |
---|
| 3805 | %set(handles.ListPairMode,'Visible',state) |
---|
| 3806 | |
---|
[12] | 3807 | %------------------------------------------------------------------------ |
---|
[2] | 3808 | function enable_fix1(handles,state) |
---|
[12] | 3809 | %------------------------------------------------------------------------ |
---|
[273] | 3810 | |
---|
[2] | 3811 | if isequal(state,0) |
---|
| 3812 | state='off'; |
---|
| 3813 | end |
---|
| 3814 | if isequal(state,1) |
---|
| 3815 | state='on'; |
---|
[273] | 3816 | RootName=get(handles.RootName,'String'); |
---|
| 3817 | if isempty(RootName) |
---|
| 3818 | msgbox_uvmat('ERROR','No input file') |
---|
| 3819 | return |
---|
| 3820 | end |
---|
[2] | 3821 | end |
---|
| 3822 | if isequal(state,'on') |
---|
[282] | 3823 | set(handles.Fix1,'Visible','on') |
---|
[273] | 3824 | % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3825 | else |
---|
[282] | 3826 | set(handles.Fix1,'Visible','off') |
---|
[273] | 3827 | %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[2] | 3828 | end |
---|
[282] | 3829 | % % set(handles.REMOVE,'Visible',state) |
---|
| 3830 | % set(handles.CheckFmin2,'Visible',state) |
---|
| 3831 | % set(handles.CheckF2,'Visible',state) |
---|
| 3832 | % set(handles.CheckF3,'Visible',state) |
---|
| 3833 | % set(handles.num_MinCorr,'Visible',state) |
---|
| 3834 | % set(handles.thresh_vecC_title,'Visible',state) |
---|
[287] | 3835 | % set(handles.num_MinVel,'Visible',state) |
---|
| 3836 | % set(handles.TitleMinVel,'Visible',state) |
---|
[282] | 3837 | % set(handles.txt_MaskName,'Visible',state) |
---|
| 3838 | % set(handles.CheckMask,'Visible',state) |
---|
| 3839 | % set(handles.get_ref_fix1,'Visible',state) |
---|
| 3840 | % set(handles.ref_fix1,'Visible',state) |
---|
[287] | 3841 | % set(handles.num_MinVel,'Visible',state) |
---|
[282] | 3842 | % set(handles.field_ref1,'Visible',state) |
---|
[2] | 3843 | |
---|
[12] | 3844 | %------------------------------------------------------------------------ |
---|
[273] | 3845 | function enable_patch1(handles,state) |
---|
[12] | 3846 | %------------------------------------------------------------------------ |
---|
[273] | 3847 | if state |
---|
| 3848 | RootName=get(handles.RootName,'String'); |
---|
| 3849 | if isempty(RootName) |
---|
| 3850 | msgbox_uvmat('ERROR','No input file') |
---|
| 3851 | return |
---|
| 3852 | end |
---|
[282] | 3853 | set(handles.Patch1,'Visible','on') |
---|
[273] | 3854 | else |
---|
[282] | 3855 | set(handles.Patch1,'Visible','off') |
---|
[273] | 3856 | end |
---|
| 3857 | return |
---|
[2] | 3858 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3859 | set(handles.rho_patch1,'Visible','on') |
---|
| 3860 | set(handles.rho_text1,'Visible','on') |
---|
[282] | 3861 | if get(handles.ListPairMode,'Value')==2 |
---|
[224] | 3862 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3863 | set(handles.thresh_text1,'Visible','on') |
---|
| 3864 | end |
---|
[2] | 3865 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3866 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3867 | set(handles.nx_patch1,'Visible','on') |
---|
[274] | 3868 | set(handles.num_Ny,'Visible','on') |
---|
[2] | 3869 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3870 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3871 | % if ~isempty(patch_newBin) |
---|
[224] | 3872 | set(handles.test_interp,'Visible','off'); |
---|
[282] | 3873 | stereo_test=get(handles.ListCompareMode,'Value'); |
---|
[252] | 3874 | if stereo_test==3 |
---|
| 3875 | set(handles.test_stereo1,'Visible','on') |
---|
| 3876 | end |
---|
[100] | 3877 | % end |
---|
[252] | 3878 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 3879 | %set(handles.grid_patch1,'string','none'); |
---|
| 3880 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 3881 | |
---|
[273] | 3882 | % %------------------------------------------------------------------------ |
---|
| 3883 | % function desable_patch1(handles) |
---|
| 3884 | % %------------------------------------------------------------------------ |
---|
| 3885 | % return |
---|
| 3886 | % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3887 | % set(handles.rho_patch1,'Visible','off') |
---|
| 3888 | % set(handles.rho_text1,'Visible','off') |
---|
| 3889 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 3890 | % set(handles.thresh_text1,'Visible','off') |
---|
| 3891 | % set(handles.subdomain_patch1,'Visible','off') |
---|
| 3892 | % set(handles.subdomain_text1,'Visible','off') |
---|
| 3893 | % set(handles.nx_patch1,'Visible','off') |
---|
[274] | 3894 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 3895 | % set(handles.nx_patch1_title,'Visible','off') |
---|
| 3896 | % set(handles.ny_patch1_title,'Visible','off') |
---|
| 3897 | % set(handles.test_stereo1,'Visible','off') |
---|
| 3898 | % %set(handles.test_interp,'Visible','off') |
---|
| 3899 | % %set(handles.get_gridpatch1,'Visible','off') |
---|
| 3900 | % %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 3901 | |
---|
[12] | 3902 | %------------------------------------------------------------------------ |
---|
[2] | 3903 | function enable_civ2(handles,state) |
---|
[12] | 3904 | %------------------------------------------------------------------------ |
---|
[273] | 3905 | if state |
---|
| 3906 | RootName=get(handles.RootName,'String'); |
---|
| 3907 | if isempty(RootName) |
---|
| 3908 | msgbox_uvmat('ERROR','No input file') |
---|
| 3909 | return |
---|
| 3910 | end |
---|
[282] | 3911 | set(handles.Civ2,'Visible','on') |
---|
[289] | 3912 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
| 3913 | set(handles.SubdirCiv2,'Visible','on') |
---|
| 3914 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[2] | 3915 | else |
---|
[282] | 3916 | set(handles.Civ2,'Visible','off') |
---|
[2] | 3917 | end |
---|
[273] | 3918 | |
---|
[282] | 3919 | % |
---|
[287] | 3920 | % set(handles.num_Bx,'Visible',state) |
---|
| 3921 | % set(handles.num_By,'Visible',state) |
---|
| 3922 | % set(handles.CheckDecimal,'Visible',state) |
---|
| 3923 | % set(handles.CheckDeformation,'Visible',state) |
---|
| 3924 | % set(handles.num_Rho,'Visible',state) |
---|
[282] | 3925 | % set(handles.num_Dx,'Visible',state) |
---|
| 3926 | % set(handles.num_Dy,'Visible',state) |
---|
| 3927 | % set(handles.CheckGrid,'Visible',state) |
---|
| 3928 | % set(handles.CheckMask,'Visible',state) |
---|
| 3929 | % set(handles.parameters,'Visible',state) |
---|
| 3930 | % set(handles.grid,'Visible',state) |
---|
| 3931 | % set(handles.parameters_text,'Visible',state) |
---|
| 3932 | % set(handles.grid_text,'Visible',state) |
---|
| 3933 | % set(handles.txt_GridName,'Visible',state) |
---|
| 3934 | % set(handles.txt_Mask,'Visible',state) |
---|
| 3935 | % set(handles.dx_civ2_title,'Visible',state) |
---|
| 3936 | % set(handles.dy_civ2_title,'Visible',state) |
---|
| 3937 | % set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3938 | % set(handles.rho_civ2_title,'Visible',state) |
---|
| 3939 | % set(handles.ImaThreshold2,'Visible',state) |
---|
| 3940 | % set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3941 | % if isequal(state,'off') |
---|
[287] | 3942 | % set(handles.num_MinIma,'Visible','off') |
---|
| 3943 | % set(handles.num_MaxIma,'Visible','off') |
---|
[282] | 3944 | % set(handles.ImaThreshold2,'Value',0) |
---|
| 3945 | % if isequal(get(handles.CheckFix2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
| 3946 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 3947 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 3948 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[282] | 3949 | % set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3950 | % %set(handles.ref_i_civ2,'Visible','off') |
---|
| 3951 | % set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3952 | % set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3953 | % set(handles.ref_j_civ2,'Visible','off') |
---|
| 3954 | % end |
---|
| 3955 | % else |
---|
| 3956 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 3957 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 3958 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 3959 | % set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3960 | % % set(handles.ref_i_civ2,'Visible','on') |
---|
| 3961 | % set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3962 | % set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3963 | % set(handles.ref_j_civ2,'Visible','on') |
---|
| 3964 | % end |
---|
| 3965 | % set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3966 | |
---|
[12] | 3967 | %------------------------------------------------------------------------ |
---|
[273] | 3968 | function enable_fix2(handles,state) |
---|
[12] | 3969 | %------------------------------------------------------------------------ |
---|
[273] | 3970 | % if isequal(state,'on') |
---|
[282] | 3971 | % set(handles.Fix2,'Visible','on') |
---|
[273] | 3972 | % |
---|
| 3973 | % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3974 | % % set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3975 | % % set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3976 | % % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3977 | % else |
---|
| 3978 | if state |
---|
| 3979 | RootName=get(handles.RootName,'String'); |
---|
| 3980 | if isempty(RootName) |
---|
| 3981 | msgbox_uvmat('ERROR','No input file') |
---|
| 3982 | return |
---|
| 3983 | end |
---|
[282] | 3984 | set(handles.Fix2,'Visible','on') |
---|
[273] | 3985 | else |
---|
[282] | 3986 | set(handles.Fix2,'Visible','off') |
---|
[273] | 3987 | end |
---|
[2] | 3988 | |
---|
[282] | 3989 | % set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3990 | % set(handles.REMOVE2,'Visible','on') |
---|
[287] | 3991 | % set(handles.CheckFmin2,'Visible','on') |
---|
| 3992 | % set(handles.CheckF4,'Visible','on') |
---|
| 3993 | % set(handles.CheckF3,'Visible','on') |
---|
| 3994 | % set(handles.num_MinCorr,'Visible','on') |
---|
[282] | 3995 | % set(handles.thresh_vec2C_text,'Visible','on') |
---|
[287] | 3996 | % set(handles.num_MinVel,'Visible','on') |
---|
| 3997 | % set(handles.TitleMinVel,'Visible','on') |
---|
| 3998 | % set(handles.txt_MaskName,'Visible','on') |
---|
[282] | 3999 | % set(handles.CheckMask,'Visible','on') |
---|
| 4000 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 4001 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 4002 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 4003 | % set(handles.get_ref_fix2,'Visible','on') |
---|
| 4004 | % set(handles.ref_fix2,'Visible','on') |
---|
[287] | 4005 | % set(handles.num_MinVel,'Visible','on') |
---|
[282] | 4006 | % set(handles.field_ref2,'Visible','on') |
---|
| 4007 | |
---|
[273] | 4008 | % %------------------------------------------------------------------------ |
---|
| 4009 | % function desable_fix2(handles) |
---|
| 4010 | % %------------------------------------------------------------------------ |
---|
| 4011 | % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4012 | % set(handles.REMOVE2,'Visible','off') |
---|
[287] | 4013 | % set(handles.CheckFmin2,'Visible','off') |
---|
| 4014 | % set(handles.CheckF4,'Visible','off') |
---|
| 4015 | % set(handles.CheckF3,'Visible','off') |
---|
| 4016 | % set(handles.num_MinCorr,'Visible','off') |
---|
[273] | 4017 | % set(handles.thresh_vec2C_text,'Visible','off') |
---|
[287] | 4018 | % set(handles.num_MinVel,'Visible','off') |
---|
| 4019 | % set(handles.TitleMinVel,'Visible','off') |
---|
| 4020 | % set(handles.txt_MaskName,'Visible','off') |
---|
[282] | 4021 | % set(handles.CheckMask,'Visible','off') |
---|
[273] | 4022 | % set(handles.get_ref_fix2,'Visible','off') |
---|
| 4023 | % set(handles.ref_fix2,'Visible','off') |
---|
[287] | 4024 | % set(handles.num_MinVel,'Visible','off') |
---|
[273] | 4025 | % set(handles.field_ref2,'Visible','off') |
---|
[282] | 4026 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
| 4027 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4028 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4029 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[273] | 4030 | % end |
---|
[2] | 4031 | |
---|
[12] | 4032 | %------------------------------------------------------------------------ |
---|
[273] | 4033 | function enable_patch2(handles,state) |
---|
[12] | 4034 | %------------------------------------------------------------------------ |
---|
[273] | 4035 | if state |
---|
| 4036 | RootName=get(handles.RootName,'String'); |
---|
| 4037 | if isempty(RootName) |
---|
| 4038 | msgbox_uvmat('ERROR','No input file') |
---|
| 4039 | return |
---|
| 4040 | end |
---|
[282] | 4041 | set(handles.Patch2,'Visible','on') |
---|
[273] | 4042 | else |
---|
[282] | 4043 | set(handles.Patch2,'Visible','off') |
---|
[252] | 4044 | end |
---|
[273] | 4045 | % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[274] | 4046 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
[292] | 4047 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
[274] | 4048 | % set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 4049 | % set(handles.thresh_text2,'Visible','on') |
---|
[274] | 4050 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
[273] | 4051 | % set(handles.subdomain_text2,'Visible','on') |
---|
[274] | 4052 | % set(handles.num_Nx,'Visible','on') |
---|
| 4053 | % set(handles.num_Ny,'Visible','on') |
---|
[273] | 4054 | % set(handles.nx_patch2_title,'Visible','on') |
---|
| 4055 | % set(handles.ny_patch2_title,'Visible','on') |
---|
| 4056 | % % set(handles.get_gridpatch2,'Visible','on') |
---|
| 4057 | % % set(handles.grid_patch2,'Visible','on') |
---|
[282] | 4058 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 4059 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 4060 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 4061 | % stereo_test=get(handles.ListCompareMode,'Value'); |
---|
[273] | 4062 | % if stereo_test==3 |
---|
[282] | 4063 | % set(handles.CheckStereo,'Visible','on') |
---|
[273] | 4064 | % end |
---|
[2] | 4065 | |
---|
[273] | 4066 | % %------------------------------------------------------------------------ |
---|
| 4067 | % function desable_patch2(handles) |
---|
| 4068 | % %------------------------------------------------------------------------ |
---|
[282] | 4069 | % %set(handles.checkpatch2,'Visible','off') |
---|
[273] | 4070 | % return |
---|
| 4071 | % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[274] | 4072 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
[292] | 4073 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
[274] | 4074 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 4075 | % set(handles.thresh_text2,'Visible','off') |
---|
[274] | 4076 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
[273] | 4077 | % set(handles.subdomain_text2,'Visible','off') |
---|
[274] | 4078 | % set(handles.num_Nx,'Visible','off') |
---|
| 4079 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 4080 | % set(handles.nx_patch2_title,'Visible','off') |
---|
| 4081 | % set(handles.ny_patch2_title,'Visible','off') |
---|
| 4082 | % % set(handles.get_gridpatch2,'Visible','off') |
---|
| 4083 | % % set(handles.grid_patch2,'Visible','off') |
---|
[282] | 4084 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckFix2,'Value'),0) |
---|
| 4085 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4086 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4087 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[273] | 4088 | % end |
---|
[282] | 4089 | % set(handles.CheckStereo,'Visible','off') |
---|
[12] | 4090 | %------------------------------------------------------------------------ |
---|
[2] | 4091 | function enable_pair1(handles,state) |
---|
[12] | 4092 | %------------------------------------------------------------------------ |
---|
[289] | 4093 | set(handles.txt_SubdirCiv1,'Visible',state) |
---|
[282] | 4094 | set(handles.ListSubdirCiv1,'Visible',state) |
---|
[289] | 4095 | set(handles.TitleSubdirCiv1,'Visible',state) |
---|
[273] | 4096 | %set(handles.frame_subdirciv1,'Visible',state) |
---|
[282] | 4097 | set(handles.ListPairCiv1,'Visible',state) |
---|
[289] | 4098 | set(handles.TitlePairCiv1,'Visible',state) |
---|
[71] | 4099 | %set(handles.dt_unit,'Visible',state) |
---|
[273] | 4100 | %set(handles.PAIR_frame,'Visible',state) |
---|
[2] | 4101 | |
---|
[12] | 4102 | %------------------------------------------------------------------------ |
---|
[282] | 4103 | % --- Read the parameters for checkciv1 on the interface |
---|
[285] | 4104 | % function par=read_param_civ1(handles,filecell) |
---|
| 4105 | % % not deeden anymore |
---|
| 4106 | % %------------------------------------------------------------------------ |
---|
| 4107 | % ibx_val=str2double(get(handles.num_Bx,'String')); |
---|
| 4108 | % par.ibx=num2str(ibx_val); |
---|
| 4109 | % iby_val=str2double(get(handles.num_By,'String')); |
---|
| 4110 | % par.iby=num2str(iby_val); |
---|
[287] | 4111 | % isx=get(handles.num_Searchx,'String'); |
---|
| 4112 | % if isnan(str2double(isx)), isx='41'; set(handles.num_Searchx,'String','41'), end; %default |
---|
| 4113 | % if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.num_Searchx,'String',num2str(ibx_val+8)); end |
---|
| 4114 | % isy=get(handles.num_Searchy,'String'); |
---|
| 4115 | % if isnan(str2double(isy)), isy='41'; set(handles.num_Searchy,'String','41'), end;%default |
---|
| 4116 | % if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.num_Searchy,'String',num2str(iby_val+8)); end |
---|
| 4117 | % par.isx=get(handles.num_Searchx,'String'); |
---|
| 4118 | % par.isy=get(handles.num_Searchy,'String'); |
---|
[285] | 4119 | % par.shiftx=get(handles.num_Shiftx,'String'); |
---|
| 4120 | % par.shifty=get(handles.num_Shifty,'String'); |
---|
| 4121 | % if isnan(str2double(par.isx)) |
---|
| 4122 | % par.isx='41';%default |
---|
[287] | 4123 | % set(handles.num_Searchx,'String','41'); |
---|
[272] | 4124 | % end |
---|
[285] | 4125 | % if isnan(str2double(par.isy)) |
---|
| 4126 | % par.isy='41'; %default |
---|
[287] | 4127 | % set(handles.num_Searchy,'String','41'); |
---|
[285] | 4128 | % end |
---|
| 4129 | % if isnan(str2double(par.shiftx)) |
---|
| 4130 | % par.shiftx='0';%default |
---|
| 4131 | % set(handles.num_Shiftx,'String','0'); |
---|
| 4132 | % end |
---|
| 4133 | % if isnan(str2double(par.shifty)) |
---|
| 4134 | % par.shifty='0'; %default |
---|
| 4135 | % set(handles.num_Shifty,'String','0'); |
---|
| 4136 | % end |
---|
| 4137 | % par.rho=get(handles.num_Rho,'String'); |
---|
| 4138 | % if isequal(get(handles.num_Rho,'Style'),'popupmenu') |
---|
| 4139 | % index=get(handles.num_Rho,'Value'); |
---|
| 4140 | % par.rho=par.rho{index}; |
---|
| 4141 | % end |
---|
| 4142 | % dummy=get(handles.num_Dx,'String'); |
---|
| 4143 | % par.dx=dummy{1}; |
---|
| 4144 | % dummy=get(handles.num_Dy,'String'); |
---|
| 4145 | % par.dy=dummy{1}; |
---|
| 4146 | % if isnan(str2double(par.dx)) |
---|
| 4147 | % if isempty(get(handles.txt_GridName,'String')); |
---|
| 4148 | % par.dx='0'; %just read by civ program, not used |
---|
| 4149 | % else |
---|
| 4150 | % par.dx='20';%default |
---|
| 4151 | % set(handles.num_Dx,'String','20'); |
---|
| 4152 | % end |
---|
| 4153 | % end |
---|
| 4154 | % if isnan(str2double(par.dy)) |
---|
| 4155 | % if isempty(get(handles.txt_GridName,'String')); |
---|
| 4156 | % par.dy='0';%just read by civ program, not used |
---|
| 4157 | % else |
---|
| 4158 | % par.dy='20';%default |
---|
| 4159 | % set(handles.dy_civ1_title,'String','20'); |
---|
| 4160 | % end |
---|
| 4161 | % end |
---|
| 4162 | % par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4163 | % par.pxcmy='1'; |
---|
| 4164 | % % if exist('file_ima','var') |
---|
| 4165 | % A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 4166 | % sizim=size(A); |
---|
| 4167 | % par.npx=num2str(sizim(2)); |
---|
| 4168 | % par.npy=num2str(sizim(1)); |
---|
| 4169 | % %TODO : civ should not need npx and npy |
---|
| 4170 | % |
---|
| 4171 | % |
---|
| 4172 | % % end |
---|
| 4173 | % %time=get(handles.RootName,'UserData'); %get the set of times |
---|
| 4174 | % dummy=get(handles.txt_GridName,'String'); |
---|
| 4175 | % par.gridname=dummy{1}; |
---|
| 4176 | % par.gridflag='y'; |
---|
| 4177 | % if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
| 4178 | % par.gridname='nogrid'; |
---|
| 4179 | % par.gridflag='n'; |
---|
| 4180 | % end |
---|
| 4181 | % |
---|
[272] | 4182 | |
---|
| 4183 | |
---|
| 4184 | %------------------------------------------------------------------------ |
---|
[2] | 4185 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4186 | %------------------------------------------------------------------------ |
---|
[287] | 4187 | par.ibx=get(handles.num_Bx,'String'); |
---|
| 4188 | par.iby=get(handles.num_By,'String'); |
---|
| 4189 | par.rho=get(handles.num_Rho,'String'); |
---|
| 4190 | par.decimal=int2str(get(handles.CheckDecimal,'Value')); |
---|
| 4191 | par.deformation=int2str(get(handles.CheckDeformation,'Value')); |
---|
[276] | 4192 | par.dx=get(handles.num_Dx,'String'); |
---|
| 4193 | par.dy=get(handles.num_Dy,'String'); |
---|
[127] | 4194 | if isnan(str2double(par.dx)) |
---|
[276] | 4195 | if isempty(get(handles.txt_GridName,'String')); |
---|
[112] | 4196 | par.dx='0'; %just read by civ program, not used |
---|
| 4197 | else |
---|
[12] | 4198 | par.dx='20';%default |
---|
[276] | 4199 | set(handles.num_Dx,'String','20'); |
---|
[112] | 4200 | end |
---|
| 4201 | end |
---|
[127] | 4202 | if isnan(str2double(par.dy)) |
---|
[276] | 4203 | if isempty(get(handles.txt_GridName,'String')); |
---|
[112] | 4204 | par.dy='0';%just read by civ program, not used |
---|
| 4205 | else |
---|
[12] | 4206 | par.dy='20';%default |
---|
[276] | 4207 | set(handles.num_Dy,'String','20'); |
---|
[112] | 4208 | end |
---|
| 4209 | end |
---|
| 4210 | par.pxcmx='1'; |
---|
| 4211 | par.pxcmy='1'; |
---|
[12] | 4212 | A=imread(file_ima);%read the first image to get the size |
---|
| 4213 | sizim=size(A); |
---|
| 4214 | par.npx=num2str(sizim(2)); |
---|
| 4215 | par.npy=num2str(sizim(1)); |
---|
[127] | 4216 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[276] | 4217 | par.gridname=get(handles.txt_GridName,'String'); |
---|
[12] | 4218 | par.gridflag='y'; |
---|
[127] | 4219 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4220 | par.gridname='nogrid'; |
---|
| 4221 | par.gridflag='n'; |
---|
| 4222 | end |
---|
[2] | 4223 | |
---|
[272] | 4224 | function cmd_CIV1=CIV1_CMD(filename,param) |
---|
| 4225 | %TODO : include filename in par_civ1 |
---|
[12] | 4226 | %------------------------------------------------------------------------ |
---|
[2] | 4227 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4228 | |
---|
| 4229 | %changes : filename_cmx -> filename ( no extension ) |
---|
[272] | 4230 | |
---|
[275] | 4231 | filename=regexprep(filename,'.nc',''); |
---|
[272] | 4232 | |
---|
[284] | 4233 | if isequal(Param.Civ1.Dt,'0') |
---|
| 4234 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4235 | end |
---|
[284] | 4236 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
| 4237 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
[230] | 4238 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4239 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[284] | 4240 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4241 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[112] | 4242 | fprintf(fid, ['XX' '\n' ]); |
---|
[284] | 4243 | fprintf(fid, ['Mask ' Param.Civ1.maskflag '\n' ]); |
---|
| 4244 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.maskname,'\\','\\\\') '\n' ]); |
---|
| 4245 | fprintf(fid, ['ImageSize ' Param.Civ1.npx ' ' Param.Civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4246 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ1.ibx ' ' Param.Civ1.iby '\n' ]); |
---|
| 4247 | fprintf(fid, ['SearchBoxeSize ' Param.Civ1.isx ' ' Param.Civ1.isy '\n' ]); |
---|
| 4248 | fprintf(fid, ['RO ' Param.Civ1.rho '\n' ]); |
---|
| 4249 | fprintf(fid, ['GridSpacing ' Param.Civ1.dx ' ' Param.Civ1.dy '\n' ]); |
---|
[112] | 4250 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[284] | 4251 | fprintf(fid, ['Dt_TO ' Param.Civ1.Dt ' ' Param.Civ1.T0 '\n' ]); |
---|
| 4252 | fprintf(fid, ['PixCmXY ' Param.Civ1.pxcmx ' ' Param.Civ1.pxcmy '\n' ]); |
---|
[112] | 4253 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[284] | 4254 | fprintf(fid, ['ShiftXY ' Param.Civ1.shiftx ' ' Param.Civ1.shifty '\n' ]); |
---|
| 4255 | fprintf(fid, ['Grid ' Param.Civ1.gridflag '\n' ]); |
---|
| 4256 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.gridname,'\\','\\\\') '\n' ]); |
---|
[112] | 4257 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4258 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4259 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4260 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4261 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4262 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4263 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4264 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4265 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4266 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[284] | 4267 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
[112] | 4268 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4269 | fclose(fid); |
---|
[112] | 4270 | |
---|
[163] | 4271 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4272 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4273 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4274 | if(isunix) |
---|
[272] | 4275 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; |
---|
| 4276 | cmd_CIV1=[cmd_CIV1 '\n'... |
---|
[284] | 4277 | 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] | 4278 | 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] | 4279 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv1.cmx' '\n'];%rename .cmx as .checkciv1.cmx |
---|
[163] | 4280 | else %Windows system |
---|
[269] | 4281 | % flname=regexprep(flname,'\\','\\\\'); |
---|
[282] | 4282 | % cmd=[cmd 'copy /Y "' flname '.checkciv1.cmx" "' flname '.cmx"\n']; |
---|
[269] | 4283 | % filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4284 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx |
---|
[284] | 4285 | cmd_CIV1=[cmd_CIV1 '\n "' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[272] | 4286 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 4287 | cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4288 | |
---|
[282] | 4289 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv1.cmx"']; |
---|
[12] | 4290 | end |
---|
[2] | 4291 | |
---|
[12] | 4292 | %------------------------------------------------------------------------ |
---|
[282] | 4293 | % --- CheckCiv1 Unified |
---|
[94] | 4294 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4295 | %------------------------------------------------------------------------ |
---|
[2] | 4296 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4297 | %global CivBin%name of the executable for checkciv1 calculation |
---|
[2] | 4298 | |
---|
[112] | 4299 | civ1.image1=par.filename_ima_a; |
---|
| 4300 | civ1.image2=par.filename_ima_b; |
---|
| 4301 | civ1.imageSize_X=par.npx; |
---|
| 4302 | civ1.imageSize_Y=par.npy; |
---|
| 4303 | civ1.outputFileName=[filename '.nc']; |
---|
| 4304 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4305 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4306 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4307 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4308 | civ1.globalShift_X=par.shiftx; |
---|
| 4309 | civ1.globalShift_Y=par.shifty; |
---|
| 4310 | civ1.ro=par.rho; |
---|
| 4311 | civ1.hart='y'; |
---|
| 4312 | if isequal(par.gridflag,'y') |
---|
| 4313 | civ1.grid=par.gridname; |
---|
| 4314 | else |
---|
| 4315 | civ1.grid='n'; |
---|
| 4316 | civ1.gridSpacing_X=par.dx; |
---|
| 4317 | civ1.gridSpacing_Y=par.dy; |
---|
| 4318 | end |
---|
| 4319 | if isequal(par.maskflag,'y') |
---|
| 4320 | civ1.mask=par.maskname; |
---|
| 4321 | end |
---|
[229] | 4322 | civ1.dt=par.Dt; |
---|
[112] | 4323 | civ1.unit='pixel'; |
---|
| 4324 | civ1.absolut_time_T0=par.T0; |
---|
| 4325 | civ1.pixcmx=par.pxcmx; |
---|
| 4326 | civ1.pixcmy=par.pxcmy; |
---|
| 4327 | civ1.convectFlow='n'; |
---|
[12] | 4328 | |
---|
[112] | 4329 | xml_civ1_parameters=civ1; |
---|
| 4330 | |
---|
[12] | 4331 | %------------------------------------------------------------------------ |
---|
[282] | 4332 | % --- CheckCiv2 Unified |
---|
[94] | 4333 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4334 | %------------------------------------------------------------------------ |
---|
[2] | 4335 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4336 | %global CivBin%name of the executable for checkciv1 calculation |
---|
[275] | 4337 | |
---|
[272] | 4338 | filename=regexprep(filename,'.nc',''); |
---|
[2] | 4339 | |
---|
| 4340 | civ2.image1=par.filename_ima_a; |
---|
| 4341 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4342 | civ2.imageSize_X=par.npx; |
---|
[2] | 4343 | civ2.imageSize_Y=par.npy; |
---|
| 4344 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4345 | civ2.outputFileName=[filename '.nc']; |
---|
| 4346 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4347 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4348 | civ2.ro=par.rho; |
---|
[287] | 4349 | %checkciv2.decimalShift=par.CheckDecimal; |
---|
| 4350 | %checkciv2.CheckDeformation=par.CheckDeformation; |
---|
[2] | 4351 | if isequal(par.decimal,'1') |
---|
| 4352 | civ2.decimalShift='y'; |
---|
| 4353 | else |
---|
| 4354 | civ2.decimalShift='n'; |
---|
| 4355 | end |
---|
| 4356 | if isequal(par.deformation,'1') |
---|
| 4357 | civ2.deformation='y'; |
---|
| 4358 | else |
---|
| 4359 | civ2.deformation='n'; |
---|
| 4360 | end |
---|
| 4361 | if isequal(par.gridflag,'y') |
---|
| 4362 | civ2.grid=par.gridname; |
---|
| 4363 | else |
---|
| 4364 | civ2.grid='n'; |
---|
| 4365 | civ2.gridSpacing_X=par.dx; |
---|
| 4366 | civ2.gridSpacing_Y=par.dy; |
---|
| 4367 | end |
---|
| 4368 | civ2.gridSpacing_X='10'; |
---|
| 4369 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4370 | if isequal(par.maskflag,'y') |
---|
| 4371 | civ2.mask=par.maskname; |
---|
| 4372 | else |
---|
| 4373 | civ2.mask='n'; |
---|
| 4374 | end |
---|
| 4375 | civ2.dt=par.Dt; |
---|
| 4376 | civ2.unit='pixel'; |
---|
| 4377 | civ2.absolut_time_T0=par.T0; |
---|
| 4378 | civ2.pixcmx=par.pxcmx; |
---|
| 4379 | civ2.pixcmy=par.pxcmy; |
---|
| 4380 | civ2.convectFlow='n'; |
---|
| 4381 | civ2.pixcmx=par.pxcmx; |
---|
| 4382 | civ2.pixcmy=par.pxcmy; |
---|
| 4383 | civ2.convectFlow='n'; |
---|
| 4384 | |
---|
[12] | 4385 | %------------------------------------------------------------------------ |
---|
[282] | 4386 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
[272] | 4387 | function cmd_CIV2=CIV2_CMD(filename,param) |
---|
[12] | 4388 | %------------------------------------------------------------------------ |
---|
[2] | 4389 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4390 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
[275] | 4391 | filename=regexprep(filename,'.nc',''); |
---|
[290] | 4392 | if isequal(Param.Civ2.Dt,'0') |
---|
| 4393 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4394 | end |
---|
[290] | 4395 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
| 4396 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4397 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4398 | if isequal(fid,-1) |
---|
| 4399 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4400 | cmd_CIV2=''; |
---|
| 4401 | return |
---|
| 4402 | end |
---|
[94] | 4403 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[290] | 4404 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4405 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[94] | 4406 | fprintf(fid, ['XX' '\n' ]); |
---|
[290] | 4407 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 4408 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4409 | fprintf(fid, ['ImageSize ' Param.Civ2.npx ' ' Param.Civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4410 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n' ]); |
---|
| 4411 | fprintf(fid, ['SearchBoxeSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n']); |
---|
| 4412 | fprintf(fid, ['RO ' Param.Civ2.rho '\n']); |
---|
| 4413 | fprintf(fid, ['GridSpacing ' Param.Civ2.dx ' ' Param.Civ2.dy '\n']); |
---|
[94] | 4414 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[290] | 4415 | fprintf(fid, ['Dt_TO ' Param.Civ2.Dt ' ' Param.Civ2.T0 '\n' ]); |
---|
| 4416 | fprintf(fid, ['PixCmXY ' Param.Civ2.pxcmx ' ' Param.Civ2.pxcmy '\n' ]); |
---|
[94] | 4417 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4418 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[290] | 4419 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 4420 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
[94] | 4421 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4422 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4423 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4424 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
[290] | 4425 | fprintf(fid, ['DecimalShift ' Param.Civ2.decimal '\n']); |
---|
| 4426 | fprintf(fid, ['Deformation ' Param.Civ2.deformation '\n']); |
---|
[94] | 4427 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4428 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4429 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4430 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[290] | 4431 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 4432 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
[94] | 4433 | fclose(fid); |
---|
| 4434 | |
---|
[134] | 4435 | if(isunix) |
---|
[230] | 4436 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
[284] | 4437 | 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] | 4438 | 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] | 4439 | % 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] | 4440 | |
---|
[163] | 4441 | else |
---|
[174] | 4442 | filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4443 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; |
---|
[284] | 4444 | cmd_CIV2=[cmd_CIV2 '\n "' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[272] | 4445 | cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[282] | 4446 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv2.cmx"']; |
---|
[134] | 4447 | end |
---|
| 4448 | |
---|
| 4449 | |
---|
[12] | 4450 | %------------------------------------------------------------------------ |
---|
[2] | 4451 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4452 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4453 | %------------------------------------------------------------------------ |
---|
[2] | 4454 | %num is the view number needed for an avi movie |
---|
[45] | 4455 | switch type_ima |
---|
| 4456 | case 'movie' |
---|
| 4457 | A=read(movieobject,num); |
---|
| 4458 | case 'avi' |
---|
[112] | 4459 | mov=aviread(filename,num); |
---|
| 4460 | A=frame2im(mov(1)); |
---|
[45] | 4461 | case 'multimage' |
---|
| 4462 | A=imread(filename,num); |
---|
[112] | 4463 | case 'image' |
---|
[45] | 4464 | A=imread(filename); |
---|
| 4465 | end |
---|
| 4466 | siz=size(A); |
---|
| 4467 | if length(siz)==3;%color images |
---|
[2] | 4468 | A=sum(double(A),3); |
---|
| 4469 | A=uint16(A); |
---|
| 4470 | end |
---|
| 4471 | |
---|
[12] | 4472 | %------------------------------------------------------------------------ |
---|
[2] | 4473 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4474 | %------------------------------------------------------------------------ |
---|
[282] | 4475 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4476 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 4477 | mode=mode_list{mode_value}; |
---|
[45] | 4478 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4479 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[282] | 4480 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[2] | 4481 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4482 | end |
---|
| 4483 | |
---|
[12] | 4484 | %------------------------------------------------------------------------ |
---|
[2] | 4485 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4486 | %------------------------------------------------------------------------ |
---|
[282] | 4487 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4488 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 4489 | mode=mode_list{mode_value}; |
---|
[282] | 4490 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4491 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4492 | end |
---|
[45] | 4493 | if isequal(mode,'series(Dj)') || ... |
---|
[282] | 4494 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[2] | 4495 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4496 | end |
---|
[12] | 4497 | |
---|
| 4498 | %------------------------------------------------------------------------ |
---|
[71] | 4499 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4500 | %------------------------------------------------------------------------ |
---|
[282] | 4501 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4502 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[71] | 4503 | mode=mode_list{mode_value}; |
---|
| 4504 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4505 | |
---|
| 4506 | %------------------------------------------------------------------------ |
---|
| 4507 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4508 | %------------------------------------------------------------------------ |
---|
[282] | 4509 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4510 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[71] | 4511 | mode=mode_list{mode_value}; |
---|
[112] | 4512 | if isequal(mode,'series(Dj)') |
---|
[71] | 4513 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4514 | end |
---|
| 4515 | |
---|
| 4516 | %------------------------------------------------------------------------ |
---|
[282] | 4517 | % --- Executes on button press in ListCompareMode. |
---|
| 4518 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
[12] | 4519 | %------------------------------------------------------------------------ |
---|
[282] | 4520 | test=get(handles.ListCompareMode,'Value'); |
---|
[263] | 4521 | if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' |
---|
[71] | 4522 | filebase=get(handles.RootName,'String'); |
---|
[273] | 4523 | browse=get(handlesRootName,'Userdata'); |
---|
[2] | 4524 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
[273] | 4525 | set(handlesRootName,'UserData',browse); |
---|
[2] | 4526 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4527 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[282] | 4528 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
| 4529 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
| 4530 | set(handles.ListPairMode,'Visible','off') |
---|
[2] | 4531 | if test==2 |
---|
[282] | 4532 | set(handles.ListPairMode,'Visible','off') |
---|
| 4533 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4534 | else |
---|
[282] | 4535 | set(handles.ListPairMode,'Visible','on') |
---|
| 4536 | set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo |
---|
[2] | 4537 | end |
---|
| 4538 | |
---|
[273] | 4539 | %% menuopen an image file with the browser |
---|
[2] | 4540 | ind_opening=1;%default |
---|
| 4541 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4542 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4543 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4544 | '*.xml', '.xml files '; ... |
---|
| 4545 | '*.civ', '.civ files '; ... |
---|
| 4546 | '*.png','.png image files'; ... |
---|
| 4547 | '*.jpg',' jpeg image files'; ... |
---|
| 4548 | '*.tif','.tif image files'; ... |
---|
| 4549 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4550 | '*.nc','.netcdf files'; ... |
---|
| 4551 | '*.*', 'All Files (*.*)'}; |
---|
| 4552 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4553 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4554 | sizf=size(fileinput); |
---|
[229] | 4555 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[275] | 4556 | [path,name,ext]=fileparts(fileinput); |
---|
[2] | 4557 | [path1]=fileparts(filebase); |
---|
[263] | 4558 | if isunix |
---|
[289] | 4559 | [status,path]=system(['readlink ' path]); |
---|
| 4560 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
[263] | 4561 | end |
---|
[2] | 4562 | if ~strcmp(path1,path) |
---|
[263] | 4563 | msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') |
---|
[2] | 4564 | return |
---|
[263] | 4565 | end |
---|
| 4566 | % set(handles.RootName_1,'String',name); |
---|
[2] | 4567 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
[263] | 4568 | set(handles.RootName_1,'String',RootFile); |
---|
[273] | 4569 | browse=get(handlesRootName,'UserData'); |
---|
[2] | 4570 | browse.nom_type_ima_1=nom_type; |
---|
[273] | 4571 | set(handlesRootName,'UserData',browse) |
---|
[2] | 4572 | |
---|
| 4573 | %check image extension |
---|
[71] | 4574 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[263] | 4575 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
[2] | 4576 | return |
---|
| 4577 | end |
---|
| 4578 | |
---|
[229] | 4579 | %% check coincidence of image sizes |
---|
[263] | 4580 | % ref_i=get(handles.ref_i,'string'); |
---|
| 4581 | % ref_j=get(handles.ref_j,'string'); |
---|
| 4582 | % [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] | 4583 | % A=imread(filecell.ima1.checkciv1{1}); |
---|
[263] | 4584 | % A_1=imread(fileinput); |
---|
| 4585 | % npxy=size(A); |
---|
| 4586 | % npxy_1=size(A_1); |
---|
| 4587 | % if ~isequal(size(A),size(A_1)) |
---|
| 4588 | % msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
| 4589 | % return |
---|
| 4590 | % end |
---|
[2] | 4591 | else |
---|
[282] | 4592 | set(handles.ListPairMode,'Visible','on') |
---|
[71] | 4593 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4594 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4595 | set(handles.RootName_1,'String',[]); |
---|
[282] | 4596 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 4597 | set(handles.ListPairMode,'Value',1) |
---|
| 4598 | set(handles.ListPairMode,'String',mode_store) |
---|
[2] | 4599 | set(handles.test_stereo1,'Value',0) |
---|
[282] | 4600 | set(handles.CheckStereo,'Value',0) |
---|
| 4601 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4602 | end |
---|
[282] | 4603 | if test==3 && get(handles.CheckPatch1,'Value') |
---|
[263] | 4604 | set(handles.test_stereo1,'Visible','on') |
---|
[252] | 4605 | else |
---|
[263] | 4606 | set(handles.test_stereo1,'Visible','off') |
---|
[252] | 4607 | end |
---|
[282] | 4608 | if test==3 && get(handles.CheckPatch2,'Value') |
---|
| 4609 | set(handles.CheckStereo,'Visible','on') |
---|
[252] | 4610 | else |
---|
[282] | 4611 | set(handles.CheckStereo,'Visible','off') |
---|
[252] | 4612 | end |
---|
[2] | 4613 | mode_Callback(hObject, eventdata, handles) |
---|
| 4614 | |
---|
[12] | 4615 | %------------------------------------------------------------------------ |
---|
[2] | 4616 | % --- Executes on button press in get_ref_fix1. |
---|
| 4617 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4618 | %------------------------------------------------------------------------ |
---|
[71] | 4619 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4620 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4621 | {'*.nc', ' (*.nc)'; |
---|
| 4622 | '*.nc', 'netcdf files '; ... |
---|
| 4623 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4624 | 'Pick a file',filebase); |
---|
| 4625 | |
---|
[2] | 4626 | fileinput=[PathName FileName]; |
---|
| 4627 | sizf=size(fileinput); |
---|
[122] | 4628 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4629 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4630 | ref.filebase=fullfile(Path,File); |
---|
| 4631 | ref.num_a=stra2num(str_a); |
---|
| 4632 | ref.num_b=stra2num(str_b); |
---|
[89] | 4633 | ref.num1=str2double(field_count); |
---|
| 4634 | ref.num2=str2double(str2); |
---|
[2] | 4635 | browse=[];%initialisation |
---|
| 4636 | if ~isequal(ref.ext,'.nc') |
---|
| 4637 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4638 | return |
---|
| 4639 | end |
---|
| 4640 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4641 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4642 | menu_field{1}='civ1'; |
---|
| 4643 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4644 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4645 | menu_field{2}='filter1'; |
---|
| 4646 | end |
---|
[45] | 4647 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4648 | menu_field{3}='civ2'; |
---|
| 4649 | end |
---|
[45] | 4650 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4651 | menu_field{4}='filter2'; |
---|
| 4652 | end |
---|
| 4653 | set(handles.field_ref1,'String',menu_field); |
---|
| 4654 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
[287] | 4655 | set(handles.num_MinVel,'Value',2); |
---|
| 4656 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 4657 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4658 | |
---|
| 4659 | %------------------------------------------------------------------------ |
---|
[2] | 4660 | % --- Executes on button press in get_ref_fix2. |
---|
| 4661 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4662 | %------------------------------------------------------------------------ |
---|
[2] | 4663 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4664 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4665 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4666 | {'*.nc', ' (*.nc)'; |
---|
| 4667 | '*.nc', 'netcdf files '; ... |
---|
| 4668 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4669 | 'Pick a file',filebase); |
---|
[2] | 4670 | fileinput=[PathName FileName]; |
---|
| 4671 | sizf=size(fileinput); |
---|
[45] | 4672 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4673 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4674 | ref.filebase=fullfile(Path,File); |
---|
| 4675 | ref.num_a=stra2num(str_a); |
---|
| 4676 | ref.num_b=stra2num(str_b); |
---|
| 4677 | ref.num1=str2num(field_count); |
---|
| 4678 | ref.num2=str2num(str2); |
---|
| 4679 | browse=[];%initialisation |
---|
| 4680 | if ~isequal(ref.ext,'.nc') |
---|
| 4681 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4682 | return |
---|
| 4683 | end |
---|
| 4684 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4685 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4686 | menu_field{1}='civ1'; |
---|
| 4687 | Data=nc2struct(fileinput,[]); |
---|
| 4688 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4689 | menu_field{2}='filter1'; |
---|
| 4690 | end |
---|
| 4691 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4692 | menu_field{3}='civ2'; |
---|
| 4693 | end |
---|
| 4694 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4695 | menu_field{4}='filter2'; |
---|
| 4696 | end |
---|
| 4697 | set(handles.field_ref2,'String',menu_field); |
---|
| 4698 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
[287] | 4699 | set(handles.num_MinVel,'Value',2); |
---|
| 4700 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 4701 | set(handles.ref_fix2,'Enable','on') |
---|
| 4702 | set(handles.ref_fix2,'Visible','on') |
---|
| 4703 | set(handles.field_ref2,'Visible','on') |
---|
| 4704 | else |
---|
| 4705 | set(handles.ref_fix2,'Visible','off') |
---|
| 4706 | set(handles.field_ref2,'Visible','off') |
---|
| 4707 | end |
---|
| 4708 | |
---|
[12] | 4709 | %------------------------------------------------------------------------ |
---|
[2] | 4710 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4711 | %------------------------------------------------------------------------ |
---|
[287] | 4712 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 4713 | set(handles.field_ref1,'Value',1) |
---|
| 4714 | set(handles.field_ref1,'String',{' '}) |
---|
| 4715 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4716 | set(handles.ref_fix1,'String',''); |
---|
| 4717 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4718 | |
---|
[12] | 4719 | %------------------------------------------------------------------------ |
---|
[2] | 4720 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4721 | %------------------------------------------------------------------------ |
---|
[287] | 4722 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 4723 | set(handles.field_ref2,'Value',1) |
---|
| 4724 | set(handles.field_ref2,'String',{' '}) |
---|
| 4725 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4726 | set(handles.ref_fix2,'String',''); |
---|
[287] | 4727 | set(handles.num_MinVel,'String','0'); |
---|
[2] | 4728 | |
---|
[12] | 4729 | %------------------------------------------------------------------------ |
---|
[2] | 4730 | % --- Executes on button press in test_stereo1. |
---|
| 4731 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4732 | %------------------------------------------------------------------------ |
---|
[2] | 4733 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4734 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4735 | set(handles.rho_patch1,'Visible','on') |
---|
| 4736 | else |
---|
| 4737 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4738 | set(handles.rho_patch1,'Visible','off') |
---|
| 4739 | end |
---|
| 4740 | |
---|
[12] | 4741 | %------------------------------------------------------------------------ |
---|
[282] | 4742 | % --- Executes on button press in CheckStereo. |
---|
[273] | 4743 | function StereoCheck_Callback(hObject, eventdata, handles) |
---|
[12] | 4744 | %------------------------------------------------------------------------ |
---|
[282] | 4745 | if isequal(get(handles.CheckStereo,'Value'),0) |
---|
[274] | 4746 | set(handles.num_SubdomainSize,'Visible','on') |
---|
[292] | 4747 | set(handles.num_SmoothingParam,'Visible','on') |
---|
[2] | 4748 | else |
---|
[274] | 4749 | set(handles.num_SubdomainSize,'Visible','off') |
---|
[292] | 4750 | set(handles.num_SmoothingParam,'Visible','off') |
---|
[2] | 4751 | end |
---|
| 4752 | |
---|
[12] | 4753 | %------------------------------------------------------------------------ |
---|
[276] | 4754 | % --- Executes on button press in check_Threshold. |
---|
[2] | 4755 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4756 | %------------------------------------------------------------------------ |
---|
[276] | 4757 | if isequal(get(handles.check_Threshold,'Value'),1) |
---|
[282] | 4758 | set(handles.num_MinIma,'Visible','on') |
---|
| 4759 | set(handles.num_MaxIma,'Visible','on') |
---|
[2] | 4760 | else |
---|
[282] | 4761 | set(handles.num_MinIma,'Visible','off') |
---|
| 4762 | set(handles.num_MaxIma,'Visible','off') |
---|
[2] | 4763 | end |
---|
| 4764 | |
---|
[12] | 4765 | %------------------------------------------------------------------------ |
---|
[2] | 4766 | % --- Executes on button press in ImaThreshold2. |
---|
| 4767 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4768 | %------------------------------------------------------------------------ |
---|
[2] | 4769 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
[287] | 4770 | set(handles.num_MinIma,'Visible','on') |
---|
| 4771 | set(handles.num_MaxIma,'Visible','on') |
---|
[2] | 4772 | else |
---|
[287] | 4773 | set(handles.num_MinIma,'Visible','off') |
---|
| 4774 | set(handles.num_MaxIma,'Visible','off') |
---|
[2] | 4775 | end |
---|
| 4776 | |
---|
[224] | 4777 | %------------------------------------------------------------------------ |
---|
[225] | 4778 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4779 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4780 | %------------------------------------------------------------------------ |
---|
[233] | 4781 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
| 4782 | drawnow |
---|
[150] | 4783 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4784 | if test_civ1 |
---|
[227] | 4785 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4786 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4787 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4788 | else |
---|
| 4789 | ref_j=1;%default |
---|
| 4790 | end |
---|
[224] | 4791 | [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] | 4792 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[224] | 4793 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4794 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4795 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4796 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4797 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4798 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4799 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4800 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4801 | par_civ1.T0=0; |
---|
| 4802 | par_civ1.Dt=1; |
---|
[246] | 4803 | Param.Civ1=par_civ1; |
---|
| 4804 | Data=civ_uvmat(Param); |
---|
[231] | 4805 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4806 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4807 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4808 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4809 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4810 | hview_field=view_field(Data); |
---|
| 4811 | set(0,'CurrentFigure',hview_field) |
---|
| 4812 | hhview_field=guihandles(hview_field); |
---|
| 4813 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4814 | ViewData=get(hview_field,'UserData'); |
---|
| 4815 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4816 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[236] | 4817 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
| 4818 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
[231] | 4819 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4820 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4821 | if isempty(corrfig) |
---|
| 4822 | corrfig=figure; |
---|
| 4823 | set(corrfig,'tag','corrfig') |
---|
| 4824 | set(corrfig,'name','image correlation') |
---|
| 4825 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4826 | end |
---|
[233] | 4827 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 4828 | else |
---|
| 4829 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4830 | if ~isempty(corrfig) |
---|
| 4831 | delete(corrfig) |
---|
| 4832 | end |
---|
| 4833 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4834 | if ~isempty(hview_field) |
---|
| 4835 | delete(hview_field) |
---|
| 4836 | end |
---|
[150] | 4837 | end |
---|
[71] | 4838 | |
---|
[224] | 4839 | function closeview_field(gcbo,eventdata) |
---|
| 4840 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4841 | if ~isempty(hview_field) |
---|
| 4842 | delete(hview_field) |
---|
| 4843 | end |
---|
[177] | 4844 | %------------------------------------------------------------------- |
---|
| 4845 | % --- Executes on button press in status. |
---|
| 4846 | function status_Callback(hObject, eventdata, handles) |
---|
| 4847 | %------------------------------------------------------------------- |
---|
| 4848 | val=get(handles.status,'Value'); |
---|
| 4849 | if val==0 |
---|
[252] | 4850 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
[177] | 4851 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4852 | if ~isempty(hfig) |
---|
| 4853 | delete(hfig) |
---|
| 4854 | end |
---|
| 4855 | return |
---|
| 4856 | end |
---|
[252] | 4857 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 4858 | drawnow |
---|
[177] | 4859 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
[282] | 4860 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
| 4861 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
| 4862 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
| 4863 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
| 4864 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
| 4865 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
[284] | 4866 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
| 4867 | |
---|
[180] | 4868 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[252] | 4869 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 4870 | test_new=0; |
---|
[177] | 4871 | if ~isfield(filecell,'nc') |
---|
[252] | 4872 | test_new=1; |
---|
[227] | 4873 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 4874 | if ~isempty(errormsg) |
---|
| 4875 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4876 | return |
---|
| 4877 | end |
---|
[252] | 4878 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
[177] | 4879 | end |
---|
| 4880 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
[252] | 4881 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
[177] | 4882 | else |
---|
| 4883 | civ_files=filecell.nc.civ1; |
---|
| 4884 | end |
---|
| 4885 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 4886 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 4887 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4888 | if isempty(hfig) |
---|
[252] | 4889 | hfig=figure('DeleteFcn',@stop_status); |
---|
[177] | 4890 | set(hfig,'name','civ_status') |
---|
[182] | 4891 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[252] | 4892 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
[177] | 4893 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 4894 | 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] | 4895 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 4896 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
[252] | 4897 | drawnow |
---|
[177] | 4898 | end |
---|
[188] | 4899 | % datnum=[]; |
---|
[177] | 4900 | Tabchar={}; |
---|
| 4901 | nbfiles=numel(civ_files); |
---|
| 4902 | count=0; |
---|
[188] | 4903 | testrecent=0; |
---|
[177] | 4904 | while count<nbfiles |
---|
| 4905 | count=0; |
---|
[188] | 4906 | datnum=zeros(1,nbfiles); |
---|
[177] | 4907 | for ifile=1:nbfiles |
---|
| 4908 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 4909 | option=0; |
---|
[177] | 4910 | if detect==0 |
---|
[179] | 4911 | option_str='not created'; |
---|
[177] | 4912 | else |
---|
[219] | 4913 | datfile=dir(civ_files{ifile}); |
---|
[188] | 4914 | if isfield(datfile,'datenum') |
---|
| 4915 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 4916 | testrecent=1; |
---|
| 4917 | end |
---|
[177] | 4918 | filefound(ifile)={datfile.name}; |
---|
| 4919 | lastfield=''; |
---|
| 4920 | % check the content netcdf file |
---|
| 4921 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 4922 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 4923 | option=6; |
---|
| 4924 | option_str='patch2'; |
---|
[177] | 4925 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 4926 | option=5; |
---|
| 4927 | option_str='fix2'; |
---|
[177] | 4928 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 4929 | option=4; |
---|
| 4930 | option_str='civ2'; |
---|
[177] | 4931 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 4932 | option=3; |
---|
| 4933 | option_str='patch1'; |
---|
[177] | 4934 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 4935 | option=2; |
---|
| 4936 | option_str='fix1'; |
---|
[177] | 4937 | else |
---|
[179] | 4938 | option=1; |
---|
| 4939 | option_str='civ1'; |
---|
[177] | 4940 | end |
---|
| 4941 | end |
---|
[179] | 4942 | if option >= option_civ |
---|
[177] | 4943 | count=count+1; |
---|
| 4944 | end |
---|
| 4945 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 4946 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 4947 | end |
---|
[219] | 4948 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 4949 | if isempty(datnum) |
---|
| 4950 | if testrecent |
---|
| 4951 | message='no civ result created yet'; |
---|
| 4952 | else |
---|
| 4953 | message=''; |
---|
| 4954 | end |
---|
[177] | 4955 | else |
---|
[219] | 4956 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 4957 | [first,ind]=min(datnum); |
---|
| 4958 | [last,indlast]=max(datnum); |
---|
[252] | 4959 | if test_new |
---|
| 4960 | message='existing file status, no processing launched yet'; |
---|
| 4961 | else |
---|
[177] | 4962 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 4963 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
[252] | 4964 | end |
---|
[177] | 4965 | end |
---|
| 4966 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
[252] | 4967 | if isempty(hfig)% the status list has been deleted |
---|
[177] | 4968 | return |
---|
| 4969 | else |
---|
| 4970 | hlist=findobj(hfig,'tag','list'); |
---|
| 4971 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 4972 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 4973 | set(hlist,'String',Tabchar) |
---|
| 4974 | set(hmsgbox,'String', message) |
---|
[252] | 4975 | if count>0 && ~test_new |
---|
[177] | 4976 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 4977 | set(hwaitbar,'Position',BarPosition) |
---|
| 4978 | end |
---|
| 4979 | end |
---|
| 4980 | set(hlist,'UserData',rootroot) |
---|
[252] | 4981 | pause(10)% wait 10 seconds for next check |
---|
[177] | 4982 | end |
---|
[150] | 4983 | |
---|
[177] | 4984 | |
---|
[252] | 4985 | %------------------------------------------------------------------------ |
---|
| 4986 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
[177] | 4987 | function open_view_field(hObject, eventdata) |
---|
[252] | 4988 | %------------------------------------------------------------------------ |
---|
| 4989 | list=get(hObject,'String'); |
---|
| 4990 | index=get(hObject,'Value'); |
---|
| 4991 | rootroot=get(hObject,'UserData'); |
---|
| 4992 | filename=list{index}; |
---|
| 4993 | ind_dot=findstr(filename,'...'); |
---|
| 4994 | filename=filename(1:ind_dot-1); |
---|
| 4995 | filename=fullfile(rootroot,filename); |
---|
| 4996 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 4997 | if exist(filename,'file')%visualise the vel field if it exists |
---|
| 4998 | uvmat(filename) |
---|
| 4999 | set(gcbo,'Value',1) |
---|
| 5000 | end |
---|
[150] | 5001 | |
---|
[252] | 5002 | %------------------------------------------------------------------------ |
---|
| 5003 | % launched by pressing OK on the status figure |
---|
[182] | 5004 | function close_GUI(hObject, eventdata) |
---|
[252] | 5005 | %------------------------------------------------------------------------ |
---|
| 5006 | delete(gcbf) |
---|
| 5007 | |
---|
| 5008 | %------------------------------------------------------------------------ |
---|
| 5009 | % launched by deleting the status figure |
---|
| 5010 | function stop_status(hObject, eventdata) |
---|
| 5011 | %------------------------------------------------------------------------ |
---|
| 5012 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 5013 | hhciv=guidata(hciv); |
---|
| 5014 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 5015 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
[220] | 5016 | |
---|
[252] | 5017 | %------------------------------------------------------------------------ |
---|
[282] | 5018 | % % --- Executes on button press in ListPairMode. |
---|
[273] | 5019 | % function CivMode_Callback(hObject, eventdata, handles) |
---|
| 5020 | % %------------------------------------------------------------------------ |
---|
[282] | 5021 | % Listprog=get(handles.ListPairMode,'String'); |
---|
| 5022 | % index=get(handles.ListPairMode,'Value'); |
---|
[273] | 5023 | % prog=Listprog{index}; |
---|
| 5024 | % switch prog |
---|
| 5025 | % case 'CivX' |
---|
| 5026 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 5027 | % set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5028 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5029 | % set(handles.thresh_text2,'Visible','off') |
---|
[282] | 5030 | % set(handles.num_Rho,'Style','edit') |
---|
| 5031 | % set(handles.num_Rho,'String','1') |
---|
[273] | 5032 | % set(handles.BATCH,'Enable','on') |
---|
| 5033 | % case 'CivAll' |
---|
[282] | 5034 | % if get(handles.CheckPatch1,'Value') |
---|
[273] | 5035 | % set(handles.thresh_patch1,'Visible','on') |
---|
| 5036 | % set(handles.thresh_text1,'Visible','on') |
---|
| 5037 | % end |
---|
[282] | 5038 | % set(handles.num_Rho,'Style','edit') |
---|
| 5039 | % set(handles.num_Rho,'String','1') |
---|
[273] | 5040 | % set(handles.BATCH,'Enable','on') |
---|
| 5041 | % case 'CivUvmat' |
---|
| 5042 | % |
---|
| 5043 | % end |
---|
| 5044 | |
---|
| 5045 | |
---|
| 5046 | % -------------------------------------------------------------------- |
---|
| 5047 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[276] | 5048 | path_civ=fileparts(which ('civ')); |
---|
| 5049 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
| 5050 | if isempty(dir(helpfile)) |
---|
| 5051 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
[273] | 5052 | else |
---|
[276] | 5053 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
[273] | 5054 | web([helpfile '#civ']) |
---|
[224] | 5055 | end |
---|
[273] | 5056 | |
---|
| 5057 | % -------------------------------------------------------------------- |
---|
| 5058 | function CivX_Callback(hObject, eventdata, handles) |
---|
| 5059 | %set(handles.thresh_patch1,'Visible','off') |
---|
| 5060 | set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5061 | set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5062 | set(handles.thresh_text2,'Visible','off') |
---|
[282] | 5063 | set(handles.num_Rho,'Style','edit') |
---|
| 5064 | set(handles.num_Rho,'String','1') |
---|
[273] | 5065 | set(handles.BATCH,'Enable','on') |
---|
| 5066 | |
---|
| 5067 | % -------------------------------------------------------------------- |
---|
| 5068 | function Matlab_Callback(hObject, eventdata, handles) |
---|
| 5069 | set(handles.Matlab,'checked','on') |
---|
| 5070 | set(handles.CivX,'checked','off') |
---|
[282] | 5071 | if get(handles.CheckPatch1,'Value') |
---|
[273] | 5072 | set(handles.thresh_patch1,'Visible','on') |
---|
| 5073 | set(handles.thresh_text1,'Visible','on') |
---|
| 5074 | end |
---|
[282] | 5075 | if get(handles.CheckPatch2,'Value') |
---|
[274] | 5076 | set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 5077 | set(handles.thresh_text2,'Visible','on') |
---|
| 5078 | end |
---|
[282] | 5079 | set(handles.num_Rho,'Style','popupmenu') |
---|
| 5080 | set(handles.num_Rho,'Value',1) |
---|
| 5081 | set(handles.num_Rho,'String',{'1';'2'}) |
---|
[273] | 5082 | set(handles.BATCH,'Enable','off') |
---|
| 5083 | |
---|
| 5084 | % -------------------------------------------------------------------- |
---|
| 5085 | % --- read a panel with handle 'handle' producing a structure 'struct' |
---|
| 5086 | function struct=read_panel(handle) |
---|
| 5087 | hchild=get(handle,'children'); |
---|
| 5088 | for ichild=1:numel(hchild) |
---|
[282] | 5089 | if strcmp(get(hchild(ichild),'Visible'),'on') |
---|
| 5090 | object_style=get(hchild(ichild),'Style'); |
---|
| 5091 | tag=get(hchild(ichild),'tag'); |
---|
| 5092 | check_input=1;%default |
---|
| 5093 | switch object_style |
---|
| 5094 | case 'edit' |
---|
| 5095 | switch(tag(1:4)) |
---|
| 5096 | case 'num_' |
---|
| 5097 | input=str2double(get(hchild(ichild),'String')); |
---|
| 5098 | %deal with undefined input: retrieve the default value stored as UserData |
---|
| 5099 | if isnan(input) |
---|
| 5100 | input=get(hchild(ichild),'UserData'); |
---|
| 5101 | set(hchild(ichild),'String',num2str(input)) |
---|
| 5102 | end |
---|
| 5103 | case 'txt_' |
---|
| 5104 | input=get(hchild(ichild),'String'); |
---|
| 5105 | end |
---|
| 5106 | key=tag(5:end); |
---|
| 5107 | case 'checkbox' |
---|
| 5108 | input=get(hchild(ichild),'Value'); |
---|
| 5109 | key=tag(7:end); |
---|
| 5110 | otherwise |
---|
| 5111 | check_input=0; |
---|
| 5112 | end |
---|
| 5113 | if check_input |
---|
| 5114 | eval(['struct.' key '=input;']) |
---|
| 5115 | end |
---|
[273] | 5116 | end |
---|
| 5117 | end |
---|
[284] | 5118 | |
---|
| 5119 | |
---|
| 5120 | |
---|
| 5121 | function cmd=cmd_civ1(filename,Param) |
---|
| 5122 | %TODO : include filename in par_civ1 |
---|
| 5123 | %------------------------------------------------------------------------ |
---|
| 5124 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 5125 | |
---|
| 5126 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 5127 | |
---|
[285] | 5128 | filename=regexprep(filename,'.nc',''); |
---|
[284] | 5129 | |
---|
| 5130 | if isequal(Param.Civ1.Dt,'0') |
---|
| 5131 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
| 5132 | end |
---|
| 5133 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
| 5134 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
| 5135 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
| 5136 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5137 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5138 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5139 | fprintf(fid, ['XX' '\n' ]); |
---|
[285] | 5140 | fprintf(fid, ['Mask ' Param.Civ1.MaskFlag '\n' ]); |
---|
| 5141 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.MaskName,'\\','\\\\') '\n' ]); |
---|
[284] | 5142 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.npx) ' ' num2str(Param.Civ1.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5143 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]); |
---|
[287] | 5144 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]); |
---|
[284] | 5145 | fprintf(fid, ['RO ' num2str(Param.Civ1.Rho) '\n' ]); |
---|
| 5146 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
| 5147 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5148 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.T0) '\n' ]); |
---|
| 5149 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ1.pxcmx) ' ' num2str(Param.Civ1.pxcmy) '\n' ]); |
---|
| 5150 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5151 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' ' num2str(Param.Civ1.Shifty) '\n' ]); |
---|
[285] | 5152 | fprintf(fid, ['Grid ' Param.Civ1.GridFlag '\n' ]); |
---|
| 5153 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]); |
---|
[284] | 5154 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5155 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5156 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5157 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5158 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 5159 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 5160 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5161 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5162 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5163 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5164 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
| 5165 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 5166 | fclose(fid); |
---|
| 5167 | |
---|
| 5168 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 5169 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 5170 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 5171 | if(isunix) |
---|
| 5172 | cmd=['cp -f ' filename '.civ1.cmx ' filename '.cmx \n '];% the cmx file gives the name to the nc file |
---|
| 5173 | 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 |
---|
| 5174 | % 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 |
---|
| 5175 | % cmd=[cmd '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
| 5176 | cmd=[cmd 'rm ' filename '.cmx']; |
---|
| 5177 | else %Windows system |
---|
| 5178 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 5179 | cmd=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx" \n ']; |
---|
| 5180 | cmd=[cmd '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\')... |
---|
| 5181 | '" -f "' filename '.cmx" >"' filename '.civ1.log" \n ' ]; % redirect standard output to the log file |
---|
| 5182 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 5183 | % cmd=[cmd '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
[290] | 5184 | cmd=[cmd 'del "' filename '.cmx"']; |
---|
[284] | 5185 | end |
---|
[285] | 5186 | |
---|
| 5187 | |
---|
| 5188 | function cmd=cmd_fix(filename,Param,fixname) |
---|
| 5189 | %% |
---|
[291] | 5190 | switch fixname |
---|
| 5191 | case 'Fix1' |
---|
| 5192 | fi2_value=num2str(Param.(fixname).CheckF2); |
---|
| 5193 | case 'Fix2' |
---|
| 5194 | fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... |
---|
| 5195 | end |
---|
| 5196 | |
---|
| 5197 | |
---|
| 5198 | |
---|
[285] | 5199 | filename=regexprep(filename,'.nc',''); |
---|
[287] | 5200 | MaskName_string='';%default |
---|
| 5201 | if Param.(fixname).CheckMask |
---|
[288] | 5202 | MaskName_string=[' -maskName "' Param.(fixname).MaskName '"']; |
---|
[287] | 5203 | end |
---|
| 5204 | MaxVel_string='';%default |
---|
| 5205 | if ~isempty(Param.(fixname).MaxVel) |
---|
[289] | 5206 | MaxVel_string=[' -threshV ' num2str(Param.(fixname).MaxVel)]; |
---|
[287] | 5207 | end |
---|
[285] | 5208 | if isunix |
---|
[287] | 5209 | cmd=[Param.xml.FixBin ' -f ' filename '.nc -fi1 ' num2str(Param.(fixname).CheckFmin2) ... |
---|
[291] | 5210 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[287] | 5211 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
| 5212 | ' >' filename '.' lower(fixname) '.log 2>&1']; |
---|
[285] | 5213 | else |
---|
| 5214 | cmd=['"' Param.xml.FixBin '" -f "' filename '.nc" -fi1 ' num2str(Param.(fixname).CheckFmin2)... |
---|
[291] | 5215 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[288] | 5216 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
| 5217 | ' > "' filename '.' lower(fixname) '.log"']; |
---|
[285] | 5218 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 5219 | end |
---|
[286] | 5220 | |
---|
| 5221 | |
---|
| 5222 | function cmd=cmd_patch(filename,Param,patchname) |
---|
| 5223 | %% ------------------------------------------------------------------------ |
---|
| 5224 | filename=regexprep(filename,'.nc',''); |
---|
| 5225 | % if test_interp==0 |
---|
| 5226 | if isunix |
---|
| 5227 | cmd=[Param.xml.PatchBin... |
---|
| 5228 | ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)... |
---|
[292] | 5229 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
[286] | 5230 | ' -nopt ' num2str(Param.(patchname).SubdomainSize) ... |
---|
| 5231 | ' > ' filename '.' lower(patchname) '.log 2>&1']; % redirect standard output to the log file |
---|
| 5232 | else |
---|
| 5233 | cmd=['"' Param.xml.PatchBin... |
---|
| 5234 | '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)... |
---|
[292] | 5235 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
[286] | 5236 | ' -nopt ' num2str(Param.(patchname).SubdomainSize)... |
---|
| 5237 | ' > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file |
---|
| 5238 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 5239 | end |
---|
| 5240 | % else %nouveau programme patch |
---|
| 5241 | % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 5242 | % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 5243 | % end |
---|
[290] | 5244 | |
---|
| 5245 | |
---|
| 5246 | %------------------------------------------------------------------------ |
---|
| 5247 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
| 5248 | function cmd=cmd_civ2(filename,Param) |
---|
| 5249 | %------------------------------------------------------------------------ |
---|
| 5250 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 5251 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
| 5252 | filename=regexprep(filename,'.nc',''); |
---|
| 5253 | if isequal(Param.Civ2.Dt,'0') |
---|
| 5254 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
| 5255 | end |
---|
| 5256 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
| 5257 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
| 5258 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 5259 | if isequal(fid,-1) |
---|
| 5260 | msgbox_uvmat('ERROR',errormsg) |
---|
| 5261 | cmd=''; |
---|
| 5262 | return |
---|
| 5263 | end |
---|
| 5264 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5265 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5266 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5267 | fprintf(fid, ['XX' '\n' ]); |
---|
| 5268 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 5269 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5270 | fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5271 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]); |
---|
| 5272 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']); |
---|
| 5273 | fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']); |
---|
| 5274 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); |
---|
| 5275 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5276 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.T0) '\n' ]); |
---|
| 5277 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ2.pxcmx) ' ' num2str(Param.Civ2.pxcmy) '\n' ]); |
---|
| 5278 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5279 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
| 5280 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 5281 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
| 5282 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5283 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5284 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5285 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5286 | fprintf(fid, ['DecimalShift ' num2str(Param.Civ2.CheckDecimal) '\n']); |
---|
| 5287 | fprintf(fid, ['Deformation ' num2str(Param.Civ2.CheckDeformation) '\n']); |
---|
| 5288 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5289 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5290 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5291 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5292 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 5293 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
| 5294 | fclose(fid); |
---|
| 5295 | |
---|
| 5296 | if(isunix) |
---|
| 5297 | cmd=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n'... |
---|
| 5298 | 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 |
---|
| 5299 | 'rm ' filename '.cmx \n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 5300 | else |
---|
| 5301 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 5302 | cmd=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx" \n'... |
---|
| 5303 | '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.civ2.log" \n'... |
---|
| 5304 | 'del "' filename '.cmx" \n']; |
---|
| 5305 | end |
---|