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 N1=zeros(1,NT1);
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 N2=zeros(1,NT2);
0087 for n=1:NT2
0088   N2(n) = length(find(data2(n,:) >=  T2(1) & ...
0089           data2(n,:) <=  T2(2) & ~isnan(data1(n,:))));
0090 end
0091 M1 = mean(N1);
0092 M2 = mean(N2);
0093 
0094 % do non parametric test...
0095 
0096 if parametric == 0
0097   [P H] = ranksum(N1,N2,p);
0098 end
0099 
0100 % parametric test (with stabilizing transform)...
0101 
0102 %  use sqrt transformation from
0103 %  Cox and Lewis to make data more Gaussian
0104 %  the statistical analysis of series of events pg 44
0105 
0106 if parametric == 1
0107   X = sqrt(N1 +0.25);
0108   Y = sqrt(N2 +0.25);
0109   [H,P] = ttest2(X,Y,p,0);
0110 end
0111 
0112 %  Poisson test.  Use method from Zar
0113 %  pg 580 Ed 3.  Z bahaves as a normal variate under
0114 %  null of same process mean and Poisson processes
0115 
0116 if parametric == 2
0117   X = sum(N1);
0118   Y = sum(N2);
0119   Z = abs(X-Y)./sqrt(X+Y);
0120   P = 2*(1-normcdf(Z));
0121   if P < p; H = 1;else H = 0;end
0122 end  
0123 
0124 if quiet == 0
0125   if H == 1
0126     disp('Counts are signifcantly different')
0127   else
0128     disp('Counts are not signifcantly different') 
0129   end
0130   disp(['Mean count for data1 = ' num2str(M1)])
0131   disp(['Mean count for data2 = ' num2str(M2)])
0132   disp(['P value = ' num2str(P)])
0133 end
0134 
0135 
0136 
0137 
0138 
0139 
0140 
0141 
0142 
0143 
0144

Generated on Fri 12-Aug-2011 11:36:15 by m2html © 2005