I’m new to PsychoPy and I’m using the v2023.1.2 with a combination of builder with snippets of code.
I have a routine called outcomes that has two text components and two video components. The routine outcomes is presented after a routine trial, which includes a key_resp that stores all answers and check for a correct response in a column named ‘correct’ in an Excel sheet. I have the two video and two text because they are differentially positioned in the screen (bottom or up), and I want to half of the trials present the video above the text and half of the trials present the text above the video; but every time just one text & one video should be presented. The video & text presented depend on the correct answer, so I have a code that reads from the Excel sheet correct column and if the answer was correct it shows LM_text and video1, whereas if it wasn’t it shows HM_text and video2. This is the code that I’m using:
In the before experiment tab:
from psychopy.sound import Sound
In the begin experiment tab:
correct_symbol = None
symbol_number = None
text_money1 = None
text_money2 = None
video_pain1 = None
video_pain2 = None
In the begin routine tab:
if symbol_number == '1':
if trial_num % 2 == 0: # Display text above video
text_money1.setText(row['LM_text'])
video_pain1.setMovie(row['video1'])
else: # Display video above text
text_money2.setText(row['LM_text'])
video_pain2.setMovie(row['video1'])
elif symbol_number == '2':
if trial_num % 2 == 0: # Display text above video
text_money1.setText(row['HM_text'])
video_pain1.setMovie(row['video2'])
else: # Display video above text
text_money2.setText(row['HM_text'])
video_pain2.setMovie(row['video2'])
else:
print('Invalid correct symbol.')
exit(1)
print('Correct Symbol:', correct_symbol)
print('Text 1:', text_money1)
print('Video 1:', video_pain1)
print('Text 2:', text_money2)
print('Video 2:', video_pain2)
the error is: AttributeError: ‘NoneType’ object has no attribute ‘setMovie’, which comes from video_pain2.setMovie(row[‘video1’]). I know this error means that instead of an instance of whatever video, I’ve actually got None. I don’t know how to solve the issue.
Additionall -in case it matters-, I really don’t care about the sound of the video, I just want it to be displayed and played automatically once, while simultaniously showing the text either above or below the video.
Any help would be appreciated! I can also send the PyschoPy and Excel files if that helps.
Thank you!
Best,
Judit