Legend:
 Unmodified
 Added
 Removed

trunk/src/plot_field.m
r674 r688 738 738 end 739 739 end 740 PlotParamOut=PlotParam; % output plot parameters equal to input by default 740 741 741 742 %% image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%% 742 743 if isfield(PlotParam.Scalar,'ListContour')744 CheckContour=strcmp(PlotParam.Scalar.ListContour,'contours');745 else746 CheckContour=0; %default747 end748 PlotParamOut=PlotParam; %default749 743 if test_ima 744 750 745 % distinguish B/W and color images 751 746 np=size(A);%size of image … … 773 768 PlotParamOut.Scalar.CheckBW=BW; 774 769 end 770 771 % determine the plot option 'image' or 'contours' 772 if isfield(PlotParam.Scalar,'ListContour') 773 CheckContour=strcmp(PlotParam.Scalar.ListContour,'contours');% =1 for contour plot option 774 else 775 CheckContour=0; %default 776 end 777 775 778 %case of grey level images or contour plot 776 779 if siz==2 777 780 if ~isfield(PlotParam.Scalar,'CheckFixScalar') 778 PlotParam.Scalar.CheckFixScalar=0;% default781 PlotParam.Scalar.CheckFixScalar=0;% free scalar threshold value scale (from min to max) by default 779 782 end 780 783 if ~isfield(PlotParam.Scalar,'MinA') 781 PlotParam.Scalar.MinA=[];% default784 PlotParam.Scalar.MinA=[];%no min scalar threshold value set 782 785 end 783 786 if ~isfield(PlotParam.Scalar,'MaxA') 784 PlotParam.Scalar.MaxA=[];%default 785 end 786 Aline=[]; 787 if ~PlotParam.Scalar.CheckFixScalar isempty(PlotParam.Scalar.MinA)~isa(PlotParam.Scalar.MinA,'double') %correct if there is no numerical data in edit box 788 Aline=reshape(A,1,[]); 789 Aline=Aline(~isnan(A)); 790 if isempty(Aline) 787 PlotParam.Scalar.MaxA=[];%no max scalar threshold value set 788 end 789 790 % determine the min scalar value 791 if PlotParam.Scalar.CheckFixScalar && ~isempty(PlotParam.Scalar.MinA) && isnumeric(PlotParam.Scalar.MinA) 792 MinA=double(PlotParam.Scalar.MinA); % min value set as input 793 else 794 MinA=double(nanmin(nanmin(A))); % min value set as min of non NaN scalar values 795 end 796 797 % error if the input scalar is NaN everywhere 798 if isnan(MinA) 791 799 errormsg='NaN input scalar or image in plot_field'; 792 800 return 793 end 794 MinA=double(min(Aline)); 795 else 796 MinA=PlotParam.Scalar.MinA; 797 end; 798 if ~PlotParam.Scalar.CheckFixScalarisempty(PlotParam.Scalar.MaxA)~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box 799 if isempty(Aline) 800 Aline=reshape(A,1,[]); 801 Aline=Aline(~isnan(A)); 802 if isempty(Aline) 803 errormsg='NaN input scalar or image in plot_field'; 804 return 805 end 806 end 807 MaxA=double(max(Aline)); 808 else 809 MaxA=PlotParam.Scalar.MaxA; 810 end; 801 end 802 803 % determine the max scalar value 804 if PlotParam.Scalar.CheckFixScalar && ~isempty(PlotParam.Scalar.MaxA) && isnumeric(PlotParam.Scalar.MaxA) 805 MaxA=double(PlotParam.Scalar.MaxA); % max value set as input 806 else 807 MaxA=double(nanmax(nanmax(A))); % max value set as min of non NaN scalar values 808 end 809 811 810 PlotParamOut.Scalar.MinA=MinA; 812 811 PlotParamOut.Scalar.MaxA=MaxA; 813 812 PlotParamOut.Scalar.Npx=size(A,2); 814 813 PlotParamOut.Scalar.Npy=size(A,1); 814 815 815 % case of contour plot 816 816 if CheckContour 817 817 if ~isempty(hima) && ishandle(hima) 818 delete(hima) 819 end 818 delete(hima) % delete existing image 819 end 820 821 % set the contour values 820 822 if ~isfield(PlotParam.Scalar,'IncrA') 821 PlotParam.Scalar.IncrA=NaN; 822 end 823 if isempty(PlotParam.Scalar.IncrA) isnan(PlotParam.Scalar.IncrA)%  PlotParam.Scalar.AutoScal==0 823 PlotParam.Scalar.IncrA=[];% automatic contour interval 824 end 825 if ~isempty(PlotParam.Scalar.IncrA) && isnumeric(PlotParam.Scalar.IncrA) 826 interval=PlotParam.Scalar.IncrA; 827 else % automatic contour interval 824 828 cont=colbartick(MinA,MaxA); 825 intercont=cont(2)cont(1);%default 826 PlotParamOut.Scalar.IncrA=intercont; 827 else 828 intercont=PlotParam.Scalar.IncrA; 829 end 830 B=A; 831 abscontmin=intercont*floor(MinA/intercont); 832 abscontmax=intercont*ceil(MaxA/intercont); 833 contmin=intercont*floor(min(min(B))/intercont); 834 contmax=intercont*ceil(max(max(B))/intercont); 835 cont_pos_plus=0:intercont:contmax; 836 cont_pos_min=double(contmin):intercont:intercont; 837 cont_pos=[cont_pos_min cont_pos_plus]; 829 interval=cont(2)cont(1);%default 830 PlotParamOut.Scalar.IncrA=interval;% set the interval as output for display on the GUI 831 end 832 %B=A; 833 abscontmin=interval*floor(MinA/interval); 834 abscontmax=interval*ceil(MaxA/interval); 835 contmin=interval*floor(min(min(A))/interval); 836 contmax=interval*ceil(max(max(A))/interval); 837 cont_pos_plus=0:interval:contmax;% zero and positive contour values (plotted as solid lines) 838 cont_pos_min=double(contmin):interval:interval;% negative contour values (plotted as dashed lines) 839 cont_pos=[cont_pos_min cont_pos_plus];% set of all contour values 840 838 841 sizpx=(AX(end)AX(1))/(np(2)1); 839 842 sizpy=(AY(1)AY(end))/(np(1)1); 840 843 x_cont=AX(1):sizpx:AX(end); % pixel x coordinates for image display 841 844 y_cont=AY(1):sizpy:AY(end); % pixel x coordinates for image display 842 % axes(haxes)% set the input axes handle as current axis 843 txt=ver('MATLAB'); 844 Release=txt.Release; 845 relnumb=str2double(Release(3:4)); 846 if relnumb >= 14 847 vec=linspace(0,1,(abscontmaxabscontmin)/intercont);%define a greyscale colormap with steps intercont 845 846 %axes(haxes)% set the input axes handle as current axis 847 848 % colormap(map); 849 tag_axes=get(haxes,'Tag');% axes tag 850 Opacity=1; 851 if isfield(PlotParam.Scalar,'Opacity')&&~isempty(PlotParam.Scalar.Opacity) 852 Opacity=PlotParam.Scalar.Opacity; 853 end 854 % fill the space between contours if opacity is undefined or =1 855 if isequal(Opacity,1) 856 [var,hcontour]=contour(haxes,x_cont,y_cont,A,cont_pos);% determine all contours 857 set(hcontour,'Fill','on')% fill the space between contours 858 set(hcontour,'LineStyle','none') 859 hold on 860 end 861 [var_p,hcontour_p]=contour(haxes,x_cont,y_cont,A,cont_pos_plus,'k');% draw the contours for positive values as solid lines 862 hold on 863 [var_m,hcontour_m]=contour(haxes,x_cont,y_cont,A,cont_pos_min,'');% draw the contours for negative values as dashed lines 864 if isequal(Opacity,1) 865 set(hcontour_m,'LineColor',[1 1 1])% draw negative contours in white (better visibility in dark background) 866 end 867 set(haxes,'Tag',tag_axes);% restore axes tag (removed by the matlab fct contour !) 868 hold off 869 870 %determine the color scale and map 871 caxis([abscontmin abscontmax]) 872 if BW 873 vec=linspace(0,1,(abscontmaxabscontmin)/interval);%define a greyscale colormap with steps interval 848 874 map=[vec' vec' vec']; 849 875 colormap(map); 850 [var,hcontour]=contour(x_cont,y_cont,B,cont_pos); 851 set(hcontour,'Fill','on') 852 set(hcontour,'LineStyle','none') 853 hold on 854 end 855 [var_p,hcontour_p]=contour(x_cont,y_cont,B,cont_pos_plus,'k'); 856 hold on 857 [var_m,hcontour_m]=contour(x_cont,y_cont,B,cont_pos_min,':'); 858 set(hcontour_m,'LineColor',[1 1 1]) 859 hold off 860 caxis([abscontmin abscontmax]) 861 colormap(map); 876 else 877 colormap('default'); % default matlab colormap ('jet') 878 end 879 862 880 if isfield(PlotParam.Coordinates,'CheckFixAspectRatio') && isequal(PlotParam.Coordinates.CheckFixAspectRatio,1) 863 881 set(haxes,'DataAspectRatioMode','manual') … … 868 886 end 869 887 end 870 end 871 888 else 872 889 % set colormap for image display 873 if ~CheckContour874 890 % rescale the grey levels with min and max, put a grey scale colorbar 875 B=A;891 % B=A; 876 892 if BW 877 893 vec=linspace(0,1,255);%define a linear greyscale colormap … … 879 895 colormap(map); %grey scale color map 880 896 else 881 colormap('default'); % standard fa ulse colors for div, vort , scalar fields897 colormap('default'); % standard false colors for div, vort , scalar fields 882 898 end 883 899 end … … 886 902 else 887 903 if BW 888 B=uint16(sum(A,3));889 else 890 B=uint8(A);904 A=uint16(sum(A,3)); 905 else 906 A=uint8(A); 891 907 end 892 908 MinA=0; … … 898 914 % interpolate field to increase resolution of image display 899 915 test_interp=0; 900 if size( B,3)==1 % scalar of B/W image916 if size(A,3)==1 % scalar of B/W image 901 917 test_interp=1; 902 918 if max(np) <= 64 … … 917 933 xi=linspace(AX(1),AX(2),npxy(2)); 918 934 yi=linspace(AY(1),AY(2),npxy(1)); 919 B = interp2(X,Y,double(B),xi,yi');935 A = interp2(X,Y,double(A),xi,yi'); 920 936 end 921 937 % create new image if there no image handle is found … … 923 939 tag=get(haxes,'Tag'); 924 940 if MinA<MaxA 925 hima=imagesc(AX,AY, B,[MinA MaxA]);941 hima=imagesc(AX,AY,A,[MinA MaxA]); 926 942 else % to deal with uniform field 927 hima=imagesc(AX,AY, B,[MaxA1 MaxA]);943 hima=imagesc(AX,AY,A,[MaxA1 MaxA]); 928 944 end 929 945 % the function imagesc reset the axes 'DataAspectRatioMode'='auto', change if .CheckFixAspectRatio is … … 935 951 % update an existing image 936 952 else 937 set(hima,'CData', B);953 set(hima,'CData',A); 938 954 if MinA<MaxA 939 955 set(haxes,'CLim',[MinA MaxA]) 
trunk/src/uvmat.m
r686 r688 696 696 697 697 if strcmp(FileType,'txt') 698 edit(fileinput) 698 try 699 edit(fileinput) 700 catch ME 701 msgbox_uvmat('ERROR','invalid intput file') 702 end 699 703 return 700 704 elseif strcmp(FileType,'xml') … … 922 926 drawnow 923 927 [XmlDataRead,warntext]=imadoc2struct(XmlFileName); 928 if ~isempty(warntext) 929 msgbox_uvmat('WARNING',warntext) 930 end 924 931 if ~isempty(XmlDataRead) 925 ImaDoc_str=['view ' DocExt]; % DocExt= '.xml' or .civ (obsolete case) 926 if isfield(XmlDataRead,'TimeUnit')&& ~isempty(XmlDataRead.TimeUnit) 927 TimeUnit=XmlDataRead.TimeUnit; 928 end 929 if isfield(XmlDataRead,'Time')&& ~isempty(XmlDataRead.Time) 930 XmlData.Time=XmlDataRead.TimeUnit; 931 end 932 ImaDoc_str=['view ' DocExt]; % DocExt= '.xml' or .civ (obsolete case) 933 %XmlData=XmlDataRead; 934 if isfield(XmlDataRead,'TimeUnit')&& ~isempty(XmlDataRead.TimeUnit) 935 TimeUnit=XmlDataRead.TimeUnit; 936 end 937 if isfield(XmlDataRead,'Time')&& ~isempty(XmlDataRead.Time) 938 XmlData.Time=XmlDataRead.Time; 939 end 932 940 set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white 933 941 drawnow … … 937 945 set (handles.slices,'String','volume') 938 946 end 939 % check whether the GUI geometry_calib is opened 947 % check whether the GUI geometry_calib is opened 940 948 hgeometry_calib=findobj('tag','geometry_calib'); 941 949 if ~isempty(hgeometry_calib) % check whether the display of the GUI geometry_calib is consistent with the current calib param … … 1046 1054 if ~isempty(TimeUnit) 1047 1055 if index==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit) 1048 warntext=['time unit for second file series ' TimeUnit ' inconsistent with first series'];1056 msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series']) 1049 1057 else 1050 1058 UvData.TimeUnit=TimeUnit; … … 1055 1063 1056 1064 %display warning message 1057 if ~ise mpty(warntext)1065 if ~isequal(warntext,'') 1058 1066 msgbox_uvmat('WARNING',warntext); 1059 1067 end … … 3775 3783 % 3776 3784 val=get(handles.ListContour,'Value'); 3777 if val==2 3785 if val==2% option 'contours' 3778 3786 set(handles.interval_txt,'Visible','on') 3779 3787 set(handles.num_IncrA,'Visible','on') 3780 else 3788 set(handles.num_IncrA,'String','')% refresh contour interval 3789 % set(handles.opacity_txt,'Visible','off') 3790 % set(handles.num_Opacity,'Visible','off') 3791 else % option 'image' 3781 3792 set(handles.interval_txt,'Visible','off') 3782 3793 set(handles.num_IncrA,'Visible','off') 3794 % set(handles.opacity_txt,'Visible','on') 3795 % set(handles.num_Opacity,'Visible','on') 3783 3796 end 3784 3797 update_plot(handles); … … 3813 3826 function CheckFixVectors_Callback(hObject, eventdata, handles) 3814 3827 % 3815 test=get(handles.CheckFixVectors,'Value'); 3816 if test 3817 % set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) 3818 else 3828 if ~get(handles.CheckFixVectors,'Value') 3819 3829 update_plot(handles); 3820 %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3))3821 % set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7])3822 3830 end 3823 3831 … … 4024 4032 function update_plot(handles) 4025 4033 % 4034 set(handles.run0,'BackgroundColor',[1 1 0]);% indicate plot activity by yellow color 4035 drawnow 4026 4036 UvData=get(handles.uvmat,'UserData'); 4027 4037 AxeData=UvData.PlotAxes;% retrieve the current plotted data … … 4029 4039 [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); 4030 4040 errormsg=fill_GUI(PlotParamOut,handles.uvmat); 4031 RUNColor=get(handles.run0,'BackgroundColor');% 4032 if isequal(RUNColor,[1 0 1])% suppress magenta color (indicate that plot is updated) 4033 set(handles.run0,'BackgroundColor',[1 0 0]); 4034 end 4041 if ~isempty(errormsg) 4042 msgbox_uvmat('ERROR',errormsg) 4043 return 4044 end 4045 % RUNColor=get(handles.run0,'BackgroundColor');% 4046 % if isequal(RUNColor,[1 0 1])% suppress magenta color (indicate that plot is updated) 4047 % set(handles.run0,'BackgroundColor',[1 0 0]); 4048 % end 4049 set(handles.run0,'BackgroundColor',[1 0 0]); 4035 4050 4036 4051 %
Note: See TracChangeset
for help on using the changeset viewer.