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 @ 0:f233164f4c86

History | View | Annotate | Download (8.86 KB)

1
function testAN
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 IHCpreSynapseParams
7
global AN_IHCsynapseParams
8
% global saveMembranePotential MacGregorMultiParams
9
dbstop if error
10

    
11
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
12
    ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
13
    ['..' filesep 'testPrograms'])
14

    
15
levels=-10:10:80;
16
% levels=80:10:90;
17
nLevels=length(levels);
18

    
19
toneDuration=.2;
20
rampDuration=0.002;
21
silenceDuration=.02;
22
localPSTHbinwidth=0.001;
23

    
24
% Use only the first frequency in the GUI targetFrequency box to defineBF
25
targetFrequency=stimulusParameters.targetFrequency(1);
26
BFlist=targetFrequency;
27

    
28
AN_HSRonset=zeros(nLevels,1);
29
AN_HSRsaturated=zeros(nLevels,1);
30
AN_LSRonset=zeros(nLevels,1);
31
AN_LSRsaturated=zeros(nLevels,1);
32
CNLSRrate=zeros(nLevels,1);
33
CNHSRsaturated=zeros(nLevels,1);
34
ICHSRsaturated=zeros(nLevels,1);
35
ICLSRsaturated=zeros(nLevels,1);
36
vectorStrength=zeros(nLevels,1);
37

    
38
AR=zeros(nLevels,1);
39
MOC=zeros(nLevels,1);
40

    
41
% ANoutput=zeros(200,200);
42

    
43
figure(15), clf
44
set(gcf,'position',[980   356   401   321])
45
figure(5), clf
46
 set(gcf,'position', [980 34 400 295])
47
drawnow
48

    
49
levelNo=0;
50
for leveldB=levels
51
    levelNo=levelNo+1;
52

    
53
    % sample rate should be amultiple of the targetFrequency for PSTH below
54
    sampleRate=50000;
55
    dt=1/sampleRate;
56
    period=1/targetFrequency;
57
    dt=dt*(dt/period)*round(period/dt);
58

    
59
    fprintf('%4.0f\t', leveldB)
60
    amp=28e-6*10^(leveldB/20);
61

    
62
    time=dt:dt:toneDuration;
63
    rampTime=dt:dt:rampDuration;
64
    ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
65
        ones(1,length(time)-length(rampTime))];
66
    ramp=ramp.*fliplr(ramp);
67

    
68
    silence=zeros(1,round(silenceDuration/dt));
69

    
70
    % create signal (leveldB/ targetFrequency)
71
    inputSignal=amp*sin(2*pi*targetFrequency'*time);
72
    inputSignal= ramp.*inputSignal;
73
    inputSignal=[silence inputSignal];
74

    
75
    %% run the model
76
    AN_spikesOrProbability='spikes';
77
    MAPparamsName=experiment.name;
78
    showPlotsAndDetails=0;
79

    
80
    global ANoutput CNoutput ICoutput ICmembraneOutput tauCas
81
    global ARattenuation MOCattenuation
82
    
83
    MAP1_14(inputSignal, 1/dt, targetFrequency, ...
84
        MAPparamsName, AN_spikesOrProbability);
85

    
86
    nTaus=length(tauCas);
87

    
88
    %LSR (same as HSR if no LSR fibers present)
89
    [nANFibers nTimePoints]=size(ANoutput);
90
    dt=dt* length(inputSignal)/nTimePoints;
91

    
92
    numLSRfibers=nANFibers/nTaus;
93
    numHSRfibers=numLSRfibers;
94

    
95
    LSRspikes=ANoutput(1:numLSRfibers,:);
96
    PSTH=UTIL_makePSTH(LSRspikes, dt, localPSTHbinwidth);
97
    PSTHLSR=mean(PSTH,1)/localPSTHbinwidth;  % across fibers rates
98
    PSTHtime=localPSTHbinwidth:localPSTHbinwidth:...
99
        localPSTHbinwidth*length(PSTH);
100
    AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window
101
    AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end));
102

    
103
    % HSR
104
    HSRspikes= ANoutput(end- numHSRfibers+1:end, :);
105
    PSTH=UTIL_makePSTH(HSRspikes, dt, localPSTHbinwidth);
106
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
107
    AN_HSRonset(levelNo)= max(PSTH);
108
    AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end));
109

    
110
    figure(5), subplot(2,2,2)
111
    hold off, bar(PSTHtime,PSTH, 'b')
112
    hold on,  bar(PSTHtime,PSTHLSR,'r')
113
    ylim([0 1000])
114
xlim([0 length(PSTH)*localPSTHbinwidth])
115
    
116
    % AN - CV
117
    %  CV is computed 5 times. Use the middle one (3) as most typical
118
    cvANHSR=  UTIL_CV(HSRspikes, dt);
119

    
120
    % AN - vector strength
121
    PSTH=sum(HSRspikes);
122
    [PH, binTimes]=UTIL_periodHistogram...
123
        (PSTH, dt, targetFrequency);
124
    VS=UTIL_vectorStrength(PH);
125
    vectorStrength(levelNo)=VS;
126
    disp(['sat rate= ' num2str(AN_HSRsaturated(levelNo)) ...
127
        ';   phase-locking VS = ' num2str(VS)])
128
    title(['AN HSR: CV=' num2str(cvANHSR(3),'%5.2f') ...
129
        'VS=' num2str(VS,'%5.2f')])
130

    
131
    % CN - first-order neurons
132

    
133
    % CN LSR
134
    [nCNneurons c]=size(CNoutput);
135
    nLSRneurons=round(nCNneurons/nTaus);
136
    CNLSRspikes=CNoutput(1:nLSRneurons,:);
137
    PSTH=UTIL_makePSTH(CNLSRspikes, dt, localPSTHbinwidth);
138
    PSTH=sum(PSTH)/nLSRneurons;
139
    CNLSRrate(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
140

    
141
    %CN HSR
142
    MacGregorMultiHSRspikes=...
143
        CNoutput(end-nLSRneurons:end,:);
144
    PSTH=UTIL_makePSTH(MacGregorMultiHSRspikes, dt, localPSTHbinwidth);
145
    PSTH=sum(PSTH)/nLSRneurons;
146
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
147

    
148
    CNHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
149

    
150
    figure(5), subplot(2,2,3)
151
    bar(PSTHtime,PSTH)
152
    ylim([0 1000])
153
    xlim([0 length(PSTH)*localPSTHbinwidth])
154
    cvMMHSR= UTIL_CV(MacGregorMultiHSRspikes, dt);
155
    title(['CN    CV= ' num2str(cvMMHSR(3),'%5.2f')])
156

    
157
    % IC LSR
158
    [nICneurons c]=size(ICoutput);
159
    nLSRneurons=round(nICneurons/nTaus);
160
    ICLSRspikes=ICoutput(1:nLSRneurons,:);
161
    PSTH=UTIL_makePSTH(ICLSRspikes, dt, localPSTHbinwidth);
162
    ICLSRsaturated(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
163

    
164
    %IC HSR
165
    MacGregorMultiHSRspikes=...
166
        ICoutput(end-nLSRneurons:end,:);
167
    PSTH=UTIL_makePSTH(MacGregorMultiHSRspikes, dt, localPSTHbinwidth);
168
    PSTH=sum(PSTH)/nLSRneurons;
169
    PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
170

    
171
    ICHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
172

    
173
    AR(levelNo)=min(ARattenuation);
174
    MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end));
175

    
176
    time=dt:dt:dt*size(ICmembraneOutput,2);
177
    figure(5), subplot(2,2,4)
178
    plot(time,ICmembraneOutput(2, 1:end),'k')
179
    ylim([-0.07 0])
180
    xlim([0 max(time)])
181
    title(['IC  ' num2str(leveldB,'%4.0f') 'dB'])
182
    drawnow
183
    
184
    figure(5), subplot(2,2,1)
185
    plot(20*log10(MOC), 'k'),
186
    title(' MOC'), ylabel('dB attenuation')
187
    ylim([-30 0])
188

    
189

    
190
end % level
191
figure(5), subplot(2,2,1)
192
    plot(levels,20*log10(MOC), 'k'),
193
    title(' MOC'), ylabel('dB attenuation')
194
    ylim([-30 0])
195
xlim([0 max(levels)])
196

    
197
fprintf('\n')
198
toneDuration=2;
199
rampDuration=0.004;
200
silenceDuration=.02;
201
nRepeats=200;   % no. of AN fibers
202
fprintf('toneDuration  %6.3f\n', toneDuration)
203
fprintf(' %6.0f  AN fibers (repeats)\n', nRepeats)
204
fprintf('levels')
205
fprintf('%6.2f\t', levels)
206
fprintf('\n')
207

    
208

    
209
% ---------------------------------------------------- display parameters
210

    
211
figure(15), clf
212
set(gcf,'position',[1000   356   381   321])
213
nRows=2; nCols=2;
214

    
215
% AN rate - level ONSET functions
216
subplot(nRows,nCols,1)
217
plot(levels,AN_LSRonset,'ro'), hold on
218
plot(levels,AN_HSRonset,'ko'), hold off
219
ylim([0 1000]),  xlim([min(levels) max(levels)])
220
ttl=['tauCa= ' num2str(IHCpreSynapseParams.tauCa)];
221
title( ttl)
222
xlabel('level dB SPL'), ylabel('peak rate (sp/s)'), grid on
223
text(0, 800, 'AN onset', 'fontsize', 16)
224

    
225
% AN rate - level ADAPTED function
226
subplot(nRows,nCols,2)
227
plot(levels,AN_LSRsaturated, 'ro'), hold on
228
plot(levels,AN_HSRsaturated, 'ko'), hold off
229
ylim([0 400])
230
set(gca,'ytick',0:50:300)
231
xlim([min(levels) max(levels)])
232
set(gca,'xtick',[levels(1):20:levels(end)])
233
%     grid on
234
ttl=[   'spont=' num2str(mean(AN_HSRsaturated(1,:)),'%4.0f')...
235
    '  sat=' num2str(mean(AN_HSRsaturated(end,1)),'%4.0f')];
236
title( ttl)
237
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
238
text(0, 340, 'AN adapted', 'fontsize', 16), grid on
239

    
240
% CN rate - level ADAPTED function
241
subplot(nRows,nCols,3)
242
plot(levels,CNLSRrate, 'ro'), hold on
243
plot(levels,CNHSRsaturated, '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(CNHSRsaturated(1,:)),'%4.0f') '  sat=' ...
250
    num2str(mean(CNHSRsaturated(end,1)),'%4.0f')];
251
title( ttl)
252
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
253
text(0, 350, 'CN', 'fontsize', 16), grid on
254

    
255
% IC rate - level ADAPTED function
256
subplot(nRows,nCols,4)
257
plot(levels,ICLSRsaturated, 'ro'), hold on
258
plot(levels,ICHSRsaturated, '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)]), grid on
263

    
264
ttl=['spont=' num2str(mean(ICHSRsaturated(1,:)),'%4.0f') ...
265
    '  sat=' num2str(mean(ICHSRsaturated(end,1)),'%4.0f')];
266
title( ttl)
267
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
268
text(0, 350, 'IC', 'fontsize', 16)
269
set(gcf,'name',' AN CN IC rate/level')
270

    
271
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
272
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
273

    
274
fprintf('\n')
275
disp('levels vectorStrength')
276
fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
277
fprintf('\n')
278
fprintf('Phase locking, max vector strength= %6.4f\n\n',...
279
    max(vectorStrength))
280

    
281
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
282
    AN_LSRonset AN_LSRsaturated ...
283
    CNHSRsaturated CNLSRrate...
284
    ICHSRsaturated ICLSRsaturated];
285
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
286
UTIL_printTabTable(round(allData))
287
fprintf('VS (phase locking)= \t%6.4f\n\n',...
288
    max(vectorStrength))
289