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 @ 34:e097e9044ef6

History | View | Annotate | Download (8.42 KB)

1 32:82fb37eb430e rmeddis
function testFM(BFlist,paramsName, AN_spikesOrProbability,...
2
    paramChanges)
3
% testFM(1000,'Normal','probability', [])
4
% testFM(1000,'Normal','spikes', [])
5
6
% Demonstration is based on Harris and Dallos
7 29:b51bf546ca3f rmeddis
%   specify whether you want AN 'probability' or 'spikes'
8
%       spikes is more realistic but takes longer
9
%       refractory effect is included only for spikes
10
%
11
12
13 32:82fb37eb430e rmeddis
global inputStimulusParams outerMiddleEarParams DRNLParams
14 29:b51bf546ca3f rmeddis
global IHC_VResp_VivoParams IHCpreSynapseParams  AN_IHCsynapseParams
15 32:82fb37eb430e rmeddis
global  ANprobRateOutput  ANoutput ANtauCas  ANdt
16 29:b51bf546ca3f rmeddis
17
dbstop if error
18
19
restorePath=path;
20
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
21
    ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
22
    ['..' filesep 'testPrograms'])
23
24
if nargin<3
25
    paramChanges=[];
26
end
27
28
% masker and probe levels are relative to this threshold
29
thresholdAtCF=10; % dB SPL
30 33:161913b595ae rmeddis
maskerLevels=[-80   10 20 30 40 60 ] + thresholdAtCF;
31 29:b51bf546ca3f rmeddis
32 32:82fb37eb430e rmeddis
showPSTHs=1;
33 29:b51bf546ca3f rmeddis
34
sampleRate=50000;
35 32:82fb37eb430e rmeddis
dt=1/sampleRate;
36 29:b51bf546ca3f rmeddis
37
% fetch BF from GUI: use only the first target frequency
38
maskerFrequency=BFlist;
39
maskerDuration=.1;
40
41
targetFrequency=maskerFrequency;
42
probeLeveldB=20+thresholdAtCF;	% H&D use 20 dB SL/ TMC uses 10 dB SL
43
probeDuration=0.015; % HD use 15 ms probe (fig 3).
44
45
rampDuration=.001;  % HD use 1 ms linear ramp
46
initialSilenceDuration=0.02;
47
finalSilenceDuration=0.05;      % useful for showing recovery
48
49
figure(7), clf
50
set(gcf,'position',[613    36   360   247])
51
set(gcf,'name', ['forward masking: thresholdAtCF=' num2str(thresholdAtCF)])
52
53
if showPSTHs
54
    figure(8), clf
55
    set(gcf,'name', 'Harris and Dallos simulation')
56
    set(gcf,'position',[980    36   380   249])
57
end
58
59
% Plot Harris and Dallos result for comparison
60 32:82fb37eb430e rmeddis
figure(7)
61 29:b51bf546ca3f rmeddis
gapDurations=[0.001	0.002	0.005	0.01	0.02	0.05	0.1	0.3];
62
HDmaskerLevels=[+10	+20	+30	+40	+60];
63
HDresponse=[
64
    1 1 1 1 1 1 1 1;
65
    0.8  	0.82	0.81	0.83	0.87	0.95	1	    1;
66
    0.48	0.5	    0.54	0.58	0.7	    0.85	0.95	1;
67
    0.3	    0.31	0.35	0.4	    0.5	    0.68	0.82	0.94;
68
    0.2 	0.27	0.27	0.29	0.42	0.64	0.75	0.92;
69
    0.15	0.17	0.18	0.23	0.3	     0.5	0.6	    0.82];
70
semilogx(gapDurations,HDresponse,'o'), hold on
71
legend(strvcat(num2str(maskerLevels')),'location','southeast')
72
title([ 'masker dB: ' num2str(HDmaskerLevels)])
73
74
%% Run the trials
75
maxProbeResponse=0;
76
levelNo=0;
77
resultsMatrix=zeros(length(maskerLevels), length(gapDurations));
78
summaryFiringRates=[];
79
80
% initial silence
81
time=dt: dt: initialSilenceDuration;
82
initialSilence=zeros(1,length(time));
83
84
% probe
85
time=dt: dt: probeDuration;
86
amp=28e-6*10^(probeLeveldB/20);
87
probe=amp*sin(2*pi.*targetFrequency*time);
88
% ramps
89
% catch rampTime error
90
if rampDuration>0.5*probeDuration, rampDuration=probeDuration/2; end
91
rampTime=dt:dt:rampDuration;
92
% raised cosine ramp
93
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
94
    ones(1,length(time)-length(rampTime))];
95
%  onset ramp
96
probe=probe.*ramp;
97
%  offset ramp makes complete ramp for probe
98
ramp=fliplr(ramp);
99
% apply ramp mask to probe. Probe does not change below
100
probe=probe.*ramp;
101
102
% final silence
103
time=dt: dt: finalSilenceDuration;
104
finalSilence=zeros(1,length(time));
105
106
PSTHplotCount=0;
107
longestSignalDuration=initialSilenceDuration + maskerDuration +...
108
    max(gapDurations) + probeDuration + finalSilenceDuration ;
109
for maskerLeveldB=maskerLevels
110
    levelNo=levelNo+1;
111
    allDurations=[];
112
    allFiringRates=[];
113
114
    %masker
115
    time=dt: dt: maskerDuration;
116
    masker=sin(2*pi.*maskerFrequency*time);
117
    % masker ramps
118
    if rampDuration>0.5*maskerDuration
119
        % catch ramp duration error
120
        rampDuration=maskerDuration/2;
121
    end
122
    % NB masker ramp (not probe ramp)
123
    rampTime=dt:dt:rampDuration;
124
    % raised cosine ramp
125
    ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi))...
126
        ones(1,length(time)-length(rampTime))];
127
    %  onset ramp
128
    masker=masker.*ramp;
129
    %  offset ramp
130
    ramp=fliplr(ramp);
131
    % apply ramp
132
    masker=masker.*ramp;
133
    amp=28e-6*10^(maskerLeveldB/20);
134
    maskerPa=amp*masker;
135
136
    for gapDuration=gapDurations
137
        time=dt: dt: gapDuration;
138
        gap=zeros(1,length(time));
139
140
        inputSignal=...
141
            [initialSilence maskerPa gap probe finalSilence];
142 33:161913b595ae rmeddis
%         time=dt:dt:length(inputSignal)*dt;
143
%         figure(99), plot(time,inputSignal)
144 29:b51bf546ca3f rmeddis
145
        % **********************************  run MAP model
146 32:82fb37eb430e rmeddis
%         showPlotsAndDetails=0;
147 34:e097e9044ef6 rmeddis
nChanges=length(paramChanges);
148
paramChanges{nChanges+1}='AN_IHCsynapseParams.numFibers=	500;';
149 32:82fb37eb430e rmeddis
        MAP1_14(inputSignal, 1/dt, targetFrequency, ...
150
            paramsName, AN_spikesOrProbability, paramChanges);
151 29:b51bf546ca3f rmeddis
152 32:82fb37eb430e rmeddis
        if strcmp(AN_spikesOrProbability,'probability')
153
            [nFibers c]=size(ANprobRateOutput);
154
            nLSRfibers=nFibers/length(ANtauCas);
155
            ANresponse=ANprobRateOutput(end-nLSRfibers:end,:);
156 33:161913b595ae rmeddis
            ANdt=dt; % no adjustment for spikes speedup
157 32:82fb37eb430e rmeddis
        else
158
            [nFibers c]=size(ANoutput);
159
            nLSRfibers=nFibers/length(ANtauCas);
160
            ANresponse=ANoutput(end-nLSRfibers:end,:);
161
        end
162 29:b51bf546ca3f rmeddis
163 34:e097e9044ef6 rmeddis
        ANresponse=sum(ANresponse);
164 33:161913b595ae rmeddis
%         ANresponseTimes=ANdt:ANdt:length(ANresponse)*ANdt;
165
%         figure(99), plot(ANresponseTimes,ANresponse)
166 32:82fb37eb430e rmeddis
167 29:b51bf546ca3f rmeddis
        % analyse results
168
        probeStart=initialSilenceDuration+maskerDuration+gapDuration;
169 32:82fb37eb430e rmeddis
        PSTHbinWidth=ANdt;
170 29:b51bf546ca3f rmeddis
        responseDelay=0.005;
171
        probeTimes=probeStart+responseDelay:...
172
            PSTHbinWidth:probeStart+probeDuration+responseDelay;
173
        probeIDX=round(probeTimes/PSTHbinWidth);
174
        probePSTH=ANresponse(probeIDX);
175
        firingRate=mean(probePSTH);
176
        % NB this only works if you start with the lowest level masker
177
        maxProbeResponse=max([maxProbeResponse firingRate]);
178
        allDurations=[allDurations gapDuration];
179
        allFiringRates=[allFiringRates firingRate];
180 32:82fb37eb430e rmeddis
181 29:b51bf546ca3f rmeddis
        %% show PSTHs
182
        if showPSTHs
183
            nLevels=length(maskerLevels);
184
            nDurations=length(gapDurations);
185
            figure(8)
186
            PSTHbinWidth=1e-3;
187 32:82fb37eb430e rmeddis
            PSTH=UTIL_PSTHmaker(ANresponse, ANdt, PSTHbinWidth);
188
            PSTH=PSTH*ANdt/PSTHbinWidth;
189 29:b51bf546ca3f rmeddis
            PSTHplotCount=PSTHplotCount+1;
190
            subplot(nLevels,nDurations,PSTHplotCount)
191 33:161913b595ae rmeddis
            PSTHtime=PSTHbinWidth:PSTHbinWidth:...
192 29:b51bf546ca3f rmeddis
                PSTHbinWidth*length(PSTH);
193 34:e097e9044ef6 rmeddis
            if strcmp(AN_spikesOrProbability, 'spikes')
194
            bar(PSTHtime, PSTH/PSTHbinWidth/nFibers)
195
%                 ylim([0 500])
196
            else
197 33:161913b595ae rmeddis
            bar(PSTHtime, PSTH)
198 29:b51bf546ca3f rmeddis
                ylim([0 500])
199
            end
200 32:82fb37eb430e rmeddis
%             xlim([0 longestSignalDuration])
201 29:b51bf546ca3f rmeddis
            grid on
202
203
            if PSTHplotCount< (nLevels-1) * nDurations+1
204
                set(gca,'xticklabel',[])
205
            end
206
207
            if ~isequal(mod(PSTHplotCount,nDurations),1)
208
                set(gca,'yticklabel',[])
209
            else
210
                ylabel([num2str(maskerLevels...
211
                    (round(PSTHplotCount/nDurations) +1))])
212
            end
213
214
            if PSTHplotCount<=nDurations
215
                title([num2str(1000*gapDurations(PSTHplotCount)) 'ms'])
216
            end
217 33:161913b595ae rmeddis
218
%         figure(99),            bar(PSTHtime, PSTH)
219
220 29:b51bf546ca3f rmeddis
        end % showPSTHs
221
222
    end     % gapDurations duration
223
    summaryFiringRates=[summaryFiringRates allFiringRates'];
224
225
    figure(7), hold on
226
    semilogx(allDurations, allFiringRates/maxProbeResponse)
227
    ylim([0 1]), hold on
228
    ylim([0 inf]), xlim([min(gapDurations) max(gapDurations)])
229
    xlim([0.001 1])
230
    pause(0.1) % to allow for CTRL/C interrupts
231
    resultsMatrix(levelNo,:)=allFiringRates;
232
end          % maskerLevel
233
234
disp('delay/ rates')
235
disp(num2str(round( [1000*allDurations' summaryFiringRates])))
236
237
% replot with best adjustment
238
% figure(34), clf% use for separate plot
239
figure(7), clf
240
peakProbe=max(max(resultsMatrix));
241
resultsMatrix=resultsMatrix/peakProbe;
242
semilogx(gapDurations,HDresponse,'o'), hold on
243
title(['FrMsk: probe ' num2str(probeLeveldB)...
244
    'dB SL: peakProbe=' num2str(peakProbe,'%5.0f') ' sp/s'])
245
xlabel('gap duration (s)'), ylabel ('probe response')
246
semilogx(allDurations, resultsMatrix'), ylim([0 1])
247
ylim([0 inf]),
248
xlim([0.001 1])
249
legend(strvcat(num2str(maskerLevels'-thresholdAtCF)), -1)
250
251
% ------------------------------------------------- display parameters
252
disp(['parameter file was: ' paramsName])
253
fprintf('\n')
254
% UTIL_showStruct(inputStimulusParams, 'inputStimulusParams')
255
% UTIL_showStruct(outerMiddleEarParams, 'outerMiddleEarParams')
256
% UTIL_showStruct(DRNLParams, 'DRNLParams')
257
% UTIL_showStruct(IHC_VResp_VivoParams, 'IHC_VResp_VivoParams')
258
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
259
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
260
261
262 32:82fb37eb430e rmeddis
path(restorePath);