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 @ 29:b51bf546ca3f

History | View | Annotate | Download (9.97 KB)

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