Send LSL triggers at specific times during a stimulus

Hello! We use Psychopy experiments to collect fNIRS data using NIRx, which uses LSL triggers. We typically send triggers before trial types/conditions adding the following code under “Begin Routine”: outlet.push_sample(x=[marker])

Now we are programming a different experiment that shows a continuous 5 minute movie, and we would like to send LSL triggers at specific time points during the movie to mark conditions, which last anywhere from 4 to 16 seconds each. For example, condition A runs from 00:00 - 00:10, then condition B runs from 00:10 - 00:16, then back to condition A for 4 more seconds, etc. I’m guess I need to use the “Each Frame” section of the custom code, but for the life of me I cannot figure out how to feed it the times. The movie is 30 frames per second, and I can convert seconds to frames if need be. It will be the same times for each participant.

Thanks in advance!

Hi, I don’t have access to this fNIR device but I imagine the code you would need would be something like this:

Begin Routine
-------------------
#send trigger at the beginning of movie
outlet.push_sample(x=[marker])

Each frame
----------
if t == 10: 
    outlet.push_sample(x=[marker]) #send trigger at 10 seconds
if t == 16:
    outlet.push_sample(x=[marker]) #send trigger at 16 seconds

I realise this is somewhat inefficient as you’re hardcoding the timestamps of when you want to send the trigger but I’m guessing each condition is of differing lengths so this is probably the most straightforward