Creating average reaction times for trials specified in excel

If this template helps then use it. If not then just delete and start from scratch.

Hi all,

I am using the psychopy 2023.2.3. builder. I have created a feedback routine which should provide feedback on the reaction time for the mouse press from the previous routine (mouse_5). Within an excel sheet, I have provided specific information to be applied for each trial. This excel sheet is used in a loop called ‘trials’ which allows me to randomise the presentation of these trials. I’m hoping to give average reaction time feedback in my feedback routine but one average for some trials specified by certain rows from the excel sheet (e.g. rows 2, 4, 10, 12, 14) then another average for other rows (e.g. 1,3,7,11,13).
I’m pretty new to psychopy, and I’ve tried doing it in various ways and get new errors.

This is my current code:
fb_text = ‘no mouse component found - look at the Std out window for info’
for i in trials==1,3,5,9,11,13:
rt_sum=mouse_5.time[i]
Uavg_rt = rt_sum/ trials
print('The average response time for uncrossed trials in ms is '+ Uavg_rt)

for ii in trials==0,2,4,8,10,12:
rt_sum=mouse_5.time[ii]
Cavg_rt = rt_sum/ trials
print(‘The average response time for crossed trials in ms is’+ Cavg_rt)

My current error is:
Uavg_rt = rt_sum/ trials
TypeError: unsupported operand type(s) for /: ‘Timestamp’ and ‘TrialHandler’