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 @ 38:c2204b18f4a2

History | View | Annotate | Download (8.67 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 38:c2204b18f4a2 rmeddis
global  ANprobRateOutput  ANoutput ANtauCas  dtSpikes
16 29:b51bf546ca3f rmeddis
dbstop if error
17
restorePath=path;
18
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
19
    ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
20
    ['..' filesep 'testPrograms'])
21
22 35:25d53244d5c8 rmeddis
if nargin==0
23
    BFlist=1000;
24
    paramsName=('Normal');
25
    AN_spikesOrProbability='spikes';
26 29:b51bf546ca3f rmeddis
    paramChanges=[];
27 35:25d53244d5c8 rmeddis
else
28
    if nargin<3
29 38:c2204b18f4a2 rmeddis
        paramChanges=[];
30 35:25d53244d5c8 rmeddis
    end
31 29:b51bf546ca3f rmeddis
end
32
33
% masker and probe levels are relative to this threshold
34
thresholdAtCF=10; % dB SPL
35 33:161913b595ae rmeddis
maskerLevels=[-80   10 20 30 40 60 ] + thresholdAtCF;
36 29:b51bf546ca3f rmeddis
37 32:82fb37eb430e rmeddis
showPSTHs=1;
38 29:b51bf546ca3f rmeddis
39
sampleRate=50000;
40 32:82fb37eb430e rmeddis
dt=1/sampleRate;
41 29:b51bf546ca3f rmeddis
42
% fetch BF from GUI: use only the first target frequency
43
maskerFrequency=BFlist;
44
maskerDuration=.1;
45
46
targetFrequency=maskerFrequency;
47
probeLeveldB=20+thresholdAtCF;	% H&D use 20 dB SL/ TMC uses 10 dB SL
48
probeDuration=0.015; % HD use 15 ms probe (fig 3).
49
50
rampDuration=.001;  % HD use 1 ms linear ramp
51
initialSilenceDuration=0.02;
52
finalSilenceDuration=0.05;      % useful for showing recovery
53
54
figure(7), clf
55
set(gcf,'position',[613    36   360   247])
56
set(gcf,'name', ['forward masking: thresholdAtCF=' num2str(thresholdAtCF)])
57
58
if showPSTHs
59
    figure(8), clf
60
    set(gcf,'name', 'Harris and Dallos simulation')
61
    set(gcf,'position',[980    36   380   249])
62
end
63
64
% Plot Harris and Dallos result for comparison
65 32:82fb37eb430e rmeddis
figure(7)
66 29:b51bf546ca3f rmeddis
gapDurations=[0.001	0.002	0.005	0.01	0.02	0.05	0.1	0.3];
67
HDmaskerLevels=[+10	+20	+30	+40	+60];
68
HDresponse=[
69
    1 1 1 1 1 1 1 1;
70
    0.8  	0.82	0.81	0.83	0.87	0.95	1	    1;
71
    0.48	0.5	    0.54	0.58	0.7	    0.85	0.95	1;
72
    0.3	    0.31	0.35	0.4	    0.5	    0.68	0.82	0.94;
73
    0.2 	0.27	0.27	0.29	0.42	0.64	0.75	0.92;
74
    0.15	0.17	0.18	0.23	0.3	     0.5	0.6	    0.82];
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 38:c2204b18f4a2 rmeddis
        %         time=dt:dt:length(inputSignal)*dt;
148
        %         figure(99), plot(time,inputSignal)
149 29:b51bf546ca3f rmeddis
150
        % **********************************  run MAP model
151 38:c2204b18f4a2 rmeddis
        %         showPlotsAndDetails=0;
152
        nChanges=length(paramChanges);
153
        paramChanges{nChanges+1}='AN_IHCsynapseParams.numFibers=	500;';
154 32:82fb37eb430e rmeddis
        MAP1_14(inputSignal, 1/dt, targetFrequency, ...
155
            paramsName, AN_spikesOrProbability, paramChanges);
156 29:b51bf546ca3f rmeddis
157 32:82fb37eb430e rmeddis
        if strcmp(AN_spikesOrProbability,'probability')
158
            [nFibers c]=size(ANprobRateOutput);
159
            nLSRfibers=nFibers/length(ANtauCas);
160
            ANresponse=ANprobRateOutput(end-nLSRfibers:end,:);
161 38:c2204b18f4a2 rmeddis
            dtSpikes=dt; % no adjustment for spikes speedup
162 32:82fb37eb430e rmeddis
        else
163
            [nFibers c]=size(ANoutput);
164
            nLSRfibers=nFibers/length(ANtauCas);
165
            ANresponse=ANoutput(end-nLSRfibers:end,:);
166
        end
167 29:b51bf546ca3f rmeddis
168 34:e097e9044ef6 rmeddis
        ANresponse=sum(ANresponse);
169 38:c2204b18f4a2 rmeddis
        %         ANresponseTimes=dtSpikes:dtSpikes:length(ANresponse)*dtSpikes;
170
        %         figure(99), plot(ANresponseTimes,ANresponse)
171 32:82fb37eb430e rmeddis
172 29:b51bf546ca3f rmeddis
        % analyse results
173
        probeStart=initialSilenceDuration+maskerDuration+gapDuration;
174 38:c2204b18f4a2 rmeddis
        PSTHbinWidth=dtSpikes;
175 29:b51bf546ca3f rmeddis
        responseDelay=0.005;
176
        probeTimes=probeStart+responseDelay:...
177
            PSTHbinWidth:probeStart+probeDuration+responseDelay;
178
        probeIDX=round(probeTimes/PSTHbinWidth);
179
        probePSTH=ANresponse(probeIDX);
180
        firingRate=mean(probePSTH);
181
        % NB this only works if you start with the lowest level masker
182
        maxProbeResponse=max([maxProbeResponse firingRate]);
183
        allDurations=[allDurations gapDuration];
184
        allFiringRates=[allFiringRates firingRate];
185 32:82fb37eb430e rmeddis
186 29:b51bf546ca3f rmeddis
        %% show PSTHs
187
        if showPSTHs
188
            nLevels=length(maskerLevels);
189
            nDurations=length(gapDurations);
190
            figure(8)
191
            PSTHbinWidth=1e-3;
192 38:c2204b18f4a2 rmeddis
            PSTH=UTIL_PSTHmaker(ANresponse, dtSpikes, PSTHbinWidth);
193
            PSTH=PSTH*dtSpikes/PSTHbinWidth;
194 29:b51bf546ca3f rmeddis
            PSTHplotCount=PSTHplotCount+1;
195
            subplot(nLevels,nDurations,PSTHplotCount)
196 33:161913b595ae rmeddis
            PSTHtime=PSTHbinWidth:PSTHbinWidth:...
197 29:b51bf546ca3f rmeddis
                PSTHbinWidth*length(PSTH);
198 34:e097e9044ef6 rmeddis
            if strcmp(AN_spikesOrProbability, 'spikes')
199 38:c2204b18f4a2 rmeddis
                bar(PSTHtime, PSTH/PSTHbinWidth/nFibers)
200
                %                 ylim([0 500])
201 34:e097e9044ef6 rmeddis
            else
202 38:c2204b18f4a2 rmeddis
                bar(PSTHtime, PSTH)
203 29:b51bf546ca3f rmeddis
                ylim([0 500])
204
            end
205 38:c2204b18f4a2 rmeddis
            xlim([0 longestSignalDuration])
206 29:b51bf546ca3f rmeddis
            grid on
207
208
            if PSTHplotCount< (nLevels-1) * nDurations+1
209
                set(gca,'xticklabel',[])
210
            end
211
212
            if ~isequal(mod(PSTHplotCount,nDurations),1)
213
                set(gca,'yticklabel',[])
214
            else
215
                ylabel([num2str(maskerLevels...
216
                    (round(PSTHplotCount/nDurations) +1))])
217
            end
218
219
            if PSTHplotCount<=nDurations
220
                title([num2str(1000*gapDurations(PSTHplotCount)) 'ms'])
221
            end
222 33:161913b595ae rmeddis
223 38:c2204b18f4a2 rmeddis
            %         figure(99),            bar(PSTHtime, PSTH)
224 33:161913b595ae rmeddis
225 29:b51bf546ca3f rmeddis
        end % showPSTHs
226
227
    end     % gapDurations duration
228
    summaryFiringRates=[summaryFiringRates allFiringRates'];
229
230
    figure(7), hold on
231
    semilogx(allDurations, allFiringRates/maxProbeResponse)
232
    ylim([0 1]), hold on
233
    ylim([0 inf]), xlim([min(gapDurations) max(gapDurations)])
234
    xlim([0.001 1])
235
    pause(0.1) % to allow for CTRL/C interrupts
236
    resultsMatrix(levelNo,:)=allFiringRates;
237
end          % maskerLevel
238
239
disp('delay/ rates')
240
disp(num2str(round( [1000*allDurations' summaryFiringRates])))
241
242
% replot with best adjustment
243
% figure(34), clf% use for separate plot
244
figure(7), clf
245
peakProbe=max(max(resultsMatrix));
246
resultsMatrix=resultsMatrix/peakProbe;
247
semilogx(gapDurations,HDresponse,'o'), hold on
248
title(['FrMsk: probe ' num2str(probeLeveldB)...
249
    'dB SL: peakProbe=' num2str(peakProbe,'%5.0f') ' sp/s'])
250
xlabel('gap duration (s)'), ylabel ('probe response')
251
semilogx(allDurations, resultsMatrix'), ylim([0 1])
252
ylim([0 inf]),
253
xlim([0.001 1])
254
legend(strvcat(num2str(maskerLevels'-thresholdAtCF)), -1)
255
256
% ------------------------------------------------- display parameters
257
disp(['parameter file was: ' paramsName])
258
fprintf('\n')
259
% UTIL_showStruct(inputStimulusParams, 'inputStimulusParams')
260
% UTIL_showStruct(outerMiddleEarParams, 'outerMiddleEarParams')
261
% UTIL_showStruct(DRNLParams, 'DRNLParams')
262
% UTIL_showStruct(IHC_VResp_VivoParams, 'IHC_VResp_VivoParams')
263
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
264
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
265
266
267 32:82fb37eb430e rmeddis
path(restorePath);