Trying to get onset time of first keypress using a sliding scale in Psychtoolbox

1 次查看(过去 30 天)
I have a slider which you can move left and right and I am trying to get the onset time of the first keypress. However, right now I only get the time for how long the rating scale is on the screen. Any suggestions?
Thanks in advance!
% Loop for scale loop
t0 = GetSecs;
answer = 0;
moved = 0;
firsttouch = 0;
while answer == 0
% Parse user input for x location
if strcmp(device, 'mouse')
[x,~,buttons,~,~,~] = GetMouse(screenPointer, 1);
elseif strcmp(device, 'keyboard')
[~, secsrating, keyCode, ~] = KbCheck;
if keyCode(responseKeys(2)) == 1 && firsttouch == 0
x = x - stepSize; % Goes stepSize pixel to the left
onset_rating = secsrating-t0;
firsttouch = 1;
elseif keyCode(responseKeys(2)) == 1 && firsttouch == 1
x = x - stepSize; % Goes stepSize pixel to the left
onset_rating=0;
elseif keyCode(responseKeys(3)) == 1 && firsttouch == 0
x = x + stepSize; % Goes stepSize pixel to the right
onset_rating = secsrating-t0;
firsttouch = 1;
elseif keyCode(responseKeys(3)) == 1 && firsttouch == 1
x = x + stepSize; % Goes stepSize pixel to the right
onset_rating=0;
end
else
error('Unknown device');
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by