Mercurial > hg > map
comparison Copy_of_multithreshold 1.46/MAPmodel.m @ 28:02aa9826efe0
mainly multiThreshold
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Fri, 01 Jul 2011 12:59:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
27:d4a7675b0413 | 28:02aa9826efe0 |
---|---|
1 function [modelResponse, MacGregorResponse]=MAPmodel( MAPplot, method) | |
2 | |
3 global experiment stimulusParameters audio withinRuns | |
4 global outerMiddleEarParams DRNLParams AN_IHCsynapseParams | |
5 | |
6 savePath=path; | |
7 addpath(['..' filesep 'MAP'], ['..' filesep 'utilities']) | |
8 modelResponse=[]; | |
9 MacGregorResponse=[]; | |
10 | |
11 % mono only (column vector) | |
12 audio=audio(:,1)'; | |
13 | |
14 % if stop button pressed earlier | |
15 if experiment.stop, return, end | |
16 | |
17 % -------------------------------------------------------------- run Model | |
18 MAPparamsName=experiment.name; | |
19 showPlotsAndDetails=experiment.MAPplot; | |
20 AN_spikesOrProbability='spikes'; | |
21 | |
22 % [response, method]=MAPsequenceSeg(audio, method, 1:8); | |
23 global ICoutput ANdt | |
24 MAP1_14(audio, 1/method.dt, method.nonlinCF,... | |
25 MAPparamsName, AN_spikesOrProbability); | |
26 | |
27 if showPlotsAndDetails | |
28 options.printModelParameters=0; | |
29 options.showModelOutput=1; | |
30 options.printFiringRates=1; | |
31 options.showACF=0; | |
32 options.showEfferent=1; | |
33 UTIL_showMAP(options) | |
34 end | |
35 | |
36 % No response, probably caused by hitting 'stop' button | |
37 if isempty(ICoutput), return, end | |
38 | |
39 % MacGregor response is the sum total of all final stage spiking | |
40 MacGregorResponse= sum(ICoutput,1); % use IC | |
41 | |
42 % ---------------------------------------------------------- end model run | |
43 | |
44 dt=ANdt; | |
45 time=dt:dt:dt*length(MacGregorResponse); | |
46 | |
47 % group delay on unit response | |
48 MacGonsetDelay= 0.004; | |
49 MacGoffsetDelay= 0.022; | |
50 | |
51 % now find the response of the MacGregor model during the target presentation + group delay | |
52 switch experiment.threshEstMethod | |
53 case {'2I2AFC++', '2I2AFC+++'} | |
54 idx= time>stimulusParameters.testTargetBegins+MacGonsetDelay ... | |
55 & time<stimulusParameters.testTargetEnds+MacGoffsetDelay; | |
56 nSpikesTrueWindow=sum(MacGregorResponse(:,idx)); | |
57 idx=find(time>stimulusParameters.testNonTargetBegins+MacGonsetDelay ... | |
58 & time<stimulusParameters.testNonTargetEnds+MacGoffsetDelay); | |
59 nSpikesFalseWindow=sum(MacGregorResponse(:,idx)); | |
60 % nSpikesDuringTarget is +ve when more spikes are found | |
61 % in the target window | |
62 difference= nSpikesTrueWindow-nSpikesFalseWindow; | |
63 | |
64 if difference>0 | |
65 % hit | |
66 nSpikesDuringTarget=experiment.MacGThreshold+1; | |
67 elseif difference<0 | |
68 % miss (wrong choice) | |
69 nSpikesDuringTarget=experiment.MacGThreshold-1; | |
70 else | |
71 if rand>0.5 | |
72 % hit (random choice) | |
73 nSpikesDuringTarget=experiment.MacGThreshold+1; | |
74 else | |
75 % miss (random choice) | |
76 nSpikesDuringTarget=experiment.MacGThreshold-1; | |
77 end | |
78 end | |
79 disp(['level target dummy decision: ' ... | |
80 num2str([withinRuns.variableValue nSpikesTrueWindow ... | |
81 nSpikesFalseWindow nSpikesDuringTarget], '%4.0f') ] ) | |
82 | |
83 otherwise | |
84 % idx=find(time>stimulusParameters.testTargetBegins+MacGonsetDelay ... | |
85 % & time<stimulusParameters.testTargetEnds+MacGoffsetDelay); | |
86 % no delay at onset | |
87 idx=find(time>stimulusParameters.testTargetBegins +MacGonsetDelay... | |
88 & time<stimulusParameters.testTargetEnds+MacGoffsetDelay); | |
89 nSpikesDuringTarget=sum(MacGregorResponse(:,idx)); | |
90 | |
91 % find(MacGregorResponse)*dt-stimulusParameters.stimulusDelay | |
92 timeX=time(idx); | |
93 end | |
94 | |
95 % now find the response of the MacGregor model at the end of the masker | |
96 idx2=find(time>stimulusParameters.testTargetBegins-0.02 ... | |
97 & time<stimulusParameters.testTargetBegins); | |
98 if ~isempty(idx2) | |
99 maskerRate=mean(mean(MacGregorResponse(idx2))); | |
100 else | |
101 %e.g. no masker | |
102 maskerRate=0; | |
103 end | |
104 | |
105 if experiment.MAPplot | |
106 % add vertical lines to indicate target region | |
107 figure(99), subplot(6,1,6) | |
108 hold on | |
109 yL=get(gca,'YLim'); | |
110 plot([stimulusParameters.testTargetBegins + MacGonsetDelay ... | |
111 stimulusParameters.testTargetBegins + MacGonsetDelay],yL,'r') | |
112 plot([stimulusParameters.testTargetEnds + MacGoffsetDelay ... | |
113 stimulusParameters.testTargetEnds + MacGoffsetDelay],yL,'r') | |
114 end | |
115 | |
116 % specify unambiguous response | |
117 switch experiment.paradigm | |
118 case 'gapDetection' | |
119 gapResponse=(maskerRate-nSpikesDuringTarget)/maskerRate; | |
120 if gapResponse>0.2 | |
121 modelResponse=2; % gap detected | |
122 else | |
123 modelResponse=1; % gap not detected | |
124 end | |
125 [nSpikesDuringTarget maskerRate gapResponse modelResponse] | |
126 figure(22), plot(timeX,earObject(idx)) | |
127 otherwise | |
128 if nSpikesDuringTarget>experiment.MacGThreshold | |
129 modelResponse=2; % stimulus detected | |
130 else | |
131 modelResponse=1; % nothing heard (default) | |
132 end | |
133 end | |
134 | |
135 | |
136 path(savePath) |