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

History | View | Annotate | Download (7.98 KB)

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