Hello,
I am currently trying to modify a script previously used in the group. For this current study, the objective is to present black bars to the participants which will be tilted. The participant will then indicate with the arrows of the keyboard to which side the bar is tilted and will subsequently receive feedback (a 1 second video will appear peripherally on the screen).
So the steps in the code are:
- Cross in the middle appears
- Cross disappears
- Bar appears for 200 ms
- Bar disappears
-Cross appears and stays waiting for participant’s response (press of either right or left arrow) - Cross continues on the screen
- Short video appears on either side of the screen
- restart the loop
My main problem is: everything is working but the video. The video does not show on the screen, however there are no error messages and the code for the video works fine when done completely separately.
The system I am using is linux and psychopy version is 2021.2.3.
trials.py (13.2 KB)
I’ve uploaded the script for better comprehension, but the main part of the code I need help with is the following:
import os
from psychopy import visual, core, monitors, event, constants, prefs#, gui
prefs.hardware['audioLib'] = ['PTB', 'sounddevice', 'pyo', 'pygame']
print(prefs)
from psychopy import sound
import pylink
import random
import local_settings
from get_sample import gaze_square, gaze_ellipse #gaze-contingency routine
import sys
import cv2
import time
def comp_main(this_stimuli, win, fixkreuz, timer, tracker, p_port, background, this_central_stimuli, dataFileName):
core.wait(0.5)
central_bar = visual.ImageStim(win=win, size=[50, 200], name="cent_bar", pos=(0, 0),
image=this_central_stimuli.file_path) #central bar
fix_time = random.randrange(1500, 2500) / 1000.0 #randomise inter-trial interval
fixkreuz_neutral = visual.ImageStim(win=win, name="fixcross", pos=(0, 0), image="fixkreuz.png", depth=-1)
background.setAutoDraw(True)
fixkreuz_neutral.setAutoDraw(True) #draw background and fix cross
win.flip()
timer.reset() #timer for presentation timing
t = timer.getTime()
fixkreuz_neutral.setAutoDraw(False) # fix cross disappears
win.flip()
central_bar.setAutoDraw(True) # draw central bar
core.wait(0.2) # need to present bar for 200 ms
win.flip()
central_bar.setAutoDraw(False) #remove bar
win.flip()
fixkreuz_neutral.setAutoDraw(True) # do not remove fixcross
win.flip()
event.waitKeys(keyList=["left", "right"])
filename = str(this_stimuli.file_path)
video_stimulus = visual.MovieStim3(win=win, filename=filename, size=[320,240], pos=this_stimuli.position, flipVert=False, flipHoriz=False, loop=False,
noAudio=True, fps = 30)
while video_stimulus.status !=constants.FINISHED: #this loop will keep the playing the movie until it finishes
video_stimulus.draw()
win.flip()
if p_port is not None:
win.callOnFlip(p_port.setData, this_stimuli.trigger) # send trigger with image flip
win.flip()
timer.reset()
t = timer.getTime()
# same as fixcross
while t < local_settings.minPeripheralDuration: #minimum presentation duration
t = timer.getTime()
fixkreuz_neutral.setAutoDraw(False)
win.flip()
I am very grateful for every advice I can get.
Best,
Laura