b@0: function pairComp(sesDat) b@0: % a pair comparison test with various possible quesions (preference e.g.) and comments b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % copy useful variables b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: UIControl_FontSize_bak = get(0, 'DefaultUIControlFontSize'); b@0: set(0, 'DefaultUIControlFontSize', 28); b@0: b@0: reREAD=sesDat.reREAD; b@0: noTst=sesDat.noTst; b@0: nbTst=sesDat.nbTst; b@0: if reREAD b@0: rsl=sesDat.tstDat{noTst}.rsl; b@0: end b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % read the test file b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: test=readPairComp(sesDat.tstDat{noTst}.tstFile); b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % Set the test screen b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: b@0: hf=figure; b@0: set(hf,'units','normalized'); b@0: %set(hf,'position',[0 .5 1 .4]); b@0: set(hf,'position',[0 .05 .55 .75]); b@0: set(hf,'closereq',''); %%% b@0: set(hf,'numbertitle','off'); b@0: set(hf,'menubar','none'); b@0: set(hf,'name',sprintf('pair #1/%d',test.nbComb)); b@0: set(gca,'position',[0 0 1 1]); b@0: axis([0 1 0 1]); b@0: set(gca,'yticklabel',''); b@0: set(gca,'xticklabel',''); b@0: grid off; b@0: hp=gca; b@0: b@0: butCol=[.6 .9 .6]; % by default pale green b@0: set(hp,'color',[.7 .7 .7]); % gray background b@0: b@0: % Figure-event properties b@0: b@0: set(gcf,'KeyPressFcn','pairKey') b@0: b@0: % Create the 3 frames b@0: b@0: % set the upper frame b@0: b@0: y1=.76; b@0: y2=.75; b@0: y3=.31; b@0: y4=.3; b@0: x1=0; b@0: x2=.8; b@0: x3=.81; b@0: b@0: hold on b@0: b@0: % sound frame b@0: fill([x1 x1 1 1],[y1 1 1 y1],[.8 .8 1]); b@0: % questions frames b@0: fill([x1 x1 1 1],[y3 y2 y2 y3],[.7 .7 1]); b@0: % comments and "finished" button frame b@0: fill([x1 x1 1 1],[0 y4 y4 0],[.9 .9 .1]); b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % PUSH BUTTONS b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: y=(1-y1); b@0: yy=y/20; b@0: h=y-2*yy; b@0: b@0: x=(1-x1); b@0: xx=(1-x1)/8; b@0: b@0: wab=3*xx; b@0: wstop=2*xx; b@0: xa=xx/2; b@0: xb=9/2*xx; b@0: xstop=3*xx; b@0: b@0: posA=[xa y1+yy wab h]; b@0: posB=[xb y1+yy wab h]; b@0: posStop=[xstop y1+yy wstop h]; b@0: b@0: ha=uicontrol('style','pushbutton','string','A','units','normalized','position',posA, 'FontSize', 56); b@0: set(ha,'backgroundcolor',butCol); b@2: set(ha,'callback',sprintf('PCpush(%d,1)',hf.Number)); b@0: b@0: if strcmp(computer,'PCWIN') b@0: hStop=uicontrol('style','pushbutton','string','STOP','units','normalized','position',posStop, 'FontSize', 56); b@2: set(hStop,'callback',sprintf('PCpush(%d,2)',hf.Number)); b@0: else b@0: hStop=''; b@0: end b@0: b@0: hb=uicontrol('style','pushbutton','string','B','units','normalized','position',posB, 'FontSize', 56); b@0: set(hb,'backgroundcolor',butCol); b@2: set(hb,'callback',sprintf('PCpush(%d,3)',hf.Number)); b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % questions and scales b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: if ~isfield(test,'nbScale') b@0: test.nbScale=0; b@0: test.scale=''; b@0: end b@0: if ~isfield(test,'nbQuest') b@0: test.nbQuest=0; b@0: test.quest=''; b@0: end b@0: b@0: test.hScale=''; b@0: test.hQuest=''; b@0: b@0: nbGUI=2*test.nbScale+test.nbQuest; b@0: b@0: y=(y2-y3); b@0: h=y/nbGUI; b@0: hh=h/20; b@0: b@0: x=(1-x1); b@0: xx=(1-x1)/8; b@0: b@0: noGUI=1; b@0: % SCALES b@0: for noScale=1:test.nbScale b@0: s=test.scale(noScale); b@0: Y1=y2-((2*noGUI-1)*h-hh); b@0: %display text b@0: ho='horizontalAlignment'; b@0: ve='verticalAlignment'; b@0: text((1-x1)/2,Y1,s.name,ho,'center',ve,'bottom'); % Scale name b@0: % Level names b@0: text(x1+xx,Y1,s.level{1},ho,'left',ve,'bottom'); b@0: text(1-xx,Y1,s.level{3},ho,'right',ve,'bottom'); b@0: b@0: Y2=Y1-h+hh; b@0: posG=[xx Y2 x-2*xx h-2*hh]; b@0: hScale(noScale)=uicontrol('style','slider','units','normalized','position',posG,'min',s.minn,'max',s.maxx,'value',s.minn); b@0: if reREAD b@0: set(hScale(noScale),'value',rsl.scale(1,noScale)); b@0: end b@0: noGUI=noGUI+1; b@0: end b@0: b@0: % QUESTIONS check boxes b@0: for noQuest=1:test.nbQuest b@0: noGUI=2*test.nbScale+noQuest; b@0: posG=[xx y2-(noGUI*h-hh) x-2*xx h]; b@0: hQuest(noQuest)=uicontrol('style','checkbox','string',test.quest{noQuest},'units','normalized','position',posG,'min',0,'max',1); b@2: set(hQuest(noQuest),'callback',sprintf('PCcheck(%d,%d)',hf.Number,noQuest)); b@0: if reREAD b@0: set(hQuest(noQuest),'value',rsl.quest(1,noQuest)); b@0: end b@0: noGUI=noGUI+1; b@0: end b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % "Comments" field b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: if test.COM b@0: if reREAD b@0: stri=rsl.com{1}; b@0: else b@0: stri='Write comments here.'; b@0: end b@0: posCom=[x1 0 x2-x1 y4]; b@0: hCom=uicontrol('style','edit','max',2,'string',stri,'units','normalized','position',posCom); b@0: dat.com=stri; b@0: else b@0: hCom=''; b@0: dat.com=''; b@0: end b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % "Submit" button b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: posFin=[x3 y4/3 1-x3 y4/3]; b@0: hFin=uicontrol('style','pushbutton','string','Submit','units','normalized','position',posFin); b@2: set(hFin,'callback',sprintf('endPairComp(%d)',hf.Number)); b@0: b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % Test timer b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: dat.t0=clock; b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % Send useful datas b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: % sounds and combination b@0: dat.noComb=1; b@0: dat.nbComb=test.nbComb; b@0: dat.comb=test.comb; b@0: dat.quest=test.quest; b@0: dat.nbQuest=test.nbQuest; b@0: dat.scale=test.scale; b@0: dat.nbScale=test.nbScale; b@0: dat.stri=stri; b@0: dat.COM=test.COM; b@0: b@0: % handles b@0: dat.hf=hf; b@0: dat.butCol=butCol; b@0: b@0: dat.ha=ha; b@0: dat.hb=hb; b@0: dat.hStop=hStop; b@0: dat.hQuest=hQuest; b@0: %dat.hScale=hScale; % errors when uncommented b@0: dat.hFin=hFin; b@0: dat.hCom=hCom; b@0: b@0: % global datas b@0: dat.test=test; b@0: dat.sesDat=sesDat; b@0: if reREAD b@0: dat.rsl=rsl; b@0: else b@0: dat.rsl=''; b@0: end b@0: b@0: set(hf,'userdata',dat); b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % clean up b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: clear all; b@0: