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] = ...
0002           countsig(data1,data2,T1,T2,parametric,p,quiet)
0003 % Give the program two spike data sets and one
0004 % or two time intervals and it will decide if
0005 % the counts are significantly different.
0006 % this is either with a non-parametric method
0007 % or with a sqrt transformation followed by a
0008 % t-test
0009 % Usage: [H,P,M1,M2,N1,N2] = countsig(data1,data2,T1,T2,parametric,p,quiet)
0010 %
0011 % Input:
0012 % Note that all times have to be consistent. If data
0013 % is in seconds, so must be sig and t. If data is in
0014 % samples, so must sig and t. The default is seconds.
0015 %
0016 % data1      - structure array of spike times (required)
0017 % data2      - structure array of spike times (required)
0018 % T1         - time interval (default all)
0019 % T2         - time interval (default T1)
0020 % parametric - 0 = non-parametric (Wilcoxon)
0021 %            - 1 = ttest on sqrt of counts
0022 %            - 2 = Poisson assumption
0023 %              (default = 0)
0024 % p          - significance level (0.05)
0025 % quiet      - 1 = no display 0 = display
0026 %
0027 % Output:
0028 %
0029 % H          - 1 if different 0 if not
0030 % P          - prob of result if same
0031 % M1         - mean count for data1
0032 % M2         - mean count for data2
0033 % N1         - counts for data1
0034 % N2         - counts for data2
0035 
0036 
0037 if nargin < 2;error('I need 2 sets of spike data');end
0038 data1=padNaN(data1); % create a zero padded data matrix from input structural array
0039 data2=padNaN(data2); % create a zero padded data matrix from input structural array
0040 data1=data1'; data2=data2'; % transpose data to get it into a form acceptable to Murray's routine
0041 if nargin < 3, 
0042    T1 = [min(data(:,1)) max(max(data))]; 
0043 end
0044 if nargin < 4, 
0045    T2 = T1; 
0046 end
0047 if nargin < 5, 
0048    parametric = 0;
0049 end  
0050 if nargin < 6; p = 0.05;end
0051 if nargin < 7; quiet = 0; end
0052 
0053 if isempty(T1), 
0054    T1 = [min(data(:,1)) max(max(data))]; 
0055 end
0056 if isempty(T2) 
0057    T2 = T1; 
0058 end
0059 if isempty(parametric),
0060    parametric = 0;
0061 end  
0062 if isempty(p) 
0063    p = 0.05;
0064 end
0065 if isempty(quiet), 
0066     quiet = 0; 
0067 end
0068 
0069 NT1 = length(data1(:,1));
0070 NT2 = length(data2(:,2));
0071 
0072 if (NT1 < 4 | NT2 < 4) & parametric ~= 2,
0073   disp('Low number of trials : switch to Poisson test')
0074   parametric = 2;
0075 end
0076 
0077 if abs((T1(2)-T1(1)) - (T1(2)-T1(1))) > 10.^-6
0078   error('Time intervals for analysis are different')
0079 end
0080 
0081 % get counts...
0082 
0083 for n=1:NT1
0084   N1(n) = length(find(data1(n,:) >=  T1(1) & ...
0085           data1(n,:) <=  T1(2) & ~isnan(data1(n,:))));
0086 end
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 20-May-2005 13:10:28 by m2html © 2003