Conditional file

OS (e.g. Win10): WIN 11

PsychoPy version (e.g. 1.84.x): 2023.1.2

Standard Standalone? (y/n) If not then what?:yes

Hi guys,

I have a question, why I can’t achieve the above result with the variables in the condition file, and the program also reports an error: variable not defined. Is this because the variables in the condition file cannot be used to define the stimulus shape.
Thank you for your kindness.
Yours truly hu.

Running: E:\psychopy 文件\5555\untitled_lastrun.py ###############
1091.6264 INFO Loaded monitor calibration from [‘2023_05_29 18:19’]
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. Contribute - pygame wiki
3.9639 WARNING User requested fullscreen with size [1024 768], but screen is actually [1920, 1080]. Using actual size
Traceback (most recent call last):
File “E:\psychopy 文件\5555\untitled_lastrun.py”, line 106, in
edges=targetshape, size=(0.5, 0.5),
NameError: name ‘targetshape’ is not defined
0.5919 WARNING Monitor specification not found. Creating a temporary one…
################ Experiment ended with exit code 1 [pid:21596] #################
1102.2698 INFO Loaded monitor calibration from [‘2023_05_29 18:19’]

Hello,
Can you please share the condition file?
Please also shows us where you try using this variable (take a screenshot of the component properties).

Thanks

Hi Chen.
Thank you very much for your advice, but I can’t upload the image due to network problem or whatever reason. Every time I upload an image there is always an error and it reminds me "sorry , there was an error uploading that file. please try again. “. So, to make my problem more clear, I will describe in words how I set up the experiment.
Conditions.xlsx(targetshape=[4,5])----components----polygon----shape:regular polygon ----num.vertices:$targetshape. I imported the conditions file into the loop, rendering in The output says the variable targetshape is not defined. What is the reason for this?
Thank you once more for your kindness.
Yours truly Hu

Hello,

there seems to be a typo

instead of targetshape.

Best wishes Jens

Hi Jens.
I made a typo here, but the variables used in Psychopy are correct, and I still can’t solve the problem. Is it possible that regular polygon cannot use the variables($) in the condition file?
Best wishes Hu

Hello

do mind posting a screenshot of your condition-file showing targetshape and a screenshot of the property where you use targetshape?

Best wishes Jens

Hi Jens,

Due to the time difference, I am just responding to you now. I am unable to upload image information, perhaps due to network restrictions or other reasons. Whenever I try to upload an image, I get the message “Sorry, there was an error uploading that file. Please try again.” Therefore, to make my question clearer, I will use text to describe how I set up the experiment.

In the loop, I imported “Conditions.xlsx(targetshape=[4,5])” → components → polygon → shape: regular polygon → num.vertices: $targetshape.

Best wishes, Hu

Hello

basically your experiment looked like the following:

  1. Conditions.xlsx
    grafik

Notice, that targetshape is only a number not a tuple as you wrote [4,5].

  1. experiment flow
    grafik

  2. parameter setting polygon

  3. the code-component initializes targetshape in a Begin experiment tab with a value that won’t be used in the experiment. Without this PsychoPy throws the error-message that targetshape is not defined. This is due to the fact that the polygon is defined before targetshape from the condition-file become available.

Anyway setting set every repeat or set every frame throws an error: AttributeError: ‘Polygon’ object has no attribute ‘setNVertices’. So, this is not the way to go. I also receive a warning: I don’t know the appropriate default value for a ‘nVertices’ parameter.

Best wishes Jens

Hello

one way to get the experiment running is to define the polygons you want to use via the Builder and change their opacity depending on the condition. The following experiment uses three predefined polygons, triangle, square and star. Their opacity is set based on the value of the variable condition.

  1. Excel-file
    grafik

  2. Experiment flow

  3. Set the opacity of each polygon (opacTri, opacSquare, opacStar) on every repeat. See the example for the polygon polyTri.

  4. in a Begin experiment tab initialize each variable

nVertices = 2

opacTri = 0
opacSquare = 0
opacStar = 0
  1. in the Begin routine tab set the opacity of each polygon
if condition == 3:
    opacTri = 1
    opacSquare = 0
    opacStar = 0
elif condition == 4:
    opacTri = 0
    opacSquare = 1
    opacStar = 0
elif condition == 5:
    opacTri = 0
    opacSquare = 0
    opacStar = 1

Best wishes Jens

1 Like

Hi Jens,

Thank you very much for patiently answering my questions. Your approach has been very helpful in my experiment design.

Best regards, Hu

1 Like