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 @ 33:161913b595ae
History | View | Annotate | Download (2.55 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 |
%% Generate stimuli |
| 38 |
|
| 39 |
switch signalType |
| 40 |
case 'tones' |
| 41 |
inputSignal=createMultiTone(sampleRate, toneFrequency, ... |
| 42 |
leveldBSPL, duration, rampDuration); |
| 43 |
|
| 44 |
case 'file' |
| 45 |
[inputSignal sampleRate]=wavread(fileName); |
| 46 |
inputSignal(:,1); |
| 47 |
targetRMS=20e-6*10^(leveldBSPL/20); |
| 48 |
rms=(mean(inputSignal.^2))^0.5; |
| 49 |
amp=targetRMS/rms; |
| 50 |
inputSignal=inputSignal*amp; |
| 51 |
end |
| 52 |
|
| 53 |
|
| 54 |
%% run the model |
| 55 |
tic |
| 56 |
|
| 57 |
fprintf('\n')
|
| 58 |
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)]) |
| 59 |
disp([num2str(numChannels) ' channel model']) |
| 60 |
disp('Computing ...')
|
| 61 |
|
| 62 |
MAP1_14(inputSignal, sampleRate, BFlist, ... |
| 63 |
MAPparamsName, AN_spikesOrProbability, paramChanges); |
| 64 |
|
| 65 |
|
| 66 |
%% the model run is finished. Now display the results |
| 67 |
|
| 68 |
%% delare showMap options |
| 69 |
showMapOptions.printModelParameters=1; |
| 70 |
showMapOptions.showModelOutput=1; |
| 71 |
showMapOptions.printFiringRates=1; |
| 72 |
showMapOptions.showACF=0; |
| 73 |
showMapOptions.showEfferent=0; |
| 74 |
showMapOptions.surfProbability=1; % 2D plot of HSR response |
| 75 |
|
| 76 |
UTIL_showMAP(showMapOptions, paramChanges) |
| 77 |
|
| 78 |
toc |
| 79 |
path(restorePath) |
| 80 |
|
| 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 |
|