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 / demoTwisterSpikes.m @ 23:6cce421531e2
History | View | Annotate | Download (2.62 KB)
| 1 |
function demoTwisterSpikes |
|---|---|
| 2 |
|
| 3 |
% MAPdemo runs the MATLAB auditory periphery model (MAP1_14) as far as |
| 4 |
% IC (spikes) with graphical output |
| 5 |
|
| 6 |
|
| 7 |
%% #1 parameter file name |
| 8 |
MAPparamsName='Normal'; |
| 9 |
|
| 10 |
|
| 11 |
%% #2 probability (fast) or spikes (slow) representation |
| 12 |
AN_spikesOrProbability='spikes'; |
| 13 |
|
| 14 |
|
| 15 |
%% #3 pure tone, harmonic sequence or speech file input |
| 16 |
signalType= 'file'; |
| 17 |
fileName='twister_44kHz'; |
| 18 |
|
| 19 |
|
| 20 |
%% #4 rms level |
| 21 |
% signal details |
| 22 |
leveldBSPL=70; % dB SPL |
| 23 |
|
| 24 |
|
| 25 |
%% #5 number of channels in the model |
| 26 |
% 21-channel model (log spacing) |
| 27 |
numChannels=21; |
| 28 |
lowestBF=250; highestBF= 8000; |
| 29 |
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); |
| 30 |
|
| 31 |
|
| 32 |
%% #6 change model parameters |
| 33 |
paramChanges=[]; |
| 34 |
|
| 35 |
%% delare showMap options |
| 36 |
showMapOptions=[]; % use defaults |
| 37 |
|
| 38 |
% or (example: show everything including an smoothed SACF output |
| 39 |
showMapOptions.printModelParameters=1; |
| 40 |
showMapOptions.showModelOutput=1; |
| 41 |
showMapOptions.printFiringRates=1; |
| 42 |
showMapOptions.showACF=0; |
| 43 |
showMapOptions.showEfferent=0; |
| 44 |
|
| 45 |
%% Generate stimuli |
| 46 |
|
| 47 |
dbstop if error |
| 48 |
restorePath=path; |
| 49 |
addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore']) |
| 50 |
switch signalType |
| 51 |
case 'tones' |
| 52 |
inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
| 53 |
leveldBSPL, duration, rampDuration); |
| 54 |
|
| 55 |
case 'file' |
| 56 |
[inputSignal sampleRate]=wavread(fileName); |
| 57 |
inputSignal(:,1); |
| 58 |
targetRMS=20e-6*10^(leveldBSPL/20); |
| 59 |
rms=(mean(inputSignal.^2))^0.5; |
| 60 |
amp=targetRMS/rms; |
| 61 |
inputSignal=inputSignal*amp; |
| 62 |
end |
| 63 |
|
| 64 |
|
| 65 |
%% run the model |
| 66 |
tic |
| 67 |
|
| 68 |
fprintf('\n')
|
| 69 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
| 70 |
disp([num2str(numChannels) ' channel model']) |
| 71 |
disp('Computing ...')
|
| 72 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
| 73 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
| 74 |
toc |
| 75 |
|
| 76 |
% the model run is now complete. Now display the results |
| 77 |
UTIL_showMAP(showMapOptions) |
| 78 |
|
| 79 |
toc |
| 80 |
path(restorePath) |
| 81 |
|
| 82 |
|
| 83 |
function inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
| 84 |
leveldBSPL, duration, rampDuration) |
| 85 |
% Create pure tone stimulus |
| 86 |
dt=1/sampleRate; % seconds |
| 87 |
time=dt: dt: duration; |
| 88 |
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1); |
| 89 |
amp=10^(leveldBSPL/20)*28e-6; % converts to Pascals (peak) |
| 90 |
inputSignal=amp*inputSignal; |
| 91 |
|
| 92 |
% apply ramps |
| 93 |
% catch rampTime error |
| 94 |
if rampDuration>0.5*duration, rampDuration=duration/2; end |
| 95 |
rampTime=dt:dt:rampDuration; |
| 96 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ... |
| 97 |
ones(1,length(time)-length(rampTime))]; |
| 98 |
inputSignal=inputSignal.*ramp; |
| 99 |
ramp=fliplr(ramp); |
| 100 |
inputSignal=inputSignal.*ramp; |
| 101 |
|
| 102 |
% add 10 ms silence |
| 103 |
silence= zeros(1,round(0.03/dt)); |
| 104 |
% inputSignal= [silence inputSignal silence]; |
| 105 |
|