


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

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; T1 = [min(data(:,1)) max(max(data))]; end 0042 if nargin < 4; T2 = T1; end 0043 if nargin < 5; parametric = 0;end 0044 if nargin < 6; p = 0.05;end 0045 if nargin < 7; quiet = 0; end 0046 0047 if isempty(T1); T1 = [min(data(:,1)) max(max(data))]; end 0048 if isempty(T2); T2 = T1; end 0049 if isempty(parametric); parametric = 0;end 0050 if isempty(p); p = 0.05;end 0051 if isempty(quiet); quiet = 0; end 0052 0053 NT1 = length(data1(:,1)); 0054 NT2 = length(data2(:,2)); 0055 0056 if (NT1 < 4 | NT2 < 4) & parametric ~= 2 0057 disp('Low number of trials : switch to Poisson test') 0058 parametric = 2; 0059 end 0060 0061 if abs((T1(2)-T1(1)) - (T1(2)-T1(1))) > 10.^-6 0062 error('Time intervals for analysis are different') 0063 end 0064 0065 % get counts... 0066 0067 for n=1:NT1 0068 N1(n) = length(find(data1(n,:) >= T1(1) & ... 0069 data1(n,:) <= T1(2) & ~isnan(data1(n,:)))); 0070 end 0071 for n=1:NT2 0072 N2(n) = length(find(data2(n,:) >= T2(1) & ... 0073 data2(n,:) <= T2(2) & ~isnan(data1(n,:)))); 0074 end 0075 M1 = mean(N1); 0076 M2 = mean(N2); 0077 0078 % do non parametric test... 0079 0080 if parametric == 0 0081 [P H] = ranksum(N1,N2,p); 0082 end 0083 0084 % parametric test (with stabilizing transform)... 0085 0086 % use sqrt transformation from 0087 % Cox and Lewis to make data more Gaussian 0088 % the statistical analysis of series of events pg 44 0089 0090 if parametric == 1 0091 X = sqrt(N1 +0.25); 0092 Y = sqrt(N2 +0.25); 0093 [H,P] = ttest2(X,Y,p,0); 0094 end 0095 0096 % Poisson test. Use method from Zar 0097 % pg 580 Ed 3. Z bahaves as a normal variate under 0098 % null of same process mean and Poisson processes 0099 0100 if parametric == 2 0101 X = sum(N1); 0102 Y = sum(N2); 0103 Z = abs(X-Y)./sqrt(X+Y); 0104 P = 2*(1-normcdf(Z)); 0105 if P < p; H = 1;else; H = 0;end 0106 end 0107 0108 if quiet == 0 0109 if H == 1 0110 disp('Counts are signifcantly different') 0111 else 0112 disp('Counts are not signifcantly different') 0113 end 0114 disp(['Mean count for data1 = ' num2str(M1)]) 0115 disp(['Mean count for data2 = ' num2str(M2)]) 0116 disp(['P value = ' num2str(P)]) 0117 end 0118 0119 0120 0121 0122 0123 0124 0125 0126 0127 0128