staogram

PURPOSE ^

SYNOPSIS ^

function[S,tau,tc] = staogram(data_spk,data_lfp,smp,plt,Tc,Tinc,Tw,w,D)

DESCRIPTION ^

 staogram : calculates a moving window spike triggered ave %
   Usage:[S,tau,tc] = staogram(data_spk,data_lfp,smp,plt,Tc,Tinc,Tw,w,D)
   
                 ******** INPUT *********                  %
 Note that all times have to be consistent. If data_spk
 is in seconds, so must be sig and t. If data_spk is in 
 samples, so must sig and t. The default is seconds.

 data_spk    - strucuture array of spike times data        %
 data_lfp    - array of lfp data(samples x trials)         %
 smp         - lfp times of samples                        %
                                                           %
 Optional...                                               %
                                                           %
 Parameter                                                 %
                                                           %
 plt     'y'|'n'                                           %
                                                           %
 'y' standard staogram                                     %
 'n' no plot                                               %
                                                           %
 start and end times (centres)           whole trial       %
 time increment between windows             0.1            %
 time window width                          0.3            %
 w = smoothing width in seconds                            %
 D = plot sta out to on axis [D(1) D(2)] s                 %
                                                           %
                ******** OUTPUT ********                   %
  S spike triggered average                                %
  tau - lag                                                %
  tc  - bin centers                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function[S,tau,tc] = staogram(data_spk,data_lfp,smp,plt,Tc,Tinc,Tw,w,D)
0002 %
0003 % staogram : calculates a moving window spike triggered ave %
0004 %   Usage:[S,tau,tc] = staogram(data_spk,data_lfp,smp,plt,Tc,Tinc,Tw,w,D)
0005 %
0006 %                 ******** INPUT *********                  %
0007 % Note that all times have to be consistent. If data_spk
0008 % is in seconds, so must be sig and t. If data_spk is in
0009 % samples, so must sig and t. The default is seconds.
0010 %
0011 % data_spk    - strucuture array of spike times data        %
0012 % data_lfp    - array of lfp data(samples x trials)         %
0013 % smp         - lfp times of samples                        %
0014 %                                                           %
0015 % Optional...                                               %
0016 %                                                           %
0017 % Parameter                                                 %
0018 %                                                           %
0019 % plt     'y'|'n'                                           %
0020 %                                                           %
0021 % 'y' standard staogram                                     %
0022 % 'n' no plot                                               %
0023 %                                                           %
0024 % start and end times (centres)           whole trial       %
0025 % time increment between windows             0.1            %
0026 % time window width                          0.3            %
0027 % w = smoothing width in seconds                            %
0028 % D = plot sta out to on axis [D(1) D(2)] s                 %
0029 %                                                           %
0030 %                ******** OUTPUT ********                   %
0031 %  S spike triggered average                                %
0032 %  tau - lag                                                %
0033 %  tc  - bin centers                                        %
0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035 
0036 
0037 % setup defaults...
0038 if nargin < 3;error('Require spike, lfp and lfptimes ');end
0039 [data_spk]=padNaN(data_spk); % create a zero padded data matrix from input structural array
0040 data_spk=data_spk'; % transposes data to get it in a form compatible with Murray's routine
0041 if nargin < 4; plt = 'y';end
0042 if nargin < 6; Tinc = 0.1; end
0043 if nargin < 7; Tw = 0.5;end
0044 if nargin < 8; w = 0.01;end
0045 if nargin < 9; D = 0.15*[-1 1]; end
0046 if nargin < 5; 
0047     Tc(1) = min(data_spk(:,1)) + Tw/2;
0048     Tc(2) = max(max(data_spk)) - Tw/2;
0049 end
0050 
0051 if isempty(plt); plt = 'y';end
0052 if isempty(Tinc); Tinc = 0.1; end
0053 if isempty(Tw); Tw = 0.5;end
0054 if isempty(w); w = 0.01;end
0055 if isempty(D); D = 0.15*[-1 1]; end
0056 if isempty(Tc); 
0057     Tc(1) = min(data_spk(:,1)) + Tw/2;
0058     Tc(2) = max(max(data_spk)) - Tw/2;
0059 end
0060 
0061 
0062 %  round to nearest tinc...
0063 
0064 t = smp;
0065 Tc(1) = ceil(Tc(1)/Tinc)*Tinc;
0066 Tc(2) = floor(Tc(2)/Tinc)*Tinc;
0067 tc = Tc(1):Tinc:Tc(2);
0068 for tt=1:length(tc)
0069   T = [tc(tt)-Tw/2 tc(tt)+Tw/2];
0070   if tt == 1
0071     [SS,tau,E] = sta(data_spk,data_lfp,t,'y',w,T,D,0);
0072     S = zeros(length(tc),length(SS));
0073   else
0074     [SS,tau,E] = sta(data_spk,data_lfp,t,'y',w,T,D,0);
0075   end
0076   S(tt,:) = SS';
0077   S(tt,:) = SS';
0078 end
0079 
0080 if ~strcmp(plt,'n')
0081   imagesc(tc,tau,squeeze(S)')
0082   set(gca,'ydir','normal')
0083   xlabel('time (s)')
0084   ylabel('frequency (Hz)')
0085   h = colorbar;
0086 %  axes(h)
0087 %  line(get(h,'xlim'),conf_C*[1 1],'color','k','linewidth',5)
0088 end
0089 
0090 
0091 
0092 
0093 
0094 
0095 
0096 
0097 
0098

Generated on Tue 24-Aug-2004 15:55:33 by m2html © 2003