psychopy.org | Reference | Downloads | Github

Waitkeys and timestamp


#1

I was thinking about using waitKeys to get the response time, but I really dislike how the date is presented on the csv file. If we have the code I presented below it generates something like this two columns:

first column        RT
("T",   12.23555) I 200ms

I want it to show only this:

T I 200ms

Is there any way we can go around this? I am considering going with the clock instead if there is not a good option but I wonder if they would still give me the key pressed with the quotation marks which I cannot get as it would not allow then accuracy to be determined. Do you have any suggestions?

 disptime = win.flip()

# Wait for the user to press the right number
keys = event.waitKeys(keyList=[str(num)], timeStamped=True)

# extract the values from the 0th element of the list we are returned
key, keytime = keys[0]

# Store the reaction time for later use
rts = (keytime - disptime)*1000

#2

How are you getting those values into your data? PsychoPy isn’t going to output something like 200ms as a reaction time for a start (at the analysis stage, you really will not want units attached to your numeric values…)

So presumably you are using your own code to add data to the file?


#3

Yes, I have code to generate a csv file. I am aware that the output will not look like 200ms, it was just an example.

My output looks like this:

trialCounter Responses TimeStamp RT(ms)
1 (‘m’ 14.994935355173993) 882.0954525
2 (‘n’ 15.043443971725083) 18.2816561
3 (‘x’ 15.107173009750568) 48.4281623
4 (‘z’ 15.131167248828888) 5.907262404
5 (‘m’ 15.227080305262689) 78.29456851
6 (‘n’ 15.31511612892541) 58.10651083
7 (‘x’ 15.362922177893324) 28.66025461
8 (‘m’ 15.482857946926742) 98.48560597
9 (‘z’ 15.50723790289203) 2.695382985
10 (‘x’ 15.547362060688329) 11.60726406
11 (‘m’ 15.722842054728744) 141.0889466
12 (‘x’ 15.754920125151102) 19.10838148
13 (‘n’ 15.843044349164757) 73.79641432
14 (‘m’ 15.954958862383592) 95.48396709
15 (‘n’ 16.043181419371876) 60.37777079

I don’t need the time stamp nor do I want the key pressed to be presented in brackets and quotations. How can I do that?

Can use the clock function instead or does it generate too much delay?

displaytime = win.flip() # flip everything to the window

responseKey = event.waitKeys() # get participant response

end = myClock.getTime() # get time for participant's response

RT = (end - displaytime)*1000 # calculate response time

#4

You’re coming at this from the wrong direction. Since you are generating the csv file through your own code, the solution lies at that point. Instead of saving the tuple of two values you get back from the waitKeys function, just extract the first value from the tuple (i.e. the keypress) and save that. Similarly, extract the second value and use it for your time calculations.