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 @ 35:25d53244d5c8
History | View | Annotate | Download (15 KB)
| 1 | 26:b03ef38fe497 | rmeddis | function UTIL_showMAP (showMapOptions, paramChanges) |
|---|---|---|---|
| 2 | 24:a5e4a43c1673 | rmeddis | % 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 |
||
| 4 | % simply assumes that they are in place. |
||
| 5 | % |
||
| 6 | 25:d2c4c07df02c | 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 | % showMapOptions.surfProbability=0; % HSR (probability) surf plot |
||
| 13 | % showMapOptions.fileName=[]; % parameter filename for plot title |
||
| 14 | 23:6cce421531e2 | rmeddis | |
| 15 | 35:25d53244d5c8 | rmeddis | % dbstop if warning |
| 16 | 23:6cce421531e2 | rmeddis | |
| 17 | 32:82fb37eb430e | rmeddis | global dt ANdt savedBFlist saveAN_spikesOrProbability saveMAPparamsName... |
| 18 | savedInputSignal OMEextEarPressure TMoutput OMEoutput ARattenuation ... |
||
| 19 | 23:6cce421531e2 | rmeddis | DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
| 20 | 32:82fb37eb430e | rmeddis | IHCoutput ANprobRateOutput ANoutput savePavailable ANtauCas ... |
| 21 | CNtauGk CNoutput ICoutput ICmembraneOutput ICfiberTypeRates ... |
||
| 22 | MOCattenuation |
||
| 23 | 23:6cce421531e2 | rmeddis | global OMEParams DRNLParams IHC_cilia_RPParams IHCpreSynapseParams |
| 24 | global AN_IHCsynapseParams MacGregorParams MacGregorMultiParams |
||
| 25 | 32:82fb37eb430e | rmeddis | global ICrate |
| 26 | 23:6cce421531e2 | rmeddis | |
| 27 | |||
| 28 | restorePath=path; |
||
| 29 | addpath ( ['..' filesep 'utilities'], ['..' filesep 'parameterStore']) |
||
| 30 | |||
| 31 | if nargin<1 |
||
| 32 | 25:d2c4c07df02c | rmeddis | showMapOptions=[]; |
| 33 | 23:6cce421531e2 | rmeddis | end |
| 34 | 25:d2c4c07df02c | rmeddis | % defaults (plot staged outputs and print rates only) if options omitted |
| 35 | if ~isfield(showMapOptions,'printModelParameters') |
||
| 36 | 32:82fb37eb430e | rmeddis | showMapOptions.printModelParameters=0; end |
| 37 | 25:d2c4c07df02c | rmeddis | if ~isfield(showMapOptions,'showModelOutput'),showMapOptions.showModelOutput=1;end |
| 38 | if ~isfield(showMapOptions,'printFiringRates'),showMapOptions.printFiringRates=1;end |
||
| 39 | if ~isfield(showMapOptions,'showACF'),showMapOptions.showACF=0;end |
||
| 40 | if ~isfield(showMapOptions,'showEfferent'),showMapOptions.showEfferent=0;end |
||
| 41 | if ~isfield(showMapOptions,'surfProbability'),showMapOptions.surfProbability=0;end |
||
| 42 | if ~isfield(showMapOptions,'fileName'),showMapOptions.fileName=[];end |
||
| 43 | if ~isfield(showMapOptions,'surfSpikes'),showMapOptions.surfSpikes=0;end |
||
| 44 | 32:82fb37eb430e | rmeddis | if ~isfield(showMapOptions,'ICrates'),showMapOptions.ICrates=0;end |
| 45 | 23:6cce421531e2 | rmeddis | |
| 46 | 26:b03ef38fe497 | rmeddis | %% send all model parameters to command window |
| 47 | 25:d2c4c07df02c | rmeddis | if showMapOptions.printModelParameters |
| 48 | 23:6cce421531e2 | rmeddis | % Read parameters from MAPparams<***> file in 'parameterStore' folder |
| 49 | % and print out all parameters |
||
| 50 | 26:b03ef38fe497 | rmeddis | if nargin>1 |
| 51 | cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1, paramChanges);']; |
||
| 52 | eval(cmd); |
||
| 53 | else |
||
| 54 | cmd=['MAPparams' saveMAPparamsName '(-1, 1/dt, 1);']; |
||
| 55 | eval(cmd); |
||
| 56 | disp(' no parameter changes found')
|
||
| 57 | end |
||
| 58 | 23:6cce421531e2 | rmeddis | end |
| 59 | |||
| 60 | 26:b03ef38fe497 | rmeddis | %% summarise firing rates in command window |
| 61 | 25:d2c4c07df02c | rmeddis | if showMapOptions.printFiringRates |
| 62 | 23:6cce421531e2 | rmeddis | %% print summary firing rates |
| 63 | 35:25d53244d5c8 | rmeddis | fprintf('\n')
|
| 64 | 23:6cce421531e2 | rmeddis | disp('summary')
|
| 65 | disp(['AR: ' num2str(min(ARattenuation))]) |
||
| 66 | disp(['MOC: ' num2str(min(min(MOCattenuation)))]) |
||
| 67 | 32:82fb37eb430e | rmeddis | nANfiberTypes=length(ANtauCas); |
| 68 | 23:6cce421531e2 | rmeddis | if strcmp(saveAN_spikesOrProbability, 'spikes') |
| 69 | nANfibers=size(ANoutput,1); |
||
| 70 | nHSRfibers=nANfibers/nANfiberTypes; |
||
| 71 | duration=size(TMoutput,2)*dt; |
||
| 72 | 32:82fb37eb430e | rmeddis | disp(['AN(HSR): ' num2str(sum(sum(ANoutput(end-nHSRfibers+1:end,:)))/... |
| 73 | 23:6cce421531e2 | rmeddis | (nHSRfibers*duration))]) |
| 74 | |||
| 75 | nCNneurons=size(CNoutput,1); |
||
| 76 | nHSRCNneuronss=nCNneurons/nANfiberTypes; |
||
| 77 | 32:82fb37eb430e | rmeddis | disp(['CN(HSR): ' num2str(sum(sum(CNoutput(end-nHSRCNneuronss+1:end,:)))... |
| 78 | 23:6cce421531e2 | rmeddis | /(nHSRCNneuronss*duration))]) |
| 79 | 32:82fb37eb430e | rmeddis | nICneurons=size(ICoutput,1); |
| 80 | nHSRICneurons= round(nICneurons/nANfiberTypes); |
||
| 81 | 35:25d53244d5c8 | rmeddis | ICrate=sum(sum(ICoutput(end-nHSRICneurons+1:end,:)))/duration/nHSRICneurons; |
| 82 | 32:82fb37eb430e | rmeddis | disp(['IC(HSR): ' num2str(ICrate)]) |
| 83 | 23:6cce421531e2 | rmeddis | % disp(['IC by type: ' num2str(mean(ICfiberTypeRates,2)')]) |
| 84 | else |
||
| 85 | 32:82fb37eb430e | rmeddis | HSRprobOutput= ANprobRateOutput(end-length(savedBFlist)+1:end,:); |
| 86 | 27:d4a7675b0413 | rmeddis | disp(['AN(HSR): ' num2str(mean(mean(HSRprobOutput)))]) |
| 87 | PSTH= UTIL_PSTHmakerb(HSRprobOutput, dt, 0.001); |
||
| 88 | disp(['max max AN: ' num2str(max(max(PSTH)))]) |
||
| 89 | 23:6cce421531e2 | rmeddis | end |
| 90 | end |
||
| 91 | |||
| 92 | |||
| 93 | 26:b03ef38fe497 | rmeddis | %% figure (99): display output from all model stages |
| 94 | 25:d2c4c07df02c | rmeddis | if showMapOptions.showModelOutput |
| 95 | 23:6cce421531e2 | rmeddis | plotInstructions.figureNo=99; |
| 96 | 35:25d53244d5c8 | rmeddis | |
| 97 | % ignore zero elements in signal |
||
| 98 | signalRMS=mean(savedInputSignal(find(savedInputSignal)).^2)^0.5; |
||
| 99 | 23:6cce421531e2 | rmeddis | signalRMSdb=20*log10(signalRMS/20e-6); |
| 100 | |||
| 101 | % plot signal (1) |
||
| 102 | plotInstructions.displaydt=dt; |
||
| 103 | plotInstructions.numPlots=6; |
||
| 104 | plotInstructions.subPlotNo=1; |
||
| 105 | plotInstructions.title=... |
||
| 106 | 35:25d53244d5c8 | rmeddis | ['stimulus (Pa). ' num2str(signalRMSdb, '%4.0f') ' dB SPL']; |
| 107 | 23:6cce421531e2 | rmeddis | r=size(savedInputSignal,1); |
| 108 | if r==1, savedInputSignal=savedInputSignal'; end |
||
| 109 | UTIL_plotMatrix(savedInputSignal', plotInstructions); |
||
| 110 | |||
| 111 | % stapes (2) |
||
| 112 | plotInstructions.subPlotNo=2; |
||
| 113 | 35:25d53244d5c8 | rmeddis | plotInstructions.title= ['stapes displacement (m)']; |
| 114 | 23:6cce421531e2 | rmeddis | UTIL_plotMatrix(OMEoutput, plotInstructions); |
| 115 | |||
| 116 | % DRNL (3) |
||
| 117 | plotInstructions.subPlotNo=3; |
||
| 118 | plotInstructions.yValues= savedBFlist; |
||
| 119 | 35:25d53244d5c8 | rmeddis | [r c]=size(DRNLoutput); |
| 120 | if r>1 |
||
| 121 | plotInstructions.title= ['BM displacement']; |
||
| 122 | UTIL_plotMatrix(abs(DRNLoutput), plotInstructions); |
||
| 123 | else |
||
| 124 | plotInstructions.title= ['BM displacement. BF=' ... |
||
| 125 | num2str(savedBFlist) ' Hz']; |
||
| 126 | 23:6cce421531e2 | rmeddis | UTIL_plotMatrix(DRNLoutput, plotInstructions); |
| 127 | 35:25d53244d5c8 | rmeddis | end |
| 128 | 23:6cce421531e2 | rmeddis | |
| 129 | switch saveAN_spikesOrProbability |
||
| 130 | case 'spikes' |
||
| 131 | % AN (4) |
||
| 132 | plotInstructions.displaydt=ANdt; |
||
| 133 | plotInstructions.title='AN'; |
||
| 134 | plotInstructions.subPlotNo=4; |
||
| 135 | plotInstructions.yLabel='BF'; |
||
| 136 | plotInstructions.yValues= savedBFlist; |
||
| 137 | plotInstructions.rasterDotSize=1; |
||
| 138 | 32:82fb37eb430e | rmeddis | if length(ANtauCas)==2 |
| 139 | 23:6cce421531e2 | rmeddis | plotInstructions.plotDivider=1; |
| 140 | else |
||
| 141 | plotInstructions.plotDivider=0; |
||
| 142 | end |
||
| 143 | if sum(sum(ANoutput))<100 |
||
| 144 | plotInstructions.rasterDotSize=3; |
||
| 145 | end |
||
| 146 | UTIL_plotMatrix(ANoutput, plotInstructions); |
||
| 147 | |||
| 148 | % CN (5) |
||
| 149 | plotInstructions.displaydt=ANdt; |
||
| 150 | plotInstructions.subPlotNo=5; |
||
| 151 | plotInstructions.title='CN spikes'; |
||
| 152 | if sum(sum(CNoutput))<100 |
||
| 153 | plotInstructions.rasterDotSize=3; |
||
| 154 | end |
||
| 155 | UTIL_plotMatrix(CNoutput, plotInstructions); |
||
| 156 | |||
| 157 | % IC (6) |
||
| 158 | plotInstructions.displaydt=ANdt; |
||
| 159 | plotInstructions.subPlotNo=6; |
||
| 160 | 35:25d53244d5c8 | rmeddis | plotInstructions.title='Brainstem 2nd level'; |
| 161 | 32:82fb37eb430e | rmeddis | if size(ICoutput,1)>1 |
| 162 | 23:6cce421531e2 | rmeddis | if sum(sum(ICoutput))<100 |
| 163 | plotInstructions.rasterDotSize=3; |
||
| 164 | end |
||
| 165 | UTIL_plotMatrix(ICoutput, plotInstructions); |
||
| 166 | else |
||
| 167 | plotInstructions.title='IC (HSR) membrane potential'; |
||
| 168 | plotInstructions.displaydt=dt; |
||
| 169 | plotInstructions.yLabel='V'; |
||
| 170 | plotInstructions.zValuesRange= [-.1 0]; |
||
| 171 | UTIL_plotMatrix(ICmembraneOutput, plotInstructions); |
||
| 172 | end |
||
| 173 | |||
| 174 | 26:b03ef38fe497 | rmeddis | otherwise % AN rate based on probability of firing |
| 175 | PSTHbinWidth=0.001; |
||
| 176 | 32:82fb37eb430e | rmeddis | PSTH= UTIL_PSTHmakerb(ANprobRateOutput, dt, PSTHbinWidth); |
| 177 | 35:25d53244d5c8 | rmeddis | % PSTH = makeANsmooth(PSTH, 1/PSTHbinWidth); |
| 178 | 26:b03ef38fe497 | rmeddis | plotInstructions.displaydt=PSTHbinWidth; |
| 179 | 23:6cce421531e2 | rmeddis | plotInstructions.numPlots=2; |
| 180 | plotInstructions.subPlotNo=2; |
||
| 181 | plotInstructions.yLabel='BF'; |
||
| 182 | 35:25d53244d5c8 | rmeddis | plotInstructions.xLabel='time'; |
| 183 | plotInstructions.zValuesRange= [0 300]; |
||
| 184 | 23:6cce421531e2 | rmeddis | if nANfiberTypes>1, |
| 185 | plotInstructions.yLabel='LSR HSR'; |
||
| 186 | plotInstructions.plotDivider=1; |
||
| 187 | end |
||
| 188 | 26:b03ef38fe497 | rmeddis | plotInstructions.title='AN - spike rate'; |
| 189 | UTIL_plotMatrix(PSTH, plotInstructions); |
||
| 190 | 35:25d53244d5c8 | rmeddis | shading interp |
| 191 | colorbar('southOutside')
|
||
| 192 | 23:6cce421531e2 | rmeddis | end |
| 193 | 35:25d53244d5c8 | rmeddis | set(gcf,'name','MAP output') |
| 194 | 23:6cce421531e2 | rmeddis | end |
| 195 | |||
| 196 | 32:82fb37eb430e | rmeddis | if showMapOptions.surfProbability &&... |
| 197 | strcmp(saveAN_spikesOrProbability,'probability') && ... |
||
| 198 | length(savedBFlist)>2 |
||
| 199 | 23:6cce421531e2 | rmeddis | %% surface plot of probability |
| 200 | 32:82fb37eb430e | rmeddis | % 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 | 27:d4a7675b0413 | rmeddis | |
| 220 | 32:82fb37eb430e | rmeddis | title (['firing probability of HSR fibers only. Level= ' ... |
| 221 | num2str(signalRMSdb,'% 3.0f') ' dB']) |
||
| 222 | 35:25d53244d5c8 | rmeddis | colorbar('southOutside')
|
| 223 | 23:6cce421531e2 | rmeddis | end |
| 224 | |||
| 225 | 35:25d53244d5c8 | rmeddis | %% surface plot of AN spikes |
| 226 | if showMapOptions.surfSpikes ... |
||
| 227 | && strcmp(saveAN_spikesOrProbability, 'spikes') |
||
| 228 | 25:d2c4c07df02c | rmeddis | figure(97), clf |
| 229 | % select only HSR fibers at the bottom of the matrix |
||
| 230 | ANoutput= ANoutput(end-length(savedBFlist)+1:end,:); |
||
| 231 | 26:b03ef38fe497 | rmeddis | PSTHbinWidth=0.005; % 1 ms bins |
| 232 | PSTH=UTIL_makePSTH(ANoutput, ANdt, PSTHbinWidth); |
||
| 233 | 25:d2c4c07df02c | rmeddis | [nY nX]=size(PSTH); |
| 234 | time=PSTHbinWidth*(1:nX); |
||
| 235 | surf(time, savedBFlist, PSTH) |
||
| 236 | shading interp |
||
| 237 | set(gca, 'yScale','log') |
||
| 238 | xlim([0 max(time)]) |
||
| 239 | ylim([0 max(savedBFlist)]) |
||
| 240 | 32:82fb37eb430e | rmeddis | % zlim([0 1000]) |
| 241 | 25:d2c4c07df02c | rmeddis | xlabel('time (s)')
|
| 242 | ylabel('best frequency (Hz)')
|
||
| 243 | zlabel('spike rate')
|
||
| 244 | view([-20 60]) |
||
| 245 | % view([0 90]) |
||
| 246 | title ([showMapOptions.fileName ': ' num2str(signalRMSdb,'% 3.0f') ' dB']) |
||
| 247 | 35:25d53244d5c8 | rmeddis | set(97,'name', 'spikes surface plot') |
| 248 | 25:d2c4c07df02c | rmeddis | end |
| 249 | |||
| 250 | 23:6cce421531e2 | rmeddis | |
| 251 | 26:b03ef38fe497 | rmeddis | %% figure(98) plot efferent control values as dB |
| 252 | 25:d2c4c07df02c | rmeddis | if showMapOptions.showEfferent |
| 253 | 23:6cce421531e2 | rmeddis | plotInstructions=[]; |
| 254 | plotInstructions.figureNo=98; |
||
| 255 | figure(98), clf |
||
| 256 | plotInstructions.displaydt=dt; |
||
| 257 | 35:25d53244d5c8 | rmeddis | plotInstructions.numPlots=4; |
| 258 | 23:6cce421531e2 | rmeddis | plotInstructions.subPlotNo=1; |
| 259 | 35:25d53244d5c8 | rmeddis | plotInstructions.zValuesRange= [-1 1]; |
| 260 | plotInstructions.title= ['RMS level='... |
||
| 261 | num2str(signalRMSdb, '%4.0f') ' dB SPL']; |
||
| 262 | UTIL_plotMatrix(savedInputSignal', plotInstructions); |
||
| 263 | |||
| 264 | |||
| 265 | plotInstructions.subPlotNo=2; |
||
| 266 | 23:6cce421531e2 | rmeddis | plotInstructions.zValuesRange=[ -25 0]; |
| 267 | 35:25d53244d5c8 | rmeddis | plotInstructions.title= ['AR stapes attenuation (dB); tau='... |
| 268 | num2str(OMEParams.ARtau, '%4.3f') ' s']; |
||
| 269 | 23:6cce421531e2 | rmeddis | UTIL_plotMatrix(20*log10(ARattenuation), plotInstructions); |
| 270 | |||
| 271 | 35:25d53244d5c8 | rmeddis | % MOCattenuation |
| 272 | plotInstructions.numPlots=2; |
||
| 273 | 23:6cce421531e2 | rmeddis | plotInstructions.subPlotNo=2; |
| 274 | plotInstructions.yValues= savedBFlist; |
||
| 275 | 35:25d53244d5c8 | rmeddis | plotInstructions.yLabel= 'dB'; |
| 276 | if strcmp(saveAN_spikesOrProbability,'spikes') |
||
| 277 | rate2atten=DRNLParams.rateToAttenuationFactor; |
||
| 278 | plotInstructions.title= ['MOC atten; tau=' ... |
||
| 279 | num2str(DRNLParams.MOCtau) '; factor='... |
||
| 280 | num2str(rate2atten, '%6.4f')]; |
||
| 281 | else |
||
| 282 | rate2atten=DRNLParams.rateToAttenuationFactorProb; |
||
| 283 | plotInstructions.title= ['MOC atten; tauProb=' ... |
||
| 284 | num2str(DRNLParams.MOCtauProb) '; factor='... |
||
| 285 | num2str(rate2atten, '%6.4f')]; |
||
| 286 | end |
||
| 287 | plotInstructions.zValuesRange=[0 -DRNLParams.minMOCattenuationdB+5]; |
||
| 288 | UTIL_plotMatrix(-20*log10(MOCattenuation), plotInstructions); |
||
| 289 | hold on |
||
| 290 | [r c]=size(MOCattenuation); |
||
| 291 | if r>2 |
||
| 292 | colorbar('southOutside')
|
||
| 293 | end |
||
| 294 | set(plotInstructions.figureNo, 'name', 'AR/ MOC') |
||
| 295 | |||
| 296 | binwidth=0.1; |
||
| 297 | [PSTH ]=UTIL_PSTHmaker(20*log10(MOCattenuation), dt, binwidth); |
||
| 298 | PSTH=PSTH*length(PSTH)/length(MOCattenuation); |
||
| 299 | t=binwidth:binwidth:binwidth*length(PSTH); |
||
| 300 | fprintf('\n\n')
|
||
| 301 | % UTIL_printTabTable([t' PSTH']) |
||
| 302 | % fprintf('\n\n')
|
||
| 303 | |||
| 304 | 23:6cce421531e2 | rmeddis | end |
| 305 | |||
| 306 | %% ACF plot if required |
||
| 307 | 25:d2c4c07df02c | rmeddis | if showMapOptions.showACF |
| 308 | 23:6cce421531e2 | rmeddis | 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 |
||
| 333 | % plot original waveform on ACF plot |
||
| 334 | figure(13), clf |
||
| 335 | subplot(4,1,1) |
||
| 336 | t=dt*(1:length(savedInputSignal)); |
||
| 337 | plot(t,savedInputSignal) |
||
| 338 | xlim([0 t(end)]) |
||
| 339 | title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); |
||
| 340 | end |
||
| 341 | |||
| 342 | % plot original waveform on summary/smoothed ACF plot |
||
| 343 | figure(96), clf |
||
| 344 | subplot(2,1,1) |
||
| 345 | t=dt*(1:length(savedInputSignal)); |
||
| 346 | plot(t,savedInputSignal) |
||
| 347 | xlim([0 t(end)]) |
||
| 348 | title(['stimulus: ' num2str(signalRMSdb, '%4.0f') ' dB SPL']); |
||
| 349 | |||
| 350 | |||
| 351 | % compute ACF |
||
| 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) |
||
| 366 | imagesc(P) |
||
| 367 | ylabel('periodicities (Hz)')
|
||
| 368 | xlabel('time (s)')
|
||
| 369 | title(['running smoothed (root) SACF. ' saveAN_spikesOrProbability ' input']) |
||
| 370 | pt=[1 get(gca,'ytick')]; % force top xtick to show |
||
| 371 | set(gca,'ytick',pt) |
||
| 372 | set(gca,'ytickLabel', round(pitches(pt))) |
||
| 373 | tt=get(gca,'xtick'); |
||
| 374 | set(gca,'xtickLabel', round(100*t(tt))/100) |
||
| 375 | end |
||
| 376 | |||
| 377 | path(restorePath) |
||
| 378 | 32:82fb37eb430e | rmeddis | |
| 379 | 35:25d53244d5c8 | rmeddis | |
| 380 | 32:82fb37eb430e | rmeddis | %% IC chopper analysis |
| 381 | 35:25d53244d5c8 | rmeddis | % global ICrate |
| 382 | % if showMapOptions.ICrates |
||
| 383 | % [r nEpochs]=size(ICoutput); |
||
| 384 | % ICrate=zeros(1,length(CNtauGk)); |
||
| 385 | % % convert ICoutput to a 4-D matrix (time, CNtau, BF, fiberType) |
||
| 386 | % % NB only one IC unit for any combination. |
||
| 387 | % y=reshape(ICoutput', ... |
||
| 388 | % nEpochs, length(CNtauGk),length(savedBFlist),length(ANtauCas)); |
||
| 389 | % for i=1:length(CNtauGk) |
||
| 390 | % ICrate(i)=sum(sum(sum(y(:,i,:,:))))/duration; |
||
| 391 | % fprintf('%10.5f\t%6.0f\n', CNtauGk(i), ICrate(i))
|
||
| 392 | % end |
||
| 393 | % figure(95), plot(CNtauGk,ICrate) |
||
| 394 | % title ('ICrate'), xlabel('CNtauGk'), ylabel('ICrate')
|
||
| 395 | % end |
||
| 396 | |||
| 397 | function ANsmooth = makeANsmooth(ANresponse, sampleRate, winSize, hopSize) |
||
| 398 | if nargin < 3 |
||
| 399 | winSize = 25; %default 25 ms window |
||
| 400 | end |
||
| 401 | if nargin < 4 |
||
| 402 | hopSize = 10; %default 10 ms jump between windows |
||
| 403 | end |
||
| 404 | |||
| 405 | winSizeSamples = round(winSize*sampleRate/1000); |
||
| 406 | hopSizeSamples = round(hopSize*sampleRate/1000); |
||
| 407 | |||
| 408 | % smooth |
||
| 409 | hann = hanning(winSizeSamples); |
||
| 410 | |||
| 411 | ANsmooth = [];%Cannot pre-allocate a size as it is unknown until the enframing |
||
| 412 | for chan = 1:size(ANresponse,1) |
||
| 413 | f = enframe(ANresponse(chan,:), hann, hopSizeSamples); |
||
| 414 | ANsmooth(chan,:) = mean(f,2)'; %#ok<AGROW> see above comment |
||
| 415 | end |
||
| 416 | % end% ------ OF makeANsmooth |