Inserting EEG triggers from one script into another

Hi all,
I am working on adding EEG triggers to this script I wrote through builder mode and haven’t found anything in prior posts with this particular issue. The experiment is a series of audio recordings of sentence stems and visual word endings – the recordings and words are called up through a spreadsheet. We are interested in participants’ responses upon viewing the word endings. Below is my current script without the EEG triggers, and beneath it is a script from someone else with the same system they have used to insert EEG triggers. I am looking to record beginning at the end of the “Sentences” stimulus, including when during “target” and “response," and ending after they make their response.

Thank you very much for any help!

Here is the script I already have:

------Prepare to start Routine “trial1”-------

t = 0

trial1Clock.reset()  # clock

frameN = -1

continueRoutine = True

# update component parameters for each repeat

target.setColor([1.000,1.000,1.000], colorSpace='rgb')

target.setText(word)

response = event.BuilderKeyResponse()

Sentences.setSound(sounds, secs=6)

# keep track of which components have finished

trial1Components = [target, response, Sentences, text_2]

for thisComponent in trial1Components:

    if hasattr(thisComponent, 'status'):

        thisComponent.status = NOT_STARTED

And here is the code to insert EEG triggers I am trying to integrate:

    # Send event marker to NetStation
    if mode=='eeg' and stage=='expt':
        code = 'item'
        ns.sync()
        ns.send_event(code, label='item', timestamp=egi.ms_localtime(), table = { 'item' : curr_item })

As it says in your heading, the ‘script’ you posted is just the preparation for the routine. It doesn’t show the part where you stimuli are actually drawn (shown on screen). But your triggers would have to be sent when the stimuli are drawn. This part will be under # -------Start Routine "trial"------- in the compiled script (F5 in Builder view if I’m not mistaken).

In your code component you can also insert code in the tab ‘each frame’. That is where you probably want your trigger to go. What is the ns part in the code for NetStation? Do you import that at some point?