Revision 38:c2204b18f4a2 userProgramsDomenika
| userProgramsDomenika/test_IC_DominikaTones.m | ||
|---|---|---|
| 1 |
function test_IC_DominikaTones |
|
| 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= 5000; % or a pure tone (Hz) |
|
| 58 |
|
|
| 59 |
% or |
|
| 60 |
% harmonic sequence (Hz) |
|
| 61 |
% F0=210; |
|
| 62 |
% toneFrequency= F0:F0:8000; |
|
| 63 |
|
|
| 64 |
% or |
|
| 65 |
% signalType= 'file'; |
|
| 66 |
% fileName='twister_44kHz'; |
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
%% #4 rms level |
|
| 71 |
% signal details |
|
| 72 |
leveldBSPL= 50; % dB SPL (80 for Lieberman) |
|
| 73 |
|
|
| 74 |
|
|
| 75 |
%% #5 number of channels in the model |
|
| 76 |
% 21-channel model (log spacing) |
|
| 77 |
numChannels=60; |
|
| 78 |
lowestBF=5000; highestBF= 5001; |
|
| 79 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
|
| 80 |
|
|
| 81 |
% or specify your own channel BFs |
|
| 82 |
% numChannels=1; |
|
| 83 |
% BFlist=toneFrequency; |
|
| 84 |
|
|
| 85 |
|
|
| 86 |
%% #6 change model parameters |
|
| 87 |
|
|
| 88 |
paramChanges={'IHCpreSynapseParams.tauCa= [80e-6];'};
|
|
| 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.showEfferent=0; % tracks of AR and MOC |
|
| 104 |
showMapOptions.ICrasterPlot=1; |
|
| 105 |
|
|
| 106 |
% disable certain silly options |
|
| 107 |
if strcmp(AN_spikesOrProbability, 'spikes') |
|
| 108 |
% avoid nonsensical options |
|
| 109 |
showMapOptions.surfProbability=0; |
|
| 110 |
showMapOptions.showACF=0; |
|
| 111 |
end |
|
| 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 |
|
|
| 122 |
switch signalType |
|
| 123 |
case 'tones' |
|
| 124 |
% Create pure tone stimulus |
|
| 125 |
dt=1/sampleRate; % seconds |
|
| 126 |
time=dt: dt: duration; |
|
| 127 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
|
| 128 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
|
| 129 |
inputSignal=amp*inputSignal; |
|
| 130 |
% apply ramps |
|
| 131 |
% catch rampTime error |
|
| 132 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
|
| 133 |
rampTime=dt:dt:rampDuration; |
|
| 134 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
|
| 135 |
ones(1,length(time)-length(rampTime))]; |
|
| 136 |
inputSignal=inputSignal.*ramp; |
|
| 137 |
ramp=fliplr(ramp); |
|
| 138 |
inputSignal=inputSignal.*ramp; |
|
| 139 |
% add silence |
|
| 140 |
intialSilence= zeros(1,round(beginSilence/dt)); |
|
| 141 |
finalSilence= zeros(1,round(endSilence/dt)); |
|
| 142 |
inputSignal= [intialSilence inputSignal finalSilence]; |
|
| 143 |
|
|
| 144 |
case 'file' |
|
| 145 |
%% file input simple or mixed |
|
| 146 |
[inputSignal sampleRate]=wavread(fileName); |
|
| 147 |
dt=1/sampleRate; |
|
| 148 |
inputSignal=inputSignal(:,1); |
|
| 149 |
targetRMS=20e-6*10^(leveldBSPL/20); |
|
| 150 |
rms=(mean(inputSignal.^2))^0.5; |
|
| 151 |
amp=targetRMS/rms; |
|
| 152 |
inputSignal=inputSignal*amp; |
|
| 153 |
intialSilence= zeros(1,round(0.1/dt)); |
|
| 154 |
finalSilence= zeros(1,round(0.2/dt)); |
|
| 155 |
inputSignal= [intialSilence inputSignal' finalSilence]; |
|
| 156 |
end |
|
| 157 |
|
|
| 158 |
|
|
| 159 |
%% run the model |
|
| 160 |
tic |
|
| 161 |
fprintf('\n')
|
|
| 162 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
|
| 163 |
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability]) |
|
| 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 |
if strcmp(signalType,'tones') |
|
| 174 |
disp(['duration=' num2str(duration)]) |
|
| 175 |
disp(['level=' num2str(leveldBSPL)]) |
|
| 176 |
disp(['toneFrequency=' num2str(toneFrequency)]) |
|
| 177 |
global DRNLParams |
|
| 178 |
disp(['attenuation factor =' ... |
|
| 179 |
num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ]) |
|
| 180 |
disp(['attenuation factor (probability)=' ... |
|
| 181 |
num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ]) |
|
| 182 |
disp(AN_spikesOrProbability) |
|
| 183 |
end |
|
| 184 |
disp(paramChanges) |
|
| 185 |
toc |
|
| 186 |
path(restorePath) |
|
| 187 |
|
|
Also available in: Unified diff