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 / demoTwisterSpikes.m @ 25:d2c4c07df02c

History | View | Annotate | Download (2.59 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
restorePath=path;
7
addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'], ...
8
    ['..' filesep 'utilities'])
9

    
10

    
11
%%  #1 parameter file name
12
MAPparamsName='Normal';
13

    
14

    
15
%% #2 spikes (slow) representation
16
AN_spikesOrProbability='spikes';
17

    
18

    
19
%% #3 speech file input
20
signalType= 'file';
21
fileName='twister_44kHz';
22

    
23

    
24
%% #4 rms level
25
% signal details
26
leveldBSPL=70;                  % dB SPL
27

    
28

    
29
%% #5 number of channels in the model
30
%   21-channel model (log spacing)
31
numChannels=21;
32
lowestBF=250; 	highestBF= 8000; 
33
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
34

    
35

    
36
%% #6 change model parameters
37
paramChanges=[];
38

    
39
%% delare showMap options
40
showMapOptions=[];  % use defaults
41

    
42
% or (example: show everything including an smoothed SACF output
43
    showMapOptions.printModelParameters=1;
44
    showMapOptions.showModelOutput=1;
45
    showMapOptions.printFiringRates=1;
46
    showMapOptions.showACF=0;
47
    showMapOptions.showEfferent=0;
48

    
49
%% Generate stimuli
50

    
51
switch signalType
52
    case 'tones'
53
        inputSignal=createMultiTone(sampleRate, toneFrequency, ...
54
            leveldBSPL, duration, rampDuration);
55
        
56
    case 'file'
57
        [inputSignal sampleRate]=wavread(fileName);       
58
        inputSignal(:,1);
59
        targetRMS=20e-6*10^(leveldBSPL/20);
60
        rms=(mean(inputSignal.^2))^0.5;
61
        amp=targetRMS/rms;
62
        inputSignal=inputSignal*amp;
63
end
64

    
65

    
66
%% run the model
67
tic
68

    
69
fprintf('\n')
70
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
71
disp([num2str(numChannels) ' channel model'])
72
disp('Computing ...')
73
MAP1_14(inputSignal, sampleRate, BFlist, ...
74
    MAPparamsName, AN_spikesOrProbability, paramChanges);
75
toc
76

    
77
% the model run is now complete. Now display the results
78
UTIL_showMAP(showMapOptions)
79

    
80
toc
81
path(restorePath)
82

    
83

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

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

    
103
% add 10 ms silence
104
silence= zeros(1,round(0.03/dt));
105
% inputSignal= [silence inputSignal silence];
106