comparison toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/CorrelogramFrame.m @ 0:e9a9cd732c1e tip

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