# Changing the amount of points in the circles in each frame

**URL:** <https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972>\
**Category:** Coding\
**Tags:** randomization\
**Created:** [May 21, 2023, 8:16am UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972 "2023-05-21T08:16:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shirel](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@shirel](https://discourse.psychopy.org/u/shirel)\
**Post date:** [May 21, 2023, 8:16am UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972/1 "2023-05-21T08:16:32Z")

</div>

Hey!  
I want to create an experiment in which exercises are shown when the operators are ‘clouds of points’ - meaning that two circles will be displayed on the sides of the screen, and within each circle a number of dots.  
I understood that this should be written in code so that the dots can change randomly. I would like to know what should be written in ‘nDots’ (just insert the name of the variable (in the Excel file)?):  
(in begin routine)  
polygonL = visual.ShapeStim(  
win=win, name=‘polygonL’,  
size=(0.5, 0.5), vertices=‘circle’,  
ori=0.0, pos=(-0.60, 0), anchor=‘center’,  
lineWidth=1.0, colorSpace=‘rgb’, lineColor=[-1.0000, -1.0000, -1.0000], fillColor=[0.0039, 0.0039, 0.0039],  
opacity=None, depth=0.0, interpolate=True)

dots2 = visual.DotStim(  
win=win, name=‘dots’,  
nDots=100, dotSize=10.0,  
speed=0.0, dir=0.0, coherence=0.0,  
fieldPos=(-0.6, 0.0), fieldSize=-0.43, fieldAnchor=‘center’, fieldShape=‘circle’,  
signalDots=‘same’, noiseDots=‘direction’,dotLife=0.0,  
color=[-1.0000, -1.0000, -1.0000], colorSpace=‘rgb’, opacity=None,  
depth=-1.0)

polygonR = visual.ShapeStim(  
win=win, name=‘polygonR’,  
size=(0.5, 0.5), vertices=‘circle’,  
ori=0.0, pos=(0.60, 0), anchor=‘center’,  
lineWidth=1.0, colorSpace=‘rgb’, lineColor=[-1.0000, -1.0000, -1.0000], fillColor=[0.0039, 0.0039, 0.0039],  
opacity=None, depth=0.0, interpolate=True)

dots1 = visual.DotStim(  
win=win, name=‘dots1’,  
nDots=100, dotSize=10.0,  
speed=0.0, dir=0.0, coherence=0.0,  
fieldPos=(0.6, 0.0), fieldSize=-0.43, fieldAnchor=‘center’, fieldShape=‘circle’,  
signalDots=‘same’, noiseDots=‘direction’,dotLife=0.0,  
color=[-1.0000, -1.0000, -1.0000], colorSpace=‘rgb’, opacity=None,  
depth=-1.0)

In addition, how can times be inserted in the code? I want each variable to appear for 1.5ms. What I tried (in each frame):  
if t \<= 1.500:  
polygonR.draw()  
dots1.draw()

```
polygonL.draw()
dots2.draw()

```

Thanks!

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [May 22, 2023, 10:50am UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972/2 "2023-05-22T10:50:40Z")

</div>

If you’re running from Builder then yes, `nDots` would be a column name from the conditions file, preceeded by a `$` to indicate that it’s code. If you’re coding from scratch then it would just be whatever variable you’ve previously assigned the value to - which depends on how you’ve written the experiment.

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [May 22, 2023, 11:35am UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972/3 "2023-05-22T11:35:28Z")

</div>

Hello

> [@shirel](#):
>
> In addition, how can times be inserted in the code? I want each variable to appear for 1.5ms. What I tried (in each frame):

switching every 1.5 ms requires very sophisticated hardware. Extremely expensive monitors are capable of 1 ms switching, gaming monitors often claim to be capable of high refresh rates, but they achieve this by “overshooting”, making parts much brighter than they are indented, and they are not in the 1.5 ms range. An average monitor does not switch faster than 16.667 ms.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![shirel](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@shirel](https://discourse.psychopy.org/u/shirel)\
**Post date:** [May 23, 2023, 12:41pm UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972/4 "2023-05-23T12:41:43Z")

</div>

> [@TParsons](#):
>
> If you’re running from Builder then yes, `nDots` would be a column name from the conditions file, preceeded by a `$` to indicate that it’s code. If you’re coding from scratch then it would just be whatever variable you’ve previously assigned the value to - which depends on how you’ve written the experiment.

I tried to run through Builder with a $ sign but it didn’t work…  
Can you explain to me where I went wrong?

There seems to be a problem with this line:

dots = visual.DotStim(  
win=win, name=‘dots’,  
**nDots=$nDots, dotSize=10.0,**  
speed=0.0, dir=0.0, coherence=0.0,  
fieldPos=(-0.6, 0.0), fieldSize=-0.43, fieldAnchor=‘center’, fieldShape=‘circle’,  
signalDots=‘same’, noiseDots=‘direction’,dotLife=0.0,  
color=[-1.0000, -1.0000, -1.0000], colorSpace=‘rgb’, opacity=None,  
depth=-1.0)

---

<div class="post-metadata">

**Author:** ![shirel](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@shirel](https://discourse.psychopy.org/u/shirel)\
**Post date:** [May 23, 2023, 12:45pm UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972/5 "2023-05-23T12:45:07Z")

</div>

And in general, how can you add variable display times within code?

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [May 24, 2023, 9:19am UTC](https://discourse.psychopy.org/t/changing-the-amount-of-points-in-the-circles-in-each-frame/34972/6 "2023-05-24T09:19:53Z")

</div>

Hello shirel

the code-line

```auto
fixDur = random() *(1.5 - 0.5) + 0.5

```

creates a variable called **fixDur** that has a minimum of 0.5 sec. and a maximum of 1.5 sec. Use **$fixDur** in the duration-property of your stimulus.

Best wishes Jens
