Mercurial > hg > map
comparison testPrograms/demoTwisterSpikes.m @ 9:ecad0ea62b43
May27 mainly better parameters
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Tue, 31 May 2011 09:13:07 +0100 |
parents | |
children | 6cce421531e2 |
comparison
equal
deleted
inserted
replaced
8:eafe11c86f44 | 9:ecad0ea62b43 |
---|---|
1 function demoTwisterSpikes | |
2 | |
3 % MAPdemo runs the MATLAB auditory periphery model (MAP1_14) as far as | |
4 % the AN (probabilities) or IC (spikes) with graphical output | |
5 | |
6 % Things you might want to change; #1 - #5 | |
7 | |
8 %% #1 parameter file name | |
9 MAPparamsName='Normal'; | |
10 | |
11 | |
12 %% #2 probability (fast) or spikes (slow) representation | |
13 AN_spikesOrProbability='spikes'; | |
14 % or | |
15 % AN_spikesOrProbability='probability'; | |
16 | |
17 | |
18 %% #3 pure tone, harmonic sequence or speech file input | |
19 signalType= 'tones'; | |
20 duration=0.100; % seconds | |
21 duration=0.020; % seconds | |
22 sampleRate= 64000; | |
23 % toneFrequency= 250:250:8000; % harmonic sequence (Hz) | |
24 toneFrequency= 2000; % or a pure tone (Hz8 | |
25 | |
26 rampDuration=.005; % seconds | |
27 | |
28 % or | |
29 signalType= 'file'; | |
30 fileName='twister_44kHz'; | |
31 % fileName='new-da-44khz'; | |
32 | |
33 | |
34 %% #4 rms level | |
35 % signal details | |
36 leveldBSPL=70; % dB SPL | |
37 | |
38 | |
39 %% #5 number of channels in the model | |
40 % 21-channel model (log spacing) | |
41 numChannels=21; | |
42 lowestBF=250; highestBF= 8000; | |
43 BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); | |
44 | |
45 % or specify your own channel BFs | |
46 % BFlist=toneFrequency; | |
47 | |
48 | |
49 %% #6 change model parameters | |
50 paramChanges=[]; | |
51 | |
52 % or | |
53 % Parameter changes can be used to change one or more model parameters | |
54 % *after* the MAPparams file has been read | |
55 % This example declares only one fiber type with a calcium clearance time | |
56 % constant of 80e-6 s (HSR fiber) when the probability option is selected. | |
57 % switch AN_spikesOrProbability | |
58 % case 'probability' | |
59 % paramChanges={'IHCpreSynapseParams.tauCa=80e-6;'}; | |
60 % otherwise | |
61 % paramChanges=[]; | |
62 % end | |
63 | |
64 %% delare showMap options | |
65 showMapOptions=[]; % use defaults | |
66 | |
67 % or (example: show everything including an smoothed SACF output | |
68 showMapOptions.showModelParameters=1; | |
69 showMapOptions.showModelOutput=1; | |
70 showMapOptions.printFiringRates=1; | |
71 showMapOptions.showACF=0; | |
72 showMapOptions.showEfferent=1; | |
73 | |
74 %% Generate stimuli | |
75 | |
76 dbstop if error | |
77 restorePath=path; | |
78 addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore']) | |
79 switch signalType | |
80 case 'tones' | |
81 inputSignal=createMultiTone(sampleRate, toneFrequency, ... | |
82 leveldBSPL, duration, rampDuration); | |
83 | |
84 case 'file' | |
85 [inputSignal sampleRate]=wavread(fileName); | |
86 inputSignal(:,1); | |
87 targetRMS=20e-6*10^(leveldBSPL/20); | |
88 rms=(mean(inputSignal.^2))^0.5; | |
89 amp=targetRMS/rms; | |
90 inputSignal=inputSignal*amp; | |
91 end | |
92 | |
93 | |
94 %% run the model | |
95 tic | |
96 | |
97 fprintf('\n') | |
98 disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) | |
99 disp([num2str(numChannels) ' channel model']) | |
100 disp('Computing ...') | |
101 MAP1_14(inputSignal, sampleRate, BFlist, ... | |
102 MAPparamsName, AN_spikesOrProbability, paramChanges); | |
103 toc | |
104 | |
105 % the model run is now complete. Now display the results | |
106 showMAP(showMapOptions) | |
107 | |
108 toc | |
109 path(restorePath) | |
110 | |
111 | |
112 function inputSignal=createMultiTone(sampleRate, toneFrequency, ... | |
113 leveldBSPL, duration, rampDuration) | |
114 % Create pure tone stimulus | |
115 dt=1/sampleRate; % seconds | |
116 time=dt: dt: duration; | |
117 inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); | |
118 amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) | |
119 inputSignal=amp*inputSignal; | |
120 | |
121 % apply ramps | |
122 % catch rampTime error | |
123 if rampDuration>0.5*duration, rampDuration=duration/2; end | |
124 rampTime=dt:dt:rampDuration; | |
125 ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... | |
126 ones(1,length(time)-length(rampTime))]; | |
127 inputSignal=inputSignal.*ramp; | |
128 ramp=fliplr(ramp); | |
129 inputSignal=inputSignal.*ramp; | |
130 | |
131 % add 10 ms silence | |
132 silence= zeros(1,round(0.03/dt)); | |
133 % inputSignal= [silence inputSignal silence]; | |
134 |