Logging start and end time of a trial

Dear PsychoPy forum,

I inserted a “python command” block in my experiment in order to be able to log the start and end time of each trial in the psydat files.

In short, it is coded:
Begin routine: thisExp.addData(“TrialsStartTime”, globalClock.getTime())
End routine: thisExp.addData(“TrialsEndTime”, globalClock.getTime())

Unfortunately, it doesn’t seem to work. I attached the experiment file and an example of a psydat file.

Any tip would be greatly appreciated. I have no background in programming.


run1perimeter.psyexp (51.9 KB)

004_perimeter-run1_2019_Aug_26_1423.xlsx (14.8 KB)

Hi, please explain exactly what you mean by this — at the moment, we don’t know what the actual problem is.

Sorry for the lack of clarity.

Only the accuracy and the response time are logged in the psydat file. The start time and end time of the trials is not logged in. I need this later information for fMRI data analysis, i.e. to know exactly at what time (relative to the start of the experiment) each trial was presented.

Thanks in advance!

You’re doing everything correctly, just looking in the wrong place for the output. In your experiment settings, please switch off “Save Excel file” and “Save csv file (summaries)”. The data file you need for your analysis is obtained from “Save csv file (trial-by-trial)”.

The other two formats do some summarising and so don’t contain all the info you need – I’d actually prefer it if those options were removed, as they only cause issues.

Dear Michael,

Thank you for your help. It looks like my experiment settings have already been set to “Save csv file (trial-by-trial)” (see screenshot).

Could it be some other experiment setting that I haven’t switched on properly?


Dear Micheal,

Please ignore my last message, indeed when I activate “Save csv file (trial-by-trial)” I get the start time each trial in the csv final.

Many thanks for your help,