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 / testANprob.m @ 29:b51bf546ca3f

History | View | Annotate | Download (5.57 KB)

1 29:b51bf546ca3f rmeddis
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))