Home > chronux > spectral_analysis > hybrid > staogram.m

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                                               
                                                           
 Tc = start and end times (centres)           whole trial       
 Tinc = time increment between windows             0.1            
 Tw = 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 % Tc = start and end times (centres)           whole trial
0025 % Tinc = time increment between windows             0.1
0026 % Tw = 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 % setup defaults...
0037 if nargin < 3;error('Require spike, lfp and lfptimes ');end
0038 [data_spk]=padNaN(data_spk); % create a zero padded data matrix from input structural array
0039 data_spk=data_spk'; % transposes data to get it in a form compatible with Murray's routine
0040 if nargin < 4; plt = 'y';end
0041 if nargin < 6; Tinc = 0.1; end
0042 if nargin < 7; Tw = 0.5;end
0043 if nargin < 8; w = 0.01;end
0044 if nargin < 9; D = 0.15*[-1 1]; end
0045 if nargin < 5; 
0046     Tc(1) = min(data_spk(:,1)) + Tw/2;
0047     Tc(2) = max(max(data_spk)) - Tw/2;
0048 end
0049 
0050 if isempty(plt); plt = 'y';end
0051 if isempty(Tinc); Tinc = 0.1; end
0052 if isempty(Tw); Tw = 0.5;end
0053 if isempty(w); w = 0.01;end
0054 if isempty(D); D = 0.15*[-1 1]; end
0055 if isempty(Tc); 
0056     Tc(1) = min(data_spk(:,1)) + Tw/2;
0057     Tc(2) = max(max(data_spk)) - Tw/2;
0058 end
0059 
0060 
0061 %  round to nearest tinc...
0062 
0063 t = smp;
0064 Tc(1) = ceil(Tc(1)/Tinc)*Tinc;
0065 Tc(2) = floor(Tc(2)/Tinc)*Tinc;
0066 tc = Tc(1):Tinc:Tc(2);
0067 for tt=1:length(tc)
0068   T = [tc(tt)-Tw/2 tc(tt)+Tw/2];
0069   if tt == 1
0070     [SS,tau] = sta(data_spk,data_lfp,t,'y',w,T,D,0);
0071     S = zeros(length(tc),length(SS));
0072   else
0073     [SS,tau] = sta(data_spk,data_lfp,t,'y',w,T,D,0);
0074   end
0075   S(tt,:) = SS';
0076   S(tt,:) = SS';
0077 end
0078 
0079 if ~strcmp(plt,'n')
0080   imagesc(tc,tau,squeeze(S)')
0081   set(gca,'ydir','normal')
0082   xlabel('time (s)')
0083   ylabel('frequency (Hz)')
0084   colorbar;
0085 %  axes(h)
0086 %  line(get(h,'xlim'),conf_C*[1 1],'color','k','linewidth',5)
0087 end
0088 
0089 
0090 
0091 
0092 
0093 
0094 
0095 
0096 
0097

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005