comparison multithreshold 1.46/testAN.m @ 13:9fd4960e743a

bug in testAN sorted
author Ray Meddis <rmeddis@essex.ac.uk>
date Wed, 01 Jun 2011 12:19:48 +0100
parents ecad0ea62b43
children 35af36fe0a35
comparison
equal deleted inserted replaced
12:4744176aae82 13:9fd4960e743a
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 IHC_cilia_RPParams IHCpreSynapseParams 6 global IHC_VResp_VivoParams IHC_cilia_RPParams IHCpreSynapseParams
7 global AN_IHCsynapseParams 7 global AN_IHCsynapseParams
8 % global saveMembranePotential MacGregorMultiParams 8
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'])
48 figure(5), clf 48 figure(5), clf
49 set(gcf,'position', [980 34 400 295]) 49 set(gcf,'position', [980 34 400 295])
50 set(gcf,'name',[num2str(BFlist), ' Hz']); 50 set(gcf,'name',[num2str(BFlist), ' Hz']);
51 drawnow 51 drawnow
52 52
53 %% guarantee that the sample rate is at least 10 times the frequency
54 sampleRate=50000;
55 while sampleRate< 10* targetFrequency
56 sampleRate=sampleRate+10000;
57 end
58
59 %% adjust sample rate so that the pure tone stimulus has an integer
60 %% numver of epochs in a period
61 dt=1/sampleRate;
62 period=1/targetFrequency;
63 ANspeedUpFactor=5; %anticipating MAP (needs clearing up)
64 ANdt=dt*ANspeedUpFactor;
65 ANdt=period/round(period/ANdt);
66 dt=ANdt/ANspeedUpFactor;
67 sampleRate=1/dt;
68 epochsPerPeriod=sampleRate*period;
69
70 %% main computational loop (vary level)
53 levelNo=0; 71 levelNo=0;
54 for leveldB=levels 72 for leveldB=levels
55 levelNo=levelNo+1; 73 levelNo=levelNo+1;
56
57 %% sample rate should be amultiple of the targetFrequency for PSTH below
58 sampleRate=50000;
59 sampleRate=20*targetFrequency;
60 if sampleRate<20000
61 sampleRate=round(40000/targetFrequency)*targetFrequency;
62 end
63
64
65 %% ananana
66 dt=1/sampleRate;
67 period=1/targetFrequency;
68 dt=dt*(dt/period)*round(period/dt);
69 74
70 fprintf('%4.0f\t', leveldB) 75 fprintf('%4.0f\t', leveldB)
71 amp=28e-6*10^(leveldB/20); 76 amp=28e-6*10^(leveldB/20);
72 77
73 time=dt:dt:toneDuration; 78 time=dt:dt:toneDuration;
86 %% run the model 91 %% run the model
87 AN_spikesOrProbability='spikes'; 92 AN_spikesOrProbability='spikes';
88 MAPparamsName=experiment.name; 93 MAPparamsName=experiment.name;
89 showPlotsAndDetails=0; 94 showPlotsAndDetails=0;
90 95
91 global ANoutput CNoutput ICoutput ICmembraneOutput tauCas 96 global ANoutput ANdt CNoutput ICoutput ICmembraneOutput tauCas
92 global ARattenuation MOCattenuation 97 global ARattenuation MOCattenuation
93 98
94 MAP1_14(inputSignal, 1/dt, BFlist, ... 99 MAP1_14(inputSignal, 1/dt, BFlist, ...
95 MAPparamsName, AN_spikesOrProbability); 100 MAPparamsName, AN_spikesOrProbability);
96 101
97 nTaus=length(tauCas); 102 nTaus=length(tauCas);
98 103
99 %LSR (same as HSR if no LSR fibers present) 104 %LSR (same as HSR if no LSR fibers present)
100 [nANFibers nTimePoints]=size(ANoutput); 105 [nANFibers nTimePoints]=size(ANoutput);
101 dt=dt* length(inputSignal)/nTimePoints;
102 106
103 numLSRfibers=nANFibers/nTaus; 107 numLSRfibers=nANFibers/nTaus;
104 numHSRfibers=numLSRfibers; 108 numHSRfibers=numLSRfibers;
105 109
106 LSRspikes=ANoutput(1:numLSRfibers,:); 110 LSRspikes=ANoutput(1:numLSRfibers,:);
107 PSTH=UTIL_makePSTH(LSRspikes, dt, localPSTHbinwidth); 111 PSTH=UTIL_makePSTH(LSRspikes, ANdt, localPSTHbinwidth);
108 PSTHLSR=mean(PSTH,1)/localPSTHbinwidth; % across fibers rates 112 PSTHLSR=mean(PSTH,1)/localPSTHbinwidth; % across fibers rates
109 PSTHtime=localPSTHbinwidth:localPSTHbinwidth:... 113 PSTHtime=localPSTHbinwidth:localPSTHbinwidth:...
110 localPSTHbinwidth*length(PSTH); 114 localPSTHbinwidth*length(PSTH);
111 AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window 115 AN_LSRonset(levelNo)= max(PSTHLSR); % peak in 5 ms window
112 AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end)); 116 AN_LSRsaturated(levelNo)= mean(PSTHLSR(round(length(PSTH)/2):end));
113 117
114 % HSR 118 % HSR
115 HSRspikes= ANoutput(end- numHSRfibers+1:end, :); 119 HSRspikes= ANoutput(end- numHSRfibers+1:end, :);
116 PSTH=UTIL_makePSTH(HSRspikes, dt, localPSTHbinwidth); 120 PSTH=UTIL_makePSTH(HSRspikes, ANdt, localPSTHbinwidth);
117 PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only) 121 PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
118 AN_HSRonset(levelNo)= max(PSTH); 122 AN_HSRonset(levelNo)= max(PSTH);
119 AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end)); 123 AN_HSRsaturated(levelNo)= mean(PSTH(round(length(PSTH)/2): end));
120 124
121 figure(5), subplot(2,2,2) 125 figure(5), subplot(2,2,2)
124 ylim([0 1000]) 128 ylim([0 1000])
125 xlim([0 length(PSTH)*localPSTHbinwidth]) 129 xlim([0 length(PSTH)*localPSTHbinwidth])
126 130
127 % AN - CV 131 % AN - CV
128 % CV is computed 5 times. Use the middle one (3) as most typical 132 % CV is computed 5 times. Use the middle one (3) as most typical
129 cvANHSR= UTIL_CV(HSRspikes, dt); 133 cvANHSR= UTIL_CV(HSRspikes, ANdt);
130 134
131 % AN - vector strength 135 % AN - vector strength
132 PSTH=sum(HSRspikes); 136 PSTH=sum(HSRspikes);
133 [PH, binTimes]=UTIL_periodHistogram... 137 [PH, binTimes]=UTIL_periodHistogram...
134 (PSTH, dt, targetFrequency); 138 (PSTH, ANdt, targetFrequency);
135 VS=UTIL_vectorStrength(PH); 139 VS=UTIL_vectorStrength(PH);
136 vectorStrength(levelNo)=VS; 140 vectorStrength(levelNo)=VS;
137 disp(['sat rate= ' num2str(AN_HSRsaturated(levelNo)) ... 141 disp(['sat rate= ' num2str(AN_HSRsaturated(levelNo)) ...
138 '; phase-locking VS = ' num2str(VS)]) 142 '; phase-locking VS = ' num2str(VS)])
139 title(['AN HSR: CV=' num2str(cvANHSR(3),'%5.2f') ... 143 title(['AN HSR: CV=' num2str(cvANHSR(3),'%5.2f') ...
143 147
144 % CN LSR 148 % CN LSR
145 [nCNneurons c]=size(CNoutput); 149 [nCNneurons c]=size(CNoutput);
146 nLSRneurons=round(nCNneurons/nTaus); 150 nLSRneurons=round(nCNneurons/nTaus);
147 CNLSRspikes=CNoutput(1:nLSRneurons,:); 151 CNLSRspikes=CNoutput(1:nLSRneurons,:);
148 PSTH=UTIL_makePSTH(CNLSRspikes, dt, localPSTHbinwidth); 152 PSTH=UTIL_makePSTH(CNLSRspikes, ANdt, localPSTHbinwidth);
149 PSTH=sum(PSTH)/nLSRneurons; 153 PSTH=sum(PSTH)/nLSRneurons;
150 CNLSRrate(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth; 154 CNLSRrate(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
151 155
152 %CN HSR 156 %CN HSR
153 MacGregorMultiHSRspikes=... 157 MacGregorMultiHSRspikes=...
154 CNoutput(end-nLSRneurons:end,:); 158 CNoutput(end-nLSRneurons:end,:);
155 PSTH=UTIL_makePSTH(MacGregorMultiHSRspikes, dt, localPSTHbinwidth); 159 PSTH=UTIL_makePSTH(MacGregorMultiHSRspikes, ANdt, localPSTHbinwidth);
156 PSTH=sum(PSTH)/nLSRneurons; 160 PSTH=sum(PSTH)/nLSRneurons;
157 PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only) 161 PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
158 162
159 CNHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end)); 163 CNHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
160 164
161 figure(5), subplot(2,2,3) 165 figure(5), subplot(2,2,3)
162 bar(PSTHtime,PSTH) 166 bar(PSTHtime,PSTH)
163 ylim([0 1000]) 167 ylim([0 1000])
164 xlim([0 length(PSTH)*localPSTHbinwidth]) 168 xlim([0 length(PSTH)*localPSTHbinwidth])
165 cvMMHSR= UTIL_CV(MacGregorMultiHSRspikes, dt); 169 cvMMHSR= UTIL_CV(MacGregorMultiHSRspikes, ANdt);
166 title(['CN CV= ' num2str(cvMMHSR(3),'%5.2f')]) 170 title(['CN CV= ' num2str(cvMMHSR(3),'%5.2f')])
167 171
168 % IC LSR 172 % IC LSR
169 [nICneurons c]=size(ICoutput); 173 [nICneurons c]=size(ICoutput);
170 nLSRneurons=round(nICneurons/nTaus); 174 nLSRneurons=round(nICneurons/nTaus);
171 ICLSRspikes=ICoutput(1:nLSRneurons,:); 175 ICLSRspikes=ICoutput(1:nLSRneurons,:);
172 PSTH=UTIL_makePSTH(ICLSRspikes, dt, localPSTHbinwidth); 176 PSTH=UTIL_makePSTH(ICLSRspikes, ANdt, localPSTHbinwidth);
173 ICLSRsaturated(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth; 177 ICLSRsaturated(levelNo)=mean(PSTH(round(length(PSTH)/2):end))/localPSTHbinwidth;
174 178
175 %IC HSR 179 %IC HSR
176 MacGregorMultiHSRspikes=... 180 MacGregorMultiHSRspikes=...
177 ICoutput(end-nLSRneurons:end,:); 181 ICoutput(end-nLSRneurons:end,:);
178 PSTH=UTIL_makePSTH(MacGregorMultiHSRspikes, dt, localPSTHbinwidth); 182 PSTH=UTIL_makePSTH(MacGregorMultiHSRspikes, ANdt, localPSTHbinwidth);
179 PSTH=sum(PSTH)/nLSRneurons; 183 PSTH=sum(PSTH)/nLSRneurons;
180 PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only) 184 PSTH=mean(PSTH,1)/localPSTHbinwidth; % sum across fibers (HSR only)
181 185
182 ICHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end)); 186 ICHSRsaturated(levelNo)=mean(PSTH(length(PSTH)/2:end));
183 187
184 AR(levelNo)=min(ARattenuation); 188 AR(levelNo)=min(ARattenuation);
185 MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end)); 189 MOC(levelNo)=min(MOCattenuation(length(MOCattenuation)/2:end));
186 190
187 time=dt:dt:dt*size(ICmembraneOutput,2); 191 time=ANdt:ANdt:ANdt*size(ICmembraneOutput,2);
188 figure(5), subplot(2,2,4) 192 figure(5), subplot(2,2,4)
189 plot(time,ICmembraneOutput(2, 1:end),'k') 193 plot(time,ICmembraneOutput(2, 1:end),'k')
190 ylim([-0.07 0]) 194 ylim([-0.07 0])
191 xlim([0 max(time)]) 195 xlim([0 max(time)])
192 title(['IC ' num2str(leveldB,'%4.0f') 'dB']) 196 title(['IC ' num2str(leveldB,'%4.0f') 'dB'])