To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.
root / utilities / UTIL_CAPgenerator.m @ 38:c2204b18f4a2
History | View | Annotate | Download (1.74 KB)
| 1 | 38:c2204b18f4a2 | rmeddis | function wholeNerveCAP = UTIL_CAPgenerator... |
|---|---|---|---|
| 2 | (ANresponse, dt, BFlist, numANfibers, plotCAP) |
||
| 3 | % |
||
| 4 | % Generates a compound action potential by convolving an impulse repsonse, |
||
| 5 | % as defined by Mark Chertoff (2004, JASA), with the response of the |
||
| 6 | % auditory nerve. |
||
| 7 | % |
||
| 8 | % |
||
| 9 | % -e(-k*time)*SIN(2*PI()*f*time) |
||
| 10 | % |
||
| 11 | % mu(t) = e^-kt * sin(omega*t) |
||
| 12 | % omega = 2 * pi * f |
||
| 13 | % |
||
| 14 | % |
||
| 15 | % Robert T. Ferry |
||
| 16 | % 01st May 2008 |
||
| 17 | % |
||
| 18 | % |
||
| 19 | |||
| 20 | nChannels=length(BFlist); |
||
| 21 | [r nSpikeEpochs]=size(ANresponse); |
||
| 22 | |||
| 23 | wholeNerveCAP = []; |
||
| 24 | channelCAP = []; |
||
| 25 | e = exp(1); |
||
| 26 | k = 1000; |
||
| 27 | impulseDuration = 0.01; |
||
| 28 | impulseFrequency = 750; |
||
| 29 | impulseTime = dt:dt:impulseDuration; |
||
| 30 | impulseResponse = -e.^(-k*impulseTime).*sin(2*pi*impulseFrequency*impulseTime); |
||
| 31 | impulseResponse=impulseResponse-mean(impulseResponse); |
||
| 32 | |||
| 33 | % WholeNerveCAP |
||
| 34 | ANoutput = sum(ANresponse, 1); |
||
| 35 | convolvedWholeNerveCAP = conv(ANoutput, impulseResponse(1,:)); |
||
| 36 | % truncate |
||
| 37 | convolvedWholeNerveCAP=convolvedWholeNerveCAP(1:nSpikeEpochs); |
||
| 38 | |||
| 39 | % apply measurement time constant |
||
| 40 | sampleRate=1/dt; |
||
| 41 | upperFreq=sampleRate/4; |
||
| 42 | lowPassCutOff=40; |
||
| 43 | wholeNerveCAP = UTIL_Butterworth(convolvedWholeNerveCAP, dt, lowPassCutOff, upperFreq, 1); |
||
| 44 | % or do not do this |
||
| 45 | % wholeNerveCAP = convolvedWholeNerveCAP; |
||
| 46 | |||
| 47 | % Plot output? |
||
| 48 | |||
| 49 | CAPtime = dt:dt:dt*length(wholeNerveCAP); |
||
| 50 | |||
| 51 | if (plotCAP == 1) |
||
| 52 | figure(9) |
||
| 53 | |||
| 54 | subplot(3,1,1), plot(impulseTime, impulseResponse) |
||
| 55 | title('Impulse response')
|
||
| 56 | xlabel('Time (s)'), ylabel('Amplitude (Pa)')
|
||
| 57 | xlim([0 max(impulseTime)]), ylim([-inf inf]) |
||
| 58 | |||
| 59 | subplot(3,1,2), plot(CAPtime, wholeNerveCAP) |
||
| 60 | title(['AN CAP (whole-nerve) ' num2str(length(BFlist)) ' channels' num2str(numANfibers) ' fibers/ch']) |
||
| 61 | xlabel('Time (s)'), ylabel('Amplitude (Pa)')
|
||
| 62 | xlim([0 max(CAPtime)]), ylim([-inf inf]) |
||
| 63 | |||
| 64 | end |