I am using Psychopy version 1.90.1, standalone, running on Windows 10.
I am using a parallel port to send event triggers to Brain Products Recorder.
AIM: My aim is to send an event trigger every time the space bar is pressed.
What I have done: My code (below) is written in a code component in builder. I have included win.logOnFlip() so I can record when the trigger was sent and compare this to when the spacebar was pressed in the logfile. I am not receiving any coding errors and this code is functioning enough for the triggers to be recorded by the EEG Recorder software. I have tried including the code under “Each Frame” in the “Begin Routine” section however this does not generate the trigger.
***Begin Experiment*** from psychopy import parallel target_space = parallel.ParallelPort(address=0xD050) ***Begin Routine*** # keep track if the trigger has started if hasattr(target_space, 'status'): target_space.status = NOT_STARTED ***Each Frame*** if (target_response.status == STARTED) and target_space.status == NOT_STARTED: if len(target_response.keys)>0: if 'space' in target_response.keys: # keep track of start time/frame for later target_space.tStart = t target_space.frameNStart = frameN # exact frame index target_space.status = STARTED win.callOnFlip(target_space.setData, int(target_space_trigger)) win.logOnFlip(level=logging.EXP, msg = 'target_space_start') if target_space.status == STARTED and frameN >= (target_space.frameNStart + 2): target_space.status = STOPPED win.callOnFlip(target_space.setData, int(0))
What specifically went wrong when you tried that?:
When considering the logfile output (table below) I can see that my trigger event (i.e. target_space_start) is 50-60ms after the key response was made (i.e. keypress: space).
I would be grateful if someone could review the logic of my code above and let me know if this could be causing the delay. I am v new to Psychopy and have written this code based on the code automatically created by the p_port component in builder.
Also - would any delay be expected or should these two events occur simultaneously?
Many thanks in advance for your help