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 @ 0:f233164f4c86

History | View | Annotate | Download (8.1 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

    
9
dbstop if warning
10

    
11
global dt ANdt saveAN_spikesOrProbability savedBFlist saveMAPparamsName...
12
    savedInputSignal TMoutput OMEoutput ARattenuation ...
13
    DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV...
14
    IHCoutput ANprobRateOutput ANoutput savePavailable tauCas  ...
15
    CNoutput  ICoutput ICmembraneOutput ICfiberTypeRates MOCattenuation
16

    
17
restorePath=path;
18
addpath ( ['..' filesep 'utilities'], ['..' filesep 'parameterStore'])
19

    
20
if nargin<1
21
    options.showModelParameters=1;
22
    options.showModelOutput=1;
23
    options.printFiringRates=1;
24
    options.showACF=1;
25
    options.showEfferent=1;
26
end
27

    
28
if options.showModelParameters
29
    % Read parameters from MAPparams<***> file in 'parameterStore' folder
30
    %  and print out all parameters
31
    cmd=['MAPparams' saveMAPparamsName ...
32
        '(-1, 1/dt, 1);'];
33
    eval(cmd);
34
end
35

    
36
if options.printFiringRates
37
    %% print summary firing rates
38
    fprintf('\n\n')
39
    disp('summary')
40
    disp(['AR: ' num2str(min(ARattenuation))])
41
    disp(['MOC: ' num2str(min(min(MOCattenuation)))])
42
    nANfiberTypes=length(tauCas);
43
    if strcmp(saveAN_spikesOrProbability, 'spikes')
44
        nANfibers=size(ANoutput,1);
45
        nHSRfibers=nANfibers/nANfiberTypes;
46
        duration=size(TMoutput,2)*dt;
47
        disp(['AN: ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/...
48
            (nHSRfibers*duration))])
49
        
50
        nCNneurons=size(CNoutput,1);
51
        nHSRCNneuronss=nCNneurons/nANfiberTypes;
52
        disp(['CN: ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))...
53
            /(nHSRCNneuronss*duration))])
54
        disp(['IC: ' num2str(sum(sum(ICoutput)))])
55
        disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')])
56
    else
57
        disp(['AN: ' num2str(mean(mean(ANprobRateOutput)))])
58
    end
59
end
60

    
61

    
62
%% figure (99) summarises main model output
63
if options.showModelOutput
64
    plotInstructions.figureNo=99;
65
    signalRMS=mean(savedInputSignal.^2)^0.5;
66
    signalRMSdb=20*log10(signalRMS/20e-6);
67
    
68
    % plot signal (1)
69
    plotInstructions.displaydt=dt;
70
    plotInstructions.numPlots=6;
71
    plotInstructions.subPlotNo=1;
72
    plotInstructions.title=...
73
        ['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL'];
74
    r=size(savedInputSignal,1);
75
    if r==1, savedInputSignal=savedInputSignal'; end
76
    UTIL_plotMatrix(savedInputSignal', plotInstructions);
77
    
78
    % stapes (2)
79
    plotInstructions.subPlotNo=2;
80
    plotInstructions.title= ['stapes displacement'];
81
    UTIL_plotMatrix(OMEoutput, plotInstructions);
82
    
83
    % DRNL (3)
84
    plotInstructions.subPlotNo=3;
85
    plotInstructions.title= ['BM displacement'];
86
    plotInstructions.yValues= savedBFlist;
87
    UTIL_plotMatrix(DRNLoutput, plotInstructions);
88
    
89
    switch saveAN_spikesOrProbability
90
        case 'spikes'
91
            % AN (4)
92
            plotInstructions.displaydt=ANdt;
93
            plotInstructions.title='AN';
94
            plotInstructions.subPlotNo=4;
95
            plotInstructions.yLabel='BF';
96
            plotInstructions.yValues= savedBFlist;
97
            plotInstructions.rasterDotSize=1;
98
            plotInstructions.plotDivider=1;
99
            if sum(sum(ANoutput))<100
100
                plotInstructions.rasterDotSize=3;
101
            end
102
            UTIL_plotMatrix(ANoutput, plotInstructions);
103
            
104
            % CN (5)
105
            plotInstructions.displaydt=ANdt;
106
            plotInstructions.subPlotNo=5;
107
            plotInstructions.title='CN spikes';
108
            if sum(sum(CNoutput))<100
109
                plotInstructions.rasterDotSize=3;
110
            end
111
            UTIL_plotMatrix(CNoutput, plotInstructions);
112
            
113
            % IC (6)
114
            plotInstructions.displaydt=ANdt;
115
            plotInstructions.subPlotNo=6;
116
            plotInstructions.title='IC';
117
            if size(ICoutput,1)>3
118
                if sum(sum(ICoutput))<100
119
                    plotInstructions.rasterDotSize=3;
120
                end
121
                UTIL_plotMatrix(ICoutput, plotInstructions);
122
            else
123
                plotInstructions.title='IC (HSR) membrane potential';
124
                plotInstructions.displaydt=dt;
125
                plotInstructions.yLabel='V';
126
                plotInstructions.zValuesRange= [-.1 0];
127
                UTIL_plotMatrix(ICmembraneOutput, plotInstructions);
128
            end
129
            
130
        otherwise % probability (4-6)
131
            plotInstructions.displaydt=dt;
132
            plotInstructions.numPlots=2;
133
            plotInstructions.subPlotNo=2;
134
            plotInstructions.yLabel='BF';
135
            if nANfiberTypes>1,
136
                plotInstructions.yLabel='LSR    HSR';
137
                plotInstructions.plotDivider=1;
138
            end
139
            plotInstructions.title='AN - spike probability';
140
            UTIL_plotMatrix(ANprobRateOutput, plotInstructions);
141
    end
142
end
143

    
144
%% plot efferent control values as dB
145
if options.showEfferent
146
    plotInstructions=[];
147
    plotInstructions.figureNo=98;
148
    figure(98), clf
149
    plotInstructions.displaydt=dt;
150
    plotInstructions.numPlots=2;
151
    plotInstructions.subPlotNo=1;
152
    plotInstructions.zValuesRange=[ -25 0];
153
    plotInstructions.title= ['AR strength.  Signal level= ' ...
154
        num2str(signalRMSdb,'%4.0f') ' dB SPL'];
155
    UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions);
156
    
157
    plotInstructions.subPlotNo=2;
158
    plotInstructions.yValues= savedBFlist;
159
    plotInstructions.yLabel= 'BF';
160
    plotInstructions.title= ['MOC strength'];
161
    plotInstructions.zValuesRange=[ -25 0];
162
    subplot(2,1,2)
163
    % imagesc(MOCattenuation)
164
    UTIL_plotMatrix(20*log10(MOCattenuation), plotInstructions);
165
    colorbar
166
end
167

    
168

    
169
%% ACF plot if required
170
if options.showACF
171
    tic
172
    method.dt=dt;
173
    method.segmentNo=1;
174
    method.nonlinCF=savedBFlist;
175
    
176
    minPitch=	80; maxPitch=	4000; numPitches=100;    % specify lags
177
    pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches);
178
    pitches=fliplr(pitches);
179
    filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
180
    filteredSACFParams.acfTau=	.003;       % time constant of running ACF
181
    filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
182
    filteredSACFParams.lambda=	0.01;       % slower filter to smooth ACF
183
    
184
    filteredSACFParams.plotACFs=0;          % special plot (see code)
185
    filteredSACFParams.plotFilteredSACF=0;  % 0 plots unfiltered ACFs
186
    filteredSACFParams.plotMoviePauses=.3;          % special plot (see code)
187
    
188
    filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
189
    filteredSACFParams.lagsProcedure=  'useAllLags';
190
    % filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
191
    % filteredSACFParams.lagsProcedure=  'omitShortLags';
192
    filteredSACFParams.criterionForOmittingLags=3;
193
    filteredSACFParams.plotACFsInterval=200;
194
    
195
    if filteredSACFParams.plotACFs
196
        % plot original waveform on ACF plot
197
        figure(13), clf
198
        subplot(4,1,1)
199
        t=dt*(1:length(savedInputSignal));
200
        plot(t,savedInputSignal)
201
        xlim([0 t(end)])
202
        title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
203
    end
204
    
205
    % plot original waveform on summary/smoothed ACF plot
206
    figure(97), clf
207
    subplot(2,1,1)
208
    t=dt*(1:length(savedInputSignal));
209
    plot(t,savedInputSignal)
210
    xlim([0 t(end)])
211
    title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']);
212
    
213
    
214
    % compute ACF
215
    switch saveAN_spikesOrProbability
216
        case 'probability'
217
            inputToACF=ANprobRateOutput.^0.5;
218
        otherwise
219
            inputToACF=ANoutput;
220
    end
221
    
222
    disp ('computing ACF...')
223
    [P, BFlist, sacf, boundaryValue] = ...
224
        filteredSACF(inputToACF, method, filteredSACFParams);
225
    disp(' ACF done.')
226
    
227
    % SACF
228
    subplot(2,1,2)
229
    imagesc(P)
230
    ylabel('periodicities (Hz)')
231
    xlabel('time (s)')
232
    title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input'])
233
    pt=[1 get(gca,'ytick')]; % force top xtick to show
234
    set(gca,'ytick',pt)
235
    set(gca,'ytickLabel', round(pitches(pt)))
236
    tt=get(gca,'xtick');
237
    set(gca,'xtickLabel', round(100*t(tt))/100)
238
end
239

    
240
path(restorePath)