nt_bsplot(x,w,style,abscissa,zeroflag,rmsflag) - plot average with bootstrap standard deviation x: data to plot (time * trials, or time * 1 * trials) w: weights style: 'zerobased' (default) or 'meanbased' abscissa: use this vector as plot's abscissa (as in 'plot(abscissa,x)' ) zeroflag: if 1 draw zero line (default: 1) rmsflag: if 1 use RMS instead of mean (default==0) Bootstrap uses N=1000 iterations. Example: nt_bsplot(x) where x is time*trials will plot the average of x over trials, together with +/- 2SDs of the bootstrap resampling. NoiseTools.
0001 function nt_bsplot(x,w,style,abscissa,zeroflag,rmsflag) 0002 %nt_bsplot(x,w,style,abscissa,zeroflag,rmsflag) - plot average with bootstrap standard deviation 0003 % 0004 % x: data to plot (time * trials, or time * 1 * trials) 0005 % w: weights 0006 % style: 'zerobased' (default) or 'meanbased' 0007 % abscissa: use this vector as plot's abscissa (as in 'plot(abscissa,x)' ) 0008 % zeroflag: if 1 draw zero line (default: 1) 0009 % rmsflag: if 1 use RMS instead of mean (default==0) 0010 % 0011 % Bootstrap uses N=1000 iterations. 0012 % 0013 % Example: 0014 % nt_bsplot(x) 0015 % where x is time*trials will plot the average of x over trials, together 0016 % with +/- 2SDs of the bootstrap resampling. 0017 % 0018 % NoiseTools. 0019 nt_greetings; 0020 0021 if nargin<6 || isempty(rmsflag) ; rmsflag=0; end 0022 if nargin<5 || isempty(zeroflag) ; zeroflag=1; end 0023 if nargin<4; abscissa=[]; end 0024 if nargin<3 || isempty(style); style='zerobased'; end 0025 if nargin<2 w=[]; end 0026 BAND=2; % number of SD in band 0027 0028 x=squeeze(x); 0029 if ~isempty (w); w=squeeze(w); end 0030 if ndims(x)>2; error('X should have at most 2 non-singleton dimensions'); end 0031 [m,n]=size(x); 0032 if n<2; error('bootstrap resampling requires more than 1 column'); end 0033 if isempty(abscissa); abscissa=1:m; end 0034 if numel(abscissa) ~= size(x,1); error('abscissa should be same size as x'); end 0035 0036 N=1000; 0037 if rmsflag 0038 [a,b]=nt_bsrms(x,N,w); 0039 else 0040 [a,b]=nt_bsmean(x,N,w); 0041 end 0042 b=b*BAND; 0043 0044 0045 if strcmp(style,'zerobased'); 0046 Y=[b;-flipud(b)]'; 0047 elseif strcmp(style,'meanbased'); 0048 Y=[b+a;flipud(-b+a)]'; 0049 else 0050 error('!'); 0051 end 0052 abscissa=abscissa(:); 0053 X=[abscissa;flipud(abscissa)]; 0054 C=0.7*[1 1 1]; 0055 fill(X,Y,C,'edgecolor','none'); 0056 hold on; 0057 plot(abscissa,a*0,'k'); 0058 plot(abscissa,a, 'b'); 0059 hold off 0060 0061 % return 0062 % 0063 % abscissa2=linspace(min(abscissa),max(abscissa),m*2); 0064 % plot(abscissa2,b,'g'); 0065 % c=get(gca,'children'); set(c(1),'color',[.7 .7 .7]) 0066 % hold on; 0067 % plot(abscissa,a,'b'); 0068 % if zeroflag; 0069 % plot(abscissa,0*a,'k'); 0070 % c=get(gca,'children'); set(c(1),'color',[.5 .5 .5]) 0071 % end 0072 % %set(gca,'xlim',[1 m]) 0073 % hold off 0074 0075 0076