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 @ 26:b03ef38fe497

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

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

    
72
        nCNneurons=size(CNoutput,1);
73
        nHSRCNneuronss=nCNneurons/nANfiberTypes;
74
        disp(['CN: ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))...
75
            /(nHSRCNneuronss*duration))])
76
        disp(['IC: ' num2str(sum(sum(ICoutput))/duration)])
77
        %         disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')])
78
    else
79
        disp(['AN: ' num2str(mean(mean(ANprobRateOutput)))])
80
        PSTH= UTIL_PSTHmakerb(ANprobRateOutput, dt, 0.001);
81
        disp(['max max AN: ' num2str(max(max(...
82
            PSTH )))])
83
    end
84
end
85

    
86

    
87
%% figure (99): display output from all model stages
88
if showMapOptions.showModelOutput
89
    plotInstructions.figureNo=99;
90
    signalRMS=mean(savedInputSignal.^2)^0.5;
91
    signalRMSdb=20*log10(signalRMS/20e-6);
92

    
93
    % plot signal (1)
94
    plotInstructions.displaydt=dt;
95
    plotInstructions.numPlots=6;
96
    plotInstructions.subPlotNo=1;
97
    plotInstructions.title=...
98
        ['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL'];
99
    r=size(savedInputSignal,1);
100
    if r==1, savedInputSignal=savedInputSignal'; end
101
    UTIL_plotMatrix(savedInputSignal', plotInstructions);
102

    
103
    % stapes (2)
104
    plotInstructions.subPlotNo=2;
105
    plotInstructions.title= ['stapes displacement'];
106
    UTIL_plotMatrix(OMEoutput, plotInstructions);
107

    
108
    % DRNL (3)
109
    plotInstructions.subPlotNo=3;
110
    plotInstructions.title= ['BM displacement'];
111
    plotInstructions.yValues= savedBFlist;
112
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
113

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

    
133
            % CN (5)
134
            plotInstructions.displaydt=ANdt;
135
            plotInstructions.subPlotNo=5;
136
            plotInstructions.title='CN spikes';
137
            if sum(sum(CNoutput))<100
138
                plotInstructions.rasterDotSize=3;
139
            end
140
            UTIL_plotMatrix(CNoutput, plotInstructions);
141

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

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

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

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

    
224

    
225
%% figure(98) plot efferent control values as dB
226
if showMapOptions.showEfferent
227
    plotInstructions=[];
228
    plotInstructions.figureNo=98;
229
    figure(98), clf
230
    plotInstructions.displaydt=dt;
231
    plotInstructions.numPlots=2;
232
    plotInstructions.subPlotNo=1;
233
    plotInstructions.zValuesRange=[ -25 0];
234
    plotInstructions.title= ['AR strength.  Signal level= ' ...
235
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
236
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
237

    
238
    plotInstructions.subPlotNo=2;
239
    plotInstructions.yValues= savedBFlist;
240
    plotInstructions.yLabel= 'BF';
241
    plotInstructions.title= ['MOC strength'];
242
    plotInstructions.zValuesRange=[ -25 0];
243
    subplot(2,1,2)
244
    % imagesc(MOCattenuation)
245
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
246
    colorbar
247
end
248

    
249
%% ACF plot if required
250
if showMapOptions.showACF
251
    tic
252
    method.dt=dt;
253
    method.segmentNo=1;
254
    method.nonlinCF=savedBFlist;
255

    
256
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
257
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
258
    pitches=fliplr(pitches);
259
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
260
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
261
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
262
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
263

    
264
    filteredSACFParams.plotACFs=0;          % special plot (see code)
265
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
266
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
267

    
268
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
269
    filteredSACFParams.lagsProcedure=  'useAllLags';
270
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
271
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
272
    filteredSACFParams.criterionForOmittingLags=3;
273
    filteredSACFParams.plotACFsInterval=200;
274

    
275
    if filteredSACFParams.plotACFs
276
        % plot original waveform on ACF plot
277
        figure(13), clf
278
        subplot(4,1,1)
279
        t=dt*(1:length(savedInputSignal));
280
        plot(t,savedInputSignal)
281
        xlim([0 t(end)])
282
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
283
    end
284

    
285
    % plot original waveform on summary/smoothed ACF plot
286
    figure(96), clf
287
    subplot(2,1,1)
288
    t=dt*(1:length(savedInputSignal));
289
    plot(t,savedInputSignal)
290
    xlim([0 t(end)])
291
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
292

    
293

    
294
    % compute ACF
295
    switch saveAN_spikesOrProbability
296
        case 'probability'
297
            inputToACF=ANprobRateOutput.^0.5;
298
        otherwise
299
            inputToACF=ANoutput;
300
    end
301

    
302
    disp ('computing ACF...')
303
    [P, BFlist, sacf, boundaryValue] = ...
304
        filteredSACF(inputToACF, method, filteredSACFParams);
305
    disp(' ACF done.')
306

    
307
    % SACF
308
    subplot(2,1,2)
309
    imagesc(P)
310
    ylabel('periodicities (Hz)')
311
    xlabel('time (s)')
312
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
313
    pt=[1 get(gca,'ytick')]; % force top xtick to show
314
    set(gca,'ytick',pt)
315
    set(gca,'ytickLabel', round(pitches(pt)))
316
    tt=get(gca,'xtick');
317
    set(gca,'xtickLabel', round(100*t(tt))/100)
318
end
319

    
320
path(restorePath)