Home > FMAToolbox > Plot > PlotCSD.m

PlotCSD

PURPOSE ^

PlotCSD - Plot current source density.

SYNOPSIS ^

function PlotCSD(csd,varargin)

DESCRIPTION ^

PlotCSD - Plot current source density.

  USAGE

    PlotCSD(csd,<options>)

    csd            current source density <a href="matlab:help samples">samples</a> (see <a href="matlab:help CSD">CSD</a>)
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'lfp'         local field potential <a href="matlab:help samples">samples</a>
     'scale'       scale (arbitrary units) for LFP traces (default = 1)
     'cutoffs'     cutoff values (default = [-M M] where M is the maximum
                   amplitude of the CSD)
    =========================================================================

  SEE

    See <a href="matlab:help CSD">CSD</a>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function PlotCSD(csd,varargin)
0002 
0003 %PlotCSD - Plot current source density.
0004 %
0005 %  USAGE
0006 %
0007 %    PlotCSD(csd,<options>)
0008 %
0009 %    csd            current source density <a href="matlab:help samples">samples</a> (see <a href="matlab:help CSD">CSD</a>)
0010 %    <options>      optional list of property-value pairs (see table below)
0011 %
0012 %    =========================================================================
0013 %     Properties    Values
0014 %    -------------------------------------------------------------------------
0015 %     'lfp'         local field potential <a href="matlab:help samples">samples</a>
0016 %     'scale'       scale (arbitrary units) for LFP traces (default = 1)
0017 %     'cutoffs'     cutoff values (default = [-M M] where M is the maximum
0018 %                   amplitude of the CSD)
0019 %    =========================================================================
0020 %
0021 %  SEE
0022 %
0023 %    See <a href="matlab:help CSD">CSD</a>.
0024 
0025 % Copyright (C) 2008-2011 by Michaƫl Zugaro
0026 %
0027 % This program is free software; you can redistribute it and/or modify
0028 % it under the terms of the GNU General Public License as published by
0029 % the Free Software Foundation; either version 3 of the License, or
0030 % (at your option) any later version.
0031 
0032 % Default values
0033 lfp = [];
0034 scale = 1;
0035 cutoffs = [];
0036 
0037 % Check number of parameters
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 % Parse parameter list
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]);

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005