Changeset 343 for trunk/src/civ.m
- Timestamp:
- Dec 21, 2011, 10:12:13 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r339 r343 23 23 %TODO: search range 24 24 25 % Last Modified by GUIDE v2.5 04-Dec-2011 18:52:1325 % Last Modified by GUIDE v2.5 21-Dec-2011 00:34:49 26 26 % Begin initialization code - DO NOT EDIT 27 27 gui_Singleton = 1; … … 119 119 function MenuBrowse_Callback(hObject, eventdata, handles) 120 120 %------------------------------------------------------------------------ 121 % get the current input root file name to initiate the browser121 %% get the current input root file name to initiate the browser 122 122 filebase=get(handles.RootName,'String'); 123 123 oldfile=''; %default … … 137 137 oldfile=filebase; 138 138 end 139 ind_opening=1;%default 140 browse.incr_pair=[0 0]; %default 139 % ind_opening=1;%default 140 % browse.incr_pair=[0 0]; %default 141 %% get the new input fiel with the browser 141 142 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 142 143 '*.xml', '.xml files '; ... … … 153 154 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string 154 155 155 %% prepare the GUI with parameters from the input file if opened from uvmat 156 errormsg=display_file_name(handles,fileinput); 157 if ~isempty(errormsg) 158 msgbox_uvmat('ERROR',erromsg) 159 end 160 156 %% case of the xml file opened as input (TODO: check and see whether it is useful) 161 157 [path,name,ext]=fileparts(fileinput); 162 158 testeditxml=0; … … 186 182 [~,~,~,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); 187 183 % filebase=fullfile(RootPath,RootFile); 188 if isempty(i1),i1=1;end 189 if isempty(i2),i2=i1;end 190 if isempty(j1),j1=1;end 191 if isempty(j2),j2=j1;end 192 if isequal(get(handles.ListCompareMode,'Value'),1) 193 browse=[];%initialisation 194 else 195 browse=get(handles.RootName,'UserData'); 196 end 197 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 uvmat 202 browse.nom_type_ima=NomType; 203 browse.ext_ima=FileExt; 204 set(handles.ImaExt,'String',FileExt) 205 end 206 set(handles.ImaDoc,'String',FileExt); 207 208 set(handles.RootName,'UserData',browse);% store information from browser 184 185 %% record the information obtained from the input file 186 % if isempty(i1),i1=1;end 187 % if isempty(i2),i2=i1;end 188 % if isempty(j1),j1=1;end 189 % if isempty(j2),j2=j1;end 190 % if isequal(get(handles.ListCompareMode,'Value'),1) 191 % browse=[];%initialisation 192 % else 193 % browse=get(handles.RootName,'UserData'); 194 % end 195 % browse.num_i1=i1; 196 % browse.num_i2=i2; 197 % browse.num_j1=j1; 198 % browse.num_j2=j2; 199 % if length(FileExt)>1 && (~isempty(imformats(FileExt(2:end)))||strcmpi(FileExt,'.avi'));%if an image file has been opened by uvmat 200 % browse.nom_type_ima=NomType; 201 % browse.ext_ima=FileExt; 202 % set(handles.ImaExt,'String',FileExt) 203 % end 204 % set(handles.RootName,'UserData',browse);% store information from browser 205 206 %% prepare the GUI with parameters from the input file 207 errormsg=display_file_name(handles,fileinput); 208 if ~isempty(errormsg) 209 msgbox_uvmat('ERROR',erromsg) 210 end 211 209 212 210 213 %------------------------------------------------------------------------ … … 332 335 nom_type_ima='';%default 333 336 nom_type_nc=''; 334 [RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,subdir]=name2display(fileinput);335 %[RootPath,subdir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput);TODO: use to replace name2display 337 %[RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,SubDir]=name2display(fileinput); 338 [RootPath,SubDir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput); 336 339 RootName=fullfile(RootPath,RootFile); 337 340 set(handles.RootName,'String',RootName) 338 341 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 339 i1=str2double(i1_str);340 i2=str2double(i2_str);341 j1=str2double(j1_str);342 j2=str2double(j2_str);342 % i1=str2double(i1_str); 343 % i2=str2double(i2_str); 344 % j1=str2double(j1_str); 345 % j2=str2double(j2_str); 343 346 num_ref_i=i1;%efaulmt ref index 344 347 num_ref_j=j1; … … 350 353 ext_ima=ext_input; 351 354 nom_type_ima=nom_type_input; 355 imagename=fileinput; 352 356 else %case of netcdf input file, look for corresponding images 353 357 nom_type_nc=nom_type_input; 358 imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima); 359 i1_str=''; 360 j1_str=''; 354 361 if ~isnan(i2) 355 362 num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file … … 359 366 %TODO: read the image name in the netcdf file (if documented) 360 367 %look for double image series '_i_j' 368 check_letter=regexp(nom_type_nc,'[ab|AB]$');%detect pair label by letter 369 if ~isempty(check_letter) 370 j1_str=nom_type_nc(end-1); 371 r=regexp(nom_type_nc,'_(?<num1>\d+)','names'); 372 if ~isempty(r) 373 i1_str=r.num1; 374 end 375 else 376 NomTypeIma=regexprep(nom_type_nc,'-\d','');% 377 r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names'); 378 if ~isempty(r_end) 379 j1_str=r.num2 380 end 381 end 382 r=regexp(NomTypeIma,'_(?<num1>\d+)','names'); 383 if ~isempty(r) 384 i1_str=r.num1; 385 end 361 386 dirima=dir([RootName '_' i1_str '_' j1_str '.*']); 362 387 if isempty(dirima) … … 374 399 end 375 400 for ilist=1:numel(dirima) 376 [pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name); 401 %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name); 402 [~,~,~,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name); 377 403 form=imformats(ext_list(2:end)); 378 404 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 379 405 ext_ima=ext_list; 380 406 nom_type_ima=nom_type_list; 381 i1=str2double(i1_str);382 j1=str2double(j1_str);383 i2=str2double(i2_str);384 j2=str2double(j2_str);407 % i1=str2double(i1_str); 408 % j1=str2double(j1_str); 409 % i2=str2double(i2_str); 410 % j2=str2double(j2_str); 385 411 % set the range of fields (1:1 by default) and selected pair 386 if ise qual(i2,i1)||isnan(i2)412 if isempty(i2) 387 413 num_ref_i=i1; 388 414 else … … 391 417 browse.incr_pair(2)=0; 392 418 end 393 if ise qual(j1,j2)||isnan(j2)394 if is nan(j1)419 if isempty(j2) 420 if isempty(j1) 395 421 num_ref_j=1; 396 422 else … … 405 431 end 406 432 end 433 [RootPath,RootFile,i1_series,~,j1_series,~,NomType,FileType,Object]=find_file_series(imagename); 434 MaxIndex_i=max(i1_series(i1_series>0)); 435 MaxIndex_j=max(j1_series(j1_series>0)); 407 436 408 437 %% look for an image documentation file … … 420 449 end 421 450 set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used 422 set(handles.ImaDoc,'BackgroundColor',[1 1 0]) 423 drawnow 424 %% %%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%%451 452 453 %% read the time in the image documentation file 425 454 mode=''; %default 426 455 time=[]; 427 TimeUnit=' frame'; %default428 CoordUnit=' px';%default456 TimeUnit=''; %default 457 CoordUnit='';%default 429 458 pxcmx_search=[];%default 430 459 pxcmy_search=[];%default 431 if isequal(ext_imadoc,'.civxml')%TO ABANDON 432 [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']); 433 mode='pair j1-j2'; 434 if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat 435 nom_type_ima='_i_j'; 436 end 437 elseif isequal(ext_imadoc,'.xml') 438 [XmlData,warntext]=imadoc2struct([RootName '.xml']); 439 ext_ima_read=[]; 440 nom_type_read=[]; 441 if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file 442 [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); 443 fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, 444 if ~exist(fullname,'file') 445 msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) 446 end 447 end 448 if isfield(XmlData,'Time') 449 time=XmlData.Time; 450 nbfield=size(time,1); 451 nbfield2=size(time,2); 452 %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml 453 if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector 454 if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) 455 time=time'; 456 nbfield=nbfield2; 457 nbfield2=1; 458 end 459 end 460 end 461 if isfield(XmlData,'TimeUnit') 462 TimeUnit=XmlData.TimeUnit; 463 end 464 pxcmx_search=1; 465 pxcmy_search=1; 466 if isfield(XmlData,'GeometryCalib') 467 tsai=XmlData.GeometryCalib; 468 if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') 469 rot2D=tsai.R(1:2,[1,2]); 470 pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); 471 pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); 472 end 473 if isfield(tsai,'CoordUnit') 474 CoordUnit=tsai.CoordUnit; 475 end 476 end 477 elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file 478 [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']); 479 if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']); 480 elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 481 end 482 nom_type_ima='001a'; 483 elseif strcmpi(ext_imadoc,'.avi') 484 nom_type_ima='*'; 485 ext_ima=ext_imadoc; 486 set(handles.ListPairMode,'Value',1); 487 set(handles.ListPairMode,'String',{'series(Di)'}) 488 dt=0.04;%default 489 if exist([RootName ext_imadoc],'file')==2 490 info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie 491 dt=1/info.FramesPerSecond;%time interval between successive frames 492 nbfield=info.NumFrames;%number of frames 493 end 494 time=(dt*(0:nbfield-1))';%list of image times 495 end 496 if isempty(time) 497 set(handles.ImaDoc,'String',''); %xml file not used for timing 498 end 499 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box to yellow color 500 460 if ~isempty(ext_imadoc) 461 set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning 462 drawnow 463 switch ext_imadoc 464 case '.civxml'%OBSOLETE 465 [~,~,time]=read_civxml([RootName '.civxml']); 466 mode='pair j1-j2'; 467 if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat 468 nom_type_ima='_i_j'; 469 end 470 case '.xml' 471 [XmlData,warntext]=imadoc2struct([RootName '.xml']); 472 ext_ima_read=[]; 473 nom_type_read=[]; 474 if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file 475 %[PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); 476 [~,~,~,~,~,~,~,~,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName); 477 fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, 478 if ~exist(fullname,'file') 479 msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) 480 end 481 end 482 if isfield(XmlData,'Time') 483 time=XmlData.Time; 484 %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml 485 if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector 486 if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) 487 time=time'; 488 MaxIndex_i=MaxIndex_j; 489 MaxIndex_j=1; 490 end 491 end 492 end 493 if isfield(XmlData,'TimeUnit') 494 TimeUnit=XmlData.TimeUnit; 495 end 496 pxcmx_search=1; 497 pxcmy_search=1; 498 if isfield(XmlData,'GeometryCalib') 499 tsai=XmlData.GeometryCalib; 500 if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') 501 rot2D=tsai.R(1:2,[1,2]); 502 pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); 503 pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); 504 end 505 if isfield(tsai,'CoordUnit') 506 CoordUnit=tsai.CoordUnit; 507 end 508 end 509 case '.civ'% OBSOLETE: case of .civ image documentation file 510 [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']); 511 if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']); 512 elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 513 end 514 nom_type_ima='001a'; 515 case {'.avi','.AVI'} 516 nom_type_ima='*'; 517 ext_ima=ext_imadoc; 518 set(handles.ListPairMode,'Value',1); 519 set(handles.ListPairMode,'String',{'series(Di)'}) 520 dt=0.04;%default 521 if exist([RootName ext_imadoc],'file')==2 522 info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie 523 dt=1/info.FramesPerSecond;%time interval between successive frames 524 MaxIndex_i=info.NumFrames;%number of frames 525 end 526 time=(dt*(0:MaxIndex_i-1))';%list of image times 527 TimeUnit='s'; 528 end 529 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter 530 end 501 531 502 532 %% timing display 503 533 %show the reference image edit box if relevant (not needed for movies or in the absence of time information 504 if ~isempty(time) 505 if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt 506 nbfield=size(time,1); 507 nbfield2=size(time,2); 508 set(handles.ImaDoc,'UserData',time); %store the set of times 509 set(handles.dt_unit,'String',['dt in m' TimeUnit]); 510 set(handles.TimeUnit,'String',TimeUnit); 511 set(handles.nb_field,'String',num2str(nbfield)); 512 set(handles.nb_field2,'String',num2str(nbfield2)); 513 end 514 end 534 if numel(time)>=2 % if there are at least two time values to define dt 535 MaxIndex_i=min(size(time,1),MaxIndex_i); 536 MaxIndex_j=min(size(time,2),MaxIndex_j); 537 time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) 538 time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros 539 set(handles.ImaDoc,'UserData',time); %store the matrix of times 540 set(handles.dt_unit,'String',['dt in m' TimeUnit]); 541 set(handles.TimeUnit,'String',TimeUnit); 542 else 543 set(handles.ImaDoc,'String',''); %xml file not used for timing 544 time=(i1_series(:,1)+0:size(i1_series,1)-1);% time=index i 545 time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices 546 TimeUnit='frame'; 547 end 548 set(handles.ImaDoc,'UserData',time); %store the matrix of times 549 set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) 550 set(handles.TimeUnit,'String',TimeUnit); 551 set(handles.nb_field,'String',num2str(MaxIndex_i)); 552 set(handles.nb_field2,'String',num2str(MaxIndex_j)); 515 553 set(handles.CoordUnit,'String',CoordUnit) 516 554 set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); … … 545 583 set(handles.(ListOptions{index}),'value',1) 546 584 end 547 update_CivOptions(handles )585 update_CivOptions(handles,1) 548 586 549 587 550 588 %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% 551 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing 552 if test_ima_i || isequal(nom_type_nc,'_1-2')||~(exist('nbfield2','var')&&(nbfield2~=1)) 589 check_letter=~isempty(regexp(nom_type_ima,'[a|A]$')); 590 check_separator=~isempty(regexp(nom_type_ima,'_')); 591 % test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'))%=1 for images with single indexing 592 % TODO: determine MaxIndex_i and MaxIndex_j using find_file_series (in the absence of xml file) 593 if (~check_letter&&~check_separator)|| isequal(nom_type_nc,'_1-2')|| (exist('MaxIndex_j','var')&&(MaxIndex_j==1)) 553 594 set(handles.ListPairMode,'Value',1) 554 595 set(handles.ListPairMode,'String',{'series(Di)'}) 555 elseif (nbfield==1)% simple series in j 556 set(handles.ListPairMode,'Value',1) 557 set(handles.ListPairMode,'String',{'series(Dj)'}) 596 elseif MaxIndex_i==1 && MaxIndex_j% simple series in j 597 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) 598 if MaxIndex_j <= 10 599 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 600 end 558 601 else 559 602 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice 560 if nbfield2<= 10561 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst603 if MaxIndex_j <= 10 604 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 562 605 end 563 606 end … … 577 620 end 578 621 end 579 Value=find(strcmp( subdir,listdir));%search the index of subdir in the cell listdir622 Value=find(strcmp(SubDir,listdir));%search the index of subdir in the cell listdir 580 623 if isempty(Value)% if the input subdir is not found 581 624 ValueCiv1=get(handles.ListSubdirCiv1,'Value');%read the currrently selected dir name … … 610 653 %% list the possible index pairs, depending on the option set in ListPairMode 611 654 ListPairMode_Callback([], [], handles) 655 'TESTin' 656 browse=get(handles.RootName,'UserData') 612 657 613 658 %% store the root input filename for future opening … … 632 677 function txt_SubdirCiv1_Callback(hObject, eventdata, handles) 633 678 %------------------------------------------------------------------------ 634 subdir=get(handles.txt_SubdirCiv1,'String');679 SubDir=get(handles.txt_SubdirCiv1,'String'); 635 680 menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update 636 ichoice=find(strcmp( subdir,menu_str),1);681 ichoice=find(strcmp(SubDir,menu_str),1); 637 682 if isempty(ichoice) 638 683 ilist=numel(menu_str); %select 'new...' in the menu … … 642 687 set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu 643 688 if get(handles.CheckCiv1,'Value')% if Civ1 is performed 644 set(handles.txt_SubdirCiv2,'String', subdir);% set by default civ2 directory the same as civ1689 set(handles.txt_SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1 645 690 set(handles.ListSubdirCiv2,'Value',ilist) 646 691 else % if Civ1 data already exist … … 649 694 650 695 %------------------------------------------------------------------------ 651 % --- Executes on carriage return on the subdir checkciv1 edit window696 % --- Executes on carriage return on the SubDir checkciv1 edit window 652 697 function txt_SubdirCiv2_Callback(hObject, eventdata, handles) 653 698 %------------------------------------------------------------------------ 654 subdir=get(handles.txt_SubdirCiv1,'String');699 SubDir=get(handles.txt_SubdirCiv1,'String'); 655 700 menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update 656 ichoice=find(strcmp( subdir,menu_str),1);701 ichoice=find(strcmp(SubDir,menu_str),1); 657 702 if isempty(ichoice) 658 703 ilist=numel(menu_str); %select 'new...' in the menu … … 670 715 function CheckCiv1_Callback(hObject, eventdata, handles) 671 716 %------------------------------------------------------------------------ 672 update_CivOptions(handles )717 update_CivOptions(handles,0) 673 718 674 719 %------------------------------------------------------------------------ … … 676 721 function CheckFix1_Callback(hObject, eventdata, handles) 677 722 %------------------------------------------------------------------------ 678 update_CivOptions(handles )723 update_CivOptions(handles,0) 679 724 680 725 %------------------------------------------------------------------------ … … 682 727 function CheckPatch1_Callback(hObject, eventdata, handles) 683 728 %------------------------------------------------------------------------ 684 update_CivOptions(handles )729 update_CivOptions(handles,0) 685 730 686 731 %------------------------------------------------------------------------ … … 688 733 function CheckCiv2_Callback(hObject, eventdata, handles) 689 734 %------------------------------------------------------------------------ 690 update_CivOptions(handles )735 update_CivOptions(handles,0) 691 736 692 737 %------------------------------------------------------------------------ … … 694 739 function CheckFix2_Callback(hObject, eventdata, handles) 695 740 %------------------------------------------------------------------------ 696 update_CivOptions(handles )741 update_CivOptions(handles,0) 697 742 698 743 %------------------------------------------------------------------------ … … 700 745 function CheckPatch2_Callback(hObject, eventdata, handles) 701 746 %------------------------------------------------------------------------ 702 update_CivOptions(handles )747 update_CivOptions(handles,0) 703 748 704 749 %------------------------------------------------------------------------ 705 750 % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 706 function update_CivOptions(handles )751 function update_CivOptions(handles,opening) 707 752 %------------------------------------------------------------------------ 708 753 checkbox=zeros(1,6); … … 718 763 if isempty(RootName) 719 764 msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...') 720 return 765 returnopening 721 766 end 722 767 end … … 724 769 set(handles.txt_SubdirCiv1,'Visible','on') 725 770 set(handles.ListSubdirCiv1,'Visible','on') 771 if ~opening 726 772 find_netcpair_civ1(handles) % select the available netcdf files 773 end 727 774 if max(checkbox(4:6))% case of civ2 pair choice needed 728 775 set(handles.TitlePairCiv2,'Visible','on') … … 731 778 set(handles.ListSubdirCiv2,'Visible','on') 732 779 set(handles.ListPairCiv2,'Visible','on') 780 if ~opening 733 781 find_netcpair_civ2(handles) % select the available netcdf files 782 end 734 783 else 735 784 set(handles.TitleSubdirCiv2,'Visible','off') … … 829 878 end 830 879 [root,filename,ext]=fileparts(civ_files{1}); 831 [rootroot, subdir,extdir]=fileparts(root);880 [rootroot,SubDir,extdir]=fileparts(root); 832 881 hfig=findobj(allchild(0),'name','civ_status'); 833 882 if isempty(hfig) 834 883 hfig=figure('DeleteFcn',@stop_status); 835 884 set(hfig,'name','civ_status') 836 hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); 885 %hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); 886 uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list'); 837 887 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); 838 888 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); … … 895 945 end 896 946 [rr,filename,ext]=fileparts(civ_files{ifile}); 897 Tabchar{ifile,1}=[fullfile([ subdir extdir],filename) ext '...' option_str];947 Tabchar{ifile,1}=[fullfile([SubDir extdir],filename) ext '...' option_str]; 898 948 end 899 949 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files … … 1103 1153 %% MAIN LOOP 1104 1154 time=get(handles.ImaDoc,'UserData'); %get the set of times 1155 TimeUnit=get(handles.TimeUnit,'String'); 1156 checkframe=strcmp(TimeUnit,'frame'); 1105 1157 batch_file_list=[];%should be renamed file_list, can be used for xml or bash files 1106 1158 … … 1136 1188 Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; 1137 1189 Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; 1138 if size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) 1139 Param.Civ1.Dt=(time(i2_civ1(ifile),j2_civ1(j))-time(i1_civ1(ifile),j1_civ1(j))); 1140 Param.Civ1.Time=((time(i2_civ1(ifile),j2_civ1(j))+time(i1_civ1(ifile),j1_civ1(j)))/2); 1190 if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) 1191 Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1)); 1141 1192 else 1142 1193 Param.Civ1.Dt=1; 1143 Param.Civ1.Time=0;1144 end1194 end 1195 Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); 1145 1196 Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? 1146 1197 Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% … … 1274 1325 Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; 1275 1326 Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; 1276 if size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) 1277 Param.Civ2.Dt=num2str(time(i2_civ2(ifile),j2_civ2(j))-time(i1_civ2(ifile),j1_civ2(j))); 1278 Param.Civ2.Time=num2str((time(i2_civ2(ifile),j2_civ2(j))+time(i1_civ2(ifile),j1_civ2(j)))/2); 1327 if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) 1328 Param.Civ2.Dt=num2str(time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1)); 1279 1329 else 1280 1330 Param.Civ2.Dt=1; 1281 Param.Civ2.Time=0;1282 end1331 end 1332 Param.Civ2.Time=num2str((time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2); 1283 1333 Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc); 1284 1334 Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc); … … 1620 1670 end 1621 1671 end 1622 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); 1623 namedoc=fullfile(RootPath,subdir,RootFile); 1672 %[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,SubDir]=name2display(fileresu); 1673 [RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu); 1674 namedoc=fullfile(RootPath,SubDir,RootFile); 1624 1675 detect=1; 1625 1676 while detect==1 … … 2567 2618 end 2568 2619 % set(handles.RootName_1,'String',name); 2569 [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); 2620 %[RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,SubDir]=name2display(name); 2621 [~,~,RootFile,~,~,~,~,~,nom_type]=fileparts_uvmat(name); 2570 2622 set(handles.RootName_1,'String',RootFile); 2571 2623 browse=get(handles.RootName,'UserData'); … … 2640 2692 % last_i=str2num(get(handles.last_i,'String')); 2641 2693 time=get(handles.ImaDoc,'UserData'); %get the set of times 2694 TimeUnit=get(handles.TimeUnit,'String'); 2695 checkframe=strcmp(TimeUnit,'frame'); 2642 2696 siztime=size(time); 2643 nbfield=siztime(1) ;2644 nbfield2=siztime(2) ;2697 nbfield=siztime(1)-1; 2698 nbfield2=siztime(2)-1; 2645 2699 indchosen=1; %%first pair selected by default 2646 2700 %displ_num used to define the indices of the civ pairs … … 2648 2702 % are relative to the reference indices ref_i and ref_j respectively. 2649 2703 if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') 2704 2650 2705 dt=1; 2651 2706 displ=''; … … 2661 2716 numlist_a(index)=numod_a; 2662 2717 numlist_b(index)=numod_b; 2663 if ~isempty(time)2664 dt(numod_a,numod_b)=time(ref_i ,numod_b)-time(ref_i,numod_a);%first time interval dt2718 if size(time,2)>1 && ~checkframe 2719 dt(numod_a,numod_b)=time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt 2665 2720 displ_dt(index)=dt(numod_a,numod_b); 2666 2721 else … … 2699 2754 set(handles.nb_field2,'Visible','On') 2700 2755 set(handles.ref_j,'Visible','On') 2701 if nbfield > 12702 set(handles.itext,'Visible','On')2703 set(handles.first_i,'Visible','On')2704 set(handles.last_i,'Visible','On')2705 set(handles.incr_i,'Visible','On')2706 set(handles.nb_field,'Visible','On')2707 set(handles.ref_i,'Visible','On')2708 else2709 set(handles.itext,'Visible','Off')2710 set(handles.first_i,'Visible','Off')2711 set(handles.last_i,'Visible','Off')2712 set(handles.incr_i,'Visible','Off')2713 set(handles.nb_field,'Visible','Off')2714 set(handles.ref_i,'Visible','Off')2715 end2756 % if nbfield > 1 2757 % set(handles.itext,'Visible','On') 2758 % set(handles.first_i,'Visible','On') 2759 % set(handles.last_i,'Visible','On') 2760 % set(handles.incr_i,'Visible','On') 2761 % set(handles.nb_field,'Visible','On') 2762 % set(handles.ref_i,'Visible','On') 2763 % else 2764 % set(handles.itext,'Visible','Off') 2765 % set(handles.first_i,'Visible','Off') 2766 % set(handles.last_i,'Visible','Off') 2767 % set(handles.incr_i,'Visible','Off') 2768 % set(handles.nb_field,'Visible','Off') 2769 % set(handles.ref_i,'Visible','Off') 2770 % end 2716 2771 elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') 2717 2772 index=1:200; … … 2785 2840 find_netcpair_civ1( handles) 2786 2841 find_netcpair_civ2(handles) 2842 'TESTin' 2843 browse=get(handles.RootName,'UserData') 2787 2844 2788 2845 %------------------------------------------------------------------------ … … 2947 3004 end 2948 3005 time=get(handles.ImaDoc,'UserData');%get the set of times 2949 if isempty(time) 2950 time=[0 1]; 2951 end 2952 dt_unit=1000;%default 3006 % if isempty(time) 3007 % time=[0 1]; 3008 % end 3009 TimeUnit=get(handles.TimeUnit,'String'); 3010 checkframe=strcmp(TimeUnit,'frame'); 3011 2953 3012 displ_num=get(handles.ListPairCiv1,'UserData'); 2954 3013 … … 3022 3081 if select(ipair) 3023 3082 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 3024 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3025 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 3026 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3083 if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1 3084 dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt 3085 else 3086 dt=1; 3027 3087 end 3088 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3028 3089 else 3029 3090 displ_pair{ipair}='...'; %pair not displayed in the menu … … 3038 3099 if select(ipair) 3039 3100 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 3040 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)3041 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 dt3101 if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair) 3102 dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt 3042 3103 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3043 3104 end … … 3050 3111 for ipair=1:nbpair 3051 3112 if select(ipair) 3052 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 3113 if ~checkframe && size(time,2)>1 3114 dt=time(ref_i+1+displ_num(4,ipair),displ_num(2,ipair)+1)-time(ref_i+1+displ_num(3,ipair),displ_num(1,ipair)+1);%time interval dt 3115 else % time set by default to i index 3116 dt=1; 3117 end 3053 3118 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 3054 3119 ' :dt= ' num2str(dt*1000)]; … … 3140 3205 end 3141 3206 time=get(handles.ImaDoc,'UserData'); %get the set of times 3142 if isempty(time) 3143 time=[0 1];%default 3144 end 3207 TimeUnit=get(handles.TimeUnit,'String'); 3208 checkframe=strcmp(TimeUnit,'frame'); 3209 % if isempty(time) 3210 % time=[0 1];%default 3211 % end 3145 3212 displ_num=get(handles.ListPairCiv1,'UserData'); 3146 3213 … … 3198 3265 if select(ipair) 3199 3266 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3200 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)3201 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 dt3267 if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3268 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 3202 3269 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3203 3270 end … … 3210 3277 if select(ipair) 3211 3278 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; 3212 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) 3213 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 3279 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 3280 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 3281 else 3282 dt=1; 3283 end 3214 3284 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 3215 end3216 3285 else 3217 3286 displ_pair{ipair}='...'; %pair not displayed in the menu … … 3221 3290 for ipair=1:nbpair 3222 3291 if select(ipair) 3223 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 3224 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 3292 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 3293 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 3294 else 3295 dt=1; 3296 end 3297 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair)+1,nom_type_ima) '-' num2stra(displ_num(2,ipair)+1,nom_type_ima) ... 3225 3298 ' :dt= ' num2str(dt*1000)]; 3299 3226 3300 else 3227 3301 displ_pair{ipair}='...'; %pair not displayed in the menu … … 3623 3697 list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); 3624 3698 val=get(handles.ListSubdirCiv1,'Value'); 3625 subdir=list_subdir_civ1{val};3626 if strcmp( subdir,'new...')3699 SubDir=list_subdir_civ1{val}; 3700 if strcmp(SubDir,'new...') 3627 3701 if get(handles.CheckCiv1,'Value') 3628 subdir='CIV'; %default subdirectory3702 SubDir='CIV'; %default subdirectory 3629 3703 else 3630 3704 msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation') … … 3632 3706 end 3633 3707 end 3634 set(handles.txt_SubdirCiv1,'String', subdir);3708 set(handles.txt_SubdirCiv1,'String',SubDir); 3635 3709 find_netcpair_civ1(handles) 3636 3710 … … 3641 3715 list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); 3642 3716 val=get(handles.ListSubdirCiv2,'Value'); 3643 subdir=list_subdir_civ2{val};3644 if strcmp( subdir,'new...')3717 SubDir=list_subdir_civ2{val}; 3718 if strcmp(SubDir,'new...') 3645 3719 if get(handles.CheckCiv2,'Value') 3646 subdir='CIV'; %default subdirectory3720 SubDir='CIV'; %default subdirectory 3647 3721 else 3648 3722 msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation') … … 3650 3724 end 3651 3725 end 3652 set(handles.txt_SubdirCiv2,'String', subdir);3726 set(handles.txt_SubdirCiv2,'String',SubDir); 3653 3727 3654 3728 %------------------------------------------------------------------------ … … 3860 3934 sizf=size(fileinput); 3861 3935 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string 3862 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); 3936 %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); 3937 [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); 3863 3938 ref.filebase=fullfile(Path,File); 3864 ref.num_a=stra2num(str_a);3865 ref.num_b=stra2num(str_b);3866 ref.num1=str2double(field_count);3867 ref.num2=str2double(str2);3939 % ref.num_a=stra2num(str_a); 3940 % ref.num_b=stra2num(str_b); 3941 % ref.num1=str2double(field_count); 3942 % ref.num2=str2double(str2); 3868 3943 browse=[];%initialisation 3869 3944 if ~isequal(ref.ext,'.nc') … … 3904 3979 sizf=size(fileinput); 3905 3980 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string 3906 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); 3981 %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); 3982 [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); 3907 3983 ref.filebase=fullfile(Path,File); 3908 ref.num_a=stra2num(str_a);3909 ref.num_b=stra2num(str_b);3910 ref.num1=str2num(field_count);3911 ref.num2=str2num(str2);3984 % ref.num_a=stra2num(str_a); 3985 % ref.num_b=stra2num(str_b); 3986 % ref.num1=str2num(field_count); 3987 % ref.num2=str2num(str2); 3912 3988 browse=[];%initialisation 3913 3989 if ~isequal(ref.ext,'.nc') … … 4091 4167 errormsg=''; %default 4092 4168 filename=regexprep(filename,'.nc',''); %file name for the result 4093 if isequal(Param.Civ1.Dt, '0')4094 Param.Civ1.Dt= '1';%case of 'displacement' mode4169 if isequal(Param.Civ1.Dt,0) 4170 Param.Civ1.Dt=1 ;%case of 'displacement' mode 4095 4171 end 4096 4172 Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png',''); … … 4444 4520 end 4445 4521 end 4446
Note: See TracChangeset
for help on using the changeset viewer.