How to record mouse clicks in excel with reaction time in psychopy or just python itself
I am writing a program to provide visual stimuli which are basically two tone mooney photos.
The location of the images are coming from a csv sheet, and being displayed one by one on the screen.
The images are divided in the category of face or object.
I want the user to left click if he thinks what he sees is a face and right click on a mouse if he thinks it is an object.
The left click should be recorded in an excel/csv sheet as a 'face' entry & 'right' click as an object entry. All individual participants data, should be saved in different tabs in the excel sheet.
Along with that, the response time when the click was done as soon as myWin.flip() was called, should be recorded in another column in milliseconds.
Please suggest.
Relevant code is below:
csv input for images
trials = data.TrialHandler(
trialList=data.importConditions('stimsv1.csv'),
nReps=1,
method= 'sequential')
if aTrial['type'] == 'face':
try:
windll.inpout32.Out32(0x0000D100, 1)
myWin.flip()
core.wait(0.01)
windll.inpout32.Out32(0x0000D100, 0)
except:
print 'trigger issue found '
elif aTrial['type'] == 'object':
try:
windll.inpout32.Out32(0x0000D100, 2)
myWin.flip()
core.wait(0.01)
windll.inpout32.Out32(0x0000D100, 0)
except:
print 'trigger issue found '
else:
continue
Comments
Hi,
Your plan is clear. Are you stuck at a specific point, or do you want us to tell you exactly how to do everything?
In case of the latter, it may be best for you to do an OpenSesame tutorial first; see http://osdoc.cogsci.nl/tutorials/step-by-step-tutorial/
Cheers
Josh
Hi,
I am only interested in knowing specifically, how to capture whether a left(defined as yes) or a right(defined as no) mouse clicks while the stimuli are shown, in an excel/csv sheet along with the difference in time from the myWin.flip() in milliseconds.
Can you mention the code I need to write to capture these mouse clicks along with the time(ms). I want the code part & not using the GUI.
Hi,
All information you need or on the documentation of the
mouse
object. Basically, you wait for a click of the left and the right mouse button separately, but in rapid succession (e.g. in awhile
loop with a timeout of 10 ms each). Use thekeylist
argument to sample only right, or left clicks. Once a response was given, check whether it was left or right, and based on that info you can assign proper values to your object/face/response time variables.Does this make sense?
Good luck,
Eduard
Along with that, the response time when the click was done as soon as myWin.flip() was called, should be recorded in another column in milliseconds.
sagarcog, did you get it fixed?