Logging stimuls start and end (or onset and offset) with Builder

Hi folks,

I’m trying to set up a task in Builder, and would like the start and end times of the stimuli (relative to the start of the task) in my CSV log; I want to make sure my timing is what I expect it to be.

I feel like there’s probably an easy way to do this, but I’m not seeing it anywhere. It looks like I could bodge something together with code blocks but… there must be an easier way?

For what it’s worth, my code blocks tactic is:

thisExp.addData('stim_onset', stim.tStart)

but that’s reporting times relative to the start of the routine and I don’t know how to get an end time out of it.

Thanks!
-Nate

Also: I could probably hack this up in Coder pretty easily but I’m really, really hoping to have a thing that runs easily both in locally-installed psychopy and on pavlovia.

Okay. I have this working for onsets. The trick:

  • Add a Variable (call it routineStart or something), set its “Routine start value” to core.monotonicClock.getTime(). globalClock would probably work as well; I’m not sure why there are multiple global clocks. I think core.monotonicClock is probably the best global clock to use.
  • Add a Code block, running at End Routine, that does thisExp.addData('stim_onset', routineStart + stim.tStart)

I don’t think there’s a way to log the end/offset times for stimuli.

This seems like something to add to the Components, but I’m not sure if this is the kind of PR that would get accepted…

Further discussion at https://github.com/psychopy/psychopy/issues/2187