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

History | View | Annotate | Download (10.2 KB)

1 29:b51bf546ca3f rmeddis
function vectorStrength=testAN(targetFrequency,BFlist, levels, ...
2
    paramsName,paramChanges)
3 32:82fb37eb430e rmeddis
% generates rate/level functions for AN and brainstem units.
4
%  also other information like PSTHs, MOC efferent activity levels.
5
% testAN(1000,1000, -10:10:80,'Normal',[]);
6 29:b51bf546ca3f rmeddis
7
global IHC_VResp_VivoParams  IHC_cilia_RPParams IHCpreSynapseParams
8
global AN_IHCsynapseParams
9
10 32:82fb37eb430e rmeddis
global ANoutput ANdt CNoutput ICoutput ICmembraneOutput ANtauCas
11
global ARattenuation MOCattenuation
12 29:b51bf546ca3f rmeddis
13
dbstop if error
14
restorePath=path;
15
16
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
17
    ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
18
    ['..' filesep 'testPrograms'])
19
20
if nargin<5
21
    paramChanges=[];
22
end
23
24
if nargin<4
25
    paramsName='Normal';
26
end
27
28
if nargin<3
29
    levels=-10:10:80;
30
    % levels=80:10:90;
31
end
32
33
nLevels=length(levels);
34
35
toneDuration=.2;
36
rampDuration=0.002;
37
silenceDuration=.02;
38
localPSTHbinwidth=0.001;
39
40
% Use only the first frequency in the GUI targetFrequency box to defineBF
41
% targetFrequency=stimulusParameters.targetFrequency(1);
42
% BFlist=targetFrequency;
43
44
AN_HSRonset=zeros(nLevels,1);
45
AN_HSRsaturated=zeros(nLevels,1);
46
AN_LSRonset=zeros(nLevels,1);
47
AN_LSRsaturated=zeros(nLevels,1);
48
CNLSRrate=zeros(nLevels,1);
49
CNHSRsaturated=zeros(nLevels,1);
50
ICHSRsaturated=zeros(nLevels,1);
51
ICLSRsaturated=zeros(nLevels,1);
52
vectorStrength=zeros(nLevels,1);
53
54
AR=zeros(nLevels,1);
55
MOC=zeros(nLevels,1);
56
57
% ANoutput=zeros(200,200);
58
59
figure(15), clf
60
set(gcf,'position',[980   356   401   321])
61
figure(5), clf
62
set(gcf,'position', [980 34 400 295])
63
drawnow
64
65
%% guarantee that the sample rate is at least 10 times the frequency
66
sampleRate=50000;
67
while sampleRate< 10* targetFrequency
68
    sampleRate=sampleRate+10000;
69
end
70
71
%% adjust sample rate so that the pure tone stimulus has an integer
72
%% numver of epochs in a period
73
dt=1/sampleRate;
74
period=1/targetFrequency;
75
ANspeedUpFactor=5;  %anticipating MAP (needs clearing up)
76
ANdt=dt*ANspeedUpFactor;
77
ANdt=period/round(period/ANdt);
78
dt=ANdt/ANspeedUpFactor;
79
sampleRate=1/dt;
80
epochsPerPeriod=sampleRate*period;
81
82 32:82fb37eb430e rmeddis
%% main computational loop (vary level)
83 29:b51bf546ca3f rmeddis
levelNo=0;
84
for leveldB=levels
85
    levelNo=levelNo+1;
86 32:82fb37eb430e rmeddis
87 29:b51bf546ca3f rmeddis
    fprintf('%4.0f\t', leveldB)
88
    amp=28e-6*10^(leveldB/20);
89 32:82fb37eb430e rmeddis
90 29:b51bf546ca3f rmeddis
    time=dt:dt:toneDuration;
91
    rampTime=dt:dt:rampDuration;
92
    ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
93
        ones(1,length(time)-length(rampTime))];
94
    ramp=ramp.*fliplr(ramp);
95 32:82fb37eb430e rmeddis
96 29:b51bf546ca3f rmeddis
    silence=zeros(1,round(silenceDuration/dt));
97 32:82fb37eb430e rmeddis
98 29:b51bf546ca3f rmeddis
    % create signal (leveldB/ targetFrequency)
99
    inputSignal=amp*sin(2*pi*targetFrequency'*time);
100
    inputSignal= ramp.*inputSignal;
101
    inputSignal=[silence inputSignal];
102 32:82fb37eb430e rmeddis
103 29:b51bf546ca3f rmeddis
    %% run the model
104
    AN_spikesOrProbability='spikes';
105
    showPlotsAndDetails=0;
106 32:82fb37eb430e rmeddis
107
108 29:b51bf546ca3f rmeddis
    MAP1_14(inputSignal, 1/dt, BFlist, ...
109
        paramsName, AN_spikesOrProbability, paramChanges);
110 32:82fb37eb430e rmeddis
111
    nTaus=length(ANtauCas);
112
113 29:b51bf546ca3f rmeddis
    %LSR (same as HSR if no LSR fibers present)
114
    [nANFibers nTimePoints]=size(ANoutput);
115 32:82fb37eb430e rmeddis
116 29:b51bf546ca3f rmeddis
    numLSRfibers=nANFibers/nTaus;
117
    numHSRfibers=numLSRfibers;
118 32:82fb37eb430e rmeddis
119 29:b51bf546ca3f rmeddis
    LSRspikes=ANoutput(1:numLSRfibers,:);
120
    PSTH=UTIL_PSTHmaker(LSRspikes, ANdt, localPSTHbinwidth);
121
    PSTHLSR=mean(PSTH,1)/localPSTHbinwidth;  % across fibers rates
122
    PSTHtime=localPSTHbinwidth:localPSTHbinwidth:...
123
        localPSTHbinwidth*length(PSTH);
124
    AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window
125
    AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end));
126 32:82fb37eb430e rmeddis
127 29:b51bf546ca3f rmeddis
    % HSR
128
    HSRspikes= ANoutput(end- numHSRfibers+1:end, :);
129
    PSTH=UTIL_PSTHmaker(HSRspikes, ANdt, localPSTHbinwidth);
130
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
131
    AN_HSRonset(levelNo)= max(PSTH);
132
    AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end));
133 32:82fb37eb430e rmeddis
134 29:b51bf546ca3f rmeddis
    figure(5), subplot(2,2,2)
135
    hold off, bar(PSTHtime,PSTH, 'b')
136
    hold on,  bar(PSTHtime,PSTHLSR,'r')
137
    ylim([0 1000])
138
    xlim([0 length(PSTH)*localPSTHbinwidth])
139 33:161913b595ae rmeddis
    set(gcf,'name',['PSTH: ' num2str(BFlist), ' Hz: ' num2str(leveldB) ' dB']);
140 32:82fb37eb430e rmeddis
141 29:b51bf546ca3f rmeddis
    % AN - CV
142
    %  CV is computed 5 times. Use the middle one (3) as most typical
143
    cvANHSR=  UTIL_CV(HSRspikes, ANdt);
144 32:82fb37eb430e rmeddis
145 29:b51bf546ca3f rmeddis
    % AN - vector strength
146
    PSTH=sum(HSRspikes);
147
    [PH, binTimes]=UTIL_periodHistogram...
148
        (PSTH, ANdt, targetFrequency);
149
    VS=UTIL_vectorStrength(PH);
150
    vectorStrength(levelNo)=VS;
151
    disp(['sat rate= ' num2str(AN_HSRsaturated(levelNo)) ...
152
        ';   phase-locking VS = ' num2str(VS)])
153
    title(['AN HSR: CV=' num2str(cvANHSR(3),'%5.2f') ...
154
        'VS=' num2str(VS,'%5.2f')])
155 32:82fb37eb430e rmeddis
156 29:b51bf546ca3f rmeddis
    % CN - first-order neurons
157 32:82fb37eb430e rmeddis
158 29:b51bf546ca3f rmeddis
    % CN LSR
159
    [nCNneurons c]=size(CNoutput);
160
    nLSRneurons=round(nCNneurons/nTaus);
161
    CNLSRspikes=CNoutput(1:nLSRneurons,:);
162
    PSTH=UTIL_PSTHmaker(CNLSRspikes, ANdt, localPSTHbinwidth);
163
    PSTH=sum(PSTH)/nLSRneurons;
164
    CNLSRrate(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
165 32:82fb37eb430e rmeddis
166 29:b51bf546ca3f rmeddis
    %CN HSR
167
    MacGregorMultiHSRspikes=...
168
        CNoutput(end-nLSRneurons:end,:);
169
    PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, ANdt, localPSTHbinwidth);
170
    PSTH=sum(PSTH)/nLSRneurons;
171
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
172 32:82fb37eb430e rmeddis
173 29:b51bf546ca3f rmeddis
    CNHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
174 32:82fb37eb430e rmeddis
175 29:b51bf546ca3f rmeddis
    figure(5), subplot(2,2,3)
176
    bar(PSTHtime,PSTH)
177
    ylim([0 1000])
178
    xlim([0 length(PSTH)*localPSTHbinwidth])
179
    cvMMHSR= UTIL_CV(MacGregorMultiHSRspikes, ANdt);
180
    title(['CN    CV= ' num2str(cvMMHSR(3),'%5.2f')])
181 32:82fb37eb430e rmeddis
182 29:b51bf546ca3f rmeddis
    % IC LSR
183
    [nICneurons c]=size(ICoutput);
184
    nLSRneurons=round(nICneurons/nTaus);
185
    ICLSRspikes=ICoutput(1:nLSRneurons,:);
186
    PSTH=UTIL_PSTHmaker(ICLSRspikes, ANdt, localPSTHbinwidth);
187
    ICLSRsaturated(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
188 32:82fb37eb430e rmeddis
189 29:b51bf546ca3f rmeddis
    %IC HSR
190
    MacGregorMultiHSRspikes=...
191
        ICoutput(end-nLSRneurons:end,:);
192
    PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, ANdt, localPSTHbinwidth);
193
    PSTH=sum(PSTH)/nLSRneurons;
194
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
195 32:82fb37eb430e rmeddis
196 29:b51bf546ca3f rmeddis
    ICHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
197 32:82fb37eb430e rmeddis
198 29:b51bf546ca3f rmeddis
    AR(levelNo)=min(ARattenuation);
199
    MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end));
200 32:82fb37eb430e rmeddis
201 29:b51bf546ca3f rmeddis
    time=dt:dt:dt*size(ICmembraneOutput,2);
202
    figure(5), subplot(2,2,4)
203
    plot(time,ICmembraneOutput(2, 1:end),'k')
204
    ylim([-0.07 0])
205
    xlim([0 max(time)])
206
    title(['IC  ' num2str(leveldB,'%4.0f') 'dB'])
207
    drawnow
208 32:82fb37eb430e rmeddis
209 29:b51bf546ca3f rmeddis
    figure(5), subplot(2,2,1)
210
    plot(20*log10(MOC), 'k'),
211
    title(' MOC'), ylabel('dB attenuation')
212
    ylim([-30 0])
213 32:82fb37eb430e rmeddis
214
215 29:b51bf546ca3f rmeddis
end % level
216
figure(5), subplot(2,2,1)
217
plot(levels,20*log10(MOC), 'k'),
218
title(' MOC'), ylabel('dB attenuation')
219
ylim([-30 0])
220
xlim([0 max(levels)])
221
222
fprintf('\n')
223
toneDuration=2;
224
rampDuration=0.004;
225
silenceDuration=.02;
226
nRepeats=200;   % no. of AN fibers
227
fprintf('toneDuration  %6.3f\n', toneDuration)
228
fprintf(' %6.0f  AN fibers (repeats)\n', nRepeats)
229
fprintf('levels')
230
fprintf('%6.2f\t', levels)
231
fprintf('\n')
232
233
234
% ---------------------------------------------------- display parameters
235
236
figure(15), clf
237
nRows=2; nCols=2;
238
239
% AN rate - level ONSET functions
240
subplot(nRows,nCols,1)
241
plot(levels,AN_LSRonset,'ro'), hold on
242
plot(levels,AN_HSRonset,'ko'), hold off
243
ylim([0 1000]),  xlim([min(levels) max(levels)])
244
ttl=['tauCa= ' num2str(IHCpreSynapseParams.tauCa)];
245
title( ttl)
246
xlabel('level dB SPL'), ylabel('peak rate (sp/s)'), grid on
247
text(0, 800, 'AN onset', 'fontsize', 16)
248
249
% AN rate - level ADAPTED function
250
subplot(nRows,nCols,2)
251
plot(levels,AN_LSRsaturated, 'ro'), hold on
252
plot(levels,AN_HSRsaturated, 'ko'), hold off
253
ylim([0 400])
254
set(gca,'ytick',0:50:300)
255
xlim([min(levels) max(levels)])
256
set(gca,'xtick',[levels(1):20:levels(end)])
257
%     grid on
258
ttl=[   'spont=' num2str(mean(AN_HSRsaturated(1,:)),'%4.0f')...
259
    '  sat=' num2str(mean(AN_HSRsaturated(end,1)),'%4.0f')];
260
title( ttl)
261
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
262
text(0, 340, 'AN adapted', 'fontsize', 16), grid on
263
264
% CN rate - level ADAPTED function
265
subplot(nRows,nCols,3)
266
plot(levels,CNLSRrate, 'ro'), hold on
267
plot(levels,CNHSRsaturated, 'ko'), hold off
268
ylim([0 400])
269
set(gca,'ytick',0:50:300)
270
xlim([min(levels) max(levels)])
271
set(gca,'xtick',[levels(1):20:levels(end)])
272
%     grid on
273
ttl=[   'spont=' num2str(mean(CNHSRsaturated(1,:)),'%4.0f') '  sat=' ...
274
    num2str(mean(CNHSRsaturated(end,1)),'%4.0f')];
275
title( ttl)
276
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
277
text(0, 350, 'CN', 'fontsize', 16), grid on
278
279
% IC rate - level ADAPTED function
280
subplot(nRows,nCols,4)
281
plot(levels,ICLSRsaturated, 'ro'), hold on
282
plot(levels,ICHSRsaturated, 'ko'), hold off
283
ylim([0 400])
284
set(gca,'ytick',0:50:300)
285
xlim([min(levels) max(levels)])
286
set(gca,'xtick',[levels(1):20:levels(end)]), grid on
287
288
289
ttl=['spont=' num2str(mean(ICHSRsaturated(1,:)),'%4.0f') ...
290
    '  sat=' num2str(mean(ICHSRsaturated(end,1)),'%4.0f')];
291
title( ttl)
292
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
293
text(0, 350, 'IC', 'fontsize', 16)
294
set(gcf,'name',' AN CN IC rate/level')
295
296
peakVectorStrength=max(vectorStrength);
297
298
fprintf('\n')
299
disp('levels vectorStrength')
300
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
301
fprintf('\n')
302
fprintf('Phase locking, max vector strength=\t %6.4f\n\n',...
303
    max(vectorStrength))
304
305
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
306
    AN_LSRonset AN_LSRsaturated ...
307
    CNHSRsaturated CNLSRrate...
308
    ICHSRsaturated ICLSRsaturated];
309
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
310
UTIL_printTabTable(round(allData))
311
fprintf('VS (phase locking)= \t%6.4f\n\n',...
312
    max(vectorStrength))
313
314
UTIL_showStruct(IHC_cilia_RPParams, 'IHC_cilia_RPParams')
315
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
316
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
317
318
fprintf('\n')
319
disp('levels vectorStrength')
320
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
321
fprintf('\n')
322
fprintf('Phase locking, max vector strength= \t%6.4f\n\n',...
323
    max(vectorStrength))
324
325
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
326
    AN_LSRonset AN_LSRsaturated ...
327
    CNHSRsaturated CNLSRrate...
328
    ICHSRsaturated ICLSRsaturated];
329
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
330
UTIL_printTabTable(round(allData))
331
fprintf('VS (phase locking)= \t%6.4f\n\n',...
332
    max(vectorStrength))
333
334 32:82fb37eb430e rmeddis
path(restorePath)