Daniel@0: % pic = CorrelogramFrame(data, picWidth, start, winLen) Daniel@0: % Compute one frame of a correlogram. The input data is a Daniel@0: % two-dimensional array of cochlear data, each row representing Daniel@0: % firing probabilities from one cochlear channel. The output Daniel@0: % picture is a two dimensional array of width "picWidth". Daniel@0: % Daniel@0: % The correlogram is computed with autocorrelation using Daniel@0: % data from the input array. For each channel, the data from Daniel@0: % is extracted starting at column "start" and extending for Daniel@0: % "winLength" time steps. Daniel@0: Daniel@0: % (c) 1998 Interval Research Corporation Daniel@0: Daniel@0: function pic = CorrelogramFrame(data, picWidth, start, winLen) Daniel@0: Daniel@0: if nargin < 2 Daniel@0: disp('Syntax: pic=CorrelogramFrame(data, picWidth[, start, len])'); Daniel@0: return Daniel@0: end Daniel@0: Daniel@0: if nargin < 3 Daniel@0: start = 1; Daniel@0: end Daniel@0: Daniel@0: if nargin < 4 Daniel@0: [channels, winLen] = size(data); Daniel@0: end Daniel@0: Daniel@0: [channels, dataLen] = size(data); Daniel@0: start = max(1, start); Daniel@0: last = min(dataLen, start+winLen-1); Daniel@0: Daniel@0: pic = zeros(channels, picWidth); Daniel@0: fftSize = 2^(nextpow2(max(picWidth, winLen))+1); Daniel@0: % disp(['CorrelogramFrame fftSize is ' int2str(fftSize)]); Daniel@0: Daniel@0: a = .54; Daniel@0: b = -.46; Daniel@0: wr = sqrt(64/256); Daniel@0: phi = pi/winLen; Daniel@0: ws = 2*wr/sqrt(4*a*a+2*b*b)*(a + b*cos(2*pi*(0:winLen-1)/winLen + phi)); Daniel@0: Daniel@0: for i=1:channels Daniel@0: f = zeros(1, fftSize); Daniel@0: % d = zeros(1, winLen); Daniel@0: % d(1:(last-start+1)) = data(i,start:last) .* ws(1:(last-start+1)); Daniel@0: % f(1:(winLen/2)) = d(winLen/2+1:winLen); Daniel@0: % f(fftSize-(winLen/2)+1:fftSize) = d(1:min(length(d),winLen/2)); Daniel@0: f(1:(last-start+1)) = data(i,start:last) .* ws(1:(last-start+1)); Daniel@0: f = fft(f); Daniel@0: f = ifft(f.*conj(f)); Daniel@0: pic(i,:) = real(f(1:picWidth)); Daniel@0: if pic(i,1) > pic(i,2) & pic(i,1) > pic(i,3) Daniel@0: pic(i,:) = pic(i,:)/sqrt(pic(i,1)); Daniel@0: else Daniel@0: pic(i,:) = zeros(1,picWidth); Daniel@0: end Daniel@0: end