Changeset 44 for trunk/src/series/time_series.m
 Timestamp:
 Mar 15, 2010, 5:38:02 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/time_series.m
r41 r44 91 91 % nbview=2; 92 92 end 93 94 %determine image type 93 95 hhh=which('mmreader'); 94 96 for iview=1:nbview 95 test_movie(iview)=0; 96 if ~isequal(hhh,'')&& mmreader.isPlatformSupported() 97 if isequal(lower(FileExt{iview}),'.avi') 97 if isequal(FileExt{iview},'.nc')isequal(FileExt{iview},'.cdf') 98 FileType{iview}='netcdf'; 99 elseif isequal(lower(FileExt{iview}),'.avi') 100 if ~isequal(hhh,'')&& mmreader.isPlatformSupported() 98 101 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); 99 test_movie(iview)=1; 100 end 101 end 102 FileType{iview}='movie'; 103 else 104 FileType{iview}='avi'; 105 end 106 elseif isequal(lower(FileExt{iview}),'.vol') 107 FileType{iview}='vol'; 108 else 109 form=imformats(FileExt{iview}(2:end)); 110 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 111 if isequal(NomType{iview},'*'); 112 FileType{iview}='multimage'; 113 else 114 FileType{iview}='image'; 115 end 116 end 117 end 102 118 end 103 119 filebase{1}=fullfile(RootPath{1},RootFile{1}); … … 142 158 143 159 %detect whether the two files are 'images' or 'netcdf' 144 testima=0;145 testvol=0;160 % testima=0; 161 % testvol=0; 146 162 testcivx=0; 147 testnc=0;163 % testnc=0; 148 164 FileExt=get(hseries.FileExt,'String'); 149 for iview=1:nbview150 ext=FileExt{iview};151 form=imformats(ext([2:end]));152 if isequal(lower(ext),'.vol')153 testvol=testvol+1;154 elseif ~isempty(form)isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab155 testima=testima+1;156 elseif isequal(ext,'.nc')157 testnc=testnc+1;158 end159 end160 if testvol161 msgbox_uvmat('ERROR','volume images not implemented yet')162 return163 end164 if testnc~=nbview && testima~=nbview && testvol~=nbview165 msgbox_uvmat('need a set of images or a set of netcdf files with the same fields as input','ERROR')166 return167 end165 % for iview=1:nbview 166 % ext=FileExt{iview}; 167 % form=imformats(ext([2:end])); 168 % if isequal(lower(ext),'.vol') 169 % testvol=testvol+1; 170 % elseif ~isempty(form)isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab 171 % testima=testima+1; 172 % elseif isequal(ext,'.nc') 173 % testnc=testnc+1; 174 % end 175 % end 176 % if testvol 177 % msgbox_uvmat('ERROR','volume images not implemented yet') 178 % return 179 % end 180 % if testnc~=nbview && testima~=nbview && testvol~=nbview 181 % msgbox_uvmat('need a set of images or a set of netcdf files with the same fields as input','ERROR') 182 % return 183 % end 168 184 if ~isequal(FieldName,{'get_field...'}) 169 testcivx= testnc;185 testcivx=isequal(FileType{1},'netcdf'); 170 186 end 171 187 … … 319 335 idetect(iview)=exist(filename,'file'); 320 336 Data{iview}=[]; %default 321 if testima337 if ~isequal(FileType{iview},'netcdf') 322 338 Data{iview}.ListVarName={'A'}; 323 339 Data{iview}.AName='image'; 324 if test_movie(iview) 325 A=read(MovieObject{iview},num_i1{iview}(ifile)); 326 else 327 A=double(read_image(filename,NomType{iview},num_i1{iview}(ifile)));% read the image, num2 is the counter for avi files 328 end 340 switch FileType{iview} 341 case 'movie' 342 A=read(MovieObject{iview},num_i1{iview}(ifile)); 343 case 'avi' 344 mov=aviread(filename,num_i1{iview}(ifile)); 345 A=frame2im(mov(1)); 346 case 'vol' 347 A=imread(filename); 348 case 'multimage' 349 A=imread(filename,num_i1{iview}(ifile)); 350 case 'image' 351 A=imread(filename); 352 end 329 353 Data{iview}.ListVarName={'coord_y','coord_x','A'}; % 330 354 npy=size(A,1); … … 338 362 Data{iview}.coord_y=[npy0.5 0.5]; 339 363 Data{iview}.coord_x=[0.5 npx0.5]; 340 Data{iview}.A= A;364 Data{iview}.A=double(A); 341 365 Data{iview}.CoordType='px'; 342 366 elseif testcivx … … 567 591 568 592 % 569 %  Executes on selection change in ProjObject. 570 function ProjObject_Callback(hObject, eventdata, handles) 571 572 list_object=get(handles.ProjObject,'String'); 573 index=get(handles.ProjObject,'Value'); 574 hseries=get(handles.ProjObject,'Parent'); 575 SeriesData=get(hseries,'UserData'); 576 Obj=SeriesData.ProjObject{index}; 577 [SeriesData.hset_object,SeriesData.sethandles]=set_object(SeriesData.ProjObject{index}); 578 set(hseries,'UserData',SeriesData); 579 580 % 581 %generates a series of file names with reference numbers between range1 and 582 %range2 with increment incr. The reference number num_ref is the image number at the middle of the 583 %image pair. The set of first numbers num1 of the image pairs is also 584 %given as output 585 % 586 function [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(filebase,subdir,mode,first_i,incr_i,last_i,first_j,incr_j,last_j) 587 [Path,Name]=fileparts(filebase); 588 filebasesub=fullfile(Path,subdir,Name); 589 filecell={};%default 590 num_i1=[]; 591 num_i2=[]; 592 num_j1=[]; 593 num_j2=[]; 594 ind0_i=first_i:incr_i:last_i; 595 nbcolumn=length(ind0_i); 596 ind0_j=first_j:incr_j:last_j; 597 nbline=length(ind0_j); 598 if isequal(mode,'#_ab') 599 dirpair=dir([filebasesub '*_*.nc']); 600 elseif isequal(mode,'bursts')isequal(mode,'series(Dj)') 601 dirpair=dir([filebasesub '_*_**.nc']); 602 elseif isequal(mode,'series(Di)') 603 dirpair=dir([filebasesub '_**_*.nc']); 604 else 605 errordlg('option ** not yet implemented') 606 return 607 end 608 if isempty(dirpair) 609 errordlg('no pair detected in the selected range') 610 return 611 end 612 %ind0_i=first_i:incr_i:last_i; 613 %nbcolumn=length(ind0_i); 614 %dirpair=dir([filebasesub '_*_**.nc']); 615 if isequal(mode,'bursts')isequal(mode,'#_ab') 616 icount=0; 617 for ifile=1:length(dirpair) 618 [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); 619 620 % if isempty(str2num(str_1)) 621 % dirpair(ifile).name 622 % end 623 num1_r=str2num(str_1); 624 if isequal(RootFile,Name) & ~isempty(num1_r) 625 num_i1(ifile)=num1_r; 626 num_a(ifile)=stra2num(str_a); 627 num_b(ifile)=stra2num(str_b); 628 % icount=icount+1; 629 end 630 end 631 length(dirpair) 632 % num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files 633 test_range= (num_i1 >=first_i)&(num_i1<= last_i);% =1 when both numbers are in the range 634 ind_i=((num_i1first_i)/incr_i)+1;%indices i in the list of prescribed file indices 635 select=find(test_range &(floor(ind_i)==ind_i));%selected indices of num_i1 in the file directory 636 ind_i=ind_i(select);%set of selected indices ind_i 637 [ind_i,indsort]=sort(ind_i);%sorted list of ind_i 638 select=select(indsort); 639 num_i1=num_i1(select); 640 num_a=num_a(select); 641 num_b=num_b(select); 642 dirpair=dirpair(select); 643 [ind_remove]=find_pairs(dirpair,ind_i,nbcolumn); 644 ind_i(ind_remove)=[]; 645 num_a(ind_remove)=[]; 646 num_b(ind_remove)=[]; 647 num_j1=zeros(1,nbcolumn);%default 648 num_j2=num_j1; 649 num_j1(ind_i)=num_a; 650 num_j2(ind_i)=num_b; 651 num_i1=first_i:incr_i:last_i; 652 num_i2=num_i1; 653 nbmissing=nbcolumnlength(ind_i); 654 655 elseif isequal(mode,'series(Di)') 656 %ind0_i=first_i:incr_i:last_i; 657 %nbcolumn=length(ind0_i); 658 %ind0_j=first_j:incr_j:last_j; 659 %nbline=length(ind0_j); 660 %dirpair=dir([filebasesub '_**_*.nc']); 661 for ifile=1:length(dirpair) 662 [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); 663 num_i1_r(ifile)=str2num(str_1); 664 num_i2_r(ifile)=str2num(str_2); 665 num_j(ifile)=str2num(str_a); 666 end 667 num_i=floor((num_i1_r+num_i2_r)/2); %list of reference indices of the detected files 668 test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);% =1 when both numbers are in the range 669 ind_i=((num_ifirst_i)/incr_i)+1;%indices i and j in the list of prescribed file indices 670 ind_j=((num_jfirst_j)/incr_j)+1; 671 ind_ij=ind_j+nbline*(ind_i1);%indices in the reshhaped series of prescribed file indices 672 select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory 673 ind_ij=ind_ij(select);%set of selected indices ind_ij 674 [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij 675 select=select(indsort); 676 num_i1_r=num_i1_r(select); 677 num_i2_r=num_i2_r(select); 678 % num_j=num_j(select); 679 dirpair=dirpair(select); 680 [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ; 681 ind_ij(ind_remove)=[]; 682 num_i1_r(ind_remove)=[]; 683 num_i2_r(ind_remove)=[]; 684 num_i1=zeros(1,nbline*nbcolumn);%default 685 num_i2=num_i1; 686 num_i1(ind_ij)=num_i1_r; 687 num_j2(ind_ij)=num_i2_r; 688 num_i1=reshape(num_i1,nbline,nbcolumn); 689 num_i2=reshape(num_i2,nbline,nbcolumn); 690 num_j1=meshgrid(ind0_i,ind0_j); 691 num_j2=num_j1; 692 nbmissing=nbline*nbcolumnlength(ind_ij); 693 elseif isequal(mode,'series(Dj)') 694 % ind0_i=first_i:incr_i:last_i; 695 % nbcolumn=length(ind0_i); 696 % ind0_j=first_j:incr_j:last_j; 697 % nbline=length(ind0_j); 698 % dirpair=dir([filebasesub '_*_**.nc']); 699 for ifile=1:length(dirpair) 700 [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); 701 num_i(ifile)=str2num(str_1); 702 num_a(ifile)=str2num(str_a); 703 num_b(ifile)=str2num(str_b); 704 end 705 num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files 706 test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);% =1 when both numbers are in the range 707 ind_i=((num_ifirst_i)/incr_i)+1;%indices i and j in the list of prescribed file indices 708 ind_j=((num_jfirst_j)/incr_j)+1; 709 ind_ij=ind_j+nbline*(ind_i1);%indices in the reshhaped series of prescribed file indices 710 select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory 711 ind_ij=ind_ij(select);%set of selected indices ind_ij 712 [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij 713 select=select(indsort); 714 num_i=num_i(select); 715 num_a=num_a(select); 716 num_b=num_b(select); 717 dirpair=dirpair(select); 718 [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ; 719 ind_ij(ind_remove)=[]; 720 num_a(ind_remove)=[]; 721 num_b(ind_remove)=[]; 722 num_j1=zeros(1,nbline*nbcolumn);%default 723 num_j2=num_j1; 724 num_j1(ind_ij)=num_a; 725 num_j2(ind_ij)=num_b; 726 num_j1=reshape(num_j1,nbline,nbcolumn); 727 num_j2=reshape(num_j2,nbline,nbcolumn); 728 num_i1=meshgrid(ind0_i,ind0_j); 729 num_i2=num_i1; 730 nbmissing=nbline*nbcolumnlength(ind_ij); 731 % for i=1:length(indsel);%A SUPPRIMER ULTERIEUREMENT 732 % if indsel(i)==0 733 % filecell{i}=''; 734 % else 735 % Name=dirpair(indsel(i)).name; 736 % filecell{i}=fullfile(Path,subdir,Name); 737 % end 738 % end 739 %else 740 % errordlg('option ** not yet implemented') 741 % return 742 end 593 % %  Executes on selection change in ProjObject. 594 % function ProjObject_Callback(hObject, eventdata, handles) 595 % 596 % list_object=get(handles.ProjObject,'String'); 597 % index=get(handles.ProjObject,'Value'); 598 % hseries=get(handles.ProjObject,'Parent'); 599 % SeriesData=get(hseries,'UserData'); 600 % Obj=SeriesData.ProjObject{index}; 601 % [SeriesData.hset_object,SeriesData.sethandles]=set_object(SeriesData.ProjObject{index}); 602 % set(hseries,'UserData',SeriesData); 603
Note: See TracChangeset
for help on using the changeset viewer.