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

History | View | Annotate | Download (5.54 KB)

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