Hello everyone,
I m trying to create a mask for my experiment using the PsychoPy Coder but I have some issues with my code.
The mask_screen consisted of 200 crosses normally distributed around the center of the screen, but because it will appear many times throughout the experiment I tried to create it with a function and call it when necessary.
the code I write is the following:
def mask():
import numpy as np
import psychopy.visual
pos_X = np.random.normal(0, 3.1, 200)
pos_Y = np.random.normal(0, 3.1, 200)
for i in range (200):
str("vertical_line_") + str("i") = visual.Line(win = win, start= (pos_X[i]-3, pos_Y[i]),
end= (pos_X[i]+3, pos_Y[i]), units = 'deg', lineColor = [-1, -1, -1])
vertical_line_("i").draw()
str("horizontal_line_") + str("i") = visual.Line(win = win, start= (pos_X[i], pos_Y[i]-3),
end= (pos_X[i], pos_Y[i]+3), units = 'deg', lineColor = [-1, -1, -1])
horizontal_line_("i").draw()
The error:
File “C:\Users\user\Desktop\peiramata_Psychopy\untitled.py”, line 8
** str(“vertical_line_”) + str(“i”) = visual.Line(win = win, start= (pos_X[i]-3, pos_Y[i]), **
** ^**
SyntaxError: can’t assign to operator
##### Experiment ended. #####
My questions are:
A) Is it possible to create this type of Stims with a function?
B) Is it just a typo? did I write something wrong?
Sorry for the long post!