comparison multithreshold 1.46/testAN.m @ 9:ecad0ea62b43

May27 mainly better parameters
author Ray Meddis <rmeddis@essex.ac.uk>
date Tue, 31 May 2011 09:13:07 +0100
parents f233164f4c86
children 9fd4960e743a
comparison
equal deleted inserted replaced
8:eafe11c86f44 9:ecad0ea62b43
1 function testAN 1 function vectorStrength=testAN(targetFrequency,BFlist, levels)
2 % testIHC used either for IHC I/O function ... 2 % testIHC used either for IHC I/O function ...
3 % or receptive field (doReceptiveFields=1) 3 % or receptive field (doReceptiveFields=1)
4 4
5 global experiment method stimulusParameters 5 global experiment method stimulusParameters
6 global IHC_VResp_VivoParams IHCpreSynapseParams 6 global IHC_VResp_VivoParams IHC_cilia_RPParams IHCpreSynapseParams
7 global AN_IHCsynapseParams 7 global AN_IHCsynapseParams
8 % global saveMembranePotential MacGregorMultiParams 8 % global saveMembranePotential MacGregorMultiParams
9 dbstop if error 9 dbstop if error
10 10
11 addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ... 11 addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ...
12 ['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'],... 12 ['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'],...
13 ['..' filesep 'testPrograms']) 13 ['..' filesep 'testPrograms'])
14 14
15 levels=-10:10:80; 15 if nargin<3
16 % levels=80:10:90; 16 levels=-10:10:80;
17 % levels=80:10:90;
18 end
19
17 nLevels=length(levels); 20 nLevels=length(levels);
18 21
19 toneDuration=.2; 22 toneDuration=.2;
20 rampDuration=0.002; 23 rampDuration=0.002;
21 silenceDuration=.02; 24 silenceDuration=.02;
22 localPSTHbinwidth=0.001; 25 localPSTHbinwidth=0.001;
23 26
24 % Use only the first frequency in the GUI targetFrequency box to defineBF 27 % Use only the first frequency in the GUI targetFrequency box to defineBF
25 targetFrequency=stimulusParameters.targetFrequency(1); 28 % targetFrequency=stimulusParameters.targetFrequency(1);
26 BFlist=targetFrequency; 29 % BFlist=targetFrequency;
27 30
28 AN_HSRonset=zeros(nLevels,1); 31 AN_HSRonset=zeros(nLevels,1);
29 AN_HSRsaturated=zeros(nLevels,1); 32 AN_HSRsaturated=zeros(nLevels,1);
30 AN_LSRonset=zeros(nLevels,1); 33 AN_LSRonset=zeros(nLevels,1);
31 AN_LSRsaturated=zeros(nLevels,1); 34 AN_LSRsaturated=zeros(nLevels,1);
41 % ANoutput=zeros(200,200); 44 % ANoutput=zeros(200,200);
42 45
43 figure(15), clf 46 figure(15), clf
44 set(gcf,'position',[980 356 401 321]) 47 set(gcf,'position',[980 356 401 321])
45 figure(5), clf 48 figure(5), clf
46 set(gcf,'position', [980 34 400 295]) 49 set(gcf,'position', [980 34 400 295])
50 set(gcf,'name',[num2str(BFlist), ' Hz']);
47 drawnow 51 drawnow
48 52
49 levelNo=0; 53 levelNo=0;
50 for leveldB=levels 54 for leveldB=levels
51 levelNo=levelNo+1; 55 levelNo=levelNo+1;
52 56
53 % sample rate should be amultiple of the targetFrequency for PSTH below 57 %% sample rate should be amultiple of the targetFrequency for PSTH below
54 sampleRate=50000; 58 sampleRate=50000;
59 sampleRate=20*targetFrequency;
60 if sampleRate<20000
61 sampleRate=round(40000/targetFrequency)*targetFrequency;
62 end
63
64
65 %% ananana
55 dt=1/sampleRate; 66 dt=1/sampleRate;
56 period=1/targetFrequency; 67 period=1/targetFrequency;
57 dt=dt*(dt/period)*round(period/dt); 68 dt=dt*(dt/period)*round(period/dt);
58 69
59 fprintf('%4.0f\t', leveldB) 70 fprintf('%4.0f\t', leveldB)
77 MAPparamsName=experiment.name; 88 MAPparamsName=experiment.name;
78 showPlotsAndDetails=0; 89 showPlotsAndDetails=0;
79 90
80 global ANoutput CNoutput ICoutput ICmembraneOutput tauCas 91 global ANoutput CNoutput ICoutput ICmembraneOutput tauCas
81 global ARattenuation MOCattenuation 92 global ARattenuation MOCattenuation
82 93
83 MAP1_14(inputSignal, 1/dt, targetFrequency, ... 94 MAP1_14(inputSignal, 1/dt, BFlist, ...
84 MAPparamsName, AN_spikesOrProbability); 95 MAPparamsName, AN_spikesOrProbability);
85 96
86 nTaus=length(tauCas); 97 nTaus=length(tauCas);
87 98
88 %LSR (same as HSR if no LSR fibers present) 99 %LSR (same as HSR if no LSR fibers present)
109 120
110 figure(5), subplot(2,2,2) 121 figure(5), subplot(2,2,2)
111 hold off, bar(PSTHtime,PSTH, 'b') 122 hold off, bar(PSTHtime,PSTH, 'b')
112 hold on, bar(PSTHtime,PSTHLSR,'r') 123 hold on, bar(PSTHtime,PSTHLSR,'r')
113 ylim([0 1000]) 124 ylim([0 1000])
114 xlim([0 length(PSTH)*localPSTHbinwidth]) 125 xlim([0 length(PSTH)*localPSTHbinwidth])
115 126
116 % AN - CV 127 % AN - CV
117 % CV is computed 5 times. Use the middle one (3) as most typical 128 % CV is computed 5 times. Use the middle one (3) as most typical
118 cvANHSR= UTIL_CV(HSRspikes, dt); 129 cvANHSR= UTIL_CV(HSRspikes, dt);
119 130
120 % AN - vector strength 131 % AN - vector strength
178 plot(time,ICmembraneOutput(2, 1:end),'k') 189 plot(time,ICmembraneOutput(2, 1:end),'k')
179 ylim([-0.07 0]) 190 ylim([-0.07 0])
180 xlim([0 max(time)]) 191 xlim([0 max(time)])
181 title(['IC ' num2str(leveldB,'%4.0f') 'dB']) 192 title(['IC ' num2str(leveldB,'%4.0f') 'dB'])
182 drawnow 193 drawnow
183 194
184 figure(5), subplot(2,2,1) 195 figure(5), subplot(2,2,1)
185 plot(20*log10(MOC), 'k'), 196 plot(20*log10(MOC), 'k'),
186 title(' MOC'), ylabel('dB attenuation') 197 title(' MOC'), ylabel('dB attenuation')
187 ylim([-30 0]) 198 ylim([-30 0])
188 199
189 200
190 end % level 201 end % level
191 figure(5), subplot(2,2,1) 202 figure(5), subplot(2,2,1)
192 plot(levels,20*log10(MOC), 'k'), 203 plot(levels,20*log10(MOC), 'k'),
193 title(' MOC'), ylabel('dB attenuation') 204 title(' MOC'), ylabel('dB attenuation')
194 ylim([-30 0]) 205 ylim([-30 0])
195 xlim([0 max(levels)]) 206 xlim([0 max(levels)])
196 207
197 fprintf('\n') 208 fprintf('\n')
198 toneDuration=2; 209 toneDuration=2;
199 rampDuration=0.004; 210 rampDuration=0.004;
207 218
208 219
209 % ---------------------------------------------------- display parameters 220 % ---------------------------------------------------- display parameters
210 221
211 figure(15), clf 222 figure(15), clf
212 set(gcf,'position',[1000 356 381 321])
213 nRows=2; nCols=2; 223 nRows=2; nCols=2;
214 224
215 % AN rate - level ONSET functions 225 % AN rate - level ONSET functions
216 subplot(nRows,nCols,1) 226 subplot(nRows,nCols,1)
217 plot(levels,AN_LSRonset,'ro'), hold on 227 plot(levels,AN_LSRonset,'ro'), hold on
259 ylim([0 400]) 269 ylim([0 400])
260 set(gca,'ytick',0:50:300) 270 set(gca,'ytick',0:50:300)
261 xlim([min(levels) max(levels)]) 271 xlim([min(levels) max(levels)])
262 set(gca,'xtick',[levels(1):20:levels(end)]), grid on 272 set(gca,'xtick',[levels(1):20:levels(end)]), grid on
263 273
274
264 ttl=['spont=' num2str(mean(ICHSRsaturated(1,:)),'%4.0f') ... 275 ttl=['spont=' num2str(mean(ICHSRsaturated(1,:)),'%4.0f') ...
265 ' sat=' num2str(mean(ICHSRsaturated(end,1)),'%4.0f')]; 276 ' sat=' num2str(mean(ICHSRsaturated(end,1)),'%4.0f')];
266 title( ttl) 277 title( ttl)
267 xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)') 278 xlabel('level dB SPL'), ylabel ('adapted rate (sp/s)')
268 text(0, 350, 'IC', 'fontsize', 16) 279 text(0, 350, 'IC', 'fontsize', 16)
269 set(gcf,'name',' AN CN IC rate/level') 280 set(gcf,'name',' AN CN IC rate/level')
270 281
271 UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams') 282 peakVectorStrength=max(vectorStrength);
272 UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
273 283
274 fprintf('\n') 284 fprintf('\n')
275 disp('levels vectorStrength') 285 disp('levels vectorStrength')
276 fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength']) 286 fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
277 fprintf('\n') 287 fprintf('\n')
278 fprintf('Phase locking, max vector strength= %6.4f\n\n',... 288 fprintf('Phase locking, max vector strength=\t %6.4f\n\n',...
279 max(vectorStrength)) 289 max(vectorStrength))
280 290
281 allData=[ levels' AN_HSRonset AN_HSRsaturated... 291 allData=[ levels' AN_HSRonset AN_HSRsaturated...
282 AN_LSRonset AN_LSRsaturated ... 292 AN_LSRonset AN_LSRsaturated ...
283 CNHSRsaturated CNLSRrate... 293 CNHSRsaturated CNLSRrate...
285 fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n'); 295 fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n');
286 UTIL_printTabTable(round(allData)) 296 UTIL_printTabTable(round(allData))
287 fprintf('VS (phase locking)= \t%6.4f\n\n',... 297 fprintf('VS (phase locking)= \t%6.4f\n\n',...
288 max(vectorStrength)) 298 max(vectorStrength))
289 299
300 UTIL_showStruct(IHC_cilia_RPParams, 'IHC_cilia_RPParams')
301 UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams')
302 UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams')
303
304 fprintf('\n')
305 disp('levels vectorStrength')
306 fprintf('%3.0f \t %6.4f \n', [levels; vectorStrength'])
307 fprintf('\n')
308 fprintf('Phase locking, max vector strength= \t%6.4f\n\n',...
309 max(vectorStrength))
310
311 allData=[ levels' AN_HSRonset AN_HSRsaturated...
312 AN_LSRonset AN_LSRsaturated ...
313 CNHSRsaturated CNLSRrate...
314 ICHSRsaturated ICLSRsaturated];
315 fprintf('\n levels \tANHSR Onset \tANHSR adapted\tANLSR Onset \tANLSR adapted\tCNHSR\tCNLSR\tICHSR \tICLSR \n');
316 UTIL_printTabTable(round(allData))
317 fprintf('VS (phase locking)= \t%6.4f\n\n',...
318 max(vectorStrength))
319