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 / runMAP1_14.m @ 38:c2204b18f4a2

History | View | Annotate | Download (5.71 KB)

1 38:c2204b18f4a2 rmeddis
function runMAP1_14
2
% runMAP1_14 is a general purpose test routine that can be adjusted to
3
% explore different applications of MAP1_14
4
%
5
% It is also designed as 'starter' code for building new applications.
6
%
7
% A range of options are supplied in the early part of the program
8
%
9
% #1
10
% Identify the file (in 'MAPparamsName') containing the model parameters
11
%
12
% #2
13
% Identify the kind of model required (in 'AN_spikesOrProbability').
14
%  A full brainstem model ('spikes') can be computed or a shorter model
15
%  ('probability') that computes only so far as the auditory nerve
16
%
17
% #3
18
% Choose between a tone signal or file input (in 'signalType')
19
%
20
% #4
21
% Set the signal rms level (in leveldBSPL)
22
%
23
% #5
24
% Identify the channels in terms of their best frequencies in the vector
25
%  BFlist.
26
%
27
% #6
28
% Last minute changes to the model parameters can be made using
29
%  a cell array of strings, 'paramChanges'.
30
31
dbstop if error
32
restorePath=path;
33
addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'], ...
34
    ['..' filesep 'utilities'])
35
36
%%  #1 parameter file name
37
MAPparamsName='Normal';
38
39
40
%% #2 probability (fast) or spikes (slow) representation: select one
41
% AN_spikesOrProbability='spikes';
42
%   or
43
AN_spikesOrProbability='probability';
44
45
46
%% #3 A. pure tone, B. harmonic sequence or C. speech file input
47
% comment out unwanted code
48
49
% A. tone
50
sampleRate= 95000;
51
signalType= 'tones';
52
toneFrequency= 1000;            % or a pure tone (Hz)
53
duration=0.500;                 % seconds
54
beginSilence=0.010;
55
endSilence=0.020;
56
rampDuration=.005;              % raised cosine ramp (seconds)
57
58
%   or
59
% B. harmonic tone (Hz) - useful to demonstrate a broadband sound
60
% sampleRate= 44100;
61
% signalType= 'tones';
62
% toneFrequency= F0:F0:8000;
63
% duration=0.500;                 % seconds
64
% beginSilence=0.250;
65
% endSilence=0.250;
66
% F0=210;
67
% rampDuration=.005;              % raised cosine ramp (seconds)
68
69
%   or
70
% C. signalType= 'file';
71
% fileName='twister_44kHz';
72
73
%% #4 rms level
74
% signal details
75
leveldBSPL= 80;                  % dB SPL (80 for Lieberman)
76
77
%% #5 number of channels in the model
78
%   21-channel model (log spacing)
79
numChannels=21;
80
lowestBF=100; 	highestBF= 6000;
81
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
82
83
%   or specify your own channel BFs
84
% numChannels=1;
85
% BFlist=toneFrequency;
86
87
88
%% #6 change model parameters
89
90
paramChanges={};    % no changes
91
92
% Parameter changes can be used to change one or more model parameters
93
%  *after* the MAPparams file has been read
94
%  Each string must have the same format as the corresponding line in the
95
%   file identified in 'MAPparamsName'
96
% This example declares only one fiber type with a calcium clearance time
97
% constant of 80e-6 s (HSR fiber) when the probability option is selected.
98
%   paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
99
%     'IHCpreSynapseParams.tauCa=86e-6; '};
100
paramChanges={ 'IHCpreSynapseParams.tauCa=86e-6; ',...
101
    'DRNLParams.rateToAttenuationFactorProb = 0;'};
102
103
104
105
%% delare 'showMap' options to control graphical output
106
% see UTIL_showMAP for more options
107
showMapOptions.printModelParameters=1;   % prints all parameters
108
showMapOptions.showModelOutput=0;       % plot of all stages
109
showMapOptions.printFiringRates=1;      % prints stage activity levels
110
showMapOptions.showEfferent=0;          % tracks of AR and MOC
111
showMapOptions.surfAN=1;       % 2D plot of HSR response
112
113
if strcmp(signalType, 'file')
114
    % needed for labeling plot
115
    showMapOptions.fileName=fileName;
116
else
117
    showMapOptions.fileName=[];
118
end
119
120
%% Generate stimuli
121
switch signalType
122
    case 'tones'
123
        % Create pure tone stimulus
124
        dt=1/sampleRate; % seconds
125
        time=dt: dt: duration;
126
        inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
127
        amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
128
        inputSignal=amp*inputSignal;
129
        % apply ramps
130
        % catch rampTime error
131
        if rampDuration>0.5*duration, rampDuration=duration/2; end
132
        rampTime=dt:dt:rampDuration;
133
        ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
134
            ones(1,length(time)-length(rampTime))];
135
        inputSignal=inputSignal.*ramp;
136
        ramp=fliplr(ramp);
137
        inputSignal=inputSignal.*ramp;
138
        % add silence
139
        intialSilence= zeros(1,round(beginSilence/dt));
140
        finalSilence= zeros(1,round(endSilence/dt));
141
        inputSignal= [intialSilence inputSignal finalSilence];
142
143
    case 'file'
144
        %% file input simple or mixed
145
        [inputSignal sampleRate]=wavread(fileName);
146
        dt=1/sampleRate;
147
        inputSignal=inputSignal(:,1);
148
        targetRMS=20e-6*10^(leveldBSPL/20);
149
        rms=(mean(inputSignal.^2))^0.5;
150
        amp=targetRMS/rms;
151
        inputSignal=inputSignal*amp;
152
        intialSilence= zeros(1,round(0.1/dt));
153
        finalSilence= zeros(1,round(0.2/dt));
154
        inputSignal= [intialSilence inputSignal' finalSilence];
155
end
156
157
158
%% run the model
159
tic
160
fprintf('\n')
161
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
162
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability])
163
disp('Computing ...')
164
165
MAP1_14(inputSignal, sampleRate, BFlist, ...
166
    MAPparamsName, AN_spikesOrProbability, paramChanges);
167
168
169
%% the model run is now complete. Now display the results
170
UTIL_showMAP(showMapOptions)
171
172
if strcmp(signalType,'tones')
173
    disp(['duration=' num2str(duration)])
174
    disp(['level=' num2str(leveldBSPL)])
175
    disp(['toneFrequency=' num2str(toneFrequency)])
176
    global DRNLParams
177
    disp(['attenuation factor =' ...
178
        num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ])
179
    disp(['attenuation factor (probability)=' ...
180
        num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ])
181
    disp(AN_spikesOrProbability)
182
end
183
disp('paramChanges')
184
for i=1:length(paramChanges)
185
    disp(paramChanges{i})
186
end
187
188
toc
189
path(restorePath)