psychopy.org | Reference | Downloads | Github

Saving stimuli time from the beginning of the experiment

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

OS: Win10
PsychoPy version: 2020.2.10
Standard Standalone? (y/n): yes
What are you trying to achieve?: saving when a routine started relative to the beginning time of the experiment.

I don’t completely understand what does the column routine.started and routine.stopped represent (which is usually NONE)

I wrote a code component in the “begin routine”

thisExp.addData('myTimer1', myTimer.getTime())

the timer is initialized in the “begin expriment”
myTimer = core.Clock()

I get 2 very different times on the routine.started and myTimer1.
Which one is the correct one to use

Thank you very much!
1_routineTimers_2021_Mar_04_0924.csv (308 Bytes) routineTimers.psyexp (12.2 KB)

I am going to dodge your question a little bit, if you have a component in the routine with the “save onset/offset time” box checked it should save the time when a routine started relative to the beginning time of the experiment, without the need of additional code.

tandy

it is checked. but in which variable is it saved?

It should be saved into a new column called NameOfTheComponent.started and NameOfTheComponent.stopped

But it has a very different time from what I saved in the component I added .
is it maybe because it is saved from when the first GUI of participant information appeared?

I am not sure but I guess you are right. I think you can still use it, with the time recorded for the first ever component in your experiment (e.g. 5.31) as a sort of time 0, and then subtracting this time 0 from subsequent recorded times.

thank you!
and do you know why the routine.finish is none?

Hi There,

The columns with the headers ‘text.started’ and ‘text.stopped’ refer to the onset and offset time of the text component (not a routine). But each routine does have it’s own clock (i.e. a routine called routine1 has a corresponding instance “under the hood” called routine1Clock).

The important thing here, is that when you look at the difference between each timestamp, the values are approximately similar. The difference between your two values come from the zero point of your clocks.

To help figure out the zero points of your clocks compile the experiment to code.

For your own clock, that is easy, myTimer is made on line 86, essentially the same point in the code where your routine1Clock is made actually… So we know the zero point of that, but what about the onset/offset saving of each component?

We can see on line 186 where the data are saved.

thisExp.addData('text.started', text.tStartRefresh)
thisExp.addData('text.stopped', text.tStopRefresh)

What is text.tStartRefresh ?..you can see on line 129 that the values are initialized as “None” (which probably explains why they are saved as none if nothing overwrites this):

    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None

On line 159 these values are set using win.timeOnFlip():

        text.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(text, 'tStartRefresh')  # time at next scr refresh

But what are the zero points of these timers?

Looks like the save onset/offset box uses core.monotonicClock Add timing audit data to .csv output files · Issue #2187 · psychopy/psychopy · GitHub
The zero point of core.monotonicClock is the time when core was imported psychopy.core - basic functions (clocks etc.) — PsychoPy v2021.1

If we wanted to check this, we could save core.monotonicClock.getTime() at the start of your routine, that will probably get a near identical answer to your text start time.

So, in short which clock you use depends on what you want your zero point to be.

Do you want it when core was imported? In which case the onset of your components are helpful (or use core.monotonicClock)

Do you want it to be when your experiment begins ? in which case use your custom clock that is created when the experiment begins.

Do you want it to be when a routine begins? In which case use the custom clocks that underlie each routine (i.e. routine1Clock)

Sorry for the info dense response - but hopefully this is helpful to those trying to understand what different timestamps mean in their experiments!
Becca

2 Likes