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 / test_MAP1_14.m @ 33:161913b595ae

History | View | Annotate | Download (5.59 KB)

1 0:f233164f4c86 rmeddis
function test_MAP1_14
2 15:35af36fe0a35 rmeddis
% test_MAP1_14 is a general purpose test routine that can be adjusted to
3
% test a number of different applications of MAP1_14
4
%
5
% A range of options are supplied in the early part of the program
6
%
7
% One use of the function is to create demonstrations; filenames <demoxx>
8
%  to illustrate particular features
9
%
10
% #1
11
% Identify the file (in 'MAPparamsName') containing the model parameters
12 19:5b23b9f11806 rmeddis
%
13 15:35af36fe0a35 rmeddis
% #2
14
% Identify the kind of model required (in 'AN_spikesOrProbability').
15
%  A full brainstem model (spikes) can be computed or a shorter model
16
%  (probability) that computes only so far as the auditory nerve
17
%
18
% #3
19
% Choose between a tone signal or file input (in 'signalType')
20
%
21
% #4
22
% Set the signal rms level (in leveldBSPL)
23
%
24
% #5
25 23:6cce421531e2 rmeddis
% Identify the channels in terms of their best frequencies in the vector
26 15:35af36fe0a35 rmeddis
%  BFlist.
27
%
28
% Last minute changes to the parameters fetched earlier can be made using
29
%  the cell array of strings 'paramChanges'.
30
%  Each string must have the same format as the corresponding line in the
31
%  file identified in 'MAPparamsName'
32
%
33
% When the demonstration is satisfactory, freeze it by renaming it <demoxx>
34 0:f233164f4c86 rmeddis
35 25:d2c4c07df02c rmeddis
dbstop if error
36 24:a5e4a43c1673 rmeddis
restorePath=path;
37
addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'], ...
38
    ['..' filesep 'utilities'])
39 0:f233164f4c86 rmeddis
40
%%  #1 parameter file name
41
MAPparamsName='Normal';
42
43
44
%% #2 probability (fast) or spikes (slow) representation
45 32:82fb37eb430e rmeddis
AN_spikesOrProbability='spikes';
46 23:6cce421531e2 rmeddis
47 0:f233164f4c86 rmeddis
% or
48 23:6cce421531e2 rmeddis
% NB probabilities are not corrected for refractory effects
49 32:82fb37eb430e rmeddis
% AN_spikesOrProbability='probability';
50 0:f233164f4c86 rmeddis
51
52
%% #3 pure tone, harmonic sequence or speech file input
53
signalType= 'tones';
54 26:b03ef38fe497 rmeddis
sampleRate= 50000;
55
duration=0.250;                 % seconds
56 25:d2c4c07df02c rmeddis
toneFrequency= 1000;            % or a pure tone (Hz8
57 32:82fb37eb430e rmeddis
58
F0=210;
59
toneFrequency= F0:F0:8000;  % harmonic sequence (Hz)
60
61
rampDuration=.005;              % raised cosine ramp (seconds)
62 0:f233164f4c86 rmeddis
63
% or
64 26:b03ef38fe497 rmeddis
65 23:6cce421531e2 rmeddis
% signalType= 'file';
66
% fileName='twister_44kHz';
67 0:f233164f4c86 rmeddis
68
69
%% #4 rms level
70
% signal details
71 33:161913b595ae rmeddis
leveldBSPL= 50;                  % dB SPL
72 0:f233164f4c86 rmeddis
73
74
%% #5 number of channels in the model
75
%   21-channel model (log spacing)
76
numChannels=21;
77 19:5b23b9f11806 rmeddis
lowestBF=250; 	highestBF= 8000;
78 0:f233164f4c86 rmeddis
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
79
80
%   or specify your own channel BFs
81 25:d2c4c07df02c rmeddis
% numChannels=1;
82 19:5b23b9f11806 rmeddis
% BFlist=toneFrequency;
83 0:f233164f4c86 rmeddis
84
85
%% #6 change model parameters
86
paramChanges=[];
87
88
% or
89
% Parameter changes can be used to change one or more model parameters
90
%  *after* the MAPparams file has been read
91
% This example declares only one fiber type with a calcium clearance time
92
% constant of 80e-6 s (HSR fiber) when the probability option is selected.
93 25:d2c4c07df02c rmeddis
94 16:37a379b27cff rmeddis
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
95
%     'IHCpreSynapseParams.tauCa=86e-6;'};
96 25:d2c4c07df02c rmeddis
97 27:d4a7675b0413 rmeddis
% paramChanges={'DRNLParams.rateToAttenuationFactorProb = 0;'};
98 0:f233164f4c86 rmeddis
99 25:d2c4c07df02c rmeddis
% paramChanges={'IHCpreSynapseParams.tauCa=86e-6;',
100 26:b03ef38fe497 rmeddis
%     'AN_IHCsynapseParams.numFibers=	1000;'};
101 25:d2c4c07df02c rmeddis
102 27:d4a7675b0413 rmeddis
% fixed MOC attenuation(using negative factor)
103 32:82fb37eb430e rmeddis
% paramChanges={'DRNLParams.rateToAttenuationFactorProb=-0.005;'};
104
105
% slow the CN chopping rate
106
paramChanges={' MacGregorMultiParams.tauGk=	0.0004;'};
107 23:6cce421531e2 rmeddis
108
%% delare 'showMap' options to control graphical output
109 0:f233164f4c86 rmeddis
110 23:6cce421531e2 rmeddis
showMapOptions.printModelParameters=1;   % prints all parameters
111
showMapOptions.showModelOutput=1;       % plot of all stages
112
showMapOptions.printFiringRates=1;      % prints stage activity levels
113
showMapOptions.showACF=0;               % shows SACF (probability only)
114
showMapOptions.showEfferent=1;          % tracks of AR and MOC
115
showMapOptions.surfProbability=1;       % 2D plot of HSR response
116 25:d2c4c07df02c rmeddis
showMapOptions.surfSpikes=1;            % 2D plot of spikes histogram
117 32:82fb37eb430e rmeddis
showMapOptions.ICrates=0;               % IC rates by CNtauGk
118 25:d2c4c07df02c rmeddis
119
% disable certain silly options
120 23:6cce421531e2 rmeddis
if strcmp(AN_spikesOrProbability, 'spikes')
121
    % avoid nonsensical options
122
    showMapOptions.surfProbability=0;
123
    showMapOptions.showACF=0;
124 25:d2c4c07df02c rmeddis
else
125
    showMapOptions.surfSpikes=0;
126 16:37a379b27cff rmeddis
end
127
if strcmp(signalType, 'file')
128 23:6cce421531e2 rmeddis
    % needed for labeling plot
129 16:37a379b27cff rmeddis
    showMapOptions.fileName=fileName;
130 23:6cce421531e2 rmeddis
else
131
    showMapOptions.fileName=[];
132 16:37a379b27cff rmeddis
end
133 0:f233164f4c86 rmeddis
134
%% Generate stimuli
135
136
switch signalType
137
    case 'tones'
138
        inputSignal=createMultiTone(sampleRate, toneFrequency, ...
139
            leveldBSPL, duration, rampDuration);
140 23:6cce421531e2 rmeddis
141 0:f233164f4c86 rmeddis
    case 'file'
142 16:37a379b27cff rmeddis
        %% file input simple or mixed
143 19:5b23b9f11806 rmeddis
        [inputSignal sampleRate]=wavread(fileName);
144 23:6cce421531e2 rmeddis
        dt=1/sampleRate;
145 16:37a379b27cff rmeddis
        inputSignal=inputSignal(:,1);
146 0:f233164f4c86 rmeddis
        targetRMS=20e-6*10^(leveldBSPL/20);
147
        rms=(mean(inputSignal.^2))^0.5;
148
        amp=targetRMS/rms;
149
        inputSignal=inputSignal*amp;
150 19:5b23b9f11806 rmeddis
        silence= zeros(1,round(0.1/dt));
151
        inputSignal= [silence inputSignal' silence];
152 0:f233164f4c86 rmeddis
end
153
154
155
%% run the model
156
tic
157
158 9:ecad0ea62b43 rmeddis
fprintf('\n')
159
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
160
disp([num2str(numChannels) ' channel model'])
161
disp('Computing ...')
162 15:35af36fe0a35 rmeddis
163 0:f233164f4c86 rmeddis
MAP1_14(inputSignal, sampleRate, BFlist, ...
164
    MAPparamsName, AN_spikesOrProbability, paramChanges);
165 26:b03ef38fe497 rmeddis
166 0:f233164f4c86 rmeddis
167
% the model run is now complete. Now display the results
168 26:b03ef38fe497 rmeddis
UTIL_showMAP(showMapOptions, paramChanges)
169 0:f233164f4c86 rmeddis
170 9:ecad0ea62b43 rmeddis
toc
171 0:f233164f4c86 rmeddis
path(restorePath)
172
173
174
function inputSignal=createMultiTone(sampleRate, toneFrequency, ...
175
    leveldBSPL, duration, rampDuration)
176
% Create pure tone stimulus
177
dt=1/sampleRate; % seconds
178
time=dt: dt: duration;
179
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
180
amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
181
inputSignal=amp*inputSignal;
182
183
% apply ramps
184
% catch rampTime error
185
if rampDuration>0.5*duration, rampDuration=duration/2; end
186
rampTime=dt:dt:rampDuration;
187
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
188
    ones(1,length(time)-length(rampTime))];
189
inputSignal=inputSignal.*ramp;
190
ramp=fliplr(ramp);
191
inputSignal=inputSignal.*ramp;
192
193
% add 10 ms silence
194 25:d2c4c07df02c rmeddis
silence= zeros(1,round(0.05/dt));
195 15:35af36fe0a35 rmeddis
inputSignal= [silence inputSignal silence];