Revision 38:c2204b18f4a2 testPrograms
| testPrograms/LiebermanMOCdata.m | ||
|---|---|---|
| 1 |
function LibermanData= LiebermanMOCdata |
|
| 2 |
|
|
| 3 |
LibermanData=[ |
|
| 4 |
2 0.2; |
|
| 5 |
2.1 0.19; |
|
| 6 |
2.2 0.18; |
|
| 7 |
2.3 0.18; |
|
| 8 |
2.4 0.16; |
|
| 9 |
2.5 0.15; |
|
| 10 |
2.6 0.15; |
|
| 11 |
2.7 0.15; |
|
| 12 |
2.8 0.12; |
|
| 13 |
2.9 0.12; |
|
| 14 |
3 0.1; |
|
| 15 |
3.1 0.1; |
|
| 16 |
3.2 0.05; |
|
| 17 |
3.3 0.05; |
|
| 18 |
3.4 0; |
|
| 19 |
3.5 -0.1; |
|
| 20 |
3.6 -0.4; |
|
| 21 |
3.7 -1.2; |
|
| 22 |
3.8 -1.6; |
|
| 23 |
3.9 -1.8; |
|
| 24 |
4 -1.85; |
|
| 25 |
4.1 -2; |
|
| 26 |
4.2 -2.05; |
|
| 27 |
4.3 -2.05; |
|
| 28 |
4.4 -2.15; |
|
| 29 |
4.5 -2.2; |
|
| 30 |
4.6 -2.15; |
|
| 31 |
4.7 -2.1; |
|
| 32 |
4.8 -2.15; |
|
| 33 |
4.9 -2.2; |
|
| 34 |
5 -2.1; |
|
| 35 |
5.1 -2.1; |
|
| 36 |
5.2 -2.25; |
|
| 37 |
5.3 -2.1; |
|
| 38 |
5.4 -2.15; |
|
| 39 |
5.5 -2.1; |
|
| 40 |
5.6 -2.15; |
|
| 41 |
5.7 -2.1; |
|
| 42 |
5.8 -2.2; |
|
| 43 |
5.9 -2.05; |
|
| 44 |
6 -2.15; |
|
| 45 |
6.1 -2.05; |
|
| 46 |
6.2 -2; |
|
| 47 |
6.3 -2.2; |
|
| 48 |
6.4 -2.1; |
|
| 49 |
6.5 -2.05; |
|
| 50 |
6.6 -2.05; |
|
| 51 |
6.7 -2.05; |
|
| 52 |
6.8 -2.2; |
|
| 53 |
6.9 -2.1; |
|
| 54 |
7 -2.05; |
|
| 55 |
7.1 -2.05; |
|
| 56 |
7.2 -0.7; |
|
| 57 |
7.3 -0.1; |
|
| 58 |
7.4 0; |
|
| 59 |
7.5 0.1; |
|
| 60 |
7.6 0.2; |
|
| 61 |
7.7 0.35; |
|
| 62 |
7.8 0.2; |
|
| 63 |
7.9 0.15; |
|
| 64 |
8 0.2; |
|
| 65 |
8.1 0.15; |
|
| 66 |
8.2 0.15; |
|
| 67 |
8.3 0.15; |
|
| 68 |
8.4 0.12; |
|
| 69 |
8.5 0.1; |
|
| 70 |
8.6 0.09; |
|
| 71 |
8.7 0.08; |
|
| 72 |
8.8 0.07; |
|
| 73 |
8.9 0.06; |
|
| 74 |
9 0.05; |
|
| 75 |
]; |
|
| 76 |
figure(98), subplot(2,1,2), hold on |
|
| 77 |
scalar=-15; |
|
| 78 |
plot(LibermanData(:,1)-2.5,scalar*LibermanData(:,2)) |
|
| 79 |
|
|
| testPrograms/LiebermanMOCtest.m | ||
|---|---|---|
| 1 |
function LiebermanMOCtest |
|
| 2 |
|
|
| 3 |
% In test_MAP1_14.m set these parameters |
|
| 4 |
|
|
| 5 |
% AN_spikesOrProbability='spikes'; |
|
| 6 |
|
|
| 7 |
% global dt ANdt savedBFlist saveAN_spikesOrProbability saveMAPparamsName... |
|
| 8 |
% savedInputSignal OMEextEarPressure TMoutput OMEoutput ARattenuation ... |
|
| 9 |
% DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
|
| 10 |
% IHCoutput ANprobRateOutput ANoutput savePavailable ANtauCas ... |
|
| 11 |
% CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates ... |
|
| 12 |
% MOCattenuation |
|
| 13 |
global dt ANdt saveAN_spikesOrProbability ANprobRateOutput ICoutput |
|
| 14 |
|
|
| 15 |
global DRNLParams |
|
| 16 |
|
|
| 17 |
LibermanData=[ |
|
| 18 |
2 0.2; |
|
| 19 |
2.1 0.19;2.2 0.18;2.3 0.18;2.4 0.16;2.5 0.15;2.6 0.15;2.7 0.15; |
|
| 20 |
2.8 0.12;2.9 0.12;3 0.1;3.1 0.1;3.2 0.05;3.3 0.05;3.4 0;3.5 -0.1; |
|
| 21 |
3.6 -0.4;3.7 -1.2;3.8 -1.6;3.9 -1.8;4 -1.85;4.1 -2;4.2 -2.05; |
|
| 22 |
4.3 -2.05;4.4 -2.15;4.5 -2.2;4.6 -2.15;4.7 -2.1;4.8 -2.15;4.9 -2.2; |
|
| 23 |
5 -2.1;5.1 -2.1;5.2 -2.25;5.3 -2.1;5.4 -2.15;5.5 -2.1;5.6 -2.15; |
|
| 24 |
5.7 -2.1;5.8 -2.2;5.9 -2.05;6 -2.15;6.1 -2.05;6.2 -2;6.3 -2.2;6.4 -2.1; |
|
| 25 |
6.5 -2.05;6.6 -2.05;6.7 -2.05;6.8 -2.2;6.9 -2.1;7 -2.05;7.1 -2.05;7.2 -0.7; |
|
| 26 |
7.3 -0.1;7.4 0;7.5 0.1;7.6 0.2;7.7 0.35;7.8 0.2;7.9 0.15;8 0.2;8.1 0.15;8.2 0.15; |
|
| 27 |
8.3 0.15;8.4 0.12;8.5 0.1;8.6 0.09;8.7 0.08;8.8 0.07;8.9 0.06;9 0.05; |
|
| 28 |
]; |
|
| 29 |
|
|
| 30 |
restorePath=path; |
|
| 31 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 32 |
['..' filesep 'utilities']) |
|
| 33 |
|
|
| 34 |
%% #1 parameter file name |
|
| 35 |
MAPparamsName='Normal'; |
|
| 36 |
|
|
| 37 |
|
|
| 38 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 39 |
AN_spikesOrProbability='spikes'; |
|
| 40 |
% or |
|
| 41 |
% AN_spikesOrProbability='probability'; |
|
| 42 |
|
|
| 43 |
|
|
| 44 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 45 |
signalType= 'tones'; |
|
| 46 |
sampleRate= 50000; |
|
| 47 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 48 |
toneFrequency= 1000; % or a pure tone (Hz) |
|
| 49 |
duration=3.6; % Lieberman test |
|
| 50 |
beginSilence=1; % 1 for Lieberman |
|
| 51 |
endSilence=1; % 1 for Lieberman |
|
| 52 |
|
|
| 53 |
%% #4 rms level |
|
| 54 |
% signal details |
|
| 55 |
leveldBSPL= 80; % dB SPL (80 for Lieberman) |
|
| 56 |
|
|
| 57 |
|
|
| 58 |
%% #5 number of channels in the model |
|
| 59 |
|
|
| 60 |
numChannels=1; |
|
| 61 |
BFlist=toneFrequency; |
|
| 62 |
|
|
| 63 |
|
|
| 64 |
%% #6 change model parameters |
|
| 65 |
paramChanges={};
|
|
| 66 |
|
|
| 67 |
%% delare 'showMap' options to control graphical output |
|
| 68 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 69 |
showMapOptions.showModelOutput=1; % plot of all stages |
|
| 70 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 71 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 72 |
showMapOptions.showEfferent=1; % tracks of AR and MOC |
|
| 73 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 74 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 75 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 76 |
|
|
| 77 |
%% Generate stimuli |
|
| 78 |
|
|
| 79 |
% Create pure tone stimulus |
|
| 80 |
dt=1/sampleRate; % seconds |
|
| 81 |
time=dt: dt: duration; |
|
| 82 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 83 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 84 |
inputSignal=amp*inputSignal; |
|
| 85 |
% apply ramps |
|
| 86 |
% catch rampTime error |
|
| 87 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 88 |
rampTime=dt:dt:rampDuration; |
|
| 89 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 90 |
ones(1,length(time)-length(rampTime))]; |
|
| 91 |
inputSignal=inputSignal.*ramp; |
|
| 92 |
ramp=fliplr(ramp); |
|
| 93 |
inputSignal=inputSignal.*ramp; |
|
| 94 |
% add silence |
|
| 95 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 96 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 97 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 98 |
|
|
| 99 |
%% run the model |
|
| 100 |
tic |
|
| 101 |
fprintf('\n')
|
|
| 102 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 103 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 104 |
disp('Computing ...')
|
|
| 105 |
|
|
| 106 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 107 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 108 |
|
|
| 109 |
|
|
| 110 |
%% the model run is now complete. Now display the results |
|
| 111 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 112 |
|
|
| 113 |
if strcmp(signalType,'tones') |
|
| 114 |
disp(['duration=' num2str(duration)]) |
|
| 115 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 116 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 117 |
disp(['attenuation factor =' ... |
|
| 118 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 119 |
disp(['attenuation factor (probability)=' ... |
|
| 120 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 121 |
disp(AN_spikesOrProbability) |
|
| 122 |
end |
|
| 123 |
disp(paramChanges) |
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
%% superimpose Lieberman data |
|
| 128 |
|
|
| 129 |
global DRNLParams |
|
| 130 |
% scale up DPOAE results to a maximum of whatever MAP_14 uses as its |
|
| 131 |
% maximum |
|
| 132 |
scalar=-DRNLParams.minMOCattenuationdB/min(LibermanData(:,2)); |
|
| 133 |
|
|
| 134 |
figure(98), subplot(2,1,2), hold on |
|
| 135 |
plot(LibermanData(:,1)-2.5,scalar*LibermanData(:,2),'r:') |
|
| 136 |
|
|
| 137 |
PSTHbinwidth=0.001; |
|
| 138 |
|
|
| 139 |
if strcmp(saveAN_spikesOrProbability,'probability') |
|
| 140 |
PSTH=UTIL_PSTHmaker... |
|
| 141 |
(ANprobRateOutput(2,:), ANdt, PSTHbinwidth)*ANdt/PSTHbinwidth; |
|
| 142 |
else |
|
| 143 |
PSTH=UTIL_PSTHmaker(ICoutput(2,:), dt, PSTHbinwidth)*dt/PSTHbinwidth; |
|
| 144 |
end |
|
| 145 |
|
|
| 146 |
time=PSTHbinwidth:PSTHbinwidth:PSTHbinwidth*length(PSTH); |
|
| 147 |
figure(89) |
|
| 148 |
plot(time, PSTH) |
|
| 149 |
set(gcf,'name', 'Lieberman') |
|
| 150 |
title(saveAN_spikesOrProbability) |
|
| 151 |
|
|
| 152 |
toc |
|
| 153 |
path(restorePath) |
|
| 154 |
|
|
| 155 |
% figure(88), plot(MOCattenuation) |
|
| testPrograms/MAPtwoToneDemo.m | ||
|---|---|---|
| 1 |
% function MAPtwoToneDemo |
|
| 2 |
% |
|
| 3 |
% Demonstration of two-tone suppression in the AN using a |
|
| 4 |
% F1 tone suppressed by a 1.5*F1 kHz tone |
|
| 5 |
% |
|
| 6 |
|
|
| 7 |
global ANprobRateOutput DRNLoutput |
|
| 8 |
dbstop if error |
|
| 9 |
restorePath=path; |
|
| 10 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 11 |
['..' filesep 'utilities']) |
|
| 12 |
figure(5), clf |
|
| 13 |
|
|
| 14 |
disp('')
|
|
| 15 |
primaryToneFrequency=2000; |
|
| 16 |
|
|
| 17 |
probedBs=[-100 20 :20: 90]; |
|
| 18 |
nProbeLevels=length(probedBs); |
|
| 19 |
|
|
| 20 |
% disp(['F1 F1 level= ' num2str([primaryToneFrequency probedB])]) |
|
| 21 |
|
|
| 22 |
suppressorLevels=0:10:80; |
|
| 23 |
suppressorLevels=0:10:80; |
|
| 24 |
|
|
| 25 |
lowestBF=250; highestBF= 8000; numChannels=21; |
|
| 26 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 27 |
|
|
| 28 |
suppressorFrequencies=BFlist; |
|
| 29 |
BFchannel=find(BFlist==primaryToneFrequency); |
|
| 30 |
|
|
| 31 |
sampleRate= 40000; % Hz (higher sample rate needed for BF>8000 Hz) |
|
| 32 |
dt=1/sampleRate; % seconds |
|
| 33 |
|
|
| 34 |
duration=.050; % seconds |
|
| 35 |
tone2Duration=duration/2; % s |
|
| 36 |
startSilenceDuration=0.010; |
|
| 37 |
startSilence=... |
|
| 38 |
zeros(1,startSilenceDuration*sampleRate); |
|
| 39 |
suppressorStartsPTR=... |
|
| 40 |
round((startSilenceDuration+duration/2)*sampleRate); |
|
| 41 |
|
|
| 42 |
probedBCount=0; |
|
| 43 |
for probedB=probedBs |
|
| 44 |
probedBCount=probedBCount+1; |
|
| 45 |
|
|
| 46 |
peakResponse= zeros(length(suppressorLevels),length(suppressorFrequencies)); |
|
| 47 |
suppFreqCount=0; |
|
| 48 |
for suppressorFrequency=suppressorFrequencies |
|
| 49 |
suppFreqCount=suppFreqCount+1; |
|
| 50 |
|
|
| 51 |
suppressorLevelCount=0; |
|
| 52 |
for suppressorDB=suppressorLevels |
|
| 53 |
suppressorLevelCount=suppressorLevelCount+1; |
|
| 54 |
|
|
| 55 |
% primary + suppressor |
|
| 56 |
primaryLevelDB=probedB; |
|
| 57 |
suppressorLevelDB=suppressorDB; |
|
| 58 |
|
|
| 59 |
|
|
| 60 |
% primary BF tone |
|
| 61 |
time1=dt: dt: duration; |
|
| 62 |
amp=10^(primaryLevelDB/20)*28e-6; |
|
| 63 |
inputSignal=amp*sin(2*pi*primaryToneFrequency*time1); |
|
| 64 |
rampDuration=.005; rampTime=dt:dt:rampDuration; |
|
| 65 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time1)-length(rampTime))]; |
|
| 66 |
inputSignal=inputSignal.*ramp; |
|
| 67 |
inputSignal=inputSignal.*fliplr(ramp); |
|
| 68 |
|
|
| 69 |
% suppressor |
|
| 70 |
time2= dt: dt: tone2Duration; |
|
| 71 |
% B: tone on |
|
| 72 |
amp=10^(suppressorLevelDB/20)*28e-6; |
|
| 73 |
inputSignal2=amp*sin(2*pi*suppressorFrequency*time2); |
|
| 74 |
rampDuration=.005; rampTime=dt:dt:rampDuration; |
|
| 75 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time2)-length(rampTime))]; |
|
| 76 |
inputSignal2=inputSignal2.*ramp; |
|
| 77 |
inputSignal2=inputSignal2.*fliplr(ramp); |
|
| 78 |
% A: initial silence (delay to suppressor) |
|
| 79 |
silence=zeros(1,length(time2)); |
|
| 80 |
inputSignal2=[silence inputSignal2]; |
|
| 81 |
|
|
| 82 |
% add tone and suppressor components |
|
| 83 |
inputSignal=inputSignal+inputSignal2; |
|
| 84 |
|
|
| 85 |
inputSignal=... |
|
| 86 |
[startSilence inputSignal ]; |
|
| 87 |
|
|
| 88 |
% run MAP |
|
| 89 |
MAPparamsName='Normal'; |
|
| 90 |
AN_spikesOrProbability='probability'; |
|
| 91 |
paramChanges={'IHCpreSynapseParams.tauCa=80e-6;'};
|
|
| 92 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 93 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 94 |
|
|
| 95 |
response=ANprobRateOutput; |
|
| 96 |
peakResponse(suppressorLevelCount,suppFreqCount)=... |
|
| 97 |
mean(response(BFchannel,suppressorStartsPTR:end)); |
|
| 98 |
disp(['F2 level= ', num2str([suppressorFrequency suppressorDB ... |
|
| 99 |
peakResponse(suppressorLevelCount,suppFreqCount)])]) |
|
| 100 |
|
|
| 101 |
|
|
| 102 |
%% make movie |
|
| 103 |
figure(6), subplot(4,1,2) |
|
| 104 |
axis tight |
|
| 105 |
set(gca,'nextplot','replacechildren'); |
|
| 106 |
plot(dt:dt:dt*length(inputSignal), inputSignal, 'k') |
|
| 107 |
title('probe - suppressor')
|
|
| 108 |
ylim([-.5 .5]) |
|
| 109 |
|
|
| 110 |
figure(6), subplot(2,1,2) |
|
| 111 |
PSTHbinWidth=0.010; |
|
| 112 |
PSTH= UTIL_PSTHmakerb(... |
|
| 113 |
response, dt, PSTHbinWidth); |
|
| 114 |
[nY nX]=size(PSTH); |
|
| 115 |
time=PSTHbinWidth*(0:nX-1); |
|
| 116 |
surf(time, BFlist, PSTH) |
|
| 117 |
zlim([0 500]), |
|
| 118 |
caxis([0 500]) |
|
| 119 |
shading interp |
|
| 120 |
colormap(jet) |
|
| 121 |
set(gca, 'yScale','log') |
|
| 122 |
xlim([0 max(time)+dt]) |
|
| 123 |
ylim([0 max(BFlist)]) |
|
| 124 |
view([0 90]) % view([-8 68]) |
|
| 125 |
title('probe - suppressor')
|
|
| 126 |
pause(0.05) |
|
| 127 |
end |
|
| 128 |
end |
|
| 129 |
|
|
| 130 |
%% plot matrix |
|
| 131 |
|
|
| 132 |
peakResponse=peakResponse/peakResponse(1,1); |
|
| 133 |
|
|
| 134 |
figure(5), subplot(2,nProbeLevels, probedBCount) |
|
| 135 |
surf(suppressorFrequencies,suppressorLevels,peakResponse) |
|
| 136 |
shading interp |
|
| 137 |
view([0 90]) |
|
| 138 |
set(gca,'Xscale','log') |
|
| 139 |
xlim([min(suppressorFrequencies) max(suppressorFrequencies)]) |
|
| 140 |
set(gca,'Xtick', [1000 4000],'xticklabel',{'1000', '4000'})
|
|
| 141 |
ylim([min(suppressorLevels) max(suppressorLevels)]) |
|
| 142 |
|
|
| 143 |
subplot(2,nProbeLevels,nProbeLevels+probedBCount) |
|
| 144 |
contour(suppressorFrequencies,suppressorLevels,peakResponse, ... |
|
| 145 |
[.1:.1:.9 1.1] ) |
|
| 146 |
set(gca,'Xscale','log') |
|
| 147 |
set(gca,'Xtick', [1000 4000],'xticklabel',{'1000', '4000'})
|
|
| 148 |
set(gcf, 'name',['primaryToneFrequency= ' num2str(primaryToneFrequency)]) |
|
| 149 |
title([num2str(probedB) ' dB']) |
|
| 150 |
end |
|
| 151 |
|
|
| 152 |
path=restorePath; |
|
| testPrograms/demoTwisterProbability.m | ||
|---|---|---|
| 63 | 63 |
showMapOptions.printFiringRates=1; |
| 64 | 64 |
showMapOptions.showACF=0; |
| 65 | 65 |
showMapOptions.showEfferent=0; |
| 66 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 66 |
showMapOptions.surfAN=1; % 3D plot of HSR response |
|
| 67 |
showMapOptions.PSTHbinwidth=0.002; % 3D plot of HSR response |
|
| 68 |
showMapOptions.view=[-14 76]; % 3D plot of HSR response |
|
| 67 | 69 |
|
| 68 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 70 |
|
|
| 71 |
UTIL_showMAP(showMapOptions) |
|
| 69 | 72 |
|
| 70 | 73 |
toc |
| 71 | 74 |
path(restorePath) |
| testPrograms/demoTwisterSpikes.m | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
%% #5 number of channels in the model |
| 29 | 29 |
% 21-channel model (log spacing) |
| 30 |
numChannels=21;
|
|
| 30 |
numChannels=11;
|
|
| 31 | 31 |
lowestBF=250; highestBF= 8000; |
| 32 | 32 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
| 33 | 33 |
|
| 34 | 34 |
|
| 35 | 35 |
%% #6 change model parameters |
| 36 |
paramChanges=[];
|
|
| 36 |
paramChanges={};
|
|
| 37 | 37 |
|
| 38 | 38 |
%% delare showMap options |
| 39 | 39 |
showMapOptions=[]; % use defaults |
| ... | ... | |
| 45 | 45 |
showMapOptions.showACF=0; |
| 46 | 46 |
showMapOptions.showEfferent=0; |
| 47 | 47 |
showMapOptions.surfSpikes=0; |
| 48 |
showMapOptions.surfProbability=0; % 2D plot of HSR response
|
|
| 48 |
showMapOptions.surfAN=0; % 2D plot of HSR response
|
|
| 49 | 49 |
|
| 50 | 50 |
%% Generate stimuli |
| 51 | 51 |
[inputSignal sampleRate]=wavread(fileName); |
| ... | ... | |
| 69 | 69 |
|
| 70 | 70 |
|
| 71 | 71 |
% the model run is now complete. Now display the results |
| 72 |
UTIL_showMAP(showMapOptions, paramChanges)
|
|
| 72 |
UTIL_showMAP(showMapOptions) |
|
| 73 | 73 |
|
| 74 | 74 |
toc |
| 75 | 75 |
path(restorePath) |
| testPrograms/oldTestPrograms/LiebermanMOCdata.m | ||
|---|---|---|
| 1 |
function LibermanData= LiebermanMOCdata |
|
| 2 |
|
|
| 3 |
LibermanData=[ |
|
| 4 |
2 0.2; |
|
| 5 |
2.1 0.19; |
|
| 6 |
2.2 0.18; |
|
| 7 |
2.3 0.18; |
|
| 8 |
2.4 0.16; |
|
| 9 |
2.5 0.15; |
|
| 10 |
2.6 0.15; |
|
| 11 |
2.7 0.15; |
|
| 12 |
2.8 0.12; |
|
| 13 |
2.9 0.12; |
|
| 14 |
3 0.1; |
|
| 15 |
3.1 0.1; |
|
| 16 |
3.2 0.05; |
|
| 17 |
3.3 0.05; |
|
| 18 |
3.4 0; |
|
| 19 |
3.5 -0.1; |
|
| 20 |
3.6 -0.4; |
|
| 21 |
3.7 -1.2; |
|
| 22 |
3.8 -1.6; |
|
| 23 |
3.9 -1.8; |
|
| 24 |
4 -1.85; |
|
| 25 |
4.1 -2; |
|
| 26 |
4.2 -2.05; |
|
| 27 |
4.3 -2.05; |
|
| 28 |
4.4 -2.15; |
|
| 29 |
4.5 -2.2; |
|
| 30 |
4.6 -2.15; |
|
| 31 |
4.7 -2.1; |
|
| 32 |
4.8 -2.15; |
|
| 33 |
4.9 -2.2; |
|
| 34 |
5 -2.1; |
|
| 35 |
5.1 -2.1; |
|
| 36 |
5.2 -2.25; |
|
| 37 |
5.3 -2.1; |
|
| 38 |
5.4 -2.15; |
|
| 39 |
5.5 -2.1; |
|
| 40 |
5.6 -2.15; |
|
| 41 |
5.7 -2.1; |
|
| 42 |
5.8 -2.2; |
|
| 43 |
5.9 -2.05; |
|
| 44 |
6 -2.15; |
|
| 45 |
6.1 -2.05; |
|
| 46 |
6.2 -2; |
|
| 47 |
6.3 -2.2; |
|
| 48 |
6.4 -2.1; |
|
| 49 |
6.5 -2.05; |
|
| 50 |
6.6 -2.05; |
|
| 51 |
6.7 -2.05; |
|
| 52 |
6.8 -2.2; |
|
| 53 |
6.9 -2.1; |
|
| 54 |
7 -2.05; |
|
| 55 |
7.1 -2.05; |
|
| 56 |
7.2 -0.7; |
|
| 57 |
7.3 -0.1; |
|
| 58 |
7.4 0; |
|
| 59 |
7.5 0.1; |
|
| 60 |
7.6 0.2; |
|
| 61 |
7.7 0.35; |
|
| 62 |
7.8 0.2; |
|
| 63 |
7.9 0.15; |
|
| 64 |
8 0.2; |
|
| 65 |
8.1 0.15; |
|
| 66 |
8.2 0.15; |
|
| 67 |
8.3 0.15; |
|
| 68 |
8.4 0.12; |
|
| 69 |
8.5 0.1; |
|
| 70 |
8.6 0.09; |
|
| 71 |
8.7 0.08; |
|
| 72 |
8.8 0.07; |
|
| 73 |
8.9 0.06; |
|
| 74 |
9 0.05; |
|
| 75 |
]; |
|
| 76 |
figure(98), subplot(2,1,2), hold on |
|
| 77 |
scalar=-15; |
|
| 78 |
plot(LibermanData(:,1)-2.5,scalar*LibermanData(:,2)) |
|
| 79 |
|
|
| testPrograms/oldTestPrograms/MAPtwoToneDemo1D.m | ||
|---|---|---|
| 1 |
% function MAPtwoToneDemo |
|
| 2 |
% Not for distribution but code worth keeping |
|
| 3 |
% Demonstration of two-tone suppression in the AN using a |
|
| 4 |
% single channel |
|
| 5 |
% |
|
| 6 |
|
|
| 7 |
dbstop if error |
|
| 8 |
% create access to all MAP 1_8 facilities |
|
| 9 |
% addpath ('..\modules', '..\utilities', '..\parameterStore', '..\wavFileStore' , '..\testPrograms')
|
|
| 10 |
addpath (['..' filesep 'modules'], ['..' filesep 'utilities'], ['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'] , ['..' filesep 'testPrograms']) |
|
| 11 |
|
|
| 12 |
moduleSequence= 1:7; % up to the AN |
|
| 13 |
figure(3), clf |
|
| 14 |
primaryToneFrequency=2000; |
|
| 15 |
suppressorFrequency=primaryToneFrequency*1.5; |
|
| 16 |
|
|
| 17 |
primaryDB=30; |
|
| 18 |
suppressors=20:10:80; |
|
| 19 |
frameCount=0; |
|
| 20 |
for suppressorDB=suppressors |
|
| 21 |
frameCount=frameCount+1; |
|
| 22 |
lowestBF=1000; highestBF= 5000; numChannels=30; |
|
| 23 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 24 |
BFlist=2000; |
|
| 25 |
duration=.020; % seconds |
|
| 26 |
sampleRate= 40000; % Hz (higher sample rate needed for BF>8000 Hz) |
|
| 27 |
dt=1/sampleRate; % seconds |
|
| 28 |
|
|
| 29 |
% for conditionNo=1:3 % probe alone/ suppressor alone/ combined |
|
| 30 |
for conditionNo=1:3 % probe alone/ suppressor alone/ combined |
|
| 31 |
switch conditionNo |
|
| 32 |
case 1 |
|
| 33 |
primaryLevelDB=primaryDB; |
|
| 34 |
suppressorLevelDB= -100; |
|
| 35 |
plotGuide.subPlotNo= 1; % initialize subplot count |
|
| 36 |
figureTitle=['probe alone: ' num2str(primaryToneFrequency) ' Hz; ' num2str(primaryLevelDB) ' dB SPL']; |
|
| 37 |
|
|
| 38 |
case 2 |
|
| 39 |
primaryLevelDB=-100; |
|
| 40 |
suppressorLevelDB=suppressorDB; |
|
| 41 |
plotGuide.subPlotNo= 2; % initialize subplot count |
|
| 42 |
figureTitle=['suppressor alone: ' num2str(suppressorFrequency) ' Hz; ' num2str(suppressorLevelDB) ' dB SPL']; |
|
| 43 |
case 3 |
|
| 44 |
primaryLevelDB=primaryDB; |
|
| 45 |
suppressorLevelDB=suppressorDB; |
|
| 46 |
plotGuide.subPlotNo= 3; % initialize subplot count |
|
| 47 |
figureTitle=['probe + suppressor']; |
|
| 48 |
end |
|
| 49 |
|
|
| 50 |
% primary BF tone |
|
| 51 |
time1=dt: dt: duration; |
|
| 52 |
amp=10^(primaryLevelDB/20)*28e-6; |
|
| 53 |
inputSignal=amp*sin(2*pi*primaryToneFrequency*time1); |
|
| 54 |
rampDuration=.005; rampTime=dt:dt:rampDuration; |
|
| 55 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time1)-length(rampTime))]; |
|
| 56 |
inputSignal=inputSignal.*ramp; |
|
| 57 |
inputSignal=inputSignal.*fliplr(ramp); |
|
| 58 |
|
|
| 59 |
% suppressor |
|
| 60 |
tone2Duration=duration/2; % s |
|
| 61 |
time2= dt: dt: tone2Duration; |
|
| 62 |
% B: tone on |
|
| 63 |
amp=10^(suppressorLevelDB/20)*28e-6; |
|
| 64 |
inputSignal2=amp*sin(2*pi*suppressorFrequency*time2); |
|
| 65 |
rampDuration=.005; rampTime=dt:dt:rampDuration; |
|
| 66 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time2)-length(rampTime))]; |
|
| 67 |
inputSignal2=inputSignal2.*ramp; |
|
| 68 |
% A: initial silence (delay to suppressor) |
|
| 69 |
silence=zeros(1,length(time2)); |
|
| 70 |
inputSignal2=[silence inputSignal2]; |
|
| 71 |
|
|
| 72 |
% add tone and suppressor components |
|
| 73 |
inputSignal=inputSignal+inputSignal2; |
|
| 74 |
|
|
| 75 |
% specify model parameters |
|
| 76 |
method=MAPparamsDEMO(BFlist, sampleRate); |
|
| 77 |
% parameter change (must be global to take effect) |
|
| 78 |
global AN_IHCsynapseParams |
|
| 79 |
AN_IHCsynapseParams.mode= 'probability'; |
|
| 80 |
% method.useEfferent=0; |
|
| 81 |
|
|
| 82 |
method.plotGraphs= 1; % please plot |
|
| 83 |
|
|
| 84 |
figure(4), subplot(3,1,conditionNo) |
|
| 85 |
plot(time1, inputSignal, 'k')% ************* |
|
| 86 |
|
|
| 87 |
[ANresponse, method, A]=MAPsequenceSeg(inputSignal, method, moduleSequence); |
|
| 88 |
response{conditionNo}=ANresponse;
|
|
| 89 |
% F(frameCount) = getframe(gcf); |
|
| 90 |
end |
|
| 91 |
|
|
| 92 |
% peakResponse=max(max([response{1} response{2} response{3}]));
|
|
| 93 |
% figure(3), subplot(4,1,1) |
|
| 94 |
% mesh((response{1}), [0 peakResponse])
|
|
| 95 |
% title(['primary: ' num2str(primaryDB) ' dB SPL']) |
|
| 96 |
% zlim([0 5000]), view([-28 36]) |
|
| 97 |
% |
|
| 98 |
% figure(3), subplot(4,1,2) |
|
| 99 |
% mesh((response{2}), [0 peakResponse])
|
|
| 100 |
% title(['suppressor: ' num2str(suppressorDB) ' dB SPL']) |
|
| 101 |
% zlim([0 5000]), view([-28 36]) |
|
| 102 |
% |
|
| 103 |
% figure(3), subplot(4,1,3) |
|
| 104 |
% mesh((response{3}), [0 peakResponse])
|
|
| 105 |
% title([' primary + suppressor ']) |
|
| 106 |
% zlim([0 5000]), view([-28 36]) |
|
| 107 |
% |
|
| 108 |
% figure(3), subplot(4,1,4) |
|
| 109 |
% sum= response{3}-response{1}-response{2};
|
|
| 110 |
% mesh(sum) |
|
| 111 |
% zlim([-2000 2000]) |
|
| 112 |
% title(' difference matrix (combined - primary - suppressor)')
|
|
| 113 |
% view([-28 20]) |
|
| 114 |
% disp( [num2str([ suppressorDB primaryDB max(max(sum))])] ) |
|
| 115 |
% |
|
| 116 |
% colormap(jet) |
|
| 117 |
pause(1) |
|
| 118 |
end |
|
| 119 |
|
|
| 120 |
figure(4) |
|
| 121 |
xlabel('time (s)')
|
|
| 122 |
figure(3) |
|
| 123 |
xlabel('time (s)')
|
|
| 124 |
|
|
| 125 |
% figure(99), movie(F, 1, 1) |
|
| 126 |
% UTIL_showAllMAPStructures |
|
| testPrograms/openGlobals.m | ||
|---|---|---|
| 1 |
global OMEParams DRNLParams IHC_cilia_RPParams IHCpreSynapseParams |
|
| 2 |
global AN_IHCsynapseParams MacGregorParams MacGregorMultiParams |
|
| 3 |
|
|
| 4 |
% All of the results of this function are stored as global |
|
| 5 |
global savedParamChanges savedBFlist saveAN_spikesOrProbability ... |
|
| 6 |
saveMAPparamsName savedInputSignal dt dtSpikes ... |
|
| 7 |
OMEextEarPressure TMoutput OMEoutput DRNLoutput... |
|
| 8 |
IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
|
| 9 |
IHCoutput ANprobRateOutput ANoutput savePavailable saveNavailable ... |
|
| 10 |
ANtauCas CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates... |
|
| 11 |
MOCattenuation ARattenuation |
|
| 12 |
|
|
| testPrograms/repeatTester.m | ||
|---|---|---|
| 1 |
restorePath=path; |
|
| 2 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 3 |
['..' filesep 'utilities']) |
|
| 4 |
|
|
| 5 |
global OMEParams DRNLParams IHC_cilia_RPParams IHCpreSynapseParams |
|
| 6 |
global AN_IHCsynapseParams MacGregorParams MacGregorMultiParams |
|
| 7 |
global dt ANdt savedBFlist saveAN_spikesOrProbability saveMAPparamsName... |
|
| 8 |
savedInputSignal OMEextEarPressure TMoutput OMEoutput ARattenuation ... |
|
| 9 |
DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
|
| 10 |
IHCoutput ANprobRateOutput ANoutput savePavailable ANtauCas ... |
|
| 11 |
CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates ... |
|
| 12 |
MOCattenuation |
|
| 13 |
|
|
| 14 |
signalCharacteristics.type='tones'; |
|
| 15 |
signalCharacteristicssignalCharacteristics.sampleRate=50000; |
|
| 16 |
signalCharacteristics.duration= 1; |
|
| 17 |
signalCharacteristics.rampDuration=0.05; |
|
| 18 |
signalCharacteristics.beginSilence=0.05; |
|
| 19 |
signalCharacteristics.endSilence=0.05; |
|
| 20 |
signalCharacteristics.toneFrequency=1000; |
|
| 21 |
signalCharacteristics.leveldBSPL=50; |
|
| 22 |
|
|
| 23 |
showMapOptions.printModelParameters=0; % prints all parameters |
|
| 24 |
showMapOptions.showModelOutput=0; % plot of all stages |
|
| 25 |
showMapOptions.printFiringRates=0; % prints stage activity levels |
|
| 26 |
showMapOptions.showACF=0; % shows SACF (probability only) |
|
| 27 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 28 |
showMapOptions.surfProbability=0; % 2D plot of HSR response |
|
| 29 |
showMapOptions.surfSpikes=0; % 2D plot of spikes histogram |
|
| 30 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 31 |
|
|
| 32 |
tic |
|
| 33 |
fprintf('\n')
|
|
| 34 |
disp('Computing ...')
|
|
| 35 |
|
|
| 36 |
levels=80:10:100; |
|
| 37 |
figure(10), clf |
|
| 38 |
|
|
| 39 |
for level=levels |
|
| 40 |
signalCharacteristics.leveldBSPL=level; |
|
| 41 |
% MAPrunner(MAPparamsName, AN_spikesOrProbability, ... |
|
| 42 |
% signalCharacteristics, paramChanges, showMapOptions) |
|
| 43 |
MAPrunner('Normal', 'spikes', ...
|
|
| 44 |
signalCharacteristics, {}, showMapOptions)
|
|
| 45 |
ARmin=min(ARattenuation); |
|
| 46 |
disp([num2str(level) ':' num2str(ARmin)]) |
|
| 47 |
time=dt:dt:dt*length(ARattenuation); |
|
| 48 |
hold on, plot(time,(1-ARattenuation)/(1-min(ARattenuation))) |
|
| 49 |
pause(0.1) |
|
| 50 |
end |
|
| 51 |
|
|
| 52 |
path(restorePath) |
|
| testPrograms/runMAP1_14.m | ||
|---|---|---|
| 1 |
function runMAP1_14 |
|
| 2 |
% runMAP1_14 is a general purpose test routine that can be adjusted to |
|
| 3 |
% explore different applications of MAP1_14 |
|
| 4 |
% |
|
| 5 |
% It is also designed as 'starter' code for building new applications. |
|
| 6 |
% |
|
| 7 |
% A range of options are supplied in the early part of the program |
|
| 8 |
% |
|
| 9 |
% #1 |
|
| 10 |
% Identify the file (in 'MAPparamsName') containing the model parameters |
|
| 11 |
% |
|
| 12 |
% #2 |
|
| 13 |
% Identify the kind of model required (in 'AN_spikesOrProbability'). |
|
| 14 |
% A full brainstem model ('spikes') can be computed or a shorter model
|
|
| 15 |
% ('probability') that computes only so far as the auditory nerve
|
|
| 16 |
% |
|
| 17 |
% #3 |
|
| 18 |
% Choose between a tone signal or file input (in 'signalType') |
|
| 19 |
% |
|
| 20 |
% #4 |
|
| 21 |
% Set the signal rms level (in leveldBSPL) |
|
| 22 |
% |
|
| 23 |
% #5 |
|
| 24 |
% Identify the channels in terms of their best frequencies in the vector |
|
| 25 |
% BFlist. |
|
| 26 |
% |
|
| 27 |
% #6 |
|
| 28 |
% Last minute changes to the model parameters can be made using |
|
| 29 |
% a cell array of strings, 'paramChanges'. |
|
| 30 |
|
|
| 31 |
dbstop if error |
|
| 32 |
restorePath=path; |
|
| 33 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 34 |
['..' filesep 'utilities']) |
|
| 35 |
|
|
| 36 |
%% #1 parameter file name |
|
| 37 |
MAPparamsName='Normal'; |
|
| 38 |
|
|
| 39 |
|
|
| 40 |
%% #2 probability (fast) or spikes (slow) representation: select one |
|
| 41 |
% AN_spikesOrProbability='spikes'; |
|
| 42 |
% or |
|
| 43 |
AN_spikesOrProbability='probability'; |
|
| 44 |
|
|
| 45 |
|
|
| 46 |
%% #3 A. pure tone, B. harmonic sequence or C. speech file input |
|
| 47 |
% comment out unwanted code |
|
| 48 |
|
|
| 49 |
% A. tone |
|
| 50 |
sampleRate= 95000; |
|
| 51 |
signalType= 'tones'; |
|
| 52 |
toneFrequency= 1000; % or a pure tone (Hz) |
|
| 53 |
duration=0.500; % seconds |
|
| 54 |
beginSilence=0.010; |
|
| 55 |
endSilence=0.020; |
|
| 56 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 57 |
|
|
| 58 |
% or |
|
| 59 |
% B. harmonic tone (Hz) - useful to demonstrate a broadband sound |
|
| 60 |
% sampleRate= 44100; |
|
| 61 |
% signalType= 'tones'; |
|
| 62 |
% toneFrequency= F0:F0:8000; |
|
| 63 |
% duration=0.500; % seconds |
|
| 64 |
% beginSilence=0.250; |
|
| 65 |
% endSilence=0.250; |
|
| 66 |
% F0=210; |
|
| 67 |
% rampDuration=.005; % raised cosine ramp (seconds) |
|
| 68 |
|
|
| 69 |
% or |
|
| 70 |
% C. signalType= 'file'; |
|
| 71 |
% fileName='twister_44kHz'; |
|
| 72 |
|
|
| 73 |
%% #4 rms level |
|
| 74 |
% signal details |
|
| 75 |
leveldBSPL= 80; % dB SPL (80 for Lieberman) |
|
| 76 |
|
|
| 77 |
%% #5 number of channels in the model |
|
| 78 |
% 21-channel model (log spacing) |
|
| 79 |
numChannels=21; |
|
| 80 |
lowestBF=100; highestBF= 6000; |
|
| 81 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 82 |
|
|
| 83 |
% or specify your own channel BFs |
|
| 84 |
% numChannels=1; |
|
| 85 |
% BFlist=toneFrequency; |
|
| 86 |
|
|
| 87 |
|
|
| 88 |
%% #6 change model parameters |
|
| 89 |
|
|
| 90 |
paramChanges={}; % no changes
|
|
| 91 |
|
|
| 92 |
% Parameter changes can be used to change one or more model parameters |
|
| 93 |
% *after* the MAPparams file has been read |
|
| 94 |
% Each string must have the same format as the corresponding line in the |
|
| 95 |
% file identified in 'MAPparamsName' |
|
| 96 |
% This example declares only one fiber type with a calcium clearance time |
|
| 97 |
% constant of 80e-6 s (HSR fiber) when the probability option is selected. |
|
| 98 |
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
|
|
| 99 |
% 'IHCpreSynapseParams.tauCa=86e-6; '}; |
|
| 100 |
paramChanges={ 'IHCpreSynapseParams.tauCa=86e-6; ',...
|
|
| 101 |
'DRNLParams.rateToAttenuationFactorProb = 0;'}; |
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
%% delare 'showMap' options to control graphical output |
|
| 106 |
% see UTIL_showMAP for more options |
|
| 107 |
showMapOptions.printModelParameters=1; % prints all parameters |
|
| 108 |
showMapOptions.showModelOutput=0; % plot of all stages |
|
| 109 |
showMapOptions.printFiringRates=1; % prints stage activity levels |
|
| 110 |
showMapOptions.showEfferent=0; % tracks of AR and MOC |
|
| 111 |
showMapOptions.surfAN=1; % 2D plot of HSR response |
|
| 112 |
|
|
| 113 |
if strcmp(signalType, 'file') |
|
| 114 |
% needed for labeling plot |
|
| 115 |
showMapOptions.fileName=fileName; |
|
| 116 |
else |
|
| 117 |
showMapOptions.fileName=[]; |
|
| 118 |
end |
|
| 119 |
|
|
| 120 |
%% Generate stimuli |
|
| 121 |
switch signalType |
|
| 122 |
case 'tones' |
|
| 123 |
% Create pure tone stimulus |
|
| 124 |
dt=1/sampleRate; % seconds |
|
| 125 |
time=dt: dt: duration; |
|
| 126 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 127 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 128 |
inputSignal=amp*inputSignal; |
|
| 129 |
% apply ramps |
|
| 130 |
% catch rampTime error |
|
| 131 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 132 |
rampTime=dt:dt:rampDuration; |
|
| 133 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 134 |
ones(1,length(time)-length(rampTime))]; |
|
| 135 |
inputSignal=inputSignal.*ramp; |
|
| 136 |
ramp=fliplr(ramp); |
|
| 137 |
inputSignal=inputSignal.*ramp; |
|
| 138 |
% add silence |
|
| 139 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 140 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 141 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 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 |
intialSilence= zeros(1,round(0.1/dt)); |
|
| 153 |
finalSilence= zeros(1,round(0.2/dt)); |
|
| 154 |
inputSignal= [intialSilence inputSignal' finalSilence]; |
|
| 155 |
end |
|
| 156 |
|
|
| 157 |
|
|
| 158 |
%% run the model |
|
| 159 |
tic |
|
| 160 |
fprintf('\n')
|
|
| 161 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 162 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 163 |
disp('Computing ...')
|
|
| 164 |
|
|
| 165 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 166 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 167 |
|
|
| 168 |
|
|
| 169 |
%% the model run is now complete. Now display the results |
|
| 170 |
UTIL_showMAP(showMapOptions) |
|
| 171 |
|
|
| 172 |
if strcmp(signalType,'tones') |
|
| 173 |
disp(['duration=' num2str(duration)]) |
|
| 174 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 175 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 176 |
global DRNLParams |
|
| 177 |
disp(['attenuation factor =' ... |
|
| 178 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 179 |
disp(['attenuation factor (probability)=' ... |
|
| 180 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 181 |
disp(AN_spikesOrProbability) |
|
| 182 |
end |
|
| 183 |
disp('paramChanges')
|
|
| 184 |
for i=1:length(paramChanges) |
|
| 185 |
disp(paramChanges{i})
|
|
| 186 |
end |
|
| 187 |
|
|
| 188 |
toc |
|
| 189 |
path(restorePath) |
|
| 190 |
|
|
| testPrograms/temp.m | ||
|---|---|---|
| 1 |
function test_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> |
|
| 1 |
function vectorStrength=testAN(probeFrequency,BFlist, levels, ... |
|
| 2 |
paramsName,paramChanges) |
|
| 3 |
% testAN generates rate/level functions for AN and brainstem units. |
|
| 4 |
% also other information like PSTHs, MOC efferent activity levels. |
|
| 5 |
% Vector strength calculations require the computation of period |
|
| 6 |
% histograms. for this reason the sample rate must always be an integer |
|
| 7 |
% multiple of the tone frequency. This applies to both the sampleRate and |
|
| 8 |
% the spikes sampling rate. |
|
| 9 |
% A full 'spikes' model is used. |
|
| 10 |
% paramChanges is a cell array of strings containing MATLAB statements that |
|
| 11 |
% change model parameters. See MAPparamsNormal for examples. |
|
| 12 |
% e.g. |
|
| 13 |
% testAN(1000,1000, -10:10:80,'Normal',{});
|
|
| 34 | 14 |
|
| 15 |
|
|
| 16 |
global IHC_VResp_VivoParams IHC_cilia_RPParams IHCpreSynapseParams |
|
| 17 |
global AN_IHCsynapseParams |
|
| 18 |
global ANoutput dtSpikes CNoutput ICoutput ICmembraneOutput ANtauCas |
|
| 19 |
global ARattenuation MOCattenuation |
|
| 20 |
tic |
|
| 35 | 21 |
dbstop if error |
| 36 | 22 |
restorePath=path; |
| 37 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... |
|
| 38 |
['..' filesep 'utilities']) |
|
| 23 |
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ... |
|
| 24 |
['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'],... |
|
| 25 |
['..' filesep 'testPrograms']) |
|
| 39 | 26 |
|
| 40 |
%% #1 parameter file name |
|
| 41 |
MAPparamsName='Normal'; |
|
| 27 |
if nargin<5, paramChanges={'IHCpreSynapseParams.tauCa= [30e-6 90e-6];'}; end
|
|
| 28 |
if nargin<4, paramsName='PL'; end |
|
| 29 |
if nargin<3, levels=-10:10:80; end |
|
| 30 |
if nargin==0, probeFrequency=1000; BFlist=1000; end |
|
| 31 |
nLevels=length(levels); |
|
| 42 | 32 |
|
| 33 |
toneDuration=.2; rampDuration=0.005; silenceDuration=.02; |
|
| 34 |
localPSTHbinwidth=0.001; |
|
| 43 | 35 |
|
| 44 |
%% #2 probability (fast) or spikes (slow) representation |
|
| 45 |
AN_spikesOrProbability='spikes'; |
|
| 46 |
% or |
|
| 47 |
AN_spikesOrProbability='probability'; |
|
| 36 |
%% guarantee that the sample rate is an interger multiple |
|
| 37 |
% of the probe frequency |
|
| 38 |
% we want 5 bins per period for spikes |
|
| 39 |
spikesSampleRate=5*probeFrequency; |
|
| 40 |
% model sample rate must be an integer multiple of this and in the region |
|
| 41 |
% of 50000 |
|
| 42 |
sampleRate=spikesSampleRate*round(50000/spikesSampleRate); |
|
| 43 |
dt=1/sampleRate; |
|
| 44 |
% avoid very slow spikes sampling rate |
|
| 45 |
spikesSampleRate=spikesSampleRate*ceil(10000/spikesSampleRate); |
|
| 48 | 46 |
|
| 47 |
%% pre-allocate storage |
|
| 48 |
AN_HSRonset=zeros(nLevels,1); |
|
| 49 |
AN_HSRsaturated=zeros(nLevels,1); |
|
| 50 |
AN_LSRonset=zeros(nLevels,1); |
|
| 51 |
AN_LSRsaturated=zeros(nLevels,1); |
|
| 52 |
CNLSRrate=zeros(nLevels,1); |
|
| 53 |
CNHSRsaturated=zeros(nLevels,1); |
|
| 54 |
ICHSRsaturated=zeros(nLevels,1); |
|
| 55 |
ICLSRsaturated=zeros(nLevels,1); |
|
| 56 |
vectorStrength=zeros(nLevels,1); |
|
| 49 | 57 |
|
| 50 |
%% #3 pure tone, harmonic sequence or speech file input |
|
| 51 |
signalType= 'tones'; |
|
| 52 |
sampleRate= 50000; |
|
| 53 |
duration=0.500; % seconds |
|
| 54 |
rampDuration=.005; % raised cosine ramp (seconds) |
|
| 55 |
beginSilence=0.250; |
|
| 56 |
endSilence=0.250; |
|
| 57 |
toneFrequency= 1000; % or a pure tone (Hz) |
|
| 58 |
AR=zeros(nLevels,1); |
|
| 59 |
MOC=zeros(nLevels,1); |
|
| 58 | 60 |
|
| 59 |
% or |
|
| 60 |
% harmonic sequence (Hz) |
|
| 61 |
% F0=210; |
|
| 62 |
% toneFrequency= F0:F0:8000; |
|
| 61 |
figure(15), clf |
|
| 62 |
set(gcf,'position',[980 356 401 321]) |
|
| 63 |
figure(5), clf |
|
| 64 |
set(gcf,'position', [980 34 400 295]) |
|
| 65 |
drawnow |
|
| 63 | 66 |
|
| 64 |
% or |
|
| 65 |
signalType= 'file'; |
|
| 66 |
fileName='twister_44kHz'; |
|
| 67 | 67 |
|
| 68 |
%% main computational loop (vary level) |
|
| 69 |
levelNo=0; |
|
| 70 |
for leveldB=levels |
|
| 71 |
levelNo=levelNo+1; |
|
| 72 |
amp=28e-6*10^(leveldB/20); |
|
| 73 |
fprintf('%4.0f\t', leveldB)
|
|
| 68 | 74 |
|
| 75 |
%% generate tone and silences |
|
| 76 |
time=dt:dt:toneDuration; |
|
| 77 |
rampTime=dt:dt:rampDuration; |
|
| 78 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 79 |
ones(1,length(time)-length(rampTime))]; |
|
| 80 |
ramp=ramp.*fliplr(ramp); |
|
| 81 |
|
|
| 82 |
silence=zeros(1,round(silenceDuration/dt)); |
|
| 83 |
|
|
| 84 |
inputSignal=amp*sin(2*pi*probeFrequency'*time); |
|
| 85 |
inputSignal= ramp.*inputSignal; |
|
| 86 |
inputSignal=[silence inputSignal]; |
|
| 87 |
|
|
| 88 |
%% run the model |
|
| 89 |
AN_spikesOrProbability='spikes'; |
|
| 90 |
nExistingParamChanges=length(paramChanges); |
|
| 91 |
paramChanges{nExistingParamChanges+1}=...
|
|
| 92 |
['AN_IHCsynapseParams.spikesTargetSampleRate=' ... |
|
| 93 |
num2str(spikesSampleRate) ';']; |
|
| 69 | 94 |
|
| 70 |
%% #4 rms level |
|
| 71 |
% signal details |
|
| 72 |
leveldBSPL= 70; % dB SPL (80 for Lieberman) |
|
| 95 |
MAP1_14(inputSignal, 1/dt, BFlist, ... |
|
| 96 |
paramsName, AN_spikesOrProbability, paramChanges); |
|
| 97 |
|
|
| 98 |
nTaus=length(ANtauCas); |
|
| 99 |
|
|
| 100 |
%% Auditory nerve evaluate and display (Fig. 5) |
|
| 101 |
%LSR (same as HSR if no LSR fibers present) |
|
| 102 |
[nANFibers nTimePoints]=size(ANoutput); |
|
| 103 |
numLSRfibers=nANFibers/nTaus; |
|
| 104 |
numHSRfibers=numLSRfibers; |
|
| 105 |
|
|
| 106 |
LSRspikes=ANoutput(1:numLSRfibers,:); |
|
| 107 |
PSTH=UTIL_PSTHmaker(LSRspikes, dtSpikes, localPSTHbinwidth); |
|
| 108 |
PSTHLSR=mean(PSTH,1)/localPSTHbinwidth; % across fibers rates |
|
| 109 |
PSTHtime=localPSTHbinwidth:localPSTHbinwidth:... |
|
| 110 |
localPSTHbinwidth*length(PSTH); |
|
| 111 |
AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window |
|
| 112 |
AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end)); |
|
| 113 |
|
|
| 114 |
% AN HSR |
|
| 115 |
HSRspikes= ANoutput(end- numHSRfibers+1:end, :); |
|
| 116 |
PSTH=UTIL_PSTHmaker(HSRspikes, dtSpikes, localPSTHbinwidth); |
|
| 117 |
PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only) |
|
| 118 |
AN_HSRonset(levelNo)= max(PSTH); |
|
| 119 |
AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end)); |
|
| 120 |
|
|
| 121 |
figure(5), subplot(2,2,2) |
|
| 122 |
hold off, bar(PSTHtime,PSTH, 'b') |
|
| 123 |
hold on, bar(PSTHtime,PSTHLSR,'r') |
|
| 124 |
ylim([0 1000]) |
|
| 125 |
xlim([0 length(PSTH)*localPSTHbinwidth]) |
|
| 126 |
grid on |
|
| 127 |
set(gcf,'name',['PSTH: ' num2str(BFlist), ' Hz: ' num2str(leveldB) ' dB']); |
|
| 128 |
|
|
| 129 |
% AN - CV |
|
| 130 |
% CV is computed 5 times. Use the middle one (3) as most typical |
|
| 131 |
cvANHSR= UTIL_CV(HSRspikes, dtSpikes); |
|
| 132 |
|
|
| 133 |
% AN - vector strength |
|
| 134 |
PSTH=sum(CNoutput (11:20,:)); |
|
| 135 |
[PH, binTimes]=UTIL_periodHistogram... |
|
| 136 |
(PSTH, dtSpikes, probeFrequency); |
|
| 137 |
VS=UTIL_vectorStrength(PH); |
|
| 138 |
vectorStrength(levelNo)=VS; |
|
| 139 |
disp(['sat rate= ' num2str(AN_HSRsaturated(levelNo)) ... |
|
| 140 |
'; phase-locking VS = ' num2str(VS)]) |
|
| 141 |
title(['AN HSR: CV=' num2str(cvANHSR(3),'%5.2f') ... |
|
| 142 |
'VS=' num2str(VS,'%5.2f')]) |
|
| 143 |
|
|
| 144 |
%% CN - first-order neurons |
|
| 145 |
|
|
| 146 |
% CN driven by LSR fibers |
|
| 147 |
[nCNneurons c]=size(CNoutput); |
|
| 148 |
nLSRneurons=round(nCNneurons/nTaus); |
|
| 149 |
CNLSRspikes=CNoutput(1:nLSRneurons,:); |
|
| 150 |
PSTH=UTIL_PSTHmaker(CNLSRspikes, dtSpikes, localPSTHbinwidth); |
|
| 151 |
PSTH=sum(PSTH)/nLSRneurons; |
|
| 152 |
% CNLSRrate(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth; |
|
| 153 |
CNLSRrate(levelNo)=mean(PSTH)/localPSTHbinwidth; |
|
| 154 |
|
|
| 155 |
%CN HSR |
|
| 156 |
MacGregorMultiHSRspikes=... |
|
| 157 |
CNoutput(end-nLSRneurons+1:end,:); |
|
| 158 |
PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, dtSpikes, localPSTHbinwidth); |
|
| 159 |
PSTH=sum(PSTH)/nLSRneurons; |
|
| 160 |
PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only) |
|
| 161 |
|
|
| 162 |
% CNHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end)); |
|
| 163 |
CNHSRsaturated(levelNo)=mean(PSTH); |
|
| 164 |
|
|
| 165 |
figure(5), subplot(2,2,3) |
|
| 166 |
bar(PSTHtime,PSTH) |
|
| 167 |
ylim([0 1000]) |
|
| 168 |
xlim([0 length(PSTH)*localPSTHbinwidth]) |
|
| 169 |
cvMMHSR= UTIL_CV(MacGregorMultiHSRspikes, dtSpikes); |
|
| 170 |
title(['CN CV= ' num2str(cvMMHSR(3),'%5.2f')]) |
|
| 171 |
|
|
| 172 |
%% IC LSR |
|
| 173 |
[nICneurons c]=size(ICoutput); |
|
| 174 |
nLSRneurons=round(nICneurons/nTaus); |
|
| 175 |
ICLSRspikes=ICoutput(1:nLSRneurons,:); |
|
| 176 |
PSTH=UTIL_PSTHmaker(ICLSRspikes, dtSpikes, localPSTHbinwidth); |
|
| 177 |
% ICLSRsaturated(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth; |
|
| 178 |
ICLSRsaturated(levelNo)=mean(PSTH)/localPSTHbinwidth; |
|
| 179 |
|
|
| 180 |
%IC HSR |
|
| 181 |
MacGregorMultiHSRspikes=... |
|
| 182 |
ICoutput(end-nLSRneurons+1:end,:); |
|
| 183 |
PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, dtSpikes, localPSTHbinwidth); |
|
| 184 |
ICHSRsaturated(levelNo)= (sum(PSTH)/nLSRneurons)/toneDuration; |
|
| 73 | 185 |
|
| 186 |
AR(levelNo)=min(ARattenuation); |
|
| 187 |
MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end)); |
|
| 188 |
|
|
| 189 |
time=dt:dt:dt*size(ICmembraneOutput,2); |
|
| 190 |
figure(5), subplot(2,2,4) |
|
| 191 |
% plot HSR (last of two) |
|
| 192 |
plot(time,ICmembraneOutput(end-nLSRneurons+1, 1:end),'k') |
|
| 193 |
ylim([-0.07 0]) |
|
| 194 |
xlim([0 max(time)]) |
|
| 195 |
title(['IC ' num2str(leveldB,'%4.0f') 'dB']) |
|
| 196 |
drawnow |
|
| 197 |
|
|
| 198 |
figure(5), subplot(2,2,1) |
|
| 199 |
plot(20*log10(MOC), 'k'), hold on |
|
| 200 |
plot(20*log10(AR), 'r'), hold off |
|
| 201 |
title(' MOC'), ylabel('dB attenuation')
|
|
| 202 |
ylim([-30 0]) |
|
| 203 |
|
|
| 204 |
% x=input('prompt')
|
|
| 205 |
end % level |
|
| 74 | 206 |
|
| 75 |
%% #5 number of channels in the model |
|
| 76 |
% 21-channel model (log spacing) |
|
| 77 |
numChannels=21; |
|
| 78 |
lowestBF=250; highestBF= 6000; |
|
| 79 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 207 |
%% plot with levels on x-axis |
|
| 208 |
figure(5), subplot(2,2,1) |
|
| 209 |
plot(levels,20*log10(MOC), 'k'),hold on |
|
| 210 |
plot(levels,20*log10(AR), 'r'), hold off |
|
| 211 |
title(' MOC'), ylabel('dB attenuation')
|
|
| 212 |
ylim([-30 0]) |
|
| 213 |
xlim([0 max(levels)]) |
|
| 80 | 214 |
|
| 81 |
% or specify your own channel BFs |
|
| 82 |
numChannels=1; |
|
| 83 |
BFlist=toneFrequency; |
|
| 215 |
fprintf('\n')
|
|
| 216 |
toneDuration=2; |
|
| 217 |
rampDuration=0.004; |
|
| 218 |
silenceDuration=.02; |
|
| 219 |
nRepeats=200; % no. of AN fibers |
|
| 220 |
fprintf('toneDuration %6.3f\n', toneDuration)
|
|
| 221 |
fprintf(' %6.0f AN fibers (repeats)\n', nRepeats)
|
|
| 222 |
fprintf('levels')
|
|
| 223 |
fprintf('%6.2f\t', levels)
|
|
| 224 |
fprintf('\n')
|
|
| 84 | 225 |
|
| 226 |
%% ---------------------- display summary results (Fig 15) |
|
| 227 |
figure(15), clf |
|
| 228 |
nRows=2; nCols=2; |
|
| 85 | 229 |
|
| 86 |
%% #6 change model parameters |
|
| 87 |
|
|
| 88 |
paramChanges={};
|
|
| 89 |
|
|
| 90 |
% Parameter changes can be used to change one or more model parameters |
|
| 91 |
% *after* the MAPparams file has been read |
|
| 92 |
% This example declares only one fiber type with a calcium clearance time |
|
| 93 |
% constant of 80e-6 s (HSR fiber) when the probability option is selected. |
|
| 94 |
paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
|
|
| 95 |
'IHCpreSynapseParams.tauCa=86e-6; '}; |
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
%% delare 'showMap' options to control graphical 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=1; % shows SACF (probability only) |
|
| 104 |
showMapOptions.showEfferent=1; % tracks of AR and MOC |
|
| 105 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
|
| 106 |
showMapOptions.surfSpikes=1; % 2D plot of spikes histogram |
|
| 107 |
showMapOptions.ICrates=0; % IC rates by CNtauGk |
|
| 108 |
|
|
| 109 |
% disable certain silly options |
|
| 110 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 111 |
% avoid nonsensical options |
|
| 112 |
showMapOptions.surfProbability=0; |
|
| 113 |
showMapOptions.showACF=0; |
|
| 230 |
% AN rate - level ONSET functions |
|
| 231 |
subplot(nRows,nCols,1) |
|
| 232 |
plot(levels,AN_LSRonset,'ro'), hold on |
|
| 233 |
plot(levels,AN_HSRonset,'ko'), hold off |
|
| 234 |
ylim([0 1000]) |
|
| 235 |
if length(levels)>1 |
|
| 236 |
xlim([min(levels) max(levels)]) |
|
| 114 | 237 |
end |
| 115 | 238 |
|
| 116 |
if strcmp(signalType, 'file') |
|
| 117 |
% needed for labeling plot |
|
| 118 |
showMapOptions.fileName=fileName; |
|
| 119 |
else |
|
| 120 |
showMapOptions.fileName=[]; |
|
| 239 |
ttl=['tauCa= ' num2str(IHCpreSynapseParams.tauCa)]; |
|
| 240 |
title( ttl) |
|
| 241 |
xlabel('level dB SPL'), ylabel('peak rate (sp/s)'), grid on
|
|
| 242 |
text(0, 800, 'AN onset', 'fontsize', 14) |
|
| 243 |
|
|
| 244 |
% AN rate - level ADAPTED function |
|
| 245 |
subplot(nRows,nCols,2) |
|
| 246 |
plot(levels,AN_LSRsaturated, 'ro'), hold on |
|
| 247 |
plot(levels,AN_HSRsaturated, 'ko'), hold off |
|
| 248 |
ylim([0 400]) |
|
| 249 |
set(gca,'ytick',0:50:300) |
|
| 250 |
if length(levels)>1 |
|
| 251 |
xlim([min(levels) max(levels)]) |
|
| 121 | 252 |
end |
| 253 |
set(gca,'xtick',[levels(1):20:levels(end)]) |
|
| 254 |
% grid on |
|
| 255 |
ttl=[ 'spont=' num2str(mean(AN_HSRsaturated(1,:)),'%4.0f')... |
|
| 256 |
' sat=' num2str(mean(AN_HSRsaturated(end,1)),'%4.0f')]; |
|
| 257 |
title( ttl) |
|
| 258 |
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
|
|
| 259 |
text(0, 340, 'AN adapted', 'fontsize', 14), grid on |
|
| 122 | 260 |
|
| 123 |
%% Generate stimuli |
|
| 261 |
% CN rate - level function |
|
| 262 |
subplot(nRows,nCols,3) |
|
| 263 |
plot(levels,CNLSRrate, 'ro'), hold on |
|
| 264 |
plot(levels,CNHSRsaturated, 'ko'), hold off |
|
| 265 |
ylim([0 400]) |
|
| 266 |
set(gca,'ytick',0:50:300) |
|
| 267 |
if length(levels)>1 |
|
| 268 |
xlim([min(levels) max(levels)]) |
|
| 269 |
end |
|
| 270 |
set(gca,'xtick',[levels(1):20:levels(end)]) |
|
| 271 |
% grid on |
|
| 272 |
ttl=[ 'spont=' num2str(mean(CNHSRsaturated(1,:)),'%4.0f') ' sat=' ... |
|
| 273 |
num2str(mean(CNHSRsaturated(end,1)),'%4.0f')]; |
|
| 274 |
title( ttl) |
|
| 275 |
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
|
|
| 276 |
text(0, 350, 'CN', 'fontsize', 14), grid on |
|
| 124 | 277 |
|
| 125 |
switch signalType |
|
| 126 |
case 'tones' |
|
| 127 |
% Create pure tone stimulus |
|
| 128 |
dt=1/sampleRate; % seconds |
|
| 129 |
time=dt: dt: duration; |
|
| 130 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 131 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 132 |
inputSignal=amp*inputSignal; |
|
| 133 |
% apply ramps |
|
| 134 |
% catch rampTime error |
|
| 135 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 136 |
rampTime=dt:dt:rampDuration; |
|
| 137 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 138 |
ones(1,length(time)-length(rampTime))]; |
|
| 139 |
inputSignal=inputSignal.*ramp; |
|
| 140 |
ramp=fliplr(ramp); |
|
| 141 |
inputSignal=inputSignal.*ramp; |
|
| 142 |
% add silence |
|
| 143 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 144 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 145 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 278 |
% IC rate - level function |
|
| 279 |
subplot(nRows,nCols,4) |
|
| 280 |
plot(levels,ICLSRsaturated, 'ro'), hold on |
|
| 281 |
plot(levels,ICHSRsaturated, 'ko'), hold off |
|
| 282 |
ylim([0 400]) |
|
| 283 |
set(gca,'ytick',0:50:300) |
|
| 284 |
if length(levels)>1 |
|
| 285 |
xlim([min(levels) max(levels)]) |
|
| 286 |
end |
|
| 287 |
set(gca,'xtick',[levels(1):20:levels(end)]), grid on |
|
| 288 |
ttl=['spont=' num2str(mean(ICHSRsaturated(1,:)),'%4.0f') ... |
|
| 289 |
' sat=' num2str(mean(ICHSRsaturated(end,1)),'%4.0f')]; |
|
| 290 |
title( ttl) |
|
| 291 |
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
|
|
| 292 |
text(0, 350, 'IC', 'fontsize', 14) |
|
| 293 |
set(gcf,'name',' AN CN IC rate/level') |
|
| 146 | 294 |
|
| 147 |
case 'file' |
|
| 148 |
%% file input simple or mixed |
|
| 149 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 150 |
dt=1/sampleRate; |
|
| 151 |
inputSignal=inputSignal(:,1); |
|
| 152 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 153 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 154 |
amp=targetRMS/rms; |
|
| 155 |
inputSignal=inputSignal*amp; |
|
| 156 |
intialSilence= zeros(1,round(0.1/dt)); |
|
| 157 |
finalSilence= zeros(1,round(0.2/dt)); |
|
| 158 |
inputSignal= [intialSilence inputSignal' finalSilence]; |
|
| 159 |
end |
|
| 295 |
fprintf('\n')
|
|
| 296 |
disp('levels vectorStrength')
|
|
| 297 |
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
|
|
| 298 |
fprintf('\n')
|
|
| 299 |
fprintf('Phase locking, max vector strength=\t %6.4f\n\n',...
|
|
| 300 |
max(vectorStrength)) |
|
| 160 | 301 |
|
| 302 |
allData=[ levels' AN_HSRonset AN_HSRsaturated... |
|
| 303 |
AN_LSRonset AN_LSRsaturated ... |
|
| 304 |
CNHSRsaturated CNLSRrate... |
|
| 305 |
ICHSRsaturated ICLSRsaturated]; |
|
| 306 |
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n');
|
|
| 307 |
UTIL_printTabTable(round(allData)) |
|
| 308 |
fprintf('VS (phase locking)= \t%6.4f\n\n',...
|
|
| 309 |
max(vectorStrength)) |
|
| 161 | 310 |
|
| 162 |
%% run the model |
|
| 163 |
tic |
|
| 311 |
UTIL_showStruct(IHC_cilia_RPParams, 'IHC_cilia_RPParams') |
|
| 312 |
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams') |
|
| 313 |
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams') |
|
| 314 |
|
|
| 164 | 315 |
fprintf('\n')
|
| 165 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 166 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 167 |
disp('Computing ...')
|
|
| 316 |
disp('levels vectorStrength')
|
|
| 317 |
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
|
|
| 318 |
fprintf('\n')
|
|
| 319 |
fprintf('Phase locking, max vector strength= \t%6.4f\n\n',...
|
|
| 320 |
max(vectorStrength)) |
|
| 168 | 321 |
|
| 169 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
|
| 170 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
|
| 322 |
allData=[ levels' AN_HSRonset AN_HSRsaturated... |
|
| 323 |
AN_LSRonset AN_LSRsaturated ... |
|
| 324 |
CNHSRsaturated CNLSRrate... |
|
| 325 |
ICHSRsaturated ICLSRsaturated]; |
|
| 326 |
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n');
|
|
| 327 |
UTIL_printTabTable(round(allData)) |
|
| 328 |
fprintf('VS (phase locking)= \t%6.4f\n\n',...
|
|
| 329 |
max(vectorStrength)) |
|
| 171 | 330 |
|
| 172 |
|
|
| 173 |
%% the model run is now complete. Now display the results |
|
| 174 |
UTIL_showMAP(showMapOptions, paramChanges) |
|
| 175 |
|
|
| 176 |
if strcmp(signalType,'tones') |
|
| 177 |
disp(['duration=' num2str(duration)]) |
|
| 178 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 179 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 180 |
global DRNLParams |
|
| 181 |
disp(['attenuation factor =' ... |
|
| 182 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 183 |
disp(['attenuation factor (probability)=' ... |
|
| 184 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 185 |
disp(AN_spikesOrProbability) |
|
| 186 |
end |
|
| 187 |
disp(paramChanges) |
|
| 331 |
path(restorePath) |
|
| 188 | 332 |
toc |
| 189 |
path(restorePath) |
|
| 190 |
|
|
| testPrograms/tempPL.m | ||
|---|---|---|
| 1 |
function testPhaseLocking(paramsName, paramChanges) |
|
| 2 |
|
|
| 3 |
if nargin<2 |
|
| 4 |
paramChanges=[]; |
|
| 5 |
end |
|
| 6 |
|
|
| 7 |
if nargin<1 |
|
| 8 |
paramsName='PL'; |
|
| 9 |
end |
|
| 10 |
|
|
| 11 |
testFrequencies=[250 500 1000 2000]; |
|
| 12 |
levels=0:10:100; |
|
| 13 |
|
|
| 14 |
figure(14), clf |
|
| 15 |
set(gcf,'position', [980 36 383 321]) |
|
| 16 |
set(gcf,'name', 'phase locking') |
|
| 17 |
|
|
| 18 |
allStrengths=zeros(length(testFrequencies), length(levels)); |
|
| 19 |
peakVectorStrength=zeros(1,length(testFrequencies)); |
|
| 20 |
|
|
| 21 |
freqCount=0; |
|
| 22 |
for targetFrequency=testFrequencies; |
|
| 23 |
%single test |
|
| 24 |
freqCount=freqCount+1; |
|
| 25 |
vectorStrength=... |
|
| 26 |
temp(targetFrequency,targetFrequency, levels,... |
|
| 27 |
paramsName, paramChanges); |
|
| 28 |
allStrengths(freqCount,:)=vectorStrength'; |
|
| 29 |
peakVectorStrength(freqCount)=max(vectorStrength'); |
|
| 30 |
end |
|
| 31 |
%% plot results |
|
| 32 |
figure(14) |
|
| 33 |
subplot(2,1,2) |
|
| 34 |
plot(levels,allStrengths, '+') |
|
| 35 |
xlabel('levels')
|
|
| 36 |
ylabel('vector strength')
|
|
| 37 |
legend (num2str(testFrequencies'),'location','eastOutside') |
|
| 38 |
|
|
| 39 |
subplot(2,1,1) |
|
| 40 |
semilogx(testFrequencies,peakVectorStrength) |
|
| 41 |
grid on |
|
| 42 |
title ('peak vector strength')
|
|
| 43 |
xlabel('frequency')
|
|
| 44 |
ylabel('vector strength')
|
|
| 45 |
|
|
| 46 |
johnson=[250 0.79 |
|
| 47 |
500 0.82 |
|
| 48 |
1000 0.8 |
|
| 49 |
2000 0.7 |
|
| 50 |
4000 0.25 |
|
| 51 |
5500 0.05 |
|
| 52 |
]; |
|
| 53 |
hold on |
|
| 54 |
plot(johnson(:,1),johnson(:,2),'o') |
|
| 55 |
legend({'model','Johnson 80'},'location','eastOutside')
|
|
| 56 |
hold off |
|
| 57 |
|
|
| 58 |
|
|
| testPrograms/termp.m | ||
|---|---|---|
| 1 |
|
|
| 2 |
DRNLParams.a=10; |
|
| 3 |
paramChanges={'DRNL.a=2;'}
|
|
| 4 |
for idx=1:length(paramChanges) |
|
| 5 |
x=paramChanges{idx};
|
|
| 6 |
st=x(1:strfind(x,'.')-1); |
|
Also available in: Unified diff