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

1 vue (au cours des 30 derniers jours)
Lisa M
Lisa M le 3 Fév 2020
Modifié(e) : Lisa M le 3 Fév 2020
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

Réponses (0)

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by