I am currently building a line bisection task with the PsychoPy Builder.
Now I wanna add some code, so that in the end there will be a column in my excel sheet, that tells me where, compared to the stimuli (a rectangular polygon, thin as a line), the person clicked with the mouse.
Goal is to find out if the person clicked too far to the left or too far to the right of the polygon.
Up till now the mouse response is only saved in relation to the screen-size.
If you know any way to code this or have tipps for pieces of code I could use, I’d be very thankful!
I do not know if that makes sense but psychopy records the mouse position, and you have a polygon position. you might write a code that subtract these two variables. Or ypu öay consider calculatibg in the cond file
I do not want to mislead you but, I guess you should run the experiment first.
Check the csv data file. You will see the variable names for X axis of the mouse e.g. Mouse.x mouse.y Since you are interesed in right or left, it should be x axis I think.
Did you define positions for polygon and line components in the condition xlxs file? I mean do you have a column for it? If yes, lets say the name is line_posx
Begin routine:
new_pos = mouse.x - line_posx #this is just for demonstration purposes you should decide which one to subtract first
if new_pos <0: #we mean that mouse position is less than the line position. So it is on the left
new_pos = 'left'
thisExp.addData ('leftorright', new_pos)
if new_pos > 0 :
new_pos = 'right'
thisExp.addData ('leftorright', new_pos)
if new_pos == 0 :
new_pos = 'middle'
thisExp.addData ('leftorright', new_pos)
Someone can correct me if I am wrong.
Very close, but with some unnecessary repetition. How about
new_pos = mouse.getPos()[0] - line_posx #this is just for demonstration purposes you should decide which one to subtract first
if new_pos < 0: #we mean that mouse position is less than the line position. So it is on the left
new_pos = 'left'
elif new_pos > 0 :
new_pos = 'right'
else:
new_pos = 'middle'
thisExp.addData ('leftorright', new_pos)
Is there also a possibility to save the exact deviation from the middle? For example, the subject deviated 0.2 degrees/cm/whatever measure from the middle to the right/left.
But what if I don’t wanna define the distance. So no matter how far away from the middle a person clicks, in the end I will get the distance from the middle of the polygon.
In your example, I will only get the info for 0.2, right?
Yes, I know. But that is what I’d like to obtain.
So it is important to know if the person clicked right or left from the middle, but it is also important to know how far away from the middle of the polygon he or she clicked.
Also, because I don’t know if this is clear: the polygon is not always in the middle of the screen.