I need to know the time of presentation of my stimuli

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 7
PsychoPy version (e.g. 1.84.x): 1.83
Standard Standalone? (y/n) If not then what?: Standalone

Hi there! I’m using the builder view to design an experiment that goes like this:

  1. Fixation cross (1 s)
  2. Stimulus (7 s)
  3. Fixation cross (jittered, 6 to 10 s)
  4. Question (4 s)

All these elements are inside a loop, each one represented by a routine, and a text component inserted within that corresponding routine. In the case of the stimulus, the name of the routine is “Estimulo” and the name of the text component is “Medio” (Spanish).

I need to know the exact time when the stimulus is presented. The default .csv output file doesn’t contain this information, and I would like you to tell me if you know a way to get it.

Thanks a lot!

Hello Alan,
I think you can find this information in the experiment log file.
It might not be handy to extract though. Another way is to insert a code component into the routine and add the code to store what you need in the data file. Have a look at http://www.psychopy.org/api/data.html.

Cheers,
LF

1 Like

Hi Luca,

Similar to Alan I want to record onset and offset times of each stimulus in my experiment. This information is in the log file, but like you said that is difficult to extract. In terms of using exp.addData() to add this information to my csv file, what do I call the onset and offset times, i.e. what does in the parentheses of this line?

Also, would I just put the code component with this information right after the image component in my builder?

Thank you!!
Sarah

Hi Sarah, let me make an example. So imagine that you want to record the onset and offset time of a text component which starts at the beginning of the routine and ends 1 second after. If you look at the python code that is generated out of the builder script, you get:

while continueRoutine and routineTimer.getTime() > 0: # get current time t = trialClock.getTime() frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # text updates if t >= 0.0 and text.status == NOT_STARTED: # keep track of start time/frame for later text.tStart = t text.frameNStart = frameN # exact frame index text.setAutoDraw(True) frameRemains = 0.0 + 1.0- win.monitorFramePeriod * 0.75 # most of one frame period left if text.status == STARTED and t >= frameRemains: text.setAutoDraw(False) # check if all components have finished if not continueRoutine: # a component has requested a forced-end of Routine break continueRoutine = False # will revert to True if at least one component still running for thisComponent in trialComponents: if hasattr(thisComponent, “status”) and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # check for quit (the Esc key) if endExpNow or event.getKeys(keyList=[“escape”]): core.quit() # refresh the screen if continueRoutine: # don’t flip if this routine is over or we’ll get a blank screen win.flip()

So you know that the onset time is stored in text.tStart.You can add the instruction to get the offset time:

if text.status == STARTED and t >= frameRemains: text.setAutoDraw(False) text.tEnd = t

Then to save the value in the data file:

exp.addData(‘TextOnset’, text.tStart)exp.addData(‘TextOffset’, text.tEnd)

You might want to look at all the different components to see if they provide a more accurate timing procedure and maybe refer to that one.Did I answer to the question?

Cheers,L.

Hi Luca,

This is really useful. I’m having issues placing the

exp.addData(‘TextOnset’, text.tStart)

Command into the code. It does not seem to like it. In the example you give where would it be best to place this to get the required data into the excel file.

Best,
Richard

Hi Luca,

Thanks - that is useful. I will try to implement this and post again if I have a problem. Thank you!

Richard are you using the builder or the coder? I am also going to be figuring out where to place this in a code component within a routine, so if I can get that to work I will write back to try to help you.

Best,
Sarah

Hi Richard,

Are you still having trouble with this? I was able to have success by using the coder instead of a code componnent in the builder.

Best,
Sarah

Hello Sarah,

I have the same problem of not knowing the stimuli offset, did you transfer all of your experiment to the coder to solve this problem? If so, could you share it with us?

If you made the experiment online of Pavlovia, did this cause any issues?

Thank you!
Deniz

Hi, looking into the code that the Builder outputs, I see that the start and end time of a component (considering screen refresh) are saved in [component].tStartRefresh and [component].tStopRefresh.

Thank you very much!

@Deniz To answer your question above, I am trying to make an experiment online and getting many issues saving the start and end time of a component while considering screen refresh. Will update when I get answers.

1 Like

Thank you very much!

8 Tem 2020 Çar, saat 02:17 tarihinde Ross Kempner via PsychoPy <psychopy@discoursemail.com> şunu yazdı:

Hi Sarah!
I heartily hope you are still active nowadays. I have a similar issue to extract the starting and finished time points of my components in the builder. I am so thankful @rkempner – Ross has stated it has been stored in [component].tStartRefresh

However, I check the code and it is mentioned that somehow they reset it in certain parts of the code and I am afraid it’s not getting me the exact timing (the time when the program is started) which I wish to get

Additionally from the forum above, it recommends getting the time from the logfile which I am not sure how.

Any explanation will be very helpful to get me more illuminated from the confusion.
Thanks a lot! :smile:

Warm regards,
Syifa