# Trying to base the output-timer on system-clock

**URL:** https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608
**Category:** Coding
**Tags:** timing
**Created:** [August 10, 2020, 1:19pm UTC](https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608 "2020-08-10T13:19:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nilslueschow](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/nilslueschow/32/11112_2.png) [@nilslueschow](https://discourse.psychopy.org/u/nilslueschow)
#### Post date: [August 10, 2020, 1:19pm UTC](https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608/1 "2020-08-10T13:19:19Z")

</div>

Hey everyone,  
we are currently setting up an EEG study and it would be nice, if we could sync the responses in our PsychoPy Experiment with the EEG Recordings.

This post describes a similar idea:

> [@Adding precise measure of system clock to psychopy output](https://discourse.psychopy.org/t/adding-precise-measure-of-system-clock-to-psychopy-output/8426):
>
> OS: Win10 64-bit PsychoPy version : 3.1.2 Standard Standalone?: Y What are you trying to achieve?: I am recording participants with a webcam as they complete a psychopy experiment. I need to be able to synchronize the recorded video and the psychopy output so that I know when (in video time) certain events occurred in the experiment. My plan for this is to do both the webcam recording and the psychopy experiment on the same computer. Then I can hopefully get the system clock and compare the…

I tried to integrate the proposed solutions in multiple ways, however, I was not able to get an output of the system clock. Is there anything more to add to the solution by @dvbridges to get this to run?

Thank you in advance!

Further Details:  
Windows10 64Bit  
PsychoPy v2020.2.2  
No Error Message received, the output is just missing

---

<div class="post-metadata">

### Author: ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)
#### Post date: [August 10, 2020, 2:13pm UTC](https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608/2 "2020-08-10T14:13:11Z")

</div>

Correct me if I misunderstand what you are trying to achieve, but why do you not record triggers along with your response in your EEG data?  
There is a Psychopy module for that, which you can call in a code component: [https://www.psychopy.org/api/parallel.html](https://www.psychopy.org/api/parallel.html)  
This is more precise than relying on the system clock.

---

<div class="post-metadata">

### Author: ![nilslueschow](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/nilslueschow/32/11112_2.png) [@nilslueschow](https://discourse.psychopy.org/u/nilslueschow)
#### Post date: [August 10, 2020, 2:54pm UTC](https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608/3 "2020-08-10T14:54:58Z")

</div>

That is a good idea, however the EEG and recording software are protoypes and unfortunately it is not possible to send over triggers from PsychoPy and record them along with the data.

---

<div class="post-metadata">

### Author: ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)
#### Post date: [August 10, 2020, 3:15pm UTC](https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608/4 "2020-08-10T15:15:57Z")

</div>

> [@nilslueschow](#):
>
> I was not able to get an output of the system clock.

What lines of code did you use? And what was the output?

---

<div class="post-metadata">

### Author: ![nilslueschow](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/nilslueschow/32/11112_2.png) [@nilslueschow](https://discourse.psychopy.org/u/nilslueschow)
#### Post date: [August 11, 2020, 12:36pm UTC](https://discourse.psychopy.org/t/trying-to-base-the-output-timer-on-system-clock/15608/5 "2020-08-11T12:36:49Z")

</div>

Okay nevermind, I figured it out but thank you anyway for offering help. The solution in this thread

> [Adding precise measure of system clock to psychopy output](https://discourse.psychopy.org/t/adding-precise-measure-of-system-clock-to-psychopy-output/8426)

works. I confused the .log with the .csv files. The .csv files display the time stamps set with

> thisExp.addData(“routineStart”, time.time())

in the custom code component.

If someone with a similar issue reads this later, please be aware that this approach does not apply the system clock to every component and their events in the .csv file such as “example\_text123.started”. The components still use a counter beginning with the experiments start. I guess you would have to find the place in your experiments code, where the main timer starts/is set to 0 and then set it to your system time.  
The simpler solution was sufficient for our study, yet I guess there are different instances where you would want such a feature (having a gui implementation of a custom start time setting would also be a nice addition).
