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