Round(t) doesn't work well?

Hi guys, how u doing?

I need to calculate the response time for the participant to responde a trial; but I having some troubles.

I’m using this code in each frame

if response.isPressedIn(left_response_box): 
     rt = round(t) 
     thisExp.addData('RT',rt)
elif response.isPressedIn(right_response_box): 
     rt = round(t) 
     thisExp.addData('RT',rt)

This works well, but when I’ll see on Excel spreadsheet: the following number appears with a zero.
Is not 20 seconds, It’s 2 seconds (because I calculated here). Why in spreadsheet is showing 20 instead of 2 seconds?
RT

Why is your code in Each Frame instead of End Routine?

What ends the routine? At the moment it looks like there will be a lot of redundant calculations of rt and replacement of data. What do you want to happen on the frame where the response mouse is STILL pressed in a response box?

End Routine

if response.isPressedIn(left_response_box) and required_response == 'left_response_box':
     thisExp.addData('Score',1)
     total_correct += 1
     feedback_wrong_trial = 0
     feedback_correct_trial = 1
elif response.isPressedIn(right_response_box) and required_response == 'right_response_box':
     thisExp.addData('Score',1)
     total_correct += 1
     feedback_wrong_trial = 0
     feedback_correct_trial = 1
else:
     thisExp.addData('Score',0)
     feedback_wrong_trial = 1
     feedback_correct_trial = 0

U think is better to move this coding to End Routine?

I think that the timing is slightly more accurate if you fix the value in Each Frame (because End Routine might run on the next frame after the response), but I would only expect this to work if the same code included continueRoutine = False. If your mouse component is set to end the routine on valid clicks then this might also work, though possibly only if the code component is above the mouse component in the routine (which would be good practice anyway).

1 Like