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