Mercurial > hg > map
comparison testPrograms/MAPtwoToneDemo.m @ 38:c2204b18f4a2 tip
End nov big change
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Mon, 28 Nov 2011 13:34:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
37:771a643d5c29 | 38:c2204b18f4a2 |
---|---|
1 % function MAPtwoToneDemo | |
2 % | |
3 % Demonstration of two-tone suppression in the AN using a | |
4 % F1 tone suppressed by a 1.5*F1 kHz tone | |
5 % | |
6 | |
7 global ANprobRateOutput DRNLoutput | |
8 dbstop if error | |
9 restorePath=path; | |
10 addpath (['..' filesep 'MAP'], ['..' filesep 'wavFileStore'], ... | |
11 ['..' filesep 'utilities']) | |
12 figure(5), clf | |
13 | |
14 disp('') | |
15 primaryToneFrequency=2000; | |
16 | |
17 probedBs=[-100 20 :20: 90]; | |
18 nProbeLevels=length(probedBs); | |
19 | |
20 % disp(['F1 F1 level= ' num2str([primaryToneFrequency probedB])]) | |
21 | |
22 suppressorLevels=0:10:80; | |
23 suppressorLevels=0:10:80; | |
24 | |
25 lowestBF=250; highestBF= 8000; numChannels=21; | |
26 BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels)); | |
27 | |
28 suppressorFrequencies=BFlist; | |
29 BFchannel=find(BFlist==primaryToneFrequency); | |
30 | |
31 sampleRate= 40000; % Hz (higher sample rate needed for BF>8000 Hz) | |
32 dt=1/sampleRate; % seconds | |
33 | |
34 duration=.050; % seconds | |
35 tone2Duration=duration/2; % s | |
36 startSilenceDuration=0.010; | |
37 startSilence=... | |
38 zeros(1,startSilenceDuration*sampleRate); | |
39 suppressorStartsPTR=... | |
40 round((startSilenceDuration+duration/2)*sampleRate); | |
41 | |
42 probedBCount=0; | |
43 for probedB=probedBs | |
44 probedBCount=probedBCount+1; | |
45 | |
46 peakResponse= zeros(length(suppressorLevels),length(suppressorFrequencies)); | |
47 suppFreqCount=0; | |
48 for suppressorFrequency=suppressorFrequencies | |
49 suppFreqCount=suppFreqCount+1; | |
50 | |
51 suppressorLevelCount=0; | |
52 for suppressorDB=suppressorLevels | |
53 suppressorLevelCount=suppressorLevelCount+1; | |
54 | |
55 % primary + suppressor | |
56 primaryLevelDB=probedB; | |
57 suppressorLevelDB=suppressorDB; | |
58 | |
59 | |
60 % primary BF tone | |
61 time1=dt: dt: duration; | |
62 amp=10^(primaryLevelDB/20)*28e-6; | |
63 inputSignal=amp*sin(2*pi*primaryToneFrequency*time1); | |
64 rampDuration=.005; rampTime=dt:dt:rampDuration; | |
65 ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time1)-length(rampTime))]; | |
66 inputSignal=inputSignal.*ramp; | |
67 inputSignal=inputSignal.*fliplr(ramp); | |
68 | |
69 % suppressor | |
70 time2= dt: dt: tone2Duration; | |
71 % B: tone on | |
72 amp=10^(suppressorLevelDB/20)*28e-6; | |
73 inputSignal2=amp*sin(2*pi*suppressorFrequency*time2); | |
74 rampDuration=.005; rampTime=dt:dt:rampDuration; | |
75 ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ones(1,length(time2)-length(rampTime))]; | |
76 inputSignal2=inputSignal2.*ramp; | |
77 inputSignal2=inputSignal2.*fliplr(ramp); | |
78 % A: initial silence (delay to suppressor) | |
79 silence=zeros(1,length(time2)); | |
80 inputSignal2=[silence inputSignal2]; | |
81 | |
82 % add tone and suppressor components | |
83 inputSignal=inputSignal+inputSignal2; | |
84 | |
85 inputSignal=... | |
86 [startSilence inputSignal ]; | |
87 | |
88 % run MAP | |
89 MAPparamsName='Normal'; | |
90 AN_spikesOrProbability='probability'; | |
91 paramChanges={'IHCpreSynapseParams.tauCa=80e-6;'}; | |
92 MAP1_14(inputSignal, sampleRate, BFlist, ... | |
93 MAPparamsName, AN_spikesOrProbability, paramChanges); | |
94 | |
95 response=ANprobRateOutput; | |
96 peakResponse(suppressorLevelCount,suppFreqCount)=... | |
97 mean(response(BFchannel,suppressorStartsPTR:end)); | |
98 disp(['F2 level= ', num2str([suppressorFrequency suppressorDB ... | |
99 peakResponse(suppressorLevelCount,suppFreqCount)])]) | |
100 | |
101 | |
102 %% make movie | |
103 figure(6), subplot(4,1,2) | |
104 axis tight | |
105 set(gca,'nextplot','replacechildren'); | |
106 plot(dt:dt:dt*length(inputSignal), inputSignal, 'k') | |
107 title('probe - suppressor') | |
108 ylim([-.5 .5]) | |
109 | |
110 figure(6), subplot(2,1,2) | |
111 PSTHbinWidth=0.010; | |
112 PSTH= UTIL_PSTHmakerb(... | |
113 response, dt, PSTHbinWidth); | |
114 [nY nX]=size(PSTH); | |
115 time=PSTHbinWidth*(0:nX-1); | |
116 surf(time, BFlist, PSTH) | |
117 zlim([0 500]), | |
118 caxis([0 500]) | |
119 shading interp | |
120 colormap(jet) | |
121 set(gca, 'yScale','log') | |
122 xlim([0 max(time)+dt]) | |
123 ylim([0 max(BFlist)]) | |
124 view([0 90]) % view([-8 68]) | |
125 title('probe - suppressor') | |
126 pause(0.05) | |
127 end | |
128 end | |
129 | |
130 %% plot matrix | |
131 | |
132 peakResponse=peakResponse/peakResponse(1,1); | |
133 | |
134 figure(5), subplot(2,nProbeLevels, probedBCount) | |
135 surf(suppressorFrequencies,suppressorLevels,peakResponse) | |
136 shading interp | |
137 view([0 90]) | |
138 set(gca,'Xscale','log') | |
139 xlim([min(suppressorFrequencies) max(suppressorFrequencies)]) | |
140 set(gca,'Xtick', [1000 4000],'xticklabel',{'1000', '4000'}) | |
141 ylim([min(suppressorLevels) max(suppressorLevels)]) | |
142 | |
143 subplot(2,nProbeLevels,nProbeLevels+probedBCount) | |
144 contour(suppressorFrequencies,suppressorLevels,peakResponse, ... | |
145 [.1:.1:.9 1.1] ) | |
146 set(gca,'Xscale','log') | |
147 set(gca,'Xtick', [1000 4000],'xticklabel',{'1000', '4000'}) | |
148 set(gcf, 'name',['primaryToneFrequency= ' num2str(primaryToneFrequency)]) | |
149 title([num2str(probedB) ' dB']) | |
150 end | |
151 | |
152 path=restorePath; |