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 @ 25:d2c4c07df02c

History | View | Annotate | Download (11 KB)

1
function UTIL_showMAP (showMapOptions)
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 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
    showMapOptions=[];
31
end
32
% defaults (plot staged outputs and print rates only) if options omitted
33
if ~isfield(showMapOptions,'printModelParameters')
34
        showMapOptions.printModelParameters=0; end
35
if ~isfield(showMapOptions,'showModelOutput'),showMapOptions.showModelOutput=1;end
36
if ~isfield(showMapOptions,'printFiringRates'),showMapOptions.printFiringRates=1;end
37
if ~isfield(showMapOptions,'showACF'),showMapOptions.showACF=0;end
38
if ~isfield(showMapOptions,'showEfferent'),showMapOptions.showEfferent=0;end
39
if ~isfield(showMapOptions,'surfProbability'),showMapOptions.surfProbability=0;end
40
if ~isfield(showMapOptions,'fileName'),showMapOptions.fileName=[];end
41
if ~isfield(showMapOptions,'surfSpikes'),showMapOptions.surfSpikes=0;end
42

    
43

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

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

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

    
80

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

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

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

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

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

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

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

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

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

    
190
if showMapOptions.surfSpikes
191
    %% surface plot of probability
192
    figure(97), clf
193
    % select only HSR fibers at the bottom of the matrix
194
    ANoutput= ANoutput(end-length(savedBFlist)+1:end,:);
195
    PSTHbinWidth=0.001; % 1 ms bins
196
    PSTH=UTIL_PSTHmakerb(ANoutput, ANdt, PSTHbinWidth);
197
    [nY nX]=size(PSTH);
198
    time=PSTHbinWidth*(1:nX);
199
    surf(time, savedBFlist, PSTH)
200
    shading interp
201
    set(gca, 'yScale','log')
202
    xlim([0 max(time)])
203
    ylim([0 max(savedBFlist)])
204
%     zlim([0 1000])
205
    xlabel('time (s)')
206
    ylabel('best frequency (Hz)')
207
    zlabel('spike rate')
208
    view([-20 60])
209
    %     view([0 90])
210
    title ([showMapOptions.fileName ':   ' num2str(signalRMSdb,'% 3.0f') ' dB'])
211
end
212

    
213

    
214
%% plot efferent control values as dB
215
if showMapOptions.showEfferent
216
    plotInstructions=[];
217
    plotInstructions.figureNo=98;
218
    figure(98), clf
219
    plotInstructions.displaydt=dt;
220
    plotInstructions.numPlots=2;
221
    plotInstructions.subPlotNo=1;
222
    plotInstructions.zValuesRange=[ -25 0];
223
    plotInstructions.title= ['AR strength.  Signal level= ' ...
224
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
225
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
226

    
227
    plotInstructions.subPlotNo=2;
228
    plotInstructions.yValues= savedBFlist;
229
    plotInstructions.yLabel= 'BF';
230
    plotInstructions.title= ['MOC strength'];
231
    plotInstructions.zValuesRange=[ -25 0];
232
    subplot(2,1,2)
233
    % imagesc(MOCattenuation)
234
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
235
    colorbar
236
end
237

    
238
%% ACF plot if required
239
if showMapOptions.showACF
240
    tic
241
    method.dt=dt;
242
    method.segmentNo=1;
243
    method.nonlinCF=savedBFlist;
244

    
245
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
246
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
247
    pitches=fliplr(pitches);
248
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
249
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
250
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
251
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
252

    
253
    filteredSACFParams.plotACFs=0;          % special plot (see code)
254
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
255
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
256

    
257
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
258
    filteredSACFParams.lagsProcedure=  'useAllLags';
259
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
260
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
261
    filteredSACFParams.criterionForOmittingLags=3;
262
    filteredSACFParams.plotACFsInterval=200;
263

    
264
    if filteredSACFParams.plotACFs
265
        % plot original waveform on ACF plot
266
        figure(13), clf
267
        subplot(4,1,1)
268
        t=dt*(1:length(savedInputSignal));
269
        plot(t,savedInputSignal)
270
        xlim([0 t(end)])
271
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
272
    end
273

    
274
    % plot original waveform on summary/smoothed ACF plot
275
    figure(96), clf
276
    subplot(2,1,1)
277
    t=dt*(1:length(savedInputSignal));
278
    plot(t,savedInputSignal)
279
    xlim([0 t(end)])
280
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
281

    
282

    
283
    % compute ACF
284
    switch saveAN_spikesOrProbability
285
        case 'probability'
286
            inputToACF=ANprobRateOutput.^0.5;
287
        otherwise
288
            inputToACF=ANoutput;
289
    end
290

    
291
    disp ('computing ACF...')
292
    [P, BFlist, sacf, boundaryValue] = ...
293
        filteredSACF(inputToACF, method, filteredSACFParams);
294
    disp(' ACF done.')
295

    
296
    % SACF
297
    subplot(2,1,2)
298
    imagesc(P)
299
    ylabel('periodicities (Hz)')
300
    xlabel('time (s)')
301
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
302
    pt=[1 get(gca,'ytick')]; % force top xtick to show
303
    set(gca,'ytick',pt)
304
    set(gca,'ytickLabel', round(pitches(pt)))
305
    tt=get(gca,'xtick');
306
    set(gca,'xtickLabel', round(100*t(tt))/100)
307
end
308

    
309
path(restorePath)