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.
root / utilities / UTIL_showMAP.m @ 38:c2204b18f4a2
History | View | Annotate | Download (15.7 KB)
| 1 | 38:c2204b18f4a2 | rmeddis | function UTIL_showMAP (showMapOptions) |
|---|---|---|---|
| 2 | 24:a5e4a43c1673 | rmeddis | % UTIL_showMAP produces summaries of the output from MAP's mmost recent run |
| 3 | 38:c2204b18f4a2 | rmeddis | % All MAP_14 outputs are stored in global variables and UTIL_showMAP |
| 4 | % simply assumes that they are in place. It uses whatever it there. |
||
| 5 | 24:a5e4a43c1673 | rmeddis | % |
| 6 | 38:c2204b18f4a2 | rmeddis | % showMapOptions: |
| 7 | 32:82fb37eb430e | rmeddis | % showMapOptions.printModelParameters=1; % print model parameters |
| 8 | 25:d2c4c07df02c | rmeddis | % 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 | 38:c2204b18f4a2 | rmeddis | % showMapOptions.surfAN=0; % AN output surf plot |
| 13 | % showMapOptions.fileName=''; % parameter filename for plot title |
||
| 14 | % showMapOptions.PSTHbinwidth=0.001 % binwidth for surface plots |
||
| 15 | % showMapOptions.colorbar=1; % request color bar if appropriate |
||
| 16 | % showMapOptions.view=[0 90]; |
||
| 17 | 35:25d53244d5c8 | rmeddis | % dbstop if warning |
| 18 | 23:6cce421531e2 | rmeddis | |
| 19 | 38:c2204b18f4a2 | rmeddis | % Discover results left behind by MAP1_14 |
| 20 | global savedParamChanges savedBFlist saveAN_spikesOrProbability ... |
||
| 21 | saveMAPparamsName savedInputSignal dt dtSpikes ... |
||
| 22 | OMEextEarPressure TMoutput OMEoutput DRNLoutput... |
||
| 23 | IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
||
| 24 | IHCoutput ANprobRateOutput ANoutput savePavailable saveNavailable ... |
||
| 25 | ANtauCas CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates... |
||
| 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 |
||
| 32 | 32:82fb37eb430e | rmeddis | global ICrate |
| 33 | 23:6cce421531e2 | rmeddis | |
| 34 | |||
| 35 | restorePath=path; |
||
| 36 | addpath ( ['..' filesep 'utilities'], ['..' filesep 'parameterStore']) |
||
| 37 | |||
| 38 | 38:c2204b18f4a2 | rmeddis | if nargin<1, showMapOptions=[]; end |
| 39 | paramChanges=savedParamChanges; |
||
| 40 | |||
| 41 | 25:d2c4c07df02c | rmeddis | % defaults (plot staged outputs and print rates only) if options omitted |
| 42 | if ~isfield(showMapOptions,'printModelParameters') |
||
| 43 | 32:82fb37eb430e | rmeddis | showMapOptions.printModelParameters=0; end |
| 44 | 38:c2204b18f4a2 | rmeddis | if ~isfield(showMapOptions,'showModelOutput'),showMapOptions.showModelOutput=0;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 |
||
| 48 | 25:d2c4c07df02c | rmeddis | if ~isfield(showMapOptions,'showACF'),showMapOptions.showACF=0;end |
| 49 | if ~isfield(showMapOptions,'showEfferent'),showMapOptions.showEfferent=0;end |
||
| 50 | 38:c2204b18f4a2 | rmeddis | if ~isfield(showMapOptions,'PSTHbinwidth'),showMapOptions.PSTHbinwidth=0.001;end |
| 51 | 25:d2c4c07df02c | rmeddis | if ~isfield(showMapOptions,'fileName'),showMapOptions.fileName=[];end |
| 52 | 38:c2204b18f4a2 | rmeddis | if ~isfield(showMapOptions,'colorbar'),showMapOptions.colorbar=1;end |
| 53 | if ~isfield(showMapOptions,'view'),showMapOptions.view=[-25 80];end |
||
| 54 | if ~isfield(showMapOptions,'ICrasterPlot'),showMapOptions.ICrasterPlot=0;end |
||
| 55 | 23:6cce421531e2 | rmeddis | |
| 56 | 26:b03ef38fe497 | rmeddis | %% send all model parameters to command window |
| 57 | 25:d2c4c07df02c | rmeddis | if showMapOptions.printModelParameters |
| 58 | 23:6cce421531e2 | rmeddis | % Read parameters from MAPparams<***> file in 'parameterStore' folder |
| 59 | % and print out all parameters |
||
| 60 | 26:b03ef38fe497 | rmeddis | cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1, paramChanges);']; |
| 61 | eval(cmd); |
||
| 62 | 23:6cce421531e2 | rmeddis | end |
| 63 | |||
| 64 | 38:c2204b18f4a2 | rmeddis | % ignore zero elements in signal |
| 65 | signalRMS=mean(savedInputSignal(find(savedInputSignal)).^2)^0.5; |
||
| 66 | signalRMSdb=20*log10(signalRMS/20e-6); |
||
| 67 | nANfiberTypes=length(ANtauCas); |
||
| 68 | |||
| 69 | 26:b03ef38fe497 | rmeddis | %% summarise firing rates in command window |
| 70 | 25:d2c4c07df02c | rmeddis | if showMapOptions.printFiringRates |
| 71 | 23:6cce421531e2 | rmeddis | %% print summary firing rates |
| 72 | 35:25d53244d5c8 | rmeddis | fprintf('\n')
|
| 73 | 23:6cce421531e2 | rmeddis | disp('summary')
|
| 74 | disp(['AR: ' num2str(min(ARattenuation))]) |
||
| 75 | disp(['MOC: ' num2str(min(min(MOCattenuation)))]) |
||
| 76 | if strcmp(saveAN_spikesOrProbability, 'spikes') |
||
| 77 | nANfibers=size(ANoutput,1); |
||
| 78 | nHSRfibers=nANfibers/nANfiberTypes; |
||
| 79 | duration=size(TMoutput,2)*dt; |
||
| 80 | 32:82fb37eb430e | rmeddis | disp(['AN(HSR): ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/... |
| 81 | 23:6cce421531e2 | rmeddis | (nHSRfibers*duration))]) |
| 82 | |||
| 83 | nCNneurons=size(CNoutput,1); |
||
| 84 | nHSRCNneuronss=nCNneurons/nANfiberTypes; |
||
| 85 | 32:82fb37eb430e | rmeddis | disp(['CN(HSR): ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))... |
| 86 | 23:6cce421531e2 | rmeddis | /(nHSRCNneuronss*duration))]) |
| 87 | 32:82fb37eb430e | rmeddis | nICneurons=size(ICoutput,1); |
| 88 | nHSRICneurons= round(nICneurons/nANfiberTypes); |
||
| 89 | 35:25d53244d5c8 | rmeddis | ICrate=sum(sum(ICoutput(end-nHSRICneurons+1:end,:)))/duration/nHSRICneurons; |
| 90 | 32:82fb37eb430e | rmeddis | disp(['IC(HSR): ' num2str(ICrate)]) |
| 91 | 23:6cce421531e2 | rmeddis | % disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')]) |
| 92 | else |
||
| 93 | 32:82fb37eb430e | rmeddis | HSRprobOutput= ANprobRateOutput(end-length(savedBFlist)+1:end,:); |
| 94 | 27:d4a7675b0413 | rmeddis | disp(['AN(HSR): ' num2str(mean(mean(HSRprobOutput)))]) |
| 95 | PSTH= UTIL_PSTHmakerb(HSRprobOutput, dt, 0.001); |
||
| 96 | disp(['max max AN: ' num2str(max(max(PSTH)))]) |
||
| 97 | 23:6cce421531e2 | rmeddis | end |
| 98 | end |
||
| 99 | |||
| 100 | |||
| 101 | 26:b03ef38fe497 | rmeddis | %% figure (99): display output from all model stages |
| 102 | 25:d2c4c07df02c | rmeddis | if showMapOptions.showModelOutput |
| 103 | 23:6cce421531e2 | rmeddis | plotInstructions.figureNo=99; |
| 104 | |||
| 105 | % plot signal (1) |
||
| 106 | plotInstructions.displaydt=dt; |
||
| 107 | plotInstructions.numPlots=6; |
||
| 108 | plotInstructions.subPlotNo=1; |
||
| 109 | plotInstructions.title=... |
||
| 110 | 35:25d53244d5c8 | rmeddis | ['stimulus (Pa). ' num2str(signalRMSdb, '%4.0f') ' dB SPL']; |
| 111 | 38:c2204b18f4a2 | rmeddis | UTIL_plotMatrix(savedInputSignal, plotInstructions); |
| 112 | 23:6cce421531e2 | rmeddis | |
| 113 | % stapes (2) |
||
| 114 | plotInstructions.subPlotNo=2; |
||
| 115 | 35:25d53244d5c8 | rmeddis | plotInstructions.title= ['stapes displacement (m)']; |
| 116 | 23:6cce421531e2 | rmeddis | UTIL_plotMatrix(OMEoutput, plotInstructions); |
| 117 | |||
| 118 | % DRNL (3) |
||
| 119 | plotInstructions.subPlotNo=3; |
||
| 120 | plotInstructions.yValues= savedBFlist; |
||
| 121 | 35:25d53244d5c8 | rmeddis | [r c]=size(DRNLoutput); |
| 122 | if r>1 |
||
| 123 | plotInstructions.title= ['BM displacement']; |
||
| 124 | 38:c2204b18f4a2 | rmeddis | UTIL_plotMatrix(abs(DRNLoutput), plotInstructions); |
| 125 | 35:25d53244d5c8 | rmeddis | else |
| 126 | plotInstructions.title= ['BM displacement. BF=' ... |
||
| 127 | num2str(savedBFlist) ' Hz']; |
||
| 128 | 38:c2204b18f4a2 | rmeddis | UTIL_plotMatrix(DRNLoutput, plotInstructions); |
| 129 | 35:25d53244d5c8 | rmeddis | end |
| 130 | 23:6cce421531e2 | rmeddis | |
| 131 | switch saveAN_spikesOrProbability |
||
| 132 | case 'spikes' |
||
| 133 | % AN (4) |
||
| 134 | 38:c2204b18f4a2 | rmeddis | plotInstructions.displaydt=dtSpikes; |
| 135 | 23:6cce421531e2 | rmeddis | plotInstructions.title='AN'; |
| 136 | plotInstructions.subPlotNo=4; |
||
| 137 | plotInstructions.yLabel='BF'; |
||
| 138 | plotInstructions.yValues= savedBFlist; |
||
| 139 | plotInstructions.rasterDotSize=1; |
||
| 140 | 32:82fb37eb430e | rmeddis | if length(ANtauCas)==2 |
| 141 | 23:6cce421531e2 | rmeddis | plotInstructions.plotDivider=1; |
| 142 | else |
||
| 143 | plotInstructions.plotDivider=0; |
||
| 144 | end |
||
| 145 | if sum(sum(ANoutput))<100 |
||
| 146 | plotInstructions.rasterDotSize=3; |
||
| 147 | end |
||
| 148 | UTIL_plotMatrix(ANoutput, plotInstructions); |
||
| 149 | |||
| 150 | % CN (5) |
||
| 151 | 38:c2204b18f4a2 | rmeddis | plotInstructions.displaydt=dtSpikes; |
| 152 | 23:6cce421531e2 | rmeddis | plotInstructions.subPlotNo=5; |
| 153 | plotInstructions.title='CN spikes'; |
||
| 154 | if sum(sum(CNoutput))<100 |
||
| 155 | plotInstructions.rasterDotSize=3; |
||
| 156 | end |
||
| 157 | UTIL_plotMatrix(CNoutput, plotInstructions); |
||
| 158 | |||
| 159 | % IC (6) |
||
| 160 | 38:c2204b18f4a2 | rmeddis | plotInstructions.displaydt=dtSpikes; |
| 161 | 23:6cce421531e2 | rmeddis | plotInstructions.subPlotNo=6; |
| 162 | 35:25d53244d5c8 | rmeddis | plotInstructions.title='Brainstem 2nd level'; |
| 163 | 32:82fb37eb430e | rmeddis | if size(ICoutput,1)>1 |
| 164 | 23:6cce421531e2 | rmeddis | if sum(sum(ICoutput))<100 |
| 165 | plotInstructions.rasterDotSize=3; |
||
| 166 | end |
||
| 167 | UTIL_plotMatrix(ICoutput, plotInstructions); |
||
| 168 | else |
||
| 169 | plotInstructions.title='IC (HSR) membrane potential'; |
||
| 170 | plotInstructions.displaydt=dt; |
||
| 171 | plotInstructions.yLabel='V'; |
||
| 172 | plotInstructions.zValuesRange= [-.1 0]; |
||
| 173 | UTIL_plotMatrix(ICmembraneOutput, plotInstructions); |
||
| 174 | end |
||
| 175 | |||
| 176 | 26:b03ef38fe497 | rmeddis | otherwise % AN rate based on probability of firing |
| 177 | 38:c2204b18f4a2 | rmeddis | PSTHbinWidth=0.0005; |
| 178 | 32:82fb37eb430e | rmeddis | PSTH= UTIL_PSTHmakerb(ANprobRateOutput, dt, PSTHbinWidth); |
| 179 | 38:c2204b18f4a2 | rmeddis | plotInstructions=[]; |
| 180 | 26:b03ef38fe497 | rmeddis | plotInstructions.displaydt=PSTHbinWidth; |
| 181 | 38:c2204b18f4a2 | rmeddis | plotInstructions.plotDivider=0; |
| 182 | 23:6cce421531e2 | rmeddis | plotInstructions.numPlots=2; |
| 183 | plotInstructions.subPlotNo=2; |
||
| 184 | plotInstructions.yLabel='BF'; |
||
| 185 | 38:c2204b18f4a2 | rmeddis | plotInstructions.yValues=savedBFlist; |
| 186 | plotInstructions.xLabel='time (s)'; |
||
| 187 | 35:25d53244d5c8 | rmeddis | plotInstructions.zValuesRange= [0 300]; |
| 188 | 38:c2204b18f4a2 | rmeddis | |
| 189 | 23:6cce421531e2 | rmeddis | if nANfiberTypes>1, |
| 190 | 38:c2204b18f4a2 | rmeddis | plotInstructions.yLabel='LSR HSR'; |
| 191 | 23:6cce421531e2 | rmeddis | plotInstructions.plotDivider=1; |
| 192 | end |
||
| 193 | 26:b03ef38fe497 | rmeddis | plotInstructions.title='AN - spike rate'; |
| 194 | UTIL_plotMatrix(PSTH, plotInstructions); |
||
| 195 | 35:25d53244d5c8 | rmeddis | shading interp |
| 196 | 38:c2204b18f4a2 | rmeddis | if showMapOptions.colorbar, colorbar('southOutside'), end
|
| 197 | 23:6cce421531e2 | rmeddis | end |
| 198 | 35:25d53244d5c8 | rmeddis | set(gcf,'name','MAP output') |
| 199 | 23:6cce421531e2 | rmeddis | end |
| 200 | |||
| 201 | 38:c2204b18f4a2 | rmeddis | |
| 202 | %% surface plot of AN response |
||
| 203 | % probability |
||
| 204 | if showMapOptions.surfAN &&... |
||
| 205 | 32:82fb37eb430e | rmeddis | strcmp(saveAN_spikesOrProbability,'probability') && ... |
| 206 | length(savedBFlist)>2 |
||
| 207 | 38:c2204b18f4a2 | rmeddis | % select only HSR fibers |
| 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 | 23:6cce421531e2 | rmeddis | end |
| 233 | |||
| 234 | 38:c2204b18f4a2 | rmeddis | %% surfAN ('spikes')
|
| 235 | if showMapOptions.surfAN ... |
||
| 236 | && strcmp(saveAN_spikesOrProbability, 'spikes')... |
||
| 237 | && length(savedBFlist)>2 |
||
| 238 | 25:d2c4c07df02c | rmeddis | figure(97), clf |
| 239 | 38:c2204b18f4a2 | rmeddis | % 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)); |
||
| 245 | 25:d2c4c07df02c | rmeddis | % select only HSR fibers at the bottom of the matrix |
| 246 | 38:c2204b18f4a2 | rmeddis | HSRoutput= x(end-length(savedBFlist)+1:end,:); |
| 247 | PSTH=HSRoutput; |
||
| 248 | PSTHbinWidth=showMapOptions.PSTHbinwidth; |
||
| 249 | PSTH=UTIL_makePSTH(HSRoutput, dtSpikes, PSTHbinWidth); |
||
| 250 | 25:d2c4c07df02c | rmeddis | [nY nX]=size(PSTH); |
| 251 | time=PSTHbinWidth*(1:nX); |
||
| 252 | surf(time, savedBFlist, PSTH) |
||
| 253 | shading interp |
||
| 254 | set(gca, 'yScale','log') |
||
| 255 | xlim([0 max(time)]) |
||
| 256 | ylim([0 max(savedBFlist)]) |
||
| 257 | 32:82fb37eb430e | rmeddis | % zlim([0 1000]) |
| 258 | 25:d2c4c07df02c | rmeddis | xlabel('time (s)')
|
| 259 | ylabel('best frequency (Hz)')
|
||
| 260 | zlabel('spike rate')
|
||
| 261 | 38:c2204b18f4a2 | rmeddis | view(showMapOptions.view) |
| 262 | 25:d2c4c07df02c | rmeddis | title ([showMapOptions.fileName ': ' num2str(signalRMSdb,'% 3.0f') ' dB']) |
| 263 | 35:25d53244d5c8 | rmeddis | set(97,'name', 'spikes surface plot') |
| 264 | 25:d2c4c07df02c | rmeddis | end |
| 265 | |||
| 266 | 38:c2204b18f4a2 | rmeddis | %% 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 |
||
| 297 | 23:6cce421531e2 | rmeddis | |
| 298 | 26:b03ef38fe497 | rmeddis | %% figure(98) plot efferent control values as dB |
| 299 | 25:d2c4c07df02c | rmeddis | if showMapOptions.showEfferent |
| 300 | 23:6cce421531e2 | rmeddis | plotInstructions=[]; |
| 301 | plotInstructions.figureNo=98; |
||
| 302 | figure(98), clf |
||
| 303 | plotInstructions.displaydt=dt; |
||
| 304 | 35:25d53244d5c8 | rmeddis | plotInstructions.numPlots=4; |
| 305 | 23:6cce421531e2 | rmeddis | plotInstructions.subPlotNo=1; |
| 306 | 35:25d53244d5c8 | rmeddis | plotInstructions.zValuesRange= [-1 1]; |
| 307 | plotInstructions.title= ['RMS level='... |
||
| 308 | num2str(signalRMSdb, '%4.0f') ' dB SPL']; |
||
| 309 | 38:c2204b18f4a2 | rmeddis | UTIL_plotMatrix(savedInputSignal, plotInstructions); |
| 310 | |||
| 311 | |||
| 312 | 35:25d53244d5c8 | rmeddis | plotInstructions.subPlotNo=2; |
| 313 | 23:6cce421531e2 | rmeddis | plotInstructions.zValuesRange=[ -25 0]; |
| 314 | 35:25d53244d5c8 | rmeddis | plotInstructions.title= ['AR stapes attenuation (dB); tau='... |
| 315 | num2str(OMEParams.ARtau, '%4.3f') ' s']; |
||
| 316 | 23:6cce421531e2 | rmeddis | UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions); |
| 317 | |||
| 318 | 35:25d53244d5c8 | rmeddis | % MOCattenuation |
| 319 | plotInstructions.numPlots=2; |
||
| 320 | 23:6cce421531e2 | rmeddis | plotInstructions.subPlotNo=2; |
| 321 | plotInstructions.yValues= savedBFlist; |
||
| 322 | 35:25d53244d5c8 | rmeddis | plotInstructions.yLabel= 'dB'; |
| 323 | if strcmp(saveAN_spikesOrProbability,'spikes') |
||
| 324 | rate2atten=DRNLParams.rateToAttenuationFactor; |
||
| 325 | 38:c2204b18f4a2 | rmeddis | plotInstructions.title= ['MOC atten; tau=' ... |
| 326 | num2str(DRNLParams.MOCtau) '; factor='... |
||
| 327 | num2str(rate2atten, '%6.4f')]; |
||
| 328 | 35:25d53244d5c8 | rmeddis | else |
| 329 | rate2atten=DRNLParams.rateToAttenuationFactorProb; |
||
| 330 | 38:c2204b18f4a2 | rmeddis | plotInstructions.title= ['MOC atten; tauProb=' ... |
| 331 | num2str(DRNLParams.MOCtauProb) '; factor='... |
||
| 332 | num2str(rate2atten, '%6.4f')]; |
||
| 333 | 35:25d53244d5c8 | rmeddis | end |
| 334 | plotInstructions.zValuesRange=[0 -DRNLParams.minMOCattenuationdB+5]; |
||
| 335 | UTIL_plotMatrix(-20*log10(MOCattenuation), plotInstructions); |
||
| 336 | hold on |
||
| 337 | [r c]=size(MOCattenuation); |
||
| 338 | 38:c2204b18f4a2 | rmeddis | if r>2 && showMapOptions.colorbar |
| 339 | colorbar('southOutside')
|
||
| 340 | 35:25d53244d5c8 | rmeddis | end |
| 341 | set(plotInstructions.figureNo, 'name', 'AR/ MOC') |
||
| 342 | 38:c2204b18f4a2 | rmeddis | |
| 343 | 35:25d53244d5c8 | rmeddis | binwidth=0.1; |
| 344 | [PSTH ]=UTIL_PSTHmaker(20*log10(MOCattenuation), dt, binwidth); |
||
| 345 | PSTH=PSTH*length(PSTH)/length(MOCattenuation); |
||
| 346 | t=binwidth:binwidth:binwidth*length(PSTH); |
||
| 347 | fprintf('\n\n')
|
||
| 348 | 38:c2204b18f4a2 | rmeddis | % UTIL_printTabTable([t' PSTH']) |
| 349 | % fprintf('\n\n')
|
||
| 350 | |||
| 351 | 23:6cce421531e2 | rmeddis | end |
| 352 | |||
| 353 | 38:c2204b18f4a2 | rmeddis | %% ACF plot |
| 354 | 25:d2c4c07df02c | rmeddis | if showMapOptions.showACF |
| 355 | 23:6cce421531e2 | rmeddis | tic |
| 356 | if filteredSACFParams.plotACFs |
||
| 357 | % plot original waveform on ACF plot |
||
| 358 | figure(13), clf |
||
| 359 | subplot(4,1,1) |
||
| 360 | t=dt*(1:length(savedInputSignal)); |
||
| 361 | plot(t,savedInputSignal) |
||
| 362 | xlim([0 t(end)]) |
||
| 363 | title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); |
||
| 364 | end |
||
| 365 | |||
| 366 | 38:c2204b18f4a2 | rmeddis | % 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 | |||
| 379 | 23:6cce421531e2 | rmeddis | % plot original waveform on summary/smoothed ACF plot |
| 380 | figure(96), clf |
||
| 381 | subplot(2,1,1) |
||
| 382 | t=dt*(1:length(savedInputSignal)); |
||
| 383 | plot(t,savedInputSignal) |
||
| 384 | xlim([0 t(end)]) |
||
| 385 | title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); |
||
| 386 | |||
| 387 | 38:c2204b18f4a2 | rmeddis | % plot SACF |
| 388 | figure(96) |
||
| 389 | 23:6cce421531e2 | rmeddis | subplot(2,1,2) |
| 390 | imagesc(P) |
||
| 391 | 38:c2204b18f4a2 | rmeddis | % surf(filteredSACFParams.lags, t, P) |
| 392 | 23:6cce421531e2 | rmeddis | ylabel('periodicities (Hz)')
|
| 393 | xlabel('time (s)')
|
||
| 394 | 38:c2204b18f4a2 | rmeddis | title(['running smoothed SACF. ' saveAN_spikesOrProbability ' input']) |
| 395 | pt=[1 get(gca,'ytick')]; % force top ytick to show |
||
| 396 | 23:6cce421531e2 | rmeddis | set(gca,'ytick',pt) |
| 397 | 38:c2204b18f4a2 | rmeddis | pitches=1./filteredSACFParams.lags; % autocorrelation lags vector |
| 398 | 23:6cce421531e2 | rmeddis | set(gca,'ytickLabel', round(pitches(pt))) |
| 399 | 38:c2204b18f4a2 | rmeddis | [nCH nTimes]=size(P); |
| 400 | t=dt:dt:dt*nTimes; |
||
| 401 | 23:6cce421531e2 | rmeddis | tt=get(gca,'xtick'); |
| 402 | set(gca,'xtickLabel', round(100*t(tt))/100) |
||
| 403 | end |
||
| 404 | |||
| 405 | path(restorePath) |
||
| 406 | 32:82fb37eb430e | rmeddis | |
| 407 | 35:25d53244d5c8 | rmeddis | |
| 408 | 32:82fb37eb430e | rmeddis | %% IC chopper analysis |
| 409 | 35:25d53244d5c8 | rmeddis | % global ICrate |
| 410 | % if showMapOptions.ICrates |
||
| 411 | % [r nEpochs]=size(ICoutput); |
||
| 412 | % ICrate=zeros(1,length(CNtauGk)); |
||
| 413 | % % convert ICoutput to a 4-D matrix (time, CNtau, BF, fiberType) |
||
| 414 | % % NB only one IC unit for any combination. |
||
| 415 | % y=reshape(ICoutput', ... |
||
| 416 | % nEpochs, length(CNtauGk),length(savedBFlist),length(ANtauCas)); |
||
| 417 | % for i=1:length(CNtauGk) |
||
| 418 | % ICrate(i)=sum(sum(sum(y(:,i,:,:))))/duration; |
||
| 419 | % fprintf('%10.5f\t%6.0f\n', CNtauGk(i), ICrate(i))
|
||
| 420 | % end |
||
| 421 | % figure(95), plot(CNtauGk,ICrate) |
||
| 422 | % title ('ICrate'), xlabel('CNtauGk'), ylabel('ICrate')
|
||
| 423 | % end |
||
| 424 | |||
| 425 | function ANsmooth = makeANsmooth(ANresponse, sampleRate, winSize, hopSize) |
||
| 426 | 38:c2204b18f4a2 | rmeddis | if nargin < 3 |
| 427 | winSize = 25; %default 25 ms window |
||
| 428 | end |
||
| 429 | if nargin < 4 |
||
| 430 | hopSize = 10; %default 10 ms jump between windows |
||
| 431 | end |
||
| 432 | |||
| 433 | winSizeSamples = round(winSize*sampleRate/1000); |
||
| 434 | hopSizeSamples = round(hopSize*sampleRate/1000); |
||
| 435 | |||
| 436 | % smooth |
||
| 437 | hann = hanning(winSizeSamples); |
||
| 438 | |||
| 439 | ANsmooth = [];%Cannot pre-allocate a size as it is unknown until the enframing |
||
| 440 | for chan = 1:size(ANresponse,1) |
||
| 441 | f = enframe(ANresponse(chan,:), hann, hopSizeSamples); |
||
| 442 | ANsmooth(chan,:) = mean(f,2)'; %#ok<AGROW> see above comment |
||
| 443 | end |
||
| 444 | 35:25d53244d5c8 | rmeddis | % end% ------ OF makeANsmooth |