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