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