Changeset 309
- Timestamp:
- Nov 30, 2011, 11:09:12 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r308 r309 1 1 %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) 2 2 %------------------------------------------------------------------------ 3 % provides an interface for the software CIVx3 % provides an interface for the software menucivx 4 4 % function varargout = civ(varargin) 5 % provides an interface for the software CIVx5 % provides an interface for the software menucivx 6 6 % 7 7 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 23 23 %TODO: search range 24 24 25 % Last Modified by GUIDE v2.5 21-Nov-2011 10:58:2825 % Last Modified by GUIDE v2.5 30-Nov-2011 21:52:52 26 26 % Begin initialization code - DO NOT EDIT 27 27 gui_Singleton = 1; … … 52 52 handles.output = hObject; 53 53 guidata(hObject, handles); % Update handles structure 54 set(hObject,'WindowButtonDownFcn',{'mouse_down' ,handles}) % allows mouse action with right button (zoom for uicontrol display)54 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 55 55 56 56 %% Adjust the GUI according to the binaries available in PARAM.xml … … 100 100 end 101 101 102 %% input parameters:103 % param104 % filebase=''; % root file name ('filebase'.civ)105 % ext=[];106 % num_i1=1; % set of field i numbers107 % num_i2=1; % set of field i numbers108 % num_j1=1; % set of field j numbers (fields a)109 % num_j2=1; % second set of field j numbers (fields b)110 % %subdir='A'; % subdir for the netcdf result files111 % ind_opening=0; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2)112 % %load the initial parameters if the interface is started from uvmat113 % if exist('param','var')&&isstruct(param)% the interface is opened from uvmat114 % filebase=param.RootName;115 % nom_type_read=param.NomType;116 % num_i1=param.num1;117 % if isnan(num_i1),num_i1=1;end118 % num_i2=param.num2;119 % if isnan(num_i2),num_i2=num_i1;end120 % num_j1=param.num_a;121 % if isnan(num_j1),num_j1=1;end122 % num_j2=param.num_b;123 % if isnan(num_j2),num_j2=num_j1;end124 % subdir=param.SubDir;125 % ind_opening=param.IndOpening;126 % ext=param.ImaExt;127 % end128 % browse.num_i1=num_i1;129 % browse.num_i2=num_i2;130 % browse.num_j1=num_j1;131 % browse.num_j2=num_j2;132 % if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat133 % set(handles.ImaExt,'String',ext)134 % % browse.ext_ima=ext;135 % % if exist('nom_type_read','var')136 % % browse.nom_type_ima=nom_type_read; % the image nomenclature is stored137 % % end138 % % elseif isequal(ext,'.nc')139 % % if exist('nom_type_read','var')140 % % browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored141 % % end142 % end143 % set(handles.RootName,'String',filebase);144 % set(handles.ImaDoc,'String',ext)145 146 147 102 %% prepare the GUI with parameters from the input file if opened from uvmat 148 103 if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName) … … 153 108 end 154 109 155 % %initiate advised operations156 % enable_civ1(handles,0)157 % enable_civ2(handles,0)158 % %enable_pair1(handles,'on')159 % enable_fix1(handles,0)160 % enable_patch1(handles,0)161 % enable_fix2(handles,0)162 % enable_patch2(handles,0)163 % set(handles.CheckCiv1,'Value',0)164 % set(handles.CheckFix1,'Value',0)165 % set(handles.CheckPatch1,'Value',0)166 % set(handles.CheckCiv2,'Value',0)167 % set(handles.CheckFix2,'Value',0)168 % set(handles.CheckPatch2,'Value',0)169 %170 % if isequal(ind_opening,1)171 % set(handles.CheckCiv1,'Value',1)172 % enable_civ1(handles,1)173 % elseif isequal(ind_opening,2)174 % set(handles.CheckFix1,'Value',1)175 % enable_fix1(handles,1)176 % elseif isequal(ind_opening,3)177 % set(handles.CheckPatch1,'Value',1)178 % enable_patch1(handles,1)179 % elseif isequal(ind_opening,4)180 % set(handles.CheckCiv2,'Value',1)181 % enable_civ2(handles,1)182 % elseif isequal(ind_opening,5)183 % set(handles.CheckFix2,'Value',1)184 % enable_fix2(handles,1)185 % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])186 % set(handles.ListPairCiv2,'Enable','On')187 % set(handles.ListPairCiv2,'Enable','On')188 % enable_pair1(handles,'off')189 % elseif isequal(ind_opening,6)190 % set(handles.CheckPatch2,'Value',1)191 % enable_patch2(handles,1)192 % set(handles.ListPairCiv2,'Enable','On')193 % enable_pair1(handles,'off')194 % end195 %196 % % set the range of fields (1:1 by default) and selected pair197 % if isequal(num_i2,num_i1)198 % num_ref_i=num_i1;199 % else200 % num_ref_i=floor((num_i1+num_i2)/2);201 % browse.incr_pair(1)=num_i2-num_i1;202 % browse.incr_pair(2)=0;203 % end204 % if isequal(num_j1,num_j2)205 % if isnan(num_j1)206 % num_ref_j=1;207 % else208 % num_ref_j=num_j1;209 % end210 % else211 % num_ref_j=floor((num_j1+num_j2)/2);212 % browse.incr_pair(2)=num_j2-num_j1;213 % end214 % set(handles.first_i,'String',num2str(num_ref_i));215 % set(handles.last_i,'String',num2str(num_ref_i));216 % set(handles.first_j,'String',num2str(num_ref_j));217 % set(handles.last_j,'String',num2str(num_ref_j));218 % set(handles.ref_i,'String',num2str(num_ref_i));219 % set(handles.ref_j,'String',num2str(num_ref_j));220 % set(handles.RootName,'UserData',browse);221 222 110 %------------------------------------------------------------------------ 223 111 % --- Outputs from this function are returned to the command line. … … 228 116 229 117 %------------------------------------------------------------------------ 230 % --- function activated by the Open/Browse... option in the upper menu bar.118 % --- Function activated by the Open/Browse... option in the upper menu bar. 231 119 function MenuBrowse_Callback(hObject, eventdata, handles) 232 120 %------------------------------------------------------------------------ … … 234 122 filebase=get(handles.RootName,'String'); 235 123 oldfile=''; %default 236 if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name 124 if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name 237 125 dir_perso=prefdir; 238 126 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); … … 252 140 browse.incr_pair=[0 0]; %default 253 141 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 254 255 256 257 258 259 260 261 142 '*.xml', '.xml files '; ... 143 '*.civ', '.civ files '; ... 144 '*.png','.png image files'; ... 145 '*.jpg',' jpeg image files'; ... 146 '*.tif','.tif image files'; ... 147 '*.avi;*.AVI','.avi movie files'; ... 148 '*.nc','.netcdf files'; ... 149 '*.*', 'All Files (*.*)'}; 262 150 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); 263 151 fileinput=[PathName FileName];%complete file name … … 267 155 %% prepare the GUI with parameters from the input file if opened from uvmat 268 156 errormsg=display_file_name(handles,fileinput); 269 if ~isempty(errormsg) 270 msgbox_uvmat('ERROR',erromsg) 271 end 272 157 if ~isempty(errormsg) 158 msgbox_uvmat('ERROR',erromsg) 159 end 273 160 274 161 [path,name,ext]=fileparts(fileinput); … … 297 184 end 298 185 [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); 299 filebase=fullfile(RootPath,RootFile);186 % filebase=fullfile(RootPath,RootFile); 300 187 num_i1=str2double(str1); 301 188 if isnan(num_i1),num_i1=1;end … … 323 210 324 211 set(handles.RootName,'UserData',browse);% store information from browser 325 RootName_Callback(hObject, eventdata, handles); 326 327 % ----------------------------------------------------------------------- 212 213 %------------------------------------------------------------------------ 328 214 % --- Open again the file whose name has been recorded in MenuFile_1 329 215 function MenuFile_1_Callback(hObject, eventdata, handles) … … 344 230 msgbox_uvmat('ERROR',erromsg) 345 231 end 232 346 233 % ----------------------------------------------------------------------- 347 234 % --- Open again the file whose name has been recorded in MenuFile_3 … … 353 240 msgbox_uvmat('ERROR',erromsg) 354 241 end 242 355 243 % ----------------------------------------------------------------------- 356 244 % --- Open again the file whose name has been recorded in MenuFile_4 … … 362 250 msgbox_uvmat('ERROR',erromsg) 363 251 end 252 364 253 % ----------------------------------------------------------------------- 365 254 % --- Open again the file whose name has been recorded in MenuFile_5 … … 371 260 msgbox_uvmat('ERROR',erromsg) 372 261 end 373 % %------------------------------------------------------------------------ 374 % function ImaDoc_Callback(hObject, eventdata, handles) 375 % %------------------------------------------------------------------------ 376 % RootName_Callback(hObject, eventdata, handles) 377 378 %------------------------------------------------------------------------ 379 % --- function activated when a new filebase (image series) is introduced 262 263 % ----------------------------------------------------------------------- 264 % --- Prepare the GUI for the compiled CivX program 265 function MenuCivX_Callback(hObject, eventdata, handles) 266 set(handles.MenuMatlab,'checked','off') 267 set(handles.MenuCivX,'checked','on') 268 %set(handles.thresh_patch1,'Visible','off') 269 % set(handles.thresh_text1,'Visible','off') 270 % set(handles.num_MaxDiff,'Visible','off') 271 % set(handles.thresh_text2,'Visible','off') 272 set(handles.num_Rho,'Style','edit') 273 set(handles.num_Rho,'String','1') 274 set(handles.BATCH,'Enable','on') 275 % ----------------------------------------------------------------------- 276 277 % ----------------------------------------------------------------------- 278 % --- Prepare the GUI for the Matlab PIV program 279 function MenuMatlab_Callback(hObject, eventdata, handles) 280 % ----------------------------------------------------------------------- 281 set(handles.MenuMatlab,'checked','on') 282 set(handles.MenuCivX,'checked','off') 283 if get(handles.CheckPatch1,'Value') 284 set(handles.thresh_patch1,'Visible','on') 285 set(handles.thresh_text1,'Visible','on') 286 end 287 if get(handles.CheckPatch2,'Value') 288 set(handles.num_MaxDiff,'Visible','on') 289 set(handles.thresh_text2,'Visible','on') 290 end 291 set(handles.num_Rho,'Style','popupmenu') 292 set(handles.num_Rho,'Value',1) 293 set(handles.num_Rho,'String',{'1';'2'}) 294 set(handles.BATCH,'Enable','off') 295 296 % ----------------------------------------------------------------------- 297 % --- Open the help html file 298 function MenuHelp_Callback(hObject, eventdata, handles) 299 % ----------------------------------------------------------------------- 300 path_civ=fileparts(which ('civ')); 301 helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); 302 if isempty(dir(helpfile)) 303 msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 304 else 305 addpath (fullfile(path_civ,'uvmat_doc')) 306 web([helpfile '#civ']) 307 end 308 309 %------------------------------------------------------------------------ 310 % --- Function activated when a new filebase (image series) is introduced 380 311 function RootName_Callback(hObject, eventdata, handles) 381 312 %------------------------------------------------------------------------ … … 385 316 msgbox_uvmat('ERROR',erromsg) 386 317 end 387 %------------------------------------------------------------------------ 318 319 %------------------------------------------------------------------------ 320 % --- general function activated for an input file series 388 321 function errormsg=display_file_name(handles,fileinput) 389 322 %------------------------------------------------------------------------ … … 408 341 RootName=fullfile(RootPath,FileName); 409 342 set(handles.RootName,'String',RootName) 343 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 410 344 num_i1=str2double(i1_str); 411 345 num_i2=str2double(i2_str); … … 477 411 end 478 412 479 % ext_imadoc=get(handles.ImaDoc,'String');480 % browse=get(handles.RootName,'UserData');%default481 % if isfield(browse,'nom_type_ima')482 % nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name483 % end484 % if isfield(browse,'ext_ima')485 % ext_ima=browse.ext_ima;486 % end487 % if isfield(browse,'nom_type_nc')488 % nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name489 % end490 % if isfield(browse,'num_i1')491 % field_count=browse.num_i1;% get an image index type already determined by an input file492 % end493 %set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS)494 495 496 413 %% look for an image documentation file 497 414 ext_imadoc='';%default … … 517 434 pxcmx_search=[];%default 518 435 pxcmy_search=[];%default 519 % first_i=1;%default520 % last_i=1;%default521 436 if isequal(ext_imadoc,'.civxml')%TO ABANDON 522 437 [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']); … … 592 507 %% timing display 593 508 %show the reference image edit box if relevant (not needed for movies or in the absence of time information 594 % if isempty(time)|| strcmp(nom_type_ima,'*')||strcmp(nom_type_ima,'')595 % % set(handles.ref_i,'Visible','Off')% do not use a reference index to display time intervals596 % % set(handles.ref_j,'Visible','Off')597 % first_i=1;598 % last_i=1;599 % else600 % % set(handles.ref_i,'Visible','On')%use a reference index601 % % set(handles.ref_j,'Visible','On')602 % set(handles.ref_i,'String',i1_str)603 % set(handles.ref_j,'String',j1_str)604 % end605 509 if ~isempty(time) 606 510 if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt … … 723 627 end 724 628 end 725 726 %------------------------------------------------------------------------ 727 % --- Executes on button press in ListPairMode. 728 function ListPairMode_Callback(hObject, eventdata, handles) 729 %------------------------------------------------------------------------ 730 % browse=get(handles.RootName,'UserData'); 731 compare_list=get(handles.ListCompareMode,'String'); 732 val=get(handles.ListCompareMode,'Value'); 733 compare=compare_list{val}; 734 if strcmp(compare,'displacement') 735 mode='displacement'; 736 else 737 mode_list=get(handles.ListPairMode,'String'); 738 if ischar(mode_list) 739 mode_list={mode_list}; 740 end 741 mode_value=get(handles.ListPairMode,'Value'); 742 mode=mode_list{mode_value}; 743 end 744 displ_num=[];%default 745 ref_i=str2double(get(handles.ref_i,'String')); 746 % last_i=str2num(get(handles.last_i,'String')); 747 time=get(handles.ImaDoc,'UserData'); %get the set of times 748 siztime=size(time); 749 nbfield=siztime(1); 750 nbfield2=siztime(2); 751 indchosen=1; %%first pair selected by default 752 %displ_num used to define the indices of the civ pairs 753 % displ_num(1,:)=indices j1 754 % displ_num(2,:)=indices j2 755 % displ_num(3,:)=indices i1 756 % displ_num(4,:)=indices i2 757 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices 758 % are relative to the reference indices ref_i and ref_j respectively. 759 if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') 760 dt=1; 761 displ=''; 762 index=0; 763 numlist_a=[]; 764 numlist_B=[]; 765 %get all the time intervals in bursts 766 displ_dt=1;%default 767 nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 768 for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode 769 for numod_b=(numod_a+1):nbfield2 770 index=index+1; 771 numlist_a(index)=numod_a; 772 numlist_b(index)=numod_b; 773 if ~isempty(time) 774 dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt 775 displ_dt(index)=dt(numod_a,numod_b); 776 else 777 displ_dt(index)=1; 778 end 779 end 780 end 781 [dtsort,indsort]=sort(displ_dt); 782 if ~isempty(numlist_a) 783 displ_num(1,:)=numlist_a(indsort); 784 displ_num(2,:)=numlist_b(indsort); 785 end 786 displ_num(3,:)=0; 787 displ_num(4,:)=0; 788 set(handles.jtext,'Visible','Off') 789 set(handles.first_j,'Visible','Off') 790 set(handles.last_j,'Visible','Off') 791 set(handles.incr_j,'Visible','Off') 792 set(handles.nb_field2,'Visible','Off') 793 set(handles.ref_j,'Visible','Off') 794 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') 795 index=1:200; 796 displ_num(1,index)=-floor(index/2); 797 displ_num(2,index)=ceil(index/2); 798 displ_num(3:4,index)=zeros(2,200); 799 % for index=1:min(nbfield2-1,200) 800 % displ_num(1,index)=-floor(index/2); 801 % displ_num(2,index)=ceil(index/2); 802 % displ_num(3,index)=0; 803 % displ_num(4,index)=0; 804 % end 805 set(handles.jtext,'Visible','On') 806 set(handles.first_j,'Visible','On') 807 set(handles.last_j,'Visible','On') 808 set(handles.incr_j,'Visible','On') 809 set(handles.nb_field2,'Visible','On') 810 set(handles.ref_j,'Visible','On') 811 if nbfield > 1 812 set(handles.itext,'Visible','On') 813 set(handles.first_i,'Visible','On') 814 set(handles.last_i,'Visible','On') 815 set(handles.incr_i,'Visible','On') 816 set(handles.nb_field,'Visible','On') 817 set(handles.ref_i,'Visible','On') 629 set(handles.RootName,'BackgroundColor',[1 1 1]) 630 631 %------------------------------------------------------------------------ 632 % --- Executes on carriage return on the subdir checkciv1 edit window 633 function txt_SubdirCiv1_Callback(hObject, eventdata, handles) 634 %------------------------------------------------------------------------ 635 subdir=get(handles.txt_SubdirCiv1,'String'); 636 menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update 637 ichoice=find(strcmp(subdir,menu_str),1); 638 if isempty(ichoice) 639 ilist=numel(menu_str); %select 'new...' in the menu 640 else 641 ilist=ichoice; 642 end 643 set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu 644 if get(handles.CheckCiv1,'Value')% if Civ1 is performed 645 set(handles.txt_SubdirCiv2,'String',subdir);% set by default civ2 directory the same as civ1 646 set(handles.ListSubdirCiv2,'Value',ilist) 647 else % if Civ1 data already exist 648 find_netcpair_civ1(handles); %update the list of available pairs from netcdf files in the new directory 649 end 650 651 %------------------------------------------------------------------------ 652 % --- Executes on carriage return on the subdir checkciv1 edit window 653 function txt_SubdirCiv2_Callback(hObject, eventdata, handles) 654 %------------------------------------------------------------------------ 655 subdir=get(handles.txt_SubdirCiv1,'String'); 656 menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update 657 ichoice=find(strcmp(subdir,menu_str),1); 658 if isempty(ichoice) 659 ilist=numel(menu_str); %select 'new...' in the menu 660 else 661 ilist=ichoice; 662 end 663 set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu 664 %update the list of available pairs from netcdf files in the new directory 665 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 666 find_netcpair_civ2(handles); 667 end 668 669 %------------------------------------------------------------------------ 670 % --- Executes on button press in CheckCiv1. 671 function CheckCiv1_Callback(hObject, eventdata, handles) 672 %------------------------------------------------------------------------ 673 update_CivOptions(handles) 674 675 %------------------------------------------------------------------------ 676 % --- Executes on button press in CheckFix1. 677 function CheckFix1_Callback(hObject, eventdata, handles) 678 %------------------------------------------------------------------------ 679 update_CivOptions(handles) 680 681 %------------------------------------------------------------------------ 682 % --- Executes on button press in CheckPatch1. 683 function CheckPatch1_Callback(hObject, eventdata, handles) 684 %------------------------------------------------------------------------ 685 update_CivOptions(handles) 686 687 %------------------------------------------------------------------------ 688 % --- Executes on button press in CheckCiv2. 689 function CheckCiv2_Callback(hObject, eventdata, handles) 690 %------------------------------------------------------------------------ 691 update_CivOptions(handles) 692 693 %------------------------------------------------------------------------ 694 % --- Executes on button press in CheckFix2. 695 function CheckFix2_Callback(hObject, eventdata, handles) 696 %------------------------------------------------------------------------ 697 update_CivOptions(handles) 698 699 %------------------------------------------------------------------------ 700 % --- Executes on button press in CheckPatch2. 701 function CheckPatch2_Callback(hObject, eventdata, handles) 702 %------------------------------------------------------------------------ 703 update_CivOptions(handles) 704 705 %------------------------------------------------------------------------ 706 % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 707 function update_CivOptions(handles) 708 %------------------------------------------------------------------------ 709 checkbox=zeros(1,6); 710 checkbox(1)=get(handles.CheckCiv1,'Value'); 711 checkbox(2)=get(handles.CheckFix1,'Value'); 712 checkbox(3)=get(handles.CheckPatch1,'Value'); 713 checkbox(4)=get(handles.CheckCiv2,'Value'); 714 checkbox(5)=get(handles.CheckFix2,'Value'); 715 checkbox(6)=get(handles.CheckPatch2,'Value'); 716 ind_selected=find(checkbox,1); 717 if ~isempty(ind_selected) 718 RootName=get(handles.RootName,'String'); 719 if isempty(RootName) 720 msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...') 721 return 722 end 723 end 724 set(handles.PairIndices,'Visible','on') 725 set(handles.txt_SubdirCiv1,'Visible','on') 726 set(handles.ListSubdirCiv1,'Visible','on') 727 find_netcpair_civ1(handles) % select the available netcdf files 728 if max(checkbox(4:6))% case of civ2 pair choice needed 729 set(handles.TitlePairCiv2,'Visible','on') 730 set(handles.TitleSubdirCiv2,'Visible','on') 731 set(handles.txt_SubdirCiv2,'Visible','on') 732 set(handles.ListSubdirCiv2,'Visible','on') 733 set(handles.ListPairCiv2,'Visible','on') 734 find_netcpair_civ2(handles) % select the available netcdf files 735 else 736 set(handles.TitleSubdirCiv2,'Visible','off') 737 set(handles.txt_SubdirCiv2,'Visible','off') 738 set(handles.ListSubdirCiv2,'Visible','off') 739 set(handles.ListPairCiv2,'Visible','off') 740 end 741 options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; 742 for ilist=1:length(options) 743 if checkbox(ilist) 744 set(handles.(options{ilist}),'Visible','on') 818 745 else 819 set(handles.itext,'Visible','Off') 820 set(handles.first_i,'Visible','Off') 821 set(handles.last_i,'Visible','Off') 822 set(handles.incr_i,'Visible','Off') 823 set(handles.nb_field,'Visible','Off') 824 set(handles.ref_i,'Visible','Off') 825 end 826 elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') 827 index=1:200; 828 displ_num(1:2,index)=zeros(2,200); 829 displ_num(3,index)=-floor(index/2); 830 displ_num(4,index)=ceil(index/2); 831 % for index=1:200%min(nbfield-1,200) 832 % displ_num(1,index)=0; 833 % displ_num(2,index)=0; 834 % displ_num(3,index)=-floor(index/2); 835 % displ_num(4,index)=ceil(index/2); 836 % end 837 set(handles.itext,'Visible','On') 838 set(handles.first_i,'Visible','On') 839 set(handles.last_i,'Visible','On') 840 set(handles.incr_i,'Visible','On') 841 set(handles.nb_field,'Visible','On') 842 set(handles.ref_i,'Visible','On') 843 if nbfield2 > 1 844 set(handles.jtext,'Visible','On') 845 set(handles.first_j,'Visible','On') 846 set(handles.last_j,'Visible','On') 847 set(handles.incr_j,'Visible','On') 848 set(handles.nb_field2,'Visible','On') 849 set(handles.ref_j,'Visible','On') 850 else 851 set(handles.jtext,'Visible','Off') 852 set(handles.first_j,'Visible','Off') 853 set(handles.last_j,'Visible','Off') 854 set(handles.incr_j,'Visible','Off') 855 set(handles.nb_field2,'Visible','Off') 856 set(handles.ref_j,'Visible','Off') 857 end 858 elseif isequal(mode,'displacement')%the pairs have the same indices 859 displ_num(1,1)=0; 860 displ_num(2,1)=0; 861 displ_num(3,1)=0; 862 displ_num(4,1)=0; 863 if nbfield > 1 864 set(handles.itext,'Visible','On') 865 set(handles.first_i,'Visible','On') 866 set(handles.last_i,'Visible','On') 867 set(handles.incr_i,'Visible','On') 868 set(handles.nb_field,'Visible','On') 869 set(handles.ref_i,'Visible','On') 870 else 871 set(handles.itext,'Visible','Off') 872 set(handles.first_i,'Visible','Off') 873 set(handles.last_i,'Visible','Off') 874 set(handles.incr_i,'Visible','Off') 875 set(handles.nb_field,'Visible','Off') 876 set(handles.ref_i,'Visible','Off') 877 end 878 if nbfield2 > 1 879 set(handles.jtext,'Visible','On') 880 set(handles.first_j,'Visible','On') 881 set(handles.last_j,'Visible','On') 882 set(handles.incr_j,'Visible','On') 883 set(handles.nb_field2,'Visible','On') 884 set(handles.ref_j,'Visible','On') 885 else 886 set(handles.jtext,'Visible','Off') 887 set(handles.first_j,'Visible','Off') 888 set(handles.last_j,'Visible','Off') 889 set(handles.incr_j,'Visible','Off') 890 set(handles.nb_field2,'Visible','Off') 891 set(handles.ref_j,'Visible','Off') 892 end 893 end 894 set(handles.ListPairCiv1,'UserData',displ_num); 895 find_netcpair_civ1( handles) 896 find_netcpair_civ2(handles) 897 898 %------------------------------------------------------------------------ 899 % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of 900 % the field series set by first_i, incr, last_i 901 function find_netcpair_civ1(handles) 902 %------------------------------------------------------------------------ 903 set(gcf,'Pointer','watch') 904 %nomenclature types 905 filebase=get(handles.RootName,'String'); 906 [filepath,Nme,ext_dir]=fileparts(filebase); 907 browse=get(handles.RootName,'UserData'); 908 compare_list=get(handles.ListCompareMode,'String'); 909 val=get(handles.ListCompareMode,'Value'); 910 compare=compare_list{val}; 911 if strcmp(compare,'displacement') 912 mode='displacement'; 913 else 914 mode_list=get(handles.ListPairMode,'String'); 915 mode_value=get(handles.ListPairMode,'Value'); 916 if isempty(mode_list) 917 return 918 end 919 mode=mode_list{mode_value}; 920 end 921 922 % nomenclature type of the .nc files 923 nom_type_ima=[];%default 924 if isfield(browse,'nom_type_ima') 925 nom_type_ima=browse.nom_type_ima; 926 end 927 928 %determine nom_type_nc: 929 nom_type_nc=[];%default 930 if isfield(browse,'nom_type_nc') 931 nom_type_nc=browse.nom_type_nc; 932 end 933 if isempty(nom_type_nc) 934 [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); 935 end 936 browse.nom_type_nc=nom_type_nc; 937 set(handles.RootName,'UserData',browse) 938 939 %reads .nc subdirectoy and image numbers from the interface 940 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 941 ref_i=str2double(get(handles.ref_i,'String')); 942 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 943 ref_j=0; 944 else 945 ref_j=str2double(get(handles.ref_j,'String')); 946 end 947 time=get(handles.ImaDoc,'UserData');%get the set of times 948 if isempty(time) 949 time=[0 1]; 950 end 951 dt_unit=1000;%default 952 displ_num=get(handles.ListPairCiv1,'UserData'); 953 954 %eliminate the first pairs inconsistent with the position 955 if isempty(displ_num) 956 nbpair=0; 957 else 958 nbpair=length(displ_num(1,:));%nbre of displayed pairs 959 if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') 960 nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 961 elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 962 nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 963 end 964 end 965 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 966 967 %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not 968 % be performed, while the result is needed for next steps. 969 displ_pair={''}; 970 select=ones(size(1:nbpair));%flag for displayed pairs =1 for display 971 testpair=0; 972 973 %% case with no Civ1 operation, netcdf files need to exist for reading 974 if ~get(handles.CheckCiv1,'Value') % 975 if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') 976 msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); 977 set(handles.ListPairCiv1,'String',{}); 978 return 979 end 980 for ipair=1:nbpair 981 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 982 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); 983 select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist 984 end 985 % case of no displayed pair 986 if isequal(select,zeros(size(1:nbpair))) 987 if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) 988 num_i1=ref_i-floor(browse.incr_pair(1)/2); 989 num_i2=ref_i+ceil(browse.incr_pair(1)/2); 990 num_j1=ref_j-floor(browse.incr_pair(2)/2); 991 num_j2=ref_j+ceil(browse.incr_pair(2)/2); 992 filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); 993 select(1)=exist(filename,'file')==2; 994 testpair=1; 995 else 996 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 997 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); 998 else 999 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); 1000 end 1001 set(handles.ListPairCiv1,'String',{''}); 1002 %COMPLETER CAS STEREO 1003 return 1004 end 1005 end 1006 end 1007 1008 %% determine the menu display in .ListPairCiv1 1009 % the menu depends on the mode defined in ListPairMode_callback through the array displ_num: 1010 % displ_num(1,:)=indices j1 1011 % displ_num(2,:)=indices j2 1012 % displ_num(3,:)=indices i1 1013 % displ_num(4,:)=indices i2 1014 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices 1015 % are relative to the reference indices ref_i and ref_j respectively. 1016 if isequal(mode,'series(Di)') 1017 if testpair 1018 displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; 1019 else 1020 for ipair=1:nbpair 1021 if select(ipair) 1022 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 1023 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 1024 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 1025 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1026 end 1027 else 1028 displ_pair{ipair}='...'; %pair not displayed in the menu 1029 end 1030 end 1031 end 1032 elseif isequal(mode,'series(Dj)') 1033 if testpair 1034 displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; 1035 else 1036 for ipair=1:nbpair 1037 if select(ipair) 1038 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 1039 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 1040 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 1041 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1042 end 1043 else 1044 displ_pair{ipair}='...'; %pair not displayed in the menu 1045 end 1046 end 1047 end 1048 elseif isequal(mode,'pair j1-j2')%case of pairs 1049 for ipair=1:nbpair 1050 if select(ipair) 1051 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 1052 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 1053 ' :dt= ' num2str(dt*1000)]; 1054 else 1055 displ_pair{ipair}='...'; %pair not displayed in the menu 1056 end 1057 end 1058 elseif isequal(mode,'displacement') 1059 displ_pair={'Di=Dj=0'}; 1060 end 1061 set(handles.ListPairCiv1,'String',displ_pair'); 1062 1063 %% determine the default selection in the pair menu 1064 ichoice=find(select,1);% index of selected pair 1065 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 1066 initial=get(handles.ListPairCiv1,'Value');%initial choice of pair 1067 if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) 1068 set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu 1069 end 1070 initial=get(handles.ListPairCiv2,'Value'); 1071 if initial>length(displ_pair')%|~isequal(select(initial),1) 1072 if ichoice <= length(displ_pair') 1073 set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 1074 else 1075 set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 1076 end 1077 end 1078 set(handles.ListPairCiv2,'String',displ_pair'); 1079 set(gcf,'Pointer','arrow') 1080 1081 %------------------------------------------------------------------------ 1082 % determine the menu for checkciv2 pairs depending on the existing netcdf file at the 1083 %middle of the series set by first_i, incr, last_i 1084 function find_netcpair_civ2(handles) 1085 %------------------------------------------------------------------------ 1086 set(gcf,'Pointer','watch') 1087 %nomenclature types 1088 filebase=get(handles.RootName,'String'); 1089 [filepath,Nme,ext_dir]=fileparts(filebase); 1090 browse=get(handles.RootName,'UserData'); 1091 compare_list=get(handles.ListCompareMode,'String'); 1092 val=get(handles.ListCompareMode,'Value'); 1093 compare=compare_list{val}; 1094 if strcmp(compare,'displacement') 1095 mode='displacement'; 1096 else 1097 mode_list=get(handles.ListPairMode,'String'); 1098 if isempty(mode_list) 1099 msgbox_uvmat('ERROR','please enter an input image or netcdf file') 1100 return 1101 end 1102 mode_value=get(handles.ListPairMode,'Value'); 1103 mode=mode_list{mode_value}; 1104 end 1105 1106 % nomenclature type of the .nc files 1107 nom_type_ima='ima_num';%default 1108 if isfield(browse,'nom_type_ima') 1109 nom_type_ima=browse.nom_type_ima; 1110 end 1111 nom_type_nc='_i1-i2';%default 1112 if isfield(browse,'nom_type_nc') 1113 nom_type_nc=browse.nom_type_nc; 1114 end 1115 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') 1116 nom_type_nc='netc_old';%nom_type for the netcdf files 1117 elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') 1118 nom_type_nc='none'; 1119 elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') 1120 nom_type_nc='_i1-i2'; 1121 else 1122 if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') 1123 nom_type_nc='_i1-i2_j'; % PIV in volume 1124 else 1125 nom_type_nc='_i_j1-j2'; 1126 end 1127 end 1128 browse.nom_type_nc=nom_type_nc; 1129 set(handles.RootName,'UserData',browse) 1130 1131 %reads .nc subdirectory and image numbers from the interface 1132 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 1133 subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 1134 ref_i=str2double(get(handles.ref_i,'String')); 1135 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 1136 ref_j=0; 1137 else 1138 ref_j=str2double(get(handles.ref_j,'String')); 1139 end 1140 time=get(handles.ImaDoc,'UserData'); %get the set of times 1141 if isempty(time) 1142 time=[0 1];%default 1143 end 1144 displ_num=get(handles.ListPairCiv1,'UserData'); 1145 1146 %eliminate the first pairs inconsistent with the position 1147 if isempty(displ_num) 1148 nbpair=0; 1149 else 1150 nbpair=length(displ_num(1,:));%nbre of displayed pairs 1151 if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') 1152 nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 1153 elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 1154 nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 1155 end 1156 end 1157 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 1158 1159 %% look for existing processed pairs at the reference indices if Civ1 will not 1160 % be performed, while the result is needed for next steps. 1161 displ_pair={''}; %default 1162 select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs 1163 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 1164 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 1165 errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) 1166 set(handles.ListPairCiv2,'Value',1); 1167 set(handles.ListPairCiv2,'String',{''}); 1168 return 1169 end 1170 for ipair=1:nbpair 1171 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 1172 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); 1173 select(ipair)=exist(filename,'file')==2; 1174 end 1175 if isequal(select,zeros(size(1:nbpair))) 1176 if isfield(browse,'incr_pair') 1177 num_i1=ref_i-floor(browse.incr_pair(1)/2); 1178 num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); 1179 num_j1=ref_j-floor(browse.incr_pair(2)/2); 1180 num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); 1181 filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); 1182 select(1)=exist(filename,'file')==2; 1183 else 1184 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 1185 errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) 1186 else 1187 errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) 1188 end 1189 set(handles.ListPairCiv2,'Value',1); 1190 set(handles.ListPairCiv2,'String',{''}); 1191 return 1192 end 1193 end 1194 end 1195 if isequal(mode,'series(Di)') 1196 for ipair=1:nbpair 1197 if select(ipair) 1198 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 1199 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 1200 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 1201 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1202 end 1203 else 1204 displ_pair{ipair}='...'; %pair not displayed in the menu 1205 end 1206 end 1207 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index 1208 for ipair=1:nbpair 1209 if select(ipair) 1210 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 1211 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 1212 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 1213 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1214 end 1215 else 1216 displ_pair{ipair}='...'; %pair not displayed in the menu 1217 end 1218 end 1219 elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs 1220 for ipair=1:nbpair 1221 if select(ipair) 1222 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 1223 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 1224 ' :dt= ' num2str(dt*1000)]; 1225 else 1226 displ_pair{ipair}='...'; %pair not displayed in the menu 1227 end 1228 end 1229 elseif isequal(mode,'displacement') 1230 displ_pair={'Di=Dj=0'}; 1231 end 1232 val=get(handles.ListPairCiv2,'Value'); 1233 ichoice=find(select,1); 1234 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 1235 if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 1236 val=ichoice;% first valid pair proposed by default in the menu 1237 end 1238 if val>length(displ_pair') 1239 set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu 1240 else 1241 set(handles.ListPairCiv2,'Value',val); 1242 end 1243 set(handles.ListPairCiv2,'String',displ_pair'); 1244 set(gcf,'Pointer','arrow') 1245 1246 1247 1248 1249 %------------------------------------------------------------------------ 1250 % --- Executes on selection change in ListPairCiv1. 1251 function ListPairCiv1_Callback(hObject, eventdata, handles) 1252 %------------------------------------------------------------------------ 1253 %reproduce by default the chosen pair in the checkciv2 menu 1254 list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs 1255 index_pair=get(handles.ListPairCiv1,'Value'); 1256 displ_num=get(handles.ListPairCiv1,'UserData'); 1257 % num_a=displ_num(1,index_pair); 1258 % num_b=displ_num(2,index_pair); 1259 list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs 1260 if index_pair<=length(list_pair2) 1261 set(handles.ListPairCiv2,'Value',index_pair); 1262 end 1263 1264 %update first_i and last_i according to the chosen image pairs 1265 mode_list=get(handles.ListPairMode,'String'); 1266 mode_value=get(handles.ListPairMode,'Value'); 1267 mode=mode_list{mode_value}; 1268 if isequal(mode,'series(Di)') 1269 first_i=str2double(get(handles.first_i,'String')); 1270 last_i=str2double(get(handles.last_i,'String')); 1271 incr_i=str2double(get(handles.incr_i,'String')); 1272 num1=first_i:incr_i:last_i; 1273 lastfield=str2double(get(handles.nb_field,'String')); 1274 if ~isnan(lastfield) 1275 test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... 1276 (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); 1277 num1=num1(test_find); 1278 end 1279 set(handles.first_i,'String',num2str(num1(1))); 1280 set(handles.last_i,'String',num2str(num1(end))); 1281 elseif isequal(mode,'series(Dj)') 1282 first_j=str2double(get(handles.first_j,'String')); 1283 last_j=str2double(get(handles.last_j,'String')); 1284 incr_j=str2double(get(handles.incr_j,'String')); 1285 num_j=first_j:incr_j:last_j; 1286 lastfield2=str2double(get(handles.nb_field2,'String')); 1287 if ~isnan(lastfield2) 1288 test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... 1289 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); 1290 num1=num_j(test_find); 1291 end 1292 set(handles.first_j,'String',num2str(num1(1))); 1293 set(handles.last_j,'String',num2str(num1(end))); 1294 end 1295 1296 %------------------------------------------------------------------------ 1297 % --- Executes on selection change in ListPairCiv2. 1298 function ListPairCiv2_Callback(hObject, eventdata, handles) 1299 %------------------------------------------------------------------------ 1300 index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu 1301 1302 %update first_i and last_i according to the chosen image pairs 1303 mode_list=get(handles.ListPairMode,'String'); 1304 mode_value=get(handles.ListPairMode,'Value'); 1305 mode=mode_list{mode_value}; 1306 if isequal(mode,'series(Di)') 1307 first_i=str2double(get(handles.first_i,'String')); 1308 last_i=str2double(get(handles.last_i,'String')); 1309 incr_i=str2double(get(handles.incr_i,'String')); 1310 num1=first_i:incr_i:last_i; 1311 lastfield=str2double(get(handles.nb_field,'String')); 1312 if ~isnan(lastfield) 1313 test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... 1314 (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); 1315 num1=num1(test_find); 1316 end 1317 set(handles.first_i,'String',num2str(num1(1))); 1318 set(handles.last_i,'String',num2str(num1(end))); 1319 elseif isequal(mode,'series(Dj)') 1320 first_j=str2double(get(handles.first_j,'String')); 1321 last_j=str2double(get(handles.last_j,'String')); 1322 incr_j=str2double(get(handles.incr_j,'String')); 1323 num_j=first_j:incr_j:last_j; 1324 lastfield2=str2double(get(handles.nb_field2,'String')); 1325 if ~isnan(lastfield2) 1326 test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... 1327 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); 1328 num1=num_j(test_find); 1329 end 1330 set(handles.first_j,'String',num2str(num1(1))); 1331 set(handles.last_j,'String',num2str(num1(end))); 746 set(handles.(options{ilist}),'Visible','off') 747 end 1332 748 end 1333 749 … … 1372 788 end 1373 789 1374 %------------------------------------------------------------------------ 1375 % --- Lauch command called by RUN and BATCH: remote processing 790 %------------------------------------------------------------------- 791 % --- Executes on button press in status. 792 function status_Callback(hObject, eventdata, handles) 793 %------------------------------------------------------------------- 794 val=get(handles.status,'Value'); 795 if val==0 796 set(handles.status,'BackgroundColor',[0 1 0]) 797 hfig=findobj(allchild(0),'name','civ_status'); 798 if ~isempty(hfig) 799 delete(hfig) 800 end 801 return 802 end 803 set(handles.status,'BackgroundColor',[1 1 0]) 804 drawnow 805 listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; 806 Param.CheckCiv1=get(handles.CheckCiv1,'Value'); 807 Param.CheckFix1=get(handles.CheckFix1,'Value'); 808 Param.CheckPatch1=get(handles.CheckPatch1,'Value'); 809 Param.CheckCiv2=get(handles.CheckCiv2,'Value'); 810 Param.CheckFix2=get(handles.CheckFix2,'Value'); 811 Param.CheckPatch2=get(handles.CheckPatch2,'Value'); 812 box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; 813 814 option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) 815 filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV 816 test_new=0; 817 if ~isfield(filecell,'nc') 818 test_new=1; 819 [ref_i,ref_j,errormsg]=find_ref_indices(handles); 820 if ~isempty(errormsg) 821 msgbox_uvmat('ERROR',errormsg) 822 return 823 end 824 filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status 825 end 826 if ~isequal(box_test(4:6),[0 0 0]) 827 civ_files=filecell.nc.civ2;%case of civ2 operations 828 else 829 civ_files=filecell.nc.civ1; 830 end 831 [root,filename,ext]=fileparts(civ_files{1}); 832 [rootroot,subdir,extdir]=fileparts(root); 833 hfig=findobj(allchild(0),'name','civ_status'); 834 if isempty(hfig) 835 hfig=figure('DeleteFcn',@stop_status); 836 set(hfig,'name','civ_status') 837 hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); 838 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); 839 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 840 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); 841 BarPosition=[0.05 0.81 0.01 0.05]; 842 hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); 843 drawnow 844 end 845 % datnum=[]; 846 Tabchar={}; 847 nbfiles=numel(civ_files); 848 count=0; 849 testrecent=0; 850 while count<nbfiles 851 count=0; 852 datnum=zeros(1,nbfiles); 853 for ifile=1:nbfiles 854 detect=exist(civ_files{ifile},'file'); % check the existence of the file 855 option=0; 856 if detect==0 857 option_str='not created'; 858 else 859 datfile=dir(civ_files{ifile}); 860 if isfield(datfile,'datenum') 861 datnum(ifile)=datfile.datenum;%only available in recent matlab versions 862 testrecent=1; 863 end 864 filefound(ifile)={datfile.name}; 865 lastfield=''; 866 % check the content netcdf file 867 Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); 868 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 869 option=6; 870 option_str='patch2'; 871 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 872 option=5; 873 option_str='fix2'; 874 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 875 option=4; 876 option_str='civ2'; 877 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 878 option=3; 879 option_str='patch1'; 880 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 881 option=2; 882 option_str='fix1'; 883 else 884 option=1; 885 option_str='civ1'; 886 end 887 end 888 if option >= option_civ 889 count=count+1; 890 end 891 [rr,filename,ext]=fileparts(civ_files{ifile}); 892 Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; 893 end 894 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 895 if isempty(datnum) 896 if testrecent 897 message='no civ result created yet'; 898 else 899 message=''; 900 end 901 else 902 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 903 [first,ind]=min(datnum); 904 [last,indlast]=max(datnum); 905 if test_new 906 message='existing file status, no processing launched yet'; 907 else 908 message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 909 ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 910 end 911 end 912 hfig=findobj(allchild(0),'name','civ_status'); 913 if isempty(hfig)% the status list has been deleted 914 return 915 else 916 hlist=findobj(hfig,'tag','list'); 917 hmsgbox=findobj(hfig,'tag','msgbox'); 918 hwaitbar=findobj(hfig,'tag','waitbar'); 919 set(hlist,'String',Tabchar) 920 set(hmsgbox,'String', message) 921 if count>0 && ~test_new 922 BarPosition(3)=0.9*count/nbfiles; 923 set(hwaitbar,'Position',BarPosition) 924 end 925 end 926 set(hlist,'UserData',rootroot) 927 pause(10)% wait 10 seconds for next check 928 end 929 930 %------------------------------------------------------------------------ 931 % --- Main lauch command, called by RUN and BATCH 1376 932 function errormsg=launch_jobs(hObject, eventdata, handles, batch) 1377 933 %----------------------------------------------------------------------- 1378 934 errormsg='';%default 1379 1380 %%read the civ GUI 935 %% read the civ GUI 1381 936 Param=read_GUI(handles.civ); 937 1382 938 %% check the selected list of operations: 1383 939 operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; … … 1458 1014 return 1459 1015 end 1460 1461 1016 test_interp=0; %eviter les variables test_ (LG) 1462 1463 1017 if batch 1464 1018 if isfield(s,'BatchParam') … … 1500 1054 1501 1055 %% check if the binaries exist 1502 if isequal(get(handles.M atlab,'checked'),'on')1056 if isequal(get(handles.MenuMatlab,'checked'),'on') 1503 1057 CivMode='Matlab'; 1504 1058 else … … 1513 1067 case 'Matlab' 1514 1068 if batch 1515 % vérifier M atlab installé sur le cluster1069 % vérifier MenuMatlab installé sur le cluster 1516 1070 % difficile a faire a priori 1517 1071 end 1518 1072 end 1519 for bin_name=binary_list 1520 if isfield(Param.xml,bin_name{1}) 1073 for bin_name=binary_list %loop on the list of binaries 1074 if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list 1521 1075 if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml 1522 1076 fullname=fullfile(path_civ,Param.xml.(bin_name{1})); … … 1533 1087 binpath=pwd;%path of the binary 1534 1088 Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); 1535 % display(Param.xml.(bin_name{1}));1536 1089 cd(currentdir); 1537 1090 end … … 1539 1092 end 1540 1093 end 1541 1542 1094 display('files OK, processing...') 1543 1095 … … 1545 1097 %% MAIN LOOP 1546 1098 time=get(handles.ImaDoc,'UserData'); %get the set of times 1547 1548 1099 super_cmd=[]; 1549 1100 batch_file_list=[]; 1550 1101 1551 1102 for ifile=1:nbfield 1552 1103 for j=1:nbslice … … 1577 1128 end 1578 1129 OutputFile=regexprep(OutputFile,'.nc',''); 1579 1130 1580 1131 if Param.CheckCiv1 1581 1132 % read image-dependent parameters 1582 1133 Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; 1583 1134 Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; 1584 if size(time,1)>=num2_civ1(ifile) && size(time, 1)>=num_b_civ1(ifile)1135 if size(time,1)>=num2_civ1(ifile) && size(time,2)>=num_b_civ1(ifile) 1585 1136 Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); 1586 1137 Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); … … 1592 1143 Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% 1593 1144 Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement 1594 Param.Civ1.pxcmy=1; 1595 1596 A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size 1597 sizim=size(A); 1598 Param.Civ1.npx=(sizim(2)); 1599 Param.Civ1.npy=(sizim(1)); 1145 Param.Civ1.pxcmy=1; 1146 Param.Civ1.ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size 1147 1600 1148 %TODO : civ should not need npx and npy 1601 1149 1602 1150 % read mask parameters 1603 1151 if Param.Civ1.CheckMask % the lines below should be changed with the new gui … … 1663 1211 1664 1212 if Param.CheckFix1 1665 switch CivMode1213 switch CivMode 1666 1214 case 'CivX' 1667 1215 cmd=[cmd... … … 1737 1285 if Param.CheckCiv2==1 1738 1286 Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; 1739 Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; 1740 if size(time,1)>=num2_civ 1(ifile) && size(time,1)>=num_b_civ1(ifile)1287 Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; 1288 if size(time,1)>=num2_civ2(ifile) && size(time,2)>=num_b_civ2(ifile) 1741 1289 Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); 1742 Param.Civ2.T0=num2str((time(num2_civ 1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);1290 Param.Civ2.T0=num2str((time(num2_civ2(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); 1743 1291 else 1744 1292 Param.Civ2.Dt=1; 1745 1293 Param.Civ2.T0=0; 1746 end 1294 end 1747 1295 Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); 1748 1296 Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); … … 1795 1343 Param.Civ2.GridFlag='n'; 1796 1344 end 1797 A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size1798 sizim=size(A);1799 Param.Civ2. npx=(sizim(2));1800 Param.Civ2.npy=(sizim(1));1801 1345 % A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size 1346 % sizim=size(A); 1347 Param.Civ2.ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size 1348 % Param.Civ2.npx=(sizim(2)); 1349 % Param.Civ2.npy=(sizim(1)); 1802 1350 switch CivMode 1803 1351 case 'CivX' 1804 1352 cmd=[cmd... 1805 1353 cmd_civ2(filecell.nc.civ2{ifile,j},Param) '\n']; 1806 1354 case 'CivAll' … … 1893 1441 end 1894 1442 end 1895 1443 1896 1444 switch CivMode 1897 1445 case {'CivX','CivAll'} … … 1917 1465 batch_file_list{length(batch_file_list)+1}=filename_bat; 1918 1466 1919 % if batch1920 % switch batch_mode1921 % case 'sge'1922 % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);1923 % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);1924 % case 'oar'1925 % % eval( ['!chmod +x ' filename_bat]);1926 % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]);1927 % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]);1928 %1929 % cmd_str=['sh ' filename_bat];1930 % super_cmd{length(super_cmd)+1}=cmd_str;1931 %1932 % end1933 % else1934 % %% to lauch the jobs locally :1935 % if(isunix)1936 % cmd_str=['. ' filename_bat];1937 % else %case of Windows1938 % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"'];1939 % end1940 % super_cmd=[super_cmd cmd_str '\n'];1941 % disp(cmd_str);1942 % end1943 1467 case 'Matlab' 1944 1468 drawnow 1945 if Param.CheckCiv1==11946 Param.Civ1=Param.Civ1;1947 end1948 if Param.CheckFix1==11949 fix1.WarnFlags=[];1950 if get(handles.CheckFmin2,'Value')1951 fix1.WarnFlags=[fix1.WarnFlags -2];1952 end1953 if get(handles.CheckF3,'Value')1954 fix1.WarnFlags=[fix1.WarnFlags 3];1955 end1956 fix1.LowerBoundCorr=thresh_vecC1;1957 if get(handles.num_MinVel,'Value')1958 fix1.UppperBoundVel=thresh_vel1;1959 else1960 fix1.LowerBoundVel=thresh_vel1;1961 end1962 if get(handles.CheckMask,'Value')1963 fix1.MaskName=maskname;1964 end1965 Param.Fix1=fix1;1966 end1967 if Param.CheckPatch1==11968 if strcmp(compare,'stereo PIV')1969 filebase_A=filecell.filebase;1970 [pp,ff]=fileparts(filebase_A);1971 filebase_B=fullfile(pp,get(handles.RootName_1,'String'));1972 RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},...1973 str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml'])1974 else1975 Param.Patch1.Rho=rho_patch1;1976 Param.Patch1.Threshold=thresh_patch1;1977 Param.Patch1.SubDomain=subdomain_patch1;1978 end1979 end1980 if Param.CheckCiv2==11981 Param.Civ2=Param.Civ2;1982 end1983 if Param.CheckFix2==11984 fix2.WarnFlags=[];1985 if get(handles.CheckFmin2,'Value')1986 fix2.WarnFlags=[fix2.WarnFlags -2];1987 end1988 if get(handles.CheckF4,'Value')1989 fix2.WarnFlags=[fix2.WarnFlags 4];1990 end1991 if get(handles.CheckF3,'Value')1992 fix2.WarnFlags=[fix2.WarnFlags 3];1993 end1994 fix2.LowerBoundCorr=thresh_vec2C;1995 if get(handles.num_MinVel,'Value')1996 fix2.UppperBoundVel=thresh_vel2;1997 else1998 fix2.LowerBoundVel=thresh_vel2;1999 end2000 if get(handles.CheckMask,'Value')2001 fix2.MaskName=maskname;2002 end2003 Param.Fix2=fix2;2004 end2005 if Param.CheckPatch2==12006 if strcmp(compare,'stereo PIV')2007 filebase_A=filecell.filebase;2008 [pp,ff]=fileparts(filebase_A);2009 filebase_B=fullfile(pp,get(handles.RootName_1,'String'));2010 RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...2011 str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])2012 else2013 Param.Patch2.Rho=rho_patch2;2014 Param.Patch2.Threshold=thresh_patch2;2015 Param.Patch2.SubDomain=subdomain_patch2;2016 end2017 end2018 1469 if ~strcmp(compare,'stereo PIV') 2019 [Data,erromsg]=civ_ uvmat(Param,filecell.nc.civ1{ifile,j});1470 [Data,erromsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j}); 2020 1471 if isempty(errormsg) 2021 1472 display([filecell.nc.civ1{ifile,j} ' written']) 2022 1473 else 2023 1474 msgbox_uvmat('ERROR',errormsg) 2024 end 2025 1475 end 2026 1476 end 2027 1477 end … … 2113 1563 eval(['!chmod +x ' filename_oarscript]); 2114 1564 eval(['!oarsub -S ' filename_oarscript]); 2115 2116 2117 2118 2119 2120 1565 case 'oar_new' % to be develloped with Patrick Begou 2121 1566 filename_joblist=fullfile(Rootbat,'job_list.txt'); … … 2199 1644 save (profil_perso,'MenuFile') 2200 1645 end 2201 2202 1646 2203 1647 %------------------------------------------------------------------------ … … 3062 2506 end 3063 2507 3064 3065 %------------------------------------------------------------------------ 3066 % --- STEREO Interp 3067 function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) 3068 %------------------------------------------------------------------------ 3069 namelog=[filename_nc(1:end-3) '_stinterp.log']; 3070 cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... 3071 ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file 3072 3073 %------------------------------------------------------------------------ 3074 % --- Executes on button press in CheckCiv1. 3075 function CheckCiv1_Callback(hObject, eventdata, handles) 3076 %------------------------------------------------------------------------ 3077 update_CivOptions(handles) 3078 3079 %------------------------------------------------------------------------ 3080 % --- Executes on button press in CheckFix1. 3081 function CheckFix1_Callback(hObject, eventdata, handles) 3082 %------------------------------------------------------------------------ 3083 update_CivOptions(handles) 3084 3085 %------------------------------------------------------------------------ 3086 % --- Executes on button press in CheckPatch1. 3087 function CheckPatch1_Callback(hObject, eventdata, handles) 3088 %------------------------------------------------------------------------ 3089 update_CivOptions(handles) 3090 3091 %------------------------------------------------------------------------ 3092 % --- Executes on button press in CheckCiv2. 3093 function CheckCiv2_Callback(hObject, eventdata, handles) 3094 %------------------------------------------------------------------------ 3095 update_CivOptions(handles) 3096 3097 %------------------------------------------------------------------------ 3098 % --- Executes on button press in CheckFix2. 3099 function CheckFix2_Callback(hObject, eventdata, handles) 3100 %------------------------------------------------------------------------ 3101 update_CivOptions(handles) 3102 3103 %------------------------------------------------------------------------ 3104 % --- Executes on button press in CheckPatch2. 3105 function CheckPatch2_Callback(hObject, eventdata, handles) 3106 %------------------------------------------------------------------------ 3107 update_CivOptions(handles) 3108 3109 %------------------------------------------------------------------------ 3110 % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 3111 function update_CivOptions(handles) 3112 %------------------------------------------------------------------------ 3113 checkbox=zeros(1,6); 3114 checkbox(1)=get(handles.CheckCiv1,'Value'); 3115 checkbox(2)=get(handles.CheckFix1,'Value'); 3116 checkbox(3)=get(handles.CheckPatch1,'Value'); 3117 checkbox(4)=get(handles.CheckCiv2,'Value'); 3118 checkbox(5)=get(handles.CheckFix2,'Value'); 3119 checkbox(6)=get(handles.CheckPatch2,'Value'); 3120 ind_selected=find(checkbox,1); 3121 if ~isempty(ind_selected) 3122 RootName=get(handles.RootName,'String'); 3123 if isempty(RootName) 3124 msgbox_uvmat('ERROR','No input file') 2508 %------------------------------------------------------------------------ 2509 % --- Executes on button press in ListCompareMode. 2510 function ListCompareMode_Callback(hObject, eventdata, handles) 2511 %------------------------------------------------------------------------ 2512 test=get(handles.ListCompareMode,'Value'); 2513 if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' 2514 filebase=get(handles.RootName,'String'); 2515 browse=get(handlesRootName,'Userdata'); 2516 browse.nom_type_ima1=browse.nom_type_ima; 2517 set(handlesRootName,'UserData',browse); 2518 set(handles.sub_txt,'Visible','on') 2519 set(handles.RootName_1,'Visible','On');%mkes the second file input window visible 2520 mode_store=get(handles.ListPairMode,'String');%get the present 'mode' 2521 set(handles.ListCompareMode,'UserData',mode_store);%store the mode display 2522 set(handles.ListPairMode,'Visible','off') 2523 if test==2 2524 set(handles.ListPairMode,'Visible','off') 2525 set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default 2526 else 2527 set(handles.ListPairMode,'Visible','on') 2528 set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo 2529 end 2530 2531 %% menuopen an image file with the browser 2532 ind_opening=1;%default 2533 browse.incr_pair=[0 0]; %default 2534 oldfile=get(handles.RootName,'String'); 2535 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 2536 '*.xml', '.xml files '; ... 2537 '*.civ', '.civ files '; ... 2538 '*.png','.png image files'; ... 2539 '*.jpg',' jpeg image files'; ... 2540 '*.tif','.tif image files'; ... 2541 '*.avi;*.AVI','.avi movie files'; ... 2542 '*.nc','.netcdf files'; ... 2543 '*.*', 'All Files (*.*)'}; 2544 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); 2545 fileinput=[PathName FileName];%complete file name 2546 sizf=size(fileinput); 2547 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string 2548 [path,name,ext]=fileparts(fileinput); 2549 [path1]=fileparts(filebase); 2550 if isunix 2551 [status,path]=system(['readlink ' path]); 2552 [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths 2553 end 2554 if ~strcmp(path1,path) 2555 msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') 3125 2556 return 3126 end 3127 end 3128 set(handles.PairIndices,'Visible','on') 3129 set(handles.txt_SubdirCiv1,'Visible','on') 3130 set(handles.ListSubdirCiv1,'Visible','on') 3131 find_netcpair_civ1(handles) % select the available netcdf files 3132 if max(checkbox(4:6))% case of civ2 pair choice needed 3133 set(handles.TitlePairCiv2,'Visible','on') 3134 set(handles.TitleSubdirCiv2,'Visible','on') 3135 set(handles.txt_SubdirCiv2,'Visible','on') 3136 set(handles.ListSubdirCiv2,'Visible','on') 3137 set(handles.ListPairCiv2,'Visible','on') 3138 find_netcpair_civ2(handles) % select the available netcdf files 3139 else 3140 set(handles.TitleSubdirCiv2,'Visible','off') 3141 set(handles.txt_SubdirCiv2,'Visible','off') 3142 set(handles.ListSubdirCiv2,'Visible','off') 3143 set(handles.ListPairCiv2,'Visible','off') 3144 end 3145 options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; 3146 for ilist=1:length(options) 3147 if checkbox(ilist) 3148 set(handles.(options{ilist}),'Visible','on') 2557 end 2558 % set(handles.RootName_1,'String',name); 2559 [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); 2560 set(handles.RootName_1,'String',RootFile); 2561 browse=get(handlesRootName,'UserData'); 2562 browse.nom_type_ima_1=nom_type; 2563 set(handlesRootName,'UserData',browse) 2564 2565 %check image extension 2566 if ~strcmp(ext,get(handles.ImaExt,'String')) 2567 msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') 2568 return 2569 end 2570 2571 %% check coincidence of image sizes 2572 % ref_i=get(handles.ref_i,'string'); 2573 % ref_j=get(handles.ref_j,'string'); 2574 % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); 2575 % A=imread(filecell.ima1.checkciv1{1}); 2576 % A_1=imread(fileinput); 2577 % npxy=size(A); 2578 % npxy_1=size(A_1); 2579 % if ~isequal(size(A),size(A_1)) 2580 % msgbox_uvmat('ERROR','The two input image series do not have the same size') 2581 % return 2582 % end 2583 else 2584 set(handles.ListPairMode,'Visible','on') 2585 set(handles.RootName_1,'Visible','Off'); 2586 set(handles.sub_txt,'Visible','off') 2587 set(handles.RootName_1,'String',[]); 2588 mode_store=get(handles.ListCompareMode,'UserData'); 2589 set(handles.ListPairMode,'Value',1) 2590 set(handles.ListPairMode,'String',mode_store) 2591 set(handles.test_stereo1,'Value',0) 2592 set(handles.CheckStereo,'Value',0) 2593 set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default 2594 end 2595 if test==3 && get(handles.CheckPatch1,'Value') 2596 set(handles.test_stereo1,'Visible','on') 2597 else 2598 set(handles.test_stereo1,'Visible','off') 2599 end 2600 if test==3 && get(handles.CheckPatch2,'Value') 2601 set(handles.CheckStereo,'Visible','on') 2602 else 2603 set(handles.CheckStereo,'Visible','off') 2604 end 2605 mode_Callback(hObject, eventdata, handles) 2606 2607 2608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2609 % Callbacks in the uipanel Pair Indices 2610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2611 %------------------------------------------------------------------------ 2612 % --- Executes on button press in ListPairMode. 2613 function ListPairMode_Callback(hObject, eventdata, handles) 2614 %------------------------------------------------------------------------ 2615 compare_list=get(handles.ListCompareMode,'String'); 2616 val=get(handles.ListCompareMode,'Value'); 2617 compare=compare_list{val}; 2618 if strcmp(compare,'displacement') 2619 mode='displacement'; 2620 else 2621 mode_list=get(handles.ListPairMode,'String'); 2622 if ischar(mode_list) 2623 mode_list={mode_list}; 2624 end 2625 mode_value=get(handles.ListPairMode,'Value'); 2626 mode=mode_list{mode_value}; 2627 end 2628 displ_num=[];%default 2629 ref_i=str2double(get(handles.ref_i,'String')); 2630 % last_i=str2num(get(handles.last_i,'String')); 2631 time=get(handles.ImaDoc,'UserData'); %get the set of times 2632 siztime=size(time); 2633 nbfield=siztime(1); 2634 nbfield2=siztime(2); 2635 indchosen=1; %%first pair selected by default 2636 %displ_num used to define the indices of the civ pairs 2637 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices 2638 % are relative to the reference indices ref_i and ref_j respectively. 2639 if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') 2640 dt=1; 2641 displ=''; 2642 index=0; 2643 numlist_a=[]; 2644 numlist_B=[]; 2645 %get all the time intervals in bursts 2646 displ_dt=1;%default 2647 nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 2648 for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode 2649 for numod_b=(numod_a+1):nbfield2 2650 index=index+1; 2651 numlist_a(index)=numod_a; 2652 numlist_b(index)=numod_b; 2653 if ~isempty(time) 2654 dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt 2655 displ_dt(index)=dt(numod_a,numod_b); 2656 else 2657 displ_dt(index)=1; 2658 end 2659 end 2660 end 2661 [dtsort,indsort]=sort(displ_dt); 2662 if ~isempty(numlist_a) 2663 displ_num(1,:)=numlist_a(indsort); 2664 displ_num(2,:)=numlist_b(indsort); 2665 end 2666 displ_num(3,:)=0; 2667 displ_num(4,:)=0; 2668 set(handles.jtext,'Visible','Off') 2669 set(handles.first_j,'Visible','Off') 2670 set(handles.last_j,'Visible','Off') 2671 set(handles.incr_j,'Visible','Off') 2672 set(handles.nb_field2,'Visible','Off') 2673 set(handles.ref_j,'Visible','Off') 2674 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') 2675 index=1:200; 2676 displ_num(1,index)=-floor(index/2); 2677 displ_num(2,index)=ceil(index/2); 2678 displ_num(3:4,index)=zeros(2,200); 2679 % for index=1:min(nbfield2-1,200) 2680 % displ_num(1,index)=-floor(index/2); 2681 % displ_num(2,index)=ceil(index/2); 2682 % displ_num(3,index)=0; 2683 % displ_num(4,index)=0; 2684 % end 2685 set(handles.jtext,'Visible','On') 2686 set(handles.first_j,'Visible','On') 2687 set(handles.last_j,'Visible','On') 2688 set(handles.incr_j,'Visible','On') 2689 set(handles.nb_field2,'Visible','On') 2690 set(handles.ref_j,'Visible','On') 2691 if nbfield > 1 2692 set(handles.itext,'Visible','On') 2693 set(handles.first_i,'Visible','On') 2694 set(handles.last_i,'Visible','On') 2695 set(handles.incr_i,'Visible','On') 2696 set(handles.nb_field,'Visible','On') 2697 set(handles.ref_i,'Visible','On') 3149 2698 else 3150 set(handles.(options{ilist}),'Visible','off') 3151 end 3152 end 3153 2699 set(handles.itext,'Visible','Off') 2700 set(handles.first_i,'Visible','Off') 2701 set(handles.last_i,'Visible','Off') 2702 set(handles.incr_i,'Visible','Off') 2703 set(handles.nb_field,'Visible','Off') 2704 set(handles.ref_i,'Visible','Off') 2705 end 2706 elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') 2707 index=1:200; 2708 displ_num(1:2,index)=zeros(2,200); 2709 displ_num(3,index)=-floor(index/2); 2710 displ_num(4,index)=ceil(index/2); 2711 % for index=1:200%min(nbfield-1,200) 2712 % displ_num(1,index)=0; 2713 % displ_num(2,index)=0; 2714 % displ_num(3,index)=-floor(index/2); 2715 % displ_num(4,index)=ceil(index/2); 2716 % end 2717 set(handles.itext,'Visible','On') 2718 set(handles.first_i,'Visible','On') 2719 set(handles.last_i,'Visible','On') 2720 set(handles.incr_i,'Visible','On') 2721 set(handles.nb_field,'Visible','On') 2722 set(handles.ref_i,'Visible','On') 2723 if nbfield2 > 1 2724 set(handles.jtext,'Visible','On') 2725 set(handles.first_j,'Visible','On') 2726 set(handles.last_j,'Visible','On') 2727 set(handles.incr_j,'Visible','On') 2728 set(handles.nb_field2,'Visible','On') 2729 set(handles.ref_j,'Visible','On') 2730 else 2731 set(handles.jtext,'Visible','Off') 2732 set(handles.first_j,'Visible','Off') 2733 set(handles.last_j,'Visible','Off') 2734 set(handles.incr_j,'Visible','Off') 2735 set(handles.nb_field2,'Visible','Off') 2736 set(handles.ref_j,'Visible','Off') 2737 end 2738 elseif isequal(mode,'displacement')%the pairs have the same indices 2739 displ_num(1,1)=0; 2740 displ_num(2,1)=0; 2741 displ_num(3,1)=0; 2742 displ_num(4,1)=0; 2743 if nbfield > 1 2744 set(handles.itext,'Visible','On') 2745 set(handles.first_i,'Visible','On') 2746 set(handles.last_i,'Visible','On') 2747 set(handles.incr_i,'Visible','On') 2748 set(handles.nb_field,'Visible','On') 2749 set(handles.ref_i,'Visible','On') 2750 else 2751 set(handles.itext,'Visible','Off') 2752 set(handles.first_i,'Visible','Off') 2753 set(handles.last_i,'Visible','Off') 2754 set(handles.incr_i,'Visible','Off') 2755 set(handles.nb_field,'Visible','Off') 2756 set(handles.ref_i,'Visible','Off') 2757 end 2758 if nbfield2 > 1 2759 set(handles.jtext,'Visible','On') 2760 set(handles.first_j,'Visible','On') 2761 set(handles.last_j,'Visible','On') 2762 set(handles.incr_j,'Visible','On') 2763 set(handles.nb_field2,'Visible','On') 2764 set(handles.ref_j,'Visible','On') 2765 else 2766 set(handles.jtext,'Visible','Off') 2767 set(handles.first_j,'Visible','Off') 2768 set(handles.last_j,'Visible','Off') 2769 set(handles.incr_j,'Visible','Off') 2770 set(handles.nb_field2,'Visible','Off') 2771 set(handles.ref_j,'Visible','Off') 2772 end 2773 end 2774 set(handles.ListPairCiv1,'UserData',displ_num); 2775 find_netcpair_civ1( handles) 2776 find_netcpair_civ2(handles) 2777 2778 %------------------------------------------------------------------------ 2779 % --- Executes on selection change in ListPairCiv1. 2780 function ListPairCiv1_Callback(hObject, eventdata, handles) 2781 %------------------------------------------------------------------------ 2782 %reproduce by default the chosen pair in the checkciv2 menu 2783 list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs 2784 index_pair=get(handles.ListPairCiv1,'Value'); 2785 displ_num=get(handles.ListPairCiv1,'UserData'); 2786 % num_a=displ_num(1,index_pair); 2787 % num_b=displ_num(2,index_pair); 2788 list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs 2789 if index_pair<=length(list_pair2) 2790 set(handles.ListPairCiv2,'Value',index_pair); 2791 end 2792 2793 %update first_i and last_i according to the chosen image pairs 2794 mode_list=get(handles.ListPairMode,'String'); 2795 mode_value=get(handles.ListPairMode,'Value'); 2796 mode=mode_list{mode_value}; 2797 if isequal(mode,'series(Di)') 2798 first_i=str2double(get(handles.first_i,'String')); 2799 last_i=str2double(get(handles.last_i,'String')); 2800 incr_i=str2double(get(handles.incr_i,'String')); 2801 num1=first_i:incr_i:last_i; 2802 lastfield=str2double(get(handles.nb_field,'String')); 2803 if ~isnan(lastfield) 2804 test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... 2805 (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); 2806 num1=num1(test_find); 2807 end 2808 set(handles.first_i,'String',num2str(num1(1))); 2809 set(handles.last_i,'String',num2str(num1(end))); 2810 elseif isequal(mode,'series(Dj)') 2811 first_j=str2double(get(handles.first_j,'String')); 2812 last_j=str2double(get(handles.last_j,'String')); 2813 incr_j=str2double(get(handles.incr_j,'String')); 2814 num_j=first_j:incr_j:last_j; 2815 lastfield2=str2double(get(handles.nb_field2,'String')); 2816 if ~isnan(lastfield2) 2817 test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... 2818 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); 2819 num1=num_j(test_find); 2820 end 2821 set(handles.first_j,'String',num2str(num1(1))); 2822 set(handles.last_j,'String',num2str(num1(end))); 2823 end 2824 2825 %------------------------------------------------------------------------ 2826 % --- Executes on selection change in ListPairCiv2. 2827 function ListPairCiv2_Callback(hObject, eventdata, handles) 2828 %------------------------------------------------------------------------ 2829 index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu 2830 2831 %update first_i and last_i according to the chosen image pairs 2832 mode_list=get(handles.ListPairMode,'String'); 2833 mode_value=get(handles.ListPairMode,'Value'); 2834 mode=mode_list{mode_value}; 2835 if isequal(mode,'series(Di)') 2836 first_i=str2double(get(handles.first_i,'String')); 2837 last_i=str2double(get(handles.last_i,'String')); 2838 incr_i=str2double(get(handles.incr_i,'String')); 2839 num1=first_i:incr_i:last_i; 2840 lastfield=str2double(get(handles.nb_field,'String')); 2841 if ~isnan(lastfield) 2842 test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... 2843 (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); 2844 num1=num1(test_find); 2845 end 2846 set(handles.first_i,'String',num2str(num1(1))); 2847 set(handles.last_i,'String',num2str(num1(end))); 2848 elseif isequal(mode,'series(Dj)') 2849 first_j=str2double(get(handles.first_j,'String')); 2850 last_j=str2double(get(handles.last_j,'String')); 2851 incr_j=str2double(get(handles.incr_j,'String')); 2852 num_j=first_j:incr_j:last_j; 2853 lastfield2=str2double(get(handles.nb_field2,'String')); 2854 if ~isnan(lastfield2) 2855 test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... 2856 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); 2857 num1=num_j(test_find); 2858 end 2859 set(handles.first_j,'String',num2str(num1(1))); 2860 set(handles.last_j,'String',num2str(num1(end))); 2861 end 2862 2863 %------------------------------------------------------------------------ 2864 function ref_i_Callback(hObject, eventdata, handles) 2865 %------------------------------------------------------------------------ 2866 mode_list=get(handles.ListPairMode,'String'); 2867 mode_value=get(handles.ListPairMode,'Value'); 2868 mode=mode_list{mode_value}; 2869 find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files 2870 if isequal(mode,'series(Di)') || ...% we do patch2 only 2871 (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) 2872 find_netcpair_civ2( handles); 2873 end 2874 2875 %------------------------------------------------------------------------ 2876 function ref_j_Callback(hObject, eventdata, handles) 2877 %------------------------------------------------------------------------ 2878 mode_list=get(handles.ListPairMode,'String'); 2879 mode_value=get(handles.ListPairMode,'Value'); 2880 mode=mode_list{mode_value}; 2881 if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') 2882 find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files 2883 end 2884 if isequal(mode,'series(Dj)') || ... 2885 (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) 2886 find_netcpair_civ2(handles); 2887 end 2888 % 2889 %------------------------------------------------------------------------ 2890 % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of 2891 % the field series set by first_i, incr, last_i 2892 function find_netcpair_civ1(handles) 2893 %------------------------------------------------------------------------ 2894 set(gcf,'Pointer','watch') 2895 %nomenclature types 2896 filebase=get(handles.RootName,'String'); 2897 [filepath,Nme,ext_dir]=fileparts(filebase); 2898 browse=get(handles.RootName,'UserData'); 2899 compare_list=get(handles.ListCompareMode,'String'); 2900 val=get(handles.ListCompareMode,'Value'); 2901 compare=compare_list{val}; 2902 if strcmp(compare,'displacement') 2903 mode='displacement'; 2904 else 2905 mode_list=get(handles.ListPairMode,'String'); 2906 mode_value=get(handles.ListPairMode,'Value'); 2907 if isempty(mode_list) 2908 return 2909 end 2910 mode=mode_list{mode_value}; 2911 end 2912 2913 % nomenclature type of the .nc files 2914 nom_type_ima=[];%default 2915 if isfield(browse,'nom_type_ima') 2916 nom_type_ima=browse.nom_type_ima; 2917 end 2918 2919 %determine nom_type_nc: 2920 nom_type_nc=[];%default 2921 if isfield(browse,'nom_type_nc') 2922 nom_type_nc=browse.nom_type_nc; 2923 end 2924 if isempty(nom_type_nc) 2925 [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); 2926 end 2927 browse.nom_type_nc=nom_type_nc; 2928 set(handles.RootName,'UserData',browse) 2929 2930 %reads .nc subdirectoy and image numbers from the interface 2931 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 2932 ref_i=str2double(get(handles.ref_i,'String')); 2933 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 2934 ref_j=0; 2935 else 2936 ref_j=str2double(get(handles.ref_j,'String')); 2937 end 2938 time=get(handles.ImaDoc,'UserData');%get the set of times 2939 if isempty(time) 2940 time=[0 1]; 2941 end 2942 dt_unit=1000;%default 2943 displ_num=get(handles.ListPairCiv1,'UserData'); 2944 2945 %eliminate the first pairs inconsistent with the position 2946 if isempty(displ_num) 2947 nbpair=0; 2948 else 2949 nbpair=length(displ_num(1,:));%nbre of displayed pairs 2950 if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') 2951 nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 2952 elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 2953 nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 2954 end 2955 end 2956 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 2957 2958 %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not 2959 % be performed, while the result is needed for next steps. 2960 displ_pair={''}; 2961 select=ones(size(1:nbpair));%flag for displayed pairs =1 for display 2962 testpair=0; 2963 2964 %% case with no Civ1 operation, netcdf files need to exist for reading 2965 if ~get(handles.CheckCiv1,'Value') % 2966 if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') 2967 msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); 2968 set(handles.ListPairCiv1,'String',{}); 2969 return 2970 end 2971 for ipair=1:nbpair 2972 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 2973 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); 2974 select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist 2975 end 2976 % case of no displayed pair 2977 if isequal(select,zeros(size(1:nbpair))) 2978 if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) 2979 num_i1=ref_i-floor(browse.incr_pair(1)/2); 2980 num_i2=ref_i+ceil(browse.incr_pair(1)/2); 2981 num_j1=ref_j-floor(browse.incr_pair(2)/2); 2982 num_j2=ref_j+ceil(browse.incr_pair(2)/2); 2983 filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); 2984 select(1)=exist(filename,'file')==2; 2985 testpair=1; 2986 else 2987 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 2988 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); 2989 else 2990 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); 2991 end 2992 set(handles.ListPairCiv1,'String',{''}); 2993 %COMPLETER CAS STEREO 2994 return 2995 end 2996 end 2997 end 2998 2999 %% determine the menu display in .ListPairCiv1 3000 % the menu depends on the mode defined in ListPairMode_callback through the array displ_num: 3001 % displ_num(1,:)=indices j1 3002 % displ_num(2,:)=indices j2 3003 % displ_num(3,:)=indices i1 3004 % displ_num(4,:)=indices i2 3005 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices 3006 % are relative to the reference indices ref_i and ref_j respectively. 3007 if isequal(mode,'series(Di)') 3008 if testpair 3009 displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; 3010 else 3011 for ipair=1:nbpair 3012 if select(ipair) 3013 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 3014 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3015 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 3016 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3017 end 3018 else 3019 displ_pair{ipair}='...'; %pair not displayed in the menu 3020 end 3021 end 3022 end 3023 elseif isequal(mode,'series(Dj)') 3024 if testpair 3025 displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; 3026 else 3027 for ipair=1:nbpair 3028 if select(ipair) 3029 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 3030 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3031 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 3032 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3033 end 3034 else 3035 displ_pair{ipair}='...'; %pair not displayed in the menu 3036 end 3037 end 3038 end 3039 elseif isequal(mode,'pair j1-j2')%case of pairs 3040 for ipair=1:nbpair 3041 if select(ipair) 3042 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 3043 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 3044 ' :dt= ' num2str(dt*1000)]; 3045 else 3046 displ_pair{ipair}='...'; %pair not displayed in the menu 3047 end 3048 end 3049 elseif isequal(mode,'displacement') 3050 displ_pair={'Di=Dj=0'}; 3051 end 3052 set(handles.ListPairCiv1,'String',displ_pair'); 3053 3054 %% determine the default selection in the pair menu 3055 ichoice=find(select,1);% index of selected pair 3056 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 3057 initial=get(handles.ListPairCiv1,'Value');%initial choice of pair 3058 if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) 3059 set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu 3060 end 3061 initial=get(handles.ListPairCiv2,'Value'); 3062 if initial>length(displ_pair')%|~isequal(select(initial),1) 3063 if ichoice <= length(displ_pair') 3064 set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 3065 else 3066 set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 3067 end 3068 end 3069 set(handles.ListPairCiv2,'String',displ_pair'); 3070 set(gcf,'Pointer','arrow') 3071 3072 %------------------------------------------------------------------------ 3073 % determine the menu for checkciv2 pairs depending on the existing netcdf file at the 3074 %middle of the series set by first_i, incr, last_i 3075 function find_netcpair_civ2(handles) 3076 %------------------------------------------------------------------------ 3077 set(gcf,'Pointer','watch') 3078 %nomenclature types 3079 filebase=get(handles.RootName,'String'); 3080 [filepath,Nme,ext_dir]=fileparts(filebase); 3081 browse=get(handles.RootName,'UserData'); 3082 compare_list=get(handles.ListCompareMode,'String'); 3083 val=get(handles.ListCompareMode,'Value'); 3084 compare=compare_list{val}; 3085 if strcmp(compare,'displacement') 3086 mode='displacement'; 3087 else 3088 mode_list=get(handles.ListPairMode,'String'); 3089 if isempty(mode_list) 3090 msgbox_uvmat('ERROR','please enter an input image or netcdf file') 3091 return 3092 end 3093 mode_value=get(handles.ListPairMode,'Value'); 3094 mode=mode_list{mode_value}; 3095 end 3096 3097 % nomenclature type of the .nc files 3098 nom_type_ima='ima_num';%default 3099 if isfield(browse,'nom_type_ima') 3100 nom_type_ima=browse.nom_type_ima; 3101 end 3102 nom_type_nc='_i1-i2';%default 3103 if isfield(browse,'nom_type_nc') 3104 nom_type_nc=browse.nom_type_nc; 3105 end 3106 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') 3107 nom_type_nc='netc_old';%nom_type for the netcdf files 3108 elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') 3109 nom_type_nc='none'; 3110 elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') 3111 nom_type_nc='_i1-i2'; 3112 else 3113 if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') 3114 nom_type_nc='_i1-i2_j'; % PIV in volume 3115 else 3116 nom_type_nc='_i_j1-j2'; 3117 end 3118 end 3119 browse.nom_type_nc=nom_type_nc; 3120 set(handles.RootName,'UserData',browse) 3121 3122 %reads .nc subdirectory and image numbers from the interface 3123 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 3124 subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 3125 ref_i=str2double(get(handles.ref_i,'String')); 3126 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 3127 ref_j=0; 3128 else 3129 ref_j=str2double(get(handles.ref_j,'String')); 3130 end 3131 time=get(handles.ImaDoc,'UserData'); %get the set of times 3132 if isempty(time) 3133 time=[0 1];%default 3134 end 3135 displ_num=get(handles.ListPairCiv1,'UserData'); 3136 3137 %eliminate the first pairs inconsistent with the position 3138 if isempty(displ_num) 3139 nbpair=0; 3140 else 3141 nbpair=length(displ_num(1,:));%nbre of displayed pairs 3142 if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') 3143 nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 3144 elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3145 nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 3146 end 3147 end 3148 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 3149 3150 %% look for existing processed pairs at the reference indices if Civ1 will not 3151 % be performed, while the result is needed for next steps. 3152 displ_pair={''}; %default 3153 select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs 3154 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 3155 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 3156 errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) 3157 set(handles.ListPairCiv2,'Value',1); 3158 set(handles.ListPairCiv2,'String',{''}); 3159 return 3160 end 3161 for ipair=1:nbpair 3162 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 3163 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); 3164 select(ipair)=exist(filename,'file')==2; 3165 end 3166 if isequal(select,zeros(size(1:nbpair))) 3167 if isfield(browse,'incr_pair') 3168 num_i1=ref_i-floor(browse.incr_pair(1)/2); 3169 num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); 3170 num_j1=ref_j-floor(browse.incr_pair(2)/2); 3171 num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); 3172 filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); 3173 select(1)=exist(filename,'file')==2; 3174 else 3175 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3176 errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) 3177 else 3178 errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) 3179 end 3180 set(handles.ListPairCiv2,'Value',1); 3181 set(handles.ListPairCiv2,'String',{''}); 3182 return 3183 end 3184 end 3185 end 3186 if isequal(mode,'series(Di)') 3187 for ipair=1:nbpair 3188 if select(ipair) 3189 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3190 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3191 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 3192 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3193 end 3194 else 3195 displ_pair{ipair}='...'; %pair not displayed in the menu 3196 end 3197 end 3198 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index 3199 for ipair=1:nbpair 3200 if select(ipair) 3201 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3202 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3203 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 3204 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3205 end 3206 else 3207 displ_pair{ipair}='...'; %pair not displayed in the menu 3208 end 3209 end 3210 elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs 3211 for ipair=1:nbpair 3212 if select(ipair) 3213 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 3214 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 3215 ' :dt= ' num2str(dt*1000)]; 3216 else 3217 displ_pair{ipair}='...'; %pair not displayed in the menu 3218 end 3219 end 3220 elseif isequal(mode,'displacement') 3221 displ_pair={'Di=Dj=0'}; 3222 end 3223 val=get(handles.ListPairCiv2,'Value'); 3224 ichoice=find(select,1); 3225 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 3226 if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 3227 val=ichoice;% first valid pair proposed by default in the menu 3228 end 3229 if val>length(displ_pair') 3230 set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu 3231 else 3232 set(handles.ListPairCiv2,'Value',val); 3233 end 3234 set(handles.ListPairCiv2,'String',displ_pair'); 3235 set(gcf,'Pointer','arrow') 3236 3237 3238 3239 3240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3241 % Callbacks in the uipanel Reference Indices 3242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3154 3243 %------------------------------------------------------------------------ 3155 3244 function first_i_Callback(hObject, eventdata, handles) … … 3166 3255 ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) 3167 3256 3257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3258 % Callbacks in the uipanel Civ1 3259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3168 3260 %------------------------------------------------------------------------ 3169 3261 % --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy … … 3259 3351 end 3260 3352 3261 %------------------------------------------------------------------------3262 % --- Executes on carriage return on the subdir checkciv1 edit window3263 function txt_SubdirCiv1_Callback(hObject, eventdata, handles)3264 %------------------------------------------------------------------------3265 subdir=get(handles.txt_SubdirCiv1,'String');3266 menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update3267 ichoice=find(strcmp(subdir,menu_str),1);3268 if isempty(ichoice)3269 ilist=numel(menu_str); %select 'new...' in the menu3270 else3271 ilist=ichoice;3272 end3273 set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu3274 if get(handles.CheckCiv1,'Value')% if Civ1 is performed3275 set(handles.txt_SubdirCiv2,'String',subdir);% set by default civ2 directory the same as civ13276 set(handles.ListSubdirCiv2,'Value',ilist)3277 else % if Civ1 data already exist3278 find_netcpair_civ1(handles); %update the list of available pairs from netcdf files in the new directory3279 end3280 3281 %------------------------------------------------------------------------3282 % --- Executes on carriage return on the subdir checkciv1 edit window3283 function txt_SubdirCiv2_Callback(hObject, eventdata, handles)3284 %------------------------------------------------------------------------3285 subdir=get(handles.txt_SubdirCiv1,'String');3286 menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update3287 ichoice=find(strcmp(subdir,menu_str),1);3288 if isempty(ichoice)3289 ilist=numel(menu_str); %select 'new...' in the menu3290 else3291 ilist=ichoice;3292 end3293 set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu3294 %update the list of available pairs from netcdf files in the new directory3295 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')3296 find_netcpair_civ2(handles);3297 end3298 3299 % %------------------------------------------------------------------------3300 % % --- Executes on button press in CheckMask: select box for mask option3301 % function check_Mask_Callback(hObject, eventdata, handles)3302 % %------------------------------------------------------------------------3303 % maskval=get(handles.CheckMask,'Value');3304 % if isequal(maskval,0)3305 % set(handles.txt_MaskName,'Visible','off')3306 % % set(handles.txt_MaskName,'String','')3307 % else3308 % mask_displ='no mask'; %default3309 % filebase=get(handles.RootName,'String');3310 % [ nbslice_mask, flag_mask]=get_mask(filebase,handles);3311 % if isequal(flag_mask,1)3312 % mask_displ=[num2str(nbslice_mask) 'mask'];3313 % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series3314 % common_path=fileparts(filebase);3315 % filebase_a=fullfile(common_path,get(handles.RootName_1,'String'));3316 % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);3317 % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask)3318 % mask_displ='no mask';3319 % end3320 % end3321 % if isequal(mask_displ,'no mask')3322 % [FileName, PathName, filterindex] = uigetfile( ...3323 % {'*.png', ' (*.png)';3324 % '*.png', '.png files '; ...3325 % '*.*', 'All Files (*.*)'}, ...3326 % 'Pick a mask file *.png',filebase);3327 % mask_displ=fullfile(PathName,FileName);3328 % if exist(mask_displ,'file')3329 % set(handles.txt_MaskName,'Visible','on')3330 % set(handles.txt_MaskName,'String',mask_displ)3331 % % mask_displ='no mask';3332 % end3333 % end3334 % if isequal(mask_displ,'no mask')3335 % set(handles.CheckMask,'Value',0)3336 % set(handles.CheckMask,'Value',0)3337 % set(handles.CheckMask,'Value',0)3338 % set(handles.CheckMask,'Value',0)3339 % else3340 % set(handles.CheckMask,'Value',1)3341 % set(handles.CheckMask,'Value',1)3342 % end3343 % set(handles.txt_MaskName,'String',mask_displ)3344 % set(handles.txt_MaskName,'String',mask_displ)3345 % set(handles.txt_Mask,'String',mask_displ)3346 % set(handles.txt_MaskName,'String',mask_displ)3347 % end3348 % set(handles.CheckMask,'Value',maskval)%update the checkciv2 mask with the same option as checkciv13349 3353 3350 3354 %------------------------------------------------------------------------ … … 3713 3717 end 3714 3718 3715 %------------------------------------------------------------------------3716 % --- Executes on button press in CheckGrid.3717 function browse_gridciv2_Callback(hObject, eventdata, handles)3718 %------------------------------------------------------------------------3719 value=get(handles.CheckGrid,'Value');3720 if value3721 filebase=get(handles.RootName,'String');3722 [nbslice, flag_grid]=get_grid(filebase,handles);3723 if isequal(flag_grid,1)3724 mask_displ=[num2str(nbslice) 'grid'];3725 set(handles.txt_GridName,'String',mask_displ)3726 set(handles.num_Dx,'Visible','off');3727 set(handles.num_Dy,'Visible','off');3728 else3729 [FileName, PathName, filterindex] = uigetfile( ...3730 {'*.grid', ' (*.grid)';3731 '*.grid', '.grid files '; ...3732 '*.*', 'All Files (*.*)'}, ...3733 'Pick a file',filebase);3734 filegrid=fullfile(PathName,FileName);3735 if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')3736 set(handles.CheckGrid,'Value',0);3737 set(handles.txt_GridName,'string','');3738 set(handles.num_Dx,'Visible','on');3739 set(handles.num_Dy,'Visible','on');3740 set(handles.txt_GridName,'string','');3741 else3742 set(handles.txt_GridName,'string',filegrid);3743 set(handles.num_Dx,'Visible','off');3744 set(handles.num_Dy,'Visible','off');3745 set(handles.txt_GridName,'string',filegrid);3746 end3747 end3748 else3749 set(handles.txt_GridName,'string','');3750 set(handles.num_Dx,'Visible','on');3751 set(handles.num_Dy,'Visible','on');3752 set(handles.txt_GridName,'string','');3753 end3754 3755 % % --- Executes on button press in CheckGrid.3756 % function browse_gridciv2_Callback(hObject, eventdata, handles)3757 %3758 % filebase=get(handles.RootName,'String');3759 % [FileName, PathName, filterindex] = uigetfile( ...3760 % {'*.grid', ' (*.grid)';3761 % '*.grid', '.grid files '; ...3762 % '*.*', 'All Files (*.*)'}, ...3763 % 'Pick a file',filebase);3764 % filegrid=fullfile(PathName,FileName);3765 % set(handles.txt_GridName,'string',filegrid);3766 % set(handles.num_Dx,'String',' ');3767 % set(handles.num_Dy,'String',' ');3768 % % set(handles.grid_patch2,'string',filegrid);3769 3719 3770 3720 % --- Executes on button press in get_gridpatch1. 3771 3721 function get_gridpatch1_Callback(hObject, eventdata, handles) 3772 3722 % hObject handle to get_gridpatch1 (see GCBO) 3773 % eventdata reserved - to be defined in a future version of M ATLAB3723 % eventdata reserved - to be defined in a future version of MENUMATLAB 3774 3724 % handles structure with handles and user data (see GUIDATA) 3775 3725 … … 3789 3739 %------------------------------------------------------------------------ 3790 3740 3791 %------------------------------------------------------------------------ 3792 function enable_civ1(handles,state) 3793 %------------------------------------------------------------------------ 3794 if state 3795 RootName=get(handles.RootName,'String'); 3796 if isempty(RootName) 3797 msgbox_uvmat('ERROR','No input file') 3798 return 3799 end 3800 set(handles.Civ1,'Visible','on') 3801 set(handles.PairIndices,'Visible','on') 3802 % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) 3803 % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) 3804 % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) 3805 else 3806 set(handles.Civ1,'Visible','off') 3807 % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) 3808 % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) 3809 % set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) 3810 end 3811 3812 % set(handles.num_Bx,'Visible',state) 3813 % set(handles.num_By,'Visible',state) 3814 % set(handles.num_Searchx,'Visible',state) 3815 % set(handles.num_Searchy,'Visible',state) 3816 % set(handles.num_Shiftx,'Visible',state) 3817 % set(handles.num_Shifty,'Visible',state) 3818 % set(handles.num_Rho,'Visible',state) 3819 % set(handles.num_Dx,'Visible',state) 3820 % set(handles.num_Dy,'Visible',state) 3821 % set(handles.SearchRange,'Visible',state) 3822 % set(handles.u_title,'Visible',state) 3823 % set(handles.v_title,'Visible',state) 3824 % set(handles.min_title,'Visible',state) 3825 % set(handles.max_title,'Visible',state) 3826 % set(handles.umin,'Visible',state) 3827 % set(handles.umax,'Visible',state) 3828 % set(handles.vmin,'Visible',state) 3829 % set(handles.vmax,'Visible',state) 3830 % set(handles.txt_GridName,'Visible',state) 3831 % set(handles.txt_MaskName,'Visible',state) 3832 % set(handles.CheckGrid,'Visible',state) 3833 % set(handles.CheckMask,'Visible',state) 3834 % set(handles.parameters,'Visible',state) 3835 % set(handles.grid,'Visible',state) 3836 % set(handles.num_Dx,'Visible',state) 3837 % set(handles.num_Dy,'Visible',state) 3838 % set(handles.check_Threshold,'Visible',state) 3839 % if isequal(state,'off') 3840 % set(handles.num_MinIma,'Visible','off') 3841 % set(handles.num_MaxIma,'Visible','off') 3842 % set(handles.check_Threshold,'Value',0) 3843 % end 3844 % set(handles.dx_civ1_title,'Visible',state) 3845 % set(handles.dy_civ1_title,'Visible',state) 3846 % set(handles.ImaThreshold_title,'Visible',state) 3847 % set(handles.ib_title,'Visible',state) 3848 % set(handles.is_title,'Visible',state) 3849 % set(handles.shift_title,'Visible',state) 3850 % set(handles.rho_title,'Visible',state) 3851 % set(handles.TestCiv1,'Visible',state) 3852 %set(handles.ListPairMode,'Visible',state) 3853 3854 %------------------------------------------------------------------------ 3855 function enable_fix1(handles,state) 3856 %------------------------------------------------------------------------ 3857 3858 if isequal(state,0) 3859 state='off'; 3860 end 3861 if isequal(state,1) 3862 state='on'; 3863 RootName=get(handles.RootName,'String'); 3864 if isempty(RootName) 3865 msgbox_uvmat('ERROR','No input file') 3866 return 3867 end 3868 end 3869 if isequal(state,'on') 3870 set(handles.Fix1,'Visible','on') 3871 % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) 3872 else 3873 set(handles.Fix1,'Visible','off') 3874 %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) 3875 end 3876 % % set(handles.REMOVE,'Visible',state) 3877 % set(handles.CheckFmin2,'Visible',state) 3878 % set(handles.CheckF2,'Visible',state) 3879 % set(handles.CheckF3,'Visible',state) 3880 % set(handles.num_MinCorr,'Visible',state) 3881 % set(handles.thresh_vecC_title,'Visible',state) 3882 % set(handles.num_MinVel,'Visible',state) 3883 % set(handles.TitleMinVel,'Visible',state) 3884 % set(handles.txt_MaskName,'Visible',state) 3885 % set(handles.CheckMask,'Visible',state) 3886 % set(handles.get_ref_fix1,'Visible',state) 3887 % set(handles.ref_fix1,'Visible',state) 3888 % set(handles.num_MinVel,'Visible',state) 3889 % set(handles.field_ref1,'Visible',state) 3890 3891 %------------------------------------------------------------------------ 3892 function enable_patch1(handles,state) 3893 %------------------------------------------------------------------------ 3894 if state 3895 RootName=get(handles.RootName,'String'); 3896 if isempty(RootName) 3897 msgbox_uvmat('ERROR','No input file') 3898 return 3899 end 3900 set(handles.Patch1,'Visible','on') 3901 else 3902 set(handles.Patch1,'Visible','off') 3903 end 3904 return 3905 set(handles.frame_patch1,'BackgroundColor',[1 1 0]) 3906 set(handles.rho_patch1,'Visible','on') 3907 set(handles.rho_text1,'Visible','on') 3908 if get(handles.ListPairMode,'Value')==2 3909 set(handles.thresh_patch1,'Visible','on') 3910 set(handles.thresh_text1,'Visible','on') 3911 end 3912 set(handles.subdomain_patch1,'Visible','on') 3913 set(handles.subdomain_text1,'Visible','on') 3914 set(handles.nx_patch1,'Visible','on') 3915 set(handles.num_Ny,'Visible','on') 3916 set(handles.nx_patch1_title,'Visible','on') 3917 set(handles.ny_patch1_title,'Visible','on') 3918 % if ~isempty(patch_newBin) 3919 set(handles.test_interp,'Visible','off'); 3920 stereo_test=get(handles.ListCompareMode,'Value'); 3921 if stereo_test==3 3922 set(handles.test_stereo1,'Visible','on') 3923 end 3924 % end 3925 %set(handles.get_gridpatch1,'Visible','on') 3926 %set(handles.grid_patch1,'string','none'); 3927 %set(handles.grid_patch1,'Visible','on') 3928 3929 % %------------------------------------------------------------------------ 3930 % function desable_patch1(handles) 3931 % %------------------------------------------------------------------------ 3932 % return 3933 % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) 3934 % set(handles.rho_patch1,'Visible','off') 3935 % set(handles.rho_text1,'Visible','off') 3936 % set(handles.thresh_patch1,'Visible','off') 3937 % set(handles.thresh_text1,'Visible','off') 3938 % set(handles.subdomain_patch1,'Visible','off') 3939 % set(handles.subdomain_text1,'Visible','off') 3940 % set(handles.nx_patch1,'Visible','off') 3941 % set(handles.num_Ny,'Visible','off') 3942 % set(handles.nx_patch1_title,'Visible','off') 3943 % set(handles.ny_patch1_title,'Visible','off') 3944 % set(handles.test_stereo1,'Visible','off') 3945 % %set(handles.test_interp,'Visible','off') 3946 % %set(handles.get_gridpatch1,'Visible','off') 3947 % %set(handles.grid_patch1,'Visible','off') 3948 % 3949 % %------------------------------------------------------------------------ 3950 % function enable_civ2(handles,state) 3951 % %------------------------------------------------------------------------ 3952 % if state 3953 % RootName=get(handles.RootName,'String'); 3954 % if isempty(RootName) 3955 % msgbox_uvmat('ERROR','No input file') 3956 % return 3957 % end 3958 % set(handles.Civ2,'Visible','on') 3959 % set(handles.ListSubdirCiv2,'Visible','on') 3960 % set(handles.SubdirCiv2,'Visible','on') 3961 % set(handles.TitleSubdirCiv2,'Visible','on') 3962 % else 3963 % set(handles.Civ2,'Visible','off') 3964 % end 3965 3966 % 3967 % set(handles.num_Bx,'Visible',state) 3968 % set(handles.num_By,'Visible',state) 3969 % set(handles.CheckDecimal,'Visible',state) 3970 % set(handles.CheckDeformation,'Visible',state) 3971 % set(handles.num_Rho,'Visible',state) 3972 % set(handles.num_Dx,'Visible',state) 3973 % set(handles.num_Dy,'Visible',state) 3974 % set(handles.CheckGrid,'Visible',state) 3975 % set(handles.CheckMask,'Visible',state) 3976 % set(handles.parameters,'Visible',state) 3977 % set(handles.grid,'Visible',state) 3978 % set(handles.parameters_text,'Visible',state) 3979 % set(handles.grid_text,'Visible',state) 3980 % set(handles.txt_GridName,'Visible',state) 3981 % set(handles.txt_Mask,'Visible',state) 3982 % set(handles.dx_civ2_title,'Visible',state) 3983 % set(handles.dy_civ2_title,'Visible',state) 3984 % set(handles.ibx_civ2_text,'Visible',state) 3985 % set(handles.rho_civ2_title,'Visible',state) 3986 % set(handles.ImaThreshold2,'Visible',state) 3987 % set(handles.ImaThreshold_title2,'Visible',state) 3988 % if isequal(state,'off') 3989 % set(handles.num_MinIma,'Visible','off') 3990 % set(handles.num_MaxIma,'Visible','off') 3991 % set(handles.ImaThreshold2,'Value',0) 3992 % if isequal(get(handles.CheckFix2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) 3993 % set(handles.ListPairCiv2,'Visible','off') 3994 % set(handles.txt_SubdirCiv2,'Visible','off') 3995 % set(handles.TitleSubdirCiv2,'Visible','off') 3996 % set(handles.dt_unit_civ2,'Visible','off') 3997 % %set(handles.ref_i_civ2,'Visible','off') 3998 % set(handles.i_ref_civ2_title,'Visible','off') 3999 % set(handles.j_ref_civ2_title,'Visible','off') 4000 % set(handles.ref_j_civ2,'Visible','off') 4001 % end 4002 % else 4003 % set(handles.ListPairCiv2,'Visible','on') 4004 % set(handles.txt_SubdirCiv2,'Visible','on') 4005 % set(handles.TitleSubdirCiv2,'Visible','on') 4006 % set(handles.dt_unit_civ2,'Visible','on') 4007 % % set(handles.ref_i_civ2,'Visible','on') 4008 % set(handles.i_ref_civ2_title,'Visible','on') 4009 % set(handles.j_ref_civ2_title,'Visible','on') 4010 % set(handles.ref_j_civ2,'Visible','on') 4011 % end 4012 % set(handles.rho_civ2_title,'Visible',state) 4013 4014 %------------------------------------------------------------------------ 4015 function enable_fix2(handles,state) 4016 %------------------------------------------------------------------------ 4017 % if isequal(state,'on') 4018 % set(handles.Fix2,'Visible','on') 4019 % 4020 % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) 4021 % % set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) 4022 % % set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) 4023 % % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) 4024 % else 4025 if state 4026 RootName=get(handles.RootName,'String'); 4027 if isempty(RootName) 4028 msgbox_uvmat('ERROR','No input file') 4029 return 4030 end 4031 set(handles.Fix2,'Visible','on') 4032 else 4033 set(handles.Fix2,'Visible','off') 4034 end 4035 4036 % set(handles.frame_fix2,'BackgroundColor',[1 1 0]) 4037 % set(handles.REMOVE2,'Visible','on') 4038 % set(handles.CheckFmin2,'Visible','on') 4039 % set(handles.CheckF4,'Visible','on') 4040 % set(handles.CheckF3,'Visible','on') 4041 % set(handles.num_MinCorr,'Visible','on') 4042 % set(handles.thresh_vec2C_text,'Visible','on') 4043 % set(handles.num_MinVel,'Visible','on') 4044 % set(handles.TitleMinVel,'Visible','on') 4045 % set(handles.txt_MaskName,'Visible','on') 4046 % set(handles.CheckMask,'Visible','on') 4047 % set(handles.ListPairCiv2,'Visible','on') 4048 % set(handles.txt_SubdirCiv2,'Visible','on') 4049 % set(handles.TitleSubdirCiv2,'Visible','on') 4050 % set(handles.get_ref_fix2,'Visible','on') 4051 % set(handles.ref_fix2,'Visible','on') 4052 % set(handles.num_MinVel,'Visible','on') 4053 % set(handles.field_ref2,'Visible','on') 4054 4055 % %------------------------------------------------------------------------ 4056 % function desable_fix2(handles) 4057 % %------------------------------------------------------------------------ 4058 % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) 4059 % set(handles.REMOVE2,'Visible','off') 4060 % set(handles.CheckFmin2,'Visible','off') 4061 % set(handles.CheckF4,'Visible','off') 4062 % set(handles.CheckF3,'Visible','off') 4063 % set(handles.num_MinCorr,'Visible','off') 4064 % set(handles.thresh_vec2C_text,'Visible','off') 4065 % set(handles.num_MinVel,'Visible','off') 4066 % set(handles.TitleMinVel,'Visible','off') 4067 % set(handles.txt_MaskName,'Visible','off') 4068 % set(handles.CheckMask,'Visible','off') 4069 % set(handles.get_ref_fix2,'Visible','off') 4070 % set(handles.ref_fix2,'Visible','off') 4071 % set(handles.num_MinVel,'Visible','off') 4072 % set(handles.field_ref2,'Visible','off') 4073 % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) 4074 % set(handles.ListPairCiv2,'Visible','off') 4075 % set(handles.txt_SubdirCiv2,'Visible','off') 4076 % set(handles.TitleSubdirCiv2,'Visible','off') 4077 % end 4078 4079 %------------------------------------------------------------------------ 4080 function enable_patch2(handles,state) 4081 %------------------------------------------------------------------------ 4082 if state 4083 RootName=get(handles.RootName,'String'); 4084 if isempty(RootName) 4085 msgbox_uvmat('ERROR','No input file') 4086 return 4087 end 4088 set(handles.Patch2,'Visible','on') 4089 else 4090 set(handles.Patch2,'Visible','off') 4091 end 4092 % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) 4093 % set(handles.num_SmoothingParam,'Visible','on') 4094 % set(handles.num_SmoothingParam,'Visible','on') 4095 % set(handles.num_MaxDiff,'Visible','on') 4096 % set(handles.thresh_text2,'Visible','on') 4097 % set(handles.num_SubdomainSize,'Visible','on') 4098 % set(handles.subdomain_text2,'Visible','on') 4099 % set(handles.num_Nx,'Visible','on') 4100 % set(handles.num_Ny,'Visible','on') 4101 % set(handles.nx_patch2_title,'Visible','on') 4102 % set(handles.ny_patch2_title,'Visible','on') 4103 % % set(handles.get_gridpatch2,'Visible','on') 4104 % % set(handles.grid_patch2,'Visible','on') 4105 % set(handles.ListPairCiv2,'Visible','on') 4106 % set(handles.txt_SubdirCiv2,'Visible','on') 4107 % set(handles.TitleSubdirCiv2,'Visible','on') 4108 % stereo_test=get(handles.ListCompareMode,'Value'); 4109 % if stereo_test==3 4110 % set(handles.CheckStereo,'Visible','on') 4111 % end 4112 4113 % %------------------------------------------------------------------------ 4114 % function desable_patch2(handles) 4115 % %------------------------------------------------------------------------ 4116 % %set(handles.checkpatch2,'Visible','off') 4117 % return 4118 % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) 4119 % set(handles.num_SmoothingParam,'Visible','off') 4120 % set(handles.num_SmoothingParam,'Visible','off') 4121 % set(handles.num_MaxDiff,'Visible','off') 4122 % set(handles.thresh_text2,'Visible','off') 4123 % set(handles.num_SubdomainSize,'Visible','off') 4124 % set(handles.subdomain_text2,'Visible','off') 4125 % set(handles.num_Nx,'Visible','off') 4126 % set(handles.num_Ny,'Visible','off') 4127 % set(handles.nx_patch2_title,'Visible','off') 4128 % set(handles.ny_patch2_title,'Visible','off') 4129 % % set(handles.get_gridpatch2,'Visible','off') 4130 % % set(handles.grid_patch2,'Visible','off') 4131 % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckFix2,'Value'),0) 4132 % set(handles.ListPairCiv2,'Visible','off') 4133 % set(handles.txt_SubdirCiv2,'Visible','off') 4134 % set(handles.TitleSubdirCiv2,'Visible','off') 4135 % end 4136 % set(handles.CheckStereo,'Visible','off') 4137 % %------------------------------------------------------------------------ 4138 % function enable_pair1(handles,state) 4139 % %------------------------------------------------------------------------ 4140 % set(handles.txt_SubdirCiv1,'Visible',state) 4141 % set(handles.ListSubdirCiv1,'Visible',state) 4142 % set(handles.TitleSubdirCiv1,'Visible',state) 4143 % %set(handles.frame_subdirciv1,'Visible',state) 4144 % set(handles.ListPairCiv1,'Visible',state) 4145 % set(handles.TitlePairCiv1,'Visible',state) 4146 % %set(handles.dt_unit,'Visible',state) 4147 % %set(handles.PAIR_frame,'Visible',state) 4148 4149 %------------------------------------------------------------------------ 4150 % --- Read the parameters for checkciv1 on the interface 4151 % function par=read_param_civ1(handles,filecell) 4152 % % not deeden anymore 4153 % %------------------------------------------------------------------------ 4154 % ibx_val=str2double(get(handles.num_Bx,'String')); 4155 % par.ibx=num2str(ibx_val); 4156 % iby_val=str2double(get(handles.num_By,'String')); 4157 % par.iby=num2str(iby_val); 4158 % isx=get(handles.num_Searchx,'String'); 4159 % if isnan(str2double(isx)), isx='41'; set(handles.num_Searchx,'String','41'), end; %default 4160 % if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.num_Searchx,'String',num2str(ibx_val+8)); end 4161 % isy=get(handles.num_Searchy,'String'); 4162 % if isnan(str2double(isy)), isy='41'; set(handles.num_Searchy,'String','41'), end;%default 4163 % if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.num_Searchy,'String',num2str(iby_val+8)); end 4164 % par.isx=get(handles.num_Searchx,'String'); 4165 % par.isy=get(handles.num_Searchy,'String'); 4166 % par.shiftx=get(handles.num_Shiftx,'String'); 4167 % par.shifty=get(handles.num_Shifty,'String'); 4168 % if isnan(str2double(par.isx)) 4169 % par.isx='41';%default 4170 % set(handles.num_Searchx,'String','41'); 4171 % end 4172 % if isnan(str2double(par.isy)) 4173 % par.isy='41'; %default 4174 % set(handles.num_Searchy,'String','41'); 4175 % end 4176 % if isnan(str2double(par.shiftx)) 4177 % par.shiftx='0';%default 4178 % set(handles.num_Shiftx,'String','0'); 4179 % end 4180 % if isnan(str2double(par.shifty)) 4181 % par.shifty='0'; %default 4182 % set(handles.num_Shifty,'String','0'); 4183 % end 4184 % par.rho=get(handles.num_Rho,'String'); 4185 % if isequal(get(handles.num_Rho,'Style'),'popupmenu') 4186 % index=get(handles.num_Rho,'Value'); 4187 % par.rho=par.rho{index}; 4188 % end 4189 % dummy=get(handles.num_Dx,'String'); 4190 % par.dx=dummy{1}; 4191 % dummy=get(handles.num_Dy,'String'); 4192 % par.dy=dummy{1}; 4193 % if isnan(str2double(par.dx)) 4194 % if isempty(get(handles.txt_GridName,'String')); 4195 % par.dx='0'; %just read by civ program, not used 4196 % else 4197 % par.dx='20';%default 4198 % set(handles.num_Dx,'String','20'); 4199 % end 4200 % end 4201 % if isnan(str2double(par.dy)) 4202 % if isempty(get(handles.txt_GridName,'String')); 4203 % par.dy='0';%just read by civ program, not used 4204 % else 4205 % par.dy='20';%default 4206 % set(handles.dy_civ1_title,'String','20'); 4207 % end 4208 % end 4209 % par.pxcmx='1'; %velocities are expressed in pixel dispalcement 4210 % par.pxcmy='1'; 4211 % % if exist('file_ima','var') 4212 % A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size 4213 % sizim=size(A); 4214 % par.npx=num2str(sizim(2)); 4215 % par.npy=num2str(sizim(1)); 4216 % %TODO : civ should not need npx and npy 4217 % 4218 % 4219 % % end 4220 % %time=get(handles.RootName,'UserData'); %get the set of times 4221 % dummy=get(handles.txt_GridName,'String'); 4222 % par.gridname=dummy{1}; 4223 % par.gridflag='y'; 4224 % if strcmp(par.gridname,'')|| isempty(par.gridname) 4225 % par.gridname='nogrid'; 4226 % par.gridflag='n'; 4227 % end 4228 % 4229 4230 4231 %------------------------------------------------------------------------ 4232 function par=read_param_civ2(handles,file_ima) 4233 %------------------------------------------------------------------------ 4234 par.ibx=get(handles.num_Bx,'String'); 4235 par.iby=get(handles.num_By,'String'); 4236 par.rho=get(handles.num_Rho,'String'); 4237 par.decimal=int2str(get(handles.CheckDecimal,'Value')); 4238 par.deformation=int2str(get(handles.CheckDeformation,'Value')); 4239 par.dx=get(handles.num_Dx,'String'); 4240 par.dy=get(handles.num_Dy,'String'); 4241 if isnan(str2double(par.dx)) 4242 if isempty(get(handles.txt_GridName,'String')); 4243 par.dx='0'; %just read by civ program, not used 4244 else 4245 par.dx='20';%default 4246 set(handles.num_Dx,'String','20'); 4247 end 4248 end 4249 if isnan(str2double(par.dy)) 4250 if isempty(get(handles.txt_GridName,'String')); 4251 par.dy='0';%just read by civ program, not used 4252 else 4253 par.dy='20';%default 4254 set(handles.num_Dy,'String','20'); 4255 end 4256 end 4257 par.pxcmx='1'; 4258 par.pxcmy='1'; 4259 A=imread(file_ima);%read the first image to get the size 4260 sizim=size(A); 4261 par.npx=num2str(sizim(2)); 4262 par.npy=num2str(sizim(1)); 4263 %time=get(handles.RootName,'UserData'); %get the set of times 4264 par.gridname=get(handles.txt_GridName,'String'); 4265 par.gridflag='y'; 4266 if strcmp(par.gridname,'')|| isempty(par.gridname) 4267 par.gridname='nogrid'; 4268 par.gridflag='n'; 4269 end 4270 4271 % function cmd_CIV1=CIV1_CMD(filename,param) 4272 % %TODO : include filename in par_civ1 4273 % %------------------------------------------------------------------------ 4274 % %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4275 % 4276 % %changes : filename_cmx -> filename ( no extension ) 4277 % 4278 % filename=regexprep(filename,'.nc',''); 4279 % 4280 % if isequal(Param.Civ1.Dt,'0') 4281 % Param.Civ1.Dt='1' ;%case of 'displacement' mode 4282 % end 4283 % Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); 4284 % Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); 4285 % fid=fopen([filename '.civ1.cmx'],'w'); 4286 % fprintf(fid,['############## CMX file' '\n' ]); 4287 % fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility 4288 % fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility 4289 % fprintf(fid, ['XX' '\n' ]); 4290 % fprintf(fid, ['Mask ' Param.Civ1.maskflag '\n' ]); 4291 % fprintf(fid, ['MaskName ' regexprep(Param.Civ1.maskname,'\\','\\\\') '\n' ]); 4292 % fprintf(fid, ['ImageSize ' Param.Civ1.npx ' ' Param.Civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? 4293 % fprintf(fid, ['CorrelationBoxesSize ' Param.Civ1.ibx ' ' Param.Civ1.iby '\n' ]); 4294 % fprintf(fid, ['SearchBoxeSize ' Param.Civ1.isx ' ' Param.Civ1.isy '\n' ]); 4295 % fprintf(fid, ['RO ' Param.Civ1.rho '\n' ]); 4296 % fprintf(fid, ['GridSpacing ' Param.Civ1.dx ' ' Param.Civ1.dy '\n' ]); 4297 % fprintf(fid, ['XX 1.0' '\n' ]); 4298 % fprintf(fid, ['Dt_TO ' Param.Civ1.Dt ' ' Param.Civ1.T0 '\n' ]); 4299 % fprintf(fid, ['PixCmXY ' Param.Civ1.pxcmx ' ' Param.Civ1.pxcmy '\n' ]); 4300 % fprintf(fid, ['XX 1' '\n' ]); 4301 % fprintf(fid, ['ShiftXY ' Param.Civ1.shiftx ' ' Param.Civ1.shifty '\n' ]); 4302 % fprintf(fid, ['Grid ' Param.Civ1.gridflag '\n' ]); 4303 % fprintf(fid, ['GridName ' regexprep(Param.Civ1.gridname,'\\','\\\\') '\n' ]); 4304 % fprintf(fid, ['XX 85' '\n' ]); 4305 % fprintf(fid, ['XX 1.0' '\n' ]); 4306 % fprintf(fid, ['XX 1.0' '\n' ]); 4307 % fprintf(fid, ['Hart 1' '\n' ]); 4308 % fprintf(fid, [ 'DecimalShift 0' '\n' ]); 4309 % fprintf(fid, ['Deformation 0' '\n' ]); 4310 % fprintf(fid, ['CorrelationMin 0' '\n' ]); 4311 % fprintf(fid, ['IntensityMin 0' '\n' ]); 4312 % fprintf(fid, ['SeuilImage n' '\n' ]); 4313 % fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); 4314 % fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? 4315 % fprintf(fid, ['ImageUsedBefore null null' '\n' ]); 4316 % fclose(fid); 4317 % 4318 % % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file 4319 % % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); 4320 % % namelog=regexprep(namelog,'\\','\\\\'); 4321 % if(isunix) 4322 % cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; 4323 % cmd_CIV1=[cmd_CIV1 '\n'... 4324 % Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx 4325 % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting 4326 % % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv1.cmx' '\n'];%rename .cmx as .checkciv1.cmx 4327 % else %Windows system 4328 % % flname=regexprep(flname,'\\','\\\\'); 4329 % % cmd=[cmd 'copy /Y "' flname '.checkciv1.cmx" "' flname '.cmx"\n']; 4330 % % filename=regexprep(filename,'\\','\\\\'); 4331 % cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx 4332 % cmd_CIV1=[cmd_CIV1 '\n "' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file 4333 % % namelog=regexprep(namelog,'\\','\\\\'); 4334 % cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log 4335 % 4336 % % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv1.cmx"']; 4337 % end 4338 4339 %------------------------------------------------------------------------ 4340 % --- CheckCiv1 Unified 4341 function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) 4342 %------------------------------------------------------------------------ 4343 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4344 %global CivBin%name of the executable for checkciv1 calculation 4345 4346 civ1.image1=par.filename_ima_a; 4347 civ1.image2=par.filename_ima_b; 4348 civ1.imageSize_X=par.npx; 4349 civ1.imageSize_Y=par.npy; 4350 civ1.outputFileName=[filename '.nc']; 4351 civ1.correlationBoxesSize_X=par.ibx; 4352 civ1.correlationBoxesSize_Y=par.iby; 4353 civ1.searchBoxesSize_X=par.isx; 4354 civ1.searchBoxesSize_Y=par.isy; 4355 civ1.globalShift_X=par.shiftx; 4356 civ1.globalShift_Y=par.shifty; 4357 civ1.ro=par.rho; 4358 civ1.hart='y'; 4359 if isequal(par.gridflag,'y') 4360 civ1.grid=par.gridname; 4361 else 4362 civ1.grid='n'; 4363 civ1.gridSpacing_X=par.dx; 4364 civ1.gridSpacing_Y=par.dy; 4365 end 4366 if isequal(par.maskflag,'y') 4367 civ1.mask=par.maskname; 4368 end 4369 civ1.dt=par.Dt; 4370 civ1.unit='pixel'; 4371 civ1.absolut_time_T0=par.T0; 4372 civ1.pixcmx=par.pxcmx; 4373 civ1.pixcmy=par.pxcmy; 4374 civ1.convectFlow='n'; 4375 4376 xml_civ1_parameters=civ1; 4377 4378 %------------------------------------------------------------------------ 4379 % --- CheckCiv2 Unified 4380 function civ2=CIV2_CMD_Unified(filename,namelog,par) 4381 %------------------------------------------------------------------------ 4382 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4383 %global CivBin%name of the executable for checkciv1 calculation 4384 4385 filename=regexprep(filename,'.nc',''); 4386 4387 civ2.image1=par.filename_ima_a; 4388 civ2.image2=par.filename_ima_b; 4389 civ2.imageSize_X=par.npx; 4390 civ2.imageSize_Y=par.npy; 4391 civ2.inputFileName=[par.filename_nc1 '.nc']; 4392 civ2.outputFileName=[filename '.nc']; 4393 civ2.correlationBoxesSize_X=par.ibx; 4394 civ2.correlationBoxesSize_Y=par.iby; 4395 civ2.ro=par.rho; 4396 %checkciv2.decimalShift=par.CheckDecimal; 4397 %checkciv2.CheckDeformation=par.CheckDeformation; 4398 if isequal(par.decimal,'1') 4399 civ2.decimalShift='y'; 4400 else 4401 civ2.decimalShift='n'; 4402 end 4403 if isequal(par.deformation,'1') 4404 civ2.deformation='y'; 4405 else 4406 civ2.deformation='n'; 4407 end 4408 if isequal(par.gridflag,'y') 4409 civ2.grid=par.gridname; 4410 else 4411 civ2.grid='n'; 4412 civ2.gridSpacing_X=par.dx; 4413 civ2.gridSpacing_Y=par.dy; 4414 end 4415 civ2.gridSpacing_X='10'; 4416 civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee 4417 if isequal(par.maskflag,'y') 4418 civ2.mask=par.maskname; 4419 else 4420 civ2.mask='n'; 4421 end 4422 civ2.dt=par.Dt; 4423 civ2.unit='pixel'; 4424 civ2.absolut_time_T0=par.T0; 4425 civ2.pixcmx=par.pxcmx; 4426 civ2.pixcmy=par.pxcmy; 4427 civ2.convectFlow='n'; 4428 civ2.pixcmx=par.pxcmx; 4429 civ2.pixcmy=par.pxcmy; 4430 civ2.convectFlow='n'; 4431 4432 % %------------------------------------------------------------------------ 4433 % % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 4434 % function cmd_CIV2=CIV2_CMD(filename,param) 4435 % %------------------------------------------------------------------------ 4436 % %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4437 % % global civ2Bin sge%name of the executable for checkciv1 calculation 4438 % filename=regexprep(filename,'.nc',''); 4439 % if isequal(Param.Civ2.Dt,'0') 4440 % Param.Civ2.Dt='1' ;%case of 'displacement' mode 4441 % end 4442 % Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); 4443 % Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? 4444 % [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); 4445 % if isequal(fid,-1) 4446 % msgbox_uvmat('ERROR',errormsg) 4447 % cmd_CIV2=''; 4448 % return 4449 % end 4450 % fprintf(fid,['############## CMX file' '\n' ]); 4451 % fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility 4452 % fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility 4453 % fprintf(fid, ['XX' '\n' ]); 4454 % fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); 4455 % fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility 4456 % fprintf(fid, ['ImageSize ' Param.Civ2.npx ' ' Param.Civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? 4457 % fprintf(fid, ['CorrelationBoxesSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n' ]); 4458 % fprintf(fid, ['SearchBoxeSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n']); 4459 % fprintf(fid, ['RO ' Param.Civ2.rho '\n']); 4460 % fprintf(fid, ['GridSpacing ' Param.Civ2.dx ' ' Param.Civ2.dy '\n']); 4461 % fprintf(fid, ['XX 1.0' '\n' ]); 4462 % fprintf(fid, ['Dt_TO ' Param.Civ2.Dt ' ' Param.Civ2.T0 '\n' ]); 4463 % fprintf(fid, ['PixCmXY ' Param.Civ2.pxcmx ' ' Param.Civ2.pxcmy '\n' ]); 4464 % fprintf(fid, ['XX 1' '\n' ]); 4465 % fprintf(fid, 'ShiftXY 0 0\n'); 4466 % fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); 4467 % fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); 4468 % fprintf(fid, ['XX 85' '\n' ]); 4469 % fprintf(fid, ['XX 1.0' '\n' ]); 4470 % fprintf(fid, ['XX 1.0' '\n' ]); 4471 % fprintf(fid, ['Hart 1' '\n' ]); 4472 % fprintf(fid, ['DecimalShift ' Param.Civ2.decimal '\n']); 4473 % fprintf(fid, ['Deformation ' Param.Civ2.deformation '\n']); 4474 % fprintf(fid, ['CorrelationMin 0' '\n' ]); 4475 % fprintf(fid, ['IntensityMin 0' '\n' ]); 4476 % fprintf(fid, ['SeuilImage n' '\n' ]); 4477 % fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); 4478 % fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? 4479 % fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); 4480 % fclose(fid); 4481 % 4482 % if(isunix) 4483 % cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; 4484 % cmd_CIV2=[cmd_CIV2 Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx 4485 % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log 4486 % % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv2.cmx' '\n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx 4487 % 4488 % else 4489 % filename=regexprep(filename,'\\','\\\\'); 4490 % cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; 4491 % cmd_CIV2=[cmd_CIV2 '\n "' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file 4492 % cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; 4493 % % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv2.cmx"']; 4494 % end 4495 3741 3742 %------------------------------------------------------------------------ 3743 % --- STEREO Interp 3744 function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) 3745 %------------------------------------------------------------------------ 3746 namelog=[filename_nc(1:end-3) '_stinterp.log']; 3747 cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... 3748 ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file 4496 3749 4497 3750 %------------------------------------------------------------------------ … … 4517 3770 end 4518 3771 4519 %------------------------------------------------------------------------4520 function ref_i_Callback(hObject, eventdata, handles)4521 %------------------------------------------------------------------------4522 mode_list=get(handles.ListPairMode,'String');4523 mode_value=get(handles.ListPairMode,'Value');4524 mode=mode_list{mode_value};4525 find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files4526 if isequal(mode,'series(Di)') || ...% we do patch2 only4527 (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)4528 find_netcpair_civ2( handles);4529 end4530 4531 %------------------------------------------------------------------------4532 function ref_j_Callback(hObject, eventdata, handles)4533 %------------------------------------------------------------------------4534 mode_list=get(handles.ListPairMode,'String');4535 mode_value=get(handles.ListPairMode,'Value');4536 mode=mode_list{mode_value};4537 if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)')4538 find_netcpair_civ1(handles);% update the menu of pairs depending on the available netcdf files4539 end4540 if isequal(mode,'series(Dj)') || ...4541 (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)4542 find_netcpair_civ2(handles);4543 end4544 %4545 % %------------------------------------------------------------------------4546 % function ref_i_civ2_Callback(hObject, eventdata, handles)4547 % %------------------------------------------------------------------------4548 % % mode_list=get(handles.ListPairMode,'String');4549 % % mode_value=get(handles.ListPairMode,'Value');4550 % % mode=mode_list{mode_value};4551 % find_netcpair_civ2(handles);% update the menu of pairs depending on the available netcdf files4552 %4553 % %------------------------------------------------------------------------4554 % function ref_j_civ2_Callback(hObject, eventdata, handles)4555 % %------------------------------------------------------------------------4556 % % mode_list=get(handles.ListPairMode,'String');4557 % % mode_value=get(handles.ListPairMode,'Value');4558 % % mode=mode_list{mode_value};4559 % if isequal(mode,'series(Dj)')4560 % find_netcpair_civ2(handles);% update the menu of pairs depending on the available netcdf files4561 % end4562 4563 %------------------------------------------------------------------------4564 % --- Executes on button press in ListCompareMode.4565 function ListCompareMode_Callback(hObject, eventdata, handles)4566 %------------------------------------------------------------------------4567 test=get(handles.ListCompareMode,'Value');4568 if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV'4569 filebase=get(handles.RootName,'String');4570 browse=get(handlesRootName,'Userdata');4571 browse.nom_type_ima1=browse.nom_type_ima;4572 set(handlesRootName,'UserData',browse);4573 set(handles.sub_txt,'Visible','on')4574 set(handles.RootName_1,'Visible','On');%mkes the second file input window visible4575 mode_store=get(handles.ListPairMode,'String');%get the present 'mode'4576 set(handles.ListCompareMode,'UserData',mode_store);%store the mode display4577 set(handles.ListPairMode,'Visible','off')4578 if test==24579 set(handles.ListPairMode,'Visible','off')4580 set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default4581 else4582 set(handles.ListPairMode,'Visible','on')4583 set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo4584 end4585 4586 %% menuopen an image file with the browser4587 ind_opening=1;%default4588 browse.incr_pair=[0 0]; %default4589 oldfile=get(handles.RootName,'String');4590 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';4591 '*.xml', '.xml files '; ...4592 '*.civ', '.civ files '; ...4593 '*.png','.png image files'; ...4594 '*.jpg',' jpeg image files'; ...4595 '*.tif','.tif image files'; ...4596 '*.avi;*.AVI','.avi movie files'; ...4597 '*.nc','.netcdf files'; ...4598 '*.*', 'All Files (*.*)'};4599 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile);4600 fileinput=[PathName FileName];%complete file name4601 sizf=size(fileinput);4602 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string4603 [path,name,ext]=fileparts(fileinput);4604 [path1]=fileparts(filebase);4605 if isunix4606 [status,path]=system(['readlink ' path]);4607 [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths4608 end4609 if ~strcmp(path1,path)4610 msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one')4611 return4612 end4613 % set(handles.RootName_1,'String',name);4614 [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);4615 set(handles.RootName_1,'String',RootFile);4616 browse=get(handlesRootName,'UserData');4617 browse.nom_type_ima_1=nom_type;4618 set(handlesRootName,'UserData',browse)4619 4620 %check image extension4621 if ~strcmp(ext,get(handles.ImaExt,'String'))4622 msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one')4623 return4624 end4625 4626 %% check coincidence of image sizes4627 % ref_i=get(handles.ref_i,'string');4628 % ref_j=get(handles.ref_j,'string');4629 % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);4630 % A=imread(filecell.ima1.checkciv1{1});4631 % A_1=imread(fileinput);4632 % npxy=size(A);4633 % npxy_1=size(A_1);4634 % if ~isequal(size(A),size(A_1))4635 % msgbox_uvmat('ERROR','The two input image series do not have the same size')4636 % return4637 % end4638 else4639 set(handles.ListPairMode,'Visible','on')4640 set(handles.RootName_1,'Visible','Off');4641 set(handles.sub_txt,'Visible','off')4642 set(handles.RootName_1,'String',[]);4643 mode_store=get(handles.ListCompareMode,'UserData');4644 set(handles.ListPairMode,'Value',1)4645 set(handles.ListPairMode,'String',mode_store)4646 set(handles.test_stereo1,'Value',0)4647 set(handles.CheckStereo,'Value',0)4648 set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default4649 end4650 if test==3 && get(handles.CheckPatch1,'Value')4651 set(handles.test_stereo1,'Visible','on')4652 else4653 set(handles.test_stereo1,'Visible','off')4654 end4655 if test==3 && get(handles.CheckPatch2,'Value')4656 set(handles.CheckStereo,'Visible','on')4657 else4658 set(handles.CheckStereo,'Visible','off')4659 end4660 mode_Callback(hObject, eventdata, handles)4661 3772 4662 3773 %------------------------------------------------------------------------ … … 4799 3910 4800 3911 %------------------------------------------------------------------------ 4801 % --- Executes on button press in check_Threshold.4802 function ImaThreshold_Callback(hObject, eventdata, handles)4803 %------------------------------------------------------------------------4804 if isequal(get(handles.check_Threshold,'Value'),1)4805 set(handles.num_MinIma,'Visible','on')4806 set(handles.num_MaxIma,'Visible','on')4807 else4808 set(handles.num_MinIma,'Visible','off')4809 set(handles.num_MaxIma,'Visible','off')4810 end4811 4812 %------------------------------------------------------------------------4813 % --- Executes on button press in ImaThreshold2.4814 function ImaThreshold2_Callback(hObject, eventdata, handles)4815 %------------------------------------------------------------------------4816 if isequal(get(handles.ImaThreshold2,'Value'),1)4817 set(handles.num_MinIma,'Visible','on')4818 set(handles.num_MaxIma,'Visible','on')4819 else4820 set(handles.num_MinIma,'Visible','off')4821 set(handles.num_MaxIma,'Visible','off')4822 end4823 4824 %------------------------------------------------------------------------4825 3912 % --- Executes on button press in TestCiv1: display image correlation function 4826 3913 function TestCiv1_Callback(hObject, eventdata, handles) … … 4828 3915 set(handles.TestCiv1,'BackgroundColor',[1 1 0]) 4829 3916 drawnow 4830 test_civ1=get(handles.TestCiv1,'Value'); 4831 if test_civ1 3917 if get(handles.TestCiv1,'Value') 4832 3918 ref_i=str2double(get(handles.ref_i,'String')); 4833 3919 if strcmp(get(handles.ref_j,'Visible'),'on') … … 4843 3929 Data.ny=[size(Data.A,1) 1]; 4844 3930 Data.nx=[1 size(Data.A,2)]; 4845 par_civ1=read_ param_civ1(handles,filecell.ima1.civ1{1});3931 par_civ1=read_GUI(handles.Civ1); 4846 3932 par_civ1.filename_ima_a=filecell.ima1.civ1{1}; 4847 3933 par_civ1.filename_ima_b=filecell.ima2.civ1{1}; … … 4884 3970 end 4885 3971 3972 %------------------------------------------------------------------- 3973 % --- 4886 3974 function closeview_field(gcbo,eventdata) 4887 3975 hview_field=findobj(allchild(0),'tag','view_field');% look for view_field … … 4889 3977 delete(hview_field) 4890 3978 end 4891 %------------------------------------------------------------------- 4892 % --- Executes on button press in status. 4893 function status_Callback(hObject, eventdata, handles) 4894 %------------------------------------------------------------------- 4895 val=get(handles.status,'Value'); 4896 if val==0 4897 set(handles.status,'BackgroundColor',[0 1 0]) 4898 hfig=findobj(allchild(0),'name','civ_status'); 4899 if ~isempty(hfig) 4900 delete(hfig) 4901 end 4902 return 4903 end 4904 set(handles.status,'BackgroundColor',[1 1 0]) 4905 drawnow 4906 listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; 4907 Param.CheckCiv1=get(handles.CheckCiv1,'Value'); 4908 Param.CheckFix1=get(handles.CheckFix1,'Value'); 4909 Param.CheckPatch1=get(handles.CheckPatch1,'Value'); 4910 Param.CheckCiv2=get(handles.CheckCiv2,'Value'); 4911 Param.CheckFix2=get(handles.CheckFix2,'Value'); 4912 Param.CheckPatch2=get(handles.CheckPatch2,'Value'); 4913 box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; 4914 4915 option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) 4916 filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV 4917 test_new=0; 4918 if ~isfield(filecell,'nc') 4919 test_new=1; 4920 [ref_i,ref_j,errormsg]=find_ref_indices(handles); 4921 if ~isempty(errormsg) 4922 msgbox_uvmat('ERROR',errormsg) 4923 return 4924 end 4925 filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status 4926 end 4927 if ~isequal(box_test(4:6),[0 0 0]) 4928 civ_files=filecell.nc.civ2;%case of civ2 operations 4929 else 4930 civ_files=filecell.nc.civ1; 4931 end 4932 [root,filename,ext]=fileparts(civ_files{1}); 4933 [rootroot,subdir,extdir]=fileparts(root); 4934 hfig=findobj(allchild(0),'name','civ_status'); 4935 if isempty(hfig) 4936 hfig=figure('DeleteFcn',@stop_status); 4937 set(hfig,'name','civ_status') 4938 hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); 4939 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); 4940 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 4941 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); 4942 BarPosition=[0.05 0.81 0.01 0.05]; 4943 hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); 4944 drawnow 4945 end 4946 % datnum=[]; 4947 Tabchar={}; 4948 nbfiles=numel(civ_files); 4949 count=0; 4950 testrecent=0; 4951 while count<nbfiles 4952 count=0; 4953 datnum=zeros(1,nbfiles); 4954 for ifile=1:nbfiles 4955 detect=exist(civ_files{ifile},'file'); % check the existence of the file 4956 option=0; 4957 if detect==0 4958 option_str='not created'; 4959 else 4960 datfile=dir(civ_files{ifile}); 4961 if isfield(datfile,'datenum') 4962 datnum(ifile)=datfile.datenum;%only available in recent matlab versions 4963 testrecent=1; 4964 end 4965 filefound(ifile)={datfile.name}; 4966 lastfield=''; 4967 % check the content netcdf file 4968 Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); 4969 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 4970 option=6; 4971 option_str='patch2'; 4972 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 4973 option=5; 4974 option_str='fix2'; 4975 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 4976 option=4; 4977 option_str='civ2'; 4978 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 4979 option=3; 4980 option_str='patch1'; 4981 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 4982 option=2; 4983 option_str='fix1'; 4984 else 4985 option=1; 4986 option_str='civ1'; 4987 end 4988 end 4989 if option >= option_civ 4990 count=count+1; 4991 end 4992 [rr,filename,ext]=fileparts(civ_files{ifile}); 4993 Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; 4994 end 4995 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 4996 if isempty(datnum) 4997 if testrecent 4998 message='no civ result created yet'; 4999 else 5000 message=''; 5001 end 5002 else 5003 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 5004 [first,ind]=min(datnum); 5005 [last,indlast]=max(datnum); 5006 if test_new 5007 message='existing file status, no processing launched yet'; 5008 else 5009 message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 5010 ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 5011 end 5012 end 5013 hfig=findobj(allchild(0),'name','civ_status'); 5014 if isempty(hfig)% the status list has been deleted 5015 return 5016 else 5017 hlist=findobj(hfig,'tag','list'); 5018 hmsgbox=findobj(hfig,'tag','msgbox'); 5019 hwaitbar=findobj(hfig,'tag','waitbar'); 5020 set(hlist,'String',Tabchar) 5021 set(hmsgbox,'String', message) 5022 if count>0 && ~test_new 5023 BarPosition(3)=0.9*count/nbfiles; 5024 set(hwaitbar,'Position',BarPosition) 5025 end 5026 end 5027 set(hlist,'UserData',rootroot) 5028 pause(10)% wait 10 seconds for next check 5029 end 5030 3979 5031 3980 5032 3981 %------------------------------------------------------------------------ … … 5070 4019 % prog=Listprog{index}; 5071 4020 % switch prog 5072 % case ' CivX'4021 % case 'MenuCivX' 5073 4022 % set(handles.thresh_patch1,'Visible','off') 5074 4023 % set(handles.thresh_text1,'Visible','off') … … 5091 4040 5092 4041 5093 % -------------------------------------------------------------------- 5094 function MenuHelp_Callback(hObject, eventdata, handles) 5095 path_civ=fileparts(which ('civ')); 5096 helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); 5097 if isempty(dir(helpfile)) 5098 msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 5099 else 5100 addpath (fullfile(path_civ,'uvmat_doc')) 5101 web([helpfile '#civ']) 5102 end 5103 5104 % -------------------------------------------------------------------- 5105 function CivX_Callback(hObject, eventdata, handles) 5106 %set(handles.thresh_patch1,'Visible','off') 5107 set(handles.thresh_text1,'Visible','off') 5108 set(handles.num_MaxDiff,'Visible','off') 5109 set(handles.thresh_text2,'Visible','off') 5110 set(handles.num_Rho,'Style','edit') 5111 set(handles.num_Rho,'String','1') 5112 set(handles.BATCH,'Enable','on') 5113 5114 % -------------------------------------------------------------------- 5115 function Matlab_Callback(hObject, eventdata, handles) 5116 set(handles.Matlab,'checked','on') 5117 set(handles.CivX,'checked','off') 5118 if get(handles.CheckPatch1,'Value') 5119 set(handles.thresh_patch1,'Visible','on') 5120 set(handles.thresh_text1,'Visible','on') 5121 end 5122 if get(handles.CheckPatch2,'Value') 5123 set(handles.num_MaxDiff,'Visible','on') 5124 set(handles.thresh_text2,'Visible','on') 5125 end 5126 set(handles.num_Rho,'Style','popupmenu') 5127 set(handles.num_Rho,'Value',1) 5128 set(handles.num_Rho,'String',{'1';'2'}) 5129 set(handles.BATCH,'Enable','off') 5130 5131 % -------------------------------------------------------------------- 5132 % --- read a panel with handle 'handle' producing a structure 'struct' 5133 function struct=read_panel(handle) 5134 hchild=get(handle,'children'); 5135 for ichild=1:numel(hchild) 5136 if strcmp(get(hchild(ichild),'Visible'),'on') 5137 object_style=get(hchild(ichild),'Style'); 5138 tag=get(hchild(ichild),'tag'); 5139 check_input=1;%default 5140 switch object_style 5141 case 'edit' 5142 switch(tag(1:4)) 5143 case 'num_' 5144 input=str2double(get(hchild(ichild),'String')); 5145 %deal with undefined input: retrieve the default value stored as UserData 5146 if isnan(input) 5147 input=get(hchild(ichild),'UserData'); 5148 set(hchild(ichild),'String',num2str(input)) 5149 end 5150 case 'txt_' 5151 input=get(hchild(ichild),'String'); 5152 end 5153 key=tag(5:end); 5154 case 'checkbox' 5155 input=get(hchild(ichild),'Value'); 5156 key=tag(7:end); 5157 otherwise 5158 check_input=0; 5159 end 5160 if check_input 5161 eval(['struct.' key '=input;']) 5162 end 5163 end 5164 end 5165 5166 5167 4042 4043 4044 %------------------------------------------------------------------------ 5168 4045 function cmd=cmd_civ1(filename,Param) 5169 %TODO : include filename in par_civ15170 4046 %------------------------------------------------------------------------ 5171 4047 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 5172 5173 4048 %changes : filename_cmx -> filename ( no extension ) 5174 5175 filename=regexprep(filename,'.nc',''); 5176 4049 filename=regexprep(filename,'.nc',''); %file name for the result 4050 Param.Civ1 5177 4051 if isequal(Param.Civ1.Dt,'0') 5178 4052 Param.Civ1.Dt='1' ;%case of 'displacement' mode … … 5187 4061 fprintf(fid, ['Mask ' Param.Civ1.MaskFlag '\n' ]); 5188 4062 fprintf(fid, ['MaskName ' regexprep(Param.Civ1.MaskName,'\\','\\\\') '\n' ]); 5189 fprintf(fid, ['ImageSize ' num2str(Param.Civ1. npx) ' ' num2str(Param.Civ1.npy) '\n' ]); %VERIFIER CAS GENERAL ?4063 fprintf(fid, ['ImageSize ' num2str(Param.Civ1.ImageInfo.Width) ' ' num2str(Param.Civ1.ImageInfo.Height) '\n' ]); %VERIFIER CAS GENERAL ? 5190 4064 fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]); 5191 4065 fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]); … … 5207 4081 fprintf(fid, ['CorrelationMin 0' '\n' ]); 5208 4082 fprintf(fid, ['IntensityMin 0' '\n' ]); 5209 fprintf(fid, ['SeuilImage n' '\n' ]); 5210 fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); 4083 if ~isfield(Param.Civ1,'MinIma')% Image threshold not activated 4084 fprintf(fid, ['SeuilImage n' '\n' ]); 4085 fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle 4086 else% Image threshold activated 4087 if isempty(Param.Civ1.MaxIma)||isnan(Param.Civ1.MaxIma) 4088 Param.Civ1.MaxIma=2^Param.Civ1.ImageInfo.BitDepth;%take the max image value as upper bound by default 4089 end 4090 fprintf(fid, ['SeuilImage y' '\n' ]); 4091 fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ1.MinIma) ' ' num2str(Param.Civ1.MaxIma) '\n' ]); 4092 end 5211 4093 fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? 5212 4094 fprintf(fid, ['ImageUsedBefore null null' '\n' ]); 5213 4095 fclose(fid); 5214 4096 5215 % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file 5216 % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); 5217 % namelog=regexprep(namelog,'\\','\\\\'); 5218 if(isunix) 4097 if(isunix) %unix (or Mac) system 5219 4098 cmd=['cp -f ' filename '.civ1.cmx ' filename '.cmx \n '];% the cmx file gives the name to the nc file 5220 4099 cmd=[cmd Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.civ1.log \n ' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx 5221 % cmd=[cmd '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting5222 % cmd=[cmd '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx5223 4100 cmd=[cmd 'rm ' filename '.cmx']; 5224 4101 else %Windows system … … 5227 4104 cmd=[cmd '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\')... 5228 4105 '" -f "' filename '.cmx" >"' filename '.civ1.log" \n ' ]; % redirect standard output to the log file 5229 % namelog=regexprep(namelog,'\\','\\\\');5230 % cmd=[cmd '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log5231 4106 cmd=[cmd 'del "' filename '.cmx"']; 5232 4107 end … … 5241 4116 fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... 5242 4117 end 5243 5244 5245 5246 4118 filename=regexprep(filename,'.nc',''); 5247 4119 MaskName_string='';%default … … 5270 4142 %% ------------------------------------------------------------------------ 5271 4143 filename=regexprep(filename,'.nc',''); 5272 % if test_interp==05273 4144 if isunix 5274 4145 cmd=[Param.xml.PatchBin... … … 5285 4156 cmd=regexprep(cmd,'\\','\\\\'); 5286 4157 end 5287 % else %nouveau programme patch5288 % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ...5289 % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file5290 % end5291 5292 4158 5293 4159 %------------------------------------------------------------------------ … … 5315 4181 fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); 5316 4182 fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility 5317 fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? 4183 fprintf(fid, ['ImageSize ' num2str(Param.Civ2.ImageInfo.Width) ' ' num2str(Param.Civ2.ImageInfo.Height) '\n' ]); 4184 % fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? 5318 4185 fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]); 5319 4186 fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']); … … 5335 4202 fprintf(fid, ['CorrelationMin 0' '\n' ]); 5336 4203 fprintf(fid, ['IntensityMin 0' '\n' ]); 5337 fprintf(fid, ['SeuilImage n' '\n' ]); 5338 fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); 4204 4205 if ~isfield(Param.Civ2,'MinIma')% Image threshold not activated 4206 fprintf(fid, ['SeuilImage n' '\n' ]); 4207 fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle 4208 else% Image threshold activated 4209 if isempty(Param.Civ2.MaxIma)||isnan(Param.Civ2.MaxIma) 4210 Param.Civ2.MaxIma=2^Param.Civ2.ImageInfo.BitDepth;%take the max image value as upper bound by default 4211 end 4212 fprintf(fid, ['SeuilImage y' '\n' ]); 4213 fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ2.MinIma) ' ' num2str(Param.Civ2.MaxIma) '\n' ]); 4214 end 5339 4215 fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? 5340 4216 fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); … … 5351 4227 'del "' filename '.cmx" \n']; 5352 4228 end 4229 4230 %------------------------------------------------------------------------ 4231 % --- Executes on button press in CheckThreshold. 4232 function CheckThreshold_Callback(hObject, eventdata, handles) 4233 %------------------------------------------------------------------------ 4234 huipanel=get(hObject,'parent'); 4235 obj(1)=findobj(huipanel,'Tag','num_MinIma'); 4236 obj(2)=findobj(huipanel,'Tag','num_MaxIma'); 4237 obj(3)=findobj(huipanel,'Tag','title_Threshold'); 4238 if get(hObject,'Value') 4239 set(obj,'Visible','on') 4240 else 4241 set(obj,'Visible','off') 4242 end 4243 4244 %------------------------------------------------------------------------ 4245 % --- CheckCiv1 Unified: TO ABADON 4246 function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) 4247 %------------------------------------------------------------------------ 4248 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4249 %global CivBin%name of the executable for checkciv1 calculation 4250 4251 civ1.image1=par.filename_ima_a; 4252 civ1.image2=par.filename_ima_b; 4253 civ1.imageSize_X=par.npx; 4254 civ1.imageSize_Y=par.npy; 4255 civ1.outputFileName=[filename '.nc']; 4256 civ1.correlationBoxesSize_X=par.ibx; 4257 civ1.correlationBoxesSize_Y=par.iby; 4258 civ1.searchBoxesSize_X=par.isx; 4259 civ1.searchBoxesSize_Y=par.isy; 4260 civ1.globalShift_X=par.shiftx; 4261 civ1.globalShift_Y=par.shifty; 4262 civ1.ro=par.rho; 4263 civ1.hart='y'; 4264 if isequal(par.gridflag,'y') 4265 civ1.grid=par.gridname; 4266 else 4267 civ1.grid='n'; 4268 civ1.gridSpacing_X=par.dx; 4269 civ1.gridSpacing_Y=par.dy; 4270 end 4271 if isequal(par.maskflag,'y') 4272 civ1.mask=par.maskname; 4273 end 4274 civ1.dt=par.Dt; 4275 civ1.unit='pixel'; 4276 civ1.absolut_time_T0=par.T0; 4277 civ1.pixcmx=par.pxcmx; 4278 civ1.pixcmy=par.pxcmy; 4279 civ1.convectFlow='n'; 4280 4281 xml_civ1_parameters=civ1; 4282 4283 %------------------------------------------------------------------------ 4284 % --- CheckCiv2 Unified: TO ABADON 4285 function civ2=CIV2_CMD_Unified(filename,namelog,par) 4286 %------------------------------------------------------------------------ 4287 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4288 %global CivBin%name of the executable for checkciv1 calculation 4289 4290 filename=regexprep(filename,'.nc',''); 4291 4292 civ2.image1=par.filename_ima_a; 4293 civ2.image2=par.filename_ima_b; 4294 civ2.imageSize_X=par.npx; 4295 civ2.imageSize_Y=par.npy; 4296 civ2.inputFileName=[par.filename_nc1 '.nc']; 4297 civ2.outputFileName=[filename '.nc']; 4298 civ2.correlationBoxesSize_X=par.ibx; 4299 civ2.correlationBoxesSize_Y=par.iby; 4300 civ2.ro=par.rho; 4301 %checkciv2.decimalShift=par.CheckDecimal; 4302 %checkciv2.CheckDeformation=par.CheckDeformation; 4303 if isequal(par.decimal,'1') 4304 civ2.decimalShift='y'; 4305 else 4306 civ2.decimalShift='n'; 4307 end 4308 if isequal(par.deformation,'1') 4309 civ2.deformation='y'; 4310 else 4311 civ2.deformation='n'; 4312 end 4313 if isequal(par.gridflag,'y') 4314 civ2.grid=par.gridname; 4315 else 4316 civ2.grid='n'; 4317 civ2.gridSpacing_X=par.dx; 4318 civ2.gridSpacing_Y=par.dy; 4319 end 4320 civ2.gridSpacing_X='10'; 4321 civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee 4322 if isequal(par.maskflag,'y') 4323 civ2.mask=par.maskname; 4324 else 4325 civ2.mask='n'; 4326 end 4327 civ2.dt=par.Dt; 4328 civ2.unit='pixel'; 4329 civ2.absolut_time_T0=par.T0; 4330 civ2.pixcmx=par.pxcmx; 4331 civ2.pixcmy=par.pxcmy; 4332 civ2.convectFlow='n'; 4333 civ2.pixcmx=par.pxcmx; 4334 civ2.pixcmy=par.pxcmy; 4335 civ2.convectFlow='n'; -
trunk/src/civ_uvmat.m
r273 r309 1 % To develop.... 2 function [Data,errormsg]= civ_uvmat(Param,ncfile) 1 %'civ_matlab': Matlab version of the PIV programs CivX 2 % --- call the sub-functions: 3 % civ: PIV function itself 4 % fix: removes false vectors after detection by various criteria 5 % patch: make interpolation-smoothing 6 %------------------------------------------------------------------------ 7 % function [Data,errormsg,result_conv]= civ_uvmat(Param,ncfile) 8 % 9 %OUTPUT 10 % Data=structure containing the PIV results and information on the processing parameters 11 % errormsg=error message char string, default='' 12 % resul_conv: image inter-correlation function for the last grid point (used for tests) 13 % 14 %INPUT: 15 % Param: input images and processing parameters 16 % ncfile: name of a netcdf file to be created for the result (extension .nc) 17 % 18 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 % Copyright 2011, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr. 20 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 21 % This is part of the toolbox UVMAT. 22 % 23 % UVMAT is free software; you can redistribute it and/or modify 24 % it under the terms of the GNU General Public License as published by 25 % the Free Software Foundation; either version 2 of the License, or 26 % (at your option) any later version. 27 % 28 % UVMAT is distributed in the hope that it will be useful, 29 % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 % GNU General Public License (open UVMAT/COPYING.txt) for more details. 32 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 33 34 function [Data,errormsg,result_conv]= civ_uvmat(Param,ncfile) 3 35 errormsg=''; 4 36 Data.ListGlobalAttribute={'Conventions','Program','CivStage'}; … … 20 52 image1=imread(par_civ1.filename_ima_a); 21 53 image2=imread(par_civ1.filename_ima_b); 22 stepx=str2num(par_civ1.dx); 23 stepy=str2num(par_civ1.dy); 24 ibx2=ceil(str2num(par_civ1.ibx)/2); 25 iby2=ceil(str2num(par_civ1.iby)/2); 26 isx2=ceil(str2num(par_civ1.isx)/2); 27 isy2=ceil(str2num(par_civ1.isy)/2); 28 shiftx=str2num(par_civ1.shiftx); 29 shifty=str2num(par_civ1.shifty); 54 ibx2=ceil(par_civ1.Bx/2); 55 iby2=ceil(par_civ1.By/2); 56 isx2=ceil(par_civ1.Searchx/2); 57 isy2=ceil(par_civ1.Searchy/2); 58 shiftx=par_civ1.Shiftx; 59 shifty=par_civ1.Shifty; 30 60 miniy=max(1+isy2+shifty,1+iby2); 31 61 minix=max(1+isx2-shiftx,1+ibx2); 32 62 maxiy=min(size(image1,1)-isy2+shifty,size(image1,1)-iby2); 33 63 maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); 34 [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); 35 PointCoord(:,1)=reshape(GridX,[],1); 36 PointCoord(:,2)=reshape(GridY,[],1); 37 if isfield(par_civ1,'maskname') && ~isempty(par_civ1.maskname) && ~isequal(par_civ1.maskname,'noFile use default') 38 maskname=par_civ1.maskname; 64 if ~isfield(par_civ1,'PointCoord') 65 [GridX,GridY]=meshgrid(minix:par_civ1.Dx:maxix,miniy:par_civ1.Dy:maxiy); 66 par_civ1.PointCoord(:,1)=reshape(GridX,[],1); 67 par_civ1.PointCoord(:,2)=reshape(GridY,[],1); 68 end 69 if par_civ1.CheckMask && isfield(par_civ1,'MaskName') && ~isempty(par_civ1.MaskName) 70 maskname=par_civ1.MaskName; 39 71 mask=imread(maskname); 40 72 end 41 73 % caluclate velocity data (y and v in indices, reverse to y component) 42 [xtable ytable utable vtable ctable F ] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho), mask);74 [xtable ytable utable vtable ctable F result_conv errormsg] = civ (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,par_civ1.PointCoord,par_civ1.Rho, mask); 43 75 list_param=(fieldnames(par_civ1))'; 44 76 list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'}; 45 index=zeros(size(list_param)); 46 for ilist=1:length(list_remove) 47 index=strcmp(list_remove{ilist},list_param); 48 if ~isempty(find(index,1)) 49 list_param(index)=[]; 50 end 51 end 77 index_remove=zeros(size(list_param)); 78 for name=list_remove %loop on the list of names 79 index_remove=index_remove +strcmp(name{1},list_param);%index of the current name = name{1} 80 end 81 list_param(find(index_remove,1))=[]; 82 Civ1_param=list_param;%initialisation 52 83 for ilist=1:length(list_param) 53 84 Civ1_param{ilist}=['Civ1_' list_param{ilist}]; 54 eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])85 Data.(['Civ1_' list_param{ilist}])=par_civ1.(list_param{ilist}); 55 86 end 56 87 if isfield(Data,'Civ1_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile') … … 96 127 97 128 %% Fix1 129 % if Param.CheckCiv1==1 130 % Param.Civ1=Param.Civ1; 131 % end 132 % if Param.CheckFix1==1 133 % Param.Fix1=Param.Fix1; 134 % fix1.WarnFlags=[]; 135 % if get(handles.CheckFmin2,'Value') 136 % fix1.WarnFlags=[fix1.WarnFlags -2]; 137 % end 138 % if get(handles.CheckF3,'Value') 139 % fix1.WarnFlags=[fix1.WarnFlags 3]; 140 % end 141 % fix1.LowerBoundCorr=thresh_vecC1; 142 % if get(handles.num_MinVel,'Value') 143 % fix1.UppperBoundVel=thresh_vel1; 144 % else 145 % fix1.LowerBoundVel=thresh_vel1; 146 % end 147 % if get(handles.CheckMask,'Value') 148 % fix1.MaskName=maskname; 149 % end 150 % Param.Fix1=fix1; 151 % end 152 % if Param.CheckPatch1==1 153 % if strcmp(compare,'stereo PIV') 154 % filebase_A=filecell.filebase; 155 % [pp,ff]=fileparts(filebase_A); 156 % filebase_B=fullfile(pp,get(handles.RootName_1,'String')); 157 % %TO CHECK: filecell.nc.civ1{ifile,j},filecell.ncA.civ1{ifile,j} have been switched according to Matias Duran 158 % RUN_STLIN(filecell.nc.civ1{ifile,j},filecell.ncA.civ1{ifile,j},'civ1',filecell.st{ifile,j},... 159 % str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) 160 % else 161 % Param.Patch1.Rho=rho_patch1; 162 % Param.Patch1.Threshold=thresh_patch1; 163 % Param.Patch1.SubDomain=subdomain_patch1; 164 % end 165 % end 166 % if Param.CheckCiv2==1 167 % Param.Civ2=Param.Civ2; 168 % end 169 % if Param.CheckFix2==1 170 % fix2.WarnFlags=[]; 171 % if get(handles.CheckFmin2,'Value') 172 % fix2.WarnFlags=[fix2.WarnFlags -2]; 173 % end 174 % if get(handles.CheckF4,'Value') 175 % fix2.WarnFlags=[fix2.WarnFlags 4]; 176 % end 177 % if get(handles.CheckF3,'Value') 178 % fix2.WarnFlags=[fix2.WarnFlags 3]; 179 % end 180 % fix2.LowerBoundCorr=thresh_vec2C; 181 % if get(handles.num_MinVel,'Value') 182 % fix2.UppperBoundVel=thresh_vel2; 183 % else 184 % fix2.LowerBoundVel=thresh_vel2; 185 % end 186 % if get(handles.CheckMask,'Value') 187 % fix2.MaskName=maskname; 188 % end 189 % Param.Fix2=fix2; 190 % end 191 % if Param.CheckPatch2==1 192 % if strcmp(compare,'stereo PIV') 193 % filebase_A=filecell.filebase; 194 % [pp,ff]=fileparts(filebase_A); 195 % filebase_B=fullfile(pp,get(handles.RootName_1,'String')); 196 % RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... 197 % str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) 198 % else 199 % Param.Patch2.Rho=rho_patch2; 200 % Param.Patch2.Threshold=thresh_patch2; 201 % Param.Patch2.SubDomain=subdomain_patch2; 202 % end 203 % end 204 98 205 if isfield (Param,'Fix1') 99 206 ListFixParam=fieldnames(Param.Fix1); … … 117 224 Data.VarDimName=[Data.VarDimName {'nb_vectors'}]; 118 225 end 119 Data.vec_FixFlag=fix _uvmat(Param.Fix1,Data.vec_F,Data.vec_C,Data.vec_U,Data.vec_V,Data.vec_X,Data.vec_Y);226 Data.vec_FixFlag=fix(Param.Fix1,Data.vec_F,Data.vec_C,Data.vec_U,Data.vec_V,Data.vec_X,Data.vec_Y); 120 227 else 121 228 Data.ListVarName=[Data.ListVarName {'Civ1_FF'}]; … … 123 230 nbvar=length(Data.ListVarName); 124 231 Data.VarAttribute{nbvar}.Role='errorflag'; 125 Data.Civ1_FF=fix _uvmat(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);232 Data.Civ1_FF=fix(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V); 126 233 Data.CivStage=2; 127 234 end … … 148 255 end 149 256 [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=... 150 patch _uvmat(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);257 patch(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain); 151 258 Data.Civ1_U_Diff(ind_good)=Data.Civ1_U(ind_good)-Ures; 152 259 Data.Civ1_V_Diff(ind_good)=Data.Civ1_V(ind_good)-Vres; … … 164 271 image2=imread(par_civ2.filename_ima_b);%read second image if not already done for civ1 165 272 end 166 stepx=str2double(par_civ2.dx);167 stepy=str2double(par_civ2.dy);273 % stepx=str2double(par_civ2.dx); 274 % stepy=str2double(par_civ2.dy); 168 275 ibx2=ceil(str2double(par_civ2.ibx)/2); 169 276 iby2=ceil(str2double(par_civ2.iby)/2); … … 182 289 end 183 290 [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=... 184 patch _uvmat(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);291 patch(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain); 185 292 end 186 293 % shiftx=str2num(par_civ1.shiftx); … … 192 299 maxiy=min(size(image1,1)-isy2+shifty,size(image1,1)-iby2); 193 300 maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); 194 [GridX,GridY]=meshgrid(minix: stepx:maxix,miniy:stepy:maxiy);301 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy); 195 302 PointCoord(:,1)=reshape(GridX,[],1); 196 303 PointCoord(:,2)=reshape(GridY,[],1); … … 199 306 end 200 307 % caluclate velocity data (y and v in indices, reverse to y component) 201 [xtable ytable utable vtable ctable F] = pivlab(image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho),mask);308 [xtable ytable utable vtable ctable F] = civ (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho),mask); 202 309 list_param=(fieldnames(par_civ1))'; 203 310 list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'}; … … 254 361 Data.VarDimName=[Data.VarDimName {'nb_vectors2'}]; 255 362 end 256 Data.vec_FixFlag=fix _uvmat(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V,Data.vec2_X,Data.vec2_Y);363 Data.vec_FixFlag=fix(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V,Data.vec2_X,Data.vec2_Y); 257 364 else 258 365 Data.ListVarName=[Data.ListVarName {'Civ2_FF'}]; … … 260 367 nbvar=length(Data.ListVarName); 261 368 Data.VarAttribute{nbvar}.Role='errorflag'; 262 Data.Civ2_FF=fix _uvmat(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V);369 Data.Civ2_FF=fix(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V); 263 370 Data.CivStage=5; 264 371 end … … 286 393 end 287 394 [Data.Civ2_X_SubRange,Data.Civ2_Y_SubRange,Data.Civ2_NbSites,FFres,Ures, Vres,Data.Civ2_X_tps,Data.Civ2_Y_tps,Data.Civ2_U_tps,Data.Civ2_V_tps]=... 288 patch _uvmat(Data.Civ2_X(ind_good)',Data.Civ2_Y(ind_good)',Data.Civ2_U(ind_good)',Data.Civ2_V(ind_good)',Data.Patch2_Rho,Data.Patch2_Threshold,Data.Patch2_SubDomain);395 patch(Data.Civ2_X(ind_good)',Data.Civ2_Y(ind_good)',Data.Civ2_U(ind_good)',Data.Civ2_V(ind_good)',Data.Patch2_Rho,Data.Patch2_Threshold,Data.Patch2_SubDomain); 289 396 Data.Civ2_U_Diff(ind_good)=Data.Civ2_U(ind_good)-Ures; 290 397 Data.Civ2_V_Diff(ind_good)=Data.Civ2_V(ind_good)-Vres; … … 293 400 end 294 401 295 %% write result 296 % 'TESTcalc' 297 % [DataOut,errormsg]=calc_field('velocity',Data) 402 %% write result in a netcdf file if requested 298 403 if exist('ncfile','var') 299 errormsg=struct2nc(ncfile,Data);404 errormsg=struct2nc(ncfile,Data); 300 405 end 301 406 … … 323 428 %fieldref: 'civ1','filter1'...feld used in fileref 324 429 325 function FF=fix _uvmat(Param,F,C,U,V,X,Y)430 function FF=fix(Param,F,C,U,V,X,Y) 326 431 FF=zeros(size(F));%default 432 Param 327 433 328 434 %criterium on warn flags 329 if isfield (Param,'WarnFlags') 330 for iflag=1:numel(Param.WarnFlags) 331 FF=(FF==1| F==Param.WarnFlags(iflag)); 332 end 333 end 334 435 FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'}; 436 FlagVal=[-2 2 3 4]; 437 for iflag=1:numel(FlagVal) 438 if Param.(CheckFlag(iflag)) 439 FF=(FF==1| F==FlagVal(iflag)); 440 % if isfield (Param,'WarnFlags') 441 % for iflag=1:numel(Param.WarnFlags) 442 % FF=(FF==1| F==Param.WarnFlags(iflag)); 443 % end 444 % end 445 end 446 end 335 447 %criterium on correlation values 336 if isfield (Param,'LowerBoundCorr') 337 FF=FF==1 | C<Param.LowerBoundCorr; 338 end 448 if isfield (Param,'MinCorr') 449 FF=FF==1 | C<Param.MinCorr; 450 end 451 return 452 339 453 340 454 if isfield (Param,'LowerBoundVel')&& ~isequal(Param.LowerBoundVel,0) … … 427 541 %------------------------------------------------------------------------ 428 542 % patch function 429 function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch _uvmat(X,Y,U,V,Rho,Threshold,SubDomain)543 function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch(X,Y,U,V,Rho,Threshold,SubDomain) 430 544 %subdomain decomposition 431 545 warning off … … 542 656 543 657 544 545 658 % 'civ': function piv.m adapted from PIVlab http://pivlab.blogspot.com/ 659 %-------------------------------------------------------------------------- 660 % function [xtable ytable utable vtable typevector] = civ (image1,image2,ibx,iby step, subpixfinder, mask, roi) 661 % 662 % OUTPUT: 663 % xtable: set of x coordinates 664 % ytable: set of y coordiantes 665 % utable: set of u displacements (along x) 666 % vtable: set of v displacements (along y) 667 % ctable: max image correlation for each vector 668 % typevector: set of flags, =1 for good, =0 for NaN vectors 669 % 670 %INPUT: 671 % image1:first image (matrix) 672 % image2: second image (matrix) 673 % ibx2,iby2: half size of the correlation box along x and y, in px (size=(2*iby2+1,2*ibx2+1) 674 % isx2,isy2: half size of the search box along x and y, in px (size=(2*isy2+1,2*isx2+1) 675 % shiftx, shifty: shift of the search box (in pixel index, yshift reversed) 676 % step: mesh of the measurement points (in px) 677 % subpixfinder=1 or 2 controls the curve fitting of the image correlation 678 % mask: =[] for no mask 679 % roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[]; 680 function [xtable ytable utable vtable ctable F result_conv errormsg] = civ (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask) 681 %this funtion performs the DCC PIV analysis. Recent window-deformation 682 %methods perform better and will maybe be implemented in the future. 683 nbvec=size(GridIndices,1); 684 xtable=zeros(nbvec,1); 685 ytable=xtable; 686 utable=xtable; 687 vtable=xtable; 688 ctable=xtable; 689 F=xtable; 690 result_conv=[]; 691 errormsg=''; 692 %warning off %MATLAB:log:logOfZero 693 [npy_ima npx_ima]=size(image1); 694 if ~isequal(size(image2),[npy_ima npx_ima]) 695 errormsg='image pair with unequal size'; 696 return 697 end 698 699 %% mask 700 testmask=0; 701 image1=double(image1); 702 image2=double(image2); 703 if exist('mask','var') && ~isempty(mask) 704 testmask=1; 705 if ~isequal(size(mask),[npy_ima npx_ima]) 706 errormsg='mask must be an image with the same size as the images'; 707 return 708 end 709 % Convention for mask 710 % mask >200 : velocity calculated 711 % 200 >=mask>150;velocity not calculated, interpolation allowed (bad spots) 712 % 150>=mask >100: velocity not calculated, nor interpolated 713 % 100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries) 714 % 20>=mask: velocity=0 715 test_noflux=(mask<100) ; 716 test_undefined=(mask<200 & mask>=100 ); 717 image1(test_undefined)=min(min(image1));% put image to zero in the undefined area 718 image2(test_undefined)=min(min(image2));% put image to zero in the undefined area 719 end 720 721 %% calculate correlations: MAINLOOP on velocity vectors 722 corrmax=0; 723 sum_square=1;% default 724 for ivec=1:nbvec 725 iref=GridIndices(ivec,1); 726 jref=GridIndices(ivec,2); 727 testmask_ij=0; 728 test0=0; 729 if testmask 730 if mask(jref,iref)<=20 731 vector=[0 0]; 732 test0=1; 733 else 734 mask_crop1=mask(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2); 735 mask_crop2=mask(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2); 736 if ~isempty(find(mask_crop1<=200 & mask_crop1>100,1)) || ~isempty(find(mask_crop2<=200 & mask_crop2>100,1)); 737 testmask_ij=1; 738 end 739 end 740 end 741 if ~test0 742 image1_crop=image1(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);%extract a subimage (correlation box) from images 1 743 image2_crop=image2(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);%extract a larger subimage (search box) from image 2 744 image1_crop=image1_crop-mean(mean(image1_crop));%substract the mean 745 image2_crop=image2_crop-mean(mean(image2_crop)); 746 %reference: Oliver Pust, PIV: Direct Cross-Correlation 747 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 748 corrmax= max(max(result_conv)); 749 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 750 %Find the correlation max, at 255 751 [y,x] = find(result_conv==255,1); 752 if ~isempty(y) && ~isempty(x) 753 try 754 if subpixfinder==1 755 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 756 elseif subpixfinder==2 757 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 758 end 759 sum_square=sum(sum(image1_crop.*image1_crop)); 760 ctable(ivec)=corrmax/sum_square;% correlation value 761 % if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder 762 % F(ivec)=-2;%vector reaches the border of the search zone 763 % end 764 catch ME 765 vector=[0 0]; %if something goes wrong with cross correlation..... 766 F(ivec)=3; 767 end 768 else 769 vector=[0 0]; %if something goes wrong with cross correlation..... 770 F(ivec)=3; 771 end 772 if testmask_ij 773 F(ivec)=3; 774 end 775 end 776 777 %Create the vector matrix x, y, u, v 778 xtable(ivec)=iref+vector(1)/2;% convec flow (velocity taken at the point middle from imgae1 and 2) 779 ytable(ivec)=jref+vector(2)/2; 780 utable(ivec)=vector(1)+shiftx; 781 vtable(ivec)=vector(2)+shifty; 782 end 783 result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output 784 785 786 function [vector,F] = SUBPIXGAUSS (result_conv,x,y) 787 vector=[0 0]; %default 788 F=0; 789 [npy,npx]=size(result_conv); 790 791 % if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1) 792 %the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion Israel Institute of Technology 793 %http://urapiv.wordpress.com 794 peaky = y; 795 if y <= npy-1 && y >= 1 796 f0 = log(result_conv(y,x)); 797 f1 = real(log(result_conv(y-1,x))); 798 f2 = real(log(result_conv(y+1,x))); 799 peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 800 else 801 F=-2; % warning flag for vector truncated by the limited search box 802 end 803 peakx=x; 804 if x <= npx-1 && x >= 1 805 f0 = log(result_conv(y,x)); 806 f1 = real(log(result_conv(y,x-1))); 807 f2 = real(log(result_conv(y,x+1))); 808 peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2); 809 else 810 F=-2; % warning flag for vector truncated by the limited search box 811 end 812 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 813 % else 814 % vector=[NaN NaN]; 815 % end 816 817 function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y) 818 vector=[0 0]; %default 819 F=-2; 820 peaky=y; 821 peakx=x; 822 [npy,npx]=size(result_conv); 823 if (x <= npx-1) && (y <= npy-1) && (x >= 1) && (y >= 1) 824 F=0; 825 for i=-1:1 826 for j=-1:1 827 %following 15 lines based on 828 %H. Nobach Æ M. Honkanen (2005) 829 %Two-dimensional Gaussian regression for sub-pixel displacement 830 %estimation in particle image velocimetry or particle position 831 %estimation in particle tracking velocimetry 832 %Experiments in Fluids (2005) 38: 511515 833 c10(j+2,i+2)=i*log(result_conv(y+j, x+i)); 834 c01(j+2,i+2)=j*log(result_conv(y+j, x+i)); 835 c11(j+2,i+2)=i*j*log(result_conv(y+j, x+i)); 836 c20(j+2,i+2)=(3*i^2-2)*log(result_conv(y+j, x+i)); 837 c02(j+2,i+2)=(3*j^2-2)*log(result_conv(y+j, x+i)); 838 %c00(j+2,i+2)=(5-3*i^2-3*j^2)*log(result_conv_norm(maxY+j, maxX+i)); 839 end 840 end 841 c10=(1/6)*sum(sum(c10)); 842 c01=(1/6)*sum(sum(c01)); 843 c11=(1/4)*sum(sum(c11)); 844 c20=(1/6)*sum(sum(c20)); 845 c02=(1/6)*sum(sum(c02)); 846 deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2); 847 deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2); 848 if abs(deltax)<1 849 peakx=x+deltax; 850 end 851 if abs(deltay)<1 852 peaky=y+deltay; 853 end 854 end 855 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 856 857 -
trunk/src/mouse_down.m
r302 r309 40 40 set(hcurrentfig,'Units','normalized') 41 41 hhcurrentfig=guidata(hcurrentfig); 42 if isfield(hhcurrentfig,'CheckZoom') 42 43 test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority 44 else 45 test_zoom=0; 46 end 43 47 test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler action, second priority; 44 48 test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority … … 60 64 end 61 65 end 62 xdisplay=[];%default63 ydisplay=[];%default64 66 AxeData=[];%default 65 67 … … 76 78 %% loop on all the objects in the current figure (selected by the last mouse click) 77 79 output_str=''; 80 state_visible=get(hchildren,'Visible'); 81 check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise 82 hchildren=hchildren(find(check_visible)); %kkep only the visible children 78 83 for ichild=1:length(hchildren) 79 hchild=hchildren(ichild); %handle of the current obj ect84 hchild=hchildren(ichild); %handle of the current obj 80 85 obj_pos=get(hchild,'Position');%position of the object 81 86 if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4); … … 119 124 if isequal(get(hObject,'SelectionType'),'alt') && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&... 120 125 ~isequal(get(hchild,'tag'),'ListObject') 121 if strcmp(get(hchild,'Visible'),'on') 126 % if strcmp(get(hchild,'Visible'),'on') 127 if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames 122 128 msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4); 123 129 output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos); -
trunk/src/mouse_motion.m
r292 r309 218 218 % case of PIV correlation display 219 219 if test_piv 220 par=civ('read_param_civ1',hhciv); 220 %par=civ('read_param_civ1',hhciv); 221 par=read_GUI(hhciv.Civ1); 221 222 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 222 223 xround=Field.X(ind_pt); 223 224 yround=Field.Y(ind_pt); 225 par.PointCoord=[xround size(Field.A,1)-yround+1]; 224 226 % mark the correlation box with a rectangle 225 ibx2=floor((str2double(par.ibx)-1)/2); 226 iby2=floor((str2double(par.iby)-1)/2); 227 isx2=floor((str2double(par.isx)-1)/2); 228 isy2=floor((str2double(par.isy)-1)/2); 229 shiftx=str2double(par.shiftx); 230 shifty=str2double(par.shifty); 227 par.filename_ima_a=Field.A; 228 par.filename_ima_b=Field.B; 229 Param.Civ1=par; 230 ibx2=floor((par.Bx-1)/2); 231 iby2=floor((par.By-1)/2); 232 isx2=floor((par.Searchx-1)/2); 233 isy2=floor((par.Searchy-1)/2); 234 shiftx=par.Shiftx; 235 shifty=par.Shifty; 231 236 hhh=findobj(haxes,'Tag','PIV_box_marker'); 232 237 hhhh=findobj(haxes,'Tag','PIV_search_marker'); … … 244 249 set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) 245 250 end 246 [xtable ytable utable vtable ctable typevector result_conv] = pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround size(Field.A,1)-yround+1], 1, []); 251 %[xtable, ytable, utable, vtable, ctable, typevector, result_conv] = ... 252 % pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround size(Field.A,1)-yround+1], 1, []); 253 [Data,errormsg,result_conv]= civ_matlab(Param) 247 254 rangx(1)=-(isx2-ibx2)+shiftx; 248 255 rangx(2)=isx2-ibx2+shiftx; … … 261 268 set(0,'CurrentFigure',corrfig(1)) 262 269 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]); 263 AxeData.CurrentVector=line([0 utable],[0 vtable],'Tag','vector');270 AxeData.CurrentVector=line([0 Data.Civ1_U],[0 -Data.Civ1_V],'Tag','vector'); 264 271 265 272 colorbar … … 271 278 set(AxeData.CurrentCorrImage,'XData',rangx) 272 279 set(AxeData.CurrentCorrImage,'YData',-rangy) 273 set(AxeData.CurrentVector,'XData',[0 utable],'YData',[0 -vtable])280 set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 -Data.Civ1_V]) 274 281 end 275 282 end -
trunk/src/read_GUI.m
r295 r309 1 % -------------------------------------------------------------------- 1 % ----------------------------------------------------------------------- 2 2 % --- read a GUI with handle 'handle' producing a structure 'struct' 3 3 function struct=read_GUI(handle) 4 %------------------------------------------------------------------------ 4 5 struct=[];%default 5 6 hchild=get(handle,'children'); … … 43 44 listinput=get(hchild(ichild),'String'); 44 45 value=get(hchild(ichild),'Value'); 45 input=listinput(value); 46 input=listinput(value); 47 separator=regexp(tag,'_'); 48 if strcmp(tag(1:separator),'num_') 49 input=str2double(input);% transform to numerical values if the uicontrol tag begins with 'num_' 50 tag=tag(separator+1:end); 51 end 46 52 otherwise 47 53 check_input=0; -
trunk/src/set_object.m
r307 r309 84 84 end 85 85 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front) 86 set(hObject,'WindowButtonDownFcn',{'mouse_ alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display)86 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function 87 87 enable_plot=0;%default: does not allow plot of object and projection 88 88 … … 644 644 set(handles.XObject,'String',XObject) 645 645 set(handles.YObject,'String',YObject) 646 646 647 %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening 647 648 %------------------------------------------------------------------------ … … 649 650 % executed when closing: set the parent interface button to value 0 650 651 function closefcn(gcbo,eventdata,parent_button) 651 652 652 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 653 653 if ~isempty(huvmat) … … 671 671 UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat 672 672 hhuvmat=guidata(huvmat);%handles in the uvmat GUI 673 ObjectName=get(handles.TITLE,'String');%name of the current object674 673 ListObject=get(hhuvmat.ListObject,'String');%position in the objet list 675 IndexObj=get(hhuvmat.ListObject,'Value'); 676 IndexObj_1=IndexObj(1); 677 % if isequal(get(hhuvmat.list_object_2,'Visible'),'on') 678 % IndexObj_2=get(hhuvmat.list_object_2,'Value'); 679 % List2=get(hhuvmat.list_object_2,'String'); 680 if numel(IndexObj)==2 681 IndexObj_2=IndexObj(2); 682 else 683 IndexObj_2=[]; 684 end 685 testnew=0; 674 IndexObj=get(hhuvmat.ListObject,'Value') 675 % name of the object 676 ObjectName=get(handles.TITLE,'String');%name of the current object defiend in set_object 686 677 ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object 687 if ~isempty(ListObject) && strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame 688 IndexObj=IndexObj_1; 689 projview='uvmat'; 690 elseif ~isempty(IndexObj_2) && IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field 691 IndexObj=IndexObj_2; 692 projview='view_field'; 693 else %new object 694 testnew=1; 695 IndexObj=numel(ListObject)+1; 696 projview='view_field'; 697 end 698 if strcmp(projview,'view_field') 699 hview_field=findobj(allchild(0),'tag','view_field'); 700 if isempty(hview_field) 701 hview_field=view_field; 702 end 703 PlotHandles=guidata(hview_field); 704 plotaxes=PlotHandles.axes3;%handle of axes3 in view_field 705 else 706 PlotHandles=hhuvmat; 707 plotaxes=hhuvmat.axes3;%handle of axes3 in view_field 708 709 end 710 711 %% naming the object 712 if length(ObjectName)<1% name of object not defined in set_object 713 ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name 714 elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created) 678 if isempty(ObjectName) 679 if get(hhuvmat.edit_object,'Value')% edit mode 680 ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item 681 end 682 end 683 if ~get(hhuvmat.edit_object,'Value') %new object is being created 715 684 detectname=1; 716 685 ObjectNameNew=ObjectName; 717 686 vers=0; 718 while detectname==1 687 while detectname==1 719 688 detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list 720 689 if detectname% if the object name already exists … … 725 694 else 726 695 vers=vers+1; 727 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; 696 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; 728 697 end 729 698 end 730 699 end 731 700 ObjectName=ObjectNameNew; 732 end 733 ListObject{IndexObj,1}=ObjectName; 701 ObjectName=[num2str(IndexObj(end)) '-' ObjectData.Style];%default name 702 end 703 % IndexObj_1=IndexObj(1); 704 % % if isequal(get(hhuvmat.list_object_2,'Visible'),'on') 705 % % IndexObj_2=get(hhuvmat.list_object_2,'Value'); 706 % % List2=get(hhuvmat.list_object_2,'String'); 707 % if numel(IndexObj)==2 708 % IndexObj_2=IndexObj(2); 709 % else 710 % IndexObj_2=[]; 711 % end 712 testnew=0; 713 714 if numel(IndexObj)==1 % if only one object is selected, the projection is in uvmat 715 PlotHandles=hhuvmat; 716 plotaxes=hhuvmat.axes3;%handle of axes3 in view_field 717 else % if a second object is selected, the projection is in view_field, and this second object is selected 718 hview_field=findobj(allchild(0),'tag','view_field'); 719 if isempty(hview_field) 720 hview_field=view_field; 721 end 722 PlotHandles=guidata(hview_field); 723 plotaxes=PlotHandles.axes3;%handle of axes3 in view_field 724 end 725 726 %% naming the object 727 ListObject{IndexObj(end),1}=ObjectName; 734 728 set(hhuvmat.ListObject,'String',ListObject) 735 % set(hhuvmat.list_object_2,'String',ListObject)736 729 737 730 %% update the object plot and projection field 738 if testnew 739 set(hhuvmat.ListObject,'Value',IndexObj) 740 % set(hhuvmat.list_object_2,'Value',IndexObj) 731 if testnew 732 set(hhuvmat.ListObject,'Value',IndexObj) 741 733 ObjectData.DisplayHandle_uvmat=hhuvmat.axes3; 742 734 ObjectData.DisplayHandle_view_field=[]; 743 735 else 744 IndexObj 745 UvData.Object{IndexObj} 746 if IndexObj<=length(UvData.Object) && isfield(UvData.Object{IndexObj},'DisplayHandle_uvmat')% save the previous object graph handles 747 ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat; 736 if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles 737 ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat; 748 738 else 749 739 ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input 750 740 end 751 if isfield(UvData.Object{IndexObj },'DisplayHandle_view_field')% save the previous object graph handles752 ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj }.DisplayHandle_view_field;741 if isfield(UvData.Object{IndexObj(end)},'DisplayHandle_view_field')% save the previous object graph handles 742 ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj(end)}.DisplayHandle_view_field; 753 743 else 754 744 ObjectData.DisplayHandle_view_field=[]; 755 745 end 756 746 end 757 UvData.Object{IndexObj}=ObjectData;%update the current object properties 758 UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2); 747 UvData.Object{IndexObj(end)}=ObjectData;%update the current object properties 748 if numel(IndexObj)==2 749 UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2)); 750 end 759 751 set(huvmat,'UserData',UvData) 760 752 … … 765 757 return 766 758 end 767 %PlotParam=read_plot_param(PlotHandles);768 759 fighandle=get(plotaxes,'parent'); 769 760 PlotParam=read_GUI(fighandle); 770 [PlotType,Object_out{IndexObj }.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot761 [PlotType,Object_out{IndexObj(end)}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot 771 762 772 763 %% update the GUI uvmat … … 775 766 set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update 776 767 set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow 777 %UvData.MouseAction='edit_object'; % set the edit button to 'on'778 768 779 769 %------------------------------------------------------------------------ -
trunk/src/uvmat.m
r307 r309 236 236 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) 237 237 set(hObject,'DeleteFcn',{@closefcn})% 238 %set(handles.ListObject,'ButtonDownFcn',{@list_object_1_Callback,handles})% allows activation of lis_object_1_callback with right mouse click239 %set(handles.list_object_2,'ButtonDownFcn',{@list_object_2_Callback,handles})240 238 241 239 %% refresh projection plane … … 1329 1327 set_scan_options(hObject, eventdata, handles) 1330 1328 1331 %--------------------------------------------------- 1332 % switch file index scanning options scan_i and scan_j in an exclusive way1329 %------------------------------------------------------------------------ 1330 % --- switch file index scanning options scan_i and scan_j in an exclusive way 1333 1331 function scan_i_Callback(hObject, eventdata, handles) 1334 %--------------------------------------------------- 1332 %------------------------------------------------------------------------ 1335 1333 if get(handles.scan_i,'Value')==1 1336 1334 set(handles.scan_i,'BackgroundColor',[1 1 0]) … … 1344 1342 scan_j_Callback(hObject, eventdata, handles) 1345 1343 1346 %------------------------------------------------------------------- 1347 % switch file index scanning options scan_i and scan_j in an exclusive way1344 %------------------------------------------------------------------------ 1345 % --- switch file index scanning options scan_i and scan_j in an exclusive way 1348 1346 function scan_j_Callback(hObject, eventdata, handles) 1349 %------------------------------------------------------------------- 1347 %------------------------------------------------------------------------ 1350 1348 if get(handles.scan_j,'Value')==1 1351 1349 set(handles.scan_j,'BackgroundColor',[1 1 0]) … … 1366 1364 end 1367 1365 1368 %------------------------------------------------------------------- 1366 %------------------------------------------------------------------------ 1369 1367 function i1_Callback(hObject, eventdata, handles) 1370 %------------------------------------------------------------------- 1368 %------------------------------------------------------------------------ 1371 1369 set(handles.i1,'BackgroundColor',[0.7 0.7 0.7]) 1372 1370 NomType=get(handles.FileIndex,'UserData'); … … 1386 1384 set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7]) 1387 1385 end 1388 %Run0_Callback(hObject, eventdata, handles) 1389 1390 %------------------------------------------------------------------- 1386 1387 %------------------------------------------------------------------------ 1391 1388 function i2_Callback(hObject, eventdata, handles) 1389 %------------------------------------------------------------------------ 1392 1390 set(handles.i2,'BackgroundColor',[0.7 0.7 0.7]) 1393 1391 i1_Callback(hObject, eventdata, handles) 1394 %------------------------------------------------------------------- 1395 1396 %------------------------------------------------------------------- 1392 1393 %------------------------------------------------------------------------ 1397 1394 function j1_Callback(hObject, eventdata, handles) 1395 %------------------------------------------------------------------------ 1398 1396 set(handles.j1,'BackgroundColor',[0.7 0.7 0.7]) 1399 1397 i1_Callback(hObject, eventdata, handles) 1400 %------------------------------------------------------------------- 1401 1402 %------------------------------------------------------------------- 1398 1399 %------------------------------------------------------------------------ 1403 1400 function j2_Callback(hObject, eventdata, handles) 1401 %------------------------------------------------------------------------ 1404 1402 set(handles.j2,'BackgroundColor',[0.7 0.7 0.7]) 1405 1403 i1_Callback(hObject, eventdata, handles) 1406 %------------------------------------------------------------------- 1407 1408 %------------------------------------------------------------------- 1404 1405 %------------------------------------------------------------------------ 1409 1406 function slices_Callback(hObject, eventdata, handles) 1410 %------------------------------------------------------------------- 1407 %------------------------------------------------------------------------ 1411 1408 if get(handles.slices,'Value')==1 1412 1409 set(handles.slices,'BackgroundColor',[1 1 0]) … … 1424 1421 end 1425 1422 1426 %------------------------------------------------------------------- 1423 %------------------------------------------------------------------------ 1427 1424 function nb_slice_Callback(hObject, eventdata, handles) 1428 %------------------------------------------------------------------- 1425 %------------------------------------------------------------------------ 1429 1426 nb_slice_str=get(handles.nb_slice,'String'); 1430 1427 if isequal(nb_slice_str,'volume') … … 1541 1538 end 1542 1539 set(handles.mask_test,'UserData',[]) 1543 %huvmat=get(handles.mask_test,'parent');1544 1540 UvData=get(handles.uvmat,'UserData'); 1545 1541 if isfield(UvData,'MaskName') … … 1550 1546 end 1551 1547 1552 %------------------------------------------------------------------- 1548 %------------------------------------------------------------------------ 1553 1549 function errormsg=update_mask(handles,num_i1,num_j1) 1554 %------------------------------------------------------------------- 1550 %------------------------------------------------------------------------ 1555 1551 errormsg=[];%default 1556 1552 MaskData=get(handles.mask_test,'UserData'); … … 1633 1629 1634 1630 1635 %------------------------------------------------------------------- 1631 %------------------------------------------------------------------------ 1636 1632 function MenuExportFigure_Callback(hObject, eventdata, handles) 1637 %------------------------------------------------------------------- 1633 %------------------------------------------------------------------------ 1638 1634 huvmat=get(handles.MenuExport,'parent'); 1639 %UvData=get(huvmat,'UserData');1640 1635 hfig=figure; 1641 1636 copyobj(handles.axes3,hfig); … … 1644 1639 colorbar 1645 1640 1646 %------------------------------------------------------------------- 1647 %------------------------------------------------------------------- 1641 %------------------------------------------------------------------------ 1642 %------------------------------------------------------------------------ 1648 1643 % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' 1649 %------------------------------------------------------------------- 1650 1651 %------------------------------------------------------------------- 1644 %------------------------------------------------------------------------ 1645 1646 %------------------------------------------------------------------------ 1652 1647 % --- Executes on button press in runplus: make one step forward and call 1653 1648 % --- run0. The step forward is along the fields series 1 or 2 depending on 1654 1649 % --- the scan_i and scan_j check box (exclusive each other) 1655 1650 function runplus_Callback(hObject, eventdata, handles) 1656 %------------------------------------------------------------------- 1651 %------------------------------------------------------------------------ 1657 1652 set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow 1658 1653 drawnow … … 1669 1664 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red 1670 1665 1671 %------------------------------------------------------------------- 1666 %------------------------------------------------------------------------ 1672 1667 % --- Executes on button press in runmin: make one step backward and call 1673 1668 % --- run0. The step backward is along the fields series 1 or 2 depending on 1674 1669 % --- the scan_i and scan_j check box (exclusive each other) 1675 1670 function runmin_Callback(hObject, eventdata, handles) 1676 %------------------------------------------------------------------- 1671 %------------------------------------------------------------------------ 1677 1672 set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow 1678 1673 drawnow … … 1688 1683 set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red 1689 1684 1690 %------------------------------------------------------------------- 1685 %------------------------------------------------------------------------ 1691 1686 % -- Executes on button press in Movie: make a series of +> steps 1692 1687 function Movie_Callback(hObject, eventdata, handles) 1693 %------------------------------------------------------------------ 1688 %------------------------------------------------------------------------ 1694 1689 set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow 1695 1690 drawnow … … 1719 1714 set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1720 1715 1721 %------------------------------------------------------------------- 1716 %------------------------------------------------------------------------ 1722 1717 % -- Executes on button press in Movie: make a series of <- steps 1723 1718 function MovieBackward_Callback(hObject, eventdata, handles) 1724 %------------------------------------------------------------------ 1719 %------------------------------------------------------------------------ 1725 1720 set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow 1726 1721 drawnow … … 1750 1745 set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1751 1746 1752 %------------------------------------------------------------------- 1747 %------------------------------------------------------------------------ 1753 1748 function STOP_Callback(hObject, eventdata, handles) 1754 %------------------------------------------------------------------- 1749 %------------------------------------------------------------------------ 1755 1750 set(handles.movie_pair,'BusyAction','Cancel') 1756 1751 set(handles.movie_pair,'value',0) … … 1762 1757 set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1763 1758 1764 %------------------------------------------------------------------ 1759 %------------------------------------------------------------------------ 1765 1760 function errormsg=runpm(hObject,eventdata,handles,increment) 1766 %------------------------------------------------------------------ 1767 %check for m ï¿œovie pair status1761 %------------------------------------------------------------------------ 1762 %check for movie pair status 1768 1763 movie_status=get(handles.movie_pair,'Value'); 1769 1764 if isequal(movie_status,1) … … 1771 1766 end 1772 1767 %read the data on the current input rootfile(s) 1773 1774 1768 [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles); 1775 1769 NomType=get(handles.FileIndex,'UserData'); … … 1792 1786 filename_1=[]; 1793 1787 end 1794 1795 1788 comp_input=get(handles.fix_pair,'Value'); 1796 1789 … … 1843 1836 end 1844 1837 1845 1846 %------------------------------------------------------- 1838 %------------------------------------------------------------------------ 1847 1839 % --- Executes on button press in movie_pair: create an alternating movie with two view 1848 %-------------------------------------------------------1849 1840 function movie_pair_Callback(hObject, eventdata, handles) 1841 %------------------------------------------------------------------------ 1850 1842 status=get(handles.movie_pair,'value'); 1851 1843 if isequal(status,0) … … 3675 3667 set(handles.num_MaxVec,'String','1') 3676 3668 set(handles.num_ColCode1,'String','0.333') 3677 colcode1_Callback(hObject, eventdata, handles)3669 num_ColCode1_Callback(hObject, eventdata, handles) 3678 3670 set(handles.num_ColCode2,'String','0.666') 3679 colcode2_Callback(hObject, eventdata, handles)3671 num_ColCode2_Callback(hObject, eventdata, handles) 3680 3672 else 3681 3673 set(handles.CheckFixVecColor,'Value',1)%auto scale between min,max by default … … 3707 3699 set(handles.num_ColCode2,'String',num2str(col)) 3708 3700 end 3709 colcode1_Callback(hObject, eventdata, handles)3701 num_ColCode1_Callback(hObject, eventdata, handles) 3710 3702 3711 3703 %---------------------------------------------------------------- … … 3722 3714 set(handles.num_ColCode1,'String',num2str(col)) 3723 3715 end 3724 colcode2_Callback(hObject, eventdata, handles)3716 num_ColCode2_Callback(hObject, eventdata, handles) 3725 3717 3726 3718 %---------------------------------------------------------------- 3727 % execute on return carriage on the edit box corresponding to slider 13719 % --- Execute on return carriage on the edit box corresponding to slider 1 3728 3720 %---------------------------------------------------------------- 3729 function num_ColCode1_Callback(hObject, eventdata, handles) 3730 % col=str2num(get(handles.num_ColCode1,'String')); 3731 % set(handles.Slider1,'Value',col) 3721 function num_ColCode1_Callback(hObject, eventdata, handles) 3732 3722 set_vec_col_bar(handles) 3733 3723 update_plot(handles); 3734 3724 3735 3725 %---------------------------------------------------------------- 3736 % execute on return carriage on the edit box corresponding to slider 23726 % --- Execute on return carriage on the edit box corresponding to slider 2 3737 3727 %---------------------------------------------------------------- 3738 3728 function num_ColCode2_Callback(hObject, eventdata, handles) 3739 % col=str2num(get(handles.num_ColCode2,'String'));3740 % set(handles.Slider2,'Value',col)3741 % slider2_Callback(hObject, eventdata, handles)3742 3729 set_vec_col_bar(handles) 3743 3730 update_plot(handles); 3744 %------------------------------------------------------------ 3745 %update the slider values after displaying vectors 3746 %-------------------------------------------------------- 3747 % function slider_update(handles,auto,minC,num_ColCode1,num_ColCode2,maxC) 3748 % set(handles.Slider1,'Min',minC) 3749 % set(handles.Slider1,'Max',maxC) 3750 % set(handles.Slider2,'Min',minC) 3751 % set(handles.Slider2,'Max',maxC) 3752 % set(handles.min_title_vec,'String',num2str(minC)) 3753 % set(handles.num_MaxVec,'String',num2str(maxC)) 3754 % if auto 3755 % set(handles.num_ColCode1,'String',num2str(num_ColCode1,3))%update display 3756 % set(handles.num_ColCode2,'String',num2str(num_ColCode2,3)) 3757 % end 3758 % set(handles.Slider1,'Value',num_ColCode1)%update slider with constant display 3759 % set(handles.Slider2,'Value',num_ColCode2) 3760 % set_vec_col_bar(handles) 3761 3762 3731 %------------------------------------------------------------------------ 3763 3732 %------------------------------------------------------- 3764 3733 % --- Executes on button press in CheckFixVecColor. … … 3771 3740 function transform_fct_Callback(hObject, eventdata, handles) 3772 3741 %------------------------------------------------------------- 3773 3774 3742 UvData=get(handles.uvmat,'UserData'); 3775 3743 menu=get(handles.transform_fct,'String');
Note: See TracChangeset
for help on using the changeset viewer.