comparison toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/MeddisHairCell.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 function y = MeddisHairCell(data,sampleRate,subtractSpont)
2 % y = MeddisHairCell(data,sampleRate)
3 % This function calculates Ray Meddis' hair cell model for a
4 % number of channels. Data is arrayed as one channel per row.
5 % All channels are done in parallel (but each time step is
6 % sequential) so it will be much more efficient to process lots
7 % of channels at once.
8
9 % (c) 1998 Interval Research Corporation
10 % Changed h and added comment at suggestion of Alain de Cheveigne' 12/11/98
11
12 if (nargin<3), subtractSpont=0; end
13
14 % Parameters from Meddis' April 1990 JASA paper.
15 M = 1;
16 A = 5;
17 B = 300;
18 g = 2000;
19 y = 5.05;
20 l = 2500;
21 r = 6580;
22 x = 66.31;
23 h = 50000; % This parameter scales the discharge rate. Adjust as necessary.
24 % In combination with the gammatone filterbank (ERBFilterBank),
25 % h=50000 will produce a steady-state average discharge
26 % probability of about 135 spikes/s within the 1kHz channel,
27 % for an input consisting of a 1 kHz sinewave at 60 dB SPL
28 % (0 dB SPL corresponds to an RMS level of 1.0 at the
29 % input of the gammatone filter). Scaling and constant
30 % courtesy of Alain de Cheveigne'
31
32
33 % Internal constants
34 dt = 1/sampleRate;
35 gdt = g*dt;
36 ydt = y*dt;
37 ldt = l*dt;
38 rdt = r*dt;
39 xdt = x*dt;
40 [numChannels dataLength] = size(data);
41
42 % Initial values
43 kt = g*A/(A+B);
44 spont = M*y*kt/(l*kt+y*(l+r));
45 c = spont * ones(numChannels,1);
46 q = c*(l+r)/kt;
47 w = c*r/x;
48 zeroVector = zeros(numChannels,1);
49
50 % Now iterate through each time slice of the data. Use the
51 % max function to implement the "if (0>" test.
52 y = zeros(numChannels, dataLength);
53 for i = 1:dataLength
54 limitedSt = max(data(:,i)+A,0);
55 kt = gdt*limitedSt./(limitedSt+B);
56 replenish = max(ydt*(M-q),zeroVector);
57 eject = kt.*q;
58 loss = ldt.*c;
59 reuptake = rdt.*c;
60 reprocess = xdt.*w;
61
62 q = q + replenish - eject + reprocess;
63 c = c + eject - loss - reuptake;
64 w = w + reuptake - reprocess;
65 y(:,i) = c;
66 end
67
68 y = h .* y;
69
70 if (subtractSpont > 0)
71 y=max(0,y-spont);
72 end