Home > chronux_0.5 > pointtimes > countsig.m

countsig

PURPOSE ^

Give the program two spike data sets and one

SYNOPSIS ^

function[H,P,M1,M2,N1,N2] = countsig(data1,data2,T1,T2,parametric,p,quiet)

DESCRIPTION ^

 Give the program two spike data sets and one 
 or two time intervals and it will decide if  
 the counts are significantly different.      
 this is either with a non-parametric method  
 or with a sqrt transformation followed by a   
 t-test                                       
 Usage: [H,P,M1,M2,N1,N2] = countsig(data1,data2,T1,T2,parametric,p,quiet)
                                              
 Input:                                       
 Note that all times have to be consistent. If data
 is in seconds, so must be sig and t. If data is in 
 samples, so must sig and t. The default is seconds.

 data1      - structure array of spike times (required)  
 data2      - structure array of spike times (required)  
 T1         - time interval (default all)     
 T2         - time interval (default T1)      
 parametric - 0 = non-parametric (Wilcoxon)   
            - 1 = ttest on sqrt of counts     
            - 2 = Poisson assumption          
              (default = 0)                   
 p          - significance level (0.05)       
 quiet      - 1 = no display 0 = display      
                                              
 Output:                                      
                                              
 H          - 1 if different 0 if not         
 P          - prob of result if same          
 M1         - mean count for data1            
 M2         - mean count for data2            
 N1         - counts for data1                
 N2         - counts for data2

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function[H,P,M1,M2,N1,N2] = countsig(data1,data2,T1,T2,parametric,p,quiet)
0002 % Give the program two spike data sets and one
0003 % or two time intervals and it will decide if
0004 % the counts are significantly different.
0005 % this is either with a non-parametric method
0006 % or with a sqrt transformation followed by a
0007 % t-test
0008 % Usage: [H,P,M1,M2,N1,N2] = countsig(data1,data2,T1,T2,parametric,p,quiet)
0009 %
0010 % Input:
0011 % Note that all times have to be consistent. If data
0012 % is in seconds, so must be sig and t. If data is in
0013 % samples, so must sig and t. The default is seconds.
0014 %
0015 % data1      - structure array of spike times (required)
0016 % data2      - structure array of spike times (required)
0017 % T1         - time interval (default all)
0018 % T2         - time interval (default T1)
0019 % parametric - 0 = non-parametric (Wilcoxon)
0020 %            - 1 = ttest on sqrt of counts
0021 %            - 2 = Poisson assumption
0022 %              (default = 0)
0023 % p          - significance level (0.05)
0024 % quiet      - 1 = no display 0 = display
0025 %
0026 % Output:
0027 %
0028 % H          - 1 if different 0 if not
0029 % P          - prob of result if same
0030 % M1         - mean count for data1
0031 % M2         - mean count for data2
0032 % N1         - counts for data1
0033 % N2         - counts for data2
0034 
0035 
0036 if nargin < 2;error('I need 2 sets of spike data');end
0037 data1=padNaN(data1); % create a zero padded data matrix from input structural array
0038 data2=padNaN(data2); % create a zero padded data matrix from input structural array
0039 data1=data1'; data2=data2'; % transpose data to get it into a form acceptable to Murray's routine
0040 if nargin < 3, 
0041    T1 = [min(data1(:,1)) max(max(data1))]; 
0042 end
0043 if nargin < 4, 
0044    T2 = T1; 
0045 end
0046 if nargin < 5, 
0047    parametric = 0;
0048 end  
0049 if nargin < 6; p = 0.05;end
0050 if nargin < 7; quiet = 0; end
0051 
0052 if isempty(T1), 
0053    T1 = [min(data1(:,1)) max(max(data1))]; 
0054 end
0055 if isempty(T2) 
0056    T2 = T1; 
0057 end
0058 if isempty(parametric),
0059    parametric = 0;
0060 end  
0061 if isempty(p) 
0062    p = 0.05;
0063 end
0064 if isempty(quiet), 
0065     quiet = 0; 
0066 end
0067 
0068 NT1 = length(data1(:,1));
0069 NT2 = length(data2(:,2));
0070 
0071 if (NT1 < 4 || NT2 < 4) && parametric ~= 2,
0072   disp('Low number of trials : switch to Poisson test')
0073   parametric = 2;
0074 end
0075 
0076 if abs((T1(2)-T1(1)) - (T1(2)-T1(1))) > 10.^-6
0077   error('Time intervals for analysis are different')
0078 end
0079 
0080 % get counts...
0081 
0082 for n=1:NT1
0083   N1(n) = length(find(data1(n,:) >=  T1(1) & ...
0084           data1(n,:) <=  T1(2) & ~isnan(data1(n,:))));
0085 end
0086 for n=1:NT2
0087   N2(n) = length(find(data2(n,:) >=  T2(1) & ...
0088           data2(n,:) <=  T2(2) & ~isnan(data1(n,:))));
0089 end
0090 M1 = mean(N1);
0091 M2 = mean(N2);
0092 
0093 % do non parametric test...
0094 
0095 if parametric == 0
0096   [P H] = ranksum(N1,N2,p);
0097 end
0098 
0099 % parametric test (with stabilizing transform)...
0100 
0101 %  use sqrt transformation from
0102 %  Cox and Lewis to make data more Gaussian
0103 %  the statistical analysis of series of events pg 44
0104 
0105 if parametric == 1
0106   X = sqrt(N1 +0.25);
0107   Y = sqrt(N2 +0.25);
0108   [H,P] = ttest2(X,Y,p,0);
0109 end
0110 
0111 %  Poisson test.  Use method from Zar
0112 %  pg 580 Ed 3.  Z bahaves as a normal variate under
0113 %  null of same process mean and Poisson processes
0114 
0115 if parametric == 2
0116   X = sum(N1);
0117   Y = sum(N2);
0118   Z = abs(X-Y)./sqrt(X+Y);
0119   P = 2*(1-normcdf(Z));
0120   if P < p; H = 1;else H = 0;end
0121 end  
0122 
0123 if quiet == 0
0124   if H == 1
0125     disp('Counts are signifcantly different')
0126   else
0127     disp('Counts are not signifcantly different') 
0128   end
0129   disp(['Mean count for data1 = ' num2str(M1)])
0130   disp(['Mean count for data2 = ' num2str(M2)])
0131   disp(['P value = ' num2str(P)])
0132 end
0133 
0134 
0135 
0136 
0137 
0138 
0139 
0140 
0141 
0142 
0143

Generated on Tue 16-Aug-2005 21:33:45 by m2html © 2003