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 @ 25:d2c4c07df02c

History | View | Annotate | Download (5.44 KB)

1
function test_MAP1_14
2
% 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
%
13
% #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
% Identify the channels in terms of their best frequencies in the vector
26
%  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

    
35
dbstop if error
36
restorePath=path;
37
addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'], ...
38
    ['..' filesep 'utilities'])
39

    
40
%%  #1 parameter file name
41
MAPparamsName='Normal';
42

    
43

    
44
%% #2 probability (fast) or spikes (slow) representation
45
AN_spikesOrProbability='spikes';
46

    
47
% or
48
% NB probabilities are not corrected for refractory effects
49
% AN_spikesOrProbability='probability';
50

    
51

    
52
%% #3 pure tone, harmonic sequence or speech file input
53
signalType= 'tones';
54
sampleRate= 100000;
55
duration=0.050;                 % seconds
56
% toneFrequency= 250:250:8000;    % harmonic sequence (Hz)
57
toneFrequency= 1000;            % or a pure tone (Hz8
58
rampDuration=.005;              % seconds
59

    
60
% or
61
% signalType= 'file';
62
% fileName='twister_44kHz';
63

    
64

    
65
%% #4 rms level
66
% signal details
67
leveldBSPL= 70;                  % dB SPL
68

    
69

    
70
%% #5 number of channels in the model
71
%   21-channel model (log spacing)
72
numChannels=21;
73
lowestBF=250; 	highestBF= 8000;
74
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
75

    
76
%   or specify your own channel BFs
77
% numChannels=1;
78
% BFlist=toneFrequency;
79

    
80

    
81
%% #6 change model parameters
82
paramChanges=[];
83

    
84
% or
85
% Parameter changes can be used to change one or more model parameters
86
%  *after* the MAPparams file has been read
87
% This example declares only one fiber type with a calcium clearance time
88
% constant of 80e-6 s (HSR fiber) when the probability option is selected.
89

    
90
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
91
%     'IHCpreSynapseParams.tauCa=86e-6;'};
92

    
93
% paramChanges={'DRNLParams.rateToAttenuationFactorProb = 0;'};
94

    
95
% paramChanges={'IHCpreSynapseParams.tauCa=86e-6;',
96
%     'AN_IHCsynapseParams.numFibers=	100;'};
97

    
98

    
99
%% delare 'showMap' options to control graphical output
100

    
101
showMapOptions.printModelParameters=1;   % prints all parameters
102
showMapOptions.showModelOutput=1;       % plot of all stages
103
showMapOptions.printFiringRates=1;      % prints stage activity levels
104
showMapOptions.showACF=0;               % shows SACF (probability only)
105
showMapOptions.showEfferent=1;          % tracks of AR and MOC
106
showMapOptions.surfProbability=1;       % 2D plot of HSR response 
107
showMapOptions.surfSpikes=1;            % 2D plot of spikes histogram
108

    
109
% disable certain silly options
110
if strcmp(AN_spikesOrProbability, 'spikes')
111
    % avoid nonsensical options
112
    showMapOptions.surfProbability=0;
113
    showMapOptions.showACF=0;
114
else
115
    showMapOptions.surfSpikes=0;
116
end
117
if strcmp(signalType, 'file')
118
    % needed for labeling plot
119
    showMapOptions.fileName=fileName;
120
else
121
    showMapOptions.fileName=[];
122
end
123

    
124
%% Generate stimuli
125

    
126
switch signalType
127
    case 'tones'
128
        inputSignal=createMultiTone(sampleRate, toneFrequency, ...
129
            leveldBSPL, duration, rampDuration);
130

    
131
    case 'file'
132
        %% file input simple or mixed
133
        [inputSignal sampleRate]=wavread(fileName);
134
        dt=1/sampleRate;
135
        inputSignal=inputSignal(:,1);
136
        targetRMS=20e-6*10^(leveldBSPL/20);
137
        rms=(mean(inputSignal.^2))^0.5;
138
        amp=targetRMS/rms;
139
        inputSignal=inputSignal*amp;
140
        silence= zeros(1,round(0.1/dt));
141
        inputSignal= [silence inputSignal' silence];
142
end
143

    
144

    
145
%% run the model
146
tic
147

    
148
fprintf('\n')
149
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
150
disp([num2str(numChannels) ' channel model'])
151
disp('Computing ...')
152

    
153
MAP1_14(inputSignal, sampleRate, BFlist, ...
154
    MAPparamsName, AN_spikesOrProbability, paramChanges);
155
toc
156

    
157
% the model run is now complete. Now display the results
158
disp(' param changes to list of parameters below')
159
for i=1:length(paramChanges)
160
    disp(paramChanges{i})
161
end
162
UTIL_showMAP(showMapOptions)
163

    
164

    
165
toc
166
path(restorePath)
167

    
168

    
169
function inputSignal=createMultiTone(sampleRate, toneFrequency, ...
170
    leveldBSPL, duration, rampDuration)
171
% Create pure tone stimulus
172
dt=1/sampleRate; % seconds
173
time=dt: dt: duration;
174
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
175
amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
176
inputSignal=amp*inputSignal;
177

    
178
% apply ramps
179
% catch rampTime error
180
if rampDuration>0.5*duration, rampDuration=duration/2; end
181
rampTime=dt:dt:rampDuration;
182
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
183
    ones(1,length(time)-length(rampTime))];
184
inputSignal=inputSignal.*ramp;
185
ramp=fliplr(ramp);
186
inputSignal=inputSignal.*ramp;
187

    
188
% add 10 ms silence
189
silence= zeros(1,round(0.05/dt));
190
silence= zeros(1,round(0.05/dt));
191
inputSignal= [silence inputSignal silence];
192