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 / showMAP.m @ 21:c489ebada16e

History | View | Annotate | Download (8.99 KB)

1
function showMAP ()
2
% defaults
3
% options.showModelParameters=1;
4
% options.showModelOutput=1;
5
% options.printFiringRates=1;
6
% options.showACF=1;
7
% options.showEfferent=1;
8
% options.surfProbability=0;
9
% options.fileName=[];
10

    
11
dbstop if warning
12

    
13
global dt ANdt saveAN_spikesOrProbability savedBFlist saveMAPparamsName...
14
    savedInputSignal TMoutput OMEoutput ARattenuation ...
15
    DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV...
16
    IHCoutput ANprobRateOutput ANoutput savePavailable tauCas  ...
17
    CNoutput  ICoutput ICmembraneOutput ICfiberTypeRates MOCattenuation
18
global OMEParams DRNLParams IHC_cilia_RPParams IHCpreSynapseParams
19
global AN_IHCsynapseParams MacGregorParams MacGregorMultiParams
20
global showMapOptions
21

    
22

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

    
26
if nargin<1
27
    options.showModelParameters=1;
28
    options.showModelOutput=1;
29
    options.printFiringRates=1;
30
    options.showACF=0;
31
    options.showEfferent=1;
32
    options.surfProbability=0;
33
    options.fileName=[];
34
end
35

    
36
if options.showModelParameters
37
    % Read parameters from MAPparams<***> file in 'parameterStore' folder
38
    %  and print out all parameters
39
    cmd=['MAPparams' saveMAPparamsName ...
40
        '(-1, 1/dt, 1);'];
41
    eval(cmd);
42
end
43

    
44
if options.printFiringRates
45
    %% print summary firing rates
46
    fprintf('\n\n')
47
    disp('summary')
48
    disp(['AR: ' num2str(min(ARattenuation))])
49
    disp(['MOC: ' num2str(min(min(MOCattenuation)))])
50
    nANfiberTypes=length(tauCas);
51
    if strcmp(saveAN_spikesOrProbability, 'spikes')
52
        nANfibers=size(ANoutput,1);
53
        nHSRfibers=nANfibers/nANfiberTypes;
54
        duration=size(TMoutput,2)*dt;
55
        disp(['AN: ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/...
56
            (nHSRfibers*duration))])
57

    
58
        nCNneurons=size(CNoutput,1);
59
        nHSRCNneuronss=nCNneurons/nANfiberTypes;
60
        disp(['CN: ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))...
61
            /(nHSRCNneuronss*duration))])
62
        disp(['IC: ' num2str(sum(sum(ICoutput))/duration)])
63
        %         disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')])
64
    else
65
        disp(['AN: ' num2str(mean(mean(ANprobRateOutput)))])
66
    end
67
end
68

    
69

    
70
%% figure (99) summarises main model output
71
if options.showModelOutput
72
    plotInstructions.figureNo=99;
73
    signalRMS=mean(savedInputSignal.^2)^0.5;
74
    signalRMSdb=20*log10(signalRMS/20e-6);
75

    
76
    % plot signal (1)
77
    plotInstructions.displaydt=dt;
78
    plotInstructions.numPlots=6;
79
    plotInstructions.subPlotNo=1;
80
    plotInstructions.title=...
81
        ['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL'];
82
    r=size(savedInputSignal,1);
83
    if r==1, savedInputSignal=savedInputSignal'; end
84
    UTIL_plotMatrix(savedInputSignal', plotInstructions);
85

    
86
    % stapes (2)
87
    plotInstructions.subPlotNo=2;
88
    plotInstructions.title= ['stapes displacement'];
89
    UTIL_plotMatrix(OMEoutput, plotInstructions);
90

    
91
    % DRNL (3)
92
    plotInstructions.subPlotNo=3;
93
    plotInstructions.title= ['BM displacement'];
94
    plotInstructions.yValues= savedBFlist;
95
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
96

    
97
    switch saveAN_spikesOrProbability
98
        case 'spikes'
99
            % AN (4)
100
            plotInstructions.displaydt=ANdt;
101
            plotInstructions.title='AN';
102
            plotInstructions.subPlotNo=4;
103
            plotInstructions.yLabel='BF';
104
            plotInstructions.yValues= savedBFlist;
105
            plotInstructions.rasterDotSize=1;
106
            plotInstructions.plotDivider=1;
107
            if sum(sum(ANoutput))<100
108
                plotInstructions.rasterDotSize=3;
109
            end
110
            UTIL_plotMatrix(ANoutput, plotInstructions);
111

    
112
            % CN (5)
113
            plotInstructions.displaydt=ANdt;
114
            plotInstructions.subPlotNo=5;
115
            plotInstructions.title='CN spikes';
116
            if sum(sum(CNoutput))<100
117
                plotInstructions.rasterDotSize=3;
118
            end
119
            UTIL_plotMatrix(CNoutput, plotInstructions);
120

    
121
            % IC (6)
122
            plotInstructions.displaydt=ANdt;
123
            plotInstructions.subPlotNo=6;
124
            plotInstructions.title='IC';
125
            if size(ICoutput,1)>3
126
                if sum(sum(ICoutput))<100
127
                    plotInstructions.rasterDotSize=3;
128
                end
129
                UTIL_plotMatrix(ICoutput, plotInstructions);
130
            else
131
                plotInstructions.title='IC (HSR) membrane potential';
132
                plotInstructions.displaydt=dt;
133
                plotInstructions.yLabel='V';
134
                plotInstructions.zValuesRange= [-.1 0];
135
                UTIL_plotMatrix(ICmembraneOutput, plotInstructions);
136
            end
137

    
138
        otherwise % probability (4-6)
139
            plotInstructions.displaydt=dt;
140
            plotInstructions.numPlots=2;
141
            plotInstructions.subPlotNo=2;
142
            plotInstructions.yLabel='BF';
143
            if nANfiberTypes>1,
144
                plotInstructions.yLabel='LSR    HSR';
145
                plotInstructions.plotDivider=1;
146
            end
147
            plotInstructions.title='AN - spike probability';
148
            UTIL_plotMatrix(ANprobRateOutput, plotInstructions);
149
    end
150
end
151

    
152
%% plot efferent control values as dB
153
if options.showEfferent
154
    plotInstructions=[];
155
    plotInstructions.figureNo=98;
156
    figure(98), clf
157
    plotInstructions.displaydt=dt;
158
    plotInstructions.numPlots=2;
159
    plotInstructions.subPlotNo=1;
160
    plotInstructions.zValuesRange=[ -25 0];
161
    plotInstructions.title= ['AR strength.  Signal level= ' ...
162
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
163
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
164

    
165
    plotInstructions.subPlotNo=2;
166
    plotInstructions.yValues= savedBFlist;
167
    plotInstructions.yLabel= 'BF';
168
    plotInstructions.title= ['MOC strength'];
169
    plotInstructions.zValuesRange=[ -25 0];
170
    subplot(2,1,2)
171
    % imagesc(MOCattenuation)
172
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
173
    colorbar
174
end
175

    
176
if options.surfProbability
177
%% surface plot of probability
178
    figure(97), clf
179
    % select only HSR fibers at the bottom of the matrix
180
    ANprobRateOutput= ANprobRateOutput(end-length(savedBFlist)+1:end,:);
181
    PSTHbinWidth=0.001;
182
    PSTH=UTIL_PSTHmakerb(ANprobRateOutput, ANdt, PSTHbinWidth);
183
    [nY nX]=size(PSTH);
184
    PSTH=PSTH(:,200:end);
185
    [nY nX]=size(PSTH);
186
    time=PSTHbinWidth*(1:nX);
187
    surf(time, savedBFlist, PSTH)
188
    shading interp
189
    set(gca, 'yScale','log')
190
    xlim([0 max(time)])
191
    ylim([0 max(savedBFlist)])
192
    zlim([0 1000])
193
    xlabel('time (s)')
194
    ylabel('best frequency (Hz)')
195
    zlabel('spike rate')
196
    view([-20 60])
197
%     view([0 90])
198
    title ([options.fileName ':   ' num2str(signalRMSdb,'% 3.0f') ' dB'])
199
end
200

    
201

    
202
%% ACF plot if required
203
if options.showACF
204
    tic
205
    method.dt=dt;
206
    method.segmentNo=1;
207
    method.nonlinCF=savedBFlist;
208

    
209
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
210
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
211
    pitches=fliplr(pitches);
212
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
213
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
214
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
215
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
216

    
217
    filteredSACFParams.plotACFs=0;          % special plot (see code)
218
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
219
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
220

    
221
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
222
    filteredSACFParams.lagsProcedure=  'useAllLags';
223
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
224
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
225
    filteredSACFParams.criterionForOmittingLags=3;
226
    filteredSACFParams.plotACFsInterval=200;
227

    
228
    if filteredSACFParams.plotACFs
229
        % plot original waveform on ACF plot
230
        figure(13), clf
231
        subplot(4,1,1)
232
        t=dt*(1:length(savedInputSignal));
233
        plot(t,savedInputSignal)
234
        xlim([0 t(end)])
235
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
236
    end
237

    
238
    % plot original waveform on summary/smoothed ACF plot
239
    figure(96), clf
240
    subplot(2,1,1)
241
    t=dt*(1:length(savedInputSignal));
242
    plot(t,savedInputSignal)
243
    xlim([0 t(end)])
244
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
245

    
246

    
247
    % compute ACF
248
    switch saveAN_spikesOrProbability
249
        case 'probability'
250
            inputToACF=ANprobRateOutput.^0.5;
251
        otherwise
252
            inputToACF=ANoutput;
253
    end
254

    
255
    disp ('computing ACF...')
256
    [P, BFlist, sacf, boundaryValue] = ...
257
        filteredSACF(inputToACF, method, filteredSACFParams);
258
    disp(' ACF done.')
259

    
260
    % SACF
261
    subplot(2,1,2)
262
    imagesc(P)
263
    ylabel('periodicities (Hz)')
264
    xlabel('time (s)')
265
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
266
    pt=[1 get(gca,'ytick')]; % force top xtick to show
267
    set(gca,'ytick',pt)
268
    set(gca,'ytickLabel', round(pitches(pt)))
269
    tt=get(gca,'xtick');
270
    set(gca,'xtickLabel', round(100*t(tt))/100)
271
end
272

    
273
path(restorePath)