Changeset 360 for trunk/src/civ.m
- Timestamp:
- Jan 9, 2012, 1:16:35 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r356 r360 23 23 %TODO: search range 24 24 25 % Last Modified by GUIDE v2.5 21-Dec-2011 00:34:4925 % Last Modified by GUIDE v2.5 08-Jan-2012 11:00:13 26 26 % Begin initialization code - DO NOT EDIT 27 27 gui_Singleton = 1; … … 139 139 oldfile=filebase; 140 140 end 141 % ind_opening=1;%default 142 % browse.incr_pair=[0 0]; %default 143 %% get the new input fiel with the browser 141 142 %% get the new input file with the browser 144 143 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 145 144 '*.xml', '.xml files '; ... … … 159 158 [path,name,ext]=fileparts(fileinput); 160 159 testeditxml=0; 161 if isequal(ext,'.xml') 162 testeditxml=1; 163 t_browse=xmltree(fileinput); 164 head_element=get(t_browse,1); 165 if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') 166 testeditxml=0; 167 end 168 end 169 if testeditxml==1 || isequal(ext,'.xls') 170 heditxml=editxml({fileinput}); 171 set(heditxml,'Tag','browser') 172 waitfor(heditxml,'Tag','idle') 173 if ~ishandle(heditxml) 174 return 175 end 176 attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); 177 set(handles.browse,'UserData',fileinput)% store for future opening with browser 178 fileinput=get(attr,'UserData'); 179 if ~exist(fileinput,'file') 180 return 181 end 182 end 183 %[RootPath,RootFile,str1,str2,str_a,str_b,FileExt,NomType,subdir]=name2display(fileinput); 160 % if isequal(ext,'.xml') 161 % testeditxml=1; 162 % t_browse=xmltree(fileinput); 163 % head_element=get(t_browse,1); 164 % if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') 165 % testeditxml=0; 166 % end 167 % end 168 % if testeditxml==1 || isequal(ext,'.xls') 169 % heditxml=editxml({fileinput}); 170 % set(heditxml,'Tag','browser') 171 % waitfor(heditxml,'Tag','idle') 172 % if ~ishandle(heditxml) 173 % return 174 % end 175 % attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); 176 % set(handles.browse,'UserData',fileinput)% store for future opening with browser 177 % fileinput=get(attr,'UserData'); 178 % if ~exist(fileinput,'file') 179 % return 180 % end 181 % end 184 182 [tild,tild,tild,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); 185 % filebase=fullfile(RootPath,RootFile);186 187 %% record the information obtained from the input file188 % if isempty(i1),i1=1;end189 % if isempty(i2),i2=i1;end190 % if isempty(j1),j1=1;end191 % if isempty(j2),j2=j1;end192 % if isequal(get(handles.ListCompareMode,'Value'),1)193 % browse=[];%initialisation194 % else195 % browse=get(handles.RootName,'UserData');196 % end197 % browse.num_i1=i1;198 % browse.num_i2=i2;199 % browse.num_j1=j1;200 % browse.num_j2=j2;201 % if length(FileExt)>1 && (~isempty(imformats(FileExt(2:end)))||strcmpi(FileExt,'.avi'));%if an image file has been opened by uvmat202 % browse.nom_type_ima=NomType;203 % browse.ext_ima=FileExt;204 % set(handles.ImaExt,'String',FileExt)205 % end206 % set(handles.RootName,'UserData',browse);% store information from browser207 183 208 184 %% prepare the GUI with parameters from the input file … … 321 297 %------------------------------------------------------------------------ 322 298 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 323 filebase=get(handles.RootName,'String'); 324 errormsg=display_file_name(handles,filebase); 299 [RootPath,RootFile]=fileparts(get(handles.RootName,'String')); 300 ref_i=str2num(get(handles.ref_i,'String')); 301 ref_j=str2num(get(handles.ref_j,'String')); 302 NomType=get(handles.NomType,'String'); 303 ImaExt=get(handles.ImaExt,'String'); 304 fileinput=fullfile_uvmat(RootPath,'',RootFile,ImaExt,NomType,ref_i,[],ref_j) 305 errormsg=display_file_name(handles,fileinput); 325 306 if ~isempty(errormsg) 326 msgbox_uvmat('ERROR',erro msg)307 msgbox_uvmat('ERROR',errormsg) 327 308 end 328 309 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished … … 346 327 347 328 %% determine nomenclature types and extension of the input files 348 ext_ima='';%default349 NomTypeIma='';%default350 NomTypeNc='';351 %[RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,SubDir]=name2display(fileinput);352 329 [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); 353 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomTypeInput,FileType,Object]=find_file_series(fileinput); 354 if strcmp(NomTypeInput,'*')% movies will be opened at the first frame 355 i1=1; 356 i2=[]; 357 j1=[]; 358 j2=[]; 359 end 330 NomTypeNc='';%default 331 332 %% case of netcdf file as input, look for a coresponding image 360 333 ind_opening=0;%default 361 switch FileType 362 case 'civdata' 363 Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','Civ1_ImageA'); 364 if isfield(Data,'Txt') 365 errormsg=Data.Txt; 366 return 367 end 334 if strcmp(ExtInput,'.xml') 335 Param=xml2struct(fileinput); 336 fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file 337 return 338 end 339 if strcmp(ExtInput,'.nc') 340 NomTypeNc=NomTypeInput; 341 Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','fix','patch','civ2','fix2'); 342 if isfield(Data,'Txt') 343 errormsg=Data.Txt; 344 return 345 end 346 if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, 347 set(handles.MenuMatlab,'checked','on') %select civ/Matlab by default 348 set(handles.MenuCivX,'checked','off') 368 349 if ~isempty(Data.CivStage)%test for civ files 369 350 ind_opening=Data.CivStage; 370 351 end 371 if ~isempty(Data.Civ 1_ImageA)%test for civ files352 if ~isempty(Data.Civ2_ImageA)%get the corresponding input image in the netcdf file 372 353 imageinput=Data.Civ1_ImageA; 373 if ~exist(imageinput,'file') 374 errormsg=['the image ' imageinput ' does not exist, please enter an image']; 375 return 376 end 377 end 378 set(handles.MenuMatlab,'checked','on') 379 set(handles.MenuCivX,'checked','off') 380 NomTypeNc=NomTypeInput; 381 case 'civx' 382 Data=nc2struct(fileinput,'ListGlobalAttribute','fix','patch','civ2','fix2'); 354 elseif ~isempty(Data.Civ1_ImageA) 355 imageinput=Data.Civ1_ImageA; 356 end 357 elseif ~isempty(Data.absolut_time_T0')% case of civx data, 358 set(handles.MenuMatlab,'checked','off') %select Cix by default 359 set(handles.MenuCivX,'checked','on') 383 360 if ~isempty(Data.fix2) 384 361 ind_opening=5; … … 390 367 ind_opening=2; 391 368 end 392 % look for the input images369 % look for the corresponding input images 393 370 check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$'));%detect pair label by letter 394 371 NomTypeIma=NomTypeInput; … … 396 373 NomTypeIma=NomTypeInput(1:end-1); 397 374 else 398 r=regexp(NomTypeIma,'.-(?<num2>\d+ $','names');375 r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names'); 399 376 if ~isempty(r) 400 377 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 401 378 end 379 r=regexp(NomTypeIma,'.-(?<num2>\d+)','names'); 380 if ~isempty(r) 381 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); 382 end 402 383 end 403 384 imageinput=fullfile_uvmat(RootPath,'',RootFile,'.png',NomTypeIma,i1,[],j1); 404 if ~exist(imageinput,'file') 405 errormsg='no image corresponds to the input .nc file, please open an image'; 406 return 407 end 385 else 386 errormsg='the input netcdf file is not civ data'; 387 return 388 end 389 end 390 391 %% scan the image series when a nc file has been opened 392 ImaExt=ExtInput; 393 if ~isempty(NomTypeNc) 394 %no corresponding image found, select manually with the browser 395 if ~exist(imageinput,'file') 396 menu={'*.png;*.jpg;*.tif;*.avi;*.AVI', '(*.png,*.jpg ,*.tif, *.avi,*.AVI)'; 397 '*.png','.png image files'; ... 398 '*.jpg',' jpeg image files'; ... 399 '*.tif','.tif image files'; ... 400 '*.avi;*.AVI','.avi movie files'; ... 401 '*.*', 'All Files (*.*)'}; 402 [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput))); 403 imageinput=[PathName FileName];%complete file name 404 405 end 406 fileinput=imageinput; 407 [tild, tild,ImaExt]=fileparts(imageinput); 408 end 409 [RootPath,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object]=find_file_series(fileinput); 410 if strcmp(NomTypeInput,'*')% movies will be opened at the first frame 411 i1=1; 412 i2=[]; 413 j1=[]; 414 j2=[]; 415 end 416 switch FileType 408 417 case {'image','multimage','video'} 409 imageinput=fileinput;410 NomTypeIma=NomTypeInput;411 ext_ima=ExtInput;412 418 otherwise 413 errormsg='invalid input file: enter an image, a movie or .nc file';414 end 415 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomTypeIma,ImageType,Object]=find_file_series(imageinput); 419 errormsg='invalid input file: enter an image, a movie or civ .nc file'; 420 return 421 end 416 422 RootName=fullfile(RootPath,RootFile); 417 423 set(handles.RootName,'String',RootName) 424 browse=get(handles.RootName,'UserData'); 425 browse.nom_type_nc=NomTypeNc; 426 browse.incr_pair=[0 0];%default 427 428 %% fill reference indices from the input file indices 429 num_ref_i=i1;%efaulmt ref index 430 if ~isempty(i2) 431 num_ref_i=floor((num_ref_i+i2)/2); 432 end 433 num_ref_j=j1; 434 if ~isempty(j2) 435 num_ref_i=floor((num_ref_j+j2)/2); 436 end 437 438 %% scan the images if a civ file has been opened 439 if ~isempty(NomTypeNc) 440 [RootPath,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,ImageType,Object]=find_file_series(imageinput); 441 end 418 442 MaxIndex_i=max(i1_series(i1_series>0)); 419 443 MaxIndex_j=max(j1_series(j1_series>0)); 420 421 num_ref_i=i1;%efaulmt ref index422 num_ref_j=j1;423 browse=get(handles.RootName,'UserData');424 browse.nom_type_nc=NomTypeNc;425 browse.nom_type_ima=NomTypeInput;426 browse.incr_pair=[0 0];%default427 428 % % form=imformats(ext_input(2:end));429 % check_letter=0;430 % check_separator=0;431 % if ~isempty(ext_input)&&(~isempty(imformats(ext_input(2:end)))||strcmpi(ext_input,'.avi'))% if the extension corresponds to an image or movie format recognized by Matlab432 % ext_ima=ext_input;433 % nom_type_ima=nom_type_input;434 % imagename=fileinput;435 % check_letter=~isempty(regexp(nom_type_ima,'[a|A]$'));%detect pair label by letter436 % else %case of netcdf input file, look for corresponding images437 % nom_type_nc=nom_type_input;438 % imagename=fullfile_uvmat(RootPath,[],RootFile,ext_ima,nom_type_ima,1,[],1);439 % %imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima);440 % i1_str='';441 % j1_str='';442 % if ~isnan(i2)443 % num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file444 % browse.incr_pair(1)=i2-i1;445 % browse.incr_pair(2)=0;446 % end447 % %TODO: read the image name in the netcdf file (if documented)448 % %look for double image series '_i_j'449 % check_letter=~isempty(regexp(nom_type_nc,'[ab|AB]$'));%detect pair label by letter450 % if check_letter451 % j1_str=nom_type_nc(end-1);452 % r=regexp(nom_type_nc,'_(?<num1>\d+)','names');453 % if ~isempty(r)454 % i1_str=r.num1;455 % end456 % else457 % NomTypeIma=regexprep(nom_type_nc,'-\d','');%458 % r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names');459 % if ~isempty(r_end)460 % j1_str=r.num2;461 % end462 % end463 % r=regexp(NomTypeIma,'_(?<num1>\d+)','names');464 % if ~isempty(r)465 % i1_str=r.num1;466 % end467 % dirima=dir([RootName '_' i1_str '_' j1_str '.*']);468 % if isempty(dirima)469 % % look for images series with sub marker '_'470 % dirima=dir([RootName '_*' i1_str '.*']);471 % if isempty(dirima)472 % % look for other images series473 % dirima=dir([RootName '*' i1_str '.*']);474 % if isempty(dirima)475 % % look for other images series witth letter appendix476 % appendix=char(96+j1_str);477 % dirima=dir([RootName '*' i1_str appendix '.*']);478 % end479 % end480 % end481 % for ilist=1:numel(dirima)482 % %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);483 % [tild,tild,tild,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name);484 % form=imformats(ext_list(2:end));485 % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab486 % ext_ima=ext_list;487 % nom_type_ima=nom_type_list;488 % % i1=str2double(i1_str);489 % % j1=str2double(j1_str);490 % % i2=str2double(i2_str);491 % % j2=str2double(j2_str);492 % % set the range of fields (1:1 by default) and selected pair493 % if isempty(i2)494 % num_ref_i=i1;495 % else496 % num_ref_i=floor((i1+i2)/2);497 % browse.incr_pair(1)=i2-i1;498 % browse.incr_pair(2)=0;499 % end500 % if isempty(j2)501 % if isempty(j1)502 % num_ref_j=1;503 % else504 % num_ref_j=j1;505 % end506 % else507 % num_ref_j=floor((j1+j2)/2);508 % browse.incr_pair(2)=j2-j1;509 % end510 % break511 % end512 % end513 % end514 515 444 516 445 %% look for an image documentation file … … 528 457 end 529 458 set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used 530 531 459 532 460 %% read the time in the image documentation file … … 594 522 case {'.avi','.AVI'} 595 523 nom_type_ima='*'; 596 ext_ima=ext_imadoc;524 ImaExt=ext_imadoc; 597 525 set(handles.ListPairMode,'Value',1); 598 526 set(handles.ListPairMode,'String',{'series(Di)'}) … … 632 560 set(handles.CoordUnit,'String',CoordUnit) 633 561 set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); 634 set(handles.ImaExt,'String',ext_ima) 562 set(handles.ImaExt,'String',ImaExt) 563 set(handles.NomType,'String',NomTypeIma) 635 564 set(handles.ref_i,'String',num2str(num_ref_i)) 636 565 set(handles.first_i,'String',num2str(num_ref_i)); … … 639 568 set(handles.first_j,'String',num2str(num_ref_j)); 640 569 set(handles.last_j,'String',num2str(num_ref_j));% 570 % set(handles.civ,'UserData',CivData) 641 571 642 572 %% set the civ options depending on the input file content 643 % ind_opening=0;%default644 % if isequal(ext_input,'.nc')645 % browse.nom_type_nc=nom_type_input;646 % ind_opening=2;% propose 'fix' as the default option647 % Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2');648 % if isfield(Data,'Txt')649 % msgbox_uvmat('ERROR',Data.Txt)650 % return651 % end652 % if ~isempty(Data.CivStage)%test for civ files653 % ind_opening=Data.CivStage;654 % set(handles.ListPairMode,'Value',3)655 % end656 % end657 573 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; 658 574 for index = 1:ind_opening … … 664 580 update_CivOptions(handles,1) 665 581 666 667 582 %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% 668 % test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'))%=1 for images with single indexing669 % TODO: determine MaxIndex_i and MaxIndex_j using find_file_series (in the absence of xml file)670 % try671 583 check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter 672 584 if ~check_letter|| isequal(NomTypeNc,'_1-2')|| (MaxIndex_j==1) … … 680 592 else 681 593 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice 682 if MaxIndex_j <= 10 594 if strcmp(NomTypeNc,'_1-2_1') 595 set(handles.ListPairMode,'Value',3)% advise 'series(Di)' 596 elseif MaxIndex_j <= 10 683 597 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 684 598 end 685 599 end 686 % end687 600 688 601 %% update the subdirectory display … … 728 641 729 642 %% store info 730 % browse.nom_type_ima=nom_type_ima;731 643 set(handles.RootName,'UserData',browse)% store the nomenclature type 732 644 733 645 %% list the possible index pairs, depending on the option set in ListPairMode 734 646 ListPairMode_Callback([], [], handles) 735 browse=get(handles.RootName,'UserData');736 647 737 648 %% store the root input filename for future opening 738 649 profil_perso=fullfile(prefdir,'uvmat_perso.mat'); 739 % RootPath=fileparts(RootName);740 650 if exist(profil_perso,'file') 741 651 save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat … … 769 679 set(handles.ListSubdirCiv2,'Value',ilist) 770 680 else % if Civ1 data already exist 771 find_netcpair_civ 1(handles); %update the list of available pairs from netcdf files in the new directory681 find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory 772 682 end 773 683 … … 787 697 %update the list of available pairs from netcdf files in the new directory 788 698 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 789 find_netcpair_civ 2(handles);699 find_netcpair_civ(handles,2); 790 700 end 791 701 … … 849 759 set(handles.ListSubdirCiv1,'Visible','on') 850 760 if ~opening 851 find_netcpair_civ 1(handles) % select the available netcdf files761 find_netcpair_civ(handles,1) % select the available netcdf files 852 762 end 853 763 if max(checkbox(4:6))% case of civ2 pair choice needed … … 858 768 set(handles.ListPairCiv2,'Visible','on') 859 769 if ~opening 860 find_netcpair_civ 2(handles) % select the available netcdf files770 find_netcpair_civ(handles,2) % select the available netcdf files 861 771 end 862 772 else … … 1757 1667 end 1758 1668 end 1759 %[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,SubDir]=name2display(fileresu);1760 1669 [RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu); 1761 1670 namedoc=fullfile(RootPath,SubDir,RootFile); … … 1771 1680 end 1772 1681 end 1682 t=struct2xml(Param); 1683 save(t,[namedoc '.xml']); %save GUI parameters as xml file 1773 1684 saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) 1774 1685 … … 1844 1755 val=get(handles.ListCompareMode,'Value'); 1845 1756 compare=compare_list{val}; 1846 if strcmp(compare,'displacement') 1757 if strcmp(compare,'displacement')||strcmp(compare,'shift') 1847 1758 mode='displacement'; 1848 1759 else … … 1853 1764 %time=get(handles.RootName,'UserData'); %get the set of times 1854 1765 ext_ima=get(handles.ImaExt,'String'); 1855 nom_type_nc=browse.nom_type_nc; 1856 if isfield(browse,'nom_type_ima') 1857 nom_type_ima2=browse.nom_type_ima; 1858 end 1859 if isempty(nom_type_ima2),nom_type_ima2='1';end; %default 1860 if isempty(nom_type_nc),nom_type_nc='_1-2';end; %default 1766 if strcmp(compare,'displacement') 1767 nom_type_ima1='*'; 1768 else 1769 nom_type_ima1=get(handles.NomType,'String'); 1770 end 1771 nom_type_nc=nomtype2pair(nom_type_ima1,mode); 1772 1861 1773 [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... 1862 1774 find_pair_indices(handles,ref_i,ref_j,mode); 1863 1775 %determine the new filebase for 'displacement' ListPairMode (comparison of two series) 1864 1776 filebase_B=filebase;% root name of the second field series for stereo 1865 if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') 1866 % test_disp=1; 1867 nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series 1777 if ~strcmp(compare,'PIV') 1868 1778 [Path2,Name2]=fileparts(filebase_B); 1869 1779 Path1=Path2; … … 1880 1790 % test_disp=0; 1881 1791 filebase_A=filebase; 1882 nom_type_ima 1=nom_type_ima2;1792 nom_type_ima2=nom_type_ima1; 1883 1793 filebase_AB=filebase; 1884 1794 end 1885 if strcmp(compare,'displacement') 1795 if strcmp(compare,'displacement')||strcmp(compare,'shift') 1886 1796 filebase_ima1=filebase_A; 1887 1797 filebase_ima2=filebase_B; … … 2353 2263 for j=1:nbslice 2354 2264 filename=fullfile_uvmat(RootPath_A,subdir_civ2,RootFile_A,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j)); 2355 % filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...2356 % nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%2357 2265 filecell.ncA.civ2(ifile,j)={filename}; 2358 2266 if ~exist(filename,'file') … … 2372 2280 for j=1:nbslice 2373 2281 filename=fullfile_uvmat(RootPath_nc,subdir_civ2,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j)); 2374 % filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...2375 % nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);2376 2282 detect=exist(filename,'file')==2; 2377 2283 filecell.nc.civ2(ifile,j)={filename}; … … 2425 2331 for j=1:nbslice 2426 2332 filename=fullfile_uvmat(RootPath_nc,subdir_civ2,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j)); 2427 % filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...2428 % nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%2429 2333 filecell.nc.civ2(ifile,j)={filename}; 2430 2334 if ~exist(filename,'file') … … 2455 2359 for j=1:nbslice 2456 2360 filename=fullfile_uvmat(RootPath_AB,subdir_civ1,RootFile_AB,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j)); 2457 % filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',...2458 % nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%2459 2361 filecell.st(ifile,j)={filename}; 2460 2362 end … … 2465 2367 for j=1:nbslice 2466 2368 filename=fullfile_uvmat(RootPath_AB,subdir_civ2,RootFile_AB,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j)); 2467 % filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',...2468 % nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%2469 2369 filecell.st(ifile,j)={filename}; 2470 2370 end … … 2690 2590 function ListCompareMode_Callback(hObject, eventdata, handles) 2691 2591 %------------------------------------------------------------------------ 2692 test=get(handles.ListCompareMode,'Value'); 2693 if test==2 || test==3 % case 'displacement' or 'stereo PIV' 2592 menu=get(handles.ListCompareMode,'String'); 2593 val=get(handles.ListCompareMode,'Value'); 2594 option=menu{val}; 2595 if ~strcmp(option,'PIV') % case 'displacement' or 'stereo PIV' 2694 2596 filebase=get(handles.RootName,'String'); 2695 2597 browse=get(handles.RootName,'Userdata'); 2696 browse.nom_type_ima1=browse.nom_type_ima;2598 % browse.nom_type_ima1=browse.nom_type_ima; 2697 2599 set(handles.RootName,'UserData',browse); 2698 2600 set(handles.sub_txt,'Visible','on') … … 2735 2637 msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') 2736 2638 return 2737 end 2738 % set(handles.RootName_1,'String',name); 2739 %[RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,SubDir]=name2display(name); 2639 end 2740 2640 [tild,tild,RootFile,tild,tild,tild,tild,tild,nom_type]=fileparts_uvmat(name); 2741 2641 set(handles.RootName_1,'String',RootFile); 2742 2642 browse=get(handles.RootName,'UserData'); 2743 browse.nom_type_ima_1=nom_type;2643 %browse.nom_type_ima_1=nom_type; 2744 2644 set(handles.RootName,'UserData',browse) 2745 2645 … … 2749 2649 return 2750 2650 end 2751 2752 %% check coincidence of image sizes 2753 % ref_i=get(handles.ref_i,'string'); 2754 % ref_j=get(handles.ref_j,'string'); 2755 % [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]); 2756 % A=imread(filecell.ima1.checkciv1{1}); 2757 % A_1=imread(fileinput); 2758 % npxy=size(A); 2759 % npxy_1=size(A_1); 2760 % if ~isequal(size(A),size(A_1)) 2761 % msgbox_uvmat('ERROR','The two input image series do not have the same size') 2762 % return 2763 % end 2651 2764 2652 else 2765 2653 set(handles.ListPairMode,'Visible','on') … … 2770 2658 set(handles.ListPairMode,'Value',1) 2771 2659 set(handles.ListPairMode,'String',mode_store) 2772 % set(handles.test_stereo1,'Value',0)2773 2660 set(handles.CheckStereo,'Value',0) 2774 2661 set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default 2775 2662 end 2776 if test==3&& get(handles.CheckPatch1,'Value')2663 if strcmp(option,'stereo PIV') && get(handles.CheckPatch1,'Value') 2777 2664 set(handles.CheckStereo,'Visible','on') 2778 2665 else 2779 2666 set(handles.CheckStereo,'Visible','off') 2780 2667 end 2781 if test==3&& get(handles.CheckPatch2,'Value')2668 if strcmp(option,'stereo PIV') && get(handles.CheckPatch2,'Value') 2782 2669 set(handles.CheckStereo,'Visible','on') 2783 2670 else … … 2797 2684 val=get(handles.ListCompareMode,'Value'); 2798 2685 compare=compare_list{val}; 2799 if strcmp(compare,'displacement') 2686 if strcmp(compare,'displacement')||strcmp(compare,'shift') 2800 2687 mode='displacement'; 2801 2688 else … … 2821 2708 % are relative to the reference indices ref_i and ref_j respectively. 2822 2709 if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') 2823 2824 2710 dt=1; 2825 2711 displ=''; … … 2850 2736 displ_num(3,:)=0; 2851 2737 displ_num(4,:)=0; 2852 set(handles.jtext,'Visible','Off') 2853 set(handles.first_j,'Visible','Off') 2854 set(handles.last_j,'Visible','Off') 2855 set(handles.incr_j,'Visible','Off') 2856 set(handles.nb_field2,'Visible','Off') 2857 set(handles.ref_j,'Visible','Off') 2738 enable_j(handles, 'off') 2858 2739 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') 2859 2740 index=1:200; … … 2861 2742 displ_num(2,index)=ceil(index/2); 2862 2743 displ_num(3:4,index)=zeros(2,200); 2863 % for index=1:min(nbfield2-1,200) 2864 % displ_num(1,index)=-floor(index/2); 2865 % displ_num(2,index)=ceil(index/2); 2866 % displ_num(3,index)=0; 2867 % displ_num(4,index)=0; 2868 % end 2869 set(handles.jtext,'Visible','On') 2870 set(handles.first_j,'Visible','On') 2871 set(handles.last_j,'Visible','On') 2872 set(handles.incr_j,'Visible','On') 2873 set(handles.nb_field2,'Visible','On') 2874 set(handles.ref_j,'Visible','On') 2875 % if nbfield > 1 2876 % set(handles.itext,'Visible','On') 2877 % set(handles.first_i,'Visible','On') 2878 % set(handles.last_i,'Visible','On') 2879 % set(handles.incr_i,'Visible','On') 2880 % set(handles.nb_field,'Visible','On') 2881 % set(handles.ref_i,'Visible','On') 2882 % else 2883 % set(handles.itext,'Visible','Off') 2884 % set(handles.first_i,'Visible','Off') 2885 % set(handles.last_i,'Visible','Off') 2886 % set(handles.incr_i,'Visible','Off') 2887 % set(handles.nb_field,'Visible','Off') 2888 % set(handles.ref_i,'Visible','Off') 2889 % end 2744 enable_j(handles, 'on') 2890 2745 elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') 2891 2746 index=1:200; … … 2893 2748 displ_num(3,index)=-floor(index/2); 2894 2749 displ_num(4,index)=ceil(index/2); 2895 % for index=1:200%min(nbfield-1,200) 2896 % displ_num(1,index)=0; 2897 % displ_num(2,index)=0; 2898 % displ_num(3,index)=-floor(index/2); 2899 % displ_num(4,index)=ceil(index/2); 2900 % end 2901 set(handles.itext,'Visible','On') 2902 set(handles.first_i,'Visible','On') 2903 set(handles.last_i,'Visible','On') 2904 set(handles.incr_i,'Visible','On') 2905 set(handles.nb_field,'Visible','On') 2906 set(handles.ref_i,'Visible','On') 2750 enable_i(handles, 'on') 2907 2751 if nbfield2 > 1 2908 set(handles.jtext,'Visible','On') 2909 set(handles.first_j,'Visible','On') 2910 set(handles.last_j,'Visible','On') 2911 set(handles.incr_j,'Visible','On') 2912 set(handles.nb_field2,'Visible','On') 2913 set(handles.ref_j,'Visible','On') 2752 enable_j(handles, 'on') 2914 2753 else 2915 set(handles.jtext,'Visible','Off') 2916 set(handles.first_j,'Visible','Off') 2917 set(handles.last_j,'Visible','Off') 2918 set(handles.incr_j,'Visible','Off') 2919 set(handles.nb_field2,'Visible','Off') 2920 set(handles.ref_j,'Visible','Off') 2754 enable_j(handles, 'off') 2921 2755 end 2922 2756 elseif isequal(mode,'displacement')%the pairs have the same indices … … 2926 2760 displ_num(4,1)=0; 2927 2761 if nbfield > 1 || nbfield==0 2928 set(handles.itext,'Visible','On') 2929 set(handles.first_i,'Visible','On') 2930 set(handles.last_i,'Visible','On') 2931 set(handles.incr_i,'Visible','On') 2932 set(handles.nb_field,'Visible','On') 2933 set(handles.ref_i,'Visible','On') 2762 enable_i(handles, 'on') 2934 2763 else 2935 set(handles.itext,'Visible','Off') 2936 set(handles.first_i,'Visible','Off') 2937 set(handles.last_i,'Visible','Off') 2938 set(handles.incr_i,'Visible','Off') 2939 set(handles.nb_field,'Visible','Off') 2940 set(handles.ref_i,'Visible','Off') 2764 enable_j(handles, 'off') 2941 2765 end 2942 2766 if nbfield2 > 1 2943 set(handles.jtext,'Visible','On') 2944 set(handles.first_j,'Visible','On') 2945 set(handles.last_j,'Visible','On') 2946 set(handles.incr_j,'Visible','On') 2947 set(handles.nb_field2,'Visible','On') 2948 set(handles.ref_j,'Visible','On') 2767 enable_j(handles, 'on') 2949 2768 else 2950 set(handles.jtext,'Visible','Off') 2951 set(handles.first_j,'Visible','Off') 2952 set(handles.last_j,'Visible','Off') 2953 set(handles.incr_j,'Visible','Off') 2954 set(handles.nb_field2,'Visible','Off') 2955 set(handles.ref_j,'Visible','Off') 2769 enable_j(handles, 'off') 2956 2770 end 2957 2771 end 2958 2772 set(handles.ListPairCiv1,'UserData',displ_num); 2959 find_netcpair_civ1( handles) 2960 find_netcpair_civ2(handles) 2961 browse=get(handles.RootName,'UserData'); 2773 find_netcpair_civ( handles,1) 2774 % find_netcpair_civ2(handles) 2775 2776 function enable_i(handles, state) 2777 set(handles.itext,'Visible',state) 2778 set(handles.first_i,'Visible',state) 2779 set(handles.last_i,'Visible',state) 2780 set(handles.incr_i,'Visible',state) 2781 set(handles.nb_field,'Visible',state) 2782 set(handles.ref_i,'Visible',state) 2783 2784 function enable_j(handles, state) 2785 set(handles.jtext,'Visible',state) 2786 set(handles.first_j,'Visible',state) 2787 set(handles.last_j,'Visible',state) 2788 set(handles.incr_j,'Visible',state) 2789 set(handles.nb_field2,'Visible',state) 2790 set(handles.ref_j,'Visible',state) 2791 2962 2792 2963 2793 %------------------------------------------------------------------------ … … 3052 2882 mode_value=get(handles.ListPairMode,'Value'); 3053 2883 mode=mode_list{mode_value}; 3054 find_netcpair_civ 1(handles);% update the menu of pairs depending on the available netcdf files2884 find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files 3055 2885 if isequal(mode,'series(Di)') || ...% we do patch2 only 3056 2886 (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) 3057 find_netcpair_civ 2( handles);2887 find_netcpair_civ( handles,2); 3058 2888 end 3059 2889 … … 3065 2895 mode=mode_list{mode_value}; 3066 2896 if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') 3067 find_netcpair_civ 1(handles);% update the menu of pairs depending on the available netcdf files2897 find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files 3068 2898 end 3069 2899 if isequal(mode,'series(Dj)') || ... 3070 2900 (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) 3071 find_netcpair_civ 2(handles);2901 find_netcpair_civ(handles,2); 3072 2902 end 3073 2903 % 2904 3074 2905 %------------------------------------------------------------------------ 3075 2906 % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of 3076 2907 % the field series set by first_i, incr, last_i 3077 function find_netcpair_civ 1(handles)2908 function find_netcpair_civ(handles,index) 3078 2909 %------------------------------------------------------------------------ 3079 2910 set(gcf,'Pointer','watch') 3080 %nomenclature types3081 2911 filebase=get(handles.RootName,'String'); 3082 2912 [filepath,Nme,ext_dir]=fileparts(filebase); … … 3095 2925 mode=mode_list{mode_value}; 3096 2926 end 3097 3098 % nomenclature type of the .nc files 3099 nom_type_ima=[];%default 3100 if isfield(browse,'nom_type_ima') 3101 nom_type_ima=browse.nom_type_ima; 3102 end 3103 3104 %determine nom_type_nc: 3105 nom_type_nc=[];%default 2927 nom_type_ima=get(handles.NomType,'String'); 2928 2929 %% determine nom_type_nc, nomenclature type of the .nc files: 2930 nom_type_nc='';%default 3106 2931 if isfield(browse,'nom_type_nc') 3107 2932 nom_type_nc=browse.nom_type_nc; 3108 2933 end 3109 2934 if isempty(nom_type_nc) 3110 [nom_type_nc]=nomtype2pair(nom_type_ima, isequal(mode,'series(Di)'),isequal(mode,'series(Dj)'));2935 [nom_type_nc]=nomtype2pair(nom_type_ima,mode); 3111 2936 end 3112 2937 browse.nom_type_nc=nom_type_nc; … … 3115 2940 %reads .nc subdirectoy and image numbers from the interface 3116 2941 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 2942 subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 3117 2943 ref_i=str2double(get(handles.ref_i,'String')); 3118 2944 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') … … 3122 2948 end 3123 2949 time=get(handles.ImaDoc,'UserData');%get the set of times 3124 % if isempty(time)3125 % time=[0 1];3126 % end3127 2950 TimeUnit=get(handles.TimeUnit,'String'); 3128 2951 checkframe=strcmp(TimeUnit,'frame'); 3129 3130 2952 displ_num=get(handles.ListPairCiv1,'UserData'); 3131 2953 … … 3151 2973 %% case with no Civ1 operation, netcdf files need to exist for reading 3152 2974 [RootPath,RootFile]=fileparts(filebase); 2975 if index==1 % case civ1 3153 2976 if ~get(handles.CheckCiv1,'Value') % 3154 2977 if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') … … 3160 2983 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... 3161 2984 ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); 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 2985 select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist 3165 2986 end … … 3172 2993 num_j2=ref_j+ceil(browse.incr_pair(2)/2); 3173 2994 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); 3174 %filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);3175 2995 select(1)=exist(filename,'file')==2; 3176 2996 testpair=1; … … 3186 3006 end 3187 3007 end 3008 end 3009 else %case civ2 3010 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 3011 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 3012 errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) 3013 set(handles.ListPairCiv2,'Value',1); 3014 set(handles.ListPairCiv2,'String',{''}); 3015 return 3016 end 3017 for ipair=1:nbpair 3018 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... 3019 ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); 3020 select(ipair)=exist(filename,'file')==2; 3021 end 3022 if isequal(select,zeros(size(1:nbpair))) 3023 if isfield(browse,'incr_pair') 3024 num_i1=ref_i-floor(browse.incr_pair(1)/2); 3025 num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); 3026 num_j1=ref_j-floor(browse.incr_pair(2)/2); 3027 num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); 3028 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); 3029 select(1)=exist(filename,'file')==2; 3030 else 3031 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3032 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) 3033 else 3034 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) 3035 end 3036 set(handles.ListPairCiv2,'Value',1); 3037 set(handles.ListPairCiv2,'String',{''}); 3038 return 3039 end 3040 end 3041 end 3188 3042 end 3189 3043 … … 3270 3124 % determine the menu for checkciv2 pairs depending on the existing netcdf file at the 3271 3125 %middle of the series set by first_i, incr, last_i 3272 function find_netcpair_civ2(handles) 3273 %------------------------------------------------------------------------ 3274 set(gcf,'Pointer','watch') 3275 %nomenclature types 3276 filebase=get(handles.RootName,'String'); 3277 [filepath,Nme,ext_dir]=fileparts(filebase); 3278 browse=get(handles.RootName,'UserData'); 3279 compare_list=get(handles.ListCompareMode,'String'); 3280 val=get(handles.ListCompareMode,'Value'); 3281 compare=compare_list{val}; 3282 if strcmp(compare,'displacement') 3283 mode='displacement'; 3284 else 3285 mode_list=get(handles.ListPairMode,'String'); 3286 if isempty(mode_list) 3287 msgbox_uvmat('ERROR','please enter an input image or netcdf file') 3288 return 3289 end 3290 mode_value=get(handles.ListPairMode,'Value'); 3291 mode=mode_list{mode_value}; 3292 end 3293 3294 % nomenclature type of the .nc files 3295 nom_type_ima='ima_num';%default 3296 if isfield(browse,'nom_type_ima') 3297 nom_type_ima=browse.nom_type_ima; 3298 end 3299 nom_type_nc='_1-2';%default 3300 if isfield(browse,'nom_type_nc') 3301 nom_type_nc=browse.nom_type_nc; 3302 end 3303 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') 3304 nom_type_nc='netc_old';%nom_type for the netcdf files 3305 elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') 3306 nom_type_nc='none'; 3307 elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_1-2') 3308 nom_type_nc='_1-2'; 3309 else 3310 if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') 3311 nom_type_nc='_1-2_1'; % PIV in volume 3312 else 3313 nom_type_nc='_1_1-2'; 3314 end 3315 end 3316 browse.nom_type_nc=nom_type_nc; 3317 set(handles.RootName,'UserData',browse) 3318 3319 %reads .nc subdirectory and image numbers from the interface 3320 subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 3321 subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 3322 ref_i=str2double(get(handles.ref_i,'String')); 3323 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 3324 ref_j=0; 3325 else 3326 ref_j=str2double(get(handles.ref_j,'String')); 3327 end 3328 time=get(handles.ImaDoc,'UserData'); %get the set of times 3329 TimeUnit=get(handles.TimeUnit,'String'); 3330 checkframe=strcmp(TimeUnit,'frame'); 3331 % if isempty(time) 3332 % time=[0 1];%default 3126 % function find_netcpair_civ2(handles) 3127 % %------------------------------------------------------------------------ 3128 % set(gcf,'Pointer','watch') 3129 % %nomenclature types 3130 % filebase=get(handles.RootName,'String'); 3131 % [filepath,Nme,ext_dir]=fileparts(filebase); 3132 % browse=get(handles.RootName,'UserData'); 3133 % compare_list=get(handles.ListCompareMode,'String'); 3134 % val=get(handles.ListCompareMode,'Value'); 3135 % compare=compare_list{val}; 3136 % if strcmp(compare,'displacement') 3137 % mode='displacement'; 3138 % else 3139 % mode_list=get(handles.ListPairMode,'String'); 3140 % if isempty(mode_list) 3141 % msgbox_uvmat('ERROR','please enter an input image or netcdf file') 3142 % return 3143 % end 3144 % mode_value=get(handles.ListPairMode,'Value'); 3145 % mode=mode_list{mode_value}; 3333 3146 % end 3334 displ_num=get(handles.ListPairCiv1,'UserData'); 3335 3336 %eliminate the first pairs inconsistent with the position 3337 if isempty(displ_num) 3338 nbpair=0; 3339 else 3340 nbpair=length(displ_num(1,:));%nbre of displayed pairs 3341 if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') 3342 nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 3343 elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3344 nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 3345 end 3346 end 3347 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 3348 3349 %% look for existing processed pairs at the reference indices if Civ1 will not 3350 % be performed, while the result is needed for next steps. 3351 displ_pair={''}; %default 3352 select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs 3353 [RootPath,RootFile]=fileparts(filebase); 3354 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 3355 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 3356 errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) 3357 set(handles.ListPairCiv2,'Value',1); 3358 set(handles.ListPairCiv2,'String',{''}); 3359 return 3360 end 3361 for ipair=1:nbpair 3362 filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... 3363 ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); 3364 % filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 3365 % ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); 3366 select(ipair)=exist(filename,'file')==2; 3367 end 3368 if isequal(select,zeros(size(1:nbpair))) 3369 if isfield(browse,'incr_pair') 3370 num_i1=ref_i-floor(browse.incr_pair(1)/2); 3371 num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); 3372 num_j1=ref_j-floor(browse.incr_pair(2)/2); 3373 num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); 3374 filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); 3375 %filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); 3376 select(1)=exist(filename,'file')==2; 3377 else 3378 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3379 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) 3380 else 3381 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) 3382 end 3383 set(handles.ListPairCiv2,'Value',1); 3384 set(handles.ListPairCiv2,'String',{''}); 3385 return 3386 end 3387 end 3388 end 3389 if isequal(mode,'series(Di)') 3390 for ipair=1:nbpair 3391 if select(ipair) 3392 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3393 if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3394 dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt 3395 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3396 end 3397 else 3398 displ_pair{ipair}='...'; %pair not displayed in the menu 3399 end 3400 end 3401 elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index 3402 for ipair=1:nbpair 3403 if select(ipair) 3404 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3405 if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)&& displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1 3406 dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt 3407 else 3408 dt=1; 3409 end 3410 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3411 else 3412 displ_pair{ipair}='...'; %pair not displayed in the menu 3413 end 3414 end 3415 elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs 3416 for ipair=1:nbpair 3417 if select(ipair) 3418 if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) && displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1 3419 dt=time(ref_i+displ_num(4,ipair)+1,displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,displ_num(1,ipair)+1);%time interval dt 3420 else 3421 dt=1; 3422 end 3423 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair)+1,nom_type_ima) '-' num2stra(displ_num(2,ipair)+1,nom_type_ima) ... 3424 ' :dt= ' num2str(dt*1000)]; 3425 3426 else 3427 displ_pair{ipair}='...'; %pair not displayed in the menu 3428 end 3429 end 3430 elseif isequal(mode,'displacement') 3431 displ_pair={'Di=Dj=0'}; 3432 end 3433 val=get(handles.ListPairCiv2,'Value'); 3434 ichoice=find(select,1); 3435 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 3436 if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 3437 val=ichoice;% first valid pair proposed by default in the menu 3438 end 3439 if val>length(displ_pair') 3440 set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu 3441 else 3442 set(handles.ListPairCiv2,'Value',val); 3443 end 3444 set(handles.ListPairCiv2,'String',displ_pair'); 3445 set(gcf,'Pointer','arrow') 3147 % 3148 % % nomenclature type of the .nc files 3149 % nom_type_ima='ima_num';%default 3150 % NomTypeIma=get(handles.NomType,'String'); 3151 % nom_type_nc='_1-2';%default 3152 % if isfield(browse,'nom_type_nc') 3153 % nom_type_nc=browse.nom_type_nc; 3154 % end 3155 % 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') 3156 % nom_type_nc='netc_old';%nom_type for the netcdf files 3157 % elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') 3158 % nom_type_nc='none'; 3159 % elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_1-2') 3160 % nom_type_nc='_1-2'; 3161 % else 3162 % if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') 3163 % nom_type_nc='_1-2_1'; % PIV in volume 3164 % else 3165 % nom_type_nc='_1_1-2'; 3166 % end 3167 % end 3168 % browse.nom_type_nc=nom_type_nc; 3169 % set(handles.RootName,'UserData',browse) 3170 % 3171 % %reads .nc subdirectory and image numbers from the interface 3172 % subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 3173 % subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 3174 % ref_i=str2double(get(handles.ref_i,'String')); 3175 % if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 3176 % ref_j=0; 3177 % else 3178 % ref_j=str2double(get(handles.ref_j,'String')); 3179 % end 3180 % time=get(handles.ImaDoc,'UserData'); %get the set of times 3181 % TimeUnit=get(handles.TimeUnit,'String'); 3182 % checkframe=strcmp(TimeUnit,'frame'); 3183 % % if isempty(time) 3184 % % time=[0 1];%default 3185 % % end 3186 % displ_num=get(handles.ListPairCiv1,'UserData'); 3187 % 3188 % %eliminate the first pairs inconsistent with the position 3189 % if isempty(displ_num) 3190 % nbpair=0; 3191 % else 3192 % nbpair=length(displ_num(1,:));%nbre of displayed pairs 3193 % if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') 3194 % nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 3195 % elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3196 % nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 3197 % end 3198 % end 3199 % nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 3200 % 3201 % %% look for existing processed pairs at the reference indices if Civ1 will not 3202 % % be performed, while the result is needed for next steps. 3203 % displ_pair={''}; %default 3204 % select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs 3205 % [RootPath,RootFile]=fileparts(filebase); 3206 % if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') 3207 % if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 3208 % errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) 3209 % set(handles.ListPairCiv2,'Value',1); 3210 % set(handles.ListPairCiv2,'String',{''}); 3211 % return 3212 % end 3213 % for ipair=1:nbpair 3214 % filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... 3215 % ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); 3216 % % filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 3217 % % ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); 3218 % select(ipair)=exist(filename,'file')==2; 3219 % end 3220 % if isequal(select,zeros(size(1:nbpair))) 3221 % if isfield(browse,'incr_pair') 3222 % num_i1=ref_i-floor(browse.incr_pair(1)/2); 3223 % num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); 3224 % num_j1=ref_j-floor(browse.incr_pair(2)/2); 3225 % num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); 3226 % filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); 3227 % %filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); 3228 % select(1)=exist(filename,'file')==2; 3229 % else 3230 % if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 3231 % msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) 3232 % else 3233 % msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) 3234 % end 3235 % set(handles.ListPairCiv2,'Value',1); 3236 % set(handles.ListPairCiv2,'String',{''}); 3237 % return 3238 % end 3239 % end 3240 % end 3241 % if isequal(mode,'series(Di)') 3242 % for ipair=1:nbpair 3243 % if select(ipair) 3244 % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3245 % if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3246 % dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt 3247 % displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3248 % end 3249 % else 3250 % displ_pair{ipair}='...'; %pair not displayed in the menu 3251 % end 3252 % end 3253 % elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index 3254 % for ipair=1:nbpair 3255 % if select(ipair) 3256 % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3257 % if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)&& displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1 3258 % dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt 3259 % else 3260 % dt=1; 3261 % end 3262 % displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3263 % else 3264 % displ_pair{ipair}='...'; %pair not displayed in the menu 3265 % end 3266 % end 3267 % elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs 3268 % for ipair=1:nbpair 3269 % if select(ipair) 3270 % if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) && displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1 3271 % dt=time(ref_i+displ_num(4,ipair)+1,displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,displ_num(1,ipair)+1);%time interval dt 3272 % else 3273 % dt=1; 3274 % end 3275 % displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair)+1,nom_type_ima) '-' num2stra(displ_num(2,ipair)+1,nom_type_ima) ... 3276 % ' :dt= ' num2str(dt*1000)]; 3277 % 3278 % else 3279 % displ_pair{ipair}='...'; %pair not displayed in the menu 3280 % end 3281 % end 3282 % elseif isequal(mode,'displacement') 3283 % displ_pair={'Di=Dj=0'}; 3284 % end 3285 % val=get(handles.ListPairCiv2,'Value'); 3286 % ichoice=find(select,1); 3287 % if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 3288 % if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 3289 % val=ichoice;% first valid pair proposed by default in the menu 3290 % end 3291 % if val>length(displ_pair') 3292 % set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu 3293 % else 3294 % set(handles.ListPairCiv2,'Value',val); 3295 % end 3296 % set(handles.ListPairCiv2,'String',displ_pair'); 3297 % set(gcf,'Pointer','arrow') 3446 3298 3447 3299 %------------------------------------------------------------------- … … 3833 3685 end 3834 3686 set(handles.txt_SubdirCiv1,'String',SubDir); 3835 find_netcpair_civ 1(handles)3687 find_netcpair_civ(handles,1) 3836 3688 3837 3689 %------------------------------------------------------------------------ … … 4674 4526 % Dtj: ~=0 if i index pairs are used 4675 4527 4676 function [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj)4528 function NomTypeNc=nomtype2pair(NomTypeIma,mode) 4677 4529 4678 4530 %determine nom_type_nc: 4679 nom_type_pair=[];%default 4680 if ischar(nom_type) 4681 switch nom_type 4682 case {'_i_j'} 4683 if Dtj>0 || Dtj<0 4684 nom_type_pair='_i_j1-j2'; 4685 if Dti>0 || Dti<0 4686 nom_type_pair='_i1-i2_j1-j2'; 4687 end 4688 elseif Dti>0 || Dti<0 4689 nom_type_pair='_i1-i21_j'; 4690 else 4691 nom_type_pair='_i_j'; 4692 end 4693 case {'_i1-i2_j'} 4694 if Dtj>0 || Dtj<0 4695 nom_type_pair='_i1-i2_j1-j2'; 4696 else 4697 nom_type_pair='_i1-i2_j'; 4698 end 4699 case {'i_j1-j2'} 4700 if Dti>0 || Dti<0 4701 nom_type_pair='_i1-i2_j1-j2'; 4702 else 4703 nom_type_pair='_i1-i2_j'; 4704 end 4705 case {'i1-i2_j1-j2'} 4706 nom_type_pair='_i1-i2_j1-j2'; 4707 case '#a' 4708 if Dtj>0 || Dtj<0 4709 nom_type_pair='#_ab'; 4710 end 4711 otherwise 4712 if Dti>0 || Dti<0 4713 nom_type_pair='_i1-i2'; 4714 end 4715 end 4716 end 4717 4531 NomTypeNc='';%default 4532 switch mode 4533 case 'pair j1-j2' 4534 if ~isempty(regexp(NomTypeIma,'a$')) 4535 NomTypeNc=[NomTypeIma 'b']; 4536 elseif ~isempty(regexp(NomTypeIma,'A$')) 4537 NomTypeNc=[NomTypeIma 'B']; 4538 else 4539 r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); 4540 if ~isempty(r) 4541 NomTypeNc='_1_1-2'; 4542 end 4543 end 4544 case 'series(Dj)' 4545 r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); 4546 if ~isempty(r) 4547 NomTypeNc='_1_1-2'; 4548 end 4549 case 'series(Di)' 4550 r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); 4551 if ~isempty(r) 4552 NomTypeNc='_1-2_1'; 4553 else 4554 NomTypeNc='_1-2'; 4555 end 4556 end 4557 4558 function NomType_Callback(hObject, eventdata, handles)
Note: See TracChangeset
for help on using the changeset viewer.