Sending Triggers via Parallel Port using PsychoPy (Python Script not Builder)

67 Views Asked by At

We are trying to send triggers to a BioNex box which records peripheral physiology such as skin conductance, respiration, ECG etc. We are trying to send triggers on multiple occasions throughout our task including when a stimulus is presented, when a stimulus presentation ends, and when a participant answers questions/rating scales.

We have tried some other suggestions found on the internet but have been unsucsessful. We tried using the parallel port out in builder and then compiling that to python code which did not work. We are using the StartTech PEX1P2 parallel port card and have installed all the necessary drivers. We found the parallel port adress (LPT1 - 0378). Thanks for any help in advanced!

import psychopy.clock as clock
import psychopy.parallel as parallel


"""
Uncomment the following two lines and comment the third one if you get
the error message 'psychopy.parallel has been imported but no parallel
port driver found. Install either inpout32, inpoutx64 or dlportio.
"""
# address = 0378
# parallel_port = parallel.ParallelPort(address=address)
bionex_port = parallel.ParallelPort()
trig_start = 1
trig_event = 54
trig_eeg = 255
trig_end = 255
# START
# Send trigger with event number 1 to Bionex box.
bionex_port.setData(trig_start)
wait_time_start = 2
clock.wait(wait_time_start)
# Send trigger with event number 54 to Bionex box.
bionex_port.setData(trig_event)
wait_time0 = 4
clock.wait(wait_time0)
bionex_port.setData(trig_event)
# Trigger the EEG. I assume that the BNC cable is connected to pin 9.
wait_time1 = 2
clock.wait(wait_time1)
bionex_port.setData(trig_eeg)
wait_time2 = 3
clock.wait(wait_time2)
bionex_port.setData(trig_event)
wait_time_end = 2
clock.wait(wait_time_end)
bionex_port.setData(trig_end)
# END
0

There are 0 best solutions below