Timestamps on global time without synchronising audio stimuli to the screen?

Hello everyone,

My question refers to the Builder, synchronising with the screen, and timestamps. My task is developed with the Builder without any code components yet. I am open to insert code components or edit the code itself if needed but have not done so yet to prevent unnecessary bugs and/or suboptimal flow due to my minimal experience.


I have an auditory-only task where instructions are delivered via earphones (‘sound’ component). I will be recording MEG data and thus use ‘parallel port’ component to send triggers. The timing of the audio and the corresponding triggers via parallel port are critical.
I do use the screen to display updates to myself - but participant never sees the screen, thus the timing of stimuli on the screen is not important at all.

I noticed that in Builder, when we synchronise our components with the screen (checkbox: ‘Sync Start with Screen’ for a stimulus component; ‘Sync timing with screen refresh’ for parallel port component) the timestamps in the automatic .xlsx data output are on global time i.e., the timestamp from the start of the experiment (accounting for the screen frames), e.g., 79.54 seconds (from the start of the experiment). When I do not synchronise with the screen, the timestamps are on local routine time, i.e., in reference to the start of the current routine, e.g., 0.0043 seconds.

I would like to have all timestamps on the global time, in reference to the start of the experiment, not each individual routine. This is because it is rather wobbly to backtrack and calculate the global timings using the local routine times for each individual component. This requires continuously adding up the local routine timings. Moreover, as long as one datapoint would be missing for whatever reason (did not properly save into .xslx) then all the timestamps I would calculate for the subsequent would be affected.

Synchronising stimuli and parallel port components to the screen solves the issue. However, I deliver stimuli via audio only (it is an imagery MEG task) - thus, synchronising my audio and parallel ports with the screen imposes an ‘unnecessary’ limitation of the screen refresh rate - because audio is not related to the screen refresh. Synchronising may cause unnecessary delays - for example the parallel port would wait until the new screen frame to change the trigger value representing the end of audio - even though the audio has already ended.

Question: Is there a way to have global timestamps without synchronising components with the screen?
I suppose a code component will help but I was hesitant to add it, as I am worried an imperfect time extraction code code/inserted in a wrong place may cause even worse delays than the lag due to unnecessary sync with the screen.

Thank you in advance.

I’d recommend using a custom clock, saving time points with this.Exp.addData(‘TimeCheck’,myClock.getTime()).

For this you need the following code

In a Begin Experiment tab of a code component.

myClock = new core.Clock()

Then reset it in Begin Routine of the first routine (perhaps)

myClock.reset()

Dear Wakecarter,

thank you so much for your time and expertise.

This is very promising!

Could I please just double check with you:
1)
$thisExp.addData(‘TimeCheck’, myClock.getTime())

this code component should be manually added for each and every start and end point AND for each and every component separately (components in which timing I am interested it - which is a majority)?
Is the placement of this particular line in the code flow matter a lot? I am worried that if I put it a line too early/too far it may save times which do not actually represent the time I think they do - much worse that the extra delay from frames. Is my thinking correct or should it be reasonably possible to work out the precise placement of this code component?

$myClock = new core.Clock()

Forgive my naivety as I am new. Is the space supposed to be there, and if not, w

Is the space supposed to be there, and if not, will ‘newcore’ be recognised by standalone Psychopy, or should I also somehow define ‘newcore’?

Thank you SO much, I appreciate your time so very much.

The space is supposed to be there.

The dollar is not (if you enter the code in a code component).

I would not recommend trying to save values for every component. This would be better placed in either Begin or End Routine

Sorry. I now think that the new is only for JS.

myClock = core.Clock() #python
myClock = new util.Clock() #JS