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 / multithreshold 1.46 / testRF.m @ 29:b51bf546ca3f
History | View | Annotate | Download (12.1 KB)
| 1 |
function testRF |
|---|---|
| 2 |
% testIHC used either for IHC I/O function or receptive field (doReceptiveFields=1) |
| 3 |
|
| 4 |
global experiment method stimulusParameters expGUIhandles |
| 5 |
global inputStimulusParams IHC_ciliaParams |
| 6 |
global IHC_VResp_VivoParams IHCpreSynapseParams AN_IHCsynapseParams |
| 7 |
dbstop if error |
| 8 |
% set(expGUIhandles.pushbuttonStop, 'backgroundColor', [.941 .941 .941]) |
| 9 |
|
| 10 |
addpath (['..' filesep 'MAP'], ['..' filesep 'utilities'], ... |
| 11 |
['..' filesep 'parameterStore'], ['..' filesep 'wavFileStore'],... |
| 12 |
['..' filesep 'testPrograms']) |
| 13 |
|
| 14 |
targetFrequency=stimulusParameters.targetFrequency(1); |
| 15 |
|
| 16 |
sampleRate=50000; |
| 17 |
doReceptiveFields=1; |
| 18 |
|
| 19 |
toneDuration=.05; |
| 20 |
rampDuration=0.004; |
| 21 |
silenceDuration=.02; |
| 22 |
|
| 23 |
nRepeats=100; % no. of AN fibers |
| 24 |
|
| 25 |
plotGraphsForIHC=1; |
| 26 |
% number of MacGregor units is set in the parameter file. |
| 27 |
|
| 28 |
if doReceptiveFields |
| 29 |
% show all receptive field |
| 30 |
frequencies=targetFrequency* [ 0.5 0.7 0.9 1 1.1 1.3 1.6]; |
| 31 |
levels=0:20:80; nLevels=length(levels); |
| 32 |
figure(14), clf |
| 33 |
figure(15), clf |
| 34 |
else |
| 35 |
% show only I/O function at BF |
| 36 |
frequencies=targetFrequency; |
| 37 |
levels=-20:10:90; |
| 38 |
% levels=10:.25:13; |
| 39 |
% levels=-20:1:-15 |
| 40 |
nLevels=length(levels); |
| 41 |
% figure(13), clf, |
| 42 |
% set (gcf, 'name', ['IHC/AN input/output' num2str(AN_IHCsynapseParams.numFibers) ' repeats']) |
| 43 |
% drawnow |
| 44 |
end |
| 45 |
nFrequencies=length(frequencies); |
| 46 |
|
| 47 |
IHC_RP_peak=zeros(nLevels,nFrequencies); |
| 48 |
IHC_RP_min=zeros(nLevels,nFrequencies); |
| 49 |
IHC_RP_dc=zeros(nLevels,nFrequencies); |
| 50 |
AN_HSRonset=zeros(nLevels,nFrequencies); |
| 51 |
AN_HSRsaturated=zeros(nLevels,nFrequencies); |
| 52 |
AN_LSRonset=zeros(nLevels,nFrequencies); |
| 53 |
AN_LSRsaturated=zeros(nLevels,nFrequencies); |
| 54 |
CNLSRsaturated=zeros(nLevels,nFrequencies); |
| 55 |
CNHSRsaturated=zeros(nLevels,nFrequencies); |
| 56 |
ICHSRsaturated=zeros(nLevels,nFrequencies); |
| 57 |
ICLSRsaturated=zeros(nLevels,nFrequencies); |
| 58 |
|
| 59 |
|
| 60 |
levelNo=0; PSTHplotCount=0; |
| 61 |
for leveldB=levels |
| 62 |
fprintf('%4.0f\t', leveldB)
|
| 63 |
levelNo=levelNo+1; |
| 64 |
amp=28e-6*10^(leveldB/20); |
| 65 |
|
| 66 |
freqNo=0; |
| 67 |
for frequency=frequencies |
| 68 |
|
| 69 |
paramFunctionName=['method=MAPparams' experiment.name ... |
| 70 |
'(' num2str(targetFrequency) ');' ];
|
| 71 |
eval(paramFunctionName); % read parameters afresh each pass |
| 72 |
|
| 73 |
dt=method.dt; |
| 74 |
time=dt:dt:toneDuration; |
| 75 |
rampTime=dt:dt:rampDuration; |
| 76 |
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time)-length(rampTime))]; |
| 77 |
ramp=ramp.*fliplr(ramp); |
| 78 |
|
| 79 |
silence=zeros(1,round(silenceDuration/dt)); |
| 80 |
|
| 81 |
toneStartptr=length(silence)+1; |
| 82 |
toneMidptr=toneStartptr+round(toneDuration/(2*dt)) -1; |
| 83 |
toneEndptr=toneStartptr+round(toneDuration/dt) -1; |
| 84 |
|
| 85 |
% create signal (leveldB/ frequency) |
| 86 |
freqNo=freqNo+1; |
| 87 |
inputSignal=amp*sin(2*pi*frequency'*time); |
| 88 |
inputSignal= ramp.*inputSignal; |
| 89 |
inputSignal=[silence inputSignal silence]; |
| 90 |
|
| 91 |
if doReceptiveFields % receptive field |
| 92 |
method.plotGraphs= 0; % plot only PSTHs |
| 93 |
else |
| 94 |
method.plotGraphs= plotGraphsForIHC; % show progress |
| 95 |
end |
| 96 |
|
| 97 |
targetChannelNo=1; |
| 98 |
|
| 99 |
% force parameters |
| 100 |
% the number of AN fibers at each BF |
| 101 |
AN_IHCsynapseParams.numFibers= nRepeats; |
| 102 |
AN_IHCsynapseParams. mode= 'spikes'; |
| 103 |
AN_IHCsynapseParams.plotSynapseContents=0; |
| 104 |
AN_IHCsynapseParams.PSTHbinWidth=.001; |
| 105 |
|
| 106 |
method.DRNLSave=1; |
| 107 |
method.IHC_cilia_RPSave=1; |
| 108 |
method.PSTHbinWidth=1e-3; % useful 1-ms default for all PSTHs |
| 109 |
method.AN_IHCsynapseSave=1; |
| 110 |
method.MacGregorMultiSave=1; |
| 111 |
method.MacGregorSave=1; |
| 112 |
method.dt=dt; |
| 113 |
|
| 114 |
moduleSequence=[1:8]; |
| 115 |
|
| 116 |
global ANdt ARAttenuation TMoutput OMEoutput ... |
| 117 |
DRNLoutput IHC_cilia_output IHCrestingCiliaCond IHCrestingV... |
| 118 |
IHCoutput ANprobRateOutput ANoutput savePavailable tauCas ... |
| 119 |
CNoutput ICoutput ICmembraneOutput ICfiberTypeRates MOCattenuation |
| 120 |
|
| 121 |
AN_spikesOrProbability='spikes'; |
| 122 |
AN_spikesOrProbability='probability'; |
| 123 |
MAPparamsName='Normal'; |
| 124 |
|
| 125 |
MAP1_14(inputSignal, 1/dt, targetFrequency, ... |
| 126 |
MAPparamsName, AN_spikesOrProbability); |
| 127 |
|
| 128 |
% RP |
| 129 |
IHC_RPData=IHC_cilia_output; |
| 130 |
IHC_RPData=IHCoutput(targetChannelNo,:); |
| 131 |
IHC_RP_peak(levelNo,freqNo)=max(IHC_RPData(toneStartptr:toneEndptr)); |
| 132 |
IHC_RP_min(levelNo,freqNo)=min(IHC_RPData(toneStartptr:toneEndptr)); |
| 133 |
IHC_RP_dc(levelNo,freqNo)=mean(IHC_RPData(toneStartptr:toneEndptr)); |
| 134 |
|
| 135 |
% AN next |
| 136 |
AN_IHCsynapseAllData=ANoutput; |
| 137 |
method.PSTHbinWidth=0.001; |
| 138 |
|
| 139 |
nTaus=length(tauCas); |
| 140 |
numANfibers=size(ANoutput,1); |
| 141 |
numLSRfibers=numANfibers/nTaus; |
| 142 |
|
| 143 |
%LSR (same as HSR if no LSR fibers present) |
| 144 |
channelPtr1=(targetChannelNo-1)*numANfibers+1; |
| 145 |
channelPtr2=channelPtr1+numANfibers-1; |
| 146 |
LSRspikes=AN_IHCsynapseAllData(channelPtr1:channelPtr2,:); |
| 147 |
method.dt=method.AN_IHCsynapsedt; |
| 148 |
PSTH=UTIL_PSTHmaker(LSRspikes, method); |
| 149 |
PSTH=sum(PSTH,1); % sum across fibers (HSR only) |
| 150 |
PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1; |
| 151 |
PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1; |
| 152 |
PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1; |
| 153 |
AN_LSRonset(levelNo,freqNo)=max(max(PSTH))/(method.PSTHbinWidth*method.numANfibers); |
| 154 |
AN_LSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr))/(method.numANfibers*toneDuration/2); |
| 155 |
|
| 156 |
% HSR |
| 157 |
channelPtr1=numLSRfibers+(targetChannelNo-1)*method.numANfibers+1; |
| 158 |
channelPtr2=channelPtr1+method.numANfibers-1; |
| 159 |
HSRspikes=AN_IHCsynapseAllData(channelPtr1:channelPtr2,:); |
| 160 |
method.dt=method.AN_IHCsynapsedt; |
| 161 |
PSTH=UTIL_PSTHmaker(HSRspikes, method); |
| 162 |
PSTH=sum(PSTH,1); % sum across fibers (HSR only) |
| 163 |
PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1; |
| 164 |
PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1; |
| 165 |
PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1; |
| 166 |
AN_HSRonset(levelNo,freqNo)=max(max(PSTH))/(method.PSTHbinWidth*method.numANfibers); |
| 167 |
AN_HSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr))/(method.numANfibers*toneDuration/2); |
| 168 |
[cvANHSR, cvTimes, allTimeStamps, allISIs]= UTIL_CV(HSRspikes, method.AN_IHCsynapsedt); |
| 169 |
|
| 170 |
PSTHplotCount=PSTHplotCount+1; |
| 171 |
if doReceptiveFields % receptive field for HSR only |
| 172 |
figure(14), set(gcf,'name','AN') |
| 173 |
plotReceptiveFields(method, PSTH, PSTHplotCount, levels, frequencies) |
| 174 |
ylim([0 method.numANfibers]) |
| 175 |
xlabel(['CV= ' num2str(max(cvANHSR),'%4.2f')],'fontsize',8) |
| 176 |
end % doReceptiveFields |
| 177 |
|
| 178 |
% CN |
| 179 |
MacGregorMultiAllData=method.MacGregorMultiData; |
| 180 |
numLSRfibers=method.McGMultinNeuronsPerBF*length(method.nonlinCF)* (nTaus-1); |
| 181 |
|
| 182 |
%LSR (same as HSR if no LSR fibers present) |
| 183 |
channelPtr1=(targetChannelNo-1)*method.McGMultinNeuronsPerBF+1; |
| 184 |
channelPtr2=channelPtr1+method.McGMultinNeuronsPerBF-1; |
| 185 |
MacGregorMultiLSRspikes=MacGregorMultiAllData(channelPtr1:channelPtr2,:); |
| 186 |
method.dt=method.MacGregorMultidt; |
| 187 |
PSTH=UTIL_PSTHmaker(MacGregorMultiLSRspikes, method); |
| 188 |
PSTH=sum(PSTH,1); % sum across fibers (HSR only) |
| 189 |
PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1; |
| 190 |
PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1; |
| 191 |
PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1; |
| 192 |
CNLSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr)); |
| 193 |
CNLSRsaturated(levelNo,freqNo)=CNLSRsaturated(levelNo,freqNo)... |
| 194 |
/((toneDuration/2)*method.McGMultinNeuronsPerBF); |
| 195 |
|
| 196 |
%HSR |
| 197 |
channelPtr1=numLSRfibers+(targetChannelNo-1)*method.McGMultinNeuronsPerBF+1; |
| 198 |
channelPtr2=channelPtr1+method.McGMultinNeuronsPerBF-1; |
| 199 |
MacGregorMultiHSRspikes=MacGregorMultiAllData(channelPtr1:channelPtr2,:); |
| 200 |
method.dt=method.MacGregorMultidt; |
| 201 |
PSTH=UTIL_PSTHmaker(MacGregorMultiHSRspikes, method); |
| 202 |
PSTH=sum(PSTH,1); % sum across fibers (HSR only) |
| 203 |
PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1; |
| 204 |
PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1; |
| 205 |
PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1; |
| 206 |
CNHSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr)); |
| 207 |
CNHSRsaturated(levelNo,freqNo)=CNHSRsaturated(levelNo,freqNo)... |
| 208 |
/((toneDuration/2)*method.McGMultinNeuronsPerBF); |
| 209 |
[cvMMHSR, cvTimes, allTimeStamps, allISIs]= UTIL_CV(MacGregorMultiHSRspikes, method.MacGregorMultidt); |
| 210 |
|
| 211 |
if doReceptiveFields % receptive field |
| 212 |
figure(15), set(gcf,'name','CN HSR input') |
| 213 |
plotReceptiveFields(method, PSTH, PSTHplotCount, levels, frequencies) |
| 214 |
ylim([0 method.McGMultinNeuronsPerBF]) |
| 215 |
xlabel(['CV= ' num2str(max(cvMMHSR),'%4.2f')],'fontsize',8) |
| 216 |
end |
| 217 |
|
| 218 |
MacGregorAllData=method.MacGregorData; |
| 219 |
numLSRfibers=length(method.nonlinCF)* (nTaus-1); |
| 220 |
|
| 221 |
%LSR (same as HSR if no LSR fibers present) |
| 222 |
channelPtr1=targetChannelNo; |
| 223 |
MacGregorLSR=MacGregorAllData(channelPtr1,:); |
| 224 |
method.dt=method.MacGregordt; |
| 225 |
PSTH=UTIL_PSTHmaker(MacGregorLSR, method); |
| 226 |
PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1; |
| 227 |
PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1; |
| 228 |
PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1; |
| 229 |
ICLSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr)); |
| 230 |
ICLSRsaturated(levelNo,freqNo)=ICLSRsaturated(levelNo,freqNo)/(toneDuration/2); |
| 231 |
|
| 232 |
%LSR (same as HSR if no LSR fibers present) |
| 233 |
channelPtr1=numLSRfibers+targetChannelNo; |
| 234 |
MacGregorHSR=MacGregorAllData(channelPtr1,:); |
| 235 |
method.dt=method.MacGregordt; |
| 236 |
PSTH=UTIL_PSTHmaker(MacGregorHSR, method); |
| 237 |
PSTHStartptr=round(silenceDuration/method.PSTHbinWidth)+1; |
| 238 |
PSTHMidptr=PSTHStartptr+round(toneDuration/(2*method.PSTHbinWidth)) -1; |
| 239 |
PSTHEndptr=PSTHStartptr+round(toneDuration/method.PSTHbinWidth) -1; |
| 240 |
ICHSRsaturated(levelNo,freqNo)=sum(PSTH(PSTHMidptr:PSTHEndptr)); |
| 241 |
ICHSRsaturated(levelNo,freqNo)=ICHSRsaturated(levelNo,freqNo)/(toneDuration/2); |
| 242 |
[cvICHSR, cvTimes, allTimeStamps, allISIs]= UTIL_CV(MacGregorHSR, method.MacGregordt); |
| 243 |
|
| 244 |
% if doReceptiveFields % receptive field |
| 245 |
% figure(16), set(gcf,'name','IC HSR input') |
| 246 |
% plotReceptiveFields(method, PSTH, PSTHplotCount, levels, frequencies) |
| 247 |
% ylim([0 method.McGMultinNeuronsPerBF]) |
| 248 |
% xlabel(['CV= ' num2str(max(cvICHSR),'%4.2f')],'fontsize',8) |
| 249 |
% end |
| 250 |
end % frequency |
| 251 |
end % level |
| 252 |
fprintf('\n')
|
| 253 |
toneDuration=2; |
| 254 |
rampDuration=0.004; |
| 255 |
silenceDuration=.02; |
| 256 |
nRepeats=200; % no. of AN fibers |
| 257 |
fprintf('toneDuration %6.3f\n', toneDuration)
|
| 258 |
fprintf(' %6.0f AN fibers (repeats)\n', nRepeats)
|
| 259 |
fprintf('levels')
|
| 260 |
fprintf('%6.2f\t', levels)
|
| 261 |
fprintf('\n')
|
| 262 |
|
| 263 |
|
| 264 |
% ---------------------------------------------------------- display parameters |
| 265 |
disp(['parameter file was: ' experiment.name]) |
| 266 |
fprintf('\n')
|
| 267 |
UTIL_showStruct(IHC_VResp_VivoParams, 'IHC_cilia_RPParams') |
| 268 |
UTIL_showStruct(IHCpreSynapseParams, 'IHCpreSynapseParams') |
| 269 |
UTIL_showStruct(AN_IHCsynapseParams, 'AN_IHCsynapseParams') |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
function plotReceptiveFields(method, PSTH, PSTHplotCount, levels, frequencies) |
| 274 |
|
| 275 |
% show PSTH for each level/frequency combination |
| 276 |
nLevels=length(levels); |
| 277 |
nFrequencies=length(frequencies); |
| 278 |
|
| 279 |
PSTHtime=method.PSTHbinWidth:method.PSTHbinWidth:method.PSTHbinWidth*length(PSTH); |
| 280 |
subplot(nLevels,nFrequencies,PSTHplotCount) |
| 281 |
bar(PSTHtime, PSTH) |
| 282 |
xlim([0 max(PSTHtime)]) |
| 283 |
% write axis labels only at left and bottom |
| 284 |
if PSTHplotCount< (nLevels-1) * nFrequencies+1 |
| 285 |
set(gca,'xticklabel',[]) |
| 286 |
end |
| 287 |
if ~isequal(mod(PSTHplotCount,nFrequencies),1) |
| 288 |
set(gca,'yticklabel',[]) |
| 289 |
else |
| 290 |
ylabel([num2str(levels(round(PSTHplotCount/nFrequencies) +1)) ' dB']) |
| 291 |
end |
| 292 |
% add titles only on top row |
| 293 |
if PSTHplotCount<=nFrequencies |
| 294 |
title([num2str(frequencies(PSTHplotCount)) ' Hz']) |
| 295 |
end |