OS (e.g. WinXP): Windows XP
PsychoPy version (e.g. 1.84.x): 1.85.3
Standard Standalone? (y/n) If not then what?: Not sure
What are you trying to achieve?:
I want to present 20 frames of masking images (gratingStim) and then followed by a few frames of an object image (probe) and then followed by another 20 frames of masking images (gratingStim). The goal is to send a trigger to the EEG system (BrainVision) via a parallel port.
What did you try to make it work?:
Here are the code and stimuli I use to do so: https://drive.google.com/open?id=1ddVuhr3pwP_j10g6C4srnTbTuv02WqvE, and particularly, these are the code for sending the trigger when the probe is set to present (onset)
from psychopy import parallel
parallel.setPortAddress(0x378)
def sendCode(code,dur):
parallel.setData(code)
core.wait(dur)
parallel.setData(0)
# *probe* updates
if frameN >= 0.0 and probe.status == NOT_STARTED:
# keep track of start time/frame for later
probe.tStart = t
probe.frameNStart = frameN # exact frame index
probe.setAutoDraw(True)
win.callOnFlip(sendCode, trigger_code_probe,0.01) # send the trigger in the next refresh and wait for 0.01 seconds
win.callOnFlip(trials.addData,'probe_onset',globalClock.getTime()) # save the onset time to the result file
win.logOnFlip(level=logging.EXP,msg="trigger {}".format(trigger_code_probe)) # log th onset time to the log file
if probe.status == STARTED and frameN >= (probe.frameNStart + curr):
probe.setAutoDraw(False)
win.callOnFlip(parallel.setData, int(0)) # reset the trigger
From what I have read, the timing could be influenced by the way I present the masks before and after the probe. I used GratingStim to generate gaussian noise images as the masks and I generate-present them as I need to present them. I would love to learn how to load all the masks and then present them one by one.
Any other suggestions/solutions would be appreciated!