Home > NoiseTools > nt_bsplot_diff.m

nt_bsplot_diff

PURPOSE ^

nt_bsplot_diff(x,y,sds,style,abscissa,zeroflag,rmsflag) - plot average difference with bootstrap standard deviation

SYNOPSIS ^

function nt_bsplot_diff(x,y,band,style,abscissa,zeroflag)

DESCRIPTION ^

nt_bsplot_diff(x,y,sds,style,abscissa,zeroflag,rmsflag) - plot average difference with bootstrap standard deviation

  x, y: data (time * trials, or time * 1 * trials)
  band: width of band to plot in standard deviations (default: 2)
  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)

  Bootstrap uses N=1000 iterations.
 
  Example:
    nt_bsplot_diff(x,y)
  where x and y are time*trials will plot the average of x - y over trials, together
  with +/- 2SDs of the bootstrap resampling.

 NoiseTools.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Tue 18-Feb-2020 11:23:12 by m2html © 2005