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.

Statistics Download as Zip
| Branch: | Revision:

root / testPrograms / demoTwisterProbability.m @ 23:6cce421531e2

History | View | Annotate | Download (2.53 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
% 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='probability';
14

    
15

    
16
%% #3 pure tone, harmonic sequence or speech file input
17
signalType= 'file';
18
fileName='twister_44kHz';
19

    
20

    
21
%% #4 rms level
22
leveldBSPL=60;                  % 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
%% #6 change model parameters
32
paramChanges=[];
33

    
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
MAP1_14(inputSignal, sampleRate, BFlist, ...
69
    MAPparamsName, AN_spikesOrProbability, paramChanges);
70
toc
71

    
72
% the model run is now complete. Now display the results
73
UTIL_showMAP(showMapOptions)
74

    
75
toc
76
path(restorePath)
77

    
78

    
79
function inputSignal=createMultiTone(sampleRate, toneFrequency, ...
80
    leveldBSPL, duration, rampDuration)
81
% Create pure tone stimulus
82
dt=1/sampleRate; % seconds
83
time=dt: dt: duration;
84
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
85
amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
86
inputSignal=amp*inputSignal;
87

    
88
% apply ramps
89
% catch rampTime error
90
if rampDuration>0.5*duration, rampDuration=duration/2; end
91
rampTime=dt:dt:rampDuration;
92
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
93
    ones(1,length(time)-length(rampTime))];
94
inputSignal=inputSignal.*ramp;
95
ramp=fliplr(ramp);
96
inputSignal=inputSignal.*ramp;
97

    
98
% add 10 ms silence
99
silence= zeros(1,round(0.03/dt));
100
% inputSignal= [silence inputSignal silence];
101