Send TTL from psychopy to BrainAmp EEG system

Hello,

I’m doing an EEG experiment using PsychPy and BrainVision Software. The computers are connected via parallel port (BrainVision trigger box).
The task consists in images presentation.

I dont’ know how to send a trigger from psychopy to the BrainAmp… and a bit clueless.
I try to insert a I/O parallel port component, defining like that the element of the component


And i insert a code as done by others post on similar topic.

Unfortunately, it doesn’t work.

I’d be grateful for any suggestions about what I can try.
Thank you,

Aurore

If you are using the Trigger Box by Brain Products (see here: https://www.brainproducts.com/productdetails.php?id=55), then you are not using the parallel port and hence a parallel port component will not work.

The trigger box is emulating a serial port (COM port on Windows) and you have to send trigger signals via serial port. I am not experienced with the “Builder” but perhaps you can insert a code component. See the official example by Brain Products below:

import serial
import time
import threading

Connected = True
PulseWidth = 0.01

def ReadThread(port):
    while Connected:
        if port.inWaiting() > 0:
            print "0x%X"%ord(port.read(1))

# Open the Windows device manager, search for the "TriggerBox VirtualSerial Port (COM6)"
# in "Ports /COM & LPT)" and enter the COM port number in the constructor.
port = serial.Serial("COM6")

# Start the read thread
thread = threading.Thread(target=ReadThread, args=(port,))
thread.start()

# Set the port to an initial state
port.write([0x00])
time.sleep(PulseWidth)

# Set Bit 0, Pin 2 of the Output(to Amp) connector
port.write([0x01])
time.sleep(PulseWidth)

# Reset Bit 0, Pin 2 of the Output(to Amp) connector
port.write([0x00])
time.sleep(PulseWidth)

# Reset the port to its default state
port.write([0xFF])
time.sleep(PulseWidth)

# Terminate the read thread
Connected = False
thread.join(1.0)

# Close the serial port
port.close()

Thank you very much for your answer.

I will try this.

Aurore.

Hi Ameugnot,

I was wondering whether you tried this approach. I am having a syntax error after this part:

def ReadThread(port):
while Connected:
if port.inWaiting() > 0:
print “0x%X”%ord(port.read(1))

Is that familiar to you?

Thank you very much,
Leidy

Hi Ameugnot,

It worked out! it was just a typo. Now one trigger is working! Now, I have the question: How do you put in the task more than one trigger? what numbers one should put here in port.write([0x01]) and in which tabs? I need three triggers for my task.

Thank you very much!
Leidy

@Leidy you determine the trigger value with this part: 0x01 … simply replace that with 0x02, 0x03, 0x04, etc. and don’t forget to reset to 0x00 after sending a trigger (as shown in the example I posted).

I don’t really understand what you mean by “in which tabs”. Does that relate to the Builder?