function y = ad_pattern(x, wsize, range) % y=ad_pattern(x,wsize,maxlag) - Pattern of neural coincidence % x: spike train, % wsize: coincidence window size, range: histogram size, in samples global sr; % exponential window of duration 4*wsize. % n = 4 * wsize * sr; % z = 1:n; % w = exp(- (z-1) * 4 / n); % square window of duration wsize. n = round(wsize); w = ones(1, n); % convert time list to count array N = round(max(x) .* sr); a = histogram(x, N); %a = hist(x, N); % convolve with window mask = conv(a, w); % clip mask at 1 mask = 1- mask; mask = 1 - (abs(mask) + mask) ./ 2; % cross correlation y = zeros(1, range); for i = 1:range z = (1-mask(:,i:N)) .* a(:, 1:N-i+1); y(i) = sum(z); end