comparison testPrograms/test_DRNL_Ruggero97.m @ 38:c2204b18f4a2 tip

End nov big change
author Ray Meddis <rmeddis@essex.ac.uk>
date Mon, 28 Nov 2011 13:34:28 +0000
parents
children
comparison
equal deleted inserted replaced
37:771a643d5c29 38:c2204b18f4a2
1 function test_DRNL_Ruggero97
2 % test_DRNL_Ruggero97 attempts to match Ruggero's (1992 and 1997)
3 % iso-intensity data by fiddling with the parameters
4
5 % # BF is the BF of the filter to be assessed
6 BF=9000;
7
8 % # test frequencies. check that BF is one of them
9 % copy Ruggero's test tones as fara as possible
10 numFs=6; lowestF=4000; highestF= 11030;
11 toneFrequencyList=round(logspace(log10(lowestF), log10(highestF), numFs));
12
13 % # parameter file name. this is the base set of parameters
14 MAPparamsName='Normal';
15
16 % # probability representation (not directly relevant here as only
17 % the DRNL output is used
18 AN_spikesOrProbability='probability';
19
20 % # tone characteristics
21 sampleRate= 100000;
22 duration=0.0200; % Ruggero uses 5, 10, 25 ms tones
23 rampDuration=0.0015; % raised cosine ramp (seconds)
24 beginSilence=0.050;
25 endSilence=0.020;
26
27 % # levels
28 levels=[3 10:10:80];
29
30 %% # change model parameters
31 % Parameter changes can be used to change one or more model parameters
32 % *after* the MAPparams file has been read
33
34 paramChanges={};
35
36 paramChanges={...
37 'DRNLParams.ctBMdB = -20;'...
38 'DRNLParams.g=1000;'...
39 };
40
41 % delare 'showMap' options to control graphical output
42 % (not needed but might be useful
43 % showMapOptions.printModelParameters=0; % prints all parameters
44 % showMapOptions.showModelOutput=1; % plot of all stages
45 % showMapOptions.printFiringRates=0; % prints stage activity levels
46 % showMapOptions.showACF=0; % shows SACF (probability only)
47 % showMapOptions.showEfferent=0; % tracks of AR and MOC
48 % showMapOptions.surfAN=0; % 2D plot of HSR response
49 % showMapOptions.surfSpikes=0; % 2D plot of spikes histogram
50 % showMapOptions.ICrates=0; % IC rates by CNtauGk
51 % showMapOptions.fileName=[];
52
53 % run the program
54 global dt DRNLoutput DRNLParams TMoutput
55 dbstop if error
56 restorePath=path;
57 addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ...
58 ['..' filesep 'utilities'])
59 figure(2), clf,figure(3), clf,figure(4), clf,
60
61 peakOutputDisp=zeros(length(levels),length(toneFrequencyList));
62 peakStapesDisp=zeros(length(levels),length(toneFrequencyList));
63
64 %% now vary level and frequency while measuring the response
65 levelNo=0;
66 for leveldBSPL=levels
67 levelNo=levelNo+1;
68 disp(['level: ' num2str(leveldBSPL)])
69
70 freqNo=0;
71 for toneFrequency=toneFrequencyList
72 freqNo=freqNo+1;
73
74 %% Generate stimuli
75 dt=1/sampleRate;
76 time=dt: dt: duration;
77 inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
78 amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak)
79 inputSignal=amp*inputSignal;
80 % apply ramps
81 if rampDuration>0.5*duration, rampDuration=duration/2; end
82 rampTime=dt:dt:rampDuration;
83 ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
84 ones(1,length(time)-length(rampTime))];
85 inputSignal=inputSignal.*ramp;
86 ramp=fliplr(ramp);
87 inputSignal=inputSignal.*ramp;
88 % add silence
89 intialSilence= zeros(1,round(beginSilence/dt));
90 finalSilence= zeros(1,round(endSilence/dt));
91 inputSignal= [intialSilence inputSignal finalSilence];
92
93 %% run the model
94
95 MAP1_14(inputSignal, sampleRate, BF, ...
96 MAPparamsName, AN_spikesOrProbability, paramChanges);
97
98 peakOutputDisp(levelNo,freqNo)=max(DRNLoutput);
99 peakStapesDisp(levelNo,freqNo)=max(TMoutput);
100
101 % the model run is complete. Now display the results if debugging
102 % UTIL_showMAP(showMapOptions)
103 end % probe frequencies
104
105 % monitor progress
106 figure(2), loglog(toneFrequencyList, peakOutputDisp), hold on
107 xlabel('frequency')
108 ylabel('peak DRNL displacement (m)')
109 title ('DRNL uncorrected displacement')
110 end % levels
111 figure(2),legend(num2str(toneFrequencyList'),'location','northwest')
112
113 % convert from model BM displacement to Ruggero's velocity
114 DRNLvelocity= peakOutputDisp ...
115 .*repmat(2*pi*toneFrequencyList,length(levels),1);
116 % convert from model stapes displacement to Ruggero's velocity
117 stapesVelocity= peakStapesDisp ...
118 .*repmat(2*pi*toneFrequencyList,length(levels),1);
119 % velocity gain is increased velocity attributable to the DRNL
120 DRNLvelocityGain = DRNLvelocity./stapesVelocity;
121 DRNLvelocityGain_dB= 20*log10(DRNLvelocityGain );
122 % iso-intensity equates all functions at the same outpu for the lowest
123 % velocity tested
124 isoIntensityDRNLvel_dB= DRNLvelocityGain_dB- ...
125 repmat(DRNLvelocityGain_dB(:,1),1,length(toneFrequencyList));
126
127 % displays
128 % iso-velocity function (nrmalised by stapes velocity)
129 figure(3), clf, semilogx(toneFrequencyList, isoIntensityDRNLvel_dB)
130 ylim([-10 50])
131 xlim([3000 20000])
132 xlabel('frequency (Hz)')
133 set(gca,'Xtick', [1000 ],'xticklabel',{'1000'})
134
135 ylabel('peak DRNL velocity gain (dB)')
136 title(['CF= ' num2str(BF) ' Hz'])
137 legend(num2str(levels'),'location','northwest')
138
139 % velocity I/O function
140 figure(4), clf, semilogy(levels, (DRNLvelocity*1e6)'), hold on
141 ylim([5e0 1.2e4])
142 xlim([0 80])
143 xlabel('level')
144 ylabel(' velocity (microm/ s)')
145 title(['CF= ' num2str(BF) ' Hz'])
146 legend(num2str(toneFrequencyList'),'location','northwest')
147
148 % command window reports
149 disp(''), disp('***')
150 disp(AN_spikesOrProbability)
151
152 % DRNL parameter set
153 UTIL_showStructureSummary(DRNLParams, 'DRNLParams', 10)
154
155 % stimulus characteristics
156 disp(['CF=' num2str(BF)])
157 disp(['tone Duration=' num2str(rampDuration)])
158 disp(['ramp Duration=' num2str(duration)])
159
160 % particular parameter changes used on this run
161 for i=1:length(paramChanges)
162 disp(paramChanges{i})
163 end
164
165 % if required dump one or more matrices in tab spaced format
166 % (suitable for pasting directly into EXCEL.
167 % UTIL_printTabTable([toneFrequencyList' peakOutputDisp'])
168
169 % leave the path as you found it
170 path(restorePath)
171
172