Mercurial > hg > ape
comparison listeningTest/multiComp/multiComp.m @ 0:4fd284285159
Adding listening test plus some helpful functions and scripts.
author | Brecht <b.deman@qmul.ac.uk> |
---|---|
date | Thu, 24 Apr 2014 23:53:31 +0100 |
parents | |
children | 5e72201496c8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4fd284285159 |
---|---|
1 function multiComp(sesDat) | |
2 | |
3 % multiple comparison test on several 1D scale | |
4 % see readMultiComp for a description of specifications | |
5 | |
6 UIControl_FontSize_bak = get(0, 'DefaultUIControlFontSize'); | |
7 set(0, 'DefaultUIControlFontSize', 20); | |
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
9 % copy useful variables | |
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | |
12 reREAD=sesDat.reREAD; | |
13 noTst=sesDat.noTst; | |
14 nbTst=sesDat.nbTst; | |
15 | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 % read the test file | |
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
19 test=readMultiComp(sesDat.tstDat{noTst}.tstFile); | |
20 | |
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
22 % Set the test screen | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 | |
25 hf=figure; | |
26 set(hf,'units','normalized'); | |
27 set(hf,'position',[0.1 .15 .80 1.0]); % TODO make automatic % [left, bottom, width, height] | |
28 set(hf,'closereq',[]); | |
29 set(hf,'numbertitle','off'); | |
30 set(hf,'menubar','none'); | |
31 if (nbTst-noTst)/2 > 1 | |
32 titlestr = sprintf('%d screens left',(nbTst-noTst)/2); | |
33 else if (nbTst-noTst) > 1 | |
34 titlestr = 'One screen left after this'; | |
35 else | |
36 titlestr = 'Last screen'; | |
37 end | |
38 end | |
39 set(hf,'name',titlestr); | |
40 set(gca,'position',[0 0 1 1]); | |
41 axis([0 1 0 1]); | |
42 set(gca,'yticklabel',[]); | |
43 set(gca,'xticklabel',[]); | |
44 grid off; | |
45 hp=gca; | |
46 | |
47 set(hp,'color',[.7 .7 .7]); % gray background | |
48 | |
49 % Figure-event properties | |
50 set(hf,'windowbuttonmotionfcn',sprintf('MmoveW(%d)',hf)); | |
51 set(hf,'keypressfcn',sprintf('TpushKey(%d)',hf)); | |
52 | |
53 % Define Scales and SonIcons | |
54 | |
55 nbScale=length(test.scale); | |
56 dY=1/(nbScale+3); % vertical space for each scale+text (used to be +1, now +3) | |
57 dX=1; | |
58 dyy=dY/2; % vertical space for scale and text | |
59 dxx=1/30; % vertical margins of the scale | |
60 small=dyy/10; | |
61 | |
62 % create sonicons | |
63 nbSnd=test.nbComb; | |
64 | |
65 % RANDOM POSITIONS and ALREADY PLAYED | |
66 if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') | |
67 permVec = sesDat.tstDat{noTst}.rsl.permVec; | |
68 playVec = sesDat.tstDat{noTst}.rsl.playVec; | |
69 else | |
70 permVec = randperm(nbSnd); | |
71 playVec = zeros(nbSnd,1); | |
72 end | |
73 | |
74 fidInd=['responses/' sesDat.id,'_',sesDat.sesScript]; % print permutation in response log | |
75 fid=fopen(fidInd,'a'); | |
76 fprintf(fid,'\n%s\n', 'Random permutation mapping (comments): '); | |
77 for noSnd = 1: nbSnd | |
78 fprintf(fid,'%d ', permVec(noSnd)); | |
79 end | |
80 fprintf(fid,'\n%s\n', ' '); | |
81 | |
82 | |
83 for noScale=1:nbScale | |
84 | |
85 y=1-noScale*dY; % bottom line | |
86 dyt=dyy; % was 3/2* | |
87 %display text | |
88 h='horizontalAlignment'; | |
89 v='verticalAlignment'; | |
90 text(.5,y+dyt,test.scale(noScale).name,h,'center',v,'bottom', 'FontSize', 24); % Scale name | |
91 % Level names | |
92 text(0+small,y+dyt,test.scale(noScale).level{1},h,'left',v,'bottom', 'FontSize', 24); % MINIMUM | |
93 text(1-small,y+dyt,test.scale(noScale).level{3},h,'right',v,'bottom', 'FontSize', 24); % MAXIMUM | |
94 | |
95 % Display 1D rules | |
96 y0=y; | |
97 y1=y+dyy; | |
98 hold on; | |
99 fill([dxx dxx 1-dxx 1-dxx],[y1 y0 y0 y1],[.8 .8 .8]); | |
100 | |
101 | |
102 for noSnd=1:nbSnd | |
103 | |
104 dl=(1-2*dxx)/5; %BDM used to be /nbsnd | |
105 xI=dl*noSnd/2; | |
106 dxI=dl/10; % width of a sonicon | |
107 posIc=[xI y+small dxI dyy-2*small]; | |
108 | |
109 % position the icons on the default position | |
110 % check if the individual data contains already some past results | |
111 % | |
112 if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') | |
113 posComb=sesDat.tstDat{noTst}.rsl.mat(noScale,noSnd); | |
114 else | |
115 posComb=test.posComb(noSnd,noScale); | |
116 fidInd=['responses/' sesDat.id,'_',sesDat.sesScript]; % print initial placing | |
117 fid=fopen(fidInd,'a'); | |
118 fprintf(fid,'%f ', test.posComb(noSnd,noScale)); | |
119 end | |
120 | |
121 % Calculate Icon position relative to the screen units | |
122 minx=test.scale(noScale).minn; | |
123 maxx=test.scale(noScale).maxx; | |
124 a=(1-2*dxx)/(maxx-minx); | |
125 b=dxx-a*minx; | |
126 posIc(1)=posComb*a+b-dxI/2; | |
127 | |
128 % set handles | |
129 hIc=uicontrol('style','text','string',num2str(permVec(noSnd)),'units','normalized','position',posIc); % changed by Brecht: randperm | |
130 set(hIc,'buttondownfcn',sprintf('MpushIc(%d)',hf)); | |
131 set(hIc,'backgroundcolor', [.6 .9 .6]); % set colour to green | |
132 | |
133 %%%%%%%%%%%%%%%%%%% ENABLING | |
134 set(hIc,'enable','inactive'); | |
135 set(hIc,'tag','sonicon'); | |
136 | |
137 sndId=test.comb(noSnd); | |
138 set(hIc,'userdata',sndId); | |
139 hIcon(noScale,noSnd)=hIc; | |
140 | |
141 end | |
142 fprintf(fid,'%s\n', ' '); | |
143 %shIc= set(hIc); %??? what is this here for? suppress output. | |
144 | |
145 % set the un-movable references | |
146 nbRef=length(test.sndRef); | |
147 for noRef=1:nbRef | |
148 sndRef=test.sndRef(noRef); | |
149 %%%%%%%%%%%%%%%%%%%%%% ENABLING... | |
150 set(hIcon(noScale,sndRef),'enable','off'); %% for MAC! may be 'off' for PC?? | |
151 set(hIcon(noScale,sndRef),'string','ref'); | |
152 end | |
153 | |
154 | |
155 end | |
156 | |
157 | |
158 % create Comments | |
159 hcom = struct([]); % create empty struct for comments | |
160 if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') | |
161 for noSnd = 1:nbSnd % a comment per sample | |
162 posCom=[dxx 6*dY/(nbSnd+2)+3*dY/(nbSnd+2)*(nbSnd - noSnd) 10/15 3*dY/(nbSnd+2)-small]; % [left, bottom, width, height] | |
163 commentstr = sesDat.tstDat{noTst}.rsl.hcom{noSnd}; | |
164 hcom{noSnd} = uicontrol('style','edit','max',2,'string',commentstr, ... | |
165 'units','normalized','position',posCom, ... | |
166 'HorizontalAlignment', 'left'); | |
167 end | |
168 | |
169 posCom=[dxx small 10/15 6*dY/(nbSnd+2)-small]; % general comments | |
170 commentstr = sesDat.tstDat{noTst}.rsl.gcom; | |
171 gcom=uicontrol('style','edit','max',2,'string',commentstr, ... | |
172 'units','normalized','position',posCom, 'HorizontalAlignment', 'left'); | |
173 | |
174 | |
175 else % recall comments | |
176 for noSnd = 1:nbSnd % a comment per sample | |
177 posCom=[dxx 6*dY/(nbSnd+2)+3*dY/(nbSnd+2)*(nbSnd - noSnd) 10/15 3*dY/(nbSnd+2)-small]; % [left, bottom, width, height] | |
178 commentstr = sprintf('%d: ', noSnd); | |
179 hcom{noSnd} = uicontrol('style','edit','max',2,'string',commentstr, ... | |
180 'units','normalized','position',posCom, ... | |
181 'HorizontalAlignment', 'left'); | |
182 end | |
183 | |
184 posCom=[dxx small 10/15 6*dY/(nbSnd+2)-small]; % general comments | |
185 commentstr = sprintf('%s: ', 'General comments'); | |
186 gcom=uicontrol('style','edit','max',2,'string',commentstr, ... | |
187 'units','normalized','position',posCom, 'HorizontalAlignment', 'left'); | |
188 | |
189 end | |
190 | |
191 | |
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
193 % "Stop audio" button | |
194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
195 | |
196 posFin=[11/15 3*dY/2 3/15 3*(dY-small)/2]; % [left, bottom, width, height] | |
197 hFin=uicontrol('style','pushbutton','string','Stop audio','units','normalized','position',posFin); | |
198 set(hFin,'callback',sprintf('MpushIc(%d)',hf)); | |
199 | |
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
201 % "Finished" button | |
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
203 | |
204 posFin=[11/15 small 3/15 3*(dY-small)/2]; % [left, bottom, width, height] | |
205 hFin=uicontrol('style','pushbutton','string','Finished','units','normalized','position',posFin); | |
206 set(hFin,'callback',sprintf('endMultiComp(%d)',hf)); | |
207 | |
208 | |
209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
210 % Test timer | |
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
212 dat.t0=clock; | |
213 | |
214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
215 % Send useful datas | |
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
217 dat.dxx = dxx; %? | |
218 dat.dxI = dxI; %? | |
219 dat.hf = hf; | |
220 dat.hcom = hcom; % individual comments | |
221 dat.gcom = gcom; % general comments | |
222 dat.hIcon = hIcon; | |
223 dat.drag = 0; | |
224 dat.test = test; | |
225 dat.sesDat = sesDat; | |
226 dat.playVec = playVec; | |
227 dat.permVec = permVec; | |
228 dat.nbScale = nbScale; | |
229 dat.nbSnd = nbSnd; | |
230 set(hf,'userdata',dat) | |
231 | |
232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
233 % clean up | |
234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
235 clear all; |