How do I change this so that it will record responses?
Show older comments
Note: this is using Psychtoolbox
I'm trying to run an oddball task, where the participant has to press the spacebar when they see a square (10% of trials) and make no response when they see a circle (90% of trials). Currently this script is not collecting any keyboard responses. I suspect that this is due to the line:
while GetSecs() <=targettime(trialcount) + (stimdur = fixdur)
but I don't know how to change it to make it work.
The next part of the script is trying to make it so that if no response is made within a certain time, the fixation cross appears and then move onto the next trial.
if conditionsrand(trialcount) == 1
Screen('DrawTexture', window, Square, [], [], 0);
elseif conditionsrand(trialcount) == 2
Screen('DrawTexture', window, Circle, [], [], 0);
end
Screen('Flip', window);
targettime(trialcount) = GetSecs; % time of stimulus onset
while GetSecs ()<= targettime(trialcount) + (stimdur + fixdur)
[keyIsDown, seconds, keyCode] = KbCheck();
if keyIsDown
responseKey = KbName(find(keyCode));
responsetime(trialcount) = seconds;
buttonpressed(trialcount) = 1;
if keyCode(KbName('ESCAPE')) == 1
break
end
end
if GetSecs() + stimdur >= targettime(trialcount) % stimulus has been up for as long as it should be, so we erase it
DrawFormattedText(window, fix, 'center', 'center', textcolor);
Screen('Flip', window);
WaitSecs(fixdur);
end
end
Answers (0)
Categories
Find more on Timing and presenting 2D and 3D stimuli in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!