Revision 38:c2204b18f4a2 userProgramsRM
| userProgramsRM/MAPdemoMultiChOAE.m | ||
|---|---|---|
| 1 |
function [frequencies fft_ampdB]= ... |
|
| 2 |
MAPdemoMultiChOAE (leveldBSPL, toneFrequencies) |
|
| 3 |
% MAPdemo runs the MATLAB auditory periphery model |
|
| 4 |
% |
|
| 5 |
% The OAE is simulated by combining the output from all DRNL channels |
|
| 6 |
% |
|
| 7 |
% arguments leveldBSPL and toneFrequencies are optional |
|
| 8 |
% defaults are 70 and [5000 6000] |
|
| 9 |
% |
|
| 10 |
% e.g. |
|
| 11 |
% MAPdemoMultiChOAE (60, [3000 4000]) |
|
| 12 |
|
|
| 13 |
|
|
| 14 |
global dt DRNLoutput |
|
| 15 |
dbstop if error |
|
| 16 |
restorePath=path; |
|
| 17 |
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ... |
|
| 18 |
['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'],... |
|
| 19 |
['..' filesep 'testPrograms']) |
|
| 20 |
|
|
| 21 |
% set parameter file here |
|
| 22 |
paramsName='Normal'; |
|
| 23 |
% choose probability because spikes not used to evaluate BM |
|
| 24 |
AN_spikesOrProbability='probability'; |
|
| 25 |
% add parameter changes here. paramchanges is a cell array of command |
|
| 26 |
% strings |
|
| 27 |
paramChanges={};
|
|
| 28 |
|
|
| 29 |
% DRNL channels |
|
| 30 |
lowestBF=1000; highestBF= 8000; numChannels=41; |
|
| 31 |
% includes BFs at 250 500 1000 2000 4000 8000 (for 11, 21, 31 BFs) |
|
| 32 |
% the output from all these filters will be combined to form the OAE |
|
| 33 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 34 |
|
|
| 35 |
if nargin<2 |
|
| 36 |
toneFrequencies= 2000; % single pure tone test |
|
| 37 |
toneFrequencies=[ 2000 3000]; % F1 F2 for DPOAEs |
|
| 38 |
toneFrequencies=[ 5000 6000]; % F1 F2 |
|
| 39 |
end |
|
| 40 |
duration=0.05; % seconds |
|
| 41 |
duration=0.05; % seconds |
|
| 42 |
rampDuration=.005; |
|
| 43 |
|
|
| 44 |
if nargin<1 |
|
| 45 |
leveldBSPL=70; % dB SPL |
|
| 46 |
end |
|
| 47 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak level) |
|
| 48 |
|
|
| 49 |
% Create pure stimulus |
|
| 50 |
sampleRate= 100000; |
|
| 51 |
dt=1/sampleRate; |
|
| 52 |
time=dt: dt: duration; |
|
| 53 |
inputSignal=sum(sin(2*pi*toneFrequencies'*time), 1); |
|
| 54 |
inputSignal=amp*inputSignal; |
|
| 55 |
|
|
| 56 |
% apply ramps |
|
| 57 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 58 |
rampTime=dt:dt:rampDuration; |
|
| 59 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 60 |
ones(1,length(time)-length(rampTime))]; |
|
| 61 |
inputSignal=inputSignal.*ramp; % at the beginning |
|
| 62 |
ramp=fliplr(ramp); |
|
| 63 |
inputSignal=inputSignal.*ramp; % and at the end |
|
| 64 |
|
|
| 65 |
% add 10 ms silence |
|
| 66 |
silenceDuration=0.01; |
|
| 67 |
silence= zeros(1,round(silenceDuration/dt)); |
|
| 68 |
inputSignal= [silence inputSignal silence]; |
|
| 69 |
time=dt: dt: dt*length(inputSignal); |
|
| 70 |
|
|
| 71 |
%% delare 'showMap' options to control graphical output |
|
| 72 |
showMapOptions.printModelParameters=0; % prints all parameters |
|
| 73 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 74 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 75 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 76 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 77 |
showMapOptions.surfProbability=0; % 2D plot of HSR response |
|
| 78 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 79 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 80 |
|
|
| 81 |
|
|
| 82 |
MAP1_14(inputSignal, 1/dt, BFlist, ... |
|
| 83 |
paramsName, AN_spikesOrProbability, paramChanges); |
|
| 84 |
|
|
| 85 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 86 |
pause(0.1) |
|
| 87 |
|
|
| 88 |
% use this to produce a comnplete record of model parameters |
|
| 89 |
% UTIL_showAllMAPStructures |
|
| 90 |
|
|
| 91 |
OAE=sum(DRNLoutput); |
|
| 92 |
figure(5),subplot(2,1,1) |
|
| 93 |
plot(time,OAE) |
|
| 94 |
title(['F=' num2str(toneFrequencies)]) |
|
| 95 |
[fft_powerdB, fft_phase, frequencies, fft_ampdB]= UTIL_FFT(OAE, dt, 1e-15); |
|
| 96 |
idx=find(frequencies<1e4); |
|
| 97 |
|
|
| 98 |
figure(5),subplot(2,1,2) |
|
| 99 |
plot(frequencies(idx),fft_ampdB(idx)) |
|
| 100 |
title ('FFT of OAE')
|
|
| 101 |
ylabel('dB')
|
|
| 102 |
ylim([0 100]) |
|
| 103 |
grid on |
|
| 104 |
|
|
| 105 |
path(restorePath); |
|
| userProgramsRM/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 |
|
|
| userProgramsRM/pitchModel_RM.m | ||
|---|---|---|
| 1 |
function pitchModel_RM |
|
| 2 |
% Modification of testMAP_14 to replicate the pitch model published |
|
| 3 |
% in JASA 2006. |
|
| 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 |
dbstop if error |
|
| 36 |
restorePath=path; |
|
| 37 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 38 |
['..' filesep 'utilities']) |
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
% Pitch model modification here |
|
| 43 |
global ICrate % used to collect rate profile from showMAP temporary |
|
| 44 |
rates=[]; F0count=0; |
|
| 45 |
|
|
| 46 |
% F0s=[150 200 250]; % fundamental frequency |
|
| 47 |
% harmonics= 3:5; |
|
| 48 |
|
|
| 49 |
% F0s=[3000]; % fundamental frequency |
|
| 50 |
F0s=50:5:1000; |
|
| 51 |
harmonics= 1; |
|
| 52 |
% F0s=150; |
|
| 53 |
for F0=F0s |
|
| 54 |
F0count=F0count+1; |
|
| 55 |
|
|
| 56 |
|
|
| 57 |
%% #1 parameter file name |
|
| 58 |
MAPparamsName='Normal'; |
|
| 59 |
|
|
| 60 |
|
|
| 61 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 62 |
AN_spikesOrProbability='spikes'; |
|
| 63 |
|
|
| 64 |
% or |
|
| 65 |
% NB probabilities are not corrected for refractory effects |
|
| 66 |
% AN_spikesOrProbability='probability'; |
|
| 67 |
|
|
| 68 |
|
|
| 69 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 70 |
signalType= 'tones'; |
|
| 71 |
sampleRate= 50000; |
|
| 72 |
duration=0.50; % seconds |
|
| 73 |
% toneFrequency= 1000; % or a pure tone (Hz8 |
|
| 74 |
|
|
| 75 |
% F0=210; |
|
| 76 |
toneFrequency= F0*harmonics; % harmonic sequence (Hz) |
|
| 77 |
|
|
| 78 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 79 |
|
|
| 80 |
% or |
|
| 81 |
|
|
| 82 |
% signalType= 'file'; |
|
| 83 |
% fileName='twister_44kHz'; |
|
| 84 |
|
|
| 85 |
|
|
| 86 |
%% #4 rms level |
|
| 87 |
% signal details |
|
| 88 |
leveldBSPL= 50; % dB SPL |
|
| 89 |
|
|
| 90 |
|
|
| 91 |
%% #5 number of channels in the model |
|
| 92 |
% 21-channel model (log spacing) |
|
| 93 |
numChannels=21; |
|
| 94 |
lowestBF=250; highestBF= 8000; |
|
| 95 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 96 |
|
|
| 97 |
% or specify your own channel BFs |
|
| 98 |
% numChannels=1; |
|
| 99 |
BFlist=toneFrequency; |
|
| 100 |
% BFlist=500; |
|
| 101 |
|
|
| 102 |
|
|
| 103 |
%% #6 change model parameters |
|
| 104 |
paramChanges={...
|
|
| 105 |
'MacGregorMultiParams.currentPerSpike=25e-9;'... |
|
| 106 |
'MacGregorMultiParams.tauGk= [0.1e-3:.00005 : 1e-3];'... |
|
| 107 |
'MacGregorParams.currentPerSpike=40e-9;'... |
|
| 108 |
}; |
|
| 109 |
|
|
| 110 |
%% delare 'showMap' options to control graphical output |
|
| 111 |
|
|
| 112 |
showMapOptions.printModelParameters=0; % prints all parameters |
|
| 113 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 114 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 115 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 116 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 117 |
showMapOptions.surfProbability=0; % 2D plot of HSR response |
|
| 118 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 119 |
showMapOptions.ICrates=1; % IC rates by CNtauGk |
|
| 120 |
|
|
| 121 |
% disable certain silly options |
|
| 122 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 123 |
% avoid nonsensical options |
|
| 124 |
showMapOptions.surfProbability=0; |
|
| 125 |
showMapOptions.showACF=0; |
|
| 126 |
else |
|
| 127 |
showMapOptions.surfSpikes=0; |
|
| 128 |
end |
|
| 129 |
if strcmp(signalType, 'file') |
|
| 130 |
% needed for labeling plot |
|
| 131 |
showMapOptions.fileName=fileName; |
|
| 132 |
else |
|
| 133 |
showMapOptions.fileName=[]; |
|
| 134 |
end |
|
| 135 |
|
|
| 136 |
%% Generate stimuli |
|
| 137 |
|
|
| 138 |
switch signalType |
|
| 139 |
case 'tones' |
|
| 140 |
inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
|
| 141 |
leveldBSPL, duration, rampDuration); |
|
| 142 |
|
|
| 143 |
case 'file' |
|
| 144 |
%% file input simple or mixed |
|
| 145 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 146 |
dt=1/sampleRate; |
|
| 147 |
inputSignal=inputSignal(:,1); |
|
| 148 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 149 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 150 |
amp=targetRMS/rms; |
|
| 151 |
inputSignal=inputSignal*amp; |
|
| 152 |
silence= zeros(1,round(0.1/dt)); |
|
| 153 |
inputSignal= [silence inputSignal' silence]; |
|
| 154 |
end |
|
| 155 |
|
|
| 156 |
|
|
| 157 |
%% run the model |
|
| 158 |
tic |
|
| 159 |
|
|
| 160 |
fprintf('\n')
|
|
| 161 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 162 |
disp([num2str(numChannels) ' channel model']) |
|
| 163 |
disp([num2str(F0) ' F0']) |
|
| 164 |
disp('Computing ...')
|
|
| 165 |
|
|
| 166 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 167 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 168 |
|
|
| 169 |
|
|
| 170 |
% the model run is now complete. Now display the results |
|
| 171 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 172 |
|
|
| 173 |
%% pitch model Collect and analyse data |
|
| 174 |
% ICrate is global and computed in showMAP |
|
| 175 |
% a vector of 'stage4' rates; one value for each tauCNGk |
|
| 176 |
rates=[rates; ICrate]; |
|
| 177 |
figure(92), imagesc(rates) |
|
| 178 |
ylabel ('F0 no'), xlabel('tauGk')
|
|
| 179 |
% figure(92), plot(rates), ylim([0 inf]) |
|
| 180 |
|
|
| 181 |
h=figure(99); CNmovie(F0count)=getframe(h); |
|
| 182 |
figure(91), plot(rates'),ylim([0 inf]) |
|
| 183 |
pause (0.1) |
|
| 184 |
|
|
| 185 |
end |
|
| 186 |
%% show results |
|
| 187 |
toc |
|
| 188 |
figure(91), plot(F0s,rates'), xlabel('F0'), ylabel('rate'),ylim([0 inf])
|
|
| 189 |
% figure(99),clf,movie(CNmovie,1,4) |
|
| 190 |
path(restorePath) |
|
| 191 |
|
|
| 192 |
|
|
| 193 |
function inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
|
| 194 |
leveldBSPL, duration, rampDuration) |
|
| 195 |
% Create pure tone stimulus |
|
| 196 |
dt=1/sampleRate; % seconds |
|
| 197 |
time=dt: dt: duration; |
|
| 198 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 199 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 200 |
inputSignal=amp*inputSignal; |
|
| 201 |
|
|
| 202 |
% apply ramps |
|
| 203 |
% catch rampTime error |
|
| 204 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 205 |
rampTime=dt:dt:rampDuration; |
|
| 206 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 207 |
ones(1,length(time)-length(rampTime))]; |
|
| 208 |
inputSignal=inputSignal.*ramp; |
|
| 209 |
ramp=fliplr(ramp); |
|
| 210 |
inputSignal=inputSignal.*ramp; |
|
| 211 |
|
|
| 212 |
% add 10 ms silence |
|
| 213 |
silence= zeros(1,round(0.005/dt)); |
|
| 214 |
inputSignal= [silence inputSignal silence]; |
|
| 215 |
|
|
| userProgramsRM/temp.m | ||
|---|---|---|
| 1 |
function test_speechInNoise |
|
| 2 |
|
|
| 3 |
leveldBSPL= 60; % dB SPL |
|
| 4 |
leveldBSPLNoise=-55; |
|
| 5 |
|
|
| 6 |
paramChanges={};
|
|
| 7 |
% no attenuation |
|
| 8 |
paramChanges={'DRNLParams.rateToAttenuationFactorProb = 0.00; '};
|
|
| 9 |
% fixed attenuation |
|
| 10 |
% paramChanges={'DRNLParams.rateToAttenuationFactorProb = -0.04;'};
|
|
| 11 |
% % dynamic attenuation |
|
| 12 |
paramChanges={'DRNLParams.MOCtauProb =.15;', ...
|
|
| 13 |
'DRNLParams.rateToAttenuationFactorProb = 0.01; '}; |
|
| 14 |
% |
|
| 15 |
fileName='twister_44kHz'; |
|
| 16 |
fileName='1o7a_44kHz'; |
|
| 17 |
|
|
| 18 |
dbstop if error |
|
| 19 |
restorePath=path; |
|
| 20 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 21 |
['..' filesep 'utilities']) |
|
| 22 |
|
|
| 23 |
%% #1 parameter file name |
|
| 24 |
MAPparamsName='Normal'; |
|
| 25 |
|
|
| 26 |
|
|
| 27 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 28 |
AN_spikesOrProbability='spikes'; |
|
| 29 |
% or |
|
| 30 |
AN_spikesOrProbability='probability'; |
|
| 31 |
|
|
| 32 |
|
|
| 33 |
%% #3 speech file input |
|
| 34 |
|
|
| 35 |
beginSilence=.25; |
|
| 36 |
endSilence=0.25; |
|
| 37 |
noiseRampDuration=0.01; |
|
| 38 |
|
|
| 39 |
%% #5 number of channels in the model |
|
| 40 |
% 21-channel model (log spacing) |
|
| 41 |
numChannels=21; |
|
| 42 |
lowestBF=300; highestBF= 6000; |
|
| 43 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 44 |
|
|
| 45 |
% or specify your own channel BFs |
|
| 46 |
% numChannels=1; |
|
| 47 |
% BFlist=1000; |
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
%% delare 'showMap' options to control graphical output |
|
| 52 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 53 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 54 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 55 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 56 |
showMapOptions.showEfferent=1; % tracks of AR and MOC |
|
| 57 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 58 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 59 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 60 |
showMapOptions.PSTHbinwidth=0.002; |
|
| 61 |
|
|
| 62 |
% disable certain silly options |
|
| 63 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 64 |
% avoid nonsensical options |
|
| 65 |
showMapOptions.surfProbability=0; |
|
| 66 |
showMapOptions.showACF=0; |
|
| 67 |
else |
|
| 68 |
showMapOptions.surfSpikes=0; |
|
| 69 |
end |
|
| 70 |
% needed for labeling plot |
|
| 71 |
showMapOptions.fileName=fileName; |
|
| 72 |
|
|
| 73 |
%% Generate stimuli |
|
| 74 |
|
|
| 75 |
%% file input simple or mixed |
|
| 76 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 77 |
dt=1/sampleRate; |
|
| 78 |
inputSignal=inputSignal(:,1); |
|
| 79 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 80 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 81 |
amp=targetRMS/rms; |
|
| 82 |
inputSignal=inputSignal*amp; |
|
| 83 |
|
|
| 84 |
% add silences |
|
| 85 |
intialSilence= zeros(1,round(beginSilence*sampleRate)); |
|
| 86 |
finalSilence= zeros(1,round(endSilence*sampleRate)); |
|
| 87 |
inputSignal= [intialSilence inputSignal' finalSilence]; |
|
| 88 |
|
|
| 89 |
[inputNoise sampleRateN]=wavread('babble');
|
|
| 90 |
inputNoise=inputNoise(1:length(inputSignal)); |
|
| 91 |
inputNoise=inputNoise(:,1); |
|
| 92 |
targetRMS=20e-6*10^(leveldBSPLNoise/20); |
|
| 93 |
rms=(mean(inputNoise.^2))^0.5; |
|
| 94 |
amp=targetRMS/rms; |
|
| 95 |
inputNoise=inputNoise*amp; |
|
| 96 |
time=dt: dt: dt*length(inputNoise); |
|
| 97 |
rampTime=dt:dt:noiseRampDuration; |
|
| 98 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*noiseRampDuration)+pi)) ... |
|
| 99 |
ones(1,length(time)-length(rampTime))]; |
|
| 100 |
inputNoise=inputNoise'.*ramp; |
|
| 101 |
inputSignal=inputSignal+inputNoise; |
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
%% run the model |
|
| 106 |
tic |
|
| 107 |
|
|
| 108 |
fprintf('\n')
|
|
| 109 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 110 |
disp([num2str(numChannels) ' channel model']) |
|
| 111 |
disp('Computing ...')
|
|
| 112 |
|
|
| 113 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 114 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 115 |
|
|
| 116 |
|
|
| 117 |
%% the model run is now complete. Now display the results |
|
| 118 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 119 |
figure(97), view([-3 82]) |
|
| 120 |
title(['speech/ noise: ' num2str([leveldBSPL leveldBSPLNoise])]) |
|
| 121 |
|
|
| 122 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 123 |
disp(['noise level=' num2str(leveldBSPLNoise)]) |
|
| 124 |
|
|
| 125 |
global DRNLParams |
|
| 126 |
disp(['attenuation factor =' ... |
|
| 127 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 128 |
disp(['attenuation factor (probability)=' ... |
|
| 129 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 130 |
disp(AN_spikesOrProbability) |
|
| 131 |
disp(paramChanges) |
|
| 132 |
toc |
|
| 133 |
path(restorePath) |
|
| 134 |
|
|
| userProgramsRM/testACF.m | ||
|---|---|---|
| 1 |
% function [LP_SACF dt lags SACF]= testACF |
|
| 2 |
% testACF is a *script* to demonstrate the smoothed ACF of |
|
| 3 |
% Balaguer-Ballestera, E. Denham, S.L. and Meddis, R. (2008). |
|
| 4 |
% |
|
| 5 |
% Convert this to a *function* by uncommenting the first line |
|
| 6 |
% The function returns the LP_SACF matrix plotted in Figure 96. |
|
| 7 |
% If a function is used, the following outputs are returned: |
|
| 8 |
% LP_SACF: smoothed SACF (lags x time matrix) |
|
| 9 |
% dt: time interval between successive columns of LP_SACF |
|
| 10 |
% lags: lags used in computing LP_SACF |
|
| 11 |
% SACF: unsmoothed SACFs |
|
| 12 |
% |
|
| 13 |
% A range of options are supplied in the early part of the program |
|
| 14 |
% |
|
| 15 |
% #1 |
|
| 16 |
% Identify the model parameter file (in 'MAPparamsName') |
|
| 17 |
% |
|
| 18 |
% #2 |
|
| 19 |
% Identify the kind of model required (in 'AN_spikesOrProbability') |
|
| 20 |
% 'probability' is recommended for ACF work |
|
| 21 |
% |
|
| 22 |
% #3 |
|
| 23 |
% Choose between a harmonic complex or file input |
|
| 24 |
% by commenting out unwanted code |
|
| 25 |
% |
|
| 26 |
% #4 |
|
| 27 |
% Set the signal rms level (in leveldBSPL) |
|
| 28 |
% |
|
| 29 |
% #5 |
|
| 30 |
% Identify the model channel BFs in the vector 'BFlist'. |
|
| 31 |
% |
|
| 32 |
% #6 |
|
| 33 |
% Last minute changes to the model parameters can be made using |
|
| 34 |
% the cell array of strings 'paramChanges'. |
|
| 35 |
% This is used here to control the details of the ACF computations |
|
| 36 |
% Read the notes in this section for more information |
|
| 37 |
% |
|
| 38 |
% displays: |
|
| 39 |
% Figure 97 shows the AN response to the stimulus. this is a channel x time |
|
| 40 |
% display. The z-axis (and colour) is the AN fiber firing rate |
|
| 41 |
% |
|
| 42 |
% Figure 96 shows the LP_SACF-matrix, the smoothed SACF. |
|
| 43 |
% |
|
| 44 |
% Figure 89 shows a summary of the evolution of the unsmoothed SACF |
|
| 45 |
% over time. If you wish to take a snapshot of the LP_SACF-matrix at a |
|
| 46 |
% particular time, this figure can help identify when to take it. |
|
| 47 |
% The index on the y-axis, identifies the required row numbers |
|
| 48 |
% of the LP_SACF or SACF matrix, e.g. LP_SACF(:,2000) |
|
| 49 |
% |
|
| 50 |
% On request, (filteredSACFParams.plotACFs=1) Figure 89 shows the channel |
|
| 51 |
% by channel ACFs at intervals during the computation as a movie. |
|
| 52 |
% The number of ACF displays is controlled by 'plotACFsInterval' |
|
| 53 |
% and the movie can be slowed or speeded up using 'plotMoviePauses' |
|
| 54 |
% (see paramChanges section below). |
|
| 55 |
|
|
| 56 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
| 57 |
% This global will find results from MAP1_14 |
|
| 58 |
global savedInputSignal ANprobRateOutput ANoutput dt dtSpikes savedBFlist |
|
| 59 |
% This global,from model parameter file |
|
| 60 |
global filteredSACFParams |
|
| 61 |
|
|
| 62 |
% User sets up requirements |
|
| 63 |
%% #1 parameter file name |
|
| 64 |
MAPparamsName='Normal'; % recommended |
|
| 65 |
|
|
| 66 |
|
|
| 67 |
%% #2 probability (fast) or spikes (slow) representation: select one |
|
| 68 |
% AN_spikesOrProbability='spikes'; |
|
| 69 |
% or |
|
| 70 |
AN_spikesOrProbability='probability'; % recommended |
|
| 71 |
|
|
| 72 |
%% #3 A. harmonic sequence or B. speech file input |
|
| 73 |
% Comment out unwanted code |
|
| 74 |
% A. harmonic tone (Hz) - useful to demonstrate a broadband sound |
|
| 75 |
sampleRate= 44100; % recommended 44100 |
|
| 76 |
signalType= 'tones'; |
|
| 77 |
duration=0.100; % seconds |
|
| 78 |
beginSilence=0.020; |
|
| 79 |
endSilence=0.020; |
|
| 80 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 81 |
|
|
| 82 |
% toneFrequency is a vector of component frequencies |
|
| 83 |
F0=120; |
|
| 84 |
toneFrequency= [3*F0 4*F0 5*F0]; |
|
| 85 |
|
|
| 86 |
% or |
|
| 87 |
% B. file input |
|
| 88 |
% signalType= 'file'; |
|
| 89 |
% fileName='Oh No'; |
|
| 90 |
% fileName='twister_44kHz'; |
|
| 91 |
|
|
| 92 |
%% #4 rms level |
|
| 93 |
leveldBSPL= 100; % dB SPL (80 for Lieberman) |
|
| 94 |
|
|
| 95 |
%% #5 number of channels in the model |
|
| 96 |
% 21-channel model (log spacing of BFs) |
|
| 97 |
numChannels=21; |
|
| 98 |
lowestBF=250; highestBF= 5000; |
|
| 99 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 100 |
|
|
| 101 |
%% #6 change model parameters |
|
| 102 |
% Parameter changes can be used to change one or more model parameters |
|
| 103 |
% *after* the MAPparams file has been read (see manual) |
|
| 104 |
|
|
| 105 |
% Take control of ACF parameters |
|
| 106 |
% The filteredACF parameters are set in the MAPparamsNormal file |
|
| 107 |
% However, it is convenient to change them here leving the file intacta |
|
| 108 |
minPitch= 400; maxPitch= 3000; numPitches=200; |
|
| 109 |
maxLag=1/minPitch; minLag=1/maxPitch; |
|
| 110 |
lags= linspace(minLag, maxLag, numPitches); |
|
| 111 |
|
|
| 112 |
paramChanges={...
|
|
| 113 |
'filteredSACFParams.lags=lags; % autocorrelation lags vector;',... |
|
| 114 |
'filteredSACFParams.acfTau= 2; % (Wiegrebe) time constant ACF;',... |
|
| 115 |
'filteredSACFParams.lambda= 0.12; % slower filter to smooth ACF;',... |
|
| 116 |
'filteredSACFParams.plotACFs=1; % plot ACFs while computing;',... |
|
| 117 |
'filteredSACFParams.plotACFsInterval=0.01;',... |
|
| 118 |
'filteredSACFParams.plotMoviePauses=.1; ',... |
|
| 119 |
'filteredSACFParams.usePressnitzer=0; % attenuates ACF at long lags;',... |
|
| 120 |
'filteredSACFParams.lagsProcedure= ''useAllLags'';',... |
|
| 121 |
}; |
|
| 122 |
|
|
| 123 |
% Notes: |
|
| 124 |
% acfTau: time constant of unsmoothed ACF |
|
| 125 |
% lambda: time constant of smoothed ACFS |
|
| 126 |
% plotACFs: plot ACFs during computation (0 to switch off, for speed) |
|
| 127 |
% plotACFsInterval: sampling interval for plots |
|
| 128 |
% plotMoviePauses: pause duration between frames to allow viewing |
|
| 129 |
% usePressnitzer: gives low weights to long lags |
|
| 130 |
% lagsProcedure: used to fiddle with output (ignore) |
|
| 131 |
|
|
| 132 |
%% delare 'showMap' options to control graphical output |
|
| 133 |
% see UTIL_showMAP for more options |
|
| 134 |
showMapOptions=[]; |
|
| 135 |
% showMapOptions.showModelOutput=0; % plot of all stages |
|
| 136 |
showMapOptions.surfAN=1; % surface plot of HSR response |
|
| 137 |
showMapOptions.PSTHbinwidth=0.001; % smoothing for PSTH |
|
| 138 |
|
|
| 139 |
if exist('fileName','var')
|
|
| 140 |
% needed for labeling plot |
|
| 141 |
showMapOptions.fileName=fileName; |
|
| 142 |
end |
|
| 143 |
|
|
| 144 |
%% Generate stimuli |
|
| 145 |
switch signalType |
|
| 146 |
case 'tones' |
|
| 147 |
% Create tone stimulus |
|
| 148 |
dt=1/sampleRate; % seconds |
|
| 149 |
time=dt: dt: duration; |
|
| 150 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 151 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 152 |
inputSignal=amp*inputSignal; |
|
| 153 |
% apply ramps |
|
| 154 |
% catch rampTime error |
|
| 155 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 156 |
rampTime=dt:dt:rampDuration; |
|
| 157 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 158 |
ones(1,length(time)-length(rampTime))]; |
|
| 159 |
inputSignal=inputSignal.*ramp; |
|
| 160 |
ramp=fliplr(ramp); |
|
| 161 |
inputSignal=inputSignal.*ramp; |
|
| 162 |
% add silence |
|
| 163 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 164 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 165 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 166 |
|
|
| 167 |
case 'file' |
|
| 168 |
%% file input simple or mixed |
|
| 169 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 170 |
dt=1/sampleRate; |
|
| 171 |
inputSignal=inputSignal(:,1); |
|
| 172 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 173 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 174 |
amp=targetRMS/rms; |
|
| 175 |
inputSignal=inputSignal*amp; |
|
| 176 |
end |
|
| 177 |
|
|
| 178 |
wavplay(inputSignal, sampleRate) |
|
| 179 |
|
|
| 180 |
%% run the model |
|
| 181 |
dbstop if error |
|
| 182 |
restorePath=path; |
|
| 183 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 184 |
['..' filesep 'utilities']) |
|
| 185 |
|
|
| 186 |
fprintf('\n')
|
|
| 187 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 188 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 189 |
disp('Computing MAP ...')
|
|
| 190 |
|
|
| 191 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 192 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 193 |
|
|
| 194 |
|
|
| 195 |
%% The model run is now complete. Now display the results |
|
| 196 |
% display the AN response |
|
| 197 |
UTIL_showMAP(showMapOptions) |
|
| 198 |
|
|
| 199 |
% compute ACF |
|
| 200 |
switch AN_spikesOrProbability |
|
| 201 |
case 'probability' |
|
| 202 |
% use only HSR fibers |
|
| 203 |
inputToACF=ANprobRateOutput(end-length(savedBFlist)+1:end,:); |
|
| 204 |
otherwise |
|
| 205 |
inputToACF=ANoutput; |
|
| 206 |
dt=dtSpikes; |
|
| 207 |
end |
|
| 208 |
|
|
| 209 |
disp ('computing ACF...')
|
|
| 210 |
|
|
| 211 |
% read paramChanges to get new filteredSACFParams |
|
| 212 |
for i=1:length(paramChanges) |
|
| 213 |
eval(paramChanges{i});
|
|
| 214 |
end |
|
| 215 |
|
|
| 216 |
[LP_SACF BFlist SACF]= filteredSACF(inputToACF, dt, savedBFlist, ... |
|
| 217 |
filteredSACFParams); |
|
| 218 |
disp(' ACF done.')
|
|
| 219 |
|
|
| 220 |
%% plot original waveform on summary/smoothed ACF plot |
|
| 221 |
figure(96), clf |
|
| 222 |
subplot(3,1,3) |
|
| 223 |
t=dt*(1:length(savedInputSignal)); |
|
| 224 |
plot(t,savedInputSignal, 'k') |
|
| 225 |
xlim([0 t(end)]) |
|
| 226 |
title(['stimulus: ' num2str(leveldBSPL, '%4.0f') ' dB SPL']); |
|
| 227 |
|
|
| 228 |
% plot SACF |
|
| 229 |
figure(96) |
|
| 230 |
subplot(2,1,1) |
|
| 231 |
imagesc(LP_SACF) |
|
| 232 |
colormap bone |
|
| 233 |
ylabel('periodicities (Hz)'), xlabel('time (s)')
|
|
| 234 |
title(['smoothed SACF. (periodicity x time)']) |
|
| 235 |
% y-axis specifies pitches (1/lags) |
|
| 236 |
% Force MATLAB to show the lowest pitch |
|
| 237 |
postedYvalues=[1 get(gca,'ytick')]; set(gca,'ytick',postedYvalues) |
|
| 238 |
pitches=1./filteredSACFParams.lags; |
|
| 239 |
set(gca,'ytickLabel', round(pitches(postedYvalues))) |
|
| 240 |
% x-axis is time at which LP_SACF is samples |
|
| 241 |
[nCH nTimes]=size(LP_SACF); |
|
| 242 |
t=dt:dt:dt*nTimes; |
|
| 243 |
tt=get(gca,'xtick'); |
|
| 244 |
set(gca,'xtickLabel', round(100*t(tt))/100) |
|
| 245 |
|
|
| 246 |
%% On a new figure show a cascade of SACFs |
|
| 247 |
figure(89), clf |
|
| 248 |
% select 100 samples; |
|
| 249 |
[r c]=size(SACF); |
|
| 250 |
step=round(c/100); |
|
| 251 |
idx=step:step:c; |
|
| 252 |
|
|
| 253 |
UTIL_cascadePlot(SACF(:,idx)', 1./pitches) |
|
| 254 |
|
|
| 255 |
xlabel('lag (s)'), ylabel('time pointer -->')
|
|
| 256 |
title(' SACF summary over time')
|
|
| 257 |
yValues=get(gca,'yTick'); |
|
| 258 |
set(gca,'yTickLabel', num2str(yValues'*100)) |
|
| 259 |
|
|
| 260 |
path(restorePath) |
|
| 261 |
|
|
| userProgramsRM/testDPOAE.m | ||
|---|---|---|
| 1 |
% testDPOAE |
|
| 2 |
|
|
| 3 |
addpath (['..' filesep 'testPrograms']) |
|
| 4 |
|
|
| 5 |
leveldB=60; |
|
| 6 |
f1=3000; |
|
| 7 |
frequencyDiffs=20:20:1000; |
|
| 8 |
result=[]; |
|
| 9 |
frequenciesSoFar=[]; |
|
| 10 |
for f2=f1+frequencyDiffs |
|
| 11 |
[frequencies fft_ampdB]=testDPOAE (leveldB, [f1 f2]); |
|
| 12 |
dpFreq=2*f1-f2; |
|
| 13 |
[a idx]=min((frequencies-dpFreq).^2); |
|
| 14 |
result=[result fft_ampdB(idx)]; |
|
| 15 |
frequenciesSoFar=[frequenciesSoFar dpFreq]; |
|
| 16 |
figure(4), plot(frequenciesSoFar, result) |
|
| 17 |
title(['F1= ' num2str(f1) ' F2= ' ... |
|
| 18 |
num2str(f1+ [min(frequencyDiffs) max(frequencyDiffs)])... |
|
| 19 |
' leveldB= ' num2str(leveldB)]) |
|
| 20 |
xlabel('DP (2f1- f2) frequency'), ylim([0 100])
|
|
| 21 |
end |
|
| 22 |
|
|
| 23 |
grid on |
|
| 24 |
|
|
| 25 |
disp(result) |
|
| userProgramsRM/test_Dolan_and_Nuttall.m | ||
|---|---|---|
| 1 |
function test_Dolan_and_Nuttall |
|
| 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 |
global dt dtSpikes savedBFlist saveAN_spikesOrProbability saveMAPparamsName... |
|
| 36 |
savedInputSignal OMEextEarPressure TMoutput OMEoutput ARattenuation ... |
|
| 37 |
DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
|
| 38 |
IHCoutput ANprobRateOutput ANoutput savePavailable ANtauCas ... |
|
| 39 |
CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates ... |
|
| 40 |
MOCattenuation |
|
| 41 |
global OMEParams DRNLParams IHC_cilia_RPParams IHCpreSynapseParams |
|
| 42 |
global AN_IHCsynapseParams MacGregorParams MacGregorMultiParams |
|
| 43 |
global ICrate |
|
| 44 |
|
|
| 45 |
|
|
| 46 |
dbstop if error |
|
| 47 |
restorePath=path; |
|
| 48 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 49 |
['..' filesep 'utilities']) |
|
| 50 |
|
|
| 51 |
%% #1 parameter file name |
|
| 52 |
MAPparamsName='Normal'; |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 56 |
AN_spikesOrProbability='spikes'; |
|
| 57 |
% or |
|
| 58 |
% AN_spikesOrProbability='probability'; |
|
| 59 |
|
|
| 60 |
|
|
| 61 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 62 |
signalType= 'tones'; |
|
| 63 |
toneFrequency= 4000; % or a pure tone (Hz) |
|
| 64 |
|
|
| 65 |
sampleRate= 44100; % must agree with noise |
|
| 66 |
duration=0.010; % seconds |
|
| 67 |
beginSilence=0.010; |
|
| 68 |
endSilence=0.010; |
|
| 69 |
rampDuration=.001; % raised cosine ramp (seconds) |
|
| 70 |
noiseRampDuration=0.002; |
|
| 71 |
|
|
| 72 |
% or |
|
| 73 |
% harmonic sequence (Hz) |
|
| 74 |
% F0=210; |
|
| 75 |
% toneFrequency= F0:F0:8000; |
|
| 76 |
|
|
| 77 |
% or |
|
| 78 |
% signalType= 'file'; |
|
| 79 |
% fileName='twister_44kHz'; |
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
% %% #4 rms level |
|
| 84 |
% % signal details |
|
| 85 |
% leveldBSPL= 80; % dB SPL (80 for Lieberman) |
|
| 86 |
% leveldBSPLNoise=-30; |
|
| 87 |
|
|
| 88 |
%% #5 number of channels in the model |
|
| 89 |
% 21-channel model (log spacing) |
|
| 90 |
numChannels=21; |
|
| 91 |
lowestBF=250; highestBF= 8000; |
|
| 92 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 93 |
|
|
| 94 |
% % or specify your own channel BFs |
|
| 95 |
% numChannels=1; |
|
| 96 |
% BFlist=toneFrequency; |
|
| 97 |
|
|
| 98 |
|
|
| 99 |
%% #6 change model parameters |
|
| 100 |
|
|
| 101 |
paramChanges={};
|
|
| 102 |
|
|
| 103 |
% Parameter changes can be used to change one or more model parameters |
|
| 104 |
% *after* the MAPparams file has been read |
|
| 105 |
% This example declares only one fiber type with a calcium clearance time |
|
| 106 |
% constant of 80e-6 s (HSR fiber) when the probability option is selected. |
|
| 107 |
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
|
|
| 108 |
% 'IHCpreSynapseParams.tauCa=86e-6; '}; |
|
| 109 |
% paramChanges={'DRNLParams.MOCtauProb =.25;', ...
|
|
| 110 |
% 'DRNLParams.rateToAttenuationFactorProb = 0.02; '}; |
|
| 111 |
|
|
| 112 |
paramChanges={'AN_IHCsynapseParams.numFibers= 50; ',...
|
|
| 113 |
'DRNLParams.MOCtauProb =.15;', ... |
|
| 114 |
'DRNLParams.rateToAttenuationFactorProb = 0.00; '}; |
|
| 115 |
|
|
| 116 |
% paramChanges={'AN_IHCsynapseParams.numFibers= 50; ',...
|
|
| 117 |
% 'DRNLParams.rateToAttenuationFactorProb = -0.007;'}; |
|
| 118 |
|
|
| 119 |
|
|
| 120 |
%% delare 'showMap' options to control graphical output |
|
| 121 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 122 |
showMapOptions.showModelOutput=0; % plot of all stages |
|
| 123 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 124 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 125 |
showMapOptions.showEfferent=1; % tracks of AR and MOC |
|
| 126 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 127 |
showMapOptions.surfSpikes=1; % 2D plot of spikes histogram |
|
| 128 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 129 |
|
|
| 130 |
% disable certain silly options |
|
| 131 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 132 |
% avoid nonsensical options |
|
| 133 |
showMapOptions.surfProbability=0; |
|
| 134 |
showMapOptions.showACF=0; |
|
| 135 |
end |
|
| 136 |
|
|
| 137 |
if strcmp(signalType, 'file') |
|
| 138 |
% needed for labeling plot |
|
| 139 |
showMapOptions.fileName=fileName; |
|
| 140 |
else |
|
| 141 |
showMapOptions.fileName=[]; |
|
| 142 |
end |
|
| 143 |
|
|
| 144 |
fprintf('\n')
|
|
| 145 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 146 |
disp('Computing ...')
|
|
| 147 |
|
|
| 148 |
%%systematic |
|
| 149 |
probeLevels=30:10:80; |
|
| 150 |
noiseLevels=[-100 30]; |
|
| 151 |
noRepeats=10; |
|
| 152 |
|
|
| 153 |
% probeLevels=80; |
|
| 154 |
% noiseLevels=[-30]; |
|
| 155 |
% noRepeats=10; |
|
| 156 |
|
|
| 157 |
peakCAPs=zeros(4,length(probeLevels)); |
|
| 158 |
|
|
| 159 |
for noiseCondition=1:length(noiseLevels) |
|
| 160 |
leveldBSPLNoise=noiseLevels(noiseCondition); |
|
| 161 |
levelNo=0; |
|
| 162 |
for probeLevel=probeLevels |
|
| 163 |
leveldBSPL=probeLevel; |
|
| 164 |
levelNo=levelNo+1; |
|
| 165 |
summedCAP=[]; |
|
| 166 |
for repeatNo= 1:noRepeats |
|
| 167 |
disp(['repeat no: ' num2str(repeatNo)]) |
|
| 168 |
%% Generate stimuli |
|
| 169 |
|
|
| 170 |
switch signalType |
|
| 171 |
case 'tones' |
|
| 172 |
% Create pure tone stimulus |
|
| 173 |
dt=1/sampleRate; % seconds |
|
| 174 |
time=dt: dt: duration; |
|
| 175 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 176 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 177 |
inputSignal=amp*inputSignal; |
|
| 178 |
% apply ramps |
|
| 179 |
% catch rampTime error |
|
| 180 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 181 |
rampTime=dt:dt:rampDuration; |
|
| 182 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 183 |
ones(1,length(time)-length(rampTime))]; |
|
| 184 |
inputSignal=inputSignal.*ramp; |
|
| 185 |
ramp=fliplr(ramp); |
|
| 186 |
inputSignal=inputSignal.*ramp; |
|
| 187 |
% add silence |
|
| 188 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 189 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 190 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 191 |
|
|
| 192 |
% [inputNoise sampleRateN]=wavread('babble');
|
|
| 193 |
[inputNoise sampleRateN]=wavread('white noise');
|
|
| 194 |
inputNoise=inputNoise(1:length(inputSignal)); |
|
| 195 |
inputNoise=inputNoise(:,1); |
|
| 196 |
targetRMS=20e-6*10^(leveldBSPLNoise/20); |
|
| 197 |
rms=(mean(inputNoise.^2))^0.5; |
|
| 198 |
amp=targetRMS/rms; |
|
| 199 |
inputNoise=inputNoise*amp; |
|
| 200 |
time=dt: dt: dt*length(inputNoise); |
|
| 201 |
rampTime=dt:dt:noiseRampDuration; |
|
| 202 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*noiseRampDuration)+pi)) ... |
|
| 203 |
ones(1,length(time)-length(rampTime))]; |
|
| 204 |
inputNoise=inputNoise'.*ramp; |
|
| 205 |
ramp=fliplr(ramp); |
|
| 206 |
inputNoise=inputNoise.*ramp; |
|
| 207 |
|
|
| 208 |
inputSignal=inputSignal+inputNoise; |
|
| 209 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 210 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 211 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 212 |
|
|
| 213 |
toneOnset=2*beginSilence; |
|
| 214 |
|
|
| 215 |
figure(2), subplot(3,1,1) |
|
| 216 |
time=dt:dt:dt*length(inputSignal); |
|
| 217 |
plot(time,inputSignal,'k') |
|
| 218 |
|
|
| 219 |
case 'file' |
|
| 220 |
%% file input simple or mixed |
|
| 221 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 222 |
dt=1/sampleRate; |
|
| 223 |
inputSignal=inputSignal(:,1); |
|
| 224 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 225 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 226 |
amp=targetRMS/rms; |
|
| 227 |
inputSignal=inputSignal*amp; |
|
| 228 |
intialSilence= zeros(1,round(0.1/dt)); |
|
| 229 |
finalSilence= zeros(1,round(0.2/dt)); |
|
| 230 |
inputSignal= [intialSilence inputSignal' finalSilence]; |
|
| 231 |
|
|
| 232 |
end |
|
| 233 |
|
|
| 234 |
|
|
| 235 |
%% run the model |
|
| 236 |
tic |
|
| 237 |
|
|
| 238 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 239 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 240 |
|
|
| 241 |
|
|
| 242 |
%% the model run is now complete. Now display the results |
|
| 243 |
% UTIL_showMAP(showMapOptions, paramChanges) |
|
| 244 |
|
|
| 245 |
wholeNerveCAP = UTIL_CAPgenerator... |
|
| 246 |
(ANoutput, dtSpikes, BFlist, AN_IHCsynapseParams.numFibers, 1); |
|
| 247 |
|
|
| 248 |
if isempty(summedCAP) |
|
| 249 |
summedCAP=wholeNerveCAP; |
|
| 250 |
else |
|
| 251 |
summedCAP=summedCAP+wholeNerveCAP; |
|
| 252 |
end |
|
| 253 |
|
|
| 254 |
switch AN_spikesOrProbability |
|
| 255 |
case 'spikes' |
|
| 256 |
ANoutput = sum(ANoutput, 1); |
|
| 257 |
case 'probability' |
|
| 258 |
ANoutput = ANprobRateOutput(13+21,:); |
|
| 259 |
end |
|
| 260 |
figure(2), subplot(3,1,2), plot(ANoutput) |
|
| 261 |
spikeTimes=dtSpikes:dtSpikes:dtSpikes* length(wholeNerveCAP); |
|
| 262 |
figure(2), subplot(3,1,3), plot(spikeTimes,summedCAP/repeatNo) |
|
| 263 |
ylim([-50 50]) |
|
| 264 |
end % repeat |
|
| 265 |
|
|
| 266 |
spikeTimes=dtSpikes:dtSpikes:dtSpikes* length(wholeNerveCAP); |
|
| 267 |
idx=find(spikeTimes>toneOnset & ... |
|
| 268 |
spikeTimes>toneOnset+duration+.005); |
|
| 269 |
averageCAP=summedCAP/repeatNo; |
|
| 270 |
peakCAP=max(averageCAP(idx)); |
|
| 271 |
peakCAPs(noiseCondition,levelNo)=peakCAPs(noiseCondition,levelNo)+ peakCAP; |
|
| 272 |
|
|
| 273 |
if strcmp(signalType,'tones') |
|
| 274 |
disp(['duration=' num2str(duration)]) |
|
| 275 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 276 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 277 |
disp(['leveldBSPLNoise=' num2str(leveldBSPLNoise)]) |
|
| 278 |
|
|
| 279 |
disp(['attenuation factor =' ... |
|
| 280 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 281 |
disp(['attenuation factor (probability)=' ... |
|
| 282 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 283 |
disp(AN_spikesOrProbability) |
|
| 284 |
end |
|
| 285 |
|
|
| 286 |
|
|
| 287 |
disp([ 'peak CAP ' num2str(peakCAP)]) |
|
| 288 |
|
|
| 289 |
for i=1:length(paramChanges) |
|
| 290 |
disp(paramChanges{i})
|
|
| 291 |
end |
|
| 292 |
end % probe level |
|
| 293 |
figure(9), subplot(3,1,3), plot(probeLevels,peakCAPs) |
|
| 294 |
end % condition |
|
| 295 |
%% |
|
| 296 |
|
|
| 297 |
path(restorePath) |
|
| 298 |
|
|
| userProgramsRM/test_MAP1_14Hopkins.m | ||
|---|---|---|
| 1 |
function test_MAP1_14Hopkins |
|
| 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 |
dbstop if error |
|
| 36 |
restorePath=path; |
|
| 37 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 38 |
['..' filesep 'utilities']) |
|
| 39 |
|
|
| 40 |
%% #1 parameter file name |
|
| 41 |
MAPparamsName='Normal'; |
|
| 42 |
|
|
| 43 |
|
|
| 44 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 45 |
AN_spikesOrProbability='spikes'; |
|
| 46 |
% or |
|
| 47 |
AN_spikesOrProbability='probability'; |
|
| 48 |
|
|
| 49 |
|
|
| 50 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 51 |
signalType= 'tones'; |
|
| 52 |
sampleRate= 50000; |
|
| 53 |
duration=0.100; % seconds |
|
| 54 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 55 |
beginSilence=0.050; |
|
| 56 |
endSilence=0.050; |
|
| 57 |
toneFrequency= 1000; % or a pure tone (Hz) |
|
| 58 |
|
|
| 59 |
% or |
|
| 60 |
% harmonic sequence (Hz) |
|
| 61 |
F0=1000/11; |
|
| 62 |
toneFrequency= 10*F0:F0:12*F0; |
|
| 63 |
|
|
| 64 |
% or |
|
| 65 |
% signalType= 'file'; |
|
| 66 |
% fileName='twister_44kHz'; |
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
%% #4 rms level |
|
| 71 |
% signal details |
|
| 72 |
leveldBSPL= [44 50 44]; % dB SPL (80 for Lieberman) |
|
| 73 |
leveldBSPL= [50 50 50]; % dB SPL (80 for Lieberman) |
|
| 74 |
noiseLevel=-35; |
|
| 75 |
|
|
| 76 |
%% #5 number of channels in the model |
|
| 77 |
% 21-channel model (log spacing) |
|
| 78 |
numChannels=21; |
|
| 79 |
lowestBF=500; highestBF= 2000; |
|
| 80 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 81 |
|
|
| 82 |
% or specify your own channel BFs |
|
| 83 |
numChannels=1; |
|
| 84 |
BFlist=1000; |
|
| 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 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 102 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 103 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 104 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 105 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 106 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 107 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 108 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 109 |
showMapOptions.PSTHbinwidth=0.001; |
|
| 110 |
showMapOptions.colorbar=0; |
|
| 111 |
showMapOptions.view=[0 90]; |
|
| 112 |
|
|
| 113 |
% disable certain silly options |
|
| 114 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 115 |
% avoid nonsensical options |
|
| 116 |
showMapOptions.surfProbability=0; |
|
| 117 |
showMapOptions.showACF=0; |
|
| 118 |
end |
|
| 119 |
|
|
| 120 |
if strcmp(signalType, 'file') |
|
| 121 |
% needed for labeling plot |
|
| 122 |
showMapOptions.fileName=fileName; |
|
| 123 |
else |
|
| 124 |
showMapOptions.fileName=[]; |
|
| 125 |
end |
|
| 126 |
|
|
| 127 |
%% Generate stimuli |
|
| 128 |
|
|
| 129 |
switch signalType |
|
| 130 |
case 'tones' |
|
| 131 |
% Create pure tone stimulus |
|
| 132 |
dt=1/sampleRate; % seconds |
|
| 133 |
time=dt: dt: duration; |
|
| 134 |
amp=10.^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 135 |
inputSignal=sin(2*pi*toneFrequency'*time); |
|
| 136 |
amps=repmat(amp',1,length(time)); |
|
| 137 |
inputSignal=amps.*inputSignal; |
|
| 138 |
inputSignal=sum(inputSignal, 1); |
|
| 139 |
% apply ramps |
|
| 140 |
% catch rampTime error |
|
| 141 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 142 |
rampTime=dt:dt:rampDuration; |
|
| 143 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 144 |
ones(1,length(time)-length(rampTime))]; |
|
| 145 |
inputSignal=inputSignal.*ramp; |
|
| 146 |
ramp=fliplr(ramp); |
|
| 147 |
inputSignal=inputSignal.*ramp; |
|
| 148 |
% add silence |
|
| 149 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 150 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 151 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 152 |
|
|
| 153 |
%% TEN noise input simple or mixed |
|
| 154 |
[noise sampleRate]=wavread('TEN.wav');
|
|
| 155 |
dt=1/sampleRate; |
|
| 156 |
noise=noise(:,1); |
|
| 157 |
targetRMS=20e-6*10^(noiseLevel/20); |
|
| 158 |
rms=(mean(noise.^2))^0.5; |
|
| 159 |
amp=targetRMS/rms; |
|
| 160 |
noise=noise*amp; |
|
| 161 |
inputSignal=inputSignal+noise(1:length(inputSignal))'; |
|
| 162 |
end |
|
| 163 |
|
|
| 164 |
|
|
| 165 |
%% run the model |
|
| 166 |
tic |
|
| 167 |
fprintf('\n')
|
|
| 168 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 169 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 170 |
disp('Computing ...')
|
|
| 171 |
|
|
| 172 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 173 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 174 |
|
|
| 175 |
|
|
| 176 |
%% the model run is now complete. Now display the results |
|
| 177 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 178 |
figure(97) |
|
| 179 |
title (['tones / noise levels: ' num2str([leveldBSPL noiseLevel])]) |
|
| 180 |
if strcmp(signalType,'tones') |
|
| 181 |
disp(['duration=' num2str(duration)]) |
|
| 182 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 183 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 184 |
global DRNLParams |
|
| 185 |
disp(['attenuation factor =' ... |
|
| 186 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 187 |
disp(['attenuation factor (probability)=' ... |
|
| 188 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 189 |
disp(AN_spikesOrProbability) |
|
| 190 |
end |
|
| 191 |
disp(paramChanges) |
|
| 192 |
toc |
|
| 193 |
path(restorePath) |
|
| 194 |
|
|
| userProgramsRM/test_MAP1_14RAM.m | ||
|---|---|---|
| 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 |
% switch off all efferent effects and then play with DRNL params |
|
| 36 |
paramChanges={...
|
|
| 37 |
'DRNLParams.rateToAttenuationFactorProb = 0.00; ',... |
|
| 38 |
'OMEParams.rateToAttenuationFactorProb=0.0;', ... |
|
| 39 |
'DRNLParams.ctBMdB = -20;'... |
|
| 40 |
'DRNLParams.g=1000;'... |
|
| 41 |
'DRNLParams.linCFs=7000;'... |
|
| 42 |
'DRNLParams.linBWs=3500;'... |
|
| 43 |
}; |
|
| 44 |
|
|
Also available in: Unified diff