annotate toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/MeddisHairCell.m @ 0:cc4b1211e677 tip

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