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 @ 23:6cce421531e2

History | View | Annotate | Download (5.32 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

    
36
%%  #1 parameter file name
37
MAPparamsName='Normal';
38

    
39

    
40
%% #2 probability (fast) or spikes (slow) representation
41
AN_spikesOrProbability='spikes';
42

    
43
% or
44
% NB probabilities are not corrected for refractory effects
45
AN_spikesOrProbability='probability';
46

    
47

    
48
%% #3 pure tone, harmonic sequence or speech file input
49
signalType= 'tones';
50
sampleRate= 100000;
51
duration=0.010;                 % seconds
52
% toneFrequency= 250:250:8000;    % harmonic sequence (Hz)
53
toneFrequency= 4000;            % or a pure tone (Hz8
54
rampDuration=.005;              % seconds
55

    
56
% or
57
% signalType= 'file';
58
% fileName='twister_44kHz';
59

    
60

    
61
%% #4 rms level
62
% signal details
63
leveldBSPL= 70;                  % dB SPL
64

    
65

    
66
%% #5 number of channels in the model
67
%   21-channel model (log spacing)
68
numChannels=21;
69
lowestBF=250; 	highestBF= 8000;
70
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
71

    
72
%   or specify your own channel BFs
73
% BFlist=toneFrequency;
74

    
75

    
76
%% #6 change model parameters
77
paramChanges=[];
78

    
79
% or
80
% Parameter changes can be used to change one or more model parameters
81
%  *after* the MAPparams file has been read
82
% This example declares only one fiber type with a calcium clearance time
83
% constant of 80e-6 s (HSR fiber) when the probability option is selected.
84
% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
85
%     'IHCpreSynapseParams.tauCa=86e-6;'};
86
% paramChanges={'DRNLParams.rateToAttenuationFactorProb = 0;'};
87

    
88

    
89
%% delare 'showMap' options to control graphical output
90
global showMapOptions
91

    
92
% or (example: show everything including an smoothed SACF output
93
showMapOptions.printModelParameters=1;   % prints all parameters
94
showMapOptions.showModelOutput=1;       % plot of all stages
95
showMapOptions.printFiringRates=1;      % prints stage activity levels
96
showMapOptions.showACF=0;               % shows SACF (probability only)
97
showMapOptions.showEfferent=1;          % tracks of AR and MOC
98
showMapOptions.surfProbability=1;       % 2D plot of HSR response 
99
if strcmp(AN_spikesOrProbability, 'spikes')
100
    % avoid nonsensical options
101
    showMapOptions.surfProbability=0;
102
    showMapOptions.showACF=0;
103
end
104
if strcmp(signalType, 'file')
105
    % needed for labeling plot
106
    showMapOptions.fileName=fileName;
107
else
108
    showMapOptions.fileName=[];
109
end
110

    
111
%% Generate stimuli
112

    
113
dbstop if error
114
restorePath=path;
115
addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'])
116
switch signalType
117
    case 'tones'
118
        inputSignal=createMultiTone(sampleRate, toneFrequency, ...
119
            leveldBSPL, duration, rampDuration);
120

    
121
    case 'file'
122
        %% file input simple or mixed
123
        [inputSignal sampleRate]=wavread(fileName);
124
        dt=1/sampleRate;
125
        inputSignal=inputSignal(:,1);
126
        targetRMS=20e-6*10^(leveldBSPL/20);
127
        rms=(mean(inputSignal.^2))^0.5;
128
        amp=targetRMS/rms;
129
        inputSignal=inputSignal*amp;
130
        silence= zeros(1,round(0.1/dt));
131
        inputSignal= [silence inputSignal' silence];
132
end
133

    
134

    
135
%% run the model
136
tic
137

    
138
fprintf('\n')
139
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
140
disp([num2str(numChannels) ' channel model'])
141
disp('Computing ...')
142

    
143
restorePath=path;
144
addpath (['..' filesep 'MAP'])
145
addpath (['..' filesep 'utilities'])
146

    
147
MAP1_14(inputSignal, sampleRate, BFlist, ...
148
    MAPparamsName, AN_spikesOrProbability, paramChanges);
149
toc
150

    
151
% the model run is now complete. Now display the results
152
disp(' param changes to list of parameters below')
153
for i=1:length(paramChanges)
154
    disp(paramChanges{i})
155
end
156
UTIL_showMAP(showMapOptions)
157

    
158

    
159
toc
160
path(restorePath)
161

    
162

    
163
function inputSignal=createMultiTone(sampleRate, toneFrequency, ...
164
    leveldBSPL, duration, rampDuration)
165
% Create pure tone stimulus
166
dt=1/sampleRate; % seconds
167
time=dt: dt: duration;
168
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
169
amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
170
inputSignal=amp*inputSignal;
171

    
172
% apply ramps
173
% catch rampTime error
174
if rampDuration>0.5*duration, rampDuration=duration/2; end
175
rampTime=dt:dt:rampDuration;
176
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
177
    ones(1,length(time)-length(rampTime))];
178
inputSignal=inputSignal.*ramp;
179
ramp=fliplr(ramp);
180
inputSignal=inputSignal.*ramp;
181

    
182
% add 10 ms silence
183
silence= zeros(1,round(0.03/dt));
184
silence= zeros(1,round(0.01/dt));
185
inputSignal= [silence inputSignal silence];
186