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 / utilities / UTIL_showMAP.m @ 24:a5e4a43c1673

History | View | Annotate | Download (9.96 KB)

1
function UTIL_showMAP (options)
2
% UTIL_showMAP produces summaries of the output from MAP's mmost recent run
3
%  All MAP outputs are stored in global variables and UTIL_showMAP
4
%  simply assumes that they are in place.
5
%
6
% options
7
% options.printModelParameters=1; % print model parameters 
8
% options.showModelOutput=1;      % plot all stages output
9
% options.printFiringRates=1;     % mean activity at all stages
10
% options.showACF=1;              % SACF (probabilities only)
11
% options.showEfferent=1;         % plot of efferent activity
12
% options.surfProbability=0;      % HSR (probability) surf plot
13
% options.fileName=[];            % parameter filename for plot title
14

    
15
dbstop if warning
16

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

    
25

    
26
restorePath=path;
27
addpath ( ['..' filesep 'utilities'], ['..' filesep 'parameterStore'])
28

    
29
if nargin<1
30
    options=[];
31
end
32
% defaults (plot staged outputs and print rates only)
33
if ~isfield(options,'printModelParameters')
34
        options.printModelParameters=0; end
35
if ~isfield(options,'showModelOutput'),options.showModelOutput=1;end
36
if ~isfield(options,'printFiringRates'),options.printFiringRates=1;end
37
if ~isfield(options,'showACF'),options.showACF=0;end
38
if ~isfield(options,'showEfferent'),options.showEfferent=0;end
39
if ~isfield(options,'surfProbability'),options.surfProbability=0;end
40
if ~isfield(options,'fileName'),options.fileName=[];end
41

    
42

    
43
if options.printModelParameters
44
    % Read parameters from MAPparams<***> file in 'parameterStore' folder
45
    %  and print out all parameters
46
    cmd=['MAPparams' saveMAPparamsName ...
47
        '(-1, 1/dt, 1);'];
48
    eval(cmd);
49
end
50

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

    
65
        nCNneurons=size(CNoutput,1);
66
        nHSRCNneuronss=nCNneurons/nANfiberTypes;
67
        disp(['CN: ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))...
68
            /(nHSRCNneuronss*duration))])
69
        disp(['IC: ' num2str(sum(sum(ICoutput))/duration)])
70
        %         disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')])
71
    else
72
        disp(['AN: ' num2str(mean(mean(ANprobRateOutput)))])
73
        [PSTH pointsPerBin]= UTIL_makePSTH(ANprobRateOutput, dt, 0.001);
74
        disp(['max max AN: ' num2str(max(max(...
75
            PSTH/pointsPerBin )))])
76
    end
77
end
78

    
79

    
80
%% figure (99) summarises main model output
81
if options.showModelOutput
82
    plotInstructions.figureNo=99;
83
    signalRMS=mean(savedInputSignal.^2)^0.5;
84
    signalRMSdb=20*log10(signalRMS/20e-6);
85

    
86
    % plot signal (1)
87
    plotInstructions.displaydt=dt;
88
    plotInstructions.numPlots=6;
89
    plotInstructions.subPlotNo=1;
90
    plotInstructions.title=...
91
        ['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL'];
92
    r=size(savedInputSignal,1);
93
    if r==1, savedInputSignal=savedInputSignal'; end
94
    UTIL_plotMatrix(savedInputSignal', plotInstructions);
95

    
96
    % stapes (2)
97
    plotInstructions.subPlotNo=2;
98
    plotInstructions.title= ['stapes displacement'];
99
    UTIL_plotMatrix(OMEoutput, plotInstructions);
100

    
101
    % DRNL (3)
102
    plotInstructions.subPlotNo=3;
103
    plotInstructions.title= ['BM displacement'];
104
    plotInstructions.yValues= savedBFlist;
105
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
106

    
107
    switch saveAN_spikesOrProbability
108
        case 'spikes'
109
            % AN (4)
110
            plotInstructions.displaydt=ANdt;
111
            plotInstructions.title='AN';
112
            plotInstructions.subPlotNo=4;
113
            plotInstructions.yLabel='BF';
114
            plotInstructions.yValues= savedBFlist;
115
            plotInstructions.rasterDotSize=1;
116
            if length(tauCas)==2
117
                plotInstructions.plotDivider=1;
118
            else
119
                plotInstructions.plotDivider=0;
120
            end
121
            if sum(sum(ANoutput))<100
122
                plotInstructions.rasterDotSize=3;
123
            end
124
            UTIL_plotMatrix(ANoutput, plotInstructions);
125

    
126
            % CN (5)
127
            plotInstructions.displaydt=ANdt;
128
            plotInstructions.subPlotNo=5;
129
            plotInstructions.title='CN spikes';
130
            if sum(sum(CNoutput))<100
131
                plotInstructions.rasterDotSize=3;
132
            end
133
            UTIL_plotMatrix(CNoutput, plotInstructions);
134

    
135
            % IC (6)
136
            plotInstructions.displaydt=ANdt;
137
            plotInstructions.subPlotNo=6;
138
            plotInstructions.title='IC';
139
            if size(ICoutput,1)>3
140
                if sum(sum(ICoutput))<100
141
                    plotInstructions.rasterDotSize=3;
142
                end
143
                UTIL_plotMatrix(ICoutput, plotInstructions);
144
            else
145
                plotInstructions.title='IC (HSR) membrane potential';
146
                plotInstructions.displaydt=dt;
147
                plotInstructions.yLabel='V';
148
                plotInstructions.zValuesRange= [-.1 0];
149
                UTIL_plotMatrix(ICmembraneOutput, plotInstructions);
150
            end
151

    
152
        otherwise % probability (4-6)
153
            plotInstructions.displaydt=dt;
154
            plotInstructions.numPlots=2;
155
            plotInstructions.subPlotNo=2;
156
            plotInstructions.yLabel='BF';
157
            if nANfiberTypes>1,
158
                plotInstructions.yLabel='LSR    HSR';
159
                plotInstructions.plotDivider=1;
160
            end
161
            plotInstructions.title='AN - spike probability';
162
            UTIL_plotMatrix(ANprobRateOutput, plotInstructions);
163
    end
164
end
165

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

    
189

    
190
%% plot efferent control values as dB
191
if options.showEfferent
192
    plotInstructions=[];
193
    plotInstructions.figureNo=98;
194
    figure(98), clf
195
    plotInstructions.displaydt=dt;
196
    plotInstructions.numPlots=2;
197
    plotInstructions.subPlotNo=1;
198
    plotInstructions.zValuesRange=[ -25 0];
199
    plotInstructions.title= ['AR strength.  Signal level= ' ...
200
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
201
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
202

    
203
    plotInstructions.subPlotNo=2;
204
    plotInstructions.yValues= savedBFlist;
205
    plotInstructions.yLabel= 'BF';
206
    plotInstructions.title= ['MOC strength'];
207
    plotInstructions.zValuesRange=[ -25 0];
208
    subplot(2,1,2)
209
    % imagesc(MOCattenuation)
210
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
211
    colorbar
212
end
213

    
214
%% ACF plot if required
215
if options.showACF
216
    tic
217
    method.dt=dt;
218
    method.segmentNo=1;
219
    method.nonlinCF=savedBFlist;
220

    
221
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
222
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
223
    pitches=fliplr(pitches);
224
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
225
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
226
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
227
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
228

    
229
    filteredSACFParams.plotACFs=0;          % special plot (see code)
230
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
231
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
232

    
233
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
234
    filteredSACFParams.lagsProcedure=  'useAllLags';
235
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
236
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
237
    filteredSACFParams.criterionForOmittingLags=3;
238
    filteredSACFParams.plotACFsInterval=200;
239

    
240
    if filteredSACFParams.plotACFs
241
        % plot original waveform on ACF plot
242
        figure(13), clf
243
        subplot(4,1,1)
244
        t=dt*(1:length(savedInputSignal));
245
        plot(t,savedInputSignal)
246
        xlim([0 t(end)])
247
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
248
    end
249

    
250
    % plot original waveform on summary/smoothed ACF plot
251
    figure(96), clf
252
    subplot(2,1,1)
253
    t=dt*(1:length(savedInputSignal));
254
    plot(t,savedInputSignal)
255
    xlim([0 t(end)])
256
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
257

    
258

    
259
    % compute ACF
260
    switch saveAN_spikesOrProbability
261
        case 'probability'
262
            inputToACF=ANprobRateOutput.^0.5;
263
        otherwise
264
            inputToACF=ANoutput;
265
    end
266

    
267
    disp ('computing ACF...')
268
    [P, BFlist, sacf, boundaryValue] = ...
269
        filteredSACF(inputToACF, method, filteredSACFParams);
270
    disp(' ACF done.')
271

    
272
    % SACF
273
    subplot(2,1,2)
274
    imagesc(P)
275
    ylabel('periodicities (Hz)')
276
    xlabel('time (s)')
277
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
278
    pt=[1 get(gca,'ytick')]; % force top xtick to show
279
    set(gca,'ytick',pt)
280
    set(gca,'ytickLabel', round(pitches(pt)))
281
    tt=get(gca,'xtick');
282
    set(gca,'xtickLabel', round(100*t(tt))/100)
283
end
284

    
285
path(restorePath)