Block RT feedback for multiple responses

Hello Jonathan

as @wakecarter wrote

You are probably using the wrong loop.You need to use the name of the most inner loop in which detect.rt is registered.

Take the following example of a toy experiment:

grafik

meanRT = trials.data['long_detect.rt'].mean()

will work but

meanRT = trials_2.data['long_detect.rt'].mean()

won’t. From the image you posted above the loop trials contains embedded loops. You need to use the proper loop-name, not just trials.

Anyway, the approach @wakecarter mentioned is probably more flexible for your purpose.

Best wishes Jens

2 Likes

Thanks Jens!

That has solved my issue!

I have now edited my code to refer to the inner most loop.

Thanks so much.

In case anyone ever looks through this thread and is in the same position I was in. I still had some issues that I’ve now resolved but thought I’d stick them in here.

I had multiple responses in one routine and multiple routines. In any block it was possible, but not predictable, that some conditions contained no responses. I collected all reaction times as @wakecarter suggested, creating a blank list for each condition and response in the begin experiment tab, like so

rtList1 = []
rListN = []

for each response I appended the list:

rtlist.append(response1.rt) 
rtlistN.append(response1N.rt) 

Before the feedback was presented, I wanted a mean of all responses that were made. I wanted a new list of just means, this proved difficult because some lists were completely empty and all had ‘nan’ values. So after some fighting with the code and some help from chat gpt I did the following.

First, create a list of lists:

List_of_lists = (rtList1, rtListN) 

Then an empty list of means that I would append with means once I ran a loop excluding none and nan values:

mean_lists = []

for l in List_of_lists:
    l = [x for x in l if x is not None and not np.isnan(x)]
    if l:
        mean_lists.append(np.mean(l))

meanRT = np.nanmean(mean_lists)

I then used meanRT as a message to display.

Probably nicer ways to do it but there you go. Maybe it’ll help someone.

1 Like