Mercurial > hg > map
comparison utilities/UTIL_showMAP.m @ 38:c2204b18f4a2 tip
End nov big change
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Mon, 28 Nov 2011 13:34:28 +0000 |
parents | 25d53244d5c8 |
children |
comparison
equal
deleted
inserted
replaced
37:771a643d5c29 | 38:c2204b18f4a2 |
---|---|
1 function UTIL_showMAP (showMapOptions, paramChanges) | 1 function UTIL_showMAP (showMapOptions) |
2 % UTIL_showMAP produces summaries of the output from MAP's mmost recent run | 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 | 3 % All MAP_14 outputs are stored in global variables and UTIL_showMAP |
4 % simply assumes that they are in place. | 4 % simply assumes that they are in place. It uses whatever it there. |
5 % | 5 % |
6 % showMapOptions | 6 % showMapOptions: |
7 % showMapOptions.printModelParameters=1; % print model parameters | 7 % showMapOptions.printModelParameters=1; % print model parameters |
8 % showMapOptions.showModelOutput=1; % plot all stages output | 8 % showMapOptions.showModelOutput=1; % plot all stages output |
9 % showMapOptions.printFiringRates=1; % mean activity at all stages | 9 % showMapOptions.printFiringRates=1; % mean activity at all stages |
10 % showMapOptions.showACF=1; % SACF (probabilities only) | 10 % showMapOptions.showACF=1; % SACF (probabilities only) |
11 % showMapOptions.showEfferent=1; % plot of efferent activity | 11 % showMapOptions.showEfferent=1; % plot of efferent activity |
12 % showMapOptions.surfProbability=0; % HSR (probability) surf plot | 12 % showMapOptions.surfAN=0; % AN output surf plot |
13 % showMapOptions.fileName=[]; % parameter filename for plot title | 13 % showMapOptions.fileName=''; % parameter filename for plot title |
14 | 14 % showMapOptions.PSTHbinwidth=0.001 % binwidth for surface plots |
15 % showMapOptions.colorbar=1; % request color bar if appropriate | |
16 % showMapOptions.view=[0 90]; | |
15 % dbstop if warning | 17 % dbstop if warning |
16 | 18 |
17 global dt ANdt savedBFlist saveAN_spikesOrProbability saveMAPparamsName... | 19 % Discover results left behind by MAP1_14 |
18 savedInputSignal OMEextEarPressure TMoutput OMEoutput ARattenuation ... | 20 global savedParamChanges savedBFlist saveAN_spikesOrProbability ... |
19 DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV... | 21 saveMAPparamsName savedInputSignal dt dtSpikes ... |
20 IHCoutput ANprobRateOutput ANoutput savePavailable ANtauCas ... | 22 OMEextEarPressure TMoutput OMEoutput DRNLoutput... |
21 CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates ... | 23 IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
22 MOCattenuation | 24 IHCoutput ANprobRateOutput ANoutput savePavailable saveNavailable ... |
23 global OMEParams DRNLParams IHC_cilia_RPParams IHCpreSynapseParams | 25 ANtauCas CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates... |
24 global AN_IHCsynapseParams MacGregorParams MacGregorMultiParams | 26 MOCattenuation ARattenuation |
27 | |
28 % Find parameters created in MAPparams<name> | |
29 global inputStimulusParams OMEParams DRNLParams IHC_cilia_RPParams | |
30 global IHCpreSynapseParams AN_IHCsynapseParams | |
31 global MacGregorParams MacGregorMultiParams filteredSACFParams | |
25 global ICrate | 32 global ICrate |
26 | 33 |
27 | 34 |
28 restorePath=path; | 35 restorePath=path; |
29 addpath ( ['..' filesep 'utilities'], ['..' filesep 'parameterStore']) | 36 addpath ( ['..' filesep 'utilities'], ['..' filesep 'parameterStore']) |
30 | 37 |
31 if nargin<1 | 38 if nargin<1, showMapOptions=[]; end |
32 showMapOptions=[]; | 39 paramChanges=savedParamChanges; |
33 end | 40 |
34 % defaults (plot staged outputs and print rates only) if options omitted | 41 % defaults (plot staged outputs and print rates only) if options omitted |
35 if ~isfield(showMapOptions,'printModelParameters') | 42 if ~isfield(showMapOptions,'printModelParameters') |
36 showMapOptions.printModelParameters=0; end | 43 showMapOptions.printModelParameters=0; end |
37 if ~isfield(showMapOptions,'showModelOutput'),showMapOptions.showModelOutput=1;end | 44 if ~isfield(showMapOptions,'showModelOutput'),showMapOptions.showModelOutput=0;end |
38 if ~isfield(showMapOptions,'printFiringRates'),showMapOptions.printFiringRates=1;end | 45 if ~isfield(showMapOptions,'printFiringRates'),showMapOptions.printFiringRates=0;end |
46 if ~isfield(showMapOptions,'surfAN'),showMapOptions.surfAN=0;end | |
47 if ~isfield(showMapOptions,'ICrates'),showMapOptions.ICrates=0;end | |
39 if ~isfield(showMapOptions,'showACF'),showMapOptions.showACF=0;end | 48 if ~isfield(showMapOptions,'showACF'),showMapOptions.showACF=0;end |
40 if ~isfield(showMapOptions,'showEfferent'),showMapOptions.showEfferent=0;end | 49 if ~isfield(showMapOptions,'showEfferent'),showMapOptions.showEfferent=0;end |
41 if ~isfield(showMapOptions,'surfProbability'),showMapOptions.surfProbability=0;end | 50 if ~isfield(showMapOptions,'PSTHbinwidth'),showMapOptions.PSTHbinwidth=0.001;end |
42 if ~isfield(showMapOptions,'fileName'),showMapOptions.fileName=[];end | 51 if ~isfield(showMapOptions,'fileName'),showMapOptions.fileName=[];end |
43 if ~isfield(showMapOptions,'surfSpikes'),showMapOptions.surfSpikes=0;end | 52 if ~isfield(showMapOptions,'colorbar'),showMapOptions.colorbar=1;end |
44 if ~isfield(showMapOptions,'ICrates'),showMapOptions.ICrates=0;end | 53 if ~isfield(showMapOptions,'view'),showMapOptions.view=[-25 80];end |
54 if ~isfield(showMapOptions,'ICrasterPlot'),showMapOptions.ICrasterPlot=0;end | |
45 | 55 |
46 %% send all model parameters to command window | 56 %% send all model parameters to command window |
47 if showMapOptions.printModelParameters | 57 if showMapOptions.printModelParameters |
48 % Read parameters from MAPparams<***> file in 'parameterStore' folder | 58 % Read parameters from MAPparams<***> file in 'parameterStore' folder |
49 % and print out all parameters | 59 % and print out all parameters |
50 if nargin>1 | |
51 cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1, paramChanges);']; | 60 cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1, paramChanges);']; |
52 eval(cmd); | 61 eval(cmd); |
53 else | 62 end |
54 cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1);']; | 63 |
55 eval(cmd); | 64 % ignore zero elements in signal |
56 disp(' no parameter changes found') | 65 signalRMS=mean(savedInputSignal(find(savedInputSignal)).^2)^0.5; |
57 end | 66 signalRMSdb=20*log10(signalRMS/20e-6); |
58 end | 67 nANfiberTypes=length(ANtauCas); |
59 | 68 |
60 %% summarise firing rates in command window | 69 %% summarise firing rates in command window |
61 if showMapOptions.printFiringRates | 70 if showMapOptions.printFiringRates |
62 %% print summary firing rates | 71 %% print summary firing rates |
63 fprintf('\n') | 72 fprintf('\n') |
64 disp('summary') | 73 disp('summary') |
65 disp(['AR: ' num2str(min(ARattenuation))]) | 74 disp(['AR: ' num2str(min(ARattenuation))]) |
66 disp(['MOC: ' num2str(min(min(MOCattenuation)))]) | 75 disp(['MOC: ' num2str(min(min(MOCattenuation)))]) |
67 nANfiberTypes=length(ANtauCas); | |
68 if strcmp(saveAN_spikesOrProbability, 'spikes') | 76 if strcmp(saveAN_spikesOrProbability, 'spikes') |
69 nANfibers=size(ANoutput,1); | 77 nANfibers=size(ANoutput,1); |
70 nHSRfibers=nANfibers/nANfiberTypes; | 78 nHSRfibers=nANfibers/nANfiberTypes; |
71 duration=size(TMoutput,2)*dt; | 79 duration=size(TMoutput,2)*dt; |
72 disp(['AN(HSR): ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/... | 80 disp(['AN(HSR): ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/... |
91 | 99 |
92 | 100 |
93 %% figure (99): display output from all model stages | 101 %% figure (99): display output from all model stages |
94 if showMapOptions.showModelOutput | 102 if showMapOptions.showModelOutput |
95 plotInstructions.figureNo=99; | 103 plotInstructions.figureNo=99; |
96 | |
97 % ignore zero elements in signal | |
98 signalRMS=mean(savedInputSignal(find(savedInputSignal)).^2)^0.5; | |
99 signalRMSdb=20*log10(signalRMS/20e-6); | |
100 | 104 |
101 % plot signal (1) | 105 % plot signal (1) |
102 plotInstructions.displaydt=dt; | 106 plotInstructions.displaydt=dt; |
103 plotInstructions.numPlots=6; | 107 plotInstructions.numPlots=6; |
104 plotInstructions.subPlotNo=1; | 108 plotInstructions.subPlotNo=1; |
105 plotInstructions.title=... | 109 plotInstructions.title=... |
106 ['stimulus (Pa). ' num2str(signalRMSdb, '%4.0f') ' dB SPL']; | 110 ['stimulus (Pa). ' num2str(signalRMSdb, '%4.0f') ' dB SPL']; |
107 r=size(savedInputSignal,1); | 111 UTIL_plotMatrix(savedInputSignal, plotInstructions); |
108 if r==1, savedInputSignal=savedInputSignal'; end | |
109 UTIL_plotMatrix(savedInputSignal', plotInstructions); | |
110 | 112 |
111 % stapes (2) | 113 % stapes (2) |
112 plotInstructions.subPlotNo=2; | 114 plotInstructions.subPlotNo=2; |
113 plotInstructions.title= ['stapes displacement (m)']; | 115 plotInstructions.title= ['stapes displacement (m)']; |
114 UTIL_plotMatrix(OMEoutput, plotInstructions); | 116 UTIL_plotMatrix(OMEoutput, plotInstructions); |
117 plotInstructions.subPlotNo=3; | 119 plotInstructions.subPlotNo=3; |
118 plotInstructions.yValues= savedBFlist; | 120 plotInstructions.yValues= savedBFlist; |
119 [r c]=size(DRNLoutput); | 121 [r c]=size(DRNLoutput); |
120 if r>1 | 122 if r>1 |
121 plotInstructions.title= ['BM displacement']; | 123 plotInstructions.title= ['BM displacement']; |
122 UTIL_plotMatrix(abs(DRNLoutput), plotInstructions); | 124 UTIL_plotMatrix(abs(DRNLoutput), plotInstructions); |
123 else | 125 else |
124 plotInstructions.title= ['BM displacement. BF=' ... | 126 plotInstructions.title= ['BM displacement. BF=' ... |
125 num2str(savedBFlist) ' Hz']; | 127 num2str(savedBFlist) ' Hz']; |
126 UTIL_plotMatrix(DRNLoutput, plotInstructions); | 128 UTIL_plotMatrix(DRNLoutput, plotInstructions); |
127 end | 129 end |
128 | 130 |
129 switch saveAN_spikesOrProbability | 131 switch saveAN_spikesOrProbability |
130 case 'spikes' | 132 case 'spikes' |
131 % AN (4) | 133 % AN (4) |
132 plotInstructions.displaydt=ANdt; | 134 plotInstructions.displaydt=dtSpikes; |
133 plotInstructions.title='AN'; | 135 plotInstructions.title='AN'; |
134 plotInstructions.subPlotNo=4; | 136 plotInstructions.subPlotNo=4; |
135 plotInstructions.yLabel='BF'; | 137 plotInstructions.yLabel='BF'; |
136 plotInstructions.yValues= savedBFlist; | 138 plotInstructions.yValues= savedBFlist; |
137 plotInstructions.rasterDotSize=1; | 139 plotInstructions.rasterDotSize=1; |
144 plotInstructions.rasterDotSize=3; | 146 plotInstructions.rasterDotSize=3; |
145 end | 147 end |
146 UTIL_plotMatrix(ANoutput, plotInstructions); | 148 UTIL_plotMatrix(ANoutput, plotInstructions); |
147 | 149 |
148 % CN (5) | 150 % CN (5) |
149 plotInstructions.displaydt=ANdt; | 151 plotInstructions.displaydt=dtSpikes; |
150 plotInstructions.subPlotNo=5; | 152 plotInstructions.subPlotNo=5; |
151 plotInstructions.title='CN spikes'; | 153 plotInstructions.title='CN spikes'; |
152 if sum(sum(CNoutput))<100 | 154 if sum(sum(CNoutput))<100 |
153 plotInstructions.rasterDotSize=3; | 155 plotInstructions.rasterDotSize=3; |
154 end | 156 end |
155 UTIL_plotMatrix(CNoutput, plotInstructions); | 157 UTIL_plotMatrix(CNoutput, plotInstructions); |
156 | 158 |
157 % IC (6) | 159 % IC (6) |
158 plotInstructions.displaydt=ANdt; | 160 plotInstructions.displaydt=dtSpikes; |
159 plotInstructions.subPlotNo=6; | 161 plotInstructions.subPlotNo=6; |
160 plotInstructions.title='Brainstem 2nd level'; | 162 plotInstructions.title='Brainstem 2nd level'; |
161 if size(ICoutput,1)>1 | 163 if size(ICoutput,1)>1 |
162 if sum(sum(ICoutput))<100 | 164 if sum(sum(ICoutput))<100 |
163 plotInstructions.rasterDotSize=3; | 165 plotInstructions.rasterDotSize=3; |
170 plotInstructions.zValuesRange= [-.1 0]; | 172 plotInstructions.zValuesRange= [-.1 0]; |
171 UTIL_plotMatrix(ICmembraneOutput, plotInstructions); | 173 UTIL_plotMatrix(ICmembraneOutput, plotInstructions); |
172 end | 174 end |
173 | 175 |
174 otherwise % AN rate based on probability of firing | 176 otherwise % AN rate based on probability of firing |
175 PSTHbinWidth=0.001; | 177 PSTHbinWidth=0.0005; |
176 PSTH= UTIL_PSTHmakerb(ANprobRateOutput, dt, PSTHbinWidth); | 178 PSTH= UTIL_PSTHmakerb(ANprobRateOutput, dt, PSTHbinWidth); |
177 % PSTH = makeANsmooth(PSTH, 1/PSTHbinWidth); | 179 plotInstructions=[]; |
178 plotInstructions.displaydt=PSTHbinWidth; | 180 plotInstructions.displaydt=PSTHbinWidth; |
181 plotInstructions.plotDivider=0; | |
179 plotInstructions.numPlots=2; | 182 plotInstructions.numPlots=2; |
180 plotInstructions.subPlotNo=2; | 183 plotInstructions.subPlotNo=2; |
181 plotInstructions.yLabel='BF'; | 184 plotInstructions.yLabel='BF'; |
182 plotInstructions.xLabel='time'; | 185 plotInstructions.yValues=savedBFlist; |
186 plotInstructions.xLabel='time (s)'; | |
183 plotInstructions.zValuesRange= [0 300]; | 187 plotInstructions.zValuesRange= [0 300]; |
188 | |
184 if nANfiberTypes>1, | 189 if nANfiberTypes>1, |
185 plotInstructions.yLabel='LSR HSR'; | 190 plotInstructions.yLabel='LSR HSR'; |
186 plotInstructions.plotDivider=1; | 191 plotInstructions.plotDivider=1; |
187 end | 192 end |
188 plotInstructions.title='AN - spike rate'; | 193 plotInstructions.title='AN - spike rate'; |
189 UTIL_plotMatrix(PSTH, plotInstructions); | 194 UTIL_plotMatrix(PSTH, plotInstructions); |
190 shading interp | 195 shading interp |
191 colorbar('southOutside') | 196 if showMapOptions.colorbar, colorbar('southOutside'), end |
192 end | 197 end |
193 set(gcf,'name','MAP output') | 198 set(gcf,'name','MAP output') |
194 end | 199 end |
195 | 200 |
196 if showMapOptions.surfProbability &&... | 201 |
202 %% surface plot of AN response | |
203 % probability | |
204 if showMapOptions.surfAN &&... | |
197 strcmp(saveAN_spikesOrProbability,'probability') && ... | 205 strcmp(saveAN_spikesOrProbability,'probability') && ... |
198 length(savedBFlist)>2 | 206 length(savedBFlist)>2 |
199 %% surface plot of probability | 207 % select only HSR fibers |
200 % select only HSR fibers | |
201 figure(97), clf | |
202 HSRprobOutput= ANprobRateOutput(end-length(savedBFlist)+1:end,:); | |
203 PSTHbinWidth=0.001; | |
204 PSTH=UTIL_PSTHmakerb(HSRprobOutput, ANdt, PSTHbinWidth); | |
205 [nY nX]=size(PSTH); | |
206 time=PSTHbinWidth*(1:nX); | |
207 surf(time, savedBFlist, PSTH) | |
208 shading interp | |
209 set(gca, 'yScale','log') | |
210 xlim([0 max(time)]) | |
211 ylim([0 max(savedBFlist)]) | |
212 zlim([0 1000]) | |
213 xlabel('time (s)') | |
214 ylabel('best frequency (Hz)') | |
215 zlabel('spike rate') | |
216 view([-20 60]) | |
217 % view([0 90]) | |
218 disp(['max max AN: ' num2str(max(max(PSTH)))]) | |
219 | |
220 title (['firing probability of HSR fibers only. Level= ' ... | |
221 num2str(signalRMSdb,'% 3.0f') ' dB']) | |
222 colorbar('southOutside') | |
223 end | |
224 | |
225 %% surface plot of AN spikes | |
226 if showMapOptions.surfSpikes ... | |
227 && strcmp(saveAN_spikesOrProbability, 'spikes') | |
228 figure(97), clf | 208 figure(97), clf |
209 PSTHbinWidth=showMapOptions.PSTHbinwidth; | |
210 PSTH= UTIL_PSTHmakerb(... | |
211 ANprobRateOutput(end-length(savedBFlist)+1:end,:), ... | |
212 dt, PSTHbinWidth); | |
213 [nY nX]=size(PSTH); | |
214 time=PSTHbinWidth*(1:nX); | |
215 surf(time, savedBFlist, PSTH) | |
216 caxis([0 500]) | |
217 shading interp | |
218 set(gca, 'yScale','log') | |
219 xlim([0 max(time)]) | |
220 ylim([0 max(savedBFlist)]) | |
221 zlim([0 500]) | |
222 myFontSize=10; | |
223 xlabel('time (s)', 'fontsize',myFontSize) | |
224 ylabel('BF (Hz)', 'fontsize',myFontSize) | |
225 zlabel('spike rate') | |
226 view(showMapOptions.view) | |
227 set(gca,'ytick',[500 1000 2000 8000],'fontSize',myFontSize) | |
228 title (['AN response. Level= ' ... | |
229 num2str(signalRMSdb,'% 3.0f') ' dB'... | |
230 ' binwidth= ' num2str(1000*PSTHbinWidth) ' s']) | |
231 if showMapOptions.colorbar, colorbar('southOutside'), end | |
232 end | |
233 | |
234 %% surfAN ('spikes') | |
235 if showMapOptions.surfAN ... | |
236 && strcmp(saveAN_spikesOrProbability, 'spikes')... | |
237 && length(savedBFlist)>2 | |
238 figure(97), clf | |
239 % combine fibers across channels | |
240 nFibersPerChannel=AN_IHCsynapseParams.numFibers; | |
241 [r nEpochs]=size(ANoutput); | |
242 nChannels=round(r/nFibersPerChannel); | |
243 x=reshape(ANoutput,nChannels,nFibersPerChannel,nEpochs); | |
244 x=squeeze(sum(x,2)); | |
229 % select only HSR fibers at the bottom of the matrix | 245 % select only HSR fibers at the bottom of the matrix |
230 ANoutput= ANoutput(end-length(savedBFlist)+1:end,:); | 246 HSRoutput= x(end-length(savedBFlist)+1:end,:); |
231 PSTHbinWidth=0.005; % 1 ms bins | 247 PSTH=HSRoutput; |
232 PSTH=UTIL_makePSTH(ANoutput, ANdt, PSTHbinWidth); | 248 PSTHbinWidth=showMapOptions.PSTHbinwidth; |
249 PSTH=UTIL_makePSTH(HSRoutput, dtSpikes, PSTHbinWidth); | |
233 [nY nX]=size(PSTH); | 250 [nY nX]=size(PSTH); |
234 time=PSTHbinWidth*(1:nX); | 251 time=PSTHbinWidth*(1:nX); |
235 surf(time, savedBFlist, PSTH) | 252 surf(time, savedBFlist, PSTH) |
236 shading interp | 253 shading interp |
237 set(gca, 'yScale','log') | 254 set(gca, 'yScale','log') |
239 ylim([0 max(savedBFlist)]) | 256 ylim([0 max(savedBFlist)]) |
240 % zlim([0 1000]) | 257 % zlim([0 1000]) |
241 xlabel('time (s)') | 258 xlabel('time (s)') |
242 ylabel('best frequency (Hz)') | 259 ylabel('best frequency (Hz)') |
243 zlabel('spike rate') | 260 zlabel('spike rate') |
244 view([-20 60]) | 261 view(showMapOptions.view) |
245 % view([0 90]) | |
246 title ([showMapOptions.fileName ': ' num2str(signalRMSdb,'% 3.0f') ' dB']) | 262 title ([showMapOptions.fileName ': ' num2str(signalRMSdb,'% 3.0f') ' dB']) |
247 set(97,'name', 'spikes surface plot') | 263 set(97,'name', 'spikes surface plot') |
248 end | 264 end |
249 | 265 |
266 %% IC raster plot | |
267 if showMapOptions.ICrasterPlot &&... | |
268 strcmp(saveAN_spikesOrProbability,'spikes') && ... | |
269 length(savedBFlist)>2 | |
270 figure(91), clf | |
271 plotInstructions=[]; | |
272 plotInstructions.numPlots=2; | |
273 plotInstructions.subPlotNo=2; | |
274 plotInstructions.title=... | |
275 ['IC raster plot']; | |
276 plotInstructions.figureNo=91; | |
277 plotInstructions.displaydt=dtSpikes; | |
278 plotInstructions.title='Brainstem 2nd level'; | |
279 plotInstructions.yLabel='BF'; | |
280 plotInstructions.yValues= savedBFlist; | |
281 | |
282 if size(ICoutput,1)>1 | |
283 if sum(sum(ICoutput))<100 | |
284 plotInstructions.rasterDotSize=3; | |
285 end | |
286 UTIL_plotMatrix(ICoutput, plotInstructions); | |
287 end | |
288 | |
289 % plot signal (1) | |
290 plotInstructions.displaydt=dt; | |
291 plotInstructions.subPlotNo=1; | |
292 plotInstructions.title=... | |
293 ['stimulus (Pa). ' num2str(signalRMSdb, '%4.0f') ' dB SPL']; | |
294 UTIL_plotMatrix(savedInputSignal, plotInstructions); | |
295 | |
296 end | |
250 | 297 |
251 %% figure(98) plot efferent control values as dB | 298 %% figure(98) plot efferent control values as dB |
252 if showMapOptions.showEfferent | 299 if showMapOptions.showEfferent |
253 plotInstructions=[]; | 300 plotInstructions=[]; |
254 plotInstructions.figureNo=98; | 301 plotInstructions.figureNo=98; |
257 plotInstructions.numPlots=4; | 304 plotInstructions.numPlots=4; |
258 plotInstructions.subPlotNo=1; | 305 plotInstructions.subPlotNo=1; |
259 plotInstructions.zValuesRange= [-1 1]; | 306 plotInstructions.zValuesRange= [-1 1]; |
260 plotInstructions.title= ['RMS level='... | 307 plotInstructions.title= ['RMS level='... |
261 num2str(signalRMSdb, '%4.0f') ' dB SPL']; | 308 num2str(signalRMSdb, '%4.0f') ' dB SPL']; |
262 UTIL_plotMatrix(savedInputSignal', plotInstructions); | 309 UTIL_plotMatrix(savedInputSignal, plotInstructions); |
263 | 310 |
264 | 311 |
265 plotInstructions.subPlotNo=2; | 312 plotInstructions.subPlotNo=2; |
266 plotInstructions.zValuesRange=[ -25 0]; | 313 plotInstructions.zValuesRange=[ -25 0]; |
267 plotInstructions.title= ['AR stapes attenuation (dB); tau='... | 314 plotInstructions.title= ['AR stapes attenuation (dB); tau='... |
268 num2str(OMEParams.ARtau, '%4.3f') ' s']; | 315 num2str(OMEParams.ARtau, '%4.3f') ' s']; |
269 UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions); | 316 UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions); |
273 plotInstructions.subPlotNo=2; | 320 plotInstructions.subPlotNo=2; |
274 plotInstructions.yValues= savedBFlist; | 321 plotInstructions.yValues= savedBFlist; |
275 plotInstructions.yLabel= 'dB'; | 322 plotInstructions.yLabel= 'dB'; |
276 if strcmp(saveAN_spikesOrProbability,'spikes') | 323 if strcmp(saveAN_spikesOrProbability,'spikes') |
277 rate2atten=DRNLParams.rateToAttenuationFactor; | 324 rate2atten=DRNLParams.rateToAttenuationFactor; |
278 plotInstructions.title= ['MOC atten; tau=' ... | 325 plotInstructions.title= ['MOC atten; tau=' ... |
279 num2str(DRNLParams.MOCtau) '; factor='... | 326 num2str(DRNLParams.MOCtau) '; factor='... |
280 num2str(rate2atten, '%6.4f')]; | 327 num2str(rate2atten, '%6.4f')]; |
281 else | 328 else |
282 rate2atten=DRNLParams.rateToAttenuationFactorProb; | 329 rate2atten=DRNLParams.rateToAttenuationFactorProb; |
283 plotInstructions.title= ['MOC atten; tauProb=' ... | 330 plotInstructions.title= ['MOC atten; tauProb=' ... |
284 num2str(DRNLParams.MOCtauProb) '; factor='... | 331 num2str(DRNLParams.MOCtauProb) '; factor='... |
285 num2str(rate2atten, '%6.4f')]; | 332 num2str(rate2atten, '%6.4f')]; |
286 end | 333 end |
287 plotInstructions.zValuesRange=[0 -DRNLParams.minMOCattenuationdB+5]; | 334 plotInstructions.zValuesRange=[0 -DRNLParams.minMOCattenuationdB+5]; |
288 UTIL_plotMatrix(-20*log10(MOCattenuation), plotInstructions); | 335 UTIL_plotMatrix(-20*log10(MOCattenuation), plotInstructions); |
289 hold on | 336 hold on |
290 [r c]=size(MOCattenuation); | 337 [r c]=size(MOCattenuation); |
291 if r>2 | 338 if r>2 && showMapOptions.colorbar |
292 colorbar('southOutside') | 339 colorbar('southOutside') |
293 end | 340 end |
294 set(plotInstructions.figureNo, 'name', 'AR/ MOC') | 341 set(plotInstructions.figureNo, 'name', 'AR/ MOC') |
295 | 342 |
296 binwidth=0.1; | 343 binwidth=0.1; |
297 [PSTH ]=UTIL_PSTHmaker(20*log10(MOCattenuation), dt, binwidth); | 344 [PSTH ]=UTIL_PSTHmaker(20*log10(MOCattenuation), dt, binwidth); |
298 PSTH=PSTH*length(PSTH)/length(MOCattenuation); | 345 PSTH=PSTH*length(PSTH)/length(MOCattenuation); |
299 t=binwidth:binwidth:binwidth*length(PSTH); | 346 t=binwidth:binwidth:binwidth*length(PSTH); |
300 fprintf('\n\n') | 347 fprintf('\n\n') |
301 % UTIL_printTabTable([t' PSTH']) | 348 % UTIL_printTabTable([t' PSTH']) |
302 % fprintf('\n\n') | 349 % fprintf('\n\n') |
303 | 350 |
304 end | 351 end |
305 | 352 |
306 %% ACF plot if required | 353 %% ACF plot |
307 if showMapOptions.showACF | 354 if showMapOptions.showACF |
308 tic | 355 tic |
309 method.dt=dt; | |
310 method.segmentNo=1; | |
311 method.nonlinCF=savedBFlist; | |
312 | |
313 minPitch= 80; maxPitch= 4000; numPitches=100; % specify lags | |
314 pitches=10.^ linspace(log10(minPitch), log10(maxPitch),numPitches); | |
315 pitches=fliplr(pitches); | |
316 filteredSACFParams.lags=1./pitches; % autocorrelation lags vector | |
317 filteredSACFParams.acfTau= .003; % time constant of running ACF | |
318 filteredSACFParams.lambda= 0.12; % slower filter to smooth ACF | |
319 filteredSACFParams.lambda= 0.01; % slower filter to smooth ACF | |
320 | |
321 filteredSACFParams.plotACFs=0; % special plot (see code) | |
322 filteredSACFParams.plotFilteredSACF=0; % 0 plots unfiltered ACFs | |
323 filteredSACFParams.plotMoviePauses=.3; % special plot (see code) | |
324 | |
325 filteredSACFParams.usePressnitzer=0; % attenuates ACF at long lags | |
326 filteredSACFParams.lagsProcedure= 'useAllLags'; | |
327 % filteredSACFParams.lagsProcedure= 'useBernsteinLagWeights'; | |
328 % filteredSACFParams.lagsProcedure= 'omitShortLags'; | |
329 filteredSACFParams.criterionForOmittingLags=3; | |
330 filteredSACFParams.plotACFsInterval=200; | |
331 | |
332 if filteredSACFParams.plotACFs | 356 if filteredSACFParams.plotACFs |
333 % plot original waveform on ACF plot | 357 % plot original waveform on ACF plot |
334 figure(13), clf | 358 figure(13), clf |
335 subplot(4,1,1) | 359 subplot(4,1,1) |
336 t=dt*(1:length(savedInputSignal)); | 360 t=dt*(1:length(savedInputSignal)); |
337 plot(t,savedInputSignal) | 361 plot(t,savedInputSignal) |
338 xlim([0 t(end)]) | 362 xlim([0 t(end)]) |
339 title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); | 363 title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); |
340 end | 364 end |
341 | 365 |
366 % compute ACF | |
367 switch saveAN_spikesOrProbability | |
368 case 'probability' | |
369 inputToACF=ANprobRateOutput(end-length(savedBFlist)+1:end,:); | |
370 otherwise | |
371 inputToACF=ANoutput; | |
372 end | |
373 | |
374 disp ('computing ACF...') | |
375 [P, BFlist, sacf, boundaryValue] = ... | |
376 filteredSACF(inputToACF, dt, savedBFlist, filteredSACFParams); | |
377 disp(' ACF done.') | |
378 | |
342 % plot original waveform on summary/smoothed ACF plot | 379 % plot original waveform on summary/smoothed ACF plot |
343 figure(96), clf | 380 figure(96), clf |
344 subplot(2,1,1) | 381 subplot(2,1,1) |
345 t=dt*(1:length(savedInputSignal)); | 382 t=dt*(1:length(savedInputSignal)); |
346 plot(t,savedInputSignal) | 383 plot(t,savedInputSignal) |
347 xlim([0 t(end)]) | 384 xlim([0 t(end)]) |
348 title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); | 385 title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); |
349 | 386 |
350 | 387 % plot SACF |
351 % compute ACF | 388 figure(96) |
352 switch saveAN_spikesOrProbability | |
353 case 'probability' | |
354 inputToACF=ANprobRateOutput.^0.5; | |
355 otherwise | |
356 inputToACF=ANoutput; | |
357 end | |
358 | |
359 disp ('computing ACF...') | |
360 [P, BFlist, sacf, boundaryValue] = ... | |
361 filteredSACF(inputToACF, method, filteredSACFParams); | |
362 disp(' ACF done.') | |
363 | |
364 % SACF | |
365 subplot(2,1,2) | 389 subplot(2,1,2) |
366 imagesc(P) | 390 imagesc(P) |
391 % surf(filteredSACFParams.lags, t, P) | |
367 ylabel('periodicities (Hz)') | 392 ylabel('periodicities (Hz)') |
368 xlabel('time (s)') | 393 xlabel('time (s)') |
369 title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input']) | 394 title(['running smoothed SACF. ' saveAN_spikesOrProbability ' input']) |
370 pt=[1 get(gca,'ytick')]; % force top xtick to show | 395 pt=[1 get(gca,'ytick')]; % force top ytick to show |
371 set(gca,'ytick',pt) | 396 set(gca,'ytick',pt) |
397 pitches=1./filteredSACFParams.lags; % autocorrelation lags vector | |
372 set(gca,'ytickLabel', round(pitches(pt))) | 398 set(gca,'ytickLabel', round(pitches(pt))) |
399 [nCH nTimes]=size(P); | |
400 t=dt:dt:dt*nTimes; | |
373 tt=get(gca,'xtick'); | 401 tt=get(gca,'xtick'); |
374 set(gca,'xtickLabel', round(100*t(tt))/100) | 402 set(gca,'xtickLabel', round(100*t(tt))/100) |
375 end | 403 end |
376 | 404 |
377 path(restorePath) | 405 path(restorePath) |
393 % figure(95), plot(CNtauGk,ICrate) | 421 % figure(95), plot(CNtauGk,ICrate) |
394 % title ('ICrate'), xlabel('CNtauGk'), ylabel('ICrate') | 422 % title ('ICrate'), xlabel('CNtauGk'), ylabel('ICrate') |
395 % end | 423 % end |
396 | 424 |
397 function ANsmooth = makeANsmooth(ANresponse, sampleRate, winSize, hopSize) | 425 function ANsmooth = makeANsmooth(ANresponse, sampleRate, winSize, hopSize) |
398 if nargin < 3 | 426 if nargin < 3 |
399 winSize = 25; %default 25 ms window | 427 winSize = 25; %default 25 ms window |
400 end | 428 end |
401 if nargin < 4 | 429 if nargin < 4 |
402 hopSize = 10; %default 10 ms jump between windows | 430 hopSize = 10; %default 10 ms jump between windows |
403 end | 431 end |
404 | 432 |
405 winSizeSamples = round(winSize*sampleRate/1000); | 433 winSizeSamples = round(winSize*sampleRate/1000); |
406 hopSizeSamples = round(hopSize*sampleRate/1000); | 434 hopSizeSamples = round(hopSize*sampleRate/1000); |
407 | 435 |
408 % smooth | 436 % smooth |
409 hann = hanning(winSizeSamples); | 437 hann = hanning(winSizeSamples); |
410 | 438 |
411 ANsmooth = [];%Cannot pre-allocate a size as it is unknown until the enframing | 439 ANsmooth = [];%Cannot pre-allocate a size as it is unknown until the enframing |
412 for chan = 1:size(ANresponse,1) | 440 for chan = 1:size(ANresponse,1) |
413 f = enframe(ANresponse(chan,:), hann, hopSizeSamples); | 441 f = enframe(ANresponse(chan,:), hann, hopSizeSamples); |
414 ANsmooth(chan,:) = mean(f,2)'; %#ok<AGROW> see above comment | 442 ANsmooth(chan,:) = mean(f,2)'; %#ok<AGROW> see above comment |
415 end | 443 end |
416 % end% ------ OF makeANsmooth | 444 % end% ------ OF makeANsmooth |