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 / testPrograms / testANprob.m @ 38:c2204b18f4a2
History | View | Annotate | Download (5.9 KB)
| 1 | 34:e097e9044ef6 | rmeddis | function testANprob(targetFrequency,BFlist, levels, ... |
|---|---|---|---|
| 2 | 29:b51bf546ca3f | rmeddis | paramsName, paramChanges) |
| 3 | 38:c2204b18f4a2 | rmeddis | % testANprob generates rate/level functions for AN and brainstem units. |
| 4 | % also other information like PSTHs, MOC efferent activity levels. |
||
| 5 | % A 'probability' model is used. |
||
| 6 | % e.g. |
||
| 7 | 34:e097e9044ef6 | rmeddis | % testANprob(1000,1000, -10:10:80, 'Normal') |
| 8 | |||
| 9 | 29:b51bf546ca3f | rmeddis | global IHC_VResp_VivoParams IHC_cilia_RPParams IHCpreSynapseParams |
| 10 | global AN_IHCsynapseParams |
||
| 11 | 32:82fb37eb430e | rmeddis | global ANprobRateOutput dt ANtauCas |
| 12 | 29:b51bf546ca3f | rmeddis | global ARattenuation MOCattenuation |
| 13 | |||
| 14 | AN_spikesOrProbability='probability'; |
||
| 15 | |||
| 16 | dbstop if error |
||
| 17 | addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ... |
||
| 18 | ['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'],... |
||
| 19 | ['..' filesep 'testPrograms']) |
||
| 20 | |||
| 21 | 35:25d53244d5c8 | rmeddis | if nargin<5, paramChanges=[]; end |
| 22 | if nargin<4, paramsName='Normal'; end |
||
| 23 | if nargin<3, levels=-10:10:80; end |
||
| 24 | if nargin==0, targetFrequency=1000; BFlist=1000; end |
||
| 25 | 29:b51bf546ca3f | rmeddis | |
| 26 | nLevels=length(levels); |
||
| 27 | |||
| 28 | toneDuration=.2; |
||
| 29 | rampDuration=0.002; |
||
| 30 | silenceDuration=.02; |
||
| 31 | localPSTHbinwidth=0.001; |
||
| 32 | |||
| 33 | % Use only the first frequency in the GUI targetFrequency box to defineBF |
||
| 34 | % targetFrequency=stimulusParameters.targetFrequency(1); |
||
| 35 | % BFlist=targetFrequency; |
||
| 36 | |||
| 37 | AN_HSRonset=zeros(nLevels,1); |
||
| 38 | AN_HSRsaturated=zeros(nLevels,1); |
||
| 39 | AN_LSRonset=zeros(nLevels,1); |
||
| 40 | AN_LSRsaturated=zeros(nLevels,1); |
||
| 41 | |||
| 42 | AR=zeros(nLevels,1); |
||
| 43 | MOC=zeros(nLevels,1); |
||
| 44 | |||
| 45 | figure(15), clf |
||
| 46 | 34:e097e9044ef6 | rmeddis | set(gcf,'position',[980 356 401 321]) |
| 47 | 29:b51bf546ca3f | rmeddis | drawnow |
| 48 | |||
| 49 | %% guarantee that the sample rate is at least 10 times the frequency |
||
| 50 | sampleRate=50000; |
||
| 51 | while sampleRate< 10* targetFrequency |
||
| 52 | sampleRate=sampleRate+10000; |
||
| 53 | end |
||
| 54 | |||
| 55 | %% adjust sample rate so that the pure tone stimulus has an integer |
||
| 56 | %% numver of epochs in a period |
||
| 57 | dt=1/sampleRate; |
||
| 58 | period=1/targetFrequency; |
||
| 59 | |||
| 60 | %% main computational loop (vary level) |
||
| 61 | levelNo=0; |
||
| 62 | for leveldB=levels |
||
| 63 | levelNo=levelNo+1; |
||
| 64 | |||
| 65 | fprintf('%4.0f\t', leveldB)
|
||
| 66 | amp=28e-6*10^(leveldB/20); |
||
| 67 | |||
| 68 | time=dt:dt:toneDuration; |
||
| 69 | rampTime=dt:dt:rampDuration; |
||
| 70 | ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
||
| 71 | ones(1,length(time)-length(rampTime))]; |
||
| 72 | ramp=ramp.*fliplr(ramp); |
||
| 73 | |||
| 74 | silence=zeros(1,round(silenceDuration/dt)); |
||
| 75 | |||
| 76 | % create signal (leveldB/ targetFrequency) |
||
| 77 | inputSignal=amp*sin(2*pi*targetFrequency'*time); |
||
| 78 | inputSignal= ramp.*inputSignal; |
||
| 79 | inputSignal=[silence inputSignal]; |
||
| 80 | |||
| 81 | %% run the model |
||
| 82 | showPlotsAndDetails=0; |
||
| 83 | |||
| 84 | |||
| 85 | MAP1_14(inputSignal, 1/dt, BFlist, ... |
||
| 86 | paramsName, AN_spikesOrProbability, paramChanges); |
||
| 87 | |||
| 88 | 32:82fb37eb430e | rmeddis | nTaus=length(ANtauCas); |
| 89 | 29:b51bf546ca3f | rmeddis | |
| 90 | %LSR (same as HSR if no LSR fibers present) |
||
| 91 | [nANFibers nTimePoints]=size(ANprobRateOutput); |
||
| 92 | |||
| 93 | numLSRfibers=1; |
||
| 94 | numHSRfibers=numLSRfibers; |
||
| 95 | |||
| 96 | LSRspikes=ANprobRateOutput(1:numLSRfibers,:); |
||
| 97 | PSTH=UTIL_PSTHmaker(LSRspikes, dt, localPSTHbinwidth); |
||
| 98 | PSTHLSR=PSTH/(localPSTHbinwidth/dt); % across fibers rates |
||
| 99 | PSTHtime=localPSTHbinwidth:localPSTHbinwidth:... |
||
| 100 | localPSTHbinwidth*length(PSTH); |
||
| 101 | AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window |
||
| 102 | AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end)); |
||
| 103 | |||
| 104 | % HSR |
||
| 105 | HSRspikes= ANprobRateOutput(end- numHSRfibers+1:end, :); |
||
| 106 | PSTH=UTIL_PSTHmaker(HSRspikes, dt, localPSTHbinwidth); |
||
| 107 | PSTH=PSTH/(localPSTHbinwidth/dt); % sum across fibers (HSR only) |
||
| 108 | AN_HSRonset(levelNo)= max(PSTH); |
||
| 109 | AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end)); |
||
| 110 | |||
| 111 | figure(15), subplot(2,2,4) |
||
| 112 | 35:25d53244d5c8 | rmeddis | hold off, bar(PSTHtime,PSTH, 'k') |
| 113 | 29:b51bf546ca3f | rmeddis | hold on, bar(PSTHtime,PSTHLSR,'r') |
| 114 | ylim([0 1000]) |
||
| 115 | xlim([0 length(PSTH)*localPSTHbinwidth]) |
||
| 116 | set(gcf,'name',[num2str(BFlist), ' Hz: ' num2str(leveldB) ' dB']); |
||
| 117 | |||
| 118 | AR(levelNo)=min(ARattenuation); |
||
| 119 | MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end)); |
||
| 120 | |||
| 121 | |||
| 122 | figure(15), subplot(2,2,3) |
||
| 123 | 34:e097e9044ef6 | rmeddis | plot(20*log10(MOC), 'k'), hold on |
| 124 | plot(20*log10(AR), 'r'), hold off |
||
| 125 | title(' MOC/AR'), ylabel('dB attenuation')
|
||
| 126 | 29:b51bf546ca3f | rmeddis | ylim([-30 0]) |
| 127 | |||
| 128 | 34:e097e9044ef6 | rmeddis | end % level |
| 129 | 29:b51bf546ca3f | rmeddis | |
| 130 | figure(15), subplot(2,2,3) |
||
| 131 | 34:e097e9044ef6 | rmeddis | plot(levels,20*log10(MOC), 'k'), hold on |
| 132 | plot(levels,20*log10(AR), 'r'), hold off |
||
| 133 | title(' MOC/AR'), ylabel('dB attenuation')
|
||
| 134 | 29:b51bf546ca3f | rmeddis | ylim([-30 0]) |
| 135 | xlim([0 max(levels)]) |
||
| 136 | |||
| 137 | fprintf('\n')
|
||
| 138 | toneDuration=2; |
||
| 139 | rampDuration=0.004; |
||
| 140 | silenceDuration=.02; |
||
| 141 | nRepeats=200; % no. of AN fibers |
||
| 142 | fprintf('toneDuration %6.3f\n', toneDuration)
|
||
| 143 | fprintf(' %6.0f AN fibers (repeats)\n', nRepeats)
|
||
| 144 | fprintf('levels')
|
||
| 145 | fprintf('%6.2f\t', levels)
|
||
| 146 | fprintf('\n')
|
||
| 147 | |||
| 148 | |||
| 149 | % ---------------------------------------------------- display parameters |
||
| 150 | |||
| 151 | |||
| 152 | nRows=2; nCols=2; |
||
| 153 | |||
| 154 | % AN rate - level ONSET functions |
||
| 155 | subplot(nRows,nCols,1) |
||
| 156 | plot(levels,AN_LSRonset,'ro'), hold on |
||
| 157 | 38:c2204b18f4a2 | rmeddis | plot(levels,AN_HSRonset,'ko', 'MarkerEdgeColor','k', 'markerFaceColor','k'), hold off |
| 158 | 29:b51bf546ca3f | rmeddis | ylim([0 1000]), xlim([min(levels) max(levels)]) |
| 159 | ttl=['tauCa= ' num2str(IHCpreSynapseParams.tauCa)]; |
||
| 160 | title( ttl) |
||
| 161 | xlabel('level dB SPL'), ylabel('peak rate (sp/s)'), grid on
|
||
| 162 | 34:e097e9044ef6 | rmeddis | text(0, 800, 'AN onset', 'fontsize', 14) |
| 163 | 29:b51bf546ca3f | rmeddis | |
| 164 | % AN rate - level ADAPTED function |
||
| 165 | subplot(nRows,nCols,2) |
||
| 166 | plot(levels,AN_LSRsaturated, 'ro'), hold on |
||
| 167 | 38:c2204b18f4a2 | rmeddis | plot(levels,AN_HSRsaturated, 'ko', 'MarkerEdgeColor','k', 'markerFaceColor','k'), hold off |
| 168 | 35:25d53244d5c8 | rmeddis | maxYlim=340; |
| 169 | ylim([0 maxYlim]) |
||
| 170 | 29:b51bf546ca3f | rmeddis | set(gca,'ytick',0:50:300) |
| 171 | xlim([min(levels) max(levels)]) |
||
| 172 | set(gca,'xtick',[levels(1):20:levels(end)]) |
||
| 173 | % grid on |
||
| 174 | ttl=[ 'spont=' num2str(mean(AN_HSRsaturated(1,:)),'%4.0f')... |
||
| 175 | ' sat=' num2str(mean(AN_HSRsaturated(end,1)),'%4.0f')]; |
||
| 176 | title( ttl) |
||
| 177 | xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
|
||
| 178 | 35:25d53244d5c8 | rmeddis | text(0, maxYlim-50, 'AN adapted', 'fontsize', 14), grid on |
| 179 | 29:b51bf546ca3f | rmeddis | |
| 180 | allData=[ levels' AN_HSRonset AN_HSRsaturated... |
||
| 181 | AN_LSRonset AN_LSRsaturated ]; |
||
| 182 | fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n');
|
||
| 183 | UTIL_printTabTable(round(allData)) |
||
| 184 | |||
| 185 | |||
| 186 | UTIL_showStruct(IHC_cilia_RPParams, 'IHC_cilia_RPParams') |
||
| 187 | UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams') |
||
| 188 | UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams') |
||
| 189 | |||
| 190 | |||
| 191 | allData=[ levels' AN_HSRonset AN_HSRsaturated... |
||
| 192 | AN_LSRonset AN_LSRsaturated ]; |
||
| 193 | fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n');
|
||
| 194 | UTIL_printTabTable(round(allData)) |