s=1
while 1
while s <= 1
CurrentPos=zeros(500,2);
%画中心注视cross
Screen('DrawTexture',theWindow,cross);
Screen('Flip',theWindow);
target = 1;
trialnum = s; %刺激编号
%读取声音文件
fName = strcat('writemodesoundfiles\du100ms','.wav') ;
[y,freq]=audioread(char(fName));
sound(y,freq);
t1 = GetSecs;
[clicks,xpos,ypos,whichButton]=GetClicks;
k = 1;
if clicks==1
restarttime = GetSecs;
rt = restarttime - t1;
flag = 1;
end
%但关于采点的问题:1.总是陆续采到连续相同的坐标;2.可能是因为音频播放的问题,总是延迟采点,声音播放后3~5s之内被试画线,但数位板不能显示并记录,声音停止播放后3~5s可以显示并记录被试画的线
while flag==1
[MouseX,MouseY,button]=GetMouse(theWindow);
if (MouseX>0||MouseX<0||MouseY>0||MouseY<0) %控制开始采点的条件
flag=3;
lastX=MouseX;
lastY=MouseY;
while flag==3 %控制采点的位置和采点结束的条件
[MouseX,MouseY,button]=GetMouse(theWindow);
CurrentPos(k,1)=MouseX;
CurrentPos(k,2)=MouseY;
[MouseX,MouseY,button]=GetMouse(theWindow);
showX=MouseX;
showY=MouseY;
DrawEachLine(lastX,lastY,showX,showY,scale,ovalR,blue,theWindow);
Screen('Flip',theWindow,[],1);
lastX=showX;
lastY=showY;
k=k+1;
[kD,secs, keyCode] = KbCheck();
if keyCode(Etr)
flag=4;
end
end
%记录采点结束时的鼠标位置,给出声音提示,画线
[MouseX,MouseY,button]=GetMouse(theWindow);
CurrentPos(k,1)=MouseX;
CurrentPos(k,2)=MouseY;
k=k+1;
showX=MouseX;
showY=MouseY;
DrawEachLine(lastX,lastY,showX,showY,scale,ovalR,blue,theWindow);
Screen('Flip',theWindow,[],1);
end
%检测到按空格键时跳出while flag=1循环
[kD,secs,keyCode] = KbCheck();
if keyCode(Etr)
end
end
Screen('DrawTexture',theWindow,cross);
Screen('Flip',theWindow);
%记录k>2时,所有鼠标位置的坐标,输出并保存文件
if k>=2
for temp=1:k-1
fprintf(fp,'%d\t%.2f\t%.2f\t%d\t%d\t%.2f\n',trialnum,GoalPosition(target,1),GoalPosition(target,2),CurrentPos(temp,1),CurrentPos(temp,2),rt);
end
fprintf(fp2,'%d\t%.2f\t%.2f\t%d\t%d\t%.2f\n',trialnum,GoalPosition(target,1),GoalPosition(target,2),CurrentPos(k-1,1),CurrentPos(k-1,2),rt);
s=s+1;
end
end
Screen('DrawTexture',theWindow,endpic);
Screen('Flip',theWindow);
while KbCheck; end %确认按键释放完毕
[secs, keyCode, deltaSecs] = KbWait(); %等待按键
Screen('CloseAll');
end