Mercurial > hg > map
comparison userProgramsRM/test_speechInNoise.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_speechInNoise | |
2 | |
3 leveldBSPL= 60; % dB SPL | |
4 leveldBSPLNoise=-55; | |
5 | |
6 % leveldBSPL= 90; % test AR | |
7 % leveldBSPLNoise=85; | |
8 OMEatten=0.1; | |
9 OMEatten=0.00; | |
10 | |
11 MOCattenuation=0.00; % no attenuation | |
12 % MOCattenuation=-0.02; % fixed | |
13 % MOCattenuation=0.02; % dynamic within-channel | |
14 MOCtauProb=0.150; | |
15 | |
16 paramChanges={}; | |
17 | |
18 % no attenuation | |
19 paramChanges={['DRNLParams.rateToAttenuationFactorProb = '... | |
20 num2str(MOCattenuation) ';'],... | |
21 ['DRNLParams.MOCtauProb =' num2str(MOCtauProb) ';'],... | |
22 ['OMEParams.rateToAttenuationFactorProb=' num2str(OMEatten) ';'] }; | |
23 | |
24 % | |
25 fileName='twister_44kHz'; | |
26 % fileName='1o7a_44kHz'; | |
27 | |
28 dbstop if error | |
29 restorePath=path; | |
30 addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... | |
31 ['..' filesep 'utilities']) | |
32 | |
33 %% #1 parameter file name | |
34 MAPparamsName='Normal'; | |
35 | |
36 | |
37 %% #2 probability (fast) or spikes (slow) representation | |
38 AN_spikesOrProbability='spikes'; | |
39 % or | |
40 AN_spikesOrProbability='probability'; | |
41 | |
42 | |
43 %% #3 speech file input | |
44 | |
45 beginSilence=.25; | |
46 endSilence=0.25; | |
47 noiseRampDuration=0.01; | |
48 | |
49 %% #5 number of channels in the model | |
50 % 21-channel model (log spacing) | |
51 numChannels=21; | |
52 lowestBF=300; highestBF= 6000; | |
53 BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); | |
54 | |
55 % or specify your own channel BFs | |
56 % numChannels=1; | |
57 % BFlist=toneFrequency; | |
58 | |
59 | |
60 | |
61 %% delare 'showMap' options to control graphical output | |
62 showMapOptions.printModelParameters=1; % prints all parameters | |
63 showMapOptions.showModelOutput=1; % plot of all stages | |
64 showMapOptions.printFiringRates=1; % prints stage activity levels | |
65 showMapOptions.showACF=0; % shows SACF (probability only) | |
66 showMapOptions.showEfferent=0; % tracks of AR and MOC | |
67 showMapOptions.surfProbability=1; % 2D plot of HSR response | |
68 showMapOptions.surfSpikes=0; % 2D plot of spikes histogram | |
69 showMapOptions.ICrates=0; % IC rates by CNtauGk | |
70 showMapOptions.PSTHbinwidth=0.010; | |
71 showMapOptions.colorbar=0; | |
72 showMapOptions.view=[0 90]; | |
73 | |
74 % disable certain silly options | |
75 if strcmp(AN_spikesOrProbability, 'spikes') | |
76 % avoid nonsensical options | |
77 showMapOptions.surfProbability=0; | |
78 showMapOptions.showACF=0; | |
79 else | |
80 showMapOptions.surfSpikes=0; | |
81 end | |
82 % needed for labeling plot | |
83 showMapOptions.fileName=fileName; | |
84 | |
85 %% Generate stimuli | |
86 | |
87 %% file input simple or mixed | |
88 [inputSignal sampleRate]=wavread(fileName); | |
89 dt=1/sampleRate; | |
90 inputSignal=inputSignal(:,1); | |
91 targetRMS=20e-6*10^(leveldBSPL/20); | |
92 rms=(mean(inputSignal.^2))^0.5; | |
93 amp=targetRMS/rms; | |
94 inputSignal=inputSignal*amp; | |
95 | |
96 % add silences | |
97 intialSilence= zeros(1,round(beginSilence*sampleRate)); | |
98 finalSilence= zeros(1,round(endSilence*sampleRate)); | |
99 inputSignal= [intialSilence inputSignal' finalSilence]; | |
100 | |
101 [inputNoise sampleRateN]=wavread('babble'); | |
102 inputNoise=inputNoise(1:length(inputSignal)); | |
103 inputNoise=inputNoise(:,1); | |
104 targetRMS=20e-6*10^(leveldBSPLNoise/20); | |
105 rms=(mean(inputNoise.^2))^0.5; | |
106 amp=targetRMS/rms; | |
107 inputNoise=inputNoise*amp; | |
108 time=dt: dt: dt*length(inputNoise); | |
109 rampTime=dt:dt:noiseRampDuration; | |
110 ramp=[0.5*(1+cos(2*pi*rampTime/(2*noiseRampDuration)+pi)) ... | |
111 ones(1,length(time)-length(rampTime))]; | |
112 inputNoise=inputNoise'.*ramp; | |
113 inputSignal=inputSignal+inputNoise; | |
114 | |
115 | |
116 | |
117 %% run the model | |
118 tic | |
119 | |
120 fprintf('\n') | |
121 disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) | |
122 disp([num2str(numChannels) ' channel model']) | |
123 disp('Computing ...') | |
124 | |
125 MAP1_14(inputSignal, sampleRate, BFlist, ... | |
126 MAPparamsName, AN_spikesOrProbability, paramChanges); | |
127 | |
128 | |
129 %% the model run is now complete. Now display the results | |
130 UTIL_showMAP(showMapOptions, paramChanges) | |
131 figure(97), | |
132 title(['speech/ noise: ' num2str([leveldBSPL leveldBSPLNoise]) ... | |
133 '; atten/ tau: ' num2str([MOCattenuation MOCtauProb] )],'fontSize', 14) | |
134 | |
135 disp(['level=' num2str(leveldBSPL)]) | |
136 disp(['noise level=' num2str(leveldBSPLNoise)]) | |
137 | |
138 global DRNLParams | |
139 disp(['attenuation factor =' ... | |
140 num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) | |
141 disp(['attenuation factor (probability)=' ... | |
142 num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) | |
143 disp(AN_spikesOrProbability) | |
144 disp(paramChanges) | |
145 toc | |
146 path(restorePath) | |
147 |