b@0: function multiComp(sesDat) b@0: b@0: % multiple comparison test on several 1D scale b@0: % see readMultiComp for a description of specifications b@0: b@0: UIControl_FontSize_bak = get(0, 'DefaultUIControlFontSize'); b@0: set(0, 'DefaultUIControlFontSize', 20); b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % copy useful variables b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: reREAD=sesDat.reREAD; b@0: noTst=sesDat.noTst; b@0: nbTst=sesDat.nbTst; b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % read the test file b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: test=readMultiComp(sesDat.tstDat{noTst}.tstFile); b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % Set the test screen b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: hf=figure; b@0: set(hf,'units','normalized'); b@0: set(hf,'position',[0.1 .15 .80 1.0]); % TODO make automatic % [left, bottom, width, height] b@0: set(hf,'closereq',[]); b@0: set(hf,'numbertitle','off'); b@0: set(hf,'menubar','none'); b@0: if (nbTst-noTst)/2 > 1 b@0: titlestr = sprintf('%d screens left',(nbTst-noTst)/2); b@0: else if (nbTst-noTst) > 1 b@0: titlestr = 'One screen left after this'; b@0: else b@0: titlestr = 'Last screen'; b@0: end b@0: end b@0: set(hf,'name',titlestr); 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: set(hp,'color',[.7 .7 .7]); % gray background b@0: b@0: % Figure-event properties b@2: set(hf,'windowbuttonmotionfcn',sprintf('MmoveW(%d)',hf.Number)); b@2: set(hf,'keypressfcn',sprintf('TpushKey(%d)',hf.Number)); b@0: b@0: % Define Scales and SonIcons b@0: b@0: nbScale=length(test.scale); b@0: dY=1/(nbScale+3); % vertical space for each scale+text (used to be +1, now +3) b@0: dX=1; b@0: dyy=dY/2; % vertical space for scale and text b@0: dxx=1/30; % vertical margins of the scale b@0: small=dyy/10; b@0: b@0: % create sonicons b@0: nbSnd=test.nbComb; b@0: b@0: % RANDOM POSITIONS and ALREADY PLAYED b@0: if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') b@0: permVec = sesDat.tstDat{noTst}.rsl.permVec; b@0: playVec = sesDat.tstDat{noTst}.rsl.playVec; b@0: else b@0: permVec = randperm(nbSnd); b@0: playVec = zeros(nbSnd,1); b@0: end b@0: b@0: fidInd=['responses/' sesDat.id,'_',sesDat.sesScript]; % print permutation in response log b@0: fid=fopen(fidInd,'a'); b@0: fprintf(fid,'\n%s\n', 'Random permutation mapping (comments): '); b@0: for noSnd = 1: nbSnd b@0: fprintf(fid,'%d ', permVec(noSnd)); b@0: end b@0: fprintf(fid,'\n%s\n', ' '); b@0: b@0: b@0: for noScale=1:nbScale b@0: b@0: y=1-noScale*dY; % bottom line b@0: dyt=dyy; % was 3/2* b@0: %display text b@0: h='horizontalAlignment'; b@0: v='verticalAlignment'; b@0: text(.5,y+dyt,test.scale(noScale).name,h,'center',v,'bottom', 'FontSize', 24); % Scale name b@0: % Level names b@0: text(0+small,y+dyt,test.scale(noScale).level{1},h,'left',v,'bottom', 'FontSize', 24); % MINIMUM b@0: text(1-small,y+dyt,test.scale(noScale).level{3},h,'right',v,'bottom', 'FontSize', 24); % MAXIMUM b@0: b@0: % Display 1D rules b@0: y0=y; b@0: y1=y+dyy; b@0: hold on; b@0: fill([dxx dxx 1-dxx 1-dxx],[y1 y0 y0 y1],[.8 .8 .8]); b@0: b@0: b@0: for noSnd=1:nbSnd b@0: b@0: dl=(1-2*dxx)/5; %BDM used to be /nbsnd b@0: xI=dl*noSnd/2; b@0: dxI=dl/10; % width of a sonicon b@0: posIc=[xI y+small dxI dyy-2*small]; b@0: b@0: % position the icons on the default position b@0: % check if the individual data contains already some past results b@0: % b@0: if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') b@0: posComb=sesDat.tstDat{noTst}.rsl.mat(noScale,noSnd); b@0: else b@0: posComb=test.posComb(noSnd,noScale); b@0: fidInd=['responses/' sesDat.id,'_',sesDat.sesScript]; % print initial placing b@0: fid=fopen(fidInd,'a'); b@0: fprintf(fid,'%f ', test.posComb(noSnd,noScale)); b@0: end b@0: b@0: % Calculate Icon position relative to the screen units b@0: minx=test.scale(noScale).minn; b@0: maxx=test.scale(noScale).maxx; b@0: a=(1-2*dxx)/(maxx-minx); b@0: b=dxx-a*minx; b@0: posIc(1)=posComb*a+b-dxI/2; b@0: b@0: % set handles b@0: hIc=uicontrol('style','text','string',num2str(permVec(noSnd)),'units','normalized','position',posIc); % changed by Brecht: randperm b@2: set(hIc,'buttondownfcn',sprintf('MpushIc(%d)',hf.Number)); b@0: set(hIc,'backgroundcolor', [.6 .9 .6]); % set colour to green b@0: b@0: %%%%%%%%%%%%%%%%%%% ENABLING b@0: set(hIc,'enable','inactive'); b@0: set(hIc,'tag','sonicon'); b@0: b@0: sndId=test.comb(noSnd); b@0: set(hIc,'userdata',sndId); b@0: hIcon(noScale,noSnd)=hIc; b@0: b@0: end b@0: fprintf(fid,'%s\n', ' '); b@0: %shIc= set(hIc); %??? what is this here for? suppress output. b@0: b@0: % set the un-movable references b@0: nbRef=length(test.sndRef); b@0: for noRef=1:nbRef b@0: sndRef=test.sndRef(noRef); b@0: %%%%%%%%%%%%%%%%%%%%%% ENABLING... b@0: set(hIcon(noScale,sndRef),'enable','off'); %% for MAC! may be 'off' for PC?? b@0: set(hIcon(noScale,sndRef),'string','ref'); b@0: end b@0: b@0: b@0: end b@0: b@0: b@0: % create Comments b@0: hcom = struct([]); % create empty struct for comments b@11: if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') % recall comments b@0: for noSnd = 1:nbSnd % a comment per sample b@0: posCom=[dxx 6*dY/(nbSnd+2)+3*dY/(nbSnd+2)*(nbSnd - noSnd) 10/15 3*dY/(nbSnd+2)-small]; % [left, bottom, width, height] b@0: commentstr = sesDat.tstDat{noTst}.rsl.hcom{noSnd}; b@0: hcom{noSnd} = uicontrol('style','edit','max',2,'string',commentstr, ... b@0: 'units','normalized','position',posCom, ... b@0: 'HorizontalAlignment', 'left'); b@0: end b@0: b@0: posCom=[dxx small 10/15 6*dY/(nbSnd+2)-small]; % general comments b@0: commentstr = sesDat.tstDat{noTst}.rsl.gcom; b@0: gcom=uicontrol('style','edit','max',2,'string',commentstr, ... b@0: 'units','normalized','position',posCom, 'HorizontalAlignment', 'left'); b@0: b@0: b@11: else % new comments b@0: for noSnd = 1:nbSnd % a comment per sample b@0: posCom=[dxx 6*dY/(nbSnd+2)+3*dY/(nbSnd+2)*(nbSnd - noSnd) 10/15 3*dY/(nbSnd+2)-small]; % [left, bottom, width, height] b@0: commentstr = sprintf('%d: ', noSnd); b@0: hcom{noSnd} = uicontrol('style','edit','max',2,'string',commentstr, ... b@0: 'units','normalized','position',posCom, ... b@0: 'HorizontalAlignment', 'left'); b@0: end b@0: b@0: posCom=[dxx small 10/15 6*dY/(nbSnd+2)-small]; % general comments b@0: commentstr = sprintf('%s: ', 'General comments'); b@0: gcom=uicontrol('style','edit','max',2,'string',commentstr, ... b@0: 'units','normalized','position',posCom, 'HorizontalAlignment', 'left'); b@0: b@0: end b@0: b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % "Stop audio" button b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: posFin=[11/15 3*dY/2 3/15 3*(dY-small)/2]; % [left, bottom, width, height] b@0: hFin=uicontrol('style','pushbutton','string','Stop audio','units','normalized','position',posFin); b@2: set(hFin,'callback',sprintf('MpushIc(%d)',hf.Number)); b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % "Finished" button b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: b@0: posFin=[11/15 small 3/15 3*(dY-small)/2]; % [left, bottom, width, height] b@0: hFin=uicontrol('style','pushbutton','string','Finished','units','normalized','position',posFin); b@2: set(hFin,'callback',sprintf('endMultiComp(%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: dat.dxx = dxx; %? b@0: dat.dxI = dxI; %? b@0: dat.hf = hf; b@0: dat.hcom = hcom; % individual comments b@0: dat.gcom = gcom; % general comments b@0: dat.hIcon = hIcon; b@0: dat.drag = 0; b@0: dat.test = test; b@0: dat.sesDat = sesDat; b@0: dat.playVec = playVec; b@0: dat.permVec = permVec; b@0: dat.nbScale = nbScale; b@0: dat.nbSnd = nbSnd; b@0: set(hf,'userdata',dat) b@0: b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: % clean up b@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% b@0: clear all;