Esempio n. 1
0
 def __init__(self, win, color, shape):
     self.win = win
     if shape == 'circle':
         self.stim = circle.Circle(win=win,
                                   fillColor=color,
                                   fillColorSpace='rgb255',
                                   lineColor=color,
                                   lineColorSpace='rgb255',
                                   radius=0.1)
     elif shape == 'triangle':
         self.stim = polygon.Polygon(win=win,
                                     edges=3,
                                     fillColor=color,
                                     fillColorSpace='rgb255',
                                     lineColor=color,
                                     lineColorSpace='rgb255',
                                     radius=0.1)
     elif shape == 'square':
         self.stim = polygon.Polygon(win=win,
                                     edges=4,
                                     fillColor=color,
                                     fillColorSpace='rgb255',
                                     lineColor=color,
                                     lineColorSpace='rgb255',
                                     radius=0.1)
     elif shape == 'pentagon':
         self.stim = polygon.Polygon(win=win,
                                     edges=5,
                                     fillColor=color,
                                     fillColorSpace='rgb255',
                                     lineColor=color,
                                     lineColorSpace='rgb255',
                                     radius=0.1)
     else:
         raise ValueError('Invalid Cue Type')
Esempio n. 2
0
 def drawNewFeature(self, feature):
     dot = circle.Circle(
         self.win,
         radius=self.dotRaduis,
         pos=(feature[0] * self.winScale, feature[1] * self.winScale),
         lineColor=self.colorDict[feature[-1]],
         fillColor=self.colorDict[feature[-1]],
         units='pix',
     )
     self._highlightDot(dot)
     self.featureDots.append(dot)
Esempio n. 3
0
 def startDrawAllFeatures(self, highlightLast=True):
     for p in self.featureDots:
         p.autoDraw = True
         # p.draw()
     if highlightLast:
         highlightCircle = circle.Circle(self.win,
                                         radius=self.dotRaduis + 1,
                                         pos=self.featureDots[-1].pos,
                                         units='pix',
                                         lineWidth=2)
         highlightCircle.draw()
     self.win.flip()
Esempio n. 4
0
def highlightPoint(p, repeatTimes=2, intervalTime=0.1):
    radius = p.radius.copy()
    #print('radius', radius)
    p.draw()
    win.flip()
    core.wait(intervalTime)

    for times in range(repeatTimes):
        for _ in range(5):
            _scalePoint(p, 0.006, intervalTime)
        for _ in range(5):
            _scalePoint(p, -0.006, intervalTime)
        # for scale in [0.01,0.012,0.014,0.016,0.018]:
        #     _scalePoint(p,scale,intervalTime)
        #p.radius = radius
        #print('inhighlight', p.radius)
    #p.radius += 0.005
    whiteCircle = circle.Circle(win, radius=0.014, pos=p.pos, units='norm')
    whiteCircle.draw()
Esempio n. 5
0
def drawNewPoint(newDot):
    global allPoint
    if newDot.label == 1:
        color = 'red'
    else:
        color = 'blue'
    newCircle = circle.Circle(win,
                              radius=0.01,
                              pos=newDot.pos,
                              lineColor=color,
                              fillColor=color,
                              units='norm')
    allPoint.append(newCircle)
    #print('inDraw', allPoint[-1].radius)
    # printAllPoint(allPoint)
    drawAllPoint(allPoint, autoDraw=True)

    highlightPoint(newCircle)
    #print('afterDraw', allPoint[-1].radius)
    drawAllPoint(allPoint, autoDraw=False)
Esempio n. 6
0
 def __init__(self, win, features=None, dotRaduis=5):
     self.win = win
     self.features = features
     self.dotRaduis = dotRaduis
     self.featureDots = []
     self.positiveColor = 'red'
     self.negativeColor = 'blue'
     self.colorDict = {1: self.positiveColor, -1: self.negativeColor}
     self.winScale = win.size.min() / 2.0
     if self.features:
         for (x, y, label) in features:
             dot = circle.Circle(
                 win,
                 radius=dotRaduis,
                 pos=(x * self.winScale, y * self.winScale),
                 lineColor=self.colorDict[label],
                 fillColor=self.colorDict[label],
                 units='pix',
             )
             self.featureDots.append(dot)
Esempio n. 7
0
 def _add_new_bullet(self, x, y, label):  # destination = (x,y)
     bullet = circle.Circle(
         self.win,
         radius=self.dotRaduis,
         pos=self.startPoint,
         lineWidth=0,
         fillColor=self.colorDict[label],
         units='norm',
     )
     # v_x = (x - self.startPoint[0])/self.duration #duration为小数的时候会严重影响计算落点的准确性!
     # v_y = abs(y - self.startPoint[1])/self.duration
     self.bulletList.append({
         'bullet': bullet,
         'target_x': x,
         'target_y': y,
         'tan': x / (y + 1),
         'arrived': False
     })
     # self.featureDots.append(bullet)
     # return bullet
     self.featureDots.append(bullet)  # 父类画全部点的时候会用到
Esempio n. 8
0
 def __init__(self, win, features=None, dotRaduis=5):
     self.win = win
     self.features = features
     self.dotRaduis = dotRaduis
     self.featureDots = []
     # self.positiveColor = 'red'
     # self.negativeColor = 'blue'
     self.colorDict = {-1: 'blue', 1: 'red', 2: 'green', 3: 'yellow'}
     # self.winScale =1 #win.size.min() / 2.0
     if self.features:
         for (x, y, label) in features:
             dot = circle.Circle(
                 win,
                 radius=dotRaduis,
                 pos=(x, y),
                 lineWidth=0,
                 fillColor=self.colorDict[label],
                 opacity=0.1,
                 units='norm',
             )
             self.featureDots.append(dot)
Esempio n. 9
0
                           lineColor='white',
                           autoDraw=False)
verLine = line.Line(win, (0, 0.8), (0, -0.8),
                    units='norm',
                    lineColor='white',
                    lineWidth=0.002,
                    autoDraw=False)
horiLine = line.Line(win, (-0.8, 0), (0.8, 0),
                     units='norm',
                     lineColor='white',
                     lineWidth=0.002,
                     autoDraw=False)

circle1 = circle.Circle(win,
                        radius=0.01,
                        pos=(0.5, 0.3),
                        lineColor='red',
                        fillColor='red',
                        units='norm')

circle2 = circle.Circle(win,
                        radius=0.01,
                        pos=(-0.6, -0.4),
                        lineColor='blue',
                        fillColor='blue',
                        units='norm')

event.globalKeys.add(key='q',
                     modifiers=['ctrl'],
                     func=core.quit,
                     name='shutdown')
event.globalKeys.add(key='escape', func=core.quit, name='esc')
Esempio n. 10
0
    dotSize, mon)  # calculate dotSizePix for DotStim object
nDots = round(np.pi * fieldRadius**2 * dotDensity)  # calcuate nDots
maxFrames = int(round(maxDur / myWin.monitorFramePeriod))

# define trial handler
stimList = []
for t in dirRange:
    for d in stimDir:
        stimList.append({'dirRange': t, 'direction': d})
trials = data.TrialHandler(trialList=stimList, nReps=nTrialsPerCond)

#  ====== define stimulus components =======
# define fixation
fixation = circle.Circle(win=myWin,
                         units='deg',
                         radius=0.25,
                         lineColor=0,
                         fillColor=0)
# define coherent dots
cohDots = visual.DotStim(win=myWin,
                         nDots=nDots,
                         units='deg',
                         fieldSize=[fieldRadius * 2, fieldRadius * 2],
                         fieldShape='circle',
                         coherence=1,
                         dotSize=dotSizePix,
                         dotLife=-1)  # note here dotSize is in pixels
# Create stimulus array
chaosDots = visual.ElementArrayStim(myWin, elementTex=None, fieldShape='circle', \
                                    elementMask='circle', nElements=nDots, sizes=dotSize, units='deg', \
                                    fieldSize=[fieldRadius * 2, fieldRadius * 2])  # note here dotSize is in deg