How to save time variable

OS: Windows 10
PsychoPy 2020.2.10
What are you trying to achieve?:
I want to save the time when something happens (a message is received) in the data Excel file.
I tried the following code:

But I’m not sure it works because the time saved looks very different compared to the time saved by other “_.started” variables.

Is there any way how I can save the time in the same “timeline”?

I have also tried:

thisExp.addData('master.started', master.tStartRefresh)

But it seems to interfere with the code because the next step doesn’t happen as it is supposed to.

Maybe I’m going about it the wrong way but I haven’t found a better way to do it, if anyone could help me I would be very grateful!
Lucia

Hi There,

There will be some differences between the .started variables and the t variables because they are subtly different - you might find this post helpful with info on various timing variables! Saving stimuli time from the beginning of the experiment - #8 by Becca

Becca

1 Like

Hi Becca,

Thank you very much for your reply, very helpful!!

Exactly!! Thanks to your explanation I thought that I will save the time at which the code component is started (using “.started”) and then add the time at which (the message is received) it is saved using “t” (which from what I understood is the internal clock of the Routine) or is it not correct? This way I think I can get the time when the “message” is received in reference to the global clock, right?

Lucia

Hi Becca,
I have one routine called “trial1” that only has a code component called “code_1”.
I would like to save the time when the “code_1” component starts or the trial1 routine starts and finishes.

I tried this code, but I got an error saying “code_1”/“trial1” doesn’t exist. Is there anything else I should add?

Best,
Lucia

Hi Lucia,
Ah! I don’t think code components actually get written as a component to your script - the code within the component is simply written as code itself not as a component - so it doesn’t have a start time and stop time.

Becca

1 Like

Hi Becca,

I didn’t know that the code is not considered as a component, but makes sense! Thank you very much for this useful information! Can I save the start time and stop time for the whole routine “trial1”?

Best,
Lucia

Yes you should be able to! if in the begin routine you write:
startTime = trial1Clock.getTime() and in the endRoutine write endTime = trial1Clock.getTime() then save those values :slight_smile:

Becca

1 Like