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 / testPrograms / showMAP.m @ 18:e9e263e4fcde

History | View | Annotate | Download (8.83 KB)

1
function showMAP (options)
2
% defaults
3
% options.showModelParameters=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

    
11
dbstop if warning
12

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

    
21

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

    
25
if nargin<1
26
    options.showModelParameters=1;
27
    options.showModelOutput=1;
28
    options.printFiringRates=1;
29
    options.showACF=0;
30
    options.showEfferent=1;
31
    options.surfProbability=0;
32
    options.fileName=[];
33
end
34

    
35
if options.showModelParameters
36
    % Read parameters from MAPparams<***> file in 'parameterStore' folder
37
    %  and print out all parameters
38
    cmd=['MAPparams' saveMAPparamsName ...
39
        '(-1, 1/dt, 1);'];
40
    eval(cmd);
41
end
42

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

    
57
        nCNneurons=size(CNoutput,1);
58
        nHSRCNneuronss=nCNneurons/nANfiberTypes;
59
        disp(['CN: ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))...
60
            /(nHSRCNneuronss*duration))])
61
        disp(['IC: ' num2str(sum(sum(ICoutput))/duration)])
62
        %         disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')])
63
    else
64
        disp(['AN: ' num2str(mean(mean(ANprobRateOutput)))])
65
    end
66
end
67

    
68

    
69
%% figure (99) summarises main model output
70
if options.showModelOutput
71
    plotInstructions.figureNo=99;
72
    signalRMS=mean(savedInputSignal.^2)^0.5;
73
    signalRMSdb=20*log10(signalRMS/20e-6);
74

    
75
    % plot signal (1)
76
    plotInstructions.displaydt=dt;
77
    plotInstructions.numPlots=6;
78
    plotInstructions.subPlotNo=1;
79
    plotInstructions.title=...
80
        ['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL'];
81
    r=size(savedInputSignal,1);
82
    if r==1, savedInputSignal=savedInputSignal'; end
83
    UTIL_plotMatrix(savedInputSignal', plotInstructions);
84

    
85
    % stapes (2)
86
    plotInstructions.subPlotNo=2;
87
    plotInstructions.title= ['stapes displacement'];
88
    UTIL_plotMatrix(OMEoutput, plotInstructions);
89

    
90
    % DRNL (3)
91
    plotInstructions.subPlotNo=3;
92
    plotInstructions.title= ['BM displacement'];
93
    plotInstructions.yValues= savedBFlist;
94
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
95

    
96
    switch saveAN_spikesOrProbability
97
        case 'spikes'
98
            % AN (4)
99
            plotInstructions.displaydt=ANdt;
100
            plotInstructions.title='AN';
101
            plotInstructions.subPlotNo=4;
102
            plotInstructions.yLabel='BF';
103
            plotInstructions.yValues= savedBFlist;
104
            plotInstructions.rasterDotSize=1;
105
            plotInstructions.plotDivider=1;
106
            if sum(sum(ANoutput))<100
107
                plotInstructions.rasterDotSize=3;
108
            end
109
            UTIL_plotMatrix(ANoutput, plotInstructions);
110

    
111
            % CN (5)
112
            plotInstructions.displaydt=ANdt;
113
            plotInstructions.subPlotNo=5;
114
            plotInstructions.title='CN spikes';
115
            if sum(sum(CNoutput))<100
116
                plotInstructions.rasterDotSize=3;
117
            end
118
            UTIL_plotMatrix(CNoutput, plotInstructions);
119

    
120
            % IC (6)
121
            plotInstructions.displaydt=ANdt;
122
            plotInstructions.subPlotNo=6;
123
            plotInstructions.title='IC';
124
            if size(ICoutput,1)>3
125
                if sum(sum(ICoutput))<100
126
                    plotInstructions.rasterDotSize=3;
127
                end
128
                UTIL_plotMatrix(ICoutput, plotInstructions);
129
            else
130
                plotInstructions.title='IC (HSR) membrane potential';
131
                plotInstructions.displaydt=dt;
132
                plotInstructions.yLabel='V';
133
                plotInstructions.zValuesRange= [-.1 0];
134
                UTIL_plotMatrix(ICmembraneOutput, plotInstructions);
135
            end
136

    
137
        otherwise % probability (4-6)
138
            plotInstructions.displaydt=dt;
139
            plotInstructions.numPlots=2;
140
            plotInstructions.subPlotNo=2;
141
            plotInstructions.yLabel='BF';
142
            if nANfiberTypes>1,
143
                plotInstructions.yLabel='LSR    HSR';
144
                plotInstructions.plotDivider=1;
145
            end
146
            plotInstructions.title='AN - spike probability';
147
            UTIL_plotMatrix(ANprobRateOutput, plotInstructions);
148
    end
149
end
150

    
151
%% plot efferent control values as dB
152
if options.showEfferent
153
    plotInstructions=[];
154
    plotInstructions.figureNo=98;
155
    figure(98), clf
156
    plotInstructions.displaydt=dt;
157
    plotInstructions.numPlots=2;
158
    plotInstructions.subPlotNo=1;
159
    plotInstructions.zValuesRange=[ -25 0];
160
    plotInstructions.title= ['AR strength.  Signal level= ' ...
161
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
162
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
163

    
164
    plotInstructions.subPlotNo=2;
165
    plotInstructions.yValues= savedBFlist;
166
    plotInstructions.yLabel= 'BF';
167
    plotInstructions.title= ['MOC strength'];
168
    plotInstructions.zValuesRange=[ -25 0];
169
    subplot(2,1,2)
170
    % imagesc(MOCattenuation)
171
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
172
    colorbar
173
end
174

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

    
193

    
194
%% ACF plot if required
195
if options.showACF
196
    tic
197
    method.dt=dt;
198
    method.segmentNo=1;
199
    method.nonlinCF=savedBFlist;
200

    
201
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
202
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
203
    pitches=fliplr(pitches);
204
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
205
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
206
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
207
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
208

    
209
    filteredSACFParams.plotACFs=0;          % special plot (see code)
210
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
211
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
212

    
213
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
214
    filteredSACFParams.lagsProcedure=  'useAllLags';
215
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
216
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
217
    filteredSACFParams.criterionForOmittingLags=3;
218
    filteredSACFParams.plotACFsInterval=200;
219

    
220
    if filteredSACFParams.plotACFs
221
        % plot original waveform on ACF plot
222
        figure(13), clf
223
        subplot(4,1,1)
224
        t=dt*(1:length(savedInputSignal));
225
        plot(t,savedInputSignal)
226
        xlim([0 t(end)])
227
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
228
    end
229

    
230
    % plot original waveform on summary/smoothed ACF plot
231
    figure(96), clf
232
    subplot(2,1,1)
233
    t=dt*(1:length(savedInputSignal));
234
    plot(t,savedInputSignal)
235
    xlim([0 t(end)])
236
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
237

    
238

    
239
    % compute ACF
240
    switch saveAN_spikesOrProbability
241
        case 'probability'
242
            inputToACF=ANprobRateOutput.^0.5;
243
        otherwise
244
            inputToACF=ANoutput;
245
    end
246

    
247
    disp ('computing ACF...')
248
    [P, BFlist, sacf, boundaryValue] = ...
249
        filteredSACF(inputToACF, method, filteredSACFParams);
250
    disp(' ACF done.')
251

    
252
    % SACF
253
    subplot(2,1,2)
254
    imagesc(P)
255
    ylabel('periodicities (Hz)')
256
    xlabel('time (s)')
257
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
258
    pt=[1 get(gca,'ytick')]; % force top xtick to show
259
    set(gca,'ytick',pt)
260
    set(gca,'ytickLabel', round(pitches(pt)))
261
    tt=get(gca,'xtick');
262
    set(gca,'xtickLabel', round(100*t(tt))/100)
263
end
264

    
265
path(restorePath)