[2] | 1 | %'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % provides an interface for the software CIVx |
---|
| 4 | % function varargout = civ_3D(varargin) |
---|
| 5 | % provides an interface for the software CIVx |
---|
| 6 | % |
---|
| 7 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 8 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 9 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 10 | % This file is part of the toolbox UVMAT. |
---|
| 11 | % |
---|
| 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. |
---|
| 16 | % |
---|
| 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_3D(varargin) |
---|
| 23 | |
---|
[71] | 24 | % Last Modified by GUIDE v2.5 26-Mar-2010 22:51:31 |
---|
[2] | 25 | % Begin initialization code - DO NOT EDIT |
---|
| 26 | gui_Singleton = 1; |
---|
| 27 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 28 | 'gui_Singleton', gui_Singleton, ... |
---|
| 29 | 'gui_OpeningFcn', @civ_3D_OpeningFcn, ... |
---|
| 30 | 'gui_OutputFcn', @civ_3D_OutputFcn, ... |
---|
| 31 | 'gui_LayoutFcn', [] , ... |
---|
| 32 | 'gui_Callback', []); |
---|
| 33 | if nargin & isstr(varargin{1}) |
---|
| 34 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 35 | end |
---|
| 36 | |
---|
| 37 | if nargout |
---|
| 38 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 39 | else |
---|
| 40 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 41 | end |
---|
| 42 | % End initialization code - DO NOT EDIT |
---|
| 43 | |
---|
| 44 | %-------------------------------------------------------------------------- |
---|
| 45 | % --- Executes just before civ_3D is made visible. |
---|
| 46 | %-------------------------------------------------------------------------- |
---|
| 47 | function civ_3D_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
| 48 | % This function has no output args, see OutputFcn. |
---|
| 49 | % hObject handle to figure |
---|
| 50 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 51 | % handles structure with handles and user data (see GUIDATA) |
---|
| 52 | % varargin command line arguments to civ_3D (see VARARGIN) |
---|
| 53 | global test_batch patch_new_exe%=1 if patch processing available |
---|
| 54 | %filebase: root name |
---|
| 55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
| 56 | %list of field numbers to process |
---|
| 57 | %subdir: subdirectory of the opened netcdf file |
---|
| 58 | %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), |
---|
| 59 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
| 60 | % Choose default command line output for civ_3D |
---|
| 61 | handles.output = hObject; |
---|
| 62 | % Update handles structure |
---|
| 63 | guidata(hObject, handles); |
---|
| 64 | |
---|
| 65 | %default initial parameters |
---|
| 66 | filebase=''; % root file name ('filebase'.civ_3D) |
---|
| 67 | nom_type=[]; % nomenclature type |
---|
| 68 | ext=[]; |
---|
| 69 | testall=0; |
---|
| 70 | browse=[]; |
---|
| 71 | |
---|
| 72 | %load the initial parameters if the interface is started from uvmat |
---|
| 73 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 74 | varcell=varargin{1}; |
---|
| 75 | filebase=varcell{1}; |
---|
| 76 | nom_type_read=varcell{2}; |
---|
| 77 | num1=varcell{3}; |
---|
| 78 | num2=varcell{4}; |
---|
| 79 | num_a=varcell{5}; |
---|
| 80 | num_b=varcell{6}; |
---|
| 81 | subdir=varcell{7}; |
---|
| 82 | ind_opening=varcell{8}; |
---|
| 83 | ind_a_opening=varcell{9}; |
---|
| 84 | ind_b_opening=varcell{10}; |
---|
| 85 | ext=varcell{11}; |
---|
| 86 | else |
---|
| 87 | num1=1; % set of field i numbers |
---|
| 88 | num2=2; % set of field i numbers |
---|
| 89 | num_a=1; % set of field j numbers (fields a) |
---|
| 90 | num_b=1; % second set of field j numbers (fields b) |
---|
| 91 | subdir='A'; % subdir for the netcdf result files |
---|
| 92 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 93 | ind_a_opening=1; % proposed index in the menu of fields a |
---|
| 94 | ind_b_opening=2; % proposed index in the menu of fields b |
---|
| 95 | end |
---|
| 96 | |
---|
| 97 | if exist('ext','var') & length(ext)>1 & (~isempty(imformats(ext([2:end])))|... |
---|
| 98 | isequal(ext,'.avi')|isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
| 99 | browse.ext_ima=ext; |
---|
| 100 | if exist('nom_type_read','var') |
---|
| 101 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 102 | end |
---|
| 103 | elseif isequal(ext,'.nc') |
---|
| 104 | if exist('nom_type_read','var') |
---|
| 105 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 106 | end |
---|
| 107 | end |
---|
| 108 | set(handles.displ_filebase,'String',filebase); |
---|
| 109 | set(handles.ImaDoc,'UserData',testall); |
---|
| 110 | set(handles.browse_root,'UserData',browse) |
---|
| 111 | set(handles.ImaDoc,'String',ext) |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | % set(handles.ImaDoc,'String',ext) |
---|
| 115 | |
---|
| 116 | %read names of the .exe file to adjust the interface according to |
---|
| 117 | %available prog |
---|
| 118 | %read names of the .exe file |
---|
| 119 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 120 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 121 | if isunix |
---|
| 122 | syst='LINUX' |
---|
| 123 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ_3D binary names |
---|
| 124 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml') |
---|
| 125 | if exist(xmlfile,'file') |
---|
| 126 | t=xmltree(xmlfile); |
---|
| 127 | sparam=convert(t); |
---|
| 128 | end |
---|
| 129 | else |
---|
| 130 | syst='WIN' |
---|
| 131 | %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ_3D binary names |
---|
| 132 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 133 | if exist(xmlfile,'file') |
---|
| 134 | t=xmltree(xmlfile); |
---|
| 135 | sparam=convert(t); |
---|
| 136 | end |
---|
| 137 | end |
---|
| 138 | |
---|
| 139 | patch_new_exe=''; |
---|
| 140 | todo_patch=''; |
---|
| 141 | sge=0; |
---|
| 142 | |
---|
| 143 | if isfield(sparam,'PatchNew_exe') |
---|
| 144 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 145 | end |
---|
| 146 | if isfield(sparam,'Todo_path') |
---|
| 147 | todo_path=sparam.Todo_path |
---|
| 148 | end |
---|
| 149 | if isfield(sparam,'SGE') |
---|
| 150 | sge=str2num(sparam.SGE); |
---|
| 151 | end |
---|
| 152 | name_todo=fullfile(todo_path,'TODO.txt') |
---|
| 153 | test_batch=1; |
---|
| 154 | if ~sge |
---|
| 155 | if isequal(todo_path,'') |isequal(todo_path,[]) |
---|
| 156 | ['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst] |
---|
| 157 | test_batch=0; |
---|
| 158 | end |
---|
| 159 | if exist(name_todo,'file')~=2 |
---|
[42] | 160 | msgbox_uvmat('ERROR',['no batch distributed processing available, queue file ' name_todo ' absent']); |
---|
[2] | 161 | % test_batch=0; % Problems to detect file on linux/nfs filesystems |
---|
| 162 | end |
---|
| 163 | end |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | if test_batch==0 |
---|
| 167 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 168 | end |
---|
| 169 | |
---|
| 170 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 171 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 172 | |
---|
| 173 | %initiate advised operations |
---|
| 174 | if isequal(ind_opening,[]) |
---|
| 175 | ind_opening=1; % default |
---|
| 176 | end |
---|
| 177 | % set default operation options |
---|
| 178 | enable_civ1(handles,'off') |
---|
| 179 | enable_civ2(handles,'off') |
---|
| 180 | desable_fix1(handles) |
---|
| 181 | desable_patch1(handles) |
---|
| 182 | desable_fix2(handles) |
---|
| 183 | desable_patch2(handles) |
---|
| 184 | set(handles.CIV1,'Value',0) |
---|
| 185 | set(handles.FIX1,'Value',0) |
---|
| 186 | set(handles.PATCH1,'Value',0) |
---|
| 187 | set(handles.CIV2,'Value',0) |
---|
| 188 | set(handles.FIX2,'Value',0) |
---|
| 189 | set(handles.PATCH2,'Value',0) |
---|
| 190 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 191 | if isequal(ind_opening,1) |
---|
| 192 | set(handles.CIV1,'Value',1) |
---|
| 193 | enable_civ1(handles,'on') |
---|
| 194 | elseif isequal(ind_opening,2) |
---|
| 195 | set(handles.FIX1,'Value',1) |
---|
| 196 | enable_fix1(handles) |
---|
| 197 | elseif isequal(ind_opening,3) |
---|
| 198 | set(handles.PATCH1,'Value',1) |
---|
| 199 | enable_patch1(handles) |
---|
| 200 | elseif isequal(ind_opening,4) |
---|
| 201 | set(handles.CIV2,'Value',1) |
---|
| 202 | enable_civ2(handles,1) |
---|
| 203 | elseif isequal(ind_opening,5) |
---|
| 204 | set(handles.FIX2,'Value',1) |
---|
| 205 | enable_fix2(handles) |
---|
| 206 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 207 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 208 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 209 | elseif isequal(ind_opening,6) |
---|
| 210 | set(handles.PATCH2,'Value',1) |
---|
| 211 | enable_patch2(handles) |
---|
| 212 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 213 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 214 | end |
---|
| 215 | |
---|
| 216 | % set the range of fields (1:1 by default) and selected pair |
---|
| 217 | if isempty(num2)|isequal(num2,num1) |
---|
| 218 | num_ref_i=num1; |
---|
| 219 | else |
---|
| 220 | num_ref_i=floor((num1+num2)/2); |
---|
| 221 | browse.incr_pair(1)=num2-num1; |
---|
| 222 | browse.incr_pair(2)=0; |
---|
| 223 | end |
---|
| 224 | if isempty(num_b)|isequal(num_a,num_b) |
---|
| 225 | if isempty(num_a) |
---|
| 226 | num_ref_j=1; |
---|
| 227 | else |
---|
| 228 | num_ref_j=num_a; |
---|
| 229 | end |
---|
| 230 | else |
---|
| 231 | num_ref_j=floor((num_a+num_b)/2); |
---|
| 232 | browse.incr_pair(2)=num_b-num_a; |
---|
| 233 | end |
---|
| 234 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 235 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 236 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 237 | set(handles.browse_root,'UserData',browse); |
---|
| 238 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 239 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 240 | end |
---|
| 241 | |
---|
| 242 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 243 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 244 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 245 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 246 | |
---|
| 247 | |
---|
| 248 | %-------------------------------------------------------------- |
---|
| 249 | % --- Outputs from this function are returned to the command line. |
---|
| 250 | %----------------------------------------------------------------- |
---|
| 251 | function varargout = civ_3D_OutputFcn(hObject, eventdata, handles) |
---|
| 252 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 253 | % hObject handle to figure |
---|
| 254 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 255 | % handles structure with handles and user data (see GUIDATA) |
---|
| 256 | % Get default command line output from handles structure |
---|
| 257 | varargout{1} = handles.output; |
---|
| 258 | |
---|
| 259 | %------------------------------------------------------------------ |
---|
| 260 | % --- Executes on button press in browse_root. |
---|
| 261 | function browse_root_Callback(hObject, eventdata, handles) |
---|
| 262 | %get the input file properties |
---|
| 263 | filebase=get(handles.displ_filebase,'String'); |
---|
| 264 | oldfile=''; %default |
---|
| 265 | if isempty(filebase)|isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
| 266 | dir_perso=prefdir; |
---|
| 267 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat') |
---|
| 268 | if exist(profil_perso,'file') |
---|
| 269 | h=load (profil_perso); |
---|
| 270 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 271 | oldfile=h.filebase; |
---|
| 272 | end |
---|
| 273 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 274 | % oldfile=h.filebase{1} |
---|
| 275 | oldfile=h.RootPath; |
---|
| 276 | end |
---|
| 277 | end |
---|
| 278 | else |
---|
| 279 | oldfile=filebase; |
---|
| 280 | end |
---|
| 281 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 282 | ind_opening=1;%default |
---|
| 283 | browse.incr_pair=[0 0]; %default |
---|
| 284 | |
---|
| 285 | menu={'*.*', 'All Files (*.*)'; '*.xml;*.vol; *.avi;*.AVI','(*.xml,*.civ,*.avi,*.vol)'; ... |
---|
| 286 | '*.xml', '.xml files';'*.civ', '.civ files';... |
---|
| 287 | '*.avi;*.AVI', '.avi files';'*.vol', '.vol files'}; |
---|
| 288 | |
---|
| 289 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 290 | fileinput=[PathName FileName];%complete file name |
---|
| 291 | sizf=size(fileinput); |
---|
| 292 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 293 | [path,name,ext]=fileparts(fileinput); |
---|
| 294 | testeditxml=0; |
---|
| 295 | if isequal(ext,'.xml') |
---|
| 296 | testeditxml=1; |
---|
| 297 | t_browse=xmltree(fileinput); |
---|
| 298 | head_element=get(t_browse,1); |
---|
| 299 | if isfield(head_element,'name')& isequal(head_element.name,'ImaDoc') |
---|
| 300 | testeditxml=0; |
---|
| 301 | end |
---|
| 302 | end |
---|
| 303 | if testeditxml==1 | isequal(ext,'.xls') |
---|
| 304 | heditxml=editxml({fileinput}); |
---|
| 305 | set(heditxml,'Tag','browser') |
---|
| 306 | waitfor(heditxml,'Tag','idle') |
---|
| 307 | if ~ishandle(heditxml) |
---|
| 308 | return |
---|
| 309 | end |
---|
| 310 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 311 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 312 | fileinput=get(attr,'UserData'); |
---|
| 313 | if ~exist(fileinput,'file') |
---|
| 314 | return |
---|
| 315 | end |
---|
| 316 | end |
---|
| 317 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
| 318 | filebase=fullfile(RootPath,RootFile); |
---|
| 319 | if isequal(get(handles.compare,'Value'),1) |
---|
| 320 | browse=get(handles.browse_root,'UserData'); |
---|
| 321 | else |
---|
| 322 | browse=[];%initialisation |
---|
| 323 | end |
---|
| 324 | if length(ext)>1 & (~isempty(imformats(ext([2:end])))||... |
---|
| 325 | isequal(lower(ext),'.avi')||isequal(ext,'.vol'));%if an image file has been opened by uvmat |
---|
| 326 | browse.ext_ima=ext; |
---|
| 327 | browse.nom_type_ima=nom_type; |
---|
| 328 | browse.field_count=str2num(field_count); |
---|
| 329 | end |
---|
| 330 | set(handles.ImaDoc,'String',ext); |
---|
| 331 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 332 | if isequal(ext,'.nc') |
---|
| 333 | browse.nom_type_nc=nom_type; |
---|
| 334 | ind_opening=2;% propose 'fix' as the default option |
---|
| 335 | Data=nc2struct(fileinput,[]); |
---|
| 336 | if isfield(Data,'fix') & isequal(Data.fix,1) |
---|
| 337 | ind_opening=3; |
---|
| 338 | end |
---|
| 339 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 340 | ind_opening=4; |
---|
| 341 | end |
---|
| 342 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 343 | ind_opening=5; |
---|
| 344 | end |
---|
| 345 | if isfield(Data,'fix2') & isequal(Data.fix2,1) |
---|
| 346 | ind_opening=6; |
---|
| 347 | end |
---|
| 348 | if isfield(Data,'pixcmx') & isequal(Data,'pixcmy') |
---|
| 349 | browse.pxcmx=Data.pixcmx; |
---|
| 350 | browse.pxcmy=Data.pixcmy; |
---|
| 351 | end |
---|
| 352 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 353 | subdir='';%default |
---|
| 354 | if testciv |
---|
| 355 | [Pathbase,Namebase]=fileparts(filebase) |
---|
| 356 | [Pathprev,subdir,extdir]=fileparts(Pathbase) |
---|
| 357 | subdir=[subdir extdir] |
---|
| 358 | % if isequal (subdir,subdir_obs) |
---|
| 359 | filebase=fullfile(Pathprev,Namebase)% move upward to get the base name (corresponding to the .civ_3D file and images) |
---|
| 360 | % end |
---|
| 361 | end |
---|
| 362 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 363 | set(handles.subdir_civ2,'String',subdir); |
---|
| 364 | browse.testciv=testciv; |
---|
| 365 | browse.ind_opening=ind_opening; |
---|
| 366 | end |
---|
| 367 | set(handles.displ_filebase,'String',filebase); |
---|
| 368 | set(handles.ImaDoc,'String',ext); |
---|
| 369 | if ~isempty(str2num(field_count)) |
---|
| 370 | ref_i=str2num(field_count); |
---|
| 371 | if ~isempty(str2num(str2)) |
---|
| 372 | ref_i=floor((ref_i+str2num(str2))/2);% reference image number corresponding to the file |
---|
| 373 | browse.incr_pair(1)=str2num(str2)-str2num(field_count); |
---|
| 374 | browse.incr_pair(2)=0; |
---|
| 375 | end |
---|
| 376 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 377 | set(handles.last_i,'String',num2str(ref_i)); |
---|
| 378 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 379 | end |
---|
| 380 | if isequal(ind_opening,1) |
---|
| 381 | set(handles.CIV1,'Value',1) |
---|
| 382 | enable_civ1(handles,'on') |
---|
| 383 | elseif isequal(ind_opening,2) |
---|
| 384 | set(handles.FIX1,'Value',1) |
---|
| 385 | enable_fix1(handles) |
---|
| 386 | elseif isequal(ind_opening,3) |
---|
| 387 | set(handles.PATCH1,'Value',1) |
---|
| 388 | enable_patch1(handles) |
---|
| 389 | elseif isequal(ind_opening,4) |
---|
| 390 | set(handles.CIV2,'Value',1) |
---|
| 391 | enable_civ2(handles,1) |
---|
| 392 | elseif isequal(ind_opening,5) |
---|
| 393 | set(handles.FIX2,'Value',1) |
---|
| 394 | enable_fix2(handles) |
---|
| 395 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 396 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 397 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 398 | elseif isequal(ind_opening,6) |
---|
| 399 | set(handles.PATCH2,'Value',1) |
---|
| 400 | enable_patch2(handles) |
---|
| 401 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 402 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 403 | end |
---|
| 404 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 405 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 406 | set(handles.ImaDoc,'UserData',testall); |
---|
| 407 | |
---|
| 408 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 409 | |
---|
| 410 | %------------------------------------------------ |
---|
| 411 | |
---|
| 412 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
| 413 | displ_filebase_Callback(hObject, eventdata, handles) |
---|
| 414 | |
---|
| 415 | %-------------------------------------------------------------- |
---|
| 416 | %function activated when a new filebase (image series) is introduced |
---|
| 417 | %------------------------------------------------------------ |
---|
| 418 | function displ_filebase_Callback(hObject, eventdata, handles) |
---|
| 419 | |
---|
| 420 | global test_batch |
---|
| 421 | set(gcf,'Pointer','watch') |
---|
| 422 | ext_ima=[]; %default |
---|
| 423 | nom_type_ima=[];%default |
---|
| 424 | field_count=1;%default |
---|
| 425 | nom_type_nc=[]; |
---|
| 426 | npx=[];%default |
---|
| 427 | npy=[]; |
---|
| 428 | TimeUnit='s'; %default |
---|
| 429 | CoordUnit='cm';%default |
---|
| 430 | pxcmx_search=[];%default |
---|
| 431 | pxcmy_search=[];%default |
---|
| 432 | filebase=get(handles.displ_filebase,'String'); |
---|
| 433 | |
---|
| 434 | ext=get(handles.ImaDoc,'String'); |
---|
| 435 | browse=get(handles.browse_root,'UserData');%default |
---|
| 436 | if ~isempty(browse) |
---|
| 437 | if isfield(browse,'ext_ima') |
---|
| 438 | ext_ima=browse.ext_ima; |
---|
| 439 | end |
---|
| 440 | if isfield(browse,'nom_type_ima') |
---|
| 441 | nom_type_ima=browse.nom_type_ima; |
---|
| 442 | end |
---|
| 443 | if isfield(browse,'field_count') |
---|
| 444 | field_count=browse.field_count; |
---|
| 445 | end |
---|
| 446 | end |
---|
| 447 | |
---|
| 448 | %default first_i and j and increments |
---|
| 449 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 450 | if isempty(first_i)| first_i < 1 |
---|
| 451 | first_i=1; %default first_i |
---|
| 452 | end |
---|
| 453 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 454 | if isempty(last_i)| last_i < first_i |
---|
| 455 | last_i=first_i; %default last_i |
---|
| 456 | end |
---|
[71] | 457 | |
---|
[2] | 458 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 459 | if isempty(incr_i) | incr_i < 1; |
---|
| 460 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 461 | end |
---|
| 462 | dt=[];%default |
---|
| 463 | testmode=0;%default |
---|
| 464 | nbfield=1; %default |
---|
| 465 | if isfield(browse,'pxcmx') & isfield(browse,'pxcmy') |
---|
| 466 | pxcmx=num2str(browse.pxcmx); |
---|
| 467 | pxcmy=num2str(browse.pxcmy); |
---|
| 468 | else |
---|
| 469 | pxcmx=1;%default |
---|
| 470 | pxcmy=1; |
---|
| 471 | end |
---|
| 472 | %look for an image documentation file |
---|
| 473 | if ~isequal(ext,'.xml') & ~ isequal(ext,'.avi')& ~ isequal(ext,'.AVI') |
---|
| 474 | if exist([filebase '.xml'],'file') |
---|
| 475 | ext='.xml'; |
---|
| 476 | set(handles.ImaDoc,'String','.xml') |
---|
| 477 | elseif exist([filebase '.civ_3D'],'file') |
---|
| 478 | ext='.civ_3D'; |
---|
| 479 | set(handles.ImaDoc,'String','.civ_3D') |
---|
| 480 | elseif exist([filebase '.avi'],'file') |
---|
| 481 | ext='.avi'; |
---|
| 482 | set(handles.ImaDoc,'String','.avi') |
---|
| 483 | elseif exist([filebase '.AVI'],'file') |
---|
| 484 | ext='.AVI'; |
---|
| 485 | set(handles.ImaDoc,'String','.AVI') |
---|
| 486 | end |
---|
| 487 | end |
---|
| 488 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 489 | mode=''; %default |
---|
| 490 | if isequal(ext,'.xml') |
---|
[71] | 491 | [XmlData,warntext]=imadoc2struct([filebase '.xml']) |
---|
[2] | 492 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName') |
---|
| 493 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
| 494 | end |
---|
[71] | 495 | if isfield(XmlData,'TimeUnit') |
---|
| 496 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 497 | end |
---|
[71] | 498 | if isfield(XmlData,'Npx')&&isfield(XmlData,'Npy') |
---|
| 499 | set(handles.npx,'String',num2str(XmlData.Npx)); |
---|
| 500 | set(handles.npy,'String',num2str(XmlData.Npy)); |
---|
| 501 | end |
---|
| 502 | if isfield(XmlData,'Time')&&~isempty(XmlData.Time) |
---|
| 503 | time=XmlData.Time; |
---|
| 504 | set(handles.npz,'String',num2str(size(time,2))); |
---|
| 505 | end |
---|
[2] | 506 | pxcmx_search=1; |
---|
| 507 | pxcmy_search=1; |
---|
| 508 | if isfield(XmlData,'GeometryCalib') |
---|
| 509 | tsai=XmlData.GeometryCalib; |
---|
| 510 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
| 511 | rot2D=tsai.R([1:2],[1,2]); |
---|
| 512 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 513 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
| 514 | end |
---|
| 515 | if isfield(tsai,'CoordUnit') |
---|
| 516 | CoordUnit=tsai.CoordUnit; |
---|
| 517 | end |
---|
| 518 | end |
---|
| 519 | if isempty(ext_ima_read) |
---|
| 520 | ext_ima='.png';%default |
---|
| 521 | else |
---|
| 522 | ext_ima=ext_ima_read; |
---|
| 523 | end |
---|
| 524 | if isempty(nom_type_read) |
---|
| 525 | nom_type_ima='_i_j'; |
---|
[42] | 526 | msgbox_uvmat('WARNING','no ImageName defined in ImaDoc/Heading, take _i_j indexing by default') |
---|
[2] | 527 | else |
---|
| 528 | nom_type_ima=nom_type_read; |
---|
| 529 | end |
---|
| 530 | |
---|
| 531 | elseif isequal(ext,'.avi')|isequal(ext,'.AVI') |
---|
| 532 | nom_type_ima='avi'; |
---|
| 533 | ext_ima=ext; |
---|
| 534 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 535 | dt=0.04;%default |
---|
| 536 | if exist([filebase ext],'file')==2 |
---|
| 537 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
| 538 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 539 | nbfield=info.NumFrames;%number of frames |
---|
| 540 | end |
---|
| 541 | time=(dt*[0:nbfield-1])';%list of image times |
---|
| 542 | set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
| 543 | |
---|
| 544 | % no image documentation file found: look for a series of existing images or .nc files |
---|
| 545 | elseif ~isequal(ext,'.nc') |
---|
| 546 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 547 | incr_pair=[0 0];%default |
---|
| 548 | if isfield(browse,'incr_pair') |
---|
| 549 | incr_pair=browse.incr_pair; |
---|
| 550 | end |
---|
| 551 | nbdetect=0;%test of detected images |
---|
| 552 | field_i=field_count; |
---|
| 553 | idetect=1; |
---|
| 554 | % imagename='';%default |
---|
| 555 | while idetect==1 %look for the maximum file number in the series |
---|
| 556 | field_i=field_i+1; |
---|
| 557 | % imagename_last=imagename; |
---|
[42] | 558 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
| 559 | idetect=exist(imagename,'file'); |
---|
[2] | 560 | if isequal(nom_type_ima,'none') |
---|
| 561 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 562 | nbdetect=1; |
---|
| 563 | end |
---|
| 564 | %SEE CASE OF NETCDF FILES |
---|
| 565 | nbdetect=nbdetect+idetect; |
---|
| 566 | end |
---|
| 567 | % nb_field=field_i-1;% last detected field number |
---|
| 568 | nb_field=field_i;% last detected field number |
---|
| 569 | field_i=field_count;%look for the minimum file number in the series |
---|
| 570 | idetect=1; |
---|
| 571 | while idetect==1 |
---|
| 572 | field_i=field_i-1; |
---|
[42] | 573 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
| 574 | idetect=exist(imagename,'file'); |
---|
[2] | 575 | if isequal(nom_type_ima,'none') |
---|
| 576 | idetect=0; %stop if the same image is repeted (if nom_type='none') |
---|
| 577 | nbdetect=1; |
---|
| 578 | end |
---|
| 579 | nbdetect=nbdetect+idetect; |
---|
| 580 | end |
---|
| 581 | first_i=max(field_i+1,1); |
---|
| 582 | %determine the set of times and possible intervals for CIV_3D |
---|
[72] | 583 | % dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 584 | time=(0:nb_field-1)'; |
---|
[2] | 585 | % set(handles.incr_i,'UserData',dt);%store the time interval |
---|
| 586 | % between successive images |
---|
| 587 | %displ_num:list of possible time intervals for civ_3D calculations |
---|
| 588 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 589 | end |
---|
| 590 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
| 591 | first_i=1; |
---|
| 592 | last_i=1; |
---|
| 593 | first_j=1; |
---|
| 594 | last_j=1; |
---|
| 595 | end |
---|
[71] | 596 | |
---|
[2] | 597 | if exist('time','var') |
---|
[71] | 598 | nbfield=size(time,1); |
---|
[2] | 599 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 600 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 601 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 602 | end |
---|
| 603 | set(handles.CoordUnit,'String',[CoordUnit '/']) |
---|
| 604 | if isempty(pxcmx_search) |
---|
| 605 | set(handles.calcul_search,'UserData',[pxcmx pxcmy]); |
---|
| 606 | else |
---|
| 607 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 608 | end |
---|
| 609 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 610 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 611 | browse.ext_ima=ext_ima; |
---|
| 612 | browse.nom_type_ima=nom_type_ima; |
---|
| 613 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 614 | |
---|
| 615 | %%%%%%%%%%% set the menus of image pairs and default selection for civ_3D %%%%%%%%%%%%%%%%%%% |
---|
| 616 | if isequal(get(handles.compare,'Value'),1) |
---|
| 617 | if isequal(nom_type_ima,'_i')| isequal(nom_type_nc,'_i1-i2')|~exist('nbfield2','var')|(nbfield2==1) |
---|
| 618 | set(handles.mode,'String',{'st_series(Di)';'displacement'}) |
---|
| 619 | set(handles.mode,'Value',1) |
---|
| 620 | elseif (nbfield==1)% simple series in j |
---|
| 621 | set(handles.mode,'String',{'st_series(Dj)';'displacement'}) |
---|
| 622 | set(handles.mode,'Value',1) |
---|
| 623 | else |
---|
| 624 | set(handles.mode,'String',{'st_pair j1-j2';'st_series(Dj)';'st_series(Di)';'displacement'})%multiple choice |
---|
| 625 | if isequal(mode,'volume') |
---|
| 626 | set(handles.mode,'Value',3) |
---|
| 627 | elseif nbfield2 <= 5 |
---|
| 628 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 629 | end |
---|
| 630 | end |
---|
| 631 | else |
---|
| 632 | if isequal(nom_type_ima,'_i')| isequal(nom_type_nc,'_i1-i2')|~exist('nbfield2','var')|(nbfield2==1) |
---|
| 633 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 634 | set(handles.mode,'Value',1) |
---|
| 635 | elseif isequal(nom_type_ima,'png_old')|isequal(nom_type_nc,'netc_old') |
---|
| 636 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
| 637 | set(handles.mode,'Value',1) |
---|
| 638 | elseif (nbfield==1)% simple series in j |
---|
| 639 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 640 | set(handles.mode,'Value',1) |
---|
| 641 | else |
---|
| 642 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
| 643 | if isequal(mode,'volume') |
---|
| 644 | set(handles.mode,'Value',3) |
---|
| 645 | elseif nbfield2 <= 5 |
---|
| 646 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 647 | else |
---|
| 648 | set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 649 | end |
---|
| 650 | end |
---|
| 651 | end |
---|
| 652 | mode_Callback(hObject, eventdata, handles) |
---|
| 653 | |
---|
| 654 | %%%%%% initialize waitbars and RUN button |
---|
| 655 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 656 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 657 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 658 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 659 | set(handles.RUN, 'Enable','On') |
---|
| 660 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 661 | if isequal(test_batch,1)%if batch installation is available |
---|
| 662 | set(handles.BATCH, 'Enable','On') |
---|
| 663 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 664 | end |
---|
| 665 | |
---|
| 666 | %%%%% store the root input filename for future opening |
---|
| 667 | dir_perso=prefdir; |
---|
| 668 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 669 | RootPath=fileparts(filebase); |
---|
| 670 | if exist(profil_perso,'file') |
---|
| 671 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 672 | else |
---|
[147] | 673 | txt=ver('MATLAB'); |
---|
| 674 | Release=txt.Release; |
---|
[2] | 675 | relnumb=str2num(Release(3:4)); |
---|
| 676 | if relnumb >= 14 |
---|
| 677 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 678 | else |
---|
| 679 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 680 | end |
---|
| 681 | end |
---|
| 682 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 683 | set(gcf,'Pointer','arrow') |
---|
| 684 | |
---|
| 685 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%???????????? |
---|
| 686 | % --- Executes on button press in mode. |
---|
| 687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 688 | function mode_Callback(hObject, eventdata, handles) |
---|
| 689 | browse=get(handles.browse_root,'UserData'); |
---|
| 690 | mode_list=get(handles.mode,'String'); |
---|
| 691 | mode_value=get(handles.mode,'Value'); |
---|
| 692 | mode=mode_list{mode_value}; |
---|
| 693 | displ_num=[];%default |
---|
| 694 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 695 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 696 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 697 | siztime=size(time); |
---|
| 698 | nbfield=siztime(1); |
---|
| 699 | nbfield2=siztime(2); |
---|
| 700 | indchosen=1; %%first pair selected by default |
---|
| 701 | if isequal(mode,'pair j1-j2')| isequal(mode,'st_pair j1-j2') |
---|
| 702 | dt=1; |
---|
| 703 | displ=''; |
---|
| 704 | index=0; |
---|
| 705 | %get all the time intervals in bursts |
---|
| 706 | displ_dt=1;%default |
---|
| 707 | nbfield2=min(nbfield2,10),%limitate the number of pairs to 10x10 |
---|
| 708 | % if nbfield2<2 |
---|
| 709 | % nbfield2=2, |
---|
| 710 | % end |
---|
| 711 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 712 | for numod_b=(numod_a+1):nbfield2 |
---|
| 713 | index=index+1; |
---|
| 714 | numlist_a(index)=numod_a; |
---|
| 715 | numlist_b(index)=numod_b; |
---|
| 716 | if ~isempty(time) |
---|
| 717 | dt(numod_a,numod_b)=time(first_i,numod_b)-time(first_i,numod_a);%first time interval dt |
---|
| 718 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 719 | else |
---|
| 720 | displ_dt(index)=1 |
---|
| 721 | end |
---|
| 722 | end |
---|
| 723 | end |
---|
| 724 | [dtsort,indsort]=sort(displ_dt); |
---|
| 725 | displ_num(1,:)=numlist_a(indsort); |
---|
| 726 | displ_num(2,:)=numlist_b(indsort); |
---|
| 727 | displ_num(3,:)=0; |
---|
| 728 | displ_num(4,:)=0; |
---|
| 729 | set(handles.jtext,'Visible','Off') |
---|
| 730 | set(handles.first_j,'Visible','Off') |
---|
| 731 | set(handles.last_j,'Visible','Off') |
---|
| 732 | set(handles.incr_j,'Visible','Off') |
---|
| 733 | set(handles.nb_field2,'Visible','Off') |
---|
| 734 | set(handles.ref_j,'Visible','Off') |
---|
| 735 | elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
| 736 | for index=1:min(nbfield2-1,200) |
---|
| 737 | displ_num(1,index)=-floor(index/2); |
---|
| 738 | displ_num(2,index)=ceil(index/2); |
---|
| 739 | displ_num(3,index)=0; |
---|
| 740 | displ_num(4,index)=0; |
---|
| 741 | end |
---|
| 742 | set(handles.jtext,'Visible','On') |
---|
| 743 | set(handles.first_j,'Visible','On') |
---|
| 744 | set(handles.last_j,'Visible','On') |
---|
| 745 | set(handles.incr_j,'Visible','On') |
---|
| 746 | set(handles.nb_field2,'Visible','On') |
---|
| 747 | set(handles.ref_j,'Visible','On') |
---|
| 748 | if nbfield > 1 |
---|
| 749 | set(handles.itext,'Visible','On') |
---|
| 750 | set(handles.first_i,'Visible','On') |
---|
| 751 | set(handles.last_i,'Visible','On') |
---|
| 752 | set(handles.incr_i,'Visible','On') |
---|
| 753 | set(handles.nb_field,'Visible','On') |
---|
| 754 | set(handles.ref_i,'Visible','On') |
---|
| 755 | else |
---|
| 756 | set(handles.itext,'Visible','Off') |
---|
| 757 | set(handles.first_i,'Visible','Off') |
---|
| 758 | set(handles.last_i,'Visible','Off') |
---|
| 759 | set(handles.incr_i,'Visible','Off') |
---|
| 760 | set(handles.nb_field,'Visible','Off') |
---|
| 761 | set(handles.ref_i,'Visible','Off') |
---|
| 762 | end |
---|
| 763 | elseif isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') |
---|
| 764 | for index=1:min(nbfield-1,200) |
---|
| 765 | displ_num(1,index)=0; |
---|
| 766 | displ_num(2,index)=0; |
---|
| 767 | displ_num(3,index)=-floor(index/2); |
---|
| 768 | displ_num(4,index)=ceil(index/2); |
---|
| 769 | end |
---|
| 770 | set(handles.itext,'Visible','On') |
---|
| 771 | set(handles.first_i,'Visible','On') |
---|
| 772 | set(handles.last_i,'Visible','On') |
---|
| 773 | set(handles.incr_i,'Visible','On') |
---|
| 774 | set(handles.nb_field,'Visible','On') |
---|
| 775 | set(handles.ref_i,'Visible','On') |
---|
| 776 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 777 | displ_num(1,1)=0; |
---|
| 778 | displ_num(2,1)=0; |
---|
| 779 | displ_num(3,1)=0; |
---|
| 780 | displ_num(4,1)=0; |
---|
| 781 | if nbfield > 1 |
---|
| 782 | set(handles.itext,'Visible','On') |
---|
| 783 | set(handles.first_i,'Visible','On') |
---|
| 784 | set(handles.last_i,'Visible','On') |
---|
| 785 | set(handles.incr_i,'Visible','On') |
---|
| 786 | set(handles.nb_field,'Visible','On') |
---|
| 787 | set(handles.ref_i,'Visible','On') |
---|
| 788 | else |
---|
| 789 | set(handles.itext,'Visible','Off') |
---|
| 790 | set(handles.first_i,'Visible','Off') |
---|
| 791 | set(handles.last_i,'Visible','Off') |
---|
| 792 | set(handles.incr_i,'Visible','Off') |
---|
| 793 | set(handles.nb_field,'Visible','Off') |
---|
| 794 | set(handles.ref_i,'Visible','Off') |
---|
| 795 | end |
---|
| 796 | if nbfield2 > 1 |
---|
| 797 | set(handles.jtext,'Visible','On') |
---|
| 798 | set(handles.first_j,'Visible','On') |
---|
| 799 | set(handles.last_j,'Visible','On') |
---|
| 800 | set(handles.incr_j,'Visible','On') |
---|
| 801 | set(handles.nb_field2,'Visible','On') |
---|
| 802 | set(handles.ref_j,'Visible','On') |
---|
| 803 | else |
---|
| 804 | set(handles.jtext,'Visible','Off') |
---|
| 805 | set(handles.first_j,'Visible','Off') |
---|
| 806 | set(handles.last_j,'Visible','Off') |
---|
| 807 | set(handles.incr_j,'Visible','Off') |
---|
| 808 | set(handles.nb_field2,'Visible','Off') |
---|
| 809 | set(handles.ref_j,'Visible','Off') |
---|
| 810 | end |
---|
| 811 | end |
---|
| 812 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 813 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 814 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 815 | |
---|
| 816 | %-------------------------------------------------------------- |
---|
| 817 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 818 | % the field series set by first_i, incr, last_i |
---|
| 819 | %---------------------------------------------------------------- |
---|
| 820 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 821 | set(gcf,'Pointer','watch') |
---|
| 822 | %nomenclature types |
---|
| 823 | filebase=get(handles.displ_filebase,'String'); |
---|
| 824 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 825 | browse=get(handles.browse_root,'UserData'); |
---|
| 826 | mode_list=get(handles.mode,'String'); |
---|
| 827 | mode_value=get(handles.mode,'Value'); |
---|
| 828 | mode=mode_list{mode_value}; |
---|
| 829 | % nomenclature type of the .nc files |
---|
| 830 | nom_type_ima=[];%default |
---|
| 831 | if isfield(browse,'nom_type_ima') |
---|
| 832 | nom_type_ima=browse.nom_type_ima; |
---|
| 833 | end |
---|
| 834 | |
---|
| 835 | %determine nom_type_nc: |
---|
| 836 | nom_type_nc=[];%default |
---|
| 837 | if isfield(browse,'nom_type_nc') |
---|
| 838 | nom_type_nc=browse.nom_type_nc; |
---|
| 839 | end |
---|
| 840 | if isequal(nom_type_ima,'png_old') | isequal(nom_type_nc,'netc_old')| isequal(nom_type_ima,'raw_SMD') |
---|
| 841 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 842 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 843 | nom_type_nc='none'; |
---|
| 844 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|... |
---|
| 845 | isequal(nom_type_nc,'_i1-i2') |
---|
| 846 | nom_type_nc='_i1-i2'; |
---|
| 847 | elseif isequal(nom_type_ima,'_i_j1-j2')||isequal(nom_type_nc,'_i1-i2_j1-j2') |
---|
| 848 | nom_type_nc='_i1-i2_j1-j2'; |
---|
| 849 | else |
---|
| 850 | if isequal(mode,'series(Di)')|isequal(mode,'st_series(Di)') |
---|
| 851 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 852 | else |
---|
| 853 | nom_type_nc='_i_j1-j2'; |
---|
| 854 | end |
---|
| 855 | end |
---|
| 856 | browse.nom_type_nc=nom_type_nc; |
---|
| 857 | set(handles.browse_root,'UserData',browse) |
---|
| 858 | |
---|
| 859 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 860 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 861 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 862 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 863 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 864 | num1=first_i:incr:last_i; |
---|
| 865 | if isempty(num1) |
---|
| 866 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 867 | return |
---|
| 868 | end |
---|
| 869 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 870 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
| 871 | if isempty(time) |
---|
| 872 | time=[0 1]; |
---|
| 873 | end |
---|
| 874 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 875 | |
---|
| 876 | %eliminate the first pairs inconsistent with the position |
---|
| 877 | if isempty(displ_num) |
---|
| 878 | nbpair=0; |
---|
| 879 | else |
---|
| 880 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 881 | if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') |
---|
| 882 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 883 | elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
| 884 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 885 | end |
---|
| 886 | end |
---|
| 887 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 888 | |
---|
| 889 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 890 | % be performed, while the result is needed for next steps. |
---|
| 891 | displ_pair={''}; |
---|
| 892 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 893 | testpair=0; |
---|
| 894 | if get(handles.CIV1,'Value')==0 % |
---|
| 895 | dirname=fullfile(filepath,subdir_civ1,ext_dir); |
---|
| 896 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
[42] | 897 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
[2] | 898 | set(handles.list_pair_civ1,'String',{}); |
---|
| 899 | return |
---|
| 900 | end |
---|
| 901 | for ipair=1:nbpair |
---|
[42] | 902 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[2] | 903 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[42] | 904 | select(ipair)=exist(filename,'file'); |
---|
[2] | 905 | end |
---|
| 906 | if ~exist('select','var') | isequal(select,zeros(size(1:nbpair))) |
---|
| 907 | if isfield(browse,'incr_pair') |
---|
| 908 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 909 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 910 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 911 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
[42] | 912 | [filename]=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 913 | select(1)=exist(filename,'file'); |
---|
[2] | 914 | testpair=1; |
---|
| 915 | else |
---|
| 916 | if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
[42] | 917 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
[2] | 918 | else |
---|
[42] | 919 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
[2] | 920 | end |
---|
| 921 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 922 | %COMPLETER CAS STEREO |
---|
| 923 | return |
---|
| 924 | end |
---|
| 925 | end |
---|
| 926 | end |
---|
[71] | 927 | if isequal(mode,'series(Di)') |
---|
[2] | 928 | if testpair |
---|
| 929 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[71] | 930 | else |
---|
[2] | 931 | for ipair=1:nbpair |
---|
| 932 | if select(ipair) |
---|
[71] | 933 | dt=time(ref_i+displ_num(4,ipair),1)-time(ref_i+displ_num(3,ipair),1);%time interval dt |
---|
[2] | 934 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 935 | else |
---|
| 936 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 937 | end |
---|
| 938 | end |
---|
| 939 | end |
---|
[71] | 940 | elseif isequal(mode,'pair j1-j2')%case of pairs |
---|
[2] | 941 | for ipair=1:nbpair |
---|
| 942 | if select(ipair) |
---|
| 943 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
| 944 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 945 | ' :dt= ' num2str(dt*1000)]; |
---|
| 946 | else |
---|
| 947 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 948 | end |
---|
| 949 | end |
---|
| 950 | elseif isequal(mode,'displacement') |
---|
| 951 | displ_pair={'Di=Dj=0'}; |
---|
| 952 | end |
---|
| 953 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 954 | ichoice=min(find(select)); |
---|
| 955 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 956 | initial=get(handles.list_pair_civ1,'Value'); |
---|
| 957 | if initial>nbpair |~isequal(select(initial),1) |
---|
| 958 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 959 | end |
---|
| 960 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 961 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 962 | if initial>nbpair |~isequal(select(initial),1) |
---|
| 963 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 964 | end |
---|
| 965 | set(gcf,'Pointer','arrow') |
---|
| 966 | %-------------------------------------------------------------- |
---|
| 967 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 968 | %middle of the series set by first_i, incr, last_i |
---|
| 969 | %-------------------------------------------------------------- |
---|
| 970 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[71] | 971 | return %do not exist in 3D |
---|
[2] | 972 | set(gcf,'Pointer','watch') |
---|
| 973 | %nomenclature types |
---|
| 974 | filebase=get(handles.displ_filebase,'String'); |
---|
| 975 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 976 | browse=get(handles.browse_root,'UserData'); |
---|
| 977 | mode_list=get(handles.mode,'String'); |
---|
| 978 | mode_value=get(handles.mode,'Value'); |
---|
| 979 | mode=mode_list{mode_value}; |
---|
| 980 | |
---|
| 981 | % nomenclature type of the .nc files |
---|
| 982 | nom_type_ima='ima_num';%default |
---|
| 983 | if isfield(browse,'nom_type_ima') |
---|
| 984 | nom_type_ima=browse.nom_type_ima; |
---|
| 985 | end |
---|
| 986 | nom_type_nc='_i1-i2';%default |
---|
| 987 | if isfield(browse,'nom_type_nc') |
---|
| 988 | nom_type_nc=browse.nom_type_nc; |
---|
| 989 | end |
---|
| 990 | 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') |
---|
| 991 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 992 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 993 | nom_type_nc='none'; |
---|
| 994 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
| 995 | nom_type_nc='_i1-i2'; |
---|
| 996 | else |
---|
| 997 | if isequal(mode,'series(Di)')|isequal(mode,'st_series(Di)') |
---|
| 998 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 999 | else |
---|
| 1000 | nom_type_nc='_i_j1-j2'; |
---|
| 1001 | end |
---|
| 1002 | end |
---|
| 1003 | browse.nom_type_nc=nom_type_nc; |
---|
| 1004 | set(handles.browse_root,'UserData',browse) |
---|
| 1005 | |
---|
| 1006 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1007 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1008 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
| 1009 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1010 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1011 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 1012 | num1=first_i:incr:last_i; |
---|
| 1013 | if isempty(num1) |
---|
| 1014 | set(handles.list_pair_civ2,'String',{}); |
---|
| 1015 | return |
---|
| 1016 | end |
---|
| 1017 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1018 | if isequal(mode,'pair j1-j2')|isequal(mode,'st_pair j1-j2') |
---|
| 1019 | ref_j=0; |
---|
| 1020 | else |
---|
| 1021 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1022 | end |
---|
| 1023 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1024 | if isempty(time) |
---|
| 1025 | time=[0 1];%default |
---|
| 1026 | end |
---|
| 1027 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1028 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1029 | |
---|
| 1030 | |
---|
| 1031 | %eliminate the first pairs inconsistent with the position |
---|
| 1032 | if isempty(displ_num) |
---|
| 1033 | nbpair=0; |
---|
| 1034 | else |
---|
| 1035 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1036 | if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') |
---|
| 1037 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1038 | elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
| 1039 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1040 | end |
---|
| 1041 | end |
---|
| 1042 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1043 | |
---|
| 1044 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1045 | % be performed, while the result is needed for next steps. |
---|
| 1046 | displ_pair={''}; %default |
---|
| 1047 | select=ones(size(1:nbpair));%default =1 for nubers of displayed pairs |
---|
| 1048 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1049 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1050 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1051 | set(handles.list_pair_civ2,'String',{}); |
---|
| 1052 | return |
---|
| 1053 | end |
---|
| 1054 | for ipair=1:nbpair |
---|
[42] | 1055 | [filename]=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[2] | 1056 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[42] | 1057 | select(ipair)=exist(filename,'file'); |
---|
[2] | 1058 | end |
---|
| 1059 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1060 | if isfield(browse,'incr_pair') |
---|
| 1061 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1062 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1063 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1064 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
[42] | 1065 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1066 | select(1)=exist(filename,'file'); |
---|
[2] | 1067 | else |
---|
| 1068 | if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
[42] | 1069 | msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
[2] | 1070 | else |
---|
[42] | 1071 | msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
[2] | 1072 | end |
---|
| 1073 | set(handles.list_pair_civ2,'String',{}); |
---|
| 1074 | return |
---|
| 1075 | end |
---|
| 1076 | end |
---|
| 1077 | end |
---|
| 1078 | if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') |
---|
[71] | 1079 | if ~isequal(get(handles.ext_txt,'String'),'dt(ms)=') |
---|
[2] | 1080 | for ipair=1:nbpair |
---|
| 1081 | if select(ipair) |
---|
| 1082 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1083 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1084 | else |
---|
| 1085 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1086 | end |
---|
| 1087 | end |
---|
| 1088 | else |
---|
| 1089 | for ipair=1:nbpair |
---|
| 1090 | if select(ipair) |
---|
| 1091 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
| 1092 | else |
---|
| 1093 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1094 | end |
---|
| 1095 | end |
---|
| 1096 | end |
---|
| 1097 | elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1098 | for ipair=1:nbpair |
---|
| 1099 | if select(ipair) |
---|
| 1100 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1101 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1102 | else |
---|
| 1103 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1104 | end |
---|
| 1105 | end |
---|
| 1106 | elseif isequal(mode,'pair j1-j2') | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1107 | for ipair=1:nbpair |
---|
| 1108 | if select(ipair) |
---|
| 1109 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
| 1110 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1111 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1112 | else |
---|
| 1113 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1114 | end |
---|
| 1115 | end |
---|
| 1116 | elseif isequal(mode,'displacement') |
---|
| 1117 | displ_pair={'Di=Dj=0'}; |
---|
| 1118 | end |
---|
| 1119 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1120 | ichoice=min(find(select)); |
---|
| 1121 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1122 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1123 | set(handles.list_pair_civ2,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1124 | end |
---|
| 1125 | set(gcf,'Pointer','arrow') |
---|
| 1126 | %---------------------------------------------------- |
---|
| 1127 | % determine the list of index pairs of processing file |
---|
| 1128 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 1129 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1130 | find_pair_indices(handles,mode) |
---|
| 1131 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1132 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1133 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 1134 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1135 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 1136 | str_civ1=list_civ1{index_civ1}; |
---|
| 1137 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1138 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1139 | str_civ2=list_civ2{index_civ2}; |
---|
[71] | 1140 | if isempty(first_i), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
[2] | 1141 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
[71] | 1142 | if isempty(last_i),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[2] | 1143 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
[71] | 1144 | if isempty(incr), msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[2] | 1145 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
[71] | 1146 | if last_i < first_i , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[2] | 1147 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1148 | num1=[first_i:incr:last_i]; |
---|
[71] | 1149 | if isequal (mode,'series(Di)') |
---|
[2] | 1150 | %recognize the pair civ1 from the display |
---|
| 1151 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1152 | str_raw=str_civ1(indsel); |
---|
| 1153 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1154 | d1=str2num(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1155 | if indsepar==length(str_raw) |
---|
| 1156 | d2=str2num(str_civ1([indsel(indsepar)+1:end])); |
---|
| 1157 | else |
---|
| 1158 | d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1159 | end |
---|
| 1160 | %recognize the pair civ2 from the display |
---|
| 1161 | num1_civ1=num1-d1;% set of first image numbers |
---|
| 1162 | num2_civ1=num1+d2; |
---|
[71] | 1163 | num_a_civ1=1; |
---|
| 1164 | num_b_civ1=1; |
---|
[2] | 1165 | num1_civ2=num1-floor(index_civ2/2)*ones(size(num1));% set of first image numbers |
---|
| 1166 | num2_civ2=num1+ceil(index_civ2/2)*ones(size(num1)); |
---|
| 1167 | num1_civ2=num1-d1;% set of first image numbers |
---|
| 1168 | num2_civ2=num1+d2; |
---|
[71] | 1169 | num_a_civ2=1; |
---|
| 1170 | num_b_civ2=1; |
---|
[2] | 1171 | % adjust the first and last field number |
---|
| 1172 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1173 | if isequal(lastfield,[]) |
---|
| 1174 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1175 | else |
---|
| 1176 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1177 | end |
---|
| 1178 | if length(indsel)>=1 |
---|
| 1179 | firstind=indsel(1); |
---|
| 1180 | lastind=indsel(end); |
---|
| 1181 | set(handles.first_i,'String',num2str(num1(firstind)))%update the display of first and last fields |
---|
| 1182 | set(handles.last_i,'String',num2str(num1(lastind))) |
---|
| 1183 | num1=num1(indsel); |
---|
| 1184 | num1_civ1=num1_civ1(indsel); |
---|
| 1185 | num1_civ2=num1_civ2(indsel); |
---|
| 1186 | num2_civ1=num2_civ1(indsel); |
---|
| 1187 | num2_civ2=num2_civ2(indsel); |
---|
| 1188 | end |
---|
| 1189 | elseif isequal (mode,'series(Dj)')|isequal (mode,'st_series(Dj)') |
---|
| 1190 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
| 1191 | num1_civ1=num1;% set of first image numbers |
---|
| 1192 | num2_civ1=num1; |
---|
| 1193 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1194 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
| 1195 | num1_civ2=num1; |
---|
| 1196 | num2_civ2=num1; |
---|
| 1197 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1198 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1199 | % adjust the first and last field number |
---|
| 1200 | if isequal(lastfield_j,[]) |
---|
| 1201 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1202 | else |
---|
| 1203 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1204 | end |
---|
| 1205 | if length(indsel)>=1 |
---|
| 1206 | firstind=indsel(1); |
---|
| 1207 | lastind=indsel(end); |
---|
| 1208 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1209 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1210 | num_j=num_j(indsel); |
---|
| 1211 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1212 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1213 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1214 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1215 | end |
---|
| 1216 | elseif isequal(mode,'pair j1-j2') | isequal(mode,'st_pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 1217 | num1_civ1=num1; |
---|
| 1218 | num1_civ2=num1; |
---|
| 1219 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1220 | num2_civ1=num1; |
---|
| 1221 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1222 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 1223 | num2_civ2=num1; |
---|
| 1224 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1225 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1226 | elseif isequal(mode,'displacement') |
---|
| 1227 | num1_civ1=num1; |
---|
| 1228 | num2_civ1=num1; |
---|
| 1229 | num_a_civ1=num_j; |
---|
| 1230 | num_b_civ1=num_j; |
---|
| 1231 | num1_civ2=num1; |
---|
| 1232 | num2_civ2=num1; |
---|
| 1233 | num_a_civ2=num_j; |
---|
| 1234 | num_b_civ2=num_j; |
---|
| 1235 | end |
---|
| 1236 | |
---|
| 1237 | |
---|
| 1238 | %------------------------------------------------------------- |
---|
| 1239 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1240 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
| 1241 | %------------------------------------------------------------ |
---|
| 1242 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1243 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1244 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1245 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1246 | num_a=displ_num(1,index_pair); |
---|
| 1247 | num_b=displ_num(2,index_pair); |
---|
| 1248 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1249 | |
---|
| 1250 | %update first_i and last_i according to the chosen image pairs |
---|
| 1251 | mode_list=get(handles.mode,'String'); |
---|
| 1252 | mode_value=get(handles.mode,'Value'); |
---|
| 1253 | mode=mode_list{mode_value}; |
---|
| 1254 | if isequal(mode,'series(Di)') |
---|
| 1255 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1256 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1257 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1258 | num1=first_i:incr_i:last_i; |
---|
| 1259 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1260 | if ~isequal(lastfield,[]) |
---|
| 1261 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1262 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1263 | num1=num1(ind); |
---|
| 1264 | end |
---|
| 1265 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1266 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1267 | elseif isequal(mode,'series(Dj)') |
---|
| 1268 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1269 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1270 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1271 | num_j=first_j:incr_j:last_j; |
---|
| 1272 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1273 | if ~isequal(lastfield2,[]) |
---|
| 1274 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1275 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1276 | num1=num_j(ind); |
---|
| 1277 | end |
---|
| 1278 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1279 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1280 | end |
---|
| 1281 | |
---|
| 1282 | %------------------------------------------------------------------ |
---|
| 1283 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1284 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
| 1285 | |
---|
| 1286 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1287 | |
---|
| 1288 | %update first_i and last_i according to the chosen image pairs |
---|
| 1289 | mode_list=get(handles.mode,'String'); |
---|
| 1290 | mode_value=get(handles.mode,'Value'); |
---|
| 1291 | mode=mode_list{mode_value}; |
---|
| 1292 | if isequal(mode,'series(Di)') |
---|
| 1293 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1294 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1295 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1296 | num1=first_i:incr_i:last_i; |
---|
| 1297 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1298 | if ~isequal(lastfield,[]) |
---|
| 1299 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1300 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1301 | num1=num1(ind); |
---|
| 1302 | end |
---|
| 1303 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1304 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1305 | elseif isequal(mode,'series(Dj)') |
---|
| 1306 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1307 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1308 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1309 | num_j=first_j:incr_j:last_j; |
---|
| 1310 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1311 | if ~isequal(lastfield2,[]) |
---|
| 1312 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1313 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield)); |
---|
| 1314 | num1=num_j(ind); |
---|
| 1315 | end |
---|
| 1316 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1317 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1318 | end |
---|
| 1319 | |
---|
| 1320 | |
---|
| 1321 | |
---|
| 1322 | |
---|
| 1323 | %----------------------------------------------------------- |
---|
| 1324 | % --- Executes on button press in BATCH: remote processing |
---|
| 1325 | %----------------------------------------------------------- |
---|
| 1326 | function BATCH_Callback(hObject, eventdata, handles) |
---|
| 1327 | global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe |
---|
| 1328 | |
---|
[71] | 1329 | % pxcmx=get(handles.pxcmx,'String'); |
---|
| 1330 | % pxcmy=get(handles.pxcmy,'String'); |
---|
| 1331 | % npx=get(handles.pxcmx,'UserData'); |
---|
| 1332 | % npy=get(handles.pxcmy,'UserData'); |
---|
[2] | 1333 | |
---|
| 1334 | %check the list of operations: |
---|
| 1335 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1336 | run_flag=1; |
---|
| 1337 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1338 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1339 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1340 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1341 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1342 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1343 | index=find(box_test==1); |
---|
| 1344 | if isempty(index) |
---|
| 1345 | errordlg('no selected operation') |
---|
| 1346 | set(handles.BATCH, 'Enable','On') |
---|
| 1347 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1348 | return |
---|
| 1349 | end |
---|
| 1350 | index_first=min(index); |
---|
| 1351 | index_last=max(index); |
---|
| 1352 | box_used=box_test([index_first : index_last]); |
---|
| 1353 | [box_missing,ind_missing]=min(box_used); |
---|
| 1354 | if isequal(box_missing,0) |
---|
| 1355 | errordlg(['missing' cell2mat(operations(ind_missing))]); |
---|
| 1356 | set(handles.BATCH, 'Enable','On') |
---|
| 1357 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1358 | return |
---|
| 1359 | end |
---|
| 1360 | |
---|
| 1361 | %check mask if selecetd |
---|
| 1362 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
| 1363 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1364 | end |
---|
| 1365 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
| 1366 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1367 | end |
---|
| 1368 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
| 1369 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
| 1370 | end |
---|
| 1371 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
| 1372 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
| 1373 | end |
---|
| 1374 | |
---|
| 1375 | |
---|
| 1376 | %read names of the .exe file |
---|
| 1377 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1378 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[71] | 1379 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ_3D binary names |
---|
| 1380 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 1381 | if exist(xmlfile,'file') |
---|
| 1382 | t=xmltree(xmlfile); |
---|
| 1383 | sparam=convert(t); |
---|
| 1384 | end |
---|
| 1385 | if isfield(sparam.BatchParam,'Civ3D3CBin') |
---|
| 1386 | Civ3D3CBin=sparam.BatchParam.Civ3D3CBin; |
---|
[2] | 1387 | else |
---|
[71] | 1388 | msgbox_uvmat('ERROR','binary for CIV3D3C not defined in PARAM.xml') |
---|
| 1389 | return |
---|
[2] | 1390 | end |
---|
[71] | 1391 | |
---|
[2] | 1392 | %choice of batch priority |
---|
| 1393 | ind_answer=2; |
---|
[71] | 1394 | % if sge |
---|
[2] | 1395 | [s,w]=unix('qstat -q civ_3D.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1396 | if isequal(s,0) |
---|
| 1397 | w(end)=[]; |
---|
| 1398 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 1399 | str={'urgent';'normal';'low'}; |
---|
| 1400 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1401 | 'SelectionMode','single',... |
---|
| 1402 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 1403 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 1404 | return % a better way should be create |
---|
| 1405 | end |
---|
| 1406 | else |
---|
[42] | 1407 | msgbox_uvmat('ERROR','batch system not available') |
---|
[2] | 1408 | return |
---|
| 1409 | end |
---|
[71] | 1410 | % end |
---|
[2] | 1411 | %initialize the waitbars |
---|
| 1412 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 1413 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 1414 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 1415 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 1416 | set(handles.BATCH, 'Enable','Off') |
---|
| 1417 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1418 | |
---|
| 1419 | %get the filename root, nomenclature and numbers |
---|
| 1420 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1421 | % for Windows system find the UBC path name if needed |
---|
| 1422 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 1423 | cur_dir=pwd; |
---|
| 1424 | if ~isequal(cur_dir(2:3),':\') |
---|
| 1425 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 1426 | end |
---|
| 1427 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 1428 | if isequal(ss,0) |
---|
| 1429 | rankpath=findstr(ww,'\\'); |
---|
| 1430 | if ~isempty(rankpath) |
---|
| 1431 | wwrest=ww(rankpath:end); |
---|
| 1432 | rankend=min(find(double(wwrest)==10))-1; |
---|
| 1433 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 1434 | set(handles.displ_filebase,'String',filebase); |
---|
| 1435 | end |
---|
| 1436 | else |
---|
[42] | 1437 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
[2] | 1438 | set(handles.BATCH, 'Enable','On') |
---|
| 1439 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1440 | return |
---|
| 1441 | end |
---|
| 1442 | end |
---|
| 1443 | browse=get(handles.browse_root,'UserData') |
---|
| 1444 | ext_ima=browse.ext_ima; |
---|
| 1445 | nom_type_nc='_i1-i2'; |
---|
| 1446 | nom_type_ima=browse.nom_type_ima; |
---|
| 1447 | % nom_type_nc=browse.nom_type_nc; |
---|
| 1448 | % if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 1449 | % if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 1450 | mode_list=get(handles.mode,'String'); |
---|
| 1451 | mode_value=get(handles.mode,'Value'); |
---|
| 1452 | mode=mode_list{mode_value}; |
---|
| 1453 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1454 | |
---|
| 1455 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1456 | find_pair_indices(handles,mode); %determine the pairs of processing file |
---|
| 1457 | |
---|
| 1458 | %check dir |
---|
| 1459 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 1460 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 1461 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 1462 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 1463 | currentdir=pwd;%store the current working directory |
---|
| 1464 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ_3D) |
---|
| 1465 | if ~exist(Path_ima,'dir') |
---|
[42] | 1466 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[2] | 1467 | return |
---|
| 1468 | end |
---|
| 1469 | cd(Path_ima);%move to the directory of the images |
---|
| 1470 | dircur=pwd; %current working directory |
---|
| 1471 | m2=''; |
---|
| 1472 | [erread,message]=fileattrib(Path_ima); |
---|
| 1473 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 1474 | errordlg(['No writting access to ' Path_ima]) |
---|
| 1475 | cd(currentdir) |
---|
| 1476 | return |
---|
| 1477 | end |
---|
| 1478 | |
---|
| 1479 | %test for reference file in fix |
---|
| 1480 | ref_fix1=get(handles.ref_fix1,'UserData'); |
---|
| 1481 | ref_fix2=get(handles.ref_fix2,'UserData'); |
---|
| 1482 | if (~isempty(ref_fix1) & box_test(2)==1)|(~isempty(ref_fix2) & box_test(5)==1) |
---|
| 1483 | errordlg('reference file not implemented in BATCH mode, use RUN') |
---|
| 1484 | set(handles.BATCH, 'Enable','On') |
---|
| 1485 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1486 | return |
---|
| 1487 | end |
---|
| 1488 | nbfield=length(num1_civ1); |
---|
| 1489 | nbslice=length(num_a_civ1); |
---|
| 1490 | |
---|
| 1491 | %check the existence of the netcdf and image files involved |
---|
| 1492 | % if box_test(1)==1;%CIV1 activated |
---|
| 1493 | detect=1; |
---|
| 1494 | while detect==1 %name a new subdir if one of the netcdf files already exists |
---|
| 1495 | for ifile=1:nbfield |
---|
| 1496 | % for j=1:nbslice |
---|
[42] | 1497 | filename=name_generator(filebase,num1_civ1(ifile),[],'.nc',... |
---|
[71] | 1498 | '_i1-i2',1,num2_civ1(ifile),[],subdir_civ1);% |
---|
[42] | 1499 | detect=exist(filename,'file') |
---|
| 1500 | if detect% if a netcdf file already exists |
---|
[2] | 1501 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 1502 | subdir_civ2=subdir_civ1; |
---|
| 1503 | break |
---|
| 1504 | end |
---|
| 1505 | filecell_nc1(ifile)={filename}; |
---|
[42] | 1506 | if detect% if a netcdf file already exists |
---|
[2] | 1507 | break |
---|
| 1508 | end |
---|
| 1509 | end |
---|
| 1510 | %create the new subdir_civ1 if it does not exist |
---|
| 1511 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 1512 | [m1,m2,m3]=mkdir(subdir_civ1) |
---|
| 1513 | if ~isequal(m2,'') |
---|
| 1514 | msgbox(m2);%error message for directory creation |
---|
| 1515 | end |
---|
| 1516 | end |
---|
| 1517 | end |
---|
| 1518 | %get image names |
---|
| 1519 | for ifile=1:nbfield |
---|
[71] | 1520 | filecell_ima1_civ1{ifile}=name_generator(filebase, num1_civ1(ifile),[],'.vol','_i');%first image |
---|
| 1521 | filecell_ima2_civ1{ifile}=name_generator(filebase, num2_civ1(ifile),[],'.vol','_i'); %second image |
---|
[42] | 1522 | if ~exist(filecell_ima1_civ1{ifile},'file') |
---|
| 1523 | msgbox_uvmat('ERROR',[filecell_ima1_civ1{ifile} ' not found']) |
---|
[2] | 1524 | set(handles.BATCH, 'Enable','On') |
---|
| 1525 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1526 | cd(currentdir) |
---|
| 1527 | return |
---|
[42] | 1528 | end |
---|
| 1529 | if ~exist(filecell_ima2_civ1{ifile},'file') |
---|
| 1530 | msgbox_uvmat('ERROR',[filecell_ima2_civ1{ifile} ' not found']) |
---|
[2] | 1531 | set(handles.BATCH, 'Enable','On') |
---|
| 1532 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1533 | cd(currentdir) |
---|
| 1534 | return |
---|
| 1535 | end |
---|
| 1536 | end |
---|
| 1537 | |
---|
| 1538 | cd(currentdir);%come back to the initial working directory |
---|
| 1539 | % if ~isequal(m2,'') |
---|
| 1540 | % msgbox(m2);%error message for directory creation |
---|
| 1541 | % end |
---|
| 1542 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 1543 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 1544 | browse.nom_type_nc=nom_type_nc; |
---|
| 1545 | set(handles.browse_root,'UserData',browse);%update the nomenclature type for uvmat |
---|
| 1546 | |
---|
| 1547 | for ifile=1:nbfield |
---|
| 1548 | i_cmd=0; |
---|
| 1549 | cmd='#!/bin/bash'; |
---|
| 1550 | cmd=char({cmd;'#$ -cwd'}); |
---|
| 1551 | cmd=char({cmd;'hostname && date'}); |
---|
| 1552 | filename_cmx=cell2mat(filecell_nc1(ifile));%output netcdf file |
---|
| 1553 | filename_cmx([end-1:end])='cm';%name of cmx file |
---|
| 1554 | filename_cmx=[filename_cmx 'x']; |
---|
| 1555 | |
---|
| 1556 | %CIV1 |
---|
| 1557 | if box_test(1)==1 |
---|
| 1558 | %GET civ_3D PARAMETERS: |
---|
| 1559 | par_civ1=read_param_civ1(handles,cell2mat(filecell_ima1_civ1(1,1))); |
---|
| 1560 | p1text=[]; |
---|
| 1561 | [par_civ1.path,resu_file,resu_ext]=fileparts(filecell_nc1{ifile}); |
---|
| 1562 | par_civ1.volume1=filecell_ima1_civ1{ifile}; |
---|
[71] | 1563 | par_civ1.volume2=filecell_ima2_civ1{ifile}; |
---|
| 1564 | par_civ1.nx=str2double(get(handles.npx,'String')); |
---|
| 1565 | par_civ1.ny=str2double(get(handles.npy,'String'));; |
---|
[2] | 1566 | par_civ1.nz=par_civ1.gridLimits_Zmax - par_civ1.gridLimits_Zmin; |
---|
| 1567 | 'TEST' |
---|
| 1568 | par_civ1 |
---|
| 1569 | % civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
| 1570 | % if isequal(civAll,1) |
---|
| 1571 | civAllxml=struct2xml(par_civ1);% xml contents, all parameters |
---|
| 1572 | civAllxml=set(civAllxml,1,'name','civ3d3c'); |
---|
| 1573 | % save(civAllxml) |
---|
| 1574 | par_civ1_3d_xml=fullfile(par_civ1.path,[resu_file '.xml']);%[par_civ1.path '/test_to_change.xml']; |
---|
[71] | 1575 | pvalue=num2str((1-ind_answer)*500) |
---|
[2] | 1576 | save(civAllxml,par_civ1_3d_xml); |
---|
[72] | 1577 | nb_processor='8'; |
---|
| 1578 | ['echo /CIVX/bin/MPI/lam-7.1.3_g95/bin/mpirun C ' Civ3D3CBin ' -p ' par_civ1_3d_xml '|qsub -p ' pvalue ' -q lam.q -pe lam_loose ' nb_processor ' -e ' par_civ1_3d_xml '.errors -o ' par_civ1_3d_xml '.log' ] |
---|
| 1579 | eval ( ['!echo /CIVX/bin/MPI/lam-7.1.3_g95/bin/mpirun C ' Civ3D3CBin ' -p ' par_civ1_3d_xml '|qsub -p ' pvalue ' -q lam.q -pe lam_loose ' nb_processor ' -e ' par_civ1_3d_xml '.errors -o ' par_civ1_3d_xml '.log' ]) |
---|
[2] | 1580 | |
---|
[72] | 1581 | end |
---|
[2] | 1582 | end |
---|
| 1583 | |
---|
| 1584 | set(handles.BATCH, 'Enable','On') |
---|
| 1585 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[72] | 1586 | |
---|
| 1587 | %save GUI state |
---|
[2] | 1588 | [Path,Name]=fileparts(filebase); |
---|
| 1589 | namefig=fullfile(Path,subdir_civ2,Name); |
---|
| 1590 | detect=1; |
---|
| 1591 | while detect==1 |
---|
| 1592 | namefigfull=[namefig '.fig']; |
---|
| 1593 | hh=dir(namefigfull); |
---|
| 1594 | if ~isempty(hh) |
---|
| 1595 | detect=1; |
---|
| 1596 | namefig=[namefig '.0']; |
---|
| 1597 | else |
---|
| 1598 | detect=0; |
---|
| 1599 | end |
---|
| 1600 | end |
---|
| 1601 | saveas(gcbf,namefigfull);%save the interface with name namefigfull |
---|
| 1602 | |
---|
| 1603 | |
---|
| 1604 | %---------------------------------------- |
---|
| 1605 | %PATCH |
---|
| 1606 | %--------------------------------------- |
---|
| 1607 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
| 1608 | global patch_exe patch_new_exe |
---|
| 1609 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 1610 | if test_interp==0 |
---|
| 1611 | cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 1612 | ' > ' namelog ' 2>&1'] % redirect standard output to the log file |
---|
| 1613 | else %nouveau programme patch |
---|
| 1614 | cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 1615 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 1616 | end |
---|
| 1617 | |
---|
| 1618 | |
---|
| 1619 | %---------------------------------------------------- |
---|
| 1620 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 1621 | last_j_Callback(hObject, eventdata, handles) |
---|
| 1622 | |
---|
| 1623 | %--------------------------------------------------------- |
---|
| 1624 | % --- Executes on button press in CIV1. |
---|
| 1625 | function CIV1_Callback(hObject, eventdata, handles) |
---|
| 1626 | enable_civ1(handles,get(handles.CIV1,'Value')) |
---|
| 1627 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 1628 | |
---|
| 1629 | %------------------------------------------------------ |
---|
| 1630 | % --- Executes on button press in FIX1. |
---|
| 1631 | function FIX1_Callback(hObject, eventdata, handles) |
---|
| 1632 | |
---|
| 1633 | if get(handles.FIX1,'Value')==1 |
---|
| 1634 | enable_fix1(handles) |
---|
| 1635 | else |
---|
| 1636 | desable_fix1(handles) |
---|
| 1637 | end |
---|
| 1638 | |
---|
| 1639 | %---------------------------------------------------------------- |
---|
| 1640 | % --- Executes on button press in PATCH1. |
---|
| 1641 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
| 1642 | |
---|
| 1643 | if get(handles.PATCH1,'Value')==1 |
---|
| 1644 | enable_patch1(handles) |
---|
| 1645 | else |
---|
| 1646 | desable_patch1(handles) |
---|
| 1647 | end |
---|
| 1648 | |
---|
| 1649 | %---------------------------------------------------------- |
---|
| 1650 | % --- Executes on button press in CIV2. |
---|
| 1651 | function CIV2_Callback(hObject, eventdata, handles) |
---|
| 1652 | state=get(handles.CIV2,'Value'); |
---|
| 1653 | enable_civ2(handles,state) |
---|
| 1654 | if state |
---|
| 1655 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 1656 | end |
---|
| 1657 | |
---|
| 1658 | %--------------------------------------------------- |
---|
| 1659 | % --- Executes on button press in FIX2. |
---|
| 1660 | function FIX2_Callback(hObject, eventdata, handles) |
---|
| 1661 | if get(handles.FIX2,'Value')==1 |
---|
| 1662 | enable_fix2(handles) |
---|
| 1663 | if get(handles.CIV2,'Value')==0 |
---|
| 1664 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 1665 | end |
---|
| 1666 | else |
---|
| 1667 | desable_fix2(handles) |
---|
| 1668 | end |
---|
| 1669 | |
---|
| 1670 | |
---|
| 1671 | %------------------------------------------------------- |
---|
| 1672 | % --- Executes on button press in PATCH2. |
---|
| 1673 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
| 1674 | %-------------------------------------------------------- |
---|
| 1675 | if get(handles.PATCH2,'Value')==1 |
---|
| 1676 | enable_patch2(handles) |
---|
| 1677 | if get(handles.CIV2,'Value')==0 |
---|
| 1678 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 1679 | end |
---|
| 1680 | else |
---|
| 1681 | desable_patch2(handles) |
---|
| 1682 | end |
---|
| 1683 | |
---|
| 1684 | |
---|
| 1685 | |
---|
| 1686 | %----------------------------------------------------------- |
---|
| 1687 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 1688 | %------------------------------------------------------ |
---|
| 1689 | last_i_Callback(hObject, eventdata, handles) |
---|
| 1690 | |
---|
| 1691 | %----------------------------------------------------------- |
---|
| 1692 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 1693 | %-------------------------------------------------------- |
---|
| 1694 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
| 1695 | |
---|
| 1696 | %determine pair numbers |
---|
| 1697 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1698 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 1699 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1700 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1701 | pxcm_xy=get(handles.calcul_search,'UserData') |
---|
| 1702 | pxcmx=pxcm_xy(1); |
---|
| 1703 | pxcmy=pxcm_xy(2); |
---|
| 1704 | mode_list=get(handles.mode,'String'); |
---|
| 1705 | mode_value=get(handles.mode,'Value'); |
---|
| 1706 | mode=mode_list{mode_value}; |
---|
| 1707 | if isequal (mode, 'series(Di)' ) |
---|
| 1708 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1709 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 1710 | num2=ref_i+ceil(index/2); |
---|
| 1711 | num_a=1; |
---|
| 1712 | num_b=1; |
---|
| 1713 | elseif isequal (mode, 'series(Dj)') |
---|
| 1714 | num1=1; |
---|
| 1715 | num2=1; |
---|
| 1716 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1717 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 1718 | num_b=ref_j+ceil(index/2); |
---|
| 1719 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 1720 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1721 | num1=ref_i; |
---|
| 1722 | num2=ref_i; |
---|
| 1723 | num_a=displ_num(1,index); |
---|
| 1724 | num_b=displ_num(2,index); |
---|
| 1725 | end |
---|
| 1726 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 1727 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 1728 | iby=str2num(get(handles.iby,'String')); |
---|
| 1729 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 1730 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 1731 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 1732 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 1733 | shiftx=round((umin+umax)/2); |
---|
| 1734 | shifty=round((vmin+vmax)/2); |
---|
| 1735 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 1736 | isx=2*ceil(isx/2)+1; |
---|
| 1737 | isy=(vmax+2-shifty)*2+iby; |
---|
| 1738 | isy=2*ceil(isy/2)+1; |
---|
| 1739 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 1740 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 1741 | set(handles.isx,'String',num2str(isx)); |
---|
| 1742 | set(handles.isy,'String',num2str(isy)); |
---|
| 1743 | |
---|
| 1744 | |
---|
| 1745 | %--------------------------------------------------------- |
---|
| 1746 | % Executes on carriage return on the subdir civ1 edit window |
---|
| 1747 | %-------------------------------------------------------- |
---|
| 1748 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
| 1749 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 1750 | set(handles.subdir_civ2,'String',subdir); |
---|
| 1751 | if get(handles.CIV1,'Value')==0 |
---|
| 1752 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 1753 | end |
---|
| 1754 | |
---|
| 1755 | %--------------------------------------------------------- |
---|
| 1756 | % Executes on carriage return on the subdir civ1 edit window |
---|
| 1757 | %--------------------------------------------------------- |
---|
| 1758 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
| 1759 | %update the list of available pairs from netcdf files in the new directory |
---|
| 1760 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1761 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 1762 | end |
---|
| 1763 | |
---|
| 1764 | %------------------------------------------------------ |
---|
| 1765 | % --- Executes on button press in get_mask_civ1. |
---|
| 1766 | %------------------------------------------------------ |
---|
| 1767 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
| 1768 | maskval=get(handles.get_mask_civ1,'Value') |
---|
| 1769 | if isequal(maskval,0) |
---|
| 1770 | set(handles.mask_civ1,'String','') |
---|
| 1771 | else |
---|
| 1772 | mask_displ='no mask'; %default |
---|
| 1773 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1774 | [ nbslice, flag_mask]=get_mask(filebase,handles) |
---|
| 1775 | if isequal(flag_mask,1) |
---|
| 1776 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 1777 | end |
---|
| 1778 | if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 1779 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 1780 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles) |
---|
| 1781 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 1782 | mask_displ='no mask'; |
---|
| 1783 | end |
---|
| 1784 | end |
---|
| 1785 | if isequal(mask_displ,'no mask') |
---|
| 1786 | set(handles.get_mask_civ1,'Value',0) |
---|
| 1787 | set(handles.get_mask_fix1,'Value',0) |
---|
| 1788 | set(handles.get_mask_civ2,'Value',0) |
---|
| 1789 | set(handles.get_mask_fix2,'Value',0) |
---|
| 1790 | else |
---|
| 1791 | set(handles.get_mask_fix1,'Value',1) |
---|
| 1792 | set(handles.get_mask_civ2,'Value',1) |
---|
| 1793 | set(handles.get_mask_fix2,'Value',1) |
---|
| 1794 | end |
---|
| 1795 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 1796 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 1797 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 1798 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 1799 | end |
---|
| 1800 | %-------------------------------------------------------------- |
---|
| 1801 | % --- Executes on button press in get_mask_fix1. |
---|
| 1802 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
| 1803 | maskval=get(handles.get_mask_fix1,'Value') |
---|
| 1804 | if isequal(maskval,0) |
---|
| 1805 | set(handles.mask_fix1,'String','') |
---|
| 1806 | else |
---|
| 1807 | mask_displ='no mask'; %default |
---|
| 1808 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1809 | [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
| 1810 | if isequal(flag_mask,1) |
---|
| 1811 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 1812 | end |
---|
| 1813 | if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 1814 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 1815 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles) |
---|
| 1816 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 1817 | mask_displ='no mask'; |
---|
| 1818 | end |
---|
| 1819 | end |
---|
| 1820 | if isequal(mask_displ,'no mask') |
---|
| 1821 | set(handles.get_mask_fix1,'Value',0) |
---|
| 1822 | set(handles.get_mask_civ2,'Value',0) |
---|
| 1823 | set(handles.get_mask_fix2,'Value',0) |
---|
| 1824 | else |
---|
| 1825 | set(handles.get_mask_civ2,'Value',1) |
---|
| 1826 | set(handles.get_mask_fix2,'Value',1) |
---|
| 1827 | end |
---|
| 1828 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 1829 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 1830 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 1831 | end |
---|
| 1832 | %----------------------------------------- |
---|
| 1833 | % --- Executes on button press in get_mask_civ2. |
---|
| 1834 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
| 1835 | maskval=get(handles.get_mask_civ2,'Value') |
---|
| 1836 | if isequal(maskval,0) |
---|
| 1837 | set(handles.mask_civ2,'String','') |
---|
| 1838 | else |
---|
| 1839 | mask_displ='no mask'; %default |
---|
| 1840 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1841 | [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
| 1842 | if isequal(flag_mask,1) |
---|
| 1843 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 1844 | end |
---|
| 1845 | if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 1846 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 1847 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles) |
---|
| 1848 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 1849 | mask_displ='no mask'; |
---|
| 1850 | end |
---|
| 1851 | end |
---|
| 1852 | if isequal(mask_displ,'no mask') |
---|
| 1853 | set(handles.get_mask_civ2,'Value',0) |
---|
| 1854 | set(handles.get_mask_fix2,'Value',0) |
---|
| 1855 | else |
---|
| 1856 | set(handles.get_mask_fix2,'Value',1) |
---|
| 1857 | end |
---|
| 1858 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 1859 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 1860 | end |
---|
| 1861 | %------------------------------------- |
---|
| 1862 | % --- Executes on button press in get_mask_fix2. |
---|
| 1863 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
| 1864 | maskval=get(handles.get_mask_fix2,'Value') |
---|
| 1865 | if isequal(maskval,0) |
---|
| 1866 | set(handles.mask_fix2,'String','') |
---|
| 1867 | else |
---|
| 1868 | mask_displ='no mask'; %default |
---|
| 1869 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1870 | [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
| 1871 | if isequal(flag_mask,1) |
---|
| 1872 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 1873 | end |
---|
| 1874 | if get(handles.compare,'Value')==1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 1875 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 1876 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles) |
---|
| 1877 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 1878 | mask_displ='no mask'; |
---|
| 1879 | end |
---|
| 1880 | end |
---|
| 1881 | if isequal(mask_displ,'no mask') |
---|
| 1882 | set(handles.get_mask_fix2,'Value',0) |
---|
| 1883 | end |
---|
| 1884 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 1885 | end |
---|
| 1886 | |
---|
| 1887 | %--------------------------------------- |
---|
| 1888 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
| 1889 | %detect mask files, images with appropriate file base |
---|
| 1890 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 1891 | %flag_mask=1 indicates detection |
---|
| 1892 | |
---|
| 1893 | flag_mask=0;%default |
---|
| 1894 | nbslice=1; |
---|
| 1895 | |
---|
| 1896 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 1897 | [Path,Name]=fileparts(filebase) |
---|
| 1898 | currentdir=pwd; |
---|
| 1899 | cd(Path);%move in the dir of the root name filebase |
---|
| 1900 | maskfiles=dir([Name '_*mask_*.png'])%look for mask files |
---|
| 1901 | cd(currentdir);%come back to the current working directory |
---|
| 1902 | if isempty(maskfiles) |
---|
| 1903 | browse=get(handles.browse_root,'UserData'); |
---|
| 1904 | varargin{1}=''; |
---|
[42] | 1905 | image_name=name_generator(filebase,1,1,browse.ext_ima,browse.nom_type_ima);%name of an image |
---|
| 1906 | if exist(image_name,'file') |
---|
[2] | 1907 | varargin{1}=image_name; |
---|
| 1908 | end |
---|
[42] | 1909 | msgbox_uvmat('ERROR','no mask available, use TOOL menu in the uvmat interface to create it') |
---|
[2] | 1910 | % makemask(varargin); %open the makemask interface |
---|
| 1911 | else |
---|
| 1912 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 1913 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 1914 | Namedouble=double(Name); |
---|
| 1915 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1916 | ind_mask=findstr('mask',Name); |
---|
| 1917 | i=ind_mask-1; |
---|
| 1918 | while val(i)==0 & i>0 |
---|
| 1919 | i=i-1; |
---|
| 1920 | end |
---|
| 1921 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 1922 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 1923 | flag_mask=1; |
---|
| 1924 | else |
---|
| 1925 | errordlg(['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 1926 | return |
---|
| 1927 | nbslice=1; |
---|
| 1928 | end |
---|
| 1929 | end |
---|
| 1930 | %------------------------------ |
---|
| 1931 | |
---|
| 1932 | |
---|
| 1933 | function grid_civ1_Callback(hObject, eventdata, handles) |
---|
| 1934 | % hObject handle to grid_civ1 (see GCBO) |
---|
| 1935 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1936 | % handles structure with handles and user data (see GUIDATA) |
---|
| 1937 | |
---|
| 1938 | % Hints: get(hObject,'String') returns contents of grid_civ1 as text |
---|
| 1939 | % str2double(get(hObject,'String')) returns contents of grid_civ1 as a double |
---|
| 1940 | |
---|
| 1941 | |
---|
| 1942 | %----------------------------------------------------------- |
---|
| 1943 | % transform numbers to letters |
---|
| 1944 | %-------------------------------------------- |
---|
| 1945 | function str=num2stra(num,nom_type); |
---|
| 1946 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 1947 | str=char(96+num); |
---|
| 1948 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 1949 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 1950 | str=''; |
---|
| 1951 | else |
---|
| 1952 | str=num2str(num); |
---|
| 1953 | end |
---|
| 1954 | %--------------------------------------------------- |
---|
| 1955 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
| 1956 | set(handles.mask_civ1,'UserData',[]) |
---|
| 1957 | set(handles.mask_civ1,'String','') |
---|
| 1958 | %---------------------------------------------------- |
---|
| 1959 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
| 1960 | set(handles.mask_civ2,'UserData',[]) |
---|
| 1961 | set(handles.mask_civ2,'String','') |
---|
| 1962 | %---------------------------------------------------- |
---|
| 1963 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
| 1964 | set(handles.mask_fix1,'UserData',[]) |
---|
| 1965 | set(handles.mask_fix1,'String','') |
---|
| 1966 | %---------------------------------------------------- |
---|
| 1967 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
| 1968 | set(handles.mask_fix2,'UserData',[]) |
---|
| 1969 | set(handles.mask_fix2,'String','') |
---|
| 1970 | |
---|
| 1971 | %-------------------------------------------------------------------------- |
---|
| 1972 | % --- Executes on button press in list_subdir_civ1. |
---|
| 1973 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
| 1974 | |
---|
| 1975 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1976 | dirinput = uigetdir(filebase) |
---|
| 1977 | set(handles.subdir_civ1,'String',dirinput) |
---|
| 1978 | set(handles.subdir_civ2,'String',dirinput) |
---|
| 1979 | |
---|
| 1980 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 1981 | |
---|
| 1982 | |
---|
| 1983 | function rho_civ2_Callback(hObject, eventdata, handles) |
---|
| 1984 | % hObject handle to rho_civ2 (see GCBO) |
---|
| 1985 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1986 | % handles structure with handles and user data (see GUIDATA) |
---|
| 1987 | |
---|
| 1988 | % Hints: get(hObject,'String') returns contents of rho_civ2 as text |
---|
| 1989 | % str2double(get(hObject,'String')) returns contents of rho_civ2 as a double |
---|
| 1990 | |
---|
| 1991 | %---------------------------------------------- |
---|
| 1992 | function last_i_Callback(hObject, eventdata, handles) |
---|
| 1993 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1994 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1995 | ref_i=ceil((first_i+last_i)/2); |
---|
| 1996 | set(handles.ref_i,'String', num2str(ref_i)) |
---|
| 1997 | ref_i_Callback(hObject, eventdata, handles) |
---|
| 1998 | |
---|
| 1999 | %------------------------------------------------------- |
---|
| 2000 | function last_j_Callback(hObject, eventdata, handles) |
---|
| 2001 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2002 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2003 | ref_j=ceil((first_j+last_j)/2); |
---|
| 2004 | set(handles.ref_j,'String', num2str(ref_j)) |
---|
| 2005 | ref_j_Callback(hObject, eventdata, handles) |
---|
| 2006 | |
---|
| 2007 | %-------------------------------------------------------------------------- |
---|
| 2008 | % --- Executes on button press in browse_gridciv1. |
---|
| 2009 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
| 2010 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 2011 | if value |
---|
| 2012 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2013 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 2014 | {'*.grid', ' (*.grid)'; |
---|
| 2015 | '*.grid', '.grid files '; ... |
---|
| 2016 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2017 | 'Pick a file',filebase); |
---|
| 2018 | filegrid=fullfile(PathName,FileName); |
---|
| 2019 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 2020 | set(handles.browse_gridciv1,'Value',0); |
---|
| 2021 | set(handles.grid_civ1,'string',''); |
---|
| 2022 | set(handles.dx_civ1,'Visible','on'); |
---|
| 2023 | set(handles.dy_civ1,'Visible','on'); |
---|
| 2024 | set(handles.grid_civ2,'string',''); |
---|
| 2025 | if get(handles.CIV2,'Value') |
---|
| 2026 | set(handles.dx_civ2,'Visible','on'); |
---|
| 2027 | set(handles.dy_civ2,'Visible','on'); |
---|
| 2028 | end |
---|
| 2029 | else |
---|
| 2030 | set(handles.grid_civ1,'string',filegrid); |
---|
| 2031 | set(handles.dx_civ1,'Visible','off'); |
---|
| 2032 | set(handles.dy_civ1,'Visible','off'); |
---|
| 2033 | set(handles.grid_civ2,'string',filegrid); |
---|
| 2034 | set(handles.dx_civ2,'Visible','off'); |
---|
| 2035 | set(handles.dy_civ2,'Visible','off'); |
---|
| 2036 | % set(handles.grid_patch1,'string',filegrid); |
---|
| 2037 | % set(handles.grid_patch2,'string',filegrid); |
---|
| 2038 | end |
---|
| 2039 | else |
---|
| 2040 | set(handles.grid_civ1,'string',''); |
---|
| 2041 | set(handles.dx_civ1,'Visible','on'); |
---|
| 2042 | set(handles.dy_civ1,'Visible','on'); |
---|
| 2043 | set(handles.grid_civ2,'string',''); |
---|
| 2044 | if get(handles.CIV2,'Value') |
---|
| 2045 | set(handles.dx_civ2,'Visible','on'); |
---|
| 2046 | set(handles.dy_civ2,'Visible','on'); |
---|
| 2047 | end |
---|
| 2048 | end |
---|
| 2049 | |
---|
| 2050 | |
---|
| 2051 | |
---|
| 2052 | function pxcmx_Callback(hObject, eventdata, handles) |
---|
| 2053 | % hObject handle to pxcmx (see GCBO) |
---|
| 2054 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2055 | % handles structure with handles and user data (see GUIDATA) |
---|
| 2056 | |
---|
| 2057 | % Hints: get(hObject,'String') returns contents of pxcmx as text |
---|
| 2058 | % str2double(get(hObject,'String')) returns contents of pxcmx as a double |
---|
| 2059 | |
---|
| 2060 | |
---|
| 2061 | |
---|
| 2062 | function pxcmy_Callback(hObject, eventdata, handles) |
---|
| 2063 | % hObject handle to pxcmy (see GCBO) |
---|
| 2064 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2065 | % handles structure with handles and user data (see GUIDATA) |
---|
| 2066 | |
---|
| 2067 | % Hints: get(hObject,'String') returns contents of pxcmy as text |
---|
| 2068 | % str2double(get(hObject,'String')) returns contents of pxcmy as a double |
---|
| 2069 | |
---|
| 2070 | |
---|
| 2071 | % --- Executes on button press in browse_gridciv2. |
---|
| 2072 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 2073 | |
---|
| 2074 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2075 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 2076 | {'*.grid', ' (*.grid)'; |
---|
| 2077 | '*.grid', '.grid files '; ... |
---|
| 2078 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2079 | 'Pick a file',filebase); |
---|
| 2080 | filegrid=fullfile(PathName,FileName); |
---|
| 2081 | set(handles.grid_civ2,'string',filegrid); |
---|
| 2082 | set(handles.dx_civ2,'String',' '); |
---|
| 2083 | set(handles.dy_civ2,'String',' '); |
---|
| 2084 | % set(handles.grid_patch2,'string',filegrid); |
---|
| 2085 | |
---|
| 2086 | % --- Executes on button press in get_gridpatch1. |
---|
| 2087 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 2088 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 2089 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2090 | % handles structure with handles and user data (see GUIDATA) |
---|
| 2091 | |
---|
| 2092 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2093 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 2094 | {'*.grid', ' (*.grid)'; |
---|
| 2095 | '*.grid', '.grid files '; ... |
---|
| 2096 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2097 | 'Pick a file',filebase); |
---|
| 2098 | filegrid=fullfile(PathName,FileName); |
---|
| 2099 | set(handles.grid_patch1,'string',filegrid); |
---|
| 2100 | % set(handles.grid_patch2,'string',filegrid |
---|
| 2101 | |
---|
| 2102 | %----------------------------------------------------------------- |
---|
| 2103 | % --- Executes on button press in get_gridpatch2. |
---|
| 2104 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
| 2105 | % hObject handle to get_gridpatch2 (see GCBO) |
---|
| 2106 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2107 | % handles structure with handles and user data (see GUIDATA) |
---|
| 2108 | |
---|
| 2109 | |
---|
| 2110 | %---------------------------------------------------------- |
---|
| 2111 | function enable_civ1(handles,state) |
---|
| 2112 | if isequal(state,0) |
---|
| 2113 | state='off'; |
---|
| 2114 | end |
---|
| 2115 | if isequal(state,1) |
---|
| 2116 | state='on'; |
---|
| 2117 | end |
---|
| 2118 | if isequal(state,'on') |
---|
| 2119 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 2120 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 2121 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 2122 | else |
---|
| 2123 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2124 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2125 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2126 | end |
---|
| 2127 | set(handles.ibx,'Visible',state) |
---|
| 2128 | set(handles.iby,'Visible',state) |
---|
| 2129 | set(handles.isx,'Visible',state) |
---|
| 2130 | set(handles.isy,'Visible',state) |
---|
| 2131 | set(handles.shiftx,'Visible',state) |
---|
| 2132 | set(handles.shifty,'Visible',state) |
---|
| 2133 | set(handles.rho,'Visible',state) |
---|
| 2134 | set(handles.dx_civ1,'Visible',state) |
---|
| 2135 | set(handles.dy_civ1,'Visible',state) |
---|
| 2136 | set(handles.calcul_search,'Visible',state) |
---|
| 2137 | set(handles.u_text,'Visible',state) |
---|
| 2138 | set(handles.v_text,'Visible',state) |
---|
| 2139 | set(handles.min,'Visible',state) |
---|
| 2140 | set(handles.max,'Visible',state) |
---|
| 2141 | set(handles.umin,'Visible',state) |
---|
| 2142 | set(handles.umax,'Visible',state) |
---|
| 2143 | set(handles.vmin,'Visible',state) |
---|
| 2144 | set(handles.vmax,'Visible',state) |
---|
| 2145 | set(handles.grid_civ1,'Visible',state) |
---|
| 2146 | set(handles.mask_civ1,'Visible',state) |
---|
| 2147 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 2148 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 2149 | set(handles.parameters,'Visible',state) |
---|
| 2150 | set(handles.grid,'Visible',state) |
---|
| 2151 | set(handles.dx_civ1,'Visible',state) |
---|
| 2152 | set(handles.dy_civ1,'Visible',state) |
---|
| 2153 | set(handles.ImaThreshold,'Visible',state) |
---|
| 2154 | if isequal(state,'off') |
---|
| 2155 | set(handles.MinIma,'Visible','off') |
---|
| 2156 | set(handles.MaxIma,'Visible','off') |
---|
| 2157 | set(handles.ImaThreshold,'Value',0) |
---|
| 2158 | end |
---|
| 2159 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 2160 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 2161 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 2162 | set(handles.ib_title,'Visible',state) |
---|
| 2163 | set(handles.is_title,'Visible',state) |
---|
| 2164 | set(handles.shift_title,'Visible',state) |
---|
| 2165 | set(handles.rho_title,'Visible',state) |
---|
| 2166 | |
---|
| 2167 | %---------------------------------------------------------- |
---|
| 2168 | function enable_fix1(handles) |
---|
| 2169 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 2170 | set(handles.REMOVE,'Visible','on') |
---|
| 2171 | set(handles.vec_Fmin2,'Visible','on') |
---|
| 2172 | set(handles.vec_F2,'Visible','on') |
---|
| 2173 | set(handles.vec_F3,'Visible','on') |
---|
| 2174 | set(handles.thresh_vecC,'Visible','on') |
---|
| 2175 | set(handles.thresh_vecC_title,'Visible','on') |
---|
| 2176 | set(handles.thresh_vel,'Visible','on') |
---|
| 2177 | set(handles.thresh_vel_text,'Visible','on') |
---|
| 2178 | set(handles.mask_fix1,'Visible','on') |
---|
| 2179 | set(handles.get_mask_fix1,'Visible','on') |
---|
| 2180 | set(handles.get_ref_fix1,'Visible','on') |
---|
| 2181 | set(handles.ref_fix1,'Visible','on') |
---|
| 2182 | set(handles.inf_sup1,'Visible','on') |
---|
| 2183 | set(handles.field_ref1,'Visible','on') |
---|
| 2184 | |
---|
| 2185 | %---------------------------------------------------------- |
---|
| 2186 | function desable_fix1(handles) |
---|
| 2187 | set(handles.frame_fix1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2188 | set(handles.REMOVE,'Visible','off') |
---|
| 2189 | set(handles.vec_Fmin2,'Visible','off') |
---|
| 2190 | set(handles.vec_F2,'Visible','off') |
---|
| 2191 | set(handles.vec_F3,'Visible','off') |
---|
| 2192 | set(handles.thresh_vecC,'Visible','off') |
---|
| 2193 | set(handles.thresh_vecC_title,'Visible','off') |
---|
| 2194 | set(handles.thresh_vel,'Visible','off') |
---|
| 2195 | set(handles.thresh_vel_text,'Visible','off') |
---|
| 2196 | set(handles.mask_fix1,'Visible','off') |
---|
| 2197 | set(handles.get_mask_fix1,'Visible','off') |
---|
| 2198 | set(handles.get_ref_fix1,'Visible','off') |
---|
| 2199 | set(handles.ref_fix1,'Visible','off') |
---|
| 2200 | set(handles.inf_sup1,'Visible','off') |
---|
| 2201 | set(handles.field_ref1,'Visible','off') |
---|
| 2202 | |
---|
| 2203 | %-------------------------------------------------------------- |
---|
| 2204 | function enable_patch1(handles) |
---|
| 2205 | global patch_new_exe |
---|
| 2206 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 2207 | set(handles.rho_patch1,'Visible','on') |
---|
| 2208 | set(handles.rho_text1,'Visible','on') |
---|
| 2209 | set(handles.thresh_patch1,'Visible','on') |
---|
| 2210 | set(handles.thresh_text1,'Visible','on') |
---|
| 2211 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 2212 | set(handles.subdomain_text1,'Visible','on') |
---|
| 2213 | set(handles.nx_patch1,'Visible','on') |
---|
| 2214 | set(handles.ny_patch1,'Visible','on') |
---|
| 2215 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 2216 | set(handles.ny_patch1_title,'Visible','on') |
---|
| 2217 | if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[])) |
---|
| 2218 | set(handles.test_interp,'Visible','on'); |
---|
| 2219 | end |
---|
| 2220 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 2221 | set(handles.grid_patch1,'string','none'); |
---|
| 2222 | set(handles.grid_patch1,'Visible','on') |
---|
| 2223 | |
---|
| 2224 | %-------------------------------------------------------------- |
---|
| 2225 | function desable_patch1(handles) |
---|
| 2226 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2227 | set(handles.rho_patch1,'Visible','off') |
---|
| 2228 | set(handles.rho_text1,'Visible','off') |
---|
| 2229 | set(handles.thresh_patch1,'Visible','off') |
---|
| 2230 | set(handles.thresh_text1,'Visible','off') |
---|
| 2231 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 2232 | set(handles.subdomain_text1,'Visible','off') |
---|
| 2233 | set(handles.nx_patch1,'Visible','off') |
---|
| 2234 | set(handles.ny_patch1,'Visible','off') |
---|
| 2235 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 2236 | set(handles.ny_patch1_title,'Visible','off') |
---|
| 2237 | set(handles.test_interp,'Visible','off') |
---|
| 2238 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 2239 | set(handles.grid_patch1,'Visible','off') |
---|
| 2240 | |
---|
| 2241 | %---------------------------------------------------------- |
---|
| 2242 | function enable_civ2(handles,state) |
---|
| 2243 | if isequal(state,0) |
---|
| 2244 | state='off'; |
---|
| 2245 | end |
---|
| 2246 | if isequal(state,1) |
---|
| 2247 | state='on'; |
---|
| 2248 | end |
---|
| 2249 | if isequal(state,'on') |
---|
| 2250 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 2251 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 2252 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 2253 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 2254 | else |
---|
| 2255 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2256 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2257 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2258 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2259 | end |
---|
| 2260 | set(handles.ibx_civ2,'Visible',state) |
---|
| 2261 | set(handles.iby_civ2,'Visible',state) |
---|
| 2262 | set(handles.decimal,'Visible',state) |
---|
| 2263 | set(handles.deformation,'Visible',state) |
---|
| 2264 | set(handles.rho_civ2,'Visible',state) |
---|
| 2265 | set(handles.dx_civ2,'Visible',state) |
---|
| 2266 | set(handles.dy_civ2,'Visible',state) |
---|
| 2267 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 2268 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 2269 | set(handles.parameters,'Visible',state) |
---|
| 2270 | set(handles.grid,'Visible',state) |
---|
| 2271 | set(handles.parameters_text,'Visible',state) |
---|
| 2272 | set(handles.grid_text,'Visible',state) |
---|
| 2273 | set(handles.grid_civ2,'Visible',state) |
---|
| 2274 | set(handles.mask_civ2,'Visible',state) |
---|
| 2275 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 2276 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 2277 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 2278 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 2279 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 2280 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 2281 | if isequal(state,'off') |
---|
| 2282 | set(handles.MinIma2,'Visible','off') |
---|
| 2283 | set(handles.MaxIma2,'Visible','off') |
---|
| 2284 | set(handles.ImaThreshold2,'Value',0) |
---|
| 2285 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 2286 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 2287 | set(handles.subdir_civ2,'Visible','off') |
---|
| 2288 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 2289 | end |
---|
| 2290 | else |
---|
| 2291 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 2292 | set(handles.subdir_civ2,'Visible','on') |
---|
| 2293 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 2294 | end |
---|
| 2295 | |
---|
| 2296 | %---------------------------------------------------------- |
---|
| 2297 | % function desable_civ2(handles) |
---|
| 2298 | % set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2299 | % set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2300 | % set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2301 | % set(handles.ibx_civ2,'Visible','off') |
---|
| 2302 | % set(handles.iby_civ2,'Visible','off') |
---|
| 2303 | % set(handles.decimal,'Visible','off') |
---|
| 2304 | % set(handles.deformation,'Visible','off') |
---|
| 2305 | % set(handles.rho_civ2,'Visible','off') |
---|
| 2306 | % set(handles.dx_civ2,'Visible','off') |
---|
| 2307 | % set(handles.dy_civ2,'Visible','off') |
---|
| 2308 | % set(handles.browse_gridciv2,'Visible','off') |
---|
| 2309 | % set(handles.get_mask_civ2,'Visible','off') |
---|
| 2310 | % set(handles.parameters,'Visible','off') |
---|
| 2311 | % set(handles.grid,'Visible','off') |
---|
| 2312 | % set(handles.grid,'Visible','on') |
---|
| 2313 | % set(handles.parameters_text,'Visible','off') |
---|
| 2314 | % set(handles.grid_text,'Visible','off') |
---|
| 2315 | % set(handles.grid_civ2,'Visible','off') |
---|
| 2316 | % set(handles.mask_civ2,'Visible','off') |
---|
| 2317 | % set(handles.dx_civ2_title,'Visible','off') |
---|
| 2318 | % set(handles.dy_civ2_title,'Visible','off') |
---|
| 2319 | % set(handles.ibx_civ2_text,'Visible','off') |
---|
| 2320 | % set(handles.rho_civ2_title,'Visible','off') |
---|
| 2321 | % set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2322 | % if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 2323 | % set(handles.list_pair_civ2,'Visible','off') |
---|
| 2324 | % set(handles.subdir_civ2,'Visible','off') |
---|
| 2325 | % set(handles.subdir_civ2_text,'Visible','off') |
---|
| 2326 | % end |
---|
| 2327 | |
---|
| 2328 | %---------------------------------------------------------- |
---|
| 2329 | function enable_fix2(handles) |
---|
| 2330 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 2331 | set(handles.REMOVE2,'Visible','on') |
---|
| 2332 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 2333 | set(handles.vec_F4,'Visible','on') |
---|
| 2334 | set(handles.vec_F3_2,'Visible','on') |
---|
| 2335 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 2336 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 2337 | set(handles.thresh_vel2,'Visible','on') |
---|
| 2338 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 2339 | set(handles.mask_fix2,'Visible','on') |
---|
| 2340 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 2341 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 2342 | set(handles.subdir_civ2,'Visible','on') |
---|
| 2343 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 2344 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 2345 | set(handles.ref_fix2,'Visible','on') |
---|
| 2346 | set(handles.inf_sup2,'Visible','on') |
---|
| 2347 | set(handles.field_ref2,'Visible','on') |
---|
| 2348 | |
---|
| 2349 | %---------------------------------------------------------- |
---|
| 2350 | function desable_fix2(handles) |
---|
| 2351 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2352 | set(handles.REMOVE2,'Visible','off') |
---|
| 2353 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 2354 | set(handles.vec_F4,'Visible','off') |
---|
| 2355 | set(handles.vec_F3_2,'Visible','off') |
---|
| 2356 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 2357 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 2358 | set(handles.thresh_vel2,'Visible','off') |
---|
| 2359 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 2360 | set(handles.mask_fix2,'Visible','off') |
---|
| 2361 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 2362 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 2363 | set(handles.ref_fix2,'Visible','off') |
---|
| 2364 | set(handles.inf_sup2,'Visible','off') |
---|
| 2365 | set(handles.field_ref2,'Visible','off') |
---|
| 2366 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 2367 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 2368 | set(handles.subdir_civ2,'Visible','off') |
---|
| 2369 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 2370 | end |
---|
| 2371 | |
---|
| 2372 | %-------------------------------------------------------------- |
---|
| 2373 | function enable_patch2(handles) |
---|
| 2374 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 2375 | set(handles.rho_patch2,'Visible','on') |
---|
| 2376 | set(handles.rho_text2,'Visible','on') |
---|
| 2377 | set(handles.thresh_patch2,'Visible','on') |
---|
| 2378 | set(handles.thresh_text2,'Visible','on') |
---|
| 2379 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 2380 | set(handles.subdomain_text2,'Visible','on') |
---|
| 2381 | set(handles.nx_patch2,'Visible','on') |
---|
| 2382 | set(handles.ny_patch2,'Visible','on') |
---|
| 2383 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 2384 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 2385 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 2386 | set(handles.grid_patch2,'Visible','on') |
---|
| 2387 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 2388 | set(handles.subdir_civ2,'Visible','on') |
---|
| 2389 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 2390 | |
---|
| 2391 | %-------------------------------------------------------------- |
---|
| 2392 | function desable_patch2(handles) |
---|
| 2393 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2394 | set(handles.rho_patch2,'Visible','off') |
---|
| 2395 | set(handles.rho_text2,'Visible','off') |
---|
| 2396 | set(handles.thresh_patch2,'Visible','off') |
---|
| 2397 | set(handles.thresh_text2,'Visible','off') |
---|
| 2398 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 2399 | set(handles.subdomain_text2,'Visible','off') |
---|
| 2400 | set(handles.nx_patch2,'Visible','off') |
---|
| 2401 | set(handles.ny_patch2,'Visible','off') |
---|
| 2402 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 2403 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 2404 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 2405 | set(handles.grid_patch2,'Visible','off') |
---|
| 2406 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 2407 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 2408 | set(handles.subdir_civ2,'Visible','off') |
---|
| 2409 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 2410 | end |
---|
| 2411 | |
---|
| 2412 | % --- Executes on button press in test_interp. |
---|
| 2413 | function test_interp_Callback(hObject, eventdata, handles) |
---|
| 2414 | |
---|
| 2415 | |
---|
| 2416 | %------------------------------------------------ |
---|
| 2417 | %Read the parameters for civ1 on the interface |
---|
| 2418 | %-------------------------------------------------- |
---|
| 2419 | function par=read_param_civ1(handles,file_ima) |
---|
| 2420 | |
---|
| 2421 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 2422 | par.correlationBoxesSize_X=num2str(ibx_val); |
---|
| 2423 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 2424 | par.correlationBoxesSize_Y=num2str(iby_val); |
---|
| 2425 | ibz_val=str2num(get(handles.ibz,'String')); |
---|
| 2426 | par.correlationBoxesSize_Z=num2str(ibz_val); |
---|
| 2427 | isx=get(handles.isx,'String'); |
---|
| 2428 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 2429 | maxDisplacement_X=floor((str2num(isx)-ibx_val)/2); |
---|
| 2430 | par.maxDisplacement_X=num2str(maxDisplacement_X); |
---|
| 2431 | isy=get(handles.isy,'String'); |
---|
| 2432 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end; %default |
---|
| 2433 | maxDisplacement_Y=floor((str2num(isy)-iby_val)/2); |
---|
| 2434 | par.maxDisplacement_Y=num2str(maxDisplacement_Y); |
---|
| 2435 | isz=get(handles.isz,'String'); |
---|
| 2436 | if isempty(str2num(isz)), isz='41'; set(handles.isz,'String','41'), end; %default |
---|
| 2437 | maxDisplacement_Z=floor((str2num(isz)-ibz_val)/2); |
---|
| 2438 | par.maxDisplacement_Z=num2str(maxDisplacement_Z); |
---|
| 2439 | % par.rho=get(handles.rho,'String'); |
---|
| 2440 | par.gridSpacing_X=get(handles.dx_civ1,'String'); |
---|
| 2441 | par.gridSpacing_Y=get(handles.dy_civ1,'String'); |
---|
| 2442 | par.gridSpacing_Z=get(handles.dz_civ1,'String'); |
---|
| 2443 | % Zmin=str2num(get(handles.first_j,'String'))-1; |
---|
[71] | 2444 | Zmax=str2num(get(handles.npz,'String')); |
---|
[2] | 2445 | par.gridLimits_Xmin=0; |
---|
| 2446 | par.gridLimits_Ymin=0; |
---|
| 2447 | par.gridLimits_Zmin=0; |
---|
| 2448 | % A=imread(file_ima);%read the first image to get the size |
---|
| 2449 | %sizim=size(A); |
---|
[71] | 2450 | par.gridLimits_Xmax=str2double(get(handles.npx,'String'));%num2str(sizim(2)); |
---|
| 2451 | par.gridLimits_Ymax=str2double(get(handles.npy,'String'));%num2str(sizim(1)); |
---|
[2] | 2452 | par.gridLimits_Zmax=Zmax; |
---|
| 2453 | par.grid='grille'; |
---|
| 2454 | par.grid_division=4; |
---|
| 2455 | par.hart=0; |
---|
| 2456 | par.ratioHoverZ=1; |
---|
| 2457 | |
---|
| 2458 | % |
---|
| 2459 | % %---------------------------------------------------------------- |
---|
| 2460 | % function par=read_param_civ2(handles,file_ima) |
---|
| 2461 | % par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 2462 | % par.iby=get(handles.iby_civ2,'String'); |
---|
| 2463 | % par.rho=get(handles.rho_civ2,'String'); |
---|
| 2464 | % par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 2465 | % par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 2466 | % par.dx=get(handles.dx_civ2,'String'); |
---|
| 2467 | % par.dy=get(handles.dy_civ2,'String'); |
---|
| 2468 | % if isequal(str2num(par.dx),[]) |
---|
| 2469 | % if isempty(get(handles.grid_civ2,'String')); |
---|
| 2470 | % par.dx='0'; %just read by civ_3D program, not used |
---|
| 2471 | % else |
---|
| 2472 | % par.dx='20';%default |
---|
| 2473 | % set(handles.dx_civ2,'String','20'); |
---|
| 2474 | % end |
---|
| 2475 | % end |
---|
| 2476 | % if isequal(str2num(par.dy),[]) |
---|
| 2477 | % if isempty(get(handles.grid_civ2,'String')); |
---|
| 2478 | % par.dy='0';%just read by civ_3D program, not used |
---|
| 2479 | % else |
---|
| 2480 | % par.dy='20';%default |
---|
| 2481 | % set(handles.dy_civ2,'String','20'); |
---|
| 2482 | % end |
---|
| 2483 | % end |
---|
| 2484 | % par.pxcmx=get(handles.pxcmx,'String'); |
---|
| 2485 | % par.pxcmy=get(handles.pxcmy,'String'); |
---|
| 2486 | % if isempty(str2num(par.pxcmx)) |isempty(str2num(par.pxcmy)) |
---|
| 2487 | % par.pxcmx='1'; |
---|
| 2488 | % par.pxcmy='1'; |
---|
| 2489 | % end |
---|
| 2490 | % % par.npx=get(handles.pxcmx,'UserData'); |
---|
| 2491 | % % par.npy=get(handles.pxcmy,'UserData'); |
---|
| 2492 | % A=imread(file_ima);%read the first image to get the size |
---|
| 2493 | % sizim=size(A); |
---|
| 2494 | % par.npx=num2str(sizim(2)); |
---|
| 2495 | % par.npy=num2str(sizim(1)); |
---|
| 2496 | % time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2497 | % par.gridname=get(handles.grid_civ2,'String'); |
---|
| 2498 | % par.gridflag='y'; |
---|
| 2499 | % if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 2500 | % par.gridname='nogrid'; |
---|
| 2501 | % par.gridflag='n'; |
---|
| 2502 | % end |
---|
| 2503 | |
---|
| 2504 | |
---|
| 2505 | %--------------------------------------------------------- |
---|
| 2506 | %CIV1 CIV1 CIV1 CIV1 |
---|
| 2507 | %---------------------------------------------------------- |
---|
| 2508 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles) |
---|
| 2509 | %pixels per cm and matrix of the image times, read from the .civ_3D file by uvmat |
---|
| 2510 | global civ1_exe Civ_exe sge%name of the executable for civ1 calculation |
---|
| 2511 | |
---|
| 2512 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 2513 | |
---|
| 2514 | if isequal(par.Dt,'0') |
---|
| 2515 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 2516 | end |
---|
| 2517 | |
---|
| 2518 | textcmx={'############## CMX file';... |
---|
| 2519 | ['FirstImage ' par.filename_ima_a];... |
---|
| 2520 | ['LastImage ' par.filename_ima_b];... |
---|
| 2521 | 'XX' ;... |
---|
| 2522 | ['Mask ' par.maskflag] ;... |
---|
| 2523 | ['MaskName ' par.maskname];... |
---|
| 2524 | ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 2525 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 2526 | ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 2527 | ['RO ' par.rho];... |
---|
| 2528 | ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 2529 | 'XX 1.0';... |
---|
| 2530 | ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 2531 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 2532 | 'XX 1';... |
---|
| 2533 | ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 2534 | ['Grid ' par.gridflag];... |
---|
| 2535 | ['GridName ' par.gridname] ;... |
---|
| 2536 | 'XX 85';... |
---|
| 2537 | 'XX 1.0';... |
---|
| 2538 | 'XX 1.0';... |
---|
| 2539 | 'Hart 1';... |
---|
| 2540 | 'DecimalShift 0';... |
---|
| 2541 | 'Deformation 0';... |
---|
| 2542 | 'CorrelationMin 0';... |
---|
| 2543 | 'IntensityMin 0';... |
---|
| 2544 | 'SeuilImage n';... |
---|
| 2545 | 'SeuilImageValues 0 4096';... |
---|
| 2546 | ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 2547 | 'ImageUsedBefore null null'}; |
---|
| 2548 | |
---|
| 2549 | textout=char(textcmx); |
---|
| 2550 | % timeL1=clock; |
---|
| 2551 | dlmwrite([filename '.cmx'],textout,''); |
---|
| 2552 | % timeL2=clock; |
---|
| 2553 | % timciv1=etime(timeL2,timeL1) |
---|
| 2554 | if sge |
---|
| 2555 | cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
| 2556 | else |
---|
| 2557 | cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 2558 | end |
---|
| 2559 | if(isunix) |
---|
| 2560 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 2561 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
| 2562 | cmd_CIV1=char({cmd_CIV1 ; ['mv ' namelog ' ' namelog '.civ1.log'];['chmod g+w ' ncName]}); |
---|
| 2563 | else |
---|
| 2564 | cmd_CIV1=char({cmd_CIV1 ; ['copy /Y ' namelog ' ' namelog '.civ1.log']}); |
---|
| 2565 | end |
---|
| 2566 | |
---|
| 2567 | %--------------------------------------------------------- |
---|
| 2568 | %CIV1 Unified |
---|
| 2569 | %---------------------------------------------------------- |
---|
| 2570 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par,handles) |
---|
| 2571 | %pixels per cm and matrix of the image times, read from the .civ_3D file by uvmat |
---|
| 2572 | global civ1_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 2573 | |
---|
| 2574 | civ1.image1=par.filename_ima_a; |
---|
| 2575 | civ1.image2=par.filename_ima_b; |
---|
| 2576 | civ1.imageSize_X=par.npx; |
---|
| 2577 | civ1.imageSize_Y=par.npy; |
---|
| 2578 | civ1.outputFileName=[filename '.nc']; |
---|
| 2579 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 2580 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 2581 | civ1.searchBoxesSize_X=par.isx; |
---|
| 2582 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 2583 | civ1.globalShift_X=par.shiftx; |
---|
| 2584 | civ1.globalShift_Y=par.shifty; |
---|
| 2585 | civ1.ro=par.rho; |
---|
| 2586 | civ1.hart='y'; |
---|
| 2587 | if isequal(par.gridflag,'y') |
---|
| 2588 | civ1.grid=par.gridname; |
---|
| 2589 | end |
---|
| 2590 | civ1.gridSpacing_X=par.dx; |
---|
| 2591 | civ1.gridSpacing_Y=par.dy; |
---|
| 2592 | if isequal(par.maskflag,'y') |
---|
| 2593 | civ1.mask=par.maskname; |
---|
| 2594 | end |
---|
| 2595 | civ1.dt=par.Dt; |
---|
| 2596 | civ1.unit='pixel'; |
---|
| 2597 | civ1.absolut_time_T0=par.T0; |
---|
| 2598 | civ1.pixcmx=par.pxcmx; |
---|
| 2599 | civ1.pixcmy=par.pxcmy; |
---|
| 2600 | civ1.convectFlow='n'; |
---|
| 2601 | |
---|
| 2602 | xml_civ1_parameters=civ1; |
---|
| 2603 | |
---|
| 2604 | %--------------------------------------------------------- |
---|
| 2605 | %CIV2 CIV2 CIV2 CIV2 |
---|
| 2606 | %---------------------------------------------------------- |
---|
| 2607 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par) |
---|
| 2608 | %pixels per cm and matrix of the image times, read from the .civ_3D file by uvmat |
---|
| 2609 | global civ2_exe sge%name of the executable for civ1 calculation |
---|
| 2610 | if isequal(par.Dt,'0') |
---|
| 2611 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 2612 | end |
---|
| 2613 | textcmx={'############## CMX file';... |
---|
| 2614 | ['FirstImage ' par.filename_ima_a];... |
---|
| 2615 | ['LastImage ' par.filename_ima_b];... |
---|
| 2616 | 'XX' ;... |
---|
| 2617 | ['Mask ' par.maskflag];... |
---|
| 2618 | ['MaskName ' par.maskname];... |
---|
| 2619 | ['ImageSize ' par.npx ' ' par.npy];... |
---|
| 2620 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 2621 | ['SearchBoxeSize ' par.ibx ' ' par.iby];... |
---|
| 2622 | ['RO ' par.rho];... |
---|
| 2623 | ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 2624 | 'XX 1.0';... |
---|
| 2625 | ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 2626 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 2627 | 'XX 1';... |
---|
| 2628 | ['ShiftXY 0 0'];... |
---|
| 2629 | ['Grid ' par.gridflag];... |
---|
| 2630 | ['GridName ' par.gridname];... |
---|
| 2631 | 'XX 85';... |
---|
| 2632 | 'XX 1.0';... |
---|
| 2633 | 'XX 1.0';... |
---|
| 2634 | 'Hart 1';... |
---|
| 2635 | ['DecimalShift ' par.decimal];... |
---|
| 2636 | ['Deformation ' par.deformation];... |
---|
| 2637 | 'CorrelationMin 0';... |
---|
| 2638 | 'IntensityMin 0';... |
---|
| 2639 | 'SeuilImage n';... |
---|
| 2640 | 'SeuilImageValues 0 4096';... |
---|
| 2641 | ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 2642 | ['ImageUsedBefore ' par.filename_nc1]}; |
---|
| 2643 | textout=char(textcmx); |
---|
| 2644 | dlmwrite([filename_cmx '2'] ,textout,''); |
---|
| 2645 | if sge |
---|
| 2646 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 2647 | else |
---|
| 2648 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 2649 | end |
---|
| 2650 | |
---|
| 2651 | |
---|
| 2652 | % --- Executes on button press in HELP. |
---|
| 2653 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 2654 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 2655 | pathelp=fileparts(path_to_uvmat); |
---|
| 2656 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 2657 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 2658 | else |
---|
| 2659 | web([helpfile '#civ_3D']) |
---|
| 2660 | end |
---|
| 2661 | |
---|
| 2662 | |
---|
| 2663 | %---------------------------------------------------------- |
---|
| 2664 | %--read images and convert them to the uint16 format used for PIV |
---|
| 2665 | function A=read_image(filename,nom_type,npx,npy,num); |
---|
| 2666 | %npx, npy are the dimensions needed for the raw SMD images |
---|
| 2667 | %num is the view number needed for an avi movie |
---|
| 2668 | if isequal(nom_type,'avi') |
---|
| 2669 | mov=aviread(filename,num); |
---|
| 2670 | A=frame2im(mov(1)); |
---|
| 2671 | A=sum(double(A),3); |
---|
| 2672 | A=uint16(A); |
---|
| 2673 | elseif isequal(nom_type,'raw_SMD') |
---|
| 2674 | [fid,message]=fopen(filename,'r'); |
---|
| 2675 | B=fread(fid,Inf,'int16',0,'ieee-le');%read 16 bit binary file |
---|
| 2676 | A=(reshape(B,npx,npy))'; %remplissage ligne par ligne avec une matrice colonne ? transposer(uB) pour avoir une matrice ligne |
---|
| 2677 | A=uint16(A); |
---|
| 2678 | fclose(fid); |
---|
| 2679 | else |
---|
| 2680 | A=imread(filename); |
---|
| 2681 | siz=size(A); |
---|
| 2682 | if length(siz)==3;%color images |
---|
| 2683 | A=sum(double(A),3); |
---|
| 2684 | end |
---|
| 2685 | A=uint16(A); |
---|
| 2686 | end |
---|
| 2687 | |
---|
| 2688 | %---------------------------------------------------------------- |
---|
| 2689 | %Executes on carriage return on the time interval dt |
---|
| 2690 | %---------------------------------------------------------------- |
---|
| 2691 | function dt_Callback(hObject, eventdata, handles) |
---|
| 2692 | %determine the set of times and possible intervals for CIV_3D |
---|
| 2693 | % answer=inputdlg('time interval between images?'); |
---|
| 2694 | dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 2695 | nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series |
---|
| 2696 | time=(dt*[0:nbfield-1])'; |
---|
| 2697 | % set(handles.incr_i,'UserData',dt);%store the time interval between successive images |
---|
| 2698 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 2699 | for index=1:min(nbfield-1,200) |
---|
| 2700 | displ_num(1,index)=1; |
---|
| 2701 | displ_num(2,index)=1; |
---|
| 2702 | displ_num(3,index)=-floor(index/2); |
---|
| 2703 | displ_num(4,index)=ceil(index/2); |
---|
| 2704 | end |
---|
| 2705 | set(handles.list_pair_civ1,'Value',1); |
---|
| 2706 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 2707 | set(handles.list_pair_civ2,'Value',1); |
---|
| 2708 | %update the list of time intervals |
---|
| 2709 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 2710 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 2711 | |
---|
| 2712 | %------------------------------------------------------- |
---|
| 2713 | function ref_i_Callback(hObject, eventdata, handles) |
---|
| 2714 | mode_list=get(handles.mode,'String'); |
---|
| 2715 | mode_value=get(handles.mode,'Value'); |
---|
| 2716 | mode=mode_list{mode_value}; |
---|
| 2717 | if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)') |
---|
| 2718 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 2719 | end |
---|
| 2720 | if isequal(mode,'series(Di)') | ...% we do patch2 only |
---|
| 2721 | (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0) |
---|
| 2722 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 2723 | end |
---|
| 2724 | |
---|
| 2725 | %---------------------------------------------------- |
---|
| 2726 | function ref_j_Callback(hObject, eventdata, handles) |
---|
| 2727 | mode_list=get(handles.mode,'String'); |
---|
| 2728 | mode_value=get(handles.mode,'Value'); |
---|
| 2729 | mode=mode_list{mode_value}; |
---|
| 2730 | if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)') |
---|
| 2731 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 2732 | end |
---|
| 2733 | if isequal(mode,'series(Dj)') | ... |
---|
| 2734 | (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0) |
---|
| 2735 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 2736 | end |
---|
| 2737 | %---------------------------------------------------- |
---|
| 2738 | % --- Executes on button press in compare. |
---|
| 2739 | function compare_Callback(hObject, eventdata, handles) |
---|
| 2740 | test=get(handles.compare,'Value'); |
---|
| 2741 | if test |
---|
| 2742 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2743 | browse=get(handles.browse_root,'Userdata'); |
---|
| 2744 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 2745 | set(handles.browse_root,'UserData',browse); |
---|
| 2746 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
| 2747 | set(handles.displ_filebase2,'String',filebase); |
---|
| 2748 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 2749 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 2750 | set(handles.mode,'Value',1) |
---|
| 2751 | set(handles.mode,'String',{'displacement';'st_pair j1-j2'}) |
---|
| 2752 | else |
---|
| 2753 | set(handles.displ_filebase2,'Visible','Off'); |
---|
| 2754 | set(handles.displ_filebase2,'String',[]); |
---|
| 2755 | mode_store=get(handles.compare,'UserData'); |
---|
| 2756 | set(handles.mode,'String',mode_store) |
---|
| 2757 | set(handles.test_stereo1,'Value',0) |
---|
| 2758 | set(handles.test_stereo2,'Value',0) |
---|
| 2759 | end |
---|
| 2760 | mode_Callback(hObject, eventdata, handles) |
---|
| 2761 | |
---|
| 2762 | %----------------------------------------------------------- |
---|
| 2763 | % --- Executes on button press in get_ref_fix1. |
---|
| 2764 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
| 2765 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2766 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 2767 | {'*.nc', ' (*.nc)'; |
---|
| 2768 | '*.nc', 'netcdf files '; ... |
---|
| 2769 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2770 | 'Pick a file',filebase); |
---|
| 2771 | |
---|
| 2772 | fileinput=[PathName FileName]; |
---|
| 2773 | sizf=size(fileinput); |
---|
| 2774 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 2775 | %[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 2776 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 2777 | %filebase=fullfile(RootPath,RootFile); |
---|
| 2778 | % [Pth,FileN]=fileparts(filebasesub); |
---|
| 2779 | % Pth=fileparts(Pth); |
---|
| 2780 | ref.filebase=fullfile(Path,File); |
---|
| 2781 | ref.num_a=stra2num(str_a); |
---|
| 2782 | ref.num_b=stra2num(str_b); |
---|
| 2783 | ref.num1=str2num(field_count); |
---|
| 2784 | ref.num2=str2num(str2); |
---|
| 2785 | browse=[];%initialisation |
---|
| 2786 | if ~isequal(ref.ext,'.nc') |
---|
| 2787 | errordlg('the reference file must be in netcdf format (*.nc)') |
---|
| 2788 | return |
---|
| 2789 | end |
---|
| 2790 | % [path,name]=fileparts(ref.filebase); |
---|
| 2791 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 2792 | set(handles.ref_fix1,'UserData',ref) |
---|
| 2793 | menu_field{1}='civ1'; |
---|
| 2794 | Data=nc2struct(fileinput,[]); |
---|
| 2795 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 2796 | menu_field{2}='filter1'; |
---|
| 2797 | end |
---|
| 2798 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 2799 | menu_field{3}='civ2'; |
---|
| 2800 | end |
---|
| 2801 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 2802 | menu_field{4}='filter2'; |
---|
| 2803 | end |
---|
| 2804 | % [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'}); |
---|
| 2805 | % if isequal(cte_detect(1),1) & isequal(cte_read(1),1) |
---|
| 2806 | % menu_field{2}='filter1'; |
---|
| 2807 | % end |
---|
| 2808 | % if isequal(cte_detect(2),1) & isequal(cte_read(2),1) |
---|
| 2809 | % menu_field{3}='civ2'; |
---|
| 2810 | % end |
---|
| 2811 | % if isequal(cte_detect(3),1) & isequal(cte_read(3),1) |
---|
| 2812 | % menu_field{4}='filter2'; |
---|
| 2813 | % end |
---|
| 2814 | set(handles.field_ref1,'String',menu_field); |
---|
| 2815 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 2816 | set(handles.inf_sup1,'Value',2); |
---|
| 2817 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 2818 | set(handles.ref_fix1,'Enable','on') |
---|
| 2819 | |
---|
| 2820 | %--------------------------------------------------------------- |
---|
| 2821 | % --- Executes on button press in get_ref_fix2. |
---|
| 2822 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
| 2823 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 2824 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2825 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 2826 | {'*.nc', ' (*.nc)'; |
---|
| 2827 | '*.nc', 'netcdf files '; ... |
---|
| 2828 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2829 | 'Pick a file',filebase); |
---|
| 2830 | fileinput=[PathName FileName]; |
---|
| 2831 | sizf=size(fileinput); |
---|
| 2832 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 2833 | %[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 2834 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 2835 | % [Pth,FileN]=fileparts(filebasesub); |
---|
| 2836 | % Pth=fileparts(Pth); |
---|
| 2837 | ref.filebase=fullfile(Path,File) |
---|
| 2838 | ref.num_a=stra2num(str_a); |
---|
| 2839 | ref.num_b=stra2num(str_b); |
---|
| 2840 | ref.num1=str2num(field_count); |
---|
| 2841 | ref.num2=str2num(str2); |
---|
| 2842 | browse=[];%initialisation |
---|
| 2843 | if ~isequal(ref.ext,'.nc') |
---|
| 2844 | errordlg('the reference file must be in netcdf format (*.nc)') |
---|
| 2845 | return |
---|
| 2846 | end |
---|
| 2847 | % [path,name]=fileparts(ref.filebase); |
---|
| 2848 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 2849 | set(handles.ref_fix2,'UserData',ref) |
---|
| 2850 | menu_field{1}='civ1'; |
---|
| 2851 | % [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'}); |
---|
| 2852 | Data=nc2struct(fileinput,[]); |
---|
| 2853 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 2854 | menu_field{2}='filter1'; |
---|
| 2855 | end |
---|
| 2856 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 2857 | menu_field{3}='civ2'; |
---|
| 2858 | end |
---|
| 2859 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 2860 | menu_field{4}='filter2'; |
---|
| 2861 | end |
---|
| 2862 | |
---|
| 2863 | % if isequal(cte_detect(1),1) & isequal(cte_read(1),1) |
---|
| 2864 | % menu_field{2}='filter1'; |
---|
| 2865 | % end |
---|
| 2866 | % if isequal(cte_detect(2),1) & isequal(cte_read(2),1) |
---|
| 2867 | % menu_field{3}='civ2'; |
---|
| 2868 | % end |
---|
| 2869 | % if isequal(cte_detect(3),1) & isequal(cte_read(3),1) |
---|
| 2870 | % menu_field{4}='filter2'; |
---|
| 2871 | % end |
---|
| 2872 | set(handles.field_ref2,'String',menu_field); |
---|
| 2873 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 2874 | set(handles.inf_sup2,'Value',2); |
---|
| 2875 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 2876 | set(handles.ref_fix2,'Enable','on') |
---|
| 2877 | set(handles.ref_fix2,'Visible','on') |
---|
| 2878 | set(handles.field_ref2,'Visible','on') |
---|
| 2879 | else |
---|
| 2880 | set(handles.ref_fix2,'Visible','off') |
---|
| 2881 | set(handles.field_ref2,'Visible','off') |
---|
| 2882 | end |
---|
| 2883 | %------------------------------------------------------- |
---|
| 2884 | |
---|
| 2885 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
| 2886 | set(handles.inf_sup1,'Value',1); |
---|
| 2887 | set(handles.field_ref1,'Value',1) |
---|
| 2888 | set(handles.field_ref1,'String',{' '}) |
---|
| 2889 | set(handles.ref_fix1,'UserData',[]); |
---|
| 2890 | set(handles.ref_fix1,'String',''); |
---|
| 2891 | set(handles.thresh_vel1,'String','0'); |
---|
| 2892 | |
---|
| 2893 | |
---|
| 2894 | %------------------------------------------------------ |
---|
| 2895 | |
---|
| 2896 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
| 2897 | set(handles.inf_sup2,'Value',1); |
---|
| 2898 | set(handles.field_ref2,'Value',1) |
---|
| 2899 | set(handles.field_ref2,'String',{' '}) |
---|
| 2900 | set(handles.ref_fix2,'UserData',[]); |
---|
| 2901 | set(handles.ref_fix2,'String',''); |
---|
| 2902 | set(handles.thresh_vel2,'String','0'); |
---|
| 2903 | |
---|
| 2904 | %-------------------------------------------------------- |
---|
| 2905 | % --- Executes on selection change in inf_sup1. |
---|
| 2906 | function inf_sup1_Callback(hObject, eventdata, handles) |
---|
| 2907 | |
---|
| 2908 | %-------------------------------------------------------------------------- |
---|
| 2909 | |
---|
| 2910 | |
---|
| 2911 | % --- Executes on selection change in field_ref. |
---|
| 2912 | function field_ref_Callback(hObject, eventdata, handles) |
---|
| 2913 | |
---|
| 2914 | %------------------------------------------------------------------------- |
---|
| 2915 | |
---|
| 2916 | % --- Executes on selection change in field_ref2. |
---|
| 2917 | function field_ref2_Callback(hObject, eventdata, handles) |
---|
| 2918 | |
---|
| 2919 | % ----------------------------------------------------------- |
---|
| 2920 | % transform letters to numbers |
---|
| 2921 | %-------------------------------------------- |
---|
| 2922 | function numres=stra2num(str) |
---|
| 2923 | numres=double(str)-96; |
---|
| 2924 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 2925 | numres=str2num(str); |
---|
| 2926 | end |
---|
| 2927 | |
---|
| 2928 | |
---|
| 2929 | % --- Executes on button press in test_stereo1. |
---|
| 2930 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
| 2931 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 2932 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 2933 | set(handles.rho_patch1,'Visible','on') |
---|
| 2934 | else |
---|
| 2935 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 2936 | set(handles.rho_patch1,'Visible','off') |
---|
| 2937 | end |
---|
| 2938 | |
---|
| 2939 | % --- Executes on button press in test_stereo2. |
---|
| 2940 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
| 2941 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 2942 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 2943 | set(handles.rho_patch2,'Visible','on') |
---|
| 2944 | else |
---|
| 2945 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 2946 | set(handles.rho_patch2,'Visible','off') |
---|
| 2947 | end |
---|
| 2948 | |
---|
| 2949 | % --- Executes on button press in ImaThreshold. |
---|
| 2950 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
| 2951 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 2952 | set(handles.MinIma,'Visible','on') |
---|
| 2953 | set(handles.MaxIma,'Visible','on') |
---|
| 2954 | else |
---|
| 2955 | set(handles.MinIma,'Visible','off') |
---|
| 2956 | set(handles.MaxIma,'Visible','off') |
---|
| 2957 | end |
---|
| 2958 | |
---|
| 2959 | |
---|
| 2960 | % --- Executes on button press in ImaThreshold2. |
---|
| 2961 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
| 2962 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 2963 | set(handles.MinIma2,'Visible','on') |
---|
| 2964 | set(handles.MaxIma2,'Visible','on') |
---|
| 2965 | else |
---|
| 2966 | set(handles.MinIma2,'Visible','off') |
---|
| 2967 | set(handles.MaxIma2,'Visible','off') |
---|
| 2968 | end |
---|
| 2969 | |
---|
| 2970 | |
---|
| 2971 | |
---|
| 2972 | % --- Executes on button press in Experimental. |
---|
| 2973 | function Experimental_Callback(hObject, eventdata, handles) |
---|
| 2974 | |
---|
| 2975 | |
---|
| 2976 | |
---|
| 2977 | function ibz_Callback(hObject, eventdata, handles) |
---|
| 2978 | % hObject handle to ibz (see GCBO) |
---|
| 2979 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2980 | % handles structure with handles and user data (see GUIDATA) |
---|
| 2981 | |
---|
| 2982 | % Hints: get(hObject,'String') returns contents of ibz as text |
---|
| 2983 | % str2double(get(hObject,'String')) returns contents of ibz as a double |
---|
| 2984 | |
---|
| 2985 | |
---|
| 2986 | % --- Executes during object creation, after setting all properties. |
---|
| 2987 | function ibz_CreateFcn(hObject, eventdata, handles) |
---|
| 2988 | % hObject handle to ibz (see GCBO) |
---|
| 2989 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2990 | % handles empty - handles not created until after all CreateFcns called |
---|
| 2991 | |
---|
| 2992 | % Hint: edit controls usually have a white background on Windows. |
---|
| 2993 | % See ISPC and COMPUTER. |
---|
| 2994 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
| 2995 | set(hObject,'BackgroundColor','white'); |
---|
| 2996 | end |
---|
| 2997 | |
---|
| 2998 | |
---|
| 2999 | |
---|
| 3000 | function edit74_Callback(hObject, eventdata, handles) |
---|
| 3001 | % hObject handle to edit74 (see GCBO) |
---|
| 3002 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3003 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3004 | |
---|
| 3005 | % Hints: get(hObject,'String') returns contents of edit74 as text |
---|
| 3006 | % str2double(get(hObject,'String')) returns contents of edit74 as a double |
---|
| 3007 | |
---|
| 3008 | |
---|
| 3009 | % --- Executes during object creation, after setting all properties. |
---|
| 3010 | function edit74_CreateFcn(hObject, eventdata, handles) |
---|
| 3011 | % hObject handle to edit74 (see GCBO) |
---|
| 3012 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3013 | % handles empty - handles not created until after all CreateFcns called |
---|
| 3014 | |
---|
| 3015 | % Hint: edit controls usually have a white background on Windows. |
---|
| 3016 | % See ISPC and COMPUTER. |
---|
| 3017 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
| 3018 | set(hObject,'BackgroundColor','white'); |
---|
| 3019 | end |
---|
| 3020 | |
---|
| 3021 | |
---|
[71] | 3022 | function dz_civ1_Callback(hObject, eventdata, handles) |
---|
| 3023 | % hObject handle to dz_civ1 (see GCBO) |
---|
| 3024 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3025 | % handles structure with handles and user data (see GUIDATA) |
---|
[2] | 3026 | |
---|
[71] | 3027 | % Hints: get(hObject,'String') returns contents of dz_civ1 as text |
---|
| 3028 | % str2double(get(hObject,'String')) returns contents of dz_civ1 as a double |
---|
| 3029 | |
---|
| 3030 | |
---|
| 3031 | function edit77_Callback(hObject, eventdata, handles) |
---|
| 3032 | % hObject handle to edit77 (see GCBO) |
---|
[2] | 3033 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3034 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3035 | |
---|
[71] | 3036 | % Hints: get(hObject,'String') returns contents of edit77 as text |
---|
| 3037 | % str2double(get(hObject,'String')) returns contents of edit77 as a double |
---|
[2] | 3038 | |
---|
| 3039 | |
---|
[71] | 3040 | |
---|
| 3041 | function edit78_Callback(hObject, eventdata, handles) |
---|
| 3042 | % hObject handle to ref_i (see GCBO) |
---|
[2] | 3043 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
[71] | 3044 | % handles structure with handles and user data (see GUIDATA) |
---|
[2] | 3045 | |
---|
[71] | 3046 | % Hints: get(hObject,'String') returns contents of ref_i as text |
---|
| 3047 | % str2double(get(hObject,'String')) returns contents of ref_i as a double |
---|
[2] | 3048 | |
---|
| 3049 | |
---|
[71] | 3050 | function edit79_Callback(hObject, eventdata, handles) |
---|
| 3051 | % hObject handle to edit79 (see GCBO) |
---|
| 3052 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3053 | % handles structure with handles and user data (see GUIDATA) |
---|
[2] | 3054 | |
---|
[71] | 3055 | % Hints: get(hObject,'String') returns contents of edit79 as text |
---|
| 3056 | % str2double(get(hObject,'String')) returns contents of edit79 as a double |
---|
| 3057 | |
---|
| 3058 | |
---|
| 3059 | |
---|
| 3060 | function npz_Callback(hObject, eventdata, handles) |
---|
| 3061 | % hObject handle to npz (see GCBO) |
---|
[2] | 3062 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3063 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3064 | |
---|
[71] | 3065 | % Hints: get(hObject,'String') returns contents of npz as text |
---|
| 3066 | % str2double(get(hObject,'String')) returns contents of npz as a double |
---|
[2] | 3067 | |
---|
| 3068 | |
---|
[71] | 3069 | function npy_Callback(hObject, eventdata, handles) |
---|
| 3070 | % hObject handle to npy (see GCBO) |
---|
[2] | 3071 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
[71] | 3072 | % handles structure with handles and user data (see GUIDATA) |
---|
[2] | 3073 | |
---|
[71] | 3074 | % Hints: get(hObject,'String') returns contents of npy as text |
---|
| 3075 | % str2double(get(hObject,'String')) returns contents of npy as a double |
---|
[2] | 3076 | |
---|
| 3077 | |
---|
[71] | 3078 | |
---|
| 3079 | |
---|
| 3080 | function npx_Callback(hObject, eventdata, handles) |
---|
| 3081 | % hObject handle to npx (see GCBO) |
---|
| 3082 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3083 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3084 | |
---|
| 3085 | % Hints: get(hObject,'String') returns contents of npx as text |
---|
| 3086 | % str2double(get(hObject,'String')) returns contents of npx as a double |
---|
| 3087 | |
---|
[343] | 3088 | %TODO: replace name2display by fileparts_uvmat: |
---|
[71] | 3089 | |
---|
| 3090 | |
---|
[343] | 3091 | %'name2display': extracts the root name and field numbers from an input filename |
---|
| 3092 | %-------------------------------------------------------------------- |
---|
| 3093 | %[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput) |
---|
| 3094 | % |
---|
| 3095 | %OUTPUT: |
---|
| 3096 | %filebasesub: filename without appendix |
---|
| 3097 | %field_count: string for the first number i |
---|
| 3098 | %str2: string for the second number i (only for .nc files) |
---|
| 3099 | %str_a: string for the first number j |
---|
| 3100 | %str_b:string for the second number j (only for .nc files) |
---|
| 3101 | %ext: file extension |
---|
| 3102 | %nom_type: char chain characterizing the file nomenclature: with values |
---|
| 3103 | % nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined) |
---|
| 3104 | % nom_type='*':constant name for a file representing a series (e.g. avi movie) |
---|
| 3105 | % nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png'). |
---|
| 3106 | % nom_type='_1','_01','_001'...': series of files with a single index i with separator '_'(e.g. 'aa_045.png'). |
---|
| 3107 | % nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case) |
---|
| 3108 | % nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index |
---|
| 3109 | % nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png') |
---|
| 3110 | % nom_type='_1-2': from pairs from a single index (e.g. 'aa_45-47.nc') |
---|
| 3111 | % nom_type='_1_1-2': pairs of j indices (e.g. 'aa_45_2-3.nc') |
---|
| 3112 | % nom_type='_1-2_j': pairs of i indices (e.g. 'aa_45-46_2.nc') |
---|
| 3113 | % nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc' |
---|
| 3114 | %subdir: name of the subdirectory for netcdf files |
---|
| 3115 | % |
---|
| 3116 | %INPUT: |
---|
| 3117 | %fileinput: complete name of the file, including path |
---|
[71] | 3118 | |
---|
[343] | 3119 | function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput) |
---|
| 3120 | % siz=length(fileinput); |
---|
| 3121 | % indcur=siz; |
---|
| 3122 | % default values: |
---|
| 3123 | % test_=0; |
---|
| 3124 | field_count='';%character string |
---|
| 3125 | str2=''; |
---|
| 3126 | str_a=''; |
---|
| 3127 | str_b=''; |
---|
| 3128 | % ext=''; |
---|
| 3129 | nom_type=''; |
---|
| 3130 | subdir=''; |
---|
| 3131 | %select file extension |
---|
| 3132 | [RootPath,RootFile,ext]=fileparts(fileinput); |
---|
| 3133 | indcur=length(RootFile);% nbre of characters in fileraw |
---|
| 3134 | |
---|
| 3135 | %recognize the name form |
---|
| 3136 | % filerawascii=double(RootFile);%ascci code |
---|
| 3137 | % val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters |
---|
| 3138 | indsel=regexp(RootFile,'\D');% character indices of non numerical characters |
---|
| 3139 | filelit=RootFile(indsel);% fileraw name with numbers removed |
---|
| 3140 | nbchar=length(indsel); |
---|
| 3141 | if nbchar<4% put '*' before the name (remove at the end) |
---|
| 3142 | prefilelit(1:4-nbchar)='*';%insert 3_nbchar '*' in the file name |
---|
| 3143 | filelit=[prefilelit filelit]; |
---|
| 3144 | indsel=[1:4-nbchar indsel+4-nbchar]; |
---|
| 3145 | RootFile=[prefilelit RootFile]; |
---|
| 3146 | indcur=indcur+4-nbchar; |
---|
| 3147 | end |
---|
| 3148 | separ3=indsel(end);% index of last non numerical character in fileraw |
---|
| 3149 | separ2=indsel(end-1);% index of previous non numerical character |
---|
| 3150 | separ1=indsel(end-2); |
---|
| 3151 | separ0=indsel(end-3); |
---|
| 3152 | num1='';num2='';num3=''; |
---|
| 3153 | if separ1>=separ0+1,num0=RootFile(separ0+1:separ1-1);end |
---|
| 3154 | if separ2>=separ1+1,num1=RootFile(separ1+1:separ2-1);end |
---|
| 3155 | if separ3>=separ2+1,num2=RootFile(separ2+1:separ3-1);end |
---|
| 3156 | if indcur>=separ3+1,num3=RootFile(separ3+1:indcur);end |
---|
| 3157 | last_str=RootFile(indcur);%last character in fileraw |
---|
| 3158 | last=double(last_str);%corresponding ascii code |
---|
| 3159 | penult=double(RootFile(indcur-1));%ascii code of the penultimate character |
---|
| 3160 | testsub=0; %default |
---|
| 3161 | % % case of an indexed series in a single file |
---|
| 3162 | % if strcmpi(ext,'.avi') |
---|
| 3163 | % nom_type='*'; |
---|
| 3164 | % %case of a numerical index follewed by a lower case letter (e.g. a,b,c): |
---|
| 3165 | % %the penultimate character is a number and the last one a letter (lower case: last >= 97 && last <= 122 |
---|
| 3166 | % % capital |
---|
| 3167 | % % letter: last >= 65 && last <= 90) |
---|
| 3168 | if penult >= 48 && penult <= 57 && ((last >= 65 && last <= 90)||(last >= 97 && last <= 122)) |
---|
| 3169 | str_a=last_str; %extract appendix a,b,c... or A,B,C... as output. |
---|
| 3170 | ind_end=indcur-1; %current index just before the suffix letter |
---|
| 3171 | indices_root=regexp(RootFile(1:indcur-1),'\D');%detect non digit characters |
---|
| 3172 | indcur=max(indices_root); |
---|
| 3173 | field_count=RootFile(indcur+1:ind_end); |
---|
| 3174 | charstring=['%0' num2str(length(field_count)) 'd']; |
---|
| 3175 | nom_type=num2str(1,charstring); |
---|
| 3176 | if strcmp(RootFile(indcur),'_') |
---|
| 3177 | nom_type=['_' nom_type]; |
---|
| 3178 | indcur=indcur-1; |
---|
| 3179 | end |
---|
| 3180 | if (last >= 65 && last <= 90) |
---|
| 3181 | nom_type=[nom_type 'A']; |
---|
| 3182 | else |
---|
| 3183 | nom_type=[nom_type 'a']; |
---|
| 3184 | end |
---|
| 3185 | elseif strcmp(filelit(end-2:end),'-_-_')%new nomenclature appendix num1-num2_num_a-num_b |
---|
| 3186 | field_count=num0; |
---|
| 3187 | str2=num1; |
---|
| 3188 | str_a=num2; |
---|
| 3189 | str_b=num3; |
---|
| 3190 | nom_type='_1-2_1-2'; |
---|
| 3191 | testsub=1; |
---|
| 3192 | indcur=separ0-1; |
---|
| 3193 | elseif strcmp(filelit(end-2:end),'_-_')%new nomenclature appendix num1-num2_num_a |
---|
| 3194 | field_count=num1; |
---|
| 3195 | str2=num2; |
---|
| 3196 | str_a=num3; |
---|
| 3197 | nom_type='_1-2_1'; |
---|
| 3198 | testsub=1; |
---|
| 3199 | indcur=separ1-1; |
---|
| 3200 | elseif strcmp(filelit(end-2:end),'__-')%new nomenclature appendix num1_num2-num2 |
---|
| 3201 | indcur=separ1-1; |
---|
| 3202 | field_count=num1; |
---|
| 3203 | str_a=num2; |
---|
| 3204 | str_b=num3; |
---|
| 3205 | nom_type='_1_1-2'; |
---|
| 3206 | testsub=1; |
---|
| 3207 | elseif strcmp(filelit(end-1:end),'_-') |
---|
| 3208 | indcur=separ2-1; |
---|
| 3209 | field_count=num2; |
---|
| 3210 | str2=num3; |
---|
| 3211 | str_a=''; |
---|
| 3212 | nom_type='_1-2'; |
---|
| 3213 | testsub=1; |
---|
| 3214 | elseif strcmp(filelit(end-1:end),'__') |
---|
| 3215 | indcur=separ2-1; |
---|
| 3216 | field_count=num2; |
---|
| 3217 | str2=''; |
---|
| 3218 | str_a=num3; |
---|
| 3219 | nom_type='_1_1'; |
---|
| 3220 | elseif strcmp(filelit(end),'_') |
---|
| 3221 | indcur=separ3-1; |
---|
| 3222 | str2=''; |
---|
| 3223 | str_a=''; |
---|
| 3224 | %detect zeros before the number |
---|
| 3225 | field_count=RootFile(separ3+1:end);% set the selected field number'%03d' |
---|
| 3226 | charstring=['%0' num2str(length(field_count)) 'd']; |
---|
| 3227 | nom_type=['_' num2str(1,charstring)]; |
---|
| 3228 | elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d |
---|
| 3229 | lasts=RootFile(indcur-1:indcur); |
---|
| 3230 | % if isequal(length(last),2) |
---|
| 3231 | str_a=lasts(1);%put appendix a,b,c, ou d |
---|
| 3232 | str_b=lasts(2);%put appendix a,b,c, ou d |
---|
| 3233 | separ0=indsel(end-3); |
---|
| 3234 | field_count=RootFile(separ0+1:separ1-1); |
---|
| 3235 | indcur=separ0; |
---|
| 3236 | if double(lasts) >= 97 & double(lasts)<= 122 |
---|
| 3237 | nom_type='_ab'; |
---|
| 3238 | testsub=1; |
---|
| 3239 | elseif double(lasts) >= 65 & double(lasts) <= 90 |
---|
| 3240 | nom_type='_AB'; |
---|
| 3241 | testsub=1; |
---|
| 3242 | end |
---|
| 3243 | charstring=['%0' num2str(length(field_count)) 'd']; |
---|
| 3244 | nom_type=[num2str(1,charstring) nom_type]; |
---|
| 3245 | % end |
---|
| 3246 | %search for other names with counter |
---|
| 3247 | else |
---|
| 3248 | if length(ext)>1 |
---|
| 3249 | num=1;count=0; % extract the numerical appendix |
---|
| 3250 | while num==1; |
---|
| 3251 | filascii=double(RootFile(indcur)); |
---|
| 3252 | if (48>filascii)||(filascii>57); % select the non-numerical characters |
---|
| 3253 | num=0; |
---|
| 3254 | else |
---|
| 3255 | indcur=indcur-1; count=count+1; |
---|
| 3256 | end |
---|
| 3257 | end |
---|
| 3258 | if count~=0 |
---|
| 3259 | field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d' |
---|
| 3260 | charstring=['%0' num2str(length(field_count)) 'd']; |
---|
| 3261 | nom_type=num2str(1,charstring); |
---|
| 3262 | end |
---|
| 3263 | end |
---|
| 3264 | end |
---|
| 3265 | %select the root name in the file_input window |
---|
| 3266 | RootFile=RootFile(1:indcur); |
---|
| 3267 | if nbchar<4% put '*' before the name (remove at the end) |
---|
| 3268 | RootFile(1:4-nbchar)=[]; |
---|
| 3269 | end |
---|
| 3270 | if testsub |
---|
| 3271 | [RootPath,subdir,extdir]=fileparts(RootPath); |
---|
| 3272 | subdir=[subdir extdir]; |
---|
| 3273 | end |
---|
| 3274 | |
---|