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