Mercurial > hg > map
comparison testPrograms/testBM.m @ 29:b51bf546ca3f
physiologyProb
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Fri, 08 Jul 2011 13:48:27 +0100 |
parents | |
children | 161913b595ae |
comparison
equal
deleted
inserted
replaced
28:02aa9826efe0 | 29:b51bf546ca3f |
---|---|
1 function testBM (BMlocations, paramsName,... | |
2 relativeFrequencies, AN_spikesOrProbability, paramChanges) | |
3 % testBM generates input output functions for DRNL model for any number | |
4 % of locations. | |
5 % Computations are bast on a single channel model (channelBFs=BF) | |
6 % peak displacement (peakAmp) is measured. | |
7 % if DRNLParams.useMOC is chosen, the full model is run (slow) | |
8 % otherwise only DRNL is computed. | |
9 % Tuning curves are generated based on a range of frequencies reletove to | |
10 % the BF of the location. | |
11 % | |
12 | |
13 global DRNLParams | |
14 | |
15 if nargin<5 | |
16 paramChanges=[]; | |
17 end | |
18 | |
19 if nargin<4 | |
20 AN_spikesOrProbability='probability'; | |
21 end | |
22 | |
23 savePath=path; | |
24 addpath (['..' filesep 'utilities'],['..' filesep 'MAP']) | |
25 | |
26 levels=-10:10:90; nLevels=length(levels); | |
27 % levels= 50; nLevels=length(levels); | |
28 | |
29 % refBMdisplacement is the displacement of the BM at threshold | |
30 % 1 nm disp at threshold (9 kHz, Ruggero) | |
31 % ? adjust for frequency | |
32 refBMdisplacement= 1e-8; % adjusted for 10 nm at 1 kHz | |
33 | |
34 toneDuration=.200; | |
35 rampDuration=0.01; | |
36 silenceDuration=0.01; | |
37 | |
38 sampleRate=30000; | |
39 | |
40 dbstop if error | |
41 figure(3), clf | |
42 set(gcf,'position',[280 350 327 326]) | |
43 set(gcf,'name','DRNL - BM') | |
44 pause(0.1) | |
45 | |
46 finalSummary=[]; | |
47 nBFs=length(BMlocations); | |
48 BFno=0; plotCount=0; | |
49 for BF=BMlocations | |
50 BFno=BFno+1; | |
51 plotCount=plotCount+nBFs; | |
52 stimulusFrequencies=BF* relativeFrequencies; | |
53 nFrequencies=length(stimulusFrequencies); | |
54 | |
55 peakAmpBM=zeros(nLevels,nFrequencies); | |
56 peakAmpBMdB=NaN(nLevels,nFrequencies); | |
57 peakEfferent=NaN(nLevels,nFrequencies); | |
58 peakAREfferent=NaN(nLevels,nFrequencies); | |
59 | |
60 | |
61 levelNo=0; | |
62 for leveldB=levels | |
63 disp(['level= ' num2str(leveldB)]) | |
64 levelNo=levelNo+1; | |
65 | |
66 freqNo=0; | |
67 for frequency=stimulusFrequencies | |
68 freqNo=freqNo+1; | |
69 | |
70 % Generate stimuli | |
71 globalStimParams.FS=sampleRate; | |
72 globalStimParams.overallDuration=... | |
73 toneDuration+silenceDuration; % s | |
74 stim.phases='sin'; | |
75 stim.type='tone'; | |
76 stim.toneDuration=toneDuration; | |
77 stim.frequencies=frequency; | |
78 stim.amplitudesdB=leveldB; | |
79 stim.beginSilence=silenceDuration; | |
80 stim.rampOnDur=rampDuration; | |
81 % no offset ramp | |
82 stim.rampOffDur=rampDuration; | |
83 doPlot=0; | |
84 inputSignal=stimulusCreate(globalStimParams, stim, doPlot); | |
85 inputSignal=inputSignal(:,1)'; | |
86 | |
87 %% run the model | |
88 MAPparamsName=paramsName; | |
89 | |
90 global DRNLoutput MOCattenuation ARattenuation | |
91 MAP1_14(inputSignal, sampleRate, BF, ... | |
92 MAPparamsName, AN_spikesOrProbability, paramChanges); | |
93 | |
94 DRNLresponse=DRNLoutput; | |
95 peakAmp=max(max(... | |
96 DRNLresponse(:, end-round(length(DRNLresponse)/2):end))); | |
97 peakAmpBM(levelNo,freqNo)=peakAmp; | |
98 peakAmpBMdB(levelNo,freqNo)=... | |
99 20*log10(peakAmp/refBMdisplacement); | |
100 peakEfferent(levelNo,freqNo)=min(min(MOCattenuation)); | |
101 peakAREfferent(levelNo,freqNo)=min(min(ARattenuation)); | |
102 | |
103 end % tone frequency | |
104 end % level | |
105 | |
106 %% analyses results and plot | |
107 | |
108 % BM I/O plot (top panel) | |
109 figure(3) | |
110 subplot(3,nBFs,BFno), cla | |
111 plot(levels,peakAmpBMdB, 'linewidth',2) | |
112 hold on, plot(levels, repmat(refBMdisplacement,1,length(levels))) | |
113 hold off | |
114 title(['BF=' num2str(BF,'%5.0f') ' - ' paramsName]) | |
115 xlabel('level') | |
116 % set(gca,'xtick',levels), grid on | |
117 if length(levels)>1,xlim([min(levels) max(levels)]), end | |
118 ylabel(['dB re:' num2str(refBMdisplacement,'%6.1e') 'm']) | |
119 ylim([-20 50]) | |
120 set(gca,'ytick',[-10 0 10 20 40]) | |
121 grid on | |
122 % legend({num2str(stimulusFrequencies')}, 'location', 'EastOutside') | |
123 UTIL_printTabTable([levels' peakAmpBMdB], ... | |
124 num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f') | |
125 finalSummary=[finalSummary peakAmpBMdB]; | |
126 | |
127 % Tuning curve | |
128 if length(relativeFrequencies)>2 | |
129 figure(3), subplot(3,nBFs, 2*nBFs+BFno) | |
130 % contour(stimulusFrequencies,levels,peakAmpBM,... | |
131 % [refBMdisplacement refBMdisplacement],'r') | |
132 contour(stimulusFrequencies,levels,peakAmpBM,... | |
133 refBMdisplacement.*[1 5 10 50 100]) | |
134 title(['tuning curve at ' num2str(refBMdisplacement) 'm']); | |
135 ylabel('level (dB) at reference') | |
136 xlim([100 10000]) | |
137 grid on | |
138 hold on | |
139 set(gca,'xscale','log') | |
140 end | |
141 | |
142 | |
143 % MOC contribution | |
144 figure(3) | |
145 subplot(3,nBFs,nBFs+BFno), cla | |
146 plot(levels,20*log10(peakEfferent), 'linewidth',2) | |
147 ylabel('MOC (dB attenuation)'), xlabel('level') | |
148 title(['peak MOC: model= ' AN_spikesOrProbability]) | |
149 grid on | |
150 if length(levels)>1, xlim([min(levels) max(levels)]), end | |
151 | |
152 % AR contribution | |
153 hold on | |
154 plot(levels,20*log10(peakAREfferent), 'r') | |
155 hold off | |
156 | |
157 end % best frequency | |
158 | |
159 UTIL_showStructureSummary(DRNLParams, 'DRNLParams', 10) | |
160 | |
161 UTIL_printTabTable([levels' finalSummary], ... | |
162 num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f') | |
163 | |
164 path(savePath); |