psychopy.org | Reference | Downloads | Github

How to get time for the component of routine?

Good evening!
I am trying to get exact time (in ms) for one of the components of my routine. But I could not find the code that would help me to do that.
My goal is to get timing of this particular component (RDK) within the loop. I can get timing of the whole routine by this string (currentT = NC_CueClock.getTime()), but when I try to put the name of component instead of routine name, is says that ‘name_of_my_componentClock’ is not defined.

How can I do that?
I will appreciate a lot any advise!
Thanx in advance!

The routine has a clock, so that components know when to appear as scheduled during that routine. Components don’t get (or need) clocks themselves.

But if you inspect the code that Builder generates, you’ll see that when a component starts, it gets assigned a start time based on the trial clock. That will be an attribute that looks something like this:

name_of_my_component.tStart

I’m not sure if that onset time is what you mean by " exact time (in ms) for one of the components of my routine". Bear in mind:

  • This is a time in seconds, relative to the start of the routine.
  • It is precise only to within 1 screen refresh period (typically up to 16.7 ms before the onset of the relevant screen refresh).

Thanx a lot for your answer! it helped!
I realised also that it is possible to put clock in the end of previous routine and then use getTime() attribute of this clock in next routine (which is looped) in each frame window to get exact time (by comparing values from the list with timer). I am not sure that it is clear what solution and for which purpose i made, but the main thing is it worked. So thanx again!