I can't save key press responses
3 views (last 30 days)
Show older comments
Hello,
I'm using Matlab with Psychtoolbox and having problem with one thing. I have multiple tasks and I'm using keyIsDown for everyone of them. It works in other tasks but strangely it doesn't work in one of them.
In my task I want subjects to press '0' whenever letter X appears on the screen and press nothing if other letters appear. If X appears and they press '0' it's "correct", if other letters appear and they press '0' it's "incorrect". Also, if X appears but they press nothing I want it to be "miss" and if other letters appear and they press nothing I want it to be "correct no response".
When I use this code and save responses (I check responsedata to see what subjects did):
t1=GetSecs;
time=0;
while time < responsetime % this is the maximum wait time
[keyIsDown,t2,keyCode]=KbCheck;
time=t2-t1;
if (keyIsDown)
if mytext1{i}=='X'
responsedata1{i}.type='correct'; % correct response
responsedata1{i}.RT =t2;
elseif mytext1{i}~='X'
responsedata1{i}.type='incorrect';% correct inresponse
responsedata1{i}.RT =t2;
end
else %no button press
if mytext1{i}=='X' %they are supposed to respond but didn't
responsedata1{i}.type='miss';% no response
responsedata1{i}.RT =0;
elseif mytext1{i}~='X'
responsedata1{i}.type='correct_noresp';% correct no response
responsedata1{i}.RT =0;
end
end
end
for each target it either saves as miss or correct no response. Eventhough I press '0' whenever I see letter X, it still saves as "miss". I troubleshot other keys in my keyboard and the problem is with 'keyIsDown'. It doesn't recognize if there is a key press.
However, if I do it like this:
t1=GetSecs;
time=0;
while time < responsetime % this is the maximum wait time
[keyIsDown,t2,keyCode]=KbCheck;
if (keyIsDown)
time=t2-t1;
Then letters don't appear in a given time, only appear if there is a key press (here 'keyIsDown' recognizes if there is). I don't want that to happen. I want them to appear in a given time.
I don't know how to fix this. If there is someone who can show me what I'm doing wrong, I'd appreciate it.
Thank you.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!