comparison Copy_of_multithreshold 1.46/testBM.m @ 28:02aa9826efe0

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