Auditory offset time not saving

OS: Windows 10
PsychoPy version: 2022.2.4
What are you trying to achieve?: I want to save auditory offset times.

Hi,

My experiment is composed of trials involving first an auditory tone, then two sequentially presented visual gratings (Gabors). I am using the Builder and have ticked the box for my auditory cue to save onset/offset times. However, it is only saving the onset times and it does not save any offset times. Furthermore, the onset times it saves appear to be relative to the start of the trial and not the start of the experiment (contrary to my visual stimuli which save onset and offset times relative to the start of the experiment). How can I save the offset times of the auditory cue and change the clock used for the onset times?

Hi There,

Does the auditory stim have a known duration? or is the duration field blank? if it is blank it might be possible that the offset is not saved, in which case I’de infer from your stim start time + audiofile duration. It is curious that the visual stim save relative to the start of the experiment - are you using the grating component? could you share a screenshot of the data settings used and please tell us what version of psychopy you are using?

Thanks!

Becca

Hi Becca,

Thanks for your quick reply! The auditory stimulus does have a known duration (250 ms) and yes, I am using the grating component. I’m using version 2022.2.4 and is this what you mean by data settings?

data_settings

Hi There,

Sorry I meant the “data” tab in your grating stimulus and auditory stimulus. Does the “duration” field of the sound component therefore read as 0.25? or is the field blank?

Becca

auditory_stimulus_settings
auditory_stimulus_settings2
visual_stimulus_settings

Yep, the duration is 0.25. And the sound is a numerical value rather than a sound file.

Hi There,

This is odd - I just made a quick mockup to test and both the grating and sound in this file have start and stop times saved - and both are relative to experiment start
demo1.psyexp (8.6 KB) This was the same if I changed the sound “every repeat” using a spreadsheet as you have - are you on a windows or a mac? please can you try this demo and confirm the audio offset is stored and that both the audio and grating times are relative to experiment.

Becca

I’m using Windows 10. Yep, the demo you made seems to work fine. It is recording the start and stop time of the auditory stimulus and all timing is relative to the start of the experiment. Some of the visual grating stop times are not being recorded though.

I believe the lack of stop times is when the stop of that stimulus also signifies the end of the routine - so for instance if there was a fixation cross that lasted 2 seconds (so longer than the grating) the offset would be saved - could you give that a go and confirm? Please could you try to replace the sound in this basic demo with the sounds you are using for your exp and check the onsets/offsets save in a similar way?

Thanks,
Becca

Ok, I changed the trials loop to pull the frequency from my excel spreadsheet and set the tone to change every trial. It still saves the stop times of the auditory stimuli, but now, it doesn’t record all of the stop times, they are dropped in some trials.

is it that it is dropping the stop times of some auditory stimuli or the grating stimuli?

Becca

The auditory stop times are dropped in some trials.

Hi There,

OK so I’ve had a look into this and it looks like the status of the sound is changing to stopped before the time is written to the data file, I need to explore to better understand what is happening. However may I suggest a workaround for you to use at the moment. Hopefully these steps are clear!:

  1. From psychopy, select File > Preferences > Hardware, ensure audio library is PTB, sounddevice, pyo, pygame in that order → click apply.
  2. in your experiment settings :experiment_settings: > audio set library to ptb and latency priority to 4
  3. restart psychopy so the preferences are applied.
  4. rerun the experiment (start with my demo where you replaced the input to be your frequencies)
  5. we’re going to use the timestamps from the log files to check timings rather than the csv (technically this is always the most accurate approach anyway.

To analyse the log files please download these two files and put them in the same directory as your .psyexp file:

data_tools.py (1.4 KB)

extractFromLogs.py (869 Bytes)

Open “extractFromLogs.py” in psychopy coder view and make sure that line 8 refers to the name of the log file you are analysing. This will output a data file called “test.csv” with one column of audio onsets and one of audio offsets for this participant.

Hopefully this gives you audio onset and offset times that you need!

Becca

Hi Becca,

Yep, that seems to work! I can access the start and stop times of the auditory stimuli for both the demo experiment you gave me and my own experiment. Thanks so much for all your help!