wolffd@0
|
1 % pic = CorrelogramFrame(data, picWidth, start, winLen)
|
wolffd@0
|
2 % Compute one frame of a correlogram. The input data is a
|
wolffd@0
|
3 % two-dimensional array of cochlear data, each row representing
|
wolffd@0
|
4 % firing probabilities from one cochlear channel. The output
|
wolffd@0
|
5 % picture is a two dimensional array of width "picWidth".
|
wolffd@0
|
6 %
|
wolffd@0
|
7 % The correlogram is computed with autocorrelation using
|
wolffd@0
|
8 % data from the input array. For each channel, the data from
|
wolffd@0
|
9 % is extracted starting at column "start" and extending for
|
wolffd@0
|
10 % "winLength" time steps.
|
wolffd@0
|
11
|
wolffd@0
|
12 % (c) 1998 Interval Research Corporation
|
wolffd@0
|
13
|
wolffd@0
|
14 function pic = CorrelogramFrame(data, picWidth, start, winLen)
|
wolffd@0
|
15
|
wolffd@0
|
16 if nargin < 2
|
wolffd@0
|
17 disp('Syntax: pic=CorrelogramFrame(data, picWidth[, start, len])');
|
wolffd@0
|
18 return
|
wolffd@0
|
19 end
|
wolffd@0
|
20
|
wolffd@0
|
21 if nargin < 3
|
wolffd@0
|
22 start = 1;
|
wolffd@0
|
23 end
|
wolffd@0
|
24
|
wolffd@0
|
25 if nargin < 4
|
wolffd@0
|
26 [channels, winLen] = size(data);
|
wolffd@0
|
27 end
|
wolffd@0
|
28
|
wolffd@0
|
29 [channels, dataLen] = size(data);
|
wolffd@0
|
30 start = max(1, start);
|
wolffd@0
|
31 last = min(dataLen, start+winLen-1);
|
wolffd@0
|
32
|
wolffd@0
|
33 pic = zeros(channels, picWidth);
|
wolffd@0
|
34 fftSize = 2^(nextpow2(max(picWidth, winLen))+1);
|
wolffd@0
|
35 % disp(['CorrelogramFrame fftSize is ' int2str(fftSize)]);
|
wolffd@0
|
36
|
wolffd@0
|
37 a = .54;
|
wolffd@0
|
38 b = -.46;
|
wolffd@0
|
39 wr = sqrt(64/256);
|
wolffd@0
|
40 phi = pi/winLen;
|
wolffd@0
|
41 ws = 2*wr/sqrt(4*a*a+2*b*b)*(a + b*cos(2*pi*(0:winLen-1)/winLen + phi));
|
wolffd@0
|
42
|
wolffd@0
|
43 for i=1:channels
|
wolffd@0
|
44 f = zeros(1, fftSize);
|
wolffd@0
|
45 % d = zeros(1, winLen);
|
wolffd@0
|
46 % d(1:(last-start+1)) = data(i,start:last) .* ws(1:(last-start+1));
|
wolffd@0
|
47 % f(1:(winLen/2)) = d(winLen/2+1:winLen);
|
wolffd@0
|
48 % f(fftSize-(winLen/2)+1:fftSize) = d(1:min(length(d),winLen/2));
|
wolffd@0
|
49 f(1:(last-start+1)) = data(i,start:last) .* ws(1:(last-start+1));
|
wolffd@0
|
50 f = fft(f);
|
wolffd@0
|
51 f = ifft(f.*conj(f));
|
wolffd@0
|
52 pic(i,:) = real(f(1:picWidth));
|
wolffd@0
|
53 if pic(i,1) > pic(i,2) & pic(i,1) > pic(i,3)
|
wolffd@0
|
54 pic(i,:) = pic(i,:)/sqrt(pic(i,1));
|
wolffd@0
|
55 else
|
wolffd@0
|
56 pic(i,:) = zeros(1,picWidth);
|
wolffd@0
|
57 end
|
wolffd@0
|
58 end
|