OS (e.g. Win10): Ubuntu
PsychoPy version (e.g. 2024.2.4 Py 3.8): Psychopy 2024.2.4 Python 3.10.11
Standard Standalone Installation? (y/n) If not then what?: y
Do you want it to also run online? (y/n) n
What are you trying to achieve?:
I have a go/no-go task that sends EEG triggers via parallel port, and I need precise timing for ERPs. I built the task in Builder, but the Parallel Out component doesn’t fit my use case because:
-
I run the task on both Linux and Windows and want to set the port address based on the OS.
-
On Linux, the port is only recognised if I leave the address field blank (instead of specifying its address
/dev/parport0)
So I want to send triggers from custom code, with a 10ms pulse, synced to when the digit is presented on the screen.
What did you try to make it work?:
I looked at the code generated by the Parallel Out component and tried to replicate its behaviour by adding this custom code to the digit presentation routine:
Each Frame
if p_port.status == NOT_STARTED and digit.status == STARTED:
p_port.status = STARTED
win.callOnFlip(p_port.setData, int(1))
if tThisFlipGlobal > p_port.tStartRefresh + 0.01 - frameTolerance:
p_port.status = FINISHED
win.callOnFlip(p_port.setData, int(0))
End Routine
if p_port.status == STARTED:
win.callOnFlip(p_port.setData, int(0))
Would this work well in terms of timing and duration, or is there something else that the Parallel Out component handles that I should keep in mind?
Or overall, any better suggestion for sending triggers via custom code?
Link to the most relevant existing thread you have found: Trigger delays are highly variable and imprecise - #3 by IRIO