-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdotGenerate.py
143 lines (102 loc) · 4.6 KB
/
dotGenerate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from psychopy import visual, event, core
import numpy as np
import random
win = visual.Window([1000,1000], fullscr=False,color="black", winType='pyglet', waitBlanking=False)
win.clearBuffer(color=True)
def set_trials_sqr(n_reps, direction_vec, coherence_level,n_dotsPerTrail,shuff=True):
""" creates vector of all motion directions """
ncohernece = list(range(0, len(coherence_level)))
nAngle = list(range(0, len(direction_vec)))
nDots = list(range(0, len(n_dotsPerTrail)))
listLength = (len(direction_vec)*len(direction_vec)*len(ncohernece)*len(nDots))*n_reps
all_trials = [[0 for i in range(2)] for j in range(listLength)]
countInd = 0
for k in range(n_reps):
for DirOutsideInd in nAngle:
count = 0
for DirInsideInd in nAngle:
for CoherInd in ncohernece:
for NdotsInd in nDots:
new_column = [direction_vec[DirOutsideInd],direction_vec[DirInsideInd],coherence_level[CoherInd],n_dotsPerTrail[NdotsInd]]
all_trials[countInd] = new_column
count= count+1
countInd = countInd +1
random.shuffle(all_trials)
return(all_trials)
dirVec=[0, 45 ,90, 135, 180 ,225, 270 ,315]
num_reps = 10
coherence_vec = [1,0.5,0]
ndotsPerTrail = [1,2,3]
alltrials = set_trials_sqr(n_reps=num_reps, direction_vec = dirVec ,
coherence_level=coherence_vec,n_dotsPerTrail = ndotsPerTrail)
for dot_info in zip(alltrials):
trailInfo = dot_info[(0)]
coherencePerTrial = trailInfo[2]
n_dots = trailInfo[3]
dirSqr = trailInfo[0]
dirCirc = trailInfo[1]
nDotsPer1SqrArea = 200
fieldSizeCircle = 0.5
fieldSizeSquare = 2.1
areaCircle = (fieldSizeCircle/2)**2*np.pi
areaSquare = fieldSizeSquare**2
#nDotsCircle = round(areaCircle*nDotsPer1SqrArea)
#nDotsSquare = round(areaSquare*nDotsPer1SqrArea)
if n_dots == 1:
nDotsCircle = 1
nDotsSquare = round(areaSquare*nDotsPer1SqrArea)
elif n_dots == 2:
nDotsSquare = 1
nDotsCircle = round(areaCircle*nDotsPer1SqrArea)
elif n_dots == 3 :
nDotsCircle = round(areaCircle*nDotsPer1SqrArea)
nDotsSquare = round(areaSquare*nDotsPer1SqrArea)
r = 128
circle = visual.ShapeStim(
win, vertices="circle",
pos=(0.5, 0.5), size=(r*2, r*2), units="pix",
fillColor="black", opacity=1, interpolate=True,
autoDraw=False)
rdkCircle = visual.DotStim(win, nDots=nDotsCircle, coherence=coherencePerTrial,
fieldPos=(0,0),
fieldSize=(fieldSizeCircle,fieldSizeCircle),
fieldShape='circle', dotSize=15.0,
dotLife=-1, dir=dirCirc, speed=0.01,
rgb=None, color=(255,255,255),
colorSpace='rgb255', opacity=1,
contrast=1.0, depth=0, element=None,
signalDots='same',
noiseDots='direction', name='',
autoLog=True)
rdkSqr = visual.DotStim(win, nDots=nDotsSquare, coherence=coherencePerTrial,
fieldPos=(0,0),
fieldSize=(fieldSizeSquare,fieldSizeSquare),
fieldShape='sqr', dotSize=15.0,
dotLife=-1, dir=dirSqr, speed=0.01,
rgb=None, color=(255,255,255),
colorSpace='rgb255', opacity=1.0,
contrast=1.0, depth=0, element=None,
signalDots='same',
noiseDots='direction', name='',
autoLog=True)
stop = False
timer = core.Clock()
timer = core.CountdownTimer(3)
# while stop == False:
while timer.getTime() > 0:
if n_dots == 1:
rdkSqr.draw()
circle.draw()
win.flip()
elif n_dots == 2:
circle.draw()
rdkCircle.draw()
win.flip()
elif n_dots == 3 :
rdkSqr.draw()
circle.draw()
rdkCircle.draw()
win.flip()
if event.getKeys("a"):
win.close()
stop = True