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 @ 33:161913b595ae

History | View | Annotate | Download (12.4 KB)

1
function UTIL_showMAP (showMapOptions, paramChanges)
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
% showMapOptions
7
% showMapOptions.printModelParameters=1; % print model parameters
8
% showMapOptions.showModelOutput=1;      % plot all stages output
9
% showMapOptions.printFiringRates=1;     % mean activity at all stages
10
% showMapOptions.showACF=1;              % SACF (probabilities only)
11
% showMapOptions.showEfferent=1;         % plot of efferent activity
12
% showMapOptions.surfProbability=0;      % HSR (probability) surf plot
13
% showMapOptions.fileName=[];            % parameter filename for plot title
14

    
15
dbstop if warning
16

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

    
27

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

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

    
46
%% send all model parameters to command window
47
if showMapOptions.printModelParameters
48
    % Read parameters from MAPparams<***> file in 'parameterStore' folder
49
    %  and print out all parameters
50
    if nargin>1
51
        cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1, paramChanges);'];
52
        eval(cmd);
53
    else
54
        cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1);'];
55
        eval(cmd);
56
        disp(' no parameter changes found')
57
    end
58
end
59

    
60
%% summarise firing rates in command window
61
if showMapOptions.printFiringRates
62
    %% print summary firing rates
63
    fprintf('\n\n')
64
    disp('summary')
65
    disp(['AR: ' num2str(min(ARattenuation))])
66
    disp(['MOC: ' num2str(min(min(MOCattenuation)))])
67
    nANfiberTypes=length(ANtauCas);
68
    if strcmp(saveAN_spikesOrProbability, 'spikes')
69
        nANfibers=size(ANoutput,1);
70
        nHSRfibers=nANfibers/nANfiberTypes;
71
        duration=size(TMoutput,2)*dt;
72
        disp(['AN(HSR): ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/...
73
            (nHSRfibers*duration))])
74

    
75
        nCNneurons=size(CNoutput,1);
76
        nHSRCNneuronss=nCNneurons/nANfiberTypes;
77
        disp(['CN(HSR): ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))...
78
            /(nHSRCNneuronss*duration))])
79
        nICneurons=size(ICoutput,1);
80
        nHSRICneurons= round(nICneurons/nANfiberTypes);
81
        ICrate=sum(sum(ICoutput(end-nHSRICneurons:end,:)))/duration/nHSRICneurons;
82
        disp(['IC(HSR): ' num2str(ICrate)])
83
        %         disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')])
84
    else
85
        HSRprobOutput= ANprobRateOutput(end-length(savedBFlist)+1:end,:);
86
        disp(['AN(HSR): ' num2str(mean(mean(HSRprobOutput)))])
87
        PSTH= UTIL_PSTHmakerb(HSRprobOutput, dt, 0.001);
88
        disp(['max max AN: ' num2str(max(max(PSTH)))])
89
    end
90
end
91

    
92

    
93
%% figure (99): display output from all model stages
94
if showMapOptions.showModelOutput
95
    plotInstructions.figureNo=99;
96
    signalRMS=mean(savedInputSignal.^2)^0.5;
97
    signalRMSdb=20*log10(signalRMS/20e-6);
98

    
99
    % plot signal (1)
100
    plotInstructions.displaydt=dt;
101
    plotInstructions.numPlots=6;
102
    plotInstructions.subPlotNo=1;
103
    plotInstructions.title=...
104
        ['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL'];
105
    r=size(savedInputSignal,1);
106
    if r==1, savedInputSignal=savedInputSignal'; end
107
    UTIL_plotMatrix(savedInputSignal', plotInstructions);
108

    
109
    % stapes (2)
110
    plotInstructions.subPlotNo=2;
111
    plotInstructions.title= ['stapes displacement'];
112
    UTIL_plotMatrix(OMEoutput, plotInstructions);
113

    
114
    % DRNL (3)
115
    plotInstructions.subPlotNo=3;
116
    plotInstructions.title= ['BM displacement'];
117
    plotInstructions.yValues= savedBFlist;
118
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
119

    
120
    switch saveAN_spikesOrProbability
121
        case 'spikes'
122
            % AN (4)
123
            plotInstructions.displaydt=ANdt;
124
            plotInstructions.title='AN';
125
            plotInstructions.subPlotNo=4;
126
            plotInstructions.yLabel='BF';
127
            plotInstructions.yValues= savedBFlist;
128
            plotInstructions.rasterDotSize=1;
129
            if length(ANtauCas)==2
130
                plotInstructions.plotDivider=1;
131
            else
132
                plotInstructions.plotDivider=0;
133
            end
134
            if sum(sum(ANoutput))<100
135
                plotInstructions.rasterDotSize=3;
136
            end
137
            UTIL_plotMatrix(ANoutput, plotInstructions);
138

    
139
            % CN (5)
140
            plotInstructions.displaydt=ANdt;
141
            plotInstructions.subPlotNo=5;
142
            plotInstructions.title='CN spikes';
143
            if sum(sum(CNoutput))<100
144
                plotInstructions.rasterDotSize=3;
145
            end
146
            UTIL_plotMatrix(CNoutput, plotInstructions);
147

    
148
            % IC (6)
149
            plotInstructions.displaydt=ANdt;
150
            plotInstructions.subPlotNo=6;
151
            plotInstructions.title='IC';
152
            if size(ICoutput,1)>1
153
                if sum(sum(ICoutput))<100
154
                    plotInstructions.rasterDotSize=3;
155
                end
156
                UTIL_plotMatrix(ICoutput, plotInstructions);
157
            else
158
                plotInstructions.title='IC (HSR) membrane potential';
159
                plotInstructions.displaydt=dt;
160
                plotInstructions.yLabel='V';
161
                plotInstructions.zValuesRange= [-.1 0];
162
                UTIL_plotMatrix(ICmembraneOutput, plotInstructions);
163
            end
164

    
165
        otherwise % AN rate based on probability of firing
166
            PSTHbinWidth=0.001;
167
            PSTH= UTIL_PSTHmakerb(ANprobRateOutput, dt, PSTHbinWidth);
168
            plotInstructions.displaydt=PSTHbinWidth;
169
            plotInstructions.numPlots=2;
170
            plotInstructions.subPlotNo=2;
171
            plotInstructions.yLabel='BF';
172
            if nANfiberTypes>1,
173
                plotInstructions.yLabel='LSR    HSR';
174
                plotInstructions.plotDivider=1;
175
            end
176
            plotInstructions.title='AN - spike rate';
177
            UTIL_plotMatrix(PSTH, plotInstructions);
178
    end
179
end
180

    
181
if showMapOptions.surfProbability &&...
182
        strcmp(saveAN_spikesOrProbability,'probability') && ...
183
        length(savedBFlist)>2
184
    %% surface plot of probability
185
        % select only HSR fibers
186
        figure(97), clf
187
        HSRprobOutput= ANprobRateOutput(end-length(savedBFlist)+1:end,:);
188
        PSTHbinWidth=0.001;
189
        PSTH=UTIL_PSTHmakerb(HSRprobOutput, ANdt, PSTHbinWidth);
190
        [nY nX]=size(PSTH);
191
        time=PSTHbinWidth*(1:nX);
192
        surf(time, savedBFlist, PSTH)
193
        shading interp
194
        set(gca, 'yScale','log')
195
        xlim([0 max(time)])
196
        ylim([0 max(savedBFlist)])
197
        zlim([0 1000])
198
        xlabel('time (s)')
199
        ylabel('best frequency (Hz)')
200
        zlabel('spike rate')
201
        view([-20 60])
202
        %     view([0 90])
203
        disp(['max max AN: ' num2str(max(max(PSTH)))])
204

    
205
        title (['firing probability of HSR fibers only. Level= ' ...
206
            num2str(signalRMSdb,'% 3.0f') ' dB'])
207
end
208

    
209
if showMapOptions.surfSpikes
210
    %% surface plot of AN spikes
211
    figure(97), clf
212
    % select only HSR fibers at the bottom of the matrix
213
    ANoutput= ANoutput(end-length(savedBFlist)+1:end,:);
214
    PSTHbinWidth=0.005; % 1 ms bins
215
    PSTH=UTIL_makePSTH(ANoutput, ANdt, PSTHbinWidth);
216
    [nY nX]=size(PSTH);
217
    time=PSTHbinWidth*(1:nX);
218
    surf(time, savedBFlist, PSTH)
219
    shading interp
220
    set(gca, 'yScale','log')
221
    xlim([0 max(time)])
222
    ylim([0 max(savedBFlist)])
223
    %     zlim([0 1000])
224
    xlabel('time (s)')
225
    ylabel('best frequency (Hz)')
226
    zlabel('spike rate')
227
    view([-20 60])
228
    %     view([0 90])
229
    title ([showMapOptions.fileName ':   ' num2str(signalRMSdb,'% 3.0f') ' dB'])
230
end
231

    
232

    
233
%% figure(98) plot efferent control values as dB
234
if showMapOptions.showEfferent
235
    plotInstructions=[];
236
    plotInstructions.figureNo=98;
237
    figure(98), clf
238
    plotInstructions.displaydt=dt;
239
    plotInstructions.numPlots=2;
240
    plotInstructions.subPlotNo=1;
241
    plotInstructions.zValuesRange=[ -25 0];
242
    plotInstructions.title= ['AR strength.  Signal level= ' ...
243
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
244
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
245

    
246
    plotInstructions.subPlotNo=2;
247
    plotInstructions.yValues= savedBFlist;
248
    plotInstructions.yLabel= 'BF';
249
    plotInstructions.title= ['MOC strength'];
250
    plotInstructions.zValuesRange=[ -25 0];
251
    subplot(2,1,2)
252
    % imagesc(MOCattenuation)
253
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
254
    colorbar
255
end
256

    
257
%% ACF plot if required
258
if showMapOptions.showACF
259
    tic
260
    method.dt=dt;
261
    method.segmentNo=1;
262
    method.nonlinCF=savedBFlist;
263

    
264
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
265
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
266
    pitches=fliplr(pitches);
267
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
268
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
269
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
270
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
271

    
272
    filteredSACFParams.plotACFs=0;          % special plot (see code)
273
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
274
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
275

    
276
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
277
    filteredSACFParams.lagsProcedure=  'useAllLags';
278
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
279
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
280
    filteredSACFParams.criterionForOmittingLags=3;
281
    filteredSACFParams.plotACFsInterval=200;
282

    
283
    if filteredSACFParams.plotACFs
284
        % plot original waveform on ACF plot
285
        figure(13), clf
286
        subplot(4,1,1)
287
        t=dt*(1:length(savedInputSignal));
288
        plot(t,savedInputSignal)
289
        xlim([0 t(end)])
290
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
291
    end
292

    
293
    % plot original waveform on summary/smoothed ACF plot
294
    figure(96), clf
295
    subplot(2,1,1)
296
    t=dt*(1:length(savedInputSignal));
297
    plot(t,savedInputSignal)
298
    xlim([0 t(end)])
299
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
300

    
301

    
302
    % compute ACF
303
    switch saveAN_spikesOrProbability
304
        case 'probability'
305
            inputToACF=ANprobRateOutput.^0.5;
306
        otherwise
307
            inputToACF=ANoutput;
308
    end
309

    
310
    disp ('computing ACF...')
311
    [P, BFlist, sacf, boundaryValue] = ...
312
        filteredSACF(inputToACF, method, filteredSACFParams);
313
    disp(' ACF done.')
314

    
315
    % SACF
316
    subplot(2,1,2)
317
    imagesc(P)
318
    ylabel('periodicities (Hz)')
319
    xlabel('time (s)')
320
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
321
    pt=[1 get(gca,'ytick')]; % force top xtick to show
322
    set(gca,'ytick',pt)
323
    set(gca,'ytickLabel', round(pitches(pt)))
324
    tt=get(gca,'xtick');
325
    set(gca,'xtickLabel', round(100*t(tt))/100)
326
end
327

    
328
path(restorePath)
329

    
330
%% IC chopper analysis
331
global ICrate
332
if showMapOptions.ICrates
333
[r nEpochs]=size(ICoutput);
334
ICrate=zeros(1,length(CNtauGk));
335
% convert ICoutput to a 4-D matrix (time, CNtau, BF, fiberType)
336
%  NB only one IC unit for any combination.
337
y=reshape(ICoutput', ...
338
    nEpochs, length(CNtauGk),length(savedBFlist),length(ANtauCas));
339
for i=1:length(CNtauGk)
340
    ICrate(i)=sum(sum(sum(y(:,i,:,:))))/duration;
341
    fprintf('%10.5f\t%6.0f\n', CNtauGk(i), ICrate(i))
342
end
343
figure(95), plot(CNtauGk,ICrate)
344
title ('ICrate'), xlabel('CNtauGk'), ylabel('ICrate')
345
end