Triggering PsychoPy with TTL signal from Qualisys Track Manager

I am trying to send a TTL trigger from Qualisys Track Manager (QTM) via a BNC cable to a computer running PsychoPy. I am not quite sure what the best way to interface the BNC cable with the computer would be, as it is a laptop with only USB A, USB C, and an HDMI port.

Ideally, QTM would start a data capture and send a single square wave to PsychoPy, and PsychoPy (which would be started, and at a wait screen waiting for an input) would receive the square wave and start a trial. What is the best way to convert the signal into something PsychoPy can understand?

I see that under I/O PsychoPy only has Parallel Out and Serial Out options. Are there any Python packages which can allow PsychoPy to accept inputs?

Are the suggestions in this thread of any help?

Hi,

Disclaimer: I am an employee of Qualisys.

QTM has the capability to initiate a recording using a UDP packet. Furthermore, upon starting, it sends out a UDP packet that can be intercepted by Psychopy to trigger an experiment. However, there are certain considerations to keep in mind, especially concerning timing.

You can refer to the documentation of the UDP packet functionality here: Qualisys Track Manager Help.

Should you have any further questions or require assistance, our support staff is always ready to help. You can reach them at support@qualisys.com.

Good luck, Martin

Additionally, for practical implementation, you might find this Python program useful for sending and receiving these packets: GitHub - ulvs/udp_trigger.

Extra post due to the 2 link minimum for new members…

Hi, thanks for the info! I was able to successfully start a QTM capture from a Python script using this info. For future reproducibility, here is the Python code I used. The ‘host’ object is the IPv4 Address of the computer where QTM is installed.

import socket

# create space, host, and port objects
host = 'ip.address'
port = 8989

# define the XML start packet
start = '''
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CaptureStart>
    <Name VALUE="measurement directory"/>
    <Delay VALUE="0"/>
    <PacketID VALUE="increasing number"/>
    <HostName VALUE="computer name"/>
    <ProcessID VALUE="process id"/>
    <Notes VALUE=""/>
    <Description VALUE=""/>
    <TimeCode VALUE=""/>
</CaptureStart>
'''

client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

client.sendto(start.encode('UTF-8'), (host, port))

client.close()
1 Like