Collecting responses with PsychToolbox
조회 수: 16 (최근 30일)
이전 댓글 표시
Hello, I am trying to collect keyboard responses with PsychToolbox using KbCheck, but when I run the code the screen freezes and refuses to close. This script is intended to close all screens ONLY after keyboard input 'y' or 'n' (yes/no). I also want to collect which key response was made and the response time. Here is the code I am using to collect responses:
Screen('DrawText', window, 'XXXXX') %stimulus is drawn
[VBL stimulusOnset] = Screen('Flip', window)
acceptedKeys = [KbName('y'), KbName('n')];
responded = 0;
while responded == 0
[tmp,KeyTime,KeyCode] = KbCheck;
if KeyCode(acceptedKeys)
RT = KeyTime - stimulusOnset
strResponse = KeyCode
responded = 1;
end
% time between iterations of KbCheck loop
WaitSecs(0.001);
end
Screen('CloseAll');
Do you have any idea why it is not responding to the correct keyboard inputs? Thank you!
댓글 수: 0
답변 (1개)
Matteo Lisi
2018년 1월 23일
편집: Matteo Lisi
2018년 1월 23일
Since you have two accepted keys the command
KeyCode(acceptedKeys)
produces a vector which corresponds to a logical "true" only if all its elements are equal to 1. Try changing it to
any(KeyCode(acceptedKeys))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Psychtoolbox-3: Vision and neuroscience research에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!