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 / multithreshold 1.46 / testAN.m @ 29:b51bf546ca3f

History | View | Annotate | Download (9.89 KB)

1
function vectorStrength=testAN(targetFrequency,BFlist, levels)
2
% testIHC used either for IHC I/O function ...
3
%  or receptive field (doReceptiveFields=1)
4

    
5
global experiment method stimulusParameters
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

    
14
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
15
    ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
16
    ['..' filesep 'testPrograms'])
17

    
18
if nargin<3
19
    levels=-10:10:80;
20
    % levels=80:10:90;
21
end
22

    
23
nLevels=length(levels);
24

    
25
toneDuration=.2;
26
rampDuration=0.002;
27
silenceDuration=.02;
28
localPSTHbinwidth=0.001;
29

    
30
% Use only the first frequency in the GUI targetFrequency box to defineBF
31
% targetFrequency=stimulusParameters.targetFrequency(1);
32
% BFlist=targetFrequency;
33

    
34
AN_HSRonset=zeros(nLevels,1);
35
AN_HSRsaturated=zeros(nLevels,1);
36
AN_LSRonset=zeros(nLevels,1);
37
AN_LSRsaturated=zeros(nLevels,1);
38
CNLSRrate=zeros(nLevels,1);
39
CNHSRsaturated=zeros(nLevels,1);
40
ICHSRsaturated=zeros(nLevels,1);
41
ICLSRsaturated=zeros(nLevels,1);
42
vectorStrength=zeros(nLevels,1);
43

    
44
AR=zeros(nLevels,1);
45
MOC=zeros(nLevels,1);
46

    
47
% ANoutput=zeros(200,200);
48

    
49
figure(15), clf
50
set(gcf,'position',[980   356   401   321])
51
figure(5), clf
52
set(gcf,'position', [980 34 400 295])
53
drawnow
54

    
55
%% guarantee that the sample rate is at least 10 times the frequency
56
sampleRate=50000;
57
while sampleRate< 10* targetFrequency
58
    sampleRate=sampleRate+10000;
59
end
60

    
61
%% adjust sample rate so that the pure tone stimulus has an integer
62
%% numver of epochs in a period
63
dt=1/sampleRate;
64
period=1/targetFrequency;
65
ANspeedUpFactor=5;  %anticipating MAP (needs clearing up)
66
ANdt=dt*ANspeedUpFactor;
67
ANdt=period/round(period/ANdt);
68
dt=ANdt/ANspeedUpFactor;
69
sampleRate=1/dt;
70
epochsPerPeriod=sampleRate*period;
71

    
72
%% main computational loop (vary level)    
73
levelNo=0;
74
for leveldB=levels
75
    levelNo=levelNo+1;
76

    
77
    fprintf('%4.0f\t', leveldB)
78
    amp=28e-6*10^(leveldB/20);
79

    
80
    time=dt:dt:toneDuration;
81
    rampTime=dt:dt:rampDuration;
82
    ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
83
        ones(1,length(time)-length(rampTime))];
84
    ramp=ramp.*fliplr(ramp);
85

    
86
    silence=zeros(1,round(silenceDuration/dt));
87

    
88
    % create signal (leveldB/ targetFrequency)
89
    inputSignal=amp*sin(2*pi*targetFrequency'*time);
90
    inputSignal= ramp.*inputSignal;
91
    inputSignal=[silence inputSignal];
92

    
93
    %% run the model
94
    AN_spikesOrProbability='spikes';
95
    MAPparamsName=experiment.name;
96
    showPlotsAndDetails=0;
97

    
98

    
99
    MAP1_14(inputSignal, 1/dt, BFlist, ...
100
        MAPparamsName, AN_spikesOrProbability);
101

    
102
    nTaus=length(tauCas);
103

    
104
    %LSR (same as HSR if no LSR fibers present)
105
    [nANFibers nTimePoints]=size(ANoutput);
106

    
107
    numLSRfibers=nANFibers/nTaus;
108
    numHSRfibers=numLSRfibers;
109

    
110
    LSRspikes=ANoutput(1:numLSRfibers,:);
111
    PSTH=UTIL_PSTHmaker(LSRspikes, ANdt, localPSTHbinwidth);
112
    PSTHLSR=mean(PSTH,1)/localPSTHbinwidth;  % across fibers rates
113
    PSTHtime=localPSTHbinwidth:localPSTHbinwidth:...
114
        localPSTHbinwidth*length(PSTH);
115
    AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window
116
    AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end));
117

    
118
    % HSR
119
    HSRspikes= ANoutput(end- numHSRfibers+1:end, :);
120
    PSTH=UTIL_PSTHmaker(HSRspikes, ANdt, localPSTHbinwidth);
121
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
122
    AN_HSRonset(levelNo)= max(PSTH);
123
    AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end));
124

    
125
    figure(5), subplot(2,2,2)
126
    hold off, bar(PSTHtime,PSTH, 'b')
127
    hold on,  bar(PSTHtime,PSTHLSR,'r')
128
    ylim([0 1000])
129
    xlim([0 length(PSTH)*localPSTHbinwidth])
130
    set(gcf,'name',[num2str(BFlist), ' Hz: ' num2str(leveldB) ' dB']);
131

    
132
    % AN - CV
133
    %  CV is computed 5 times. Use the middle one (3) as most typical
134
    cvANHSR=  UTIL_CV(HSRspikes, ANdt);
135

    
136
    % AN - vector strength
137
    PSTH=sum(HSRspikes);
138
    [PH, binTimes]=UTIL_periodHistogram...
139
        (PSTH, ANdt, targetFrequency);
140
    VS=UTIL_vectorStrength(PH);
141
    vectorStrength(levelNo)=VS;
142
    disp(['sat rate= ' num2str(AN_HSRsaturated(levelNo)) ...
143
        ';   phase-locking VS = ' num2str(VS)])
144
    title(['AN HSR: CV=' num2str(cvANHSR(3),'%5.2f') ...
145
        'VS=' num2str(VS,'%5.2f')])
146

    
147
    % CN - first-order neurons
148

    
149
    % CN LSR
150
    [nCNneurons c]=size(CNoutput);
151
    nLSRneurons=round(nCNneurons/nTaus);
152
    CNLSRspikes=CNoutput(1:nLSRneurons,:);
153
    PSTH=UTIL_PSTHmaker(CNLSRspikes, ANdt, localPSTHbinwidth);
154
    PSTH=sum(PSTH)/nLSRneurons;
155
    CNLSRrate(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
156

    
157
    %CN HSR
158
    MacGregorMultiHSRspikes=...
159
        CNoutput(end-nLSRneurons:end,:);
160
    PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, ANdt, localPSTHbinwidth);
161
    PSTH=sum(PSTH)/nLSRneurons;
162
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
163

    
164
    CNHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
165

    
166
    figure(5), subplot(2,2,3)
167
    bar(PSTHtime,PSTH)
168
    ylim([0 1000])
169
    xlim([0 length(PSTH)*localPSTHbinwidth])
170
    cvMMHSR= UTIL_CV(MacGregorMultiHSRspikes, ANdt);
171
    title(['CN    CV= ' num2str(cvMMHSR(3),'%5.2f')])
172

    
173
    % IC LSR
174
    [nICneurons c]=size(ICoutput);
175
    nLSRneurons=round(nICneurons/nTaus);
176
    ICLSRspikes=ICoutput(1:nLSRneurons,:);
177
    PSTH=UTIL_PSTHmaker(ICLSRspikes, ANdt, localPSTHbinwidth);
178
    ICLSRsaturated(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
179

    
180
    %IC HSR
181
    MacGregorMultiHSRspikes=...
182
        ICoutput(end-nLSRneurons:end,:);
183
    PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, ANdt, localPSTHbinwidth);
184
    PSTH=sum(PSTH)/nLSRneurons;
185
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
186

    
187
    ICHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
188

    
189
    AR(levelNo)=min(ARattenuation);
190
    MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end));
191

    
192
    time=dt:dt:dt*size(ICmembraneOutput,2);
193
    figure(5), subplot(2,2,4)
194
    plot(time,ICmembraneOutput(2, 1:end),'k')
195
    ylim([-0.07 0])
196
    xlim([0 max(time)])
197
    title(['IC  ' num2str(leveldB,'%4.0f') 'dB'])
198
    drawnow
199

    
200
    figure(5), subplot(2,2,1)
201
    plot(20*log10(MOC), 'k'),
202
    title(' MOC'), ylabel('dB attenuation')
203
    ylim([-30 0])
204

    
205

    
206
end % level
207
figure(5), subplot(2,2,1)
208
plot(levels,20*log10(MOC), 'k'),
209
title(' MOC'), ylabel('dB attenuation')
210
ylim([-30 0])
211
xlim([0 max(levels)])
212

    
213
fprintf('\n')
214
toneDuration=2;
215
rampDuration=0.004;
216
silenceDuration=.02;
217
nRepeats=200;   % no. of AN fibers
218
fprintf('toneDuration  %6.3f\n', toneDuration)
219
fprintf(' %6.0f  AN fibers (repeats)\n', nRepeats)
220
fprintf('levels')
221
fprintf('%6.2f\t', levels)
222
fprintf('\n')
223

    
224

    
225
% ---------------------------------------------------- display parameters
226

    
227
figure(15), clf
228
nRows=2; nCols=2;
229

    
230
% AN rate - level ONSET functions
231
subplot(nRows,nCols,1)
232
plot(levels,AN_LSRonset,'ro'), hold on
233
plot(levels,AN_HSRonset,'ko'), hold off
234
ylim([0 1000]),  xlim([min(levels) max(levels)])
235
ttl=['tauCa= ' num2str(IHCpreSynapseParams.tauCa)];
236
title( ttl)
237
xlabel('level dB SPL'), ylabel('peak rate (sp/s)'), grid on
238
text(0, 800, 'AN onset', 'fontsize', 16)
239

    
240
% AN rate - level ADAPTED function
241
subplot(nRows,nCols,2)
242
plot(levels,AN_LSRsaturated, 'ro'), hold on
243
plot(levels,AN_HSRsaturated, 'ko'), hold off
244
ylim([0 400])
245
set(gca,'ytick',0:50:300)
246
xlim([min(levels) max(levels)])
247
set(gca,'xtick',[levels(1):20:levels(end)])
248
%     grid on
249
ttl=[   'spont=' num2str(mean(AN_HSRsaturated(1,:)),'%4.0f')...
250
    '  sat=' num2str(mean(AN_HSRsaturated(end,1)),'%4.0f')];
251
title( ttl)
252
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
253
text(0, 340, 'AN adapted', 'fontsize', 16), grid on
254

    
255
% CN rate - level ADAPTED function
256
subplot(nRows,nCols,3)
257
plot(levels,CNLSRrate, 'ro'), hold on
258
plot(levels,CNHSRsaturated, 'ko'), hold off
259
ylim([0 400])
260
set(gca,'ytick',0:50:300)
261
xlim([min(levels) max(levels)])
262
set(gca,'xtick',[levels(1):20:levels(end)])
263
%     grid on
264
ttl=[   'spont=' num2str(mean(CNHSRsaturated(1,:)),'%4.0f') '  sat=' ...
265
    num2str(mean(CNHSRsaturated(end,1)),'%4.0f')];
266
title( ttl)
267
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
268
text(0, 350, 'CN', 'fontsize', 16), grid on
269

    
270
% IC rate - level ADAPTED function
271
subplot(nRows,nCols,4)
272
plot(levels,ICLSRsaturated, 'ro'), hold on
273
plot(levels,ICHSRsaturated, 'ko'), hold off
274
ylim([0 400])
275
set(gca,'ytick',0:50:300)
276
xlim([min(levels) max(levels)])
277
set(gca,'xtick',[levels(1):20:levels(end)]), grid on
278

    
279

    
280
ttl=['spont=' num2str(mean(ICHSRsaturated(1,:)),'%4.0f') ...
281
    '  sat=' num2str(mean(ICHSRsaturated(end,1)),'%4.0f')];
282
title( ttl)
283
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
284
text(0, 350, 'IC', 'fontsize', 16)
285
set(gcf,'name',' AN CN IC rate/level')
286

    
287
peakVectorStrength=max(vectorStrength);
288

    
289
fprintf('\n')
290
disp('levels vectorStrength')
291
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
292
fprintf('\n')
293
fprintf('Phase locking, max vector strength=\t %6.4f\n\n',...
294
    max(vectorStrength))
295

    
296
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
297
    AN_LSRonset AN_LSRsaturated ...
298
    CNHSRsaturated CNLSRrate...
299
    ICHSRsaturated ICLSRsaturated];
300
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
301
UTIL_printTabTable(round(allData))
302
fprintf('VS (phase locking)= \t%6.4f\n\n',...
303
    max(vectorStrength))
304

    
305
UTIL_showStruct(IHC_cilia_RPParams, 'IHC_cilia_RPParams')
306
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
307
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
308

    
309
fprintf('\n')
310
disp('levels vectorStrength')
311
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
312
fprintf('\n')
313
fprintf('Phase locking, max vector strength= \t%6.4f\n\n',...
314
    max(vectorStrength))
315

    
316
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
317
    AN_LSRonset AN_LSRsaturated ...
318
    CNHSRsaturated CNLSRrate...
319
    ICHSRsaturated ICLSRsaturated];
320
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
321
UTIL_printTabTable(round(allData))
322
fprintf('VS (phase locking)= \t%6.4f\n\n',...
323
    max(vectorStrength))
324