2017-03-18 1 views
0

psychtoolbox 및 정확한 타이밍에 문제가 있습니다. 필자는 웹 사이트의 튜토리얼과 PsychDocumentation의 PTBTutorial-ECVP2013.pdf에 따라 코드를 작성했습니다. 그러나 그것은 어떻게 든 여전히 올바르게 작동하지 않습니다. 뒤집기 (1 초 또는 2 초)보다 오래 걸립니다 (20 초 이상). 그래서 저는 어딘가에서 중요한 실수를 저지르고 있다고 생각합니다. 그러나 그것을 찾을 수는 없습니다. 제 코드를 도와 주시겠습니까?psychtoolbox 정확한 타이밍이 설정 프레임에서 뒤집히지 않습니다.

어쨌든 내 코드는 다음과 같습니다.

%Number of seconds to wait (ns) 
nsS = 2; %sentences 
nsW = 1; %words 
nsDot = 7; 
nsWait= 3; 
%Number of frames to wait (wf) before flipping 
wfS = round(nsS/ifi); 
wfW = round(nsW/ifi); 
wfDot = round(nsDot/ifi); 
wfWait = round(nsWait/ifi); 
vbl=Screen('Flip', window); 


for i = 1:10 %1:exp.ntrials 
    sentence = ...; %load sentences 
    word = ...% load words; 

    for iframe = 1:300 
     %draw fixation cross 
     if iframe <= 60 
      DrawFormattedText(window, '+','center','center', white); 
      vbl =Screen('Flip', window, vbl + (wfW-0.5)*ifi); 
     %draw sentence 
     elseif iframe <= 180 
      DrawFormattedText(window, sentence,'center','center', white); 
      vbl = Screen('Flip', window, vbl + (wfS-0.5)*ifi); 
     %blank screen 
     elseif iframe <= 240 
      Screen('FillRect', window, black); 
      vbl = Screen('Flip', window, vbl + (wfW-0.5)*ifi); 
     %Draw word 
     elseif iframe <=300 
      DrawFormattedText(window, word,'center','center', white); 
      vbl = Screen('Flip', window,vbl + (wfW-0.5)*ifi); 
     end 
    end 

    %Draw dot 
    for frames = 1:wfDot 
     Screen('DrawDots', window, [xCenter yCenter], 10, white, [], 2); 
     vbl=Screen('Flip', window, vbl+(wfDot-0.5)*ifi);%, vbl+(wfDot-0.5)*ifi); 
     %WaitSecs(7); 
    end 
    ... 
end 

답변

0

'iframe'루프를 사용하여 화면 프레임을 반복하는 것처럼 보입니까? Screen ('Flip') 명령은 적절한 시간에 자극을 나타 내기 위해 대기하고 'iframe'루프는 필요하지 않으며 문제의 원인이됩니다. 코드에서 수정 된 예제가 아래에 포함되어 있습니다 (예제에 정의되지 않은 몇 가지 사항을 추가해야했습니다). try/catch 문에서 코드를 래핑 할 필요는 없지만 오류가 발생하면 자동으로 화면을 닫는 것이 편리합니다.

try 
    window = Screen('OpenWindow', 0, 0); 
    ifi = Screen('GetFlipInterval', window); 

    %Number of seconds to wait (ns) 
    nsS = 2; %sentences 
    nsW = 1; %words 
    nsDot = 7; 
    nsWait= 3; 
    %Number of frames to wait (wf) before flipping 
    wfS = round(nsS/ifi); 
    wfW = round(nsW/ifi); 
    wfDot = round(nsDot/ifi); 
    wfWait = round(nsWait/ifi); 
    vbl=Screen('Flip', window); 

    black = 0; 
    white = 255; 

    for i = 1:10 %1:exp.ntrials 
     sentence = 'sentence here'; 
     word = 'word here'; 

     DrawFormattedText(window, '+','center','center', white); 
     vbl =Screen('Flip', window, vbl + (wfW-0.5)*ifi); 
     %draw sentence 
     DrawFormattedText(window, sentence,'center','center', white); 
     vbl = Screen('Flip', window, vbl + (wfS-0.5)*ifi); 
     %blank screen 
     Screen('FillRect', window, black); 
     vbl = Screen('Flip', window, vbl + (wfW-0.5)*ifi); 
     %Draw word 
     DrawFormattedText(window, word,'center','center', white); 
     vbl = Screen('Flip', window,vbl + (wfW-0.5)*ifi); 

    end 

    sca; 

catch 
    % close the screen on errors 
    sca; 
end 
관련 문제