How calculate median of RT

Hello! Hope all are good!

I’m trying here to calculate de median of RT, but having some issues.
What I’ve tried?

Blockquote

At Begin Experiment
# importing statistics module
import statistics
At Begin Routine
median_latency = round(statistics.median(rt))
At End Routine
thisExp.addData('median_latency', median_latency)

This is the following error:
error_median_code

Hello

is rt a list?

Ok, there is one approach. Define a list that that stores the rt in the Begin experiment tab

rtList = []

In the End routine tab of the rt-trial insert

rtList.append(key_resp.rt)

Change key_resp.rt to the name of your rt-component. Add a routine following your rt-loop and insert the following a Begin routine tab

median_latency = np.median(rtList)
thisExp.addData('median latency', median_latency)

BTW, I used numpy instead of statistics for computing the median.

Best wishes Jens

Thank u a lot!
That worked perfectly :slight_smile: