annotate listeningTest/pairComp/pairComp.m @ 15:24be5e9ce25b tip

Update README
author Brecht De Man <brecht.deman@bcu.ac.uk>
date Thu, 20 Sep 2018 12:23:20 +0200
parents 5e72201496c8
children
rev   line source
b@0 1 function pairComp(sesDat)
b@0 2 % a pair comparison test with various possible quesions (preference e.g.) and comments
b@0 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 4 %
b@0 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 6
b@0 7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 8 % copy useful variables
b@0 9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 10
b@0 11 UIControl_FontSize_bak = get(0, 'DefaultUIControlFontSize');
b@0 12 set(0, 'DefaultUIControlFontSize', 28);
b@0 13
b@0 14 reREAD=sesDat.reREAD;
b@0 15 noTst=sesDat.noTst;
b@0 16 nbTst=sesDat.nbTst;
b@0 17 if reREAD
b@0 18 rsl=sesDat.tstDat{noTst}.rsl;
b@0 19 end
b@0 20
b@0 21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 22 % read the test file
b@0 23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 24 test=readPairComp(sesDat.tstDat{noTst}.tstFile);
b@0 25
b@0 26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 27 % Set the test screen
b@0 28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 29
b@0 30
b@0 31 hf=figure;
b@0 32 set(hf,'units','normalized');
b@0 33 %set(hf,'position',[0 .5 1 .4]);
b@0 34 set(hf,'position',[0 .05 .55 .75]);
b@0 35 set(hf,'closereq',''); %%%
b@0 36 set(hf,'numbertitle','off');
b@0 37 set(hf,'menubar','none');
b@0 38 set(hf,'name',sprintf('pair #1/%d',test.nbComb));
b@0 39 set(gca,'position',[0 0 1 1]);
b@0 40 axis([0 1 0 1]);
b@0 41 set(gca,'yticklabel','');
b@0 42 set(gca,'xticklabel','');
b@0 43 grid off;
b@0 44 hp=gca;
b@0 45
b@0 46 butCol=[.6 .9 .6]; % by default pale green
b@0 47 set(hp,'color',[.7 .7 .7]); % gray background
b@0 48
b@0 49 % Figure-event properties
b@0 50
b@0 51 set(gcf,'KeyPressFcn','pairKey')
b@0 52
b@0 53 % Create the 3 frames
b@0 54
b@0 55 % set the upper frame
b@0 56
b@0 57 y1=.76;
b@0 58 y2=.75;
b@0 59 y3=.31;
b@0 60 y4=.3;
b@0 61 x1=0;
b@0 62 x2=.8;
b@0 63 x3=.81;
b@0 64
b@0 65 hold on
b@0 66
b@0 67 % sound frame
b@0 68 fill([x1 x1 1 1],[y1 1 1 y1],[.8 .8 1]);
b@0 69 % questions frames
b@0 70 fill([x1 x1 1 1],[y3 y2 y2 y3],[.7 .7 1]);
b@0 71 % comments and "finished" button frame
b@0 72 fill([x1 x1 1 1],[0 y4 y4 0],[.9 .9 .1]);
b@0 73
b@0 74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 75 % PUSH BUTTONS
b@0 76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 77
b@0 78 y=(1-y1);
b@0 79 yy=y/20;
b@0 80 h=y-2*yy;
b@0 81
b@0 82 x=(1-x1);
b@0 83 xx=(1-x1)/8;
b@0 84
b@0 85 wab=3*xx;
b@0 86 wstop=2*xx;
b@0 87 xa=xx/2;
b@0 88 xb=9/2*xx;
b@0 89 xstop=3*xx;
b@0 90
b@0 91 posA=[xa y1+yy wab h];
b@0 92 posB=[xb y1+yy wab h];
b@0 93 posStop=[xstop y1+yy wstop h];
b@0 94
b@0 95 ha=uicontrol('style','pushbutton','string','A','units','normalized','position',posA, 'FontSize', 56);
b@0 96 set(ha,'backgroundcolor',butCol);
b@2 97 set(ha,'callback',sprintf('PCpush(%d,1)',hf.Number));
b@0 98
b@0 99 if strcmp(computer,'PCWIN')
b@0 100 hStop=uicontrol('style','pushbutton','string','STOP','units','normalized','position',posStop, 'FontSize', 56);
b@2 101 set(hStop,'callback',sprintf('PCpush(%d,2)',hf.Number));
b@0 102 else
b@0 103 hStop='';
b@0 104 end
b@0 105
b@0 106 hb=uicontrol('style','pushbutton','string','B','units','normalized','position',posB, 'FontSize', 56);
b@0 107 set(hb,'backgroundcolor',butCol);
b@2 108 set(hb,'callback',sprintf('PCpush(%d,3)',hf.Number));
b@0 109
b@0 110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 111 % questions and scales
b@0 112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 113 if ~isfield(test,'nbScale')
b@0 114 test.nbScale=0;
b@0 115 test.scale='';
b@0 116 end
b@0 117 if ~isfield(test,'nbQuest')
b@0 118 test.nbQuest=0;
b@0 119 test.quest='';
b@0 120 end
b@0 121
b@0 122 test.hScale='';
b@0 123 test.hQuest='';
b@0 124
b@0 125 nbGUI=2*test.nbScale+test.nbQuest;
b@0 126
b@0 127 y=(y2-y3);
b@0 128 h=y/nbGUI;
b@0 129 hh=h/20;
b@0 130
b@0 131 x=(1-x1);
b@0 132 xx=(1-x1)/8;
b@0 133
b@0 134 noGUI=1;
b@0 135 % SCALES
b@0 136 for noScale=1:test.nbScale
b@0 137 s=test.scale(noScale);
b@0 138 Y1=y2-((2*noGUI-1)*h-hh);
b@0 139 %display text
b@0 140 ho='horizontalAlignment';
b@0 141 ve='verticalAlignment';
b@0 142 text((1-x1)/2,Y1,s.name,ho,'center',ve,'bottom'); % Scale name
b@0 143 % Level names
b@0 144 text(x1+xx,Y1,s.level{1},ho,'left',ve,'bottom');
b@0 145 text(1-xx,Y1,s.level{3},ho,'right',ve,'bottom');
b@0 146
b@0 147 Y2=Y1-h+hh;
b@0 148 posG=[xx Y2 x-2*xx h-2*hh];
b@0 149 hScale(noScale)=uicontrol('style','slider','units','normalized','position',posG,'min',s.minn,'max',s.maxx,'value',s.minn);
b@0 150 if reREAD
b@0 151 set(hScale(noScale),'value',rsl.scale(1,noScale));
b@0 152 end
b@0 153 noGUI=noGUI+1;
b@0 154 end
b@0 155
b@0 156 % QUESTIONS check boxes
b@0 157 for noQuest=1:test.nbQuest
b@0 158 noGUI=2*test.nbScale+noQuest;
b@0 159 posG=[xx y2-(noGUI*h-hh) x-2*xx h];
b@0 160 hQuest(noQuest)=uicontrol('style','checkbox','string',test.quest{noQuest},'units','normalized','position',posG,'min',0,'max',1);
b@2 161 set(hQuest(noQuest),'callback',sprintf('PCcheck(%d,%d)',hf.Number,noQuest));
b@0 162 if reREAD
b@0 163 set(hQuest(noQuest),'value',rsl.quest(1,noQuest));
b@0 164 end
b@0 165 noGUI=noGUI+1;
b@0 166 end
b@0 167
b@0 168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 169 % "Comments" field
b@0 170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 171
b@0 172 if test.COM
b@0 173 if reREAD
b@0 174 stri=rsl.com{1};
b@0 175 else
b@0 176 stri='Write comments here.';
b@0 177 end
b@0 178 posCom=[x1 0 x2-x1 y4];
b@0 179 hCom=uicontrol('style','edit','max',2,'string',stri,'units','normalized','position',posCom);
b@0 180 dat.com=stri;
b@0 181 else
b@0 182 hCom='';
b@0 183 dat.com='';
b@0 184 end
b@0 185
b@0 186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 187 % "Submit" button
b@0 188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 189 posFin=[x3 y4/3 1-x3 y4/3];
b@0 190 hFin=uicontrol('style','pushbutton','string','Submit','units','normalized','position',posFin);
b@2 191 set(hFin,'callback',sprintf('endPairComp(%d)',hf.Number));
b@0 192
b@0 193
b@0 194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 195 % Test timer
b@0 196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 197 dat.t0=clock;
b@0 198
b@0 199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 200 % Send useful datas
b@0 201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 202
b@0 203 % sounds and combination
b@0 204 dat.noComb=1;
b@0 205 dat.nbComb=test.nbComb;
b@0 206 dat.comb=test.comb;
b@0 207 dat.quest=test.quest;
b@0 208 dat.nbQuest=test.nbQuest;
b@0 209 dat.scale=test.scale;
b@0 210 dat.nbScale=test.nbScale;
b@0 211 dat.stri=stri;
b@0 212 dat.COM=test.COM;
b@0 213
b@0 214 % handles
b@0 215 dat.hf=hf;
b@0 216 dat.butCol=butCol;
b@0 217
b@0 218 dat.ha=ha;
b@0 219 dat.hb=hb;
b@0 220 dat.hStop=hStop;
b@0 221 dat.hQuest=hQuest;
b@0 222 %dat.hScale=hScale; % errors when uncommented
b@0 223 dat.hFin=hFin;
b@0 224 dat.hCom=hCom;
b@0 225
b@0 226 % global datas
b@0 227 dat.test=test;
b@0 228 dat.sesDat=sesDat;
b@0 229 if reREAD
b@0 230 dat.rsl=rsl;
b@0 231 else
b@0 232 dat.rsl='';
b@0 233 end
b@0 234
b@0 235 set(hf,'userdata',dat);
b@0 236
b@0 237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 238 % clean up
b@0 239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b@0 240 clear all;
b@0 241