Revision 38:c2204b18f4a2 userPrograms
| userPrograms/Pavel_MAP1_14.m | ||
|---|---|---|
| 1 |
function Pavel_MAP1_14 |
|
| 2 |
% test_MAP1_14 is a general purpose test routine that can be adjusted to |
|
| 3 |
% test a number of different applications of MAP1_14 |
|
| 4 |
% |
|
| 5 |
% A range of options are supplied in the early part of the program |
|
| 6 |
% |
|
| 7 |
% One use of the function is to create demonstrations; filenames <demoxx> |
|
| 8 |
% to illustrate particular features |
|
| 9 |
% |
|
| 10 |
% #1 |
|
| 11 |
% Identify the file (in 'MAPparamsName') containing the model parameters |
|
| 12 |
% |
|
| 13 |
% #2 |
|
| 14 |
% Identify the kind of model required (in 'AN_spikesOrProbability'). |
|
| 15 |
% A full brainstem model (spikes) can be computed or a shorter model |
|
| 16 |
% (probability) that computes only so far as the auditory nerve |
|
| 17 |
% |
|
| 18 |
% #3 |
|
| 19 |
% Choose between a tone signal or file input (in 'signalType') |
|
| 20 |
% |
|
| 21 |
% #4 |
|
| 22 |
% Set the signal rms level (in leveldBSPL) |
|
| 23 |
% |
|
| 24 |
% #5 |
|
| 25 |
% Identify the channels in terms of their best frequencies in the vector |
|
| 26 |
% BFlist. |
|
| 27 |
% |
|
| 28 |
% Last minute changes to the parameters fetched earlier can be made using |
|
| 29 |
% the cell array of strings 'paramChanges'. |
|
| 30 |
% Each string must have the same format as the corresponding line in the |
|
| 31 |
% file identified in 'MAPparamsName' |
|
| 32 |
% |
|
| 33 |
% When the demonstration is satisfactory, freeze it by renaming it <demoxx> |
|
| 34 |
|
|
| 35 |
restorePath=path; |
|
| 36 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 37 |
['..' filesep 'utilities']) |
|
| 38 |
|
|
| 39 |
%% #1 parameter file name |
|
| 40 |
MAPparamsName='Normal'; |
|
| 41 |
|
|
| 42 |
|
|
| 43 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 44 |
AN_spikesOrProbability='spikes'; |
|
| 45 |
|
|
| 46 |
% or |
|
| 47 |
% AN_spikesOrProbability='probability'; |
|
| 48 |
% NB probabilities are not corrected for refractory effects |
|
| 49 |
|
|
| 50 |
|
|
| 51 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 52 |
signalType= 'tones'; |
|
| 53 |
sampleRate= 100000; |
|
| 54 |
duration=0.1; % seconds |
|
| 55 |
% toneFrequency= 250:250:8000; % harmonic sequence (Hz) |
|
| 56 |
toneFrequency= 1000; % or a pure tone (Hz8 |
|
| 57 |
rampDuration=.005; % seconds |
|
| 58 |
|
|
| 59 |
% or |
|
| 60 |
% signalType= 'file'; |
|
| 61 |
% fileName='twister_44kHz'; |
|
| 62 |
|
|
| 63 |
|
|
| 64 |
%% #4 rms level |
|
| 65 |
% signal details |
|
| 66 |
leveldBSPL= 30; % dB SPL |
|
| 67 |
|
|
| 68 |
|
|
| 69 |
%% #5 number of channels in the model |
|
| 70 |
% 21-channel model (log spacing) |
|
| 71 |
% numChannels=21; |
|
| 72 |
% lowestBF=250; highestBF= 8000; |
|
| 73 |
% BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 74 |
|
|
| 75 |
% or specify your own channel BFs |
|
| 76 |
numChannels=1; |
|
| 77 |
BFlist=toneFrequency; |
|
| 78 |
|
|
| 79 |
|
|
| 80 |
%% #6 change model parameters |
|
| 81 |
paramChanges=[]; |
|
| 82 |
|
|
| 83 |
% or |
|
| 84 |
% Parameter changes can be used to change one or more model parameters |
|
| 85 |
% *after* the MAPparams file has been read |
|
| 86 |
% This example declares only one fiber type with a calcium clearance time |
|
| 87 |
% constant of 80e-6 s (HSR fiber) when the probability option is selected. |
|
| 88 |
% It also removes the speed up that normally takes place for AN spikes |
|
| 89 |
% It also increases the number of AN fibers computed to 500. |
|
| 90 |
paramChanges={...
|
|
| 91 |
'AN_IHCsynapseParams.ANspeedUpFactor=1;', ... |
|
| 92 |
'IHCpreSynapseParams.tauCa=86e-6;',... |
|
| 93 |
'AN_IHCsynapseParams.numFibers= 500;' }; |
|
| 94 |
|
|
| 95 |
|
|
| 96 |
%% delare 'showMap' options to control graphical output |
|
| 97 |
global showMapOptions |
|
| 98 |
|
|
| 99 |
% or (example: show everything including an smoothed SACF output |
|
| 100 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 101 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 102 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 103 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 104 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 105 |
showMapOptions.surfProbability=0; % 2D plot of HSR response |
|
| 106 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 107 |
% avoid nonsensical options |
|
| 108 |
showMapOptions.surfProbability=0; |
|
| 109 |
showMapOptions.showACF=0; |
|
| 110 |
end |
|
| 111 |
if strcmp(signalType, 'file') |
|
| 112 |
% needed for labeling plot |
|
| 113 |
showMapOptions.fileName=fileName; |
|
| 114 |
else |
|
| 115 |
showMapOptions.fileName=[]; |
|
| 116 |
end |
|
| 117 |
|
|
| 118 |
%% Generate stimuli |
|
| 119 |
|
|
| 120 |
dbstop if error |
|
| 121 |
restorePath=path; |
|
| 122 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore']) |
|
| 123 |
switch signalType |
|
| 124 |
case 'tones' |
|
| 125 |
inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
|
| 126 |
leveldBSPL, duration, rampDuration); |
|
| 127 |
|
|
| 128 |
case 'file' |
|
| 129 |
%% file input simple or mixed |
|
| 130 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 131 |
dt=1/sampleRate; |
|
| 132 |
inputSignal=inputSignal(:,1); |
|
| 133 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 134 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 135 |
amp=targetRMS/rms; |
|
| 136 |
inputSignal=inputSignal*amp; |
|
| 137 |
silence= zeros(1,round(0.1/dt)); |
|
| 138 |
inputSignal= [silence inputSignal' silence]; |
|
| 139 |
end |
|
| 140 |
|
|
| 141 |
|
|
| 142 |
%% run the model |
|
| 143 |
tic |
|
| 144 |
|
|
| 145 |
fprintf('\n')
|
|
| 146 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 147 |
disp([num2str(numChannels) ' channel model']) |
|
| 148 |
disp('Computing ...')
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 152 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 153 |
toc |
|
| 154 |
|
|
| 155 |
% the model run is now complete. Now display the results |
|
| 156 |
% the model run is now complete. Now display the results |
|
| 157 |
disp(' param changes to list of parameters below')
|
|
| 158 |
for i=1:length(paramChanges) |
|
| 159 |
disp(paramChanges{i})
|
|
| 160 |
end |
|
| 161 |
UTIL_showMAP(showMapOptions) |
|
| 162 |
|
|
| 163 |
toc |
|
| 164 |
path(restorePath) |
|
| 165 |
|
|
| 166 |
|
|
| 167 |
function inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
|
| 168 |
leveldBSPL, duration, rampDuration) |
|
| 169 |
% Create pure tone stimulus |
|
| 170 |
dt=1/sampleRate; % seconds |
|
| 171 |
time=dt: dt: duration; |
|
| 172 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 173 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 174 |
inputSignal=amp*inputSignal; |
|
| 175 |
|
|
| 176 |
% apply ramps |
|
| 177 |
% catch rampTime error |
|
| 178 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 179 |
rampTime=dt:dt:rampDuration; |
|
| 180 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 181 |
ones(1,length(time)-length(rampTime))]; |
|
| 182 |
inputSignal=inputSignal.*ramp; |
|
| 183 |
ramp=fliplr(ramp); |
|
| 184 |
inputSignal=inputSignal.*ramp; |
|
| 185 |
|
|
| 186 |
% add 10 ms silence |
|
| 187 |
silence= zeros(1,round(0.03/dt)); |
|
| 188 |
inputSignal= [silence inputSignal silence]; |
|
| 189 |
|
|
| userPrograms/pitchModel_RM.m | ||
|---|---|---|
| 1 |
function pitchModel_RM |
|
| 2 |
% Modification of testMAP_14 to replicate the pitch model published |
|
| 3 |
% in JASA 2006. |
|
| 4 |
% |
|
| 5 |
% test_MAP1_14 is a general purpose test routine that can be adjusted to |
|
| 6 |
% test a number of different applications of MAP1_14 |
|
| 7 |
% |
|
| 8 |
% A range of options are supplied in the early part of the program |
|
| 9 |
% |
|
| 10 |
% One use of the function is to create demonstrations; filenames <demoxx> |
|
| 11 |
% to illustrate particular features |
|
| 12 |
% |
|
| 13 |
% #1 |
|
| 14 |
% Identify the file (in 'MAPparamsName') containing the model parameters |
|
| 15 |
% |
|
| 16 |
% #2 |
|
| 17 |
% Identify the kind of model required (in 'AN_spikesOrProbability'). |
|
| 18 |
% A full brainstem model (spikes) can be computed or a shorter model |
|
| 19 |
% (probability) that computes only so far as the auditory nerve |
|
| 20 |
% |
|
| 21 |
% #3 |
|
| 22 |
% Choose between a tone signal or file input (in 'signalType') |
|
| 23 |
% |
|
| 24 |
% #4 |
|
| 25 |
% Set the signal rms level (in leveldBSPL) |
|
| 26 |
% |
|
| 27 |
% #5 |
|
| 28 |
% Identify the channels in terms of their best frequencies in the vector |
|
| 29 |
% BFlist. |
|
| 30 |
% |
|
| 31 |
% Last minute changes to the parameters fetched earlier can be made using |
|
| 32 |
% the cell array of strings 'paramChanges'. |
|
| 33 |
% Each string must have the same format as the corresponding line in the |
|
| 34 |
% file identified in 'MAPparamsName' |
|
| 35 |
% |
|
| 36 |
% When the demonstration is satisfactory, freeze it by renaming it <demoxx> |
|
| 37 |
|
|
| 38 |
dbstop if error |
|
| 39 |
restorePath=path; |
|
| 40 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 41 |
['..' filesep 'utilities']) |
|
| 42 |
|
|
| 43 |
% Pitch model modification here |
|
| 44 |
global ICrate % used to collect rate profile from showMAP temporary |
|
| 45 |
rates=[]; F0count=0; |
|
| 46 |
|
|
| 47 |
% F0s=[150 200 250]; % fundamental frequency |
|
| 48 |
% harmonics= 3:5; |
|
| 49 |
|
|
| 50 |
% F0s=[3000]; % fundamental frequency |
|
| 51 |
F0s=50:5:1000; |
|
| 52 |
harmonics= 1; |
|
| 53 |
% F0s=150; |
|
| 54 |
for F0=F0s |
|
| 55 |
F0count=F0count+1; |
|
| 56 |
|
|
| 57 |
|
|
| 58 |
%% #1 parameter file name |
|
| 59 |
MAPparamsName='Normal'; |
|
| 60 |
|
|
| 61 |
|
|
| 62 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 63 |
AN_spikesOrProbability='spikes'; |
|
| 64 |
|
|
| 65 |
% or |
|
| 66 |
% NB probabilities are not corrected for refractory effects |
|
| 67 |
% AN_spikesOrProbability='probability'; |
|
| 68 |
|
|
| 69 |
|
|
| 70 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 71 |
signalType= 'tones'; |
|
| 72 |
sampleRate= 50000; |
|
| 73 |
duration=0.50; % seconds |
|
| 74 |
% toneFrequency= 1000; % or a pure tone (Hz8 |
|
| 75 |
|
|
| 76 |
% F0=210; |
|
| 77 |
toneFrequency= F0*harmonics; % harmonic sequence (Hz) |
|
| 78 |
|
|
| 79 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 80 |
|
|
| 81 |
% or |
|
| 82 |
|
|
| 83 |
% signalType= 'file'; |
|
| 84 |
% fileName='twister_44kHz'; |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
%% #4 rms level |
|
| 88 |
% signal details |
|
| 89 |
leveldBSPL= 50; % dB SPL |
|
| 90 |
|
|
| 91 |
|
|
| 92 |
%% #5 number of channels in the model |
|
| 93 |
% 21-channel model (log spacing) |
|
| 94 |
numChannels=21; |
|
| 95 |
lowestBF=250; highestBF= 8000; |
|
| 96 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 97 |
|
|
| 98 |
% or specify your own channel BFs |
|
| 99 |
% numChannels=1; |
|
| 100 |
BFlist=toneFrequency; |
|
| 101 |
% BFlist=500; |
|
| 102 |
|
|
| 103 |
|
|
| 104 |
%% #6 change model parameters |
|
| 105 |
paramChanges=[]; |
|
| 106 |
|
|
| 107 |
% or |
|
| 108 |
% Parameter changes can be used to change one or more model parameters |
|
| 109 |
% *after* the MAPparams file has been read |
|
| 110 |
% This example declares only one fiber type with a calcium clearance time |
|
| 111 |
% constant of 80e-6 s (HSR fiber) when the probability option is selected. |
|
| 112 |
|
|
| 113 |
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
|
|
| 114 |
% 'IHCpreSynapseParams.tauCa=86e-6;'}; |
|
| 115 |
|
|
| 116 |
% paramChanges={'DRNLParams.rateToAttenuationFactorProb = 0;'};
|
|
| 117 |
|
|
| 118 |
% paramChanges={'IHCpreSynapseParams.tauCa=86e-6;',
|
|
| 119 |
% 'AN_IHCsynapseParams.numFibers= 1000;'}; |
|
| 120 |
|
|
| 121 |
% fixed MOC attenuation(using negative factor) |
|
| 122 |
% paramChanges={'DRNLParams.rateToAttenuationFactorProb=-0.005;'};
|
|
| 123 |
|
|
| 124 |
% slow the CN chopping rate |
|
| 125 |
% paramChanges={'IHCpreSynapseParams.tauCa= 70e-6;'...'
|
|
| 126 |
% 'MacGregorMultiParams.tauGk= [0.75e-3:.0001 : 3e-3];'... |
|
| 127 |
% ' MacGregorParams.dendriteLPfreq=4000;'... |
|
| 128 |
% 'MacGregorParams.tauGk= 1e-4;'... |
|
| 129 |
% 'MacGregorParams.currentPerSpike=220e-8;'... |
|
| 130 |
% }; |
|
| 131 |
paramChanges={...
|
|
| 132 |
'MacGregorMultiParams.currentPerSpike=25e-9;'... |
|
| 133 |
'MacGregorMultiParams.tauGk= [0.1e-3:.00005 : 1e-3];'... |
|
| 134 |
'MacGregorParams.currentPerSpike=40e-9;'... |
|
| 135 |
}; |
|
| 136 |
|
|
| 137 |
%% delare 'showMap' options to control graphical output |
|
| 138 |
|
|
| 139 |
showMapOptions.printModelParameters=0; % prints all parameters |
|
| 140 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 141 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 142 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 143 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 144 |
showMapOptions.surfProbability=0; % 2D plot of HSR response |
|
| 145 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 146 |
showMapOptions.ICrates=1; % IC rates by CNtauGk |
|
| 147 |
|
|
| 148 |
% disable certain silly options |
|
| 149 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 150 |
% avoid nonsensical options |
|
| 151 |
showMapOptions.surfProbability=0; |
|
| 152 |
showMapOptions.showACF=0; |
|
| 153 |
else |
|
| 154 |
showMapOptions.surfSpikes=0; |
|
| 155 |
end |
|
| 156 |
if strcmp(signalType, 'file') |
|
| 157 |
% needed for labeling plot |
|
| 158 |
showMapOptions.fileName=fileName; |
|
| 159 |
else |
|
| 160 |
showMapOptions.fileName=[]; |
|
| 161 |
end |
|
| 162 |
|
|
| 163 |
%% Generate stimuli |
|
| 164 |
|
|
| 165 |
switch signalType |
|
| 166 |
case 'tones' |
|
| 167 |
inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
|
| 168 |
leveldBSPL, duration, rampDuration); |
|
| 169 |
|
|
| 170 |
case 'file' |
|
| 171 |
%% file input simple or mixed |
|
| 172 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 173 |
dt=1/sampleRate; |
|
| 174 |
inputSignal=inputSignal(:,1); |
|
| 175 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 176 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 177 |
amp=targetRMS/rms; |
|
| 178 |
inputSignal=inputSignal*amp; |
|
| 179 |
silence= zeros(1,round(0.1/dt)); |
|
| 180 |
inputSignal= [silence inputSignal' silence]; |
|
| 181 |
end |
|
| 182 |
|
|
| 183 |
|
|
| 184 |
%% run the model |
|
| 185 |
tic |
|
| 186 |
|
|
| 187 |
fprintf('\n')
|
|
| 188 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 189 |
disp([num2str(numChannels) ' channel model']) |
|
| 190 |
disp([num2str(F0) ' F0']) |
|
| 191 |
disp('Computing ...')
|
|
| 192 |
|
|
| 193 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 194 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 195 |
|
|
| 196 |
|
|
| 197 |
% the model run is now complete. Now display the results |
|
| 198 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 199 |
|
|
| 200 |
%% pitch model Collect and analyse data |
|
| 201 |
% ICrate is global and computed in showMAP |
|
| 202 |
% a vector of 'stage4' rates; one value for each tauCNGk |
|
| 203 |
rates=[rates; ICrate]; |
|
| 204 |
figure(92), imagesc(rates) |
|
| 205 |
ylabel ('F0 no'), xlabel('tauGk')
|
|
| 206 |
% figure(92), plot(rates), ylim([0 inf]) |
|
| 207 |
|
|
| 208 |
h=figure(99); CNmovie(F0count)=getframe(h); |
|
| 209 |
figure(91), plot(rates'),ylim([0 inf]) |
|
| 210 |
pause (0.1) |
|
| 211 |
path(restorePath) |
|
| 212 |
|
|
| 213 |
end |
|
| 214 |
%% show results |
|
| 215 |
toc |
|
| 216 |
figure(91), plot(F0s,rates'), xlabel('F0'), ylabel('rate'),ylim([0 inf])
|
|
| 217 |
% figure(99),clf,movie(CNmovie,1,4) |
|
| 218 |
|
|
| 219 |
|
|
| 220 |
function inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
|
| 221 |
leveldBSPL, duration, rampDuration) |
|
| 222 |
% Create pure tone stimulus |
|
| 223 |
dt=1/sampleRate; % seconds |
|
| 224 |
time=dt: dt: duration; |
|
| 225 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 226 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 227 |
inputSignal=amp*inputSignal; |
|
| 228 |
|
|
| 229 |
% apply ramps |
|
| 230 |
% catch rampTime error |
|
| 231 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 232 |
rampTime=dt:dt:rampDuration; |
|
| 233 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 234 |
ones(1,length(time)-length(rampTime))]; |
|
| 235 |
inputSignal=inputSignal.*ramp; |
|
| 236 |
ramp=fliplr(ramp); |
|
| 237 |
inputSignal=inputSignal.*ramp; |
|
| 238 |
|
|
| 239 |
% add 10 ms silence |
|
| 240 |
silence= zeros(1,round(0.005/dt)); |
|
| 241 |
inputSignal= [silence inputSignal silence]; |
|
| 242 |
|
|
| userPrograms/runMAP1_14.m | ||
|---|---|---|
| 1 |
function runMAP1_14 |
|
| 2 |
% runMAP1_14 is a general purpose test routine that can be adjusted to |
|
| 3 |
% test a number of different applications of MAP1_14 |
|
| 4 |
% |
|
| 5 |
% A range of options are supplied in the early part of the program |
|
| 6 |
% |
|
| 7 |
% #1 |
|
| 8 |
% Identify the file (in 'MAPparamsName') containing the model parameters |
|
| 9 |
% |
|
| 10 |
% #2 |
|
| 11 |
% Identify the kind of model required (in 'AN_spikesOrProbability'). |
|
| 12 |
% A full brainstem model ('spikes') can be computed or a shorter model
|
|
| 13 |
% ('probability') that computes only so far as the auditory nerve
|
|
| 14 |
% |
|
| 15 |
% #3 |
|
| 16 |
% Choose between a tone signal or file input (in 'signalType') |
|
| 17 |
% |
|
| 18 |
% #4 |
|
| 19 |
% Set the signal rms level (in leveldBSPL) |
|
| 20 |
% |
|
| 21 |
% #5 |
|
| 22 |
% Identify the channels in terms of their best frequencies in the vector |
|
| 23 |
% BFlist. |
|
| 24 |
% |
|
| 25 |
% Last minute changes to the parameters can be made using |
|
| 26 |
% the cell array of strings 'paramChanges'. |
|
| 27 |
% Each string must have the same format as the corresponding line in the |
|
| 28 |
% file identified in 'MAPparamsName' |
|
| 29 |
|
|
| 30 |
dbstop if error |
|
| 31 |
restorePath=path; |
|
| 32 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 33 |
['..' filesep 'utilities']) |
|
| 34 |
|
|
| 35 |
%% #1 parameter file name |
|
| 36 |
MAPparamsName='Normal'; |
|
| 37 |
|
|
| 38 |
|
|
| 39 |
%% #2 probability (fast) or spikes (slow) representation: select one |
|
| 40 |
% AN_spikesOrProbability='spikes'; |
|
| 41 |
% or |
|
| 42 |
AN_spikesOrProbability='probability'; |
|
| 43 |
|
|
| 44 |
|
|
| 45 |
%% #3 A. pure tone, B. harmonic sequence or C. speech file input |
|
| 46 |
% comment out unwanted code |
|
| 47 |
|
|
| 48 |
% A. tone |
|
| 49 |
sampleRate= 441000; |
|
| 50 |
signalType= 'tones'; |
|
| 51 |
toneFrequency= 5000; % or a pure tone (Hz) |
|
| 52 |
duration=0.500; % seconds |
|
| 53 |
beginSilence=0.050; |
|
| 54 |
endSilence=0.050; |
|
| 55 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 56 |
|
|
| 57 |
% or |
|
| 58 |
% B. harmonic tone (Hz) - useful to demonstrate a broadband sound |
|
| 59 |
% sampleRate= 44100; |
|
| 60 |
% signalType= 'tones'; |
|
| 61 |
% toneFrequency= F0:F0:8000; |
|
| 62 |
% duration=0.500; % seconds |
|
| 63 |
% beginSilence=0.250; |
|
| 64 |
% endSilence=0.250; |
|
| 65 |
% F0=210; |
|
| 66 |
% rampDuration=.005; % raised cosine ramp (seconds) |
|
| 67 |
|
|
| 68 |
% or |
|
| 69 |
% C. signalType= 'file'; |
|
| 70 |
% fileName='twister_44kHz'; |
|
| 71 |
|
|
| 72 |
%% #4 rms level |
|
| 73 |
% signal details |
|
| 74 |
leveldBSPL= 70; % dB SPL (80 for Lieberman) |
|
| 75 |
|
|
| 76 |
%% #5 number of channels in the model |
|
| 77 |
% 21-channel model (log spacing) |
|
| 78 |
numChannels=21; |
|
| 79 |
lowestBF=250; highestBF= 6000; |
|
| 80 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 81 |
|
|
| 82 |
% or specify your own channel BFs |
|
| 83 |
% numChannels=1; |
|
| 84 |
% BFlist=toneFrequency; |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
%% #6 change model parameters |
|
| 88 |
|
|
| 89 |
paramChanges={};
|
|
| 90 |
|
|
| 91 |
% Parameter changes can be used to change one or more model parameters |
|
| 92 |
% *after* the MAPparams file has been read |
|
| 93 |
% This example declares only one fiber type with a calcium clearance time |
|
| 94 |
% constant of 80e-6 s (HSR fiber) when the probability option is selected. |
|
| 95 |
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
|
|
| 96 |
% 'IHCpreSynapseParams.tauCa=86e-6; '}; |
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
%% delare 'showMap' options to control graphical output |
|
| 101 |
% see UTIL_showMAP for more options |
|
| 102 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 103 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 104 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 105 |
showMapOptions.showEfferent=1; % tracks of AR and MOC |
|
| 106 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 107 |
|
|
| 108 |
if strcmp(signalType, 'file') |
|
| 109 |
% needed for labeling plot |
|
| 110 |
showMapOptions.fileName=fileName; |
|
| 111 |
else |
|
| 112 |
showMapOptions.fileName=[]; |
|
| 113 |
end |
|
| 114 |
|
|
| 115 |
%% Generate stimuli |
|
| 116 |
switch signalType |
|
| 117 |
case 'tones' |
|
| 118 |
% Create pure tone stimulus |
|
| 119 |
dt=1/sampleRate; % seconds |
|
| 120 |
time=dt: dt: duration; |
|
| 121 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 122 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 123 |
inputSignal=amp*inputSignal; |
|
| 124 |
% apply ramps |
|
| 125 |
% catch rampTime error |
|
| 126 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 127 |
rampTime=dt:dt:rampDuration; |
|
| 128 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 129 |
ones(1,length(time)-length(rampTime))]; |
|
| 130 |
inputSignal=inputSignal.*ramp; |
|
| 131 |
ramp=fliplr(ramp); |
|
| 132 |
inputSignal=inputSignal.*ramp; |
|
| 133 |
% add silence |
|
| 134 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 135 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 136 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 137 |
|
|
| 138 |
case 'file' |
|
| 139 |
%% file input simple or mixed |
|
| 140 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 141 |
dt=1/sampleRate; |
|
| 142 |
inputSignal=inputSignal(:,1); |
|
| 143 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 144 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 145 |
amp=targetRMS/rms; |
|
| 146 |
inputSignal=inputSignal*amp; |
|
| 147 |
intialSilence= zeros(1,round(0.1/dt)); |
|
| 148 |
finalSilence= zeros(1,round(0.2/dt)); |
|
| 149 |
inputSignal= [intialSilence inputSignal' finalSilence]; |
|
| 150 |
end |
|
| 151 |
|
|
| 152 |
|
|
| 153 |
%% run the model |
|
| 154 |
tic |
|
| 155 |
fprintf('\n')
|
|
| 156 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 157 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 158 |
disp('Computing ...')
|
|
| 159 |
|
|
| 160 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 161 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 162 |
|
|
| 163 |
|
|
| 164 |
%% the model run is now complete. Now display the results |
|
| 165 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 166 |
|
|
| 167 |
if strcmp(signalType,'tones') |
|
| 168 |
disp(['duration=' num2str(duration)]) |
|
| 169 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 170 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 171 |
global DRNLParams |
|
| 172 |
disp(['attenuation factor =' ... |
|
| 173 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 174 |
disp(['attenuation factor (probability)=' ... |
|
| 175 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 176 |
disp(AN_spikesOrProbability) |
|
| 177 |
end |
|
| 178 |
disp(paramChanges) |
|
| 179 |
toc |
|
| 180 |
path(restorePath) |
|
| 181 |
|
|
Also available in: Unified diff