Revision 29:b51bf546ca3f testPrograms

View differences:

testPrograms/testAN.m
1
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)
testPrograms/testANprob.m
1
function vectorStrength=testANprob(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 ANprobRateOutput dt tauCas
10
global ARattenuation MOCattenuation
11

  
12
AN_spikesOrProbability='probability';
13

  
14
dbstop if error
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
end
30

  
31
nLevels=length(levels);
32

  
33
toneDuration=.2;
34
rampDuration=0.002;
35
silenceDuration=.02;
36
localPSTHbinwidth=0.001;
37

  
38
% Use only the first frequency in the GUI targetFrequency box to defineBF
39
% targetFrequency=stimulusParameters.targetFrequency(1);
40
% BFlist=targetFrequency;
41

  
42
AN_HSRonset=zeros(nLevels,1);
43
AN_HSRsaturated=zeros(nLevels,1);
44
AN_LSRonset=zeros(nLevels,1);
45
AN_LSRsaturated=zeros(nLevels,1);
46

  
47
AR=zeros(nLevels,1);
48
MOC=zeros(nLevels,1);
49

  
50
figure(15), clf
51
set(gcf,'position',[607    17   368   321])
52
drawnow
53

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

  
60
%% adjust sample rate so that the pure tone stimulus has an integer
61
%% numver of epochs in a period
62
dt=1/sampleRate;
63
period=1/targetFrequency;
64

  
65
%% main computational loop (vary level)
66
levelNo=0;
67
for leveldB=levels
68
    levelNo=levelNo+1;
69

  
70
    fprintf('%4.0f\t', leveldB)
71
    amp=28e-6*10^(leveldB/20);
72

  
73
    time=dt:dt:toneDuration;
74
    rampTime=dt:dt:rampDuration;
75
    ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
76
        ones(1,length(time)-length(rampTime))];
77
    ramp=ramp.*fliplr(ramp);
78

  
79
    silence=zeros(1,round(silenceDuration/dt));
80

  
81
    % create signal (leveldB/ targetFrequency)
82
    inputSignal=amp*sin(2*pi*targetFrequency'*time);
83
    inputSignal= ramp.*inputSignal;
84
    inputSignal=[silence inputSignal];
85

  
86
    %% run the model
87
    showPlotsAndDetails=0;
88

  
89

  
90
    MAP1_14(inputSignal, 1/dt, BFlist, ...
91
        paramsName, AN_spikesOrProbability, paramChanges);
92

  
93
    nTaus=length(tauCas);
94

  
95
    %LSR (same as HSR if no LSR fibers present)
96
    [nANFibers nTimePoints]=size(ANprobRateOutput);
97

  
98
    numLSRfibers=1;
99
    numHSRfibers=numLSRfibers;
100

  
101
    LSRspikes=ANprobRateOutput(1:numLSRfibers,:);
102
    PSTH=UTIL_PSTHmaker(LSRspikes, dt, localPSTHbinwidth);
103
    PSTHLSR=PSTH/(localPSTHbinwidth/dt);  % across fibers rates
104
    PSTHtime=localPSTHbinwidth:localPSTHbinwidth:...
105
        localPSTHbinwidth*length(PSTH);
106
    AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window
107
    AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end));
108

  
109
    % HSR
110
    HSRspikes= ANprobRateOutput(end- numHSRfibers+1:end, :);
111
    PSTH=UTIL_PSTHmaker(HSRspikes, dt, localPSTHbinwidth);
112
    PSTH=PSTH/(localPSTHbinwidth/dt); % sum across fibers (HSR only)
113
    AN_HSRonset(levelNo)= max(PSTH);
114
    AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end));
115

  
116
    figure(15), subplot(2,2,4)
117
    hold off, bar(PSTHtime,PSTH, 'b')
118
    hold on,  bar(PSTHtime,PSTHLSR,'r')
119
    ylim([0 1000])
120
    xlim([0 length(PSTH)*localPSTHbinwidth])
121
    set(gcf,'name',[num2str(BFlist), ' Hz: ' num2str(leveldB) ' dB']);
122

  
123
    AR(levelNo)=min(ARattenuation);
124
    MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end));
125

  
126

  
127
    figure(15), subplot(2,2,3)
128
    plot(20*log10(MOC), 'k'),
129
    title(' MOC'), ylabel('dB attenuation')
130
    ylim([-30 0])
131

  
132

  
133
end % level
134
figure(15), subplot(2,2,3)
135
plot(levels,20*log10(MOC), 'k'),
136
title(' MOC'), ylabel('dB attenuation')
137
ylim([-30 0])
138
xlim([0 max(levels)])
139

  
140
fprintf('\n')
141
toneDuration=2;
142
rampDuration=0.004;
143
silenceDuration=.02;
144
nRepeats=200;   % no. of AN fibers
145
fprintf('toneDuration  %6.3f\n', toneDuration)
146
fprintf(' %6.0f  AN fibers (repeats)\n', nRepeats)
147
fprintf('levels')
148
fprintf('%6.2f\t', levels)
149
fprintf('\n')
150

  
151

  
152
% ---------------------------------------------------- display parameters
153

  
154

  
155
nRows=2; nCols=2;
156

  
157
% AN rate - level ONSET functions
158
subplot(nRows,nCols,1)
159
plot(levels,AN_LSRonset,'ro'), hold on
160
plot(levels,AN_HSRonset,'ko'), hold off
161
ylim([0 1000]),  xlim([min(levels) max(levels)])
162
ttl=['tauCa= ' num2str(IHCpreSynapseParams.tauCa)];
163
title( ttl)
164
xlabel('level dB SPL'), ylabel('peak rate (sp/s)'), grid on
165
text(0, 800, 'AN onset', 'fontsize', 16)
166

  
167
% AN rate - level ADAPTED function
168
subplot(nRows,nCols,2)
169
plot(levels,AN_LSRsaturated, 'ro'), hold on
170
plot(levels,AN_HSRsaturated, 'ko'), hold off
171
ylim([0 400])
172
set(gca,'ytick',0:50:300)
173
xlim([min(levels) max(levels)])
174
set(gca,'xtick',[levels(1):20:levels(end)])
175
%     grid on
176
ttl=[   'spont=' num2str(mean(AN_HSRsaturated(1,:)),'%4.0f')...
177
    '  sat=' num2str(mean(AN_HSRsaturated(end,1)),'%4.0f')];
178
title( ttl)
179
xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
180
text(0, 340, 'AN adapted', 'fontsize', 16), grid on
181

  
182
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
183
    AN_LSRonset AN_LSRsaturated ];
184
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
185
UTIL_printTabTable(round(allData))
186

  
187

  
188
UTIL_showStruct(IHC_cilia_RPParams, 'IHC_cilia_RPParams')
189
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
190
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
191

  
192
fprintf('\n')
193
disp('levels vectorStrength')
194

  
195
allData=[ levels'  AN_HSRonset AN_HSRsaturated...
196
    AN_LSRonset AN_LSRsaturated ];
197
fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR  \tICLSR \n');
198
UTIL_printTabTable(round(allData))
199

  
testPrograms/testBM.m
1
function testBM (BMlocations, paramsName,...
2
    relativeFrequencies, AN_spikesOrProbability, paramChanges)
3
% testBM generates input output functions for DRNL model for any number
4
% of locations.
5
% Computations are bast on a single channel model (channelBFs=BF)
6
% peak displacement (peakAmp) is measured.
7
%  if DRNLParams.useMOC is chosen, the full model is run (slow)
8
%  otherwise only DRNL is computed.
9
% Tuning curves are generated based on a range of frequencies reletove to
10
% the BF of the location.
11
%
12

  
13
global    DRNLParams
14

  
15
if nargin<5
16
    paramChanges=[];
17
end
18

  
19
if nargin<4
20
    AN_spikesOrProbability='probability';
21
end
22

  
23
savePath=path;
24
addpath (['..' filesep 'utilities'],['..' filesep 'MAP'])
25

  
26
levels=-10:10:90;   nLevels=length(levels);
27
% levels= 50;   nLevels=length(levels);
28

  
29
% refBMdisplacement is the displacement of the BM at threshold
30
% 1 nm disp at  threshold (9 kHz, Ruggero)
31
% ? adjust for frequency
32
refBMdisplacement= 1e-8; % adjusted for 10 nm at 1 kHz 
33

  
34
toneDuration=.200;
35
rampDuration=0.01;
36
silenceDuration=0.01;
37

  
38
sampleRate=30000;
39

  
40
dbstop if error
41
figure(3), clf
42
set(gcf,'position',[280   350   327   326])
43
set(gcf,'name','DRNL - BM')
44
pause(0.1)
45

  
46
finalSummary=[];
47
nBFs=length(BMlocations);
48
BFno=0; plotCount=0;
49
for BF=BMlocations
50
    BFno=BFno+1;
51
    plotCount=plotCount+nBFs;
52
    stimulusFrequencies=BF* relativeFrequencies;
53
    nFrequencies=length(stimulusFrequencies);
54

  
55
    peakAmpBM=zeros(nLevels,nFrequencies);
56
    peakAmpBMdB=NaN(nLevels,nFrequencies);
57
    peakEfferent=NaN(nLevels,nFrequencies);
58
    peakAREfferent=NaN(nLevels,nFrequencies);
59

  
60

  
61
    levelNo=0;
62
    for leveldB=levels
63
        disp(['level= ' num2str(leveldB)])
64
        levelNo=levelNo+1;
65

  
66
        freqNo=0;
67
        for frequency=stimulusFrequencies
68
            freqNo=freqNo+1;
69

  
70
            % Generate stimuli
71
            globalStimParams.FS=sampleRate;
72
            globalStimParams.overallDuration=...
73
                toneDuration+silenceDuration;  % s
74
            stim.phases='sin';
75
            stim.type='tone';
76
            stim.toneDuration=toneDuration;
77
            stim.frequencies=frequency;
78
            stim.amplitudesdB=leveldB;
79
            stim.beginSilence=silenceDuration;
80
            stim.rampOnDur=rampDuration;
81
            % no offset ramp
82
            stim.rampOffDur=rampDuration;
83
            doPlot=0;
84
            inputSignal=stimulusCreate(globalStimParams, stim, doPlot);
85
            inputSignal=inputSignal(:,1)';
86

  
87
            %% run the model
88
            MAPparamsName=paramsName;
89

  
90
            global DRNLoutput MOCattenuation ARattenuation
91
            MAP1_14(inputSignal, sampleRate, BF, ...
92
                MAPparamsName, AN_spikesOrProbability, paramChanges);
93

  
94
            DRNLresponse=DRNLoutput;
95
            peakAmp=max(max(...
96
                DRNLresponse(:, end-round(length(DRNLresponse)/2):end)));
97
            peakAmpBM(levelNo,freqNo)=peakAmp;
98
            peakAmpBMdB(levelNo,freqNo)=...
99
                20*log10(peakAmp/refBMdisplacement);
100
            peakEfferent(levelNo,freqNo)=min(min(MOCattenuation));
101
            peakAREfferent(levelNo,freqNo)=min(min(ARattenuation));
102

  
103
        end  % tone frequency
104
    end  % level
105

  
106
    %% analyses results and plot
107

  
108
    % BM I/O plot (top panel)
109
    figure(3)
110
    subplot(3,nBFs,BFno), cla
111
    plot(levels,peakAmpBMdB, 'linewidth',2)
112
    hold on, plot(levels, repmat(refBMdisplacement,1,length(levels)))
113
    hold off
114
    title(['BF=' num2str(BF,'%5.0f') ' - ' paramsName])
115
    xlabel('level')
116
    %     set(gca,'xtick',levels),  grid on
117
    if length(levels)>1,xlim([min(levels) max(levels)]), end
118
    ylabel(['dB re:' num2str(refBMdisplacement,'%6.1e') 'm'])
119
    ylim([-20 50])
120
    set(gca,'ytick',[-10 0 10 20 40])
121
    grid on
122
    %     legend({num2str(stimulusFrequencies')}, 'location', 'EastOutside')
123
    UTIL_printTabTable([levels' peakAmpBMdB], ...
124
        num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f')
125
    finalSummary=[finalSummary peakAmpBMdB];
126

  
127
    % Tuning curve
128
    if length(relativeFrequencies)>2
129
        figure(3), subplot(3,nBFs, 2*nBFs+BFno)
130
        %         contour(stimulusFrequencies,levels,peakAmpBM,...
131
        %             [refBMdisplacement refBMdisplacement],'r')
132
        contour(stimulusFrequencies,levels,peakAmpBM,...
133
            refBMdisplacement.*[1 5 10 50 100])
134
        title(['tuning curve at ' num2str(refBMdisplacement) 'm']);
135
        ylabel('level (dB) at reference')
136
        xlim([100 10000])
137
        grid on
138
        hold on
139
        set(gca,'xscale','log')
140
    end
141

  
142

  
143
    % MOC contribution
144
    figure(3)
145
    subplot(3,nBFs,nBFs+BFno), cla
146
    plot(levels,20*log10(peakEfferent), 'linewidth',2)
147
    ylabel('MOC (dB attenuation)'), xlabel('level')
148
    title(['peak MOC: model= ' AN_spikesOrProbability])
149
    grid on
150
    if length(levels)>1, xlim([min(levels) max(levels)]), end
151

  
152
    % AR contribution
153
    hold on
154
    plot(levels,20*log10(peakAREfferent), 'r')
155
    hold off
156

  
157
end % best frequency
158

  
159
UTIL_showStructureSummary(DRNLParams, 'DRNLParams', 10)
160

  
161
    UTIL_printTabTable([levels' finalSummary], ...
162
        num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f')
163

  
164
path(savePath);
testPrograms/testFM.m
1
function testFM(BFlist,paramsName,showPSTHs,paramChanges)
2
%   specify whether you want AN 'probability' or 'spikes'
3
%       spikes is more realistic but takes longer
4
%       refractory effect is included only for spikes
5
%
6

  
7
% specify the AN ANresponse bin width (normally 1 ms).
8
%      This can influence the measure of the AN onset rate based on the
9
%      largest bin in the ANresponse
10
%
11
% Demonstration is based on Harris and Dallos
12

  
13
global inputStimulusParams outerMiddleEarParams DRNLParams 
14
global IHC_VResp_VivoParams IHCpreSynapseParams  AN_IHCsynapseParams
15

  
16
dbstop if error
17

  
18
restorePath=path;
19
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
20
    ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
21
    ['..' filesep 'testPrograms'])
22

  
23
if nargin<3
24
    paramChanges=[];
25
end
26

  
27
% masker and probe levels are relative to this threshold
28
thresholdAtCF=10; % dB SPL
29
thresholdAtCF=5; % dB SPL
30

  
31
if nargin<1, showPSTHs=1;end
32

  
33
sampleRate=50000;
34

  
35
% fetch BF from GUI: use only the first target frequency
36
maskerFrequency=BFlist;
37
maskerDuration=.1;
38

  
39
targetFrequency=maskerFrequency;
40
probeLeveldB=20+thresholdAtCF;	% H&D use 20 dB SL/ TMC uses 10 dB SL
41
probeDuration=0.008; % HD use 15 ms probe (fig 3).
42
probeDuration=0.015; % HD use 15 ms probe (fig 3).
43

  
44
rampDuration=.001;  % HD use 1 ms linear ramp
45
initialSilenceDuration=0.02;
46
finalSilenceDuration=0.05;      % useful for showing recovery
47

  
48
maskerLevels=[-80   10 20 30 40 60 ] + thresholdAtCF;
49
% maskerLevels=[-80   40 60 ] + thresholdAtCF;
50

  
51
dt=1/sampleRate;
52

  
53
figure(7), clf
54
set(gcf,'position',[613    36   360   247])
55
set(gcf,'name', ['forward masking: thresholdAtCF=' num2str(thresholdAtCF)])
56

  
57
if showPSTHs
58
    figure(8), clf
59
    set(gcf,'name', 'Harris and Dallos simulation')
60
    set(gcf,'position',[980    36   380   249])
61
end
62

  
63
% Plot Harris and Dallos result for comparison
64
gapDurations=[0.001	0.002	0.005	0.01	0.02	0.05	0.1	0.3];
65
HDmaskerLevels=[+10	+20	+30	+40	+60];
66
HDresponse=[
67
    1 1 1 1 1 1 1 1;
68
    0.8  	0.82	0.81	0.83	0.87	0.95	1	    1;
69
    0.48	0.5	    0.54	0.58	0.7	    0.85	0.95	1;
70
    0.3	    0.31	0.35	0.4	    0.5	    0.68	0.82	0.94;
71
    0.2 	0.27	0.27	0.29	0.42	0.64	0.75	0.92;
72
    0.15	0.17	0.18	0.23	0.3	     0.5	0.6	    0.82];
73

  
74
figure(7)
75
semilogx(gapDurations,HDresponse,'o'), hold on
76
legend(strvcat(num2str(maskerLevels')),'location','southeast')
77
title([ 'masker dB: ' num2str(HDmaskerLevels)])
78

  
79
%% Run the trials
80
maxProbeResponse=0;
81
levelNo=0;
82
resultsMatrix=zeros(length(maskerLevels), length(gapDurations));
83
summaryFiringRates=[];
84

  
85
% initial silence
86
time=dt: dt: initialSilenceDuration;
87
initialSilence=zeros(1,length(time));
88

  
89
% probe
90
time=dt: dt: probeDuration;
91
amp=28e-6*10^(probeLeveldB/20);
92
probe=amp*sin(2*pi.*targetFrequency*time);
93
% ramps
94
% catch rampTime error
95
if rampDuration>0.5*probeDuration, rampDuration=probeDuration/2; end
96
rampTime=dt:dt:rampDuration;
97
% raised cosine ramp
98
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
99
    ones(1,length(time)-length(rampTime))];
100
%  onset ramp
101
probe=probe.*ramp;
102
%  offset ramp makes complete ramp for probe
103
ramp=fliplr(ramp);
104
% apply ramp mask to probe. Probe does not change below
105
probe=probe.*ramp;
106

  
107
% final silence
108
time=dt: dt: finalSilenceDuration;
109
finalSilence=zeros(1,length(time));
110

  
111
PSTHplotCount=0;
112
longestSignalDuration=initialSilenceDuration + maskerDuration +...
113
    max(gapDurations) + probeDuration + finalSilenceDuration ;
114
for maskerLeveldB=maskerLevels
115
    levelNo=levelNo+1;
116
    allDurations=[];
117
    allFiringRates=[];
118

  
119
    %masker
120
    time=dt: dt: maskerDuration;
121
    masker=sin(2*pi.*maskerFrequency*time);
122
    % masker ramps
123
    if rampDuration>0.5*maskerDuration
124
        % catch ramp duration error
125
        rampDuration=maskerDuration/2;
126
    end
127
    % NB masker ramp (not probe ramp)
128
    rampTime=dt:dt:rampDuration;
129
    % raised cosine ramp
130
    ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi))...
131
        ones(1,length(time)-length(rampTime))];
132
    %  onset ramp
133
    masker=masker.*ramp;
134
    %  offset ramp
135
    ramp=fliplr(ramp);
136
    % apply ramp
137
    masker=masker.*ramp;
138
    amp=28e-6*10^(maskerLeveldB/20);
139
    maskerPa=amp*masker;
140

  
141
    for gapDuration=gapDurations
142
        time=dt: dt: gapDuration;
143
        gap=zeros(1,length(time));
144

  
145
        inputSignal=...
146
            [initialSilence maskerPa gap probe finalSilence];
147

  
148
        % **********************************  run MAP model
149
        
150
        global  ANprobRateOutput  tauCas  ...
151

  
152
    showPlotsAndDetails=0;
153

  
154
AN_spikesOrProbability='probability';
155

  
156
MAP1_14(inputSignal, 1/dt, targetFrequency, ...
157
    paramsName, AN_spikesOrProbability, paramChanges);
158
 
159
    [nFibers c]=size(ANprobRateOutput);
160
    nLSRfibers=nFibers/length(tauCas);
161
            ANresponse=ANprobRateOutput(end-nLSRfibers:end,:);
162
            ANresponse=sum(ANresponse)/nLSRfibers;
163
    
164
        % analyse results
165
        probeStart=initialSilenceDuration+maskerDuration+gapDuration;
166
        PSTHbinWidth=dt;
167
        responseDelay=0.005;
168
        probeTimes=probeStart+responseDelay:...
169
            PSTHbinWidth:probeStart+probeDuration+responseDelay;
170
        probeIDX=round(probeTimes/PSTHbinWidth);
171
        probePSTH=ANresponse(probeIDX);
172
        firingRate=mean(probePSTH);
173
        % NB this only works if you start with the lowest level masker
174
        maxProbeResponse=max([maxProbeResponse firingRate]);
175
        allDurations=[allDurations gapDuration];
176
        allFiringRates=[allFiringRates firingRate];
177
        
178
        %% show PSTHs
179
        if showPSTHs
180
            nLevels=length(maskerLevels);
181
            nDurations=length(gapDurations);
182
            figure(8)
183
            PSTHbinWidth=1e-3;
184
            PSTH=UTIL_PSTHmaker(ANresponse, dt, PSTHbinWidth);
185
            PSTH=PSTH*dt/PSTHbinWidth;
186
            PSTHplotCount=PSTHplotCount+1;
187
            subplot(nLevels,nDurations,PSTHplotCount)
188
            probeTime=PSTHbinWidth:PSTHbinWidth:...
189
                PSTHbinWidth*length(PSTH);
190
            bar(probeTime, PSTH)
191
            if strcmp(AN_spikesOrProbability, 'spikes')
192
                ylim([0 500])
193
            else
194
                ylim([0 500])
195
            end
196
            xlim([0 longestSignalDuration])
197
            grid on
198

  
199
            if PSTHplotCount< (nLevels-1) * nDurations+1
200
                set(gca,'xticklabel',[])
201
            end
202

  
203
            if ~isequal(mod(PSTHplotCount,nDurations),1)
204
                set(gca,'yticklabel',[])
205
            else
206
                ylabel([num2str(maskerLevels...
207
                    (round(PSTHplotCount/nDurations) +1))])
208
            end
209

  
210
            if PSTHplotCount<=nDurations
211
                title([num2str(1000*gapDurations(PSTHplotCount)) 'ms'])
212
            end
213
        end % showPSTHs
214

  
215
    end     % gapDurations duration
216
    summaryFiringRates=[summaryFiringRates allFiringRates'];
217

  
218
    figure(7), hold on
219
    semilogx(allDurations, allFiringRates/maxProbeResponse)
220
    ylim([0 1]), hold on
221
    ylim([0 inf]), xlim([min(gapDurations) max(gapDurations)])
222
    xlim([0.001 1])
223
    pause(0.1) % to allow for CTRL/C interrupts
224
    resultsMatrix(levelNo,:)=allFiringRates;
225
end          % maskerLevel
226

  
227
disp('delay/ rates')
228
disp(num2str(round( [1000*allDurations' summaryFiringRates])))
229

  
230
% replot with best adjustment
231
% figure(34), clf% use for separate plot
232
figure(7), clf
233
peakProbe=max(max(resultsMatrix));
234
resultsMatrix=resultsMatrix/peakProbe;
235
semilogx(gapDurations,HDresponse,'o'), hold on
236
title(['FrMsk: probe ' num2str(probeLeveldB)...
237
    'dB SL: peakProbe=' num2str(peakProbe,'%5.0f') ' sp/s'])
238
xlabel('gap duration (s)'), ylabel ('probe response')
239
semilogx(allDurations, resultsMatrix'), ylim([0 1])
240
ylim([0 inf]),
241
xlim([0.001 1])
242
legend(strvcat(num2str(maskerLevels'-thresholdAtCF)), -1)
243

  
244
% ------------------------------------------------- display parameters
245
disp(['parameter file was: ' paramsName])
246
fprintf('\n')
247
% UTIL_showStruct(inputStimulusParams, 'inputStimulusParams')
248
% UTIL_showStruct(outerMiddleEarParams, 'outerMiddleEarParams')
249
% UTIL_showStruct(DRNLParams, 'DRNLParams')
250
% UTIL_showStruct(IHC_VResp_VivoParams, 'IHC_VResp_VivoParams')
251
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
252
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
253

  
254

  
255
path(restorePath);
testPrograms/testOME.m
1
function testOME(paramsName, paramChanges)
2

  
3
savePath=path;
4
addpath (['..' filesep 'utilities'],['..' filesep 'MAP'])
5

  
6
if nargin<2
7
    paramChanges=[];
8
end
9

  
10
sampleRate=50000;
11

  
12
dt=1/sampleRate;
13
leveldBSPL=80; 		% dB SPL as used by Huber (may trigger AR)
14
amp=10^(leveldBSPL/20)*28e-6;
15
duration=.05;
16
time=dt: dt: duration;
17

  
18
%% Comparison data (human)
19
% These data are taken directly from Huber 2001 (Fig. 4)
20
HuberFrequencies=[600	  800	 1000	 2000	 3000	4000 6000 8000];
21
HuberDisplacementAt80dBSPL=[1.5E-9	1.5E-09	1.5E-09	1.0E-09	7.0E-10	...
22
    3.0E-10	2.0E-10	1.0E-10]; % m;
23
% HuberVelocityAt80dBSPL= 2*pi*HuberFrequencies.*HuberDisplacementAt80dBSPL;
24

  
25
figure(2), clf, subplot(2,1,1)
26
set(2,'position',[5   349   268   327])
27
semilogx(HuberFrequencies, 20*log10(HuberDisplacementAt80dBSPL/1e-10),...
28
    'ko', 'MarkerFaceColor','k', 'Marker','o', 'markerSize',6)
29
hold on
30

  
31
%% Generate test stimulus .................................................................
32

  
33
% independent test using discrete frequencies
34
peakResponses=[];
35
peakTMpressure=[];
36
frequencies=[200 400 HuberFrequencies 10000];
37
for toneFrequency=frequencies
38
    inputSignal=amp*sin(2*pi*toneFrequency*time);
39

  
40
    showPlotsAndDetails=0;
41
    AN_spikesOrProbability='probability';
42
    % switch off AR & MOC (Huber's patients were deaf)
43
    paramChanges{1}='OMEParams.rateToAttenuationFactorProb=0;';
44
    paramChanges{2}='DRNLParams.rateToAttenuationFactorProb = 0;';
45

  
46
    global OMEoutput  OMEextEarPressure TMoutput ARattenuation
47
    % BF is irrelevant
48
    MAP1_14(inputSignal, sampleRate, -1, ...
49
        paramsName, AN_spikesOrProbability, paramChanges);
50

  
51
    peakDisplacement=max(OMEoutput(floor(end/2):end));
52
    peakResponses=[peakResponses peakDisplacement];
53

  
54
    peakTMpressure=[peakTMpressure max(OMEextEarPressure)];
55
    disp([' AR attenuation (dB):   ' num2str(20*log10(min(ARattenuation)))])
56
end
57

  
58
%% Report
59
disp('frequency displacement(m)')
60
% disp(num2str([frequencies' peakResponses']))
61
fprintf('%6.0f \t%10.3e\n',[frequencies' peakResponses']')
62

  
63
% stapes peak displacement
64
figure(2), subplot(2,1,1), hold on
65
semilogx(frequencies, 20*log10(peakResponses/1e-10), 'r', 'linewidth',4)
66
set(gca,'xScale','log')
67
% ylim([1e-11 1e-8])
68
xlim([100 10000]), ylim([0 30])
69
grid on
70
title(['stapes at ' num2str(leveldBSPL) ' (NB deaf)'])
71
ylabel('disp: dB re 1e-10m')
72
xlabel('stimulus frequency (Hz)')
73
legend({'Huber et al','model'},'location','southWest')
74
set(gcf,'name','OME')
75

  
76
% external ear resonance
77
figure(2), subplot(2,1,2),hold off
78
semilogx(frequencies, 20*log10(peakTMpressure/28e-6)-leveldBSPL,...
79
    'k', 'linewidth',2)
80
xlim([100 10000]) %, ylim([-10 30])
81
grid on
82
title(['External ear resonances' ])
83
ylabel('dB')
84
xlabel('frequency')
85
set(gcf,'name','OME: external resonances')
86
% ---------------------------------------------------------- display parameters
87
disp(['parameter file was: ' paramsName])
88
fprintf('\n')
89

  
90
path(savePath);
testPrograms/testPeriphery.m
1
function testPeriphery (BMlocations, paramsName)
2
% testBM generates input output functions for DRNL model for any number
3
% of locations.
4
% Computations are bast on a single channel model (channelBFs=BF)
5
% peak displacement (peakAmp) is measured.
6
%  if DRNLParams.useMOC is chosen, the full model is run (slow)
7
%  otherwise only DRNL is computed.
8
% Tuning curves are generated based on a range of frequencies reletove to
9
% the BF of the location.
10
%
11

  
12
global    DRNLParams
13

  
14
savePath=path;
15

  
16
addpath (['..' filesep 'utilities'],['..' filesep 'MAP'])
17

  
18
levels=-10:10:90;   nLevels=length(levels);
19
% levels= 50;   nLevels=length(levels);
20

  
21
% relativeFrequencies=[0.25    .5   .75  1  1.25 1.5    2];
22
relativeFrequencies=1;
23

  
24
% refBMdisplacement is the displacement of the BM at threshold
25
% 1 nm disp at  threshold (9 kHz, Ruggero)
26
refBMdisplacement= 1e-8;            % adjusted for 10 nm at 1 kHz
27

  
28
toneDuration=.200;
29
rampDuration=0.01;
30
silenceDuration=0.01;
31

  
32
sampleRate=30000;
33

  
34
dbstop if error
35
figure(3), clf
36
% set(gcf,'position',[276    33   331   645])
37
set(gcf,'name','DRNL - BM')
38

  
39
finalSummary=[];
40
nBFs=length(BMlocations);
41
BFno=0; plotCount=0;
42
for BF=BMlocations
43
    BFno=BFno+1;
44
    plotCount=plotCount+nBFs;
45
    stimulusFrequencies=BF* relativeFrequencies;
46
    nFrequencies=length(stimulusFrequencies);
47

  
48
    peakAmpBM=zeros(nLevels,nFrequencies);
49
    peakAmpBMdB=NaN(nLevels,nFrequencies);
50
    peakEfferent=NaN(nLevels,nFrequencies);
51
    peakAREfferent=NaN(nLevels,nFrequencies);
52

  
53

  
54
    levelNo=0;
55
    for leveldB=levels
56
        disp(['level= ' num2str(leveldB)])
57
        levelNo=levelNo+1;
58

  
59
        freqNo=0;
60
        for frequency=stimulusFrequencies
61
            freqNo=freqNo+1;
62

  
63
            % Generate stimuli
64
            globalStimParams.FS=sampleRate;
65
            globalStimParams.overallDuration=...
66
                toneDuration+silenceDuration;  % s
67
            stim.type='tone';
68
            stim.phases='sin';
69
            stim.toneDuration=toneDuration;
70
            stim.frequencies=frequency;
71
            stim.amplitudesdB=leveldB;
72
            stim.beginSilence=silenceDuration;
73
            stim.rampOnDur=rampDuration;
74
            stim.rampOffDur=rampDuration;
75
            doPlot=0;
76
            inputSignal=stimulusCreate(globalStimParams, stim, doPlot);
77
            inputSignal=inputSignal(:,1)';
78

  
79
            %% run the model
80
            MAPparamsName=paramsName;
81
            AN_spikesOrProbability='probability';
82
            % spikes are slow but can be used to study MOC using IC units
83
            % AN_spikesOrProbability='spikes';
84

  
85
            global DRNLoutput MOCattenuation ARattenuation IHCoutput
86
            MAP1_14(inputSignal, sampleRate, BF, ...
87
                MAPparamsName, AN_spikesOrProbability);
88

  
89
            DRNLresponse=IHCoutput;
90
            peakAmp=max(max(...
91
                DRNLresponse(:, end-round(length(DRNLresponse)/2):end)));
92
            peakAmpBM(levelNo,freqNo)=peakAmp;
93
            if peakAmp>0
94
            peakAmpBMdB(levelNo,freqNo)=...
95
                20*log10(peakAmp/refBMdisplacement);
96
            else
97
                peakAmpBMdB(levelNo,freqNo)=peakAmp;
98
            end
99
            peakEfferent(levelNo,freqNo)=min(min(MOCattenuation));
100
            peakAREfferent(levelNo,freqNo)=min(min(ARattenuation));
101

  
102
        end  % tone frequency
103
    end  % level
104

  
105
    %% analyses results and plot
106

  
107
    % BM I/O plot (top panel)
108
    figure(3)
109
    subplot(3,nBFs,BFno), cla
110
    plot(levels,peakAmpBMdB, 'linewidth',2)
111
    hold on, plot(levels, repmat(refBMdisplacement,1,length(levels)))
112
    hold off
113
    title(['BF=' num2str(BF,'%5.0f') ' - ' paramsName])
114
    xlabel('level')
115
    %     set(gca,'xtick',levels),  grid on
116
    if length(levels)>1,xlim([min(levels) max(levels)]), end
117
    ylabel(['dB re:' num2str(refBMdisplacement,'%6.1e') 'm'])
118
    ylim([-20 50])
119
    set(gca,'ytick',[-10 0 10 20 40])
120
    %     legend({num2str(stimulusFrequencies')}, 'location', 'EastOutside')
121
    UTIL_printTabTable([levels' peakAmpBMdB], ...
122
        num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f')
123
    finalSummary=[finalSummary peakAmpBMdB];
124

  
125
    % Tuning curve
126
    if length(relativeFrequencies)>2
127
        figure(3), subplot(3,nBFs, nBFs+BFno)
128
        %         contour(stimulusFrequencies,levels,peakAmpBM,...
129
        %             [refBMdisplacement refBMdisplacement],'r')
130
        contour(stimulusFrequencies,levels,peakAmpBM,...
131
            refBMdisplacement.*[1 5 10 50 100])
132
        title(['tuning curve at ' num2str(refBMdisplacement) 'm']);
133
        ylabel('level (dB) at reference')
134
        xlim([100 10000])
135
        hold on
136
        set(gca,'xscale','log')
137
    end
138

  
139

  
140
    % MOC contribution
141
    figure(3)
142
    subplot(3,nBFs,2*nBFs+BFno), cla
143
    plot(levels,20*log10(peakEfferent), 'linewidth',2)
144
    ylabel('MOC (dB attenuation)'), xlabel('level')
145
    title(['peak MOC: model= ' AN_spikesOrProbability])
146
    grid on
147
    if length(levels)>1, xlim([min(levels) max(levels)]), end
148

  
149
    % AR contribution
150
    hold on
151
    plot(levels,20*log10(peakAREfferent), 'r')
152
    hold off
153

  
154
end % best frequency
155

  
156
UTIL_showStructureSummary(DRNLParams, 'DRNLParams', 10)
157

  
158
    UTIL_printTabTable([levels' finalSummary], ...
159
        num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f')
160

  
161
path(savePath);
testPrograms/testPhaseLocking.m
1
function testPhaseLocking(paramsName, paramChanges)
2

  
3
if nargin<2
4
    paramChanges=[];
5
end
6

  
7
testFrequencies=[250 500 1000 2000 4000 8000];
8
levels=50:10:80;
9
figure(14), clf
10
set(gcf,'position', [980    36   383   321])
11
set(gcf,'name', 'phase locking')
12
allStrengths=zeros(length(testFrequencies), length(levels));
13
peakVectorStrength=zeros(1,length(testFrequencies));
14
freqCount=0;
15
for targetFrequency=testFrequencies;
16
    %single test
17
    freqCount=freqCount+1;
18
    vectorStrength=...
19
        testAN(targetFrequency,targetFrequency, levels,...
20
        paramsName, paramChanges);
21
    allStrengths(freqCount,:)=vectorStrength';
22
    peakVectorStrength(freqCount)=max(vectorStrength');
23
end
24
%% plot results
25
figure(14)
26
subplot(2,1,2)
27
plot(levels,allStrengths)
28
xlabel('levels')
29
ylabel('vector strength')
30
legend (num2str(testFrequencies'),'location','eastOutside')
31

  
32
subplot(2,1,1)
33
semilogx(testFrequencies,peakVectorStrength)
34
grid on
35
title ('peak vector strength')
36
xlabel('frequency')
37
ylabel('vector strength')
38

  
39
johnson=[250	0.79
40
500	0.82
41
1000	0.8
42
2000	0.7
43
4000	0.25
44
5500	0.05
45
];
46
hold on
47
plot(johnson(:,1),johnson(:,2),'o')
48
legend({'model','Johnson 80'},'location','eastOutside')
49
hold off
50

  
51

  
testPrograms/testPhysiology.m
1
function testPhysiology(BF,paramsName, paramChanges)
2

  
3
restorePath=path;
4
addpath (['..' filesep 'MAP'])
5

  
6
if nargin<3
7
    paramChanges=[];
8
end
9

  
10
testOME(paramsName,paramChanges)
11
relativeFrequencies=[0.25    .5   .75  1  1.25 1.5    2];
12
testBM (BF, paramsName,relativeFrequencies,'spikes', paramChanges)
13
testRP(BF,paramsName,paramChanges)
14
testSynapse(BF,paramsName,paramChanges)
15
testFM(BF,paramsName,1,paramChanges)
16
testPhaseLocking(paramsName,paramChanges)
17
testAN(BF,BF, -10:10:80,paramsName,paramChanges);
18
figure(14)
19
figure(15)
20

  
21
path(restorePath)
testPrograms/testPhysiologyProb.m
1
function testPhysiologyProb(BF,paramsName, paramChanges)
2

  
3
restorePath=path;
4
addpath (['..' filesep 'MAP'])
5

  
6
if nargin<3
7
    paramChanges=[];
8
end
9

  
10
testOME(paramsName, paramChanges)
11
relativeFrequencies=[0.25    .5   .75  1  1.25 1.5    2];
12
testBM (BF, paramsName,relativeFrequencies,'probability', paramChanges)
13
testRP(BF,paramsName, paramChanges)
14
testSynapse(BF,paramsName, paramChanges)
15
testANprob(BF,BF, -10:10:80,paramsName, paramChanges);
16

  
17
figure(4)
18

  
19
path(restorePath)
testPrograms/testRF.m
1
function testRF
2
% testIHC used either for IHC I/O function or receptive field (doReceptiveFields=1)
3

  
4
global experiment method stimulusParameters expGUIhandles
5
global inputStimulusParams  IHC_ciliaParams
6
global IHC_VResp_VivoParams IHCpreSynapseParams  AN_IHCsynapseParams
7
dbstop if error
8
% set(expGUIhandles.pushbuttonStop, 'backgroundColor', [.941 .941 .941])
9

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

  
14
targetFrequency=stimulusParameters.targetFrequency(1);
15

  
16
sampleRate=50000;
17
doReceptiveFields=1;
18

  
19
toneDuration=.05;
20
rampDuration=0.004;
21
silenceDuration=.02;
22

  
23
nRepeats=100;   % no. of AN fibers
24

  
25
plotGraphsForIHC=1;
26
% number of MacGregor units is set in the parameter file.
27

  
28
if doReceptiveFields
29
    % show all receptive field
30
    frequencies=targetFrequency*    [  0.5         0.7         0.9     1       1.1         1.3         1.6];
31
    levels=0:20:80; nLevels=length(levels);
32
    figure(14), clf
33
    figure(15), clf
34
else
35
    % show only I/O function at BF
36
    frequencies=targetFrequency;
37
    levels=-20:10:90;
38
    %         levels=10:.25:13;
39
    %         levels=-20:1:-15
40
    nLevels=length(levels);
41
%     figure(13), clf,
42
%     set (gcf, 'name', ['IHC/AN  input/output' num2str(AN_IHCsynapseParams.numFibers) ' repeats'])
43
%     drawnow
44
end
45
nFrequencies=length(frequencies);
46

  
47
IHC_RP_peak=zeros(nLevels,nFrequencies);
48
IHC_RP_min=zeros(nLevels,nFrequencies);
49
IHC_RP_dc=zeros(nLevels,nFrequencies);
50
AN_HSRonset=zeros(nLevels,nFrequencies);
51
AN_HSRsaturated=zeros(nLevels,nFrequencies);
52
AN_LSRonset=zeros(nLevels,nFrequencies);
53
AN_LSRsaturated=zeros(nLevels,nFrequencies);
54
CNLSRsaturated=zeros(nLevels,nFrequencies);
55
CNHSRsaturated=zeros(nLevels,nFrequencies);
56
ICHSRsaturated=zeros(nLevels,nFrequencies);
57
ICLSRsaturated=zeros(nLevels,nFrequencies);
58

  
59

  
60
levelNo=0; PSTHplotCount=0;
61
for leveldB=levels
62
    fprintf('%4.0f\t', leveldB)
63
    levelNo=levelNo+1;
64
    amp=28e-6*10^(leveldB/20);
65
    
66
    freqNo=0;
67
    for frequency=frequencies
68

  
69
        paramFunctionName=['method=MAPparams' experiment.name ...
70
            '(' num2str(targetFrequency) ');' ];
71
        eval(paramFunctionName);  % read parameters afresh each pass
72

  
73
        dt=method.dt;
74
        time=dt:dt:toneDuration;        
75
        rampTime=dt:dt:rampDuration;
76
        ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time)-length(rampTime))];
77
        ramp=ramp.*fliplr(ramp);
78
        
79
        silence=zeros(1,round(silenceDuration/dt));
80
        
81
        toneStartptr=length(silence)+1;
82
        toneMidptr=toneStartptr+round(toneDuration/(2*dt)) -1;
83
        toneEndptr=toneStartptr+round(toneDuration/dt) -1;
84
        
85
        % create signal (leveldB/ frequency)
86
        freqNo=freqNo+1;
87
        inputSignal=amp*sin(2*pi*frequency'*time);
88
        inputSignal= ramp.*inputSignal;
89
        inputSignal=[silence inputSignal silence];
90
        
91
        if doReceptiveFields  % receptive field
92
            method.plotGraphs=	0; % plot only PSTHs
93
        else
94
            method.plotGraphs=	plotGraphsForIHC; % show progress
95
        end
96
        
97
        targetChannelNo=1;
98
        
99
        % force parameters
100
         % the number of AN fibers at each BF
101
        AN_IHCsynapseParams.numFibers=	nRepeats;
102
        AN_IHCsynapseParams. mode= 'spikes';
103
        AN_IHCsynapseParams.plotSynapseContents=0;
104
        AN_IHCsynapseParams.PSTHbinWidth=.001;
105
        
106
        method.DRNLSave=1;
107
        method.IHC_cilia_RPSave=1;
108
        method.PSTHbinWidth=1e-3; % useful 1-ms default for all PSTHs
109
        method.AN_IHCsynapseSave=1;
110
        method.MacGregorMultiSave=1;
111
        method.MacGregorSave=1;
112
        method.dt=dt;
113
              
114
        moduleSequence=[1:8];       
115

  
116
        global ANdt ARAttenuation TMoutput OMEoutput ...
117
    DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV...
118
    IHCoutput ANprobRateOutput ANoutput savePavailable tauCas  ...
119
    CNoutput  ICoutput ICmembraneOutput ICfiberTypeRates MOCattenuation
120

  
121
AN_spikesOrProbability='spikes';
122
AN_spikesOrProbability='probability';
123
MAPparamsName='Normal';
124

  
125
MAP1_14(inputSignal, 1/dt, targetFrequency, ...
126
    MAPparamsName, AN_spikesOrProbability);
127
        
128
        % RP
129
        IHC_RPData=IHC_cilia_output;
130
        IHC_RPData=IHCoutput(targetChannelNo,:);
131
        IHC_RP_peak(levelNo,freqNo)=max(IHC_RPData(toneStartptr:toneEndptr));
132
        IHC_RP_min(levelNo,freqNo)=min(IHC_RPData(toneStartptr:toneEndptr));
133
        IHC_RP_dc(levelNo,freqNo)=mean(IHC_RPData(toneStartptr:toneEndptr));
134
        
135
        % AN next
136
        AN_IHCsynapseAllData=ANoutput;
137
        method.PSTHbinWidth=0.001;
138
        
139
        nTaus=length(tauCas);
140
        numANfibers=size(ANoutput,1);
141
        numLSRfibers=numANfibers/nTaus;
142
        
143
        %LSR (same as HSR if no LSR fibers present)
144
        channelPtr1=(targetChannelNo-1)*numANfibers+1;
145
        channelPtr2=channelPtr1+numANfibers-1;
146
        LSRspikes=AN_IHCsynapseAllData(channelPtr1:channelPtr2,:);
147
        method.dt=method.AN_IHCsynapsedt;
148
        PSTH=UTIL_PSTHmaker(LSRspikes, method);
149
        PSTH=sum(PSTH,1); % sum across fibers (HSR only)
150
        PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1;
151
        PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1;
152
        PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1;
153
        AN_LSRonset(levelNo,freqNo)=max(max(PSTH))/(method.PSTHbinWidth*method.numANfibers);
154
        AN_LSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr))/(method.numANfibers*toneDuration/2);
155
        
156
        % HSR
157
        channelPtr1=numLSRfibers+(targetChannelNo-1)*method.numANfibers+1;
158
        channelPtr2=channelPtr1+method.numANfibers-1;
159
        HSRspikes=AN_IHCsynapseAllData(channelPtr1:channelPtr2,:);
160
        method.dt=method.AN_IHCsynapsedt;
161
        PSTH=UTIL_PSTHmaker(HSRspikes, method);
162
        PSTH=sum(PSTH,1); % sum across fibers (HSR only)
163
        PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1;
164
        PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1;
165
        PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff