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 / userProgramsRM / test_MAP1_14Hopkins.m

History | View | Annotate | Download (5.95 KB)

1 38:c2204b18f4a2 rmeddis
function test_MAP1_14Hopkins
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
%   or
47
AN_spikesOrProbability='probability';
48
49
50
%% #3 pure tone, harmonic sequence or speech file input
51
signalType= 'tones';
52
sampleRate= 50000;
53
duration=0.100;                 % seconds
54
rampDuration=.005;              % raised cosine ramp (seconds)
55
beginSilence=0.050;
56
endSilence=0.050;
57
toneFrequency= 1000;            % or a pure tone (Hz)
58
59
%   or
60
% harmonic sequence (Hz)
61
F0=1000/11;
62
toneFrequency= 10*F0:F0:12*F0;
63
64
%   or
65
% signalType= 'file';
66
% fileName='twister_44kHz';
67
68
69
70
%% #4 rms level
71
% signal details
72
leveldBSPL= [44 50 44];                  % dB SPL (80 for Lieberman)
73
leveldBSPL= [50 50 50];                  % dB SPL (80 for Lieberman)
74
noiseLevel=-35;
75
76
%% #5 number of channels in the model
77
%   21-channel model (log spacing)
78
numChannels=21;
79
lowestBF=500; 	highestBF= 2000;
80
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
81
82
%   or specify your own channel BFs
83
numChannels=1;
84
BFlist=1000;
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
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=0;          % tracks of AR and MOC
106
showMapOptions.surfProbability=1;       % 2D plot of HSR response
107
showMapOptions.surfSpikes=0;            % 2D plot of spikes histogram
108
showMapOptions.ICrates=0;               % IC rates by CNtauGk
109
showMapOptions.PSTHbinwidth=0.001;
110
showMapOptions.colorbar=0;
111
showMapOptions.view=[0 90];
112
113
% disable certain silly options
114
if strcmp(AN_spikesOrProbability, 'spikes')
115
    % avoid nonsensical options
116
    showMapOptions.surfProbability=0;
117
    showMapOptions.showACF=0;
118
end
119
120
if strcmp(signalType, 'file')
121
    % needed for labeling plot
122
    showMapOptions.fileName=fileName;
123
else
124
    showMapOptions.fileName=[];
125
end
126
127
%% Generate stimuli
128
129
switch signalType
130
    case 'tones'
131
        % Create pure tone stimulus
132
        dt=1/sampleRate; % seconds
133
        time=dt: dt: duration;
134
        amp=10.^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
135
        inputSignal=sin(2*pi*toneFrequency'*time);
136
        amps=repmat(amp',1,length(time));
137
        inputSignal=amps.*inputSignal;
138
        inputSignal=sum(inputSignal, 1);
139
        % apply ramps
140
        % catch rampTime error
141
        if rampDuration>0.5*duration, rampDuration=duration/2; end
142
        rampTime=dt:dt:rampDuration;
143
        ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
144
            ones(1,length(time)-length(rampTime))];
145
        inputSignal=inputSignal.*ramp;
146
        ramp=fliplr(ramp);
147
        inputSignal=inputSignal.*ramp;
148
        % add silence
149
        intialSilence= zeros(1,round(beginSilence/dt));
150
        finalSilence= zeros(1,round(endSilence/dt));
151
        inputSignal= [intialSilence inputSignal finalSilence];
152
153
        %% TEN noise input simple or mixed
154
        [noise sampleRate]=wavread('TEN.wav');
155
        dt=1/sampleRate;
156
        noise=noise(:,1);
157
        targetRMS=20e-6*10^(noiseLevel/20);
158
        rms=(mean(noise.^2))^0.5;
159
        amp=targetRMS/rms;
160
        noise=noise*amp;
161
        inputSignal=inputSignal+noise(1:length(inputSignal))';
162
end
163
164
165
%% run the model
166
tic
167
fprintf('\n')
168
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
169
disp([num2str(numChannels) ' channel model: ' AN_spikesOrProbability])
170
disp('Computing ...')
171
172
MAP1_14(inputSignal, sampleRate, BFlist, ...
173
    MAPparamsName, AN_spikesOrProbability, paramChanges);
174
175
176
%% the model run is now complete. Now display the results
177
UTIL_showMAP(showMapOptions, paramChanges)
178
figure(97)
179
title (['tones / noise levels: ' num2str([leveldBSPL noiseLevel])])
180
if strcmp(signalType,'tones')
181
    disp(['duration=' num2str(duration)])
182
    disp(['level=' num2str(leveldBSPL)])
183
    disp(['toneFrequency=' num2str(toneFrequency)])
184
    global DRNLParams
185
    disp(['attenuation factor =' ...
186
        num2str(DRNLParams.rateToAttenuationFactor, '%5.3f') ])
187
    disp(['attenuation factor (probability)=' ...
188
        num2str(DRNLParams.rateToAttenuationFactorProb, '%5.3f') ])
189
    disp(AN_spikesOrProbability)
190
end
191
disp(paramChanges)
192
toc
193
path(restorePath)