0001 function PlotCSD(csd,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 lfp = [];
0034 scale = 1;
0035 cutoffs = [];
0036
0037
0038 if nargin < 1 | mod(length(varargin),2) ~= 0,
0039 error('Incorrect number of parameters (type ''help <a href="matlab:help PlotCSD">PlotCSD</a>'' for details).');
0040 end
0041
0042
0043 for i = 1:2:length(varargin),
0044 if ~ischar(varargin{i}),
0045 error(['Parameter ' num2str(i+1) ' is not a property (type ''help <a href="matlab:help PlotCSD">PlotCSD</a>'' for details).']);
0046 end
0047 switch(lower(varargin{i})),
0048 case 'lfp',
0049 lfp = varargin{i+1};
0050 if ~isdmatrix(lfp) | size(lfp,1) ~= size(csd,1) | size(lfp,2) ~= size(csd,2)+2,
0051 error('Incorrect size for parameter ''lfp'' (type ''help <a href="matlab:help PlotCSD">PlotCSD</a>'' for details).');
0052 end
0053 case 'scale',
0054 scale = varargin{i+1};
0055 if ~isdscalar(scale,'>0'),
0056 error('Incorrect value for property ''scale'' (type ''help <a href="matlab:help PlotCSD">PlotCSD</a>'' for details).');
0057 end
0058 case 'cutoffs',
0059 cutoffs = varargin{i+1};
0060 if ~isdvector(cutoffs,'#2','<'),
0061 error('Incorrect value for property ''cutoffs'' (type ''help <a href="matlab:help PlotCSD">PlotCSD</a>'' for details).');
0062 end
0063 otherwise,
0064 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help PlotCSD">PlotCSD</a>'' for details).']);
0065 end
0066 end
0067
0068 d = csd(:,2:end);
0069 d = interp2(d);
0070 d = d(1:2:size(d,1),:);
0071
0072 pcolor(csd(:,1),1:size(d,2),flipud(transpose(d)));
0073 shading interp;
0074 if ~isempty(cutoffs),
0075 set(gca,'clim',cutoffs);
0076 end
0077
0078 if ~isempty(lfp),
0079 hold on;
0080 y = lfp(:,2:end);
0081 y = y - repmat(mean(y),size(y,1),1);
0082 y = y / max(max(abs(y)))*scale;
0083 n = size(y,2);
0084 for i = 1:n,
0085 plot(lfp(:,1),y(:,i)+(n-i)*2-1,'k');
0086 end
0087 end
0088
0089 ylim([-2 (n-1)*2]);