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 @ 23:6cce421531e2

History | View | Annotate | Download (9.56 KB)

1
function UTIL_showMAP (options)
2
% options
3
% options.printModelParameters=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
% options.surfProbability=0;
11

    
12
dbstop if warning
13

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

    
22

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

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

    
38

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

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

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

    
75

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

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

    
92
    % stapes (2)
93
    plotInstructions.subPlotNo=2;
94
    plotInstructions.title= ['stapes displacement'];
95
    UTIL_plotMatrix(OMEoutput, plotInstructions);
96

    
97
    % DRNL (3)
98
    plotInstructions.subPlotNo=3;
99
    plotInstructions.title= ['BM displacement'];
100
    plotInstructions.yValues= savedBFlist;
101
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
102

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

    
122
            % CN (5)
123
            plotInstructions.displaydt=ANdt;
124
            plotInstructions.subPlotNo=5;
125
            plotInstructions.title='CN spikes';
126
            if sum(sum(CNoutput))<100
127
                plotInstructions.rasterDotSize=3;
128
            end
129
            UTIL_plotMatrix(CNoutput, plotInstructions);
130

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

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

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

    
185

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

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

    
210
%% ACF plot if required
211
if options.showACF
212
    tic
213
    method.dt=dt;
214
    method.segmentNo=1;
215
    method.nonlinCF=savedBFlist;
216

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

    
225
    filteredSACFParams.plotACFs=0;          % special plot (see code)
226
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
227
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
228

    
229
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
230
    filteredSACFParams.lagsProcedure=  'useAllLags';
231
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
232
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
233
    filteredSACFParams.criterionForOmittingLags=3;
234
    filteredSACFParams.plotACFsInterval=200;
235

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

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

    
254

    
255
    % compute ACF
256
    switch saveAN_spikesOrProbability
257
        case 'probability'
258
            inputToACF=ANprobRateOutput.^0.5;
259
        otherwise
260
            inputToACF=ANoutput;
261
    end
262

    
263
    disp ('computing ACF...')
264
    [P, BFlist, sacf, boundaryValue] = ...
265
        filteredSACF(inputToACF, method, filteredSACFParams);
266
    disp(' ACF done.')
267

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

    
281
path(restorePath)