Пример #1
0
 def writeInitCode(self, buff):
     kwargs = getInitVals(self.params) #replaces variable params with defaults
     kwargs['units'] = '\'\'' if self.params['units'].val == 'from exp settings' else self.params['units']
     kwargs.update(self.SHAPE_PARAMS[self.params['shape'].val])
     buff.writeIndented("%(name)s = visual.ShapeStim(win=win, name='%(name)s',units=%(units)s,\n" % kwargs)
     buff.writeIndented("    ori=%(ori)s, pos=%(pos)s, size=%(size)s, fillColor=%(color)s,\n" % kwargs)
     buff.writeIndented("    opacity=%(opacity)s, vertices=%(vertices)s, lineColor=None)\n" % kwargs)
Пример #2
0
 def _writeCreationCode(self,buff,useInits):
     #This will be called by either self.writeInitCode() or self.writeRoutineStartCode()
     #The reason for this is that moviestim is actually created fresh each time the
     #movie is loaded.
     #leave units blank if not needed
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     #If we're in writeInitCode then we need to convert params to initVals
     #because some (variable) params haven't been created yet.
     if useInits:
         params = components.getInitVals(self.params)
     else:
         params = self.params
     if self.params['backend'].val=='moviepy':
         buff.writeIndented("%s = visual.MovieStim3(win=win, name='%s',%s\n" %(params['name'],params['name'],unitsStr))
     elif self.params['backend'].val=='avbin':
         buff.writeIndented("%s = visual.MovieStim(win=win, name='%s',%s\n" %(params['name'],params['name'],unitsStr))
     else:
         buff.writeIndented("%s = visual.MovieStim2(win=win, name='%s',%s\n" %(params['name'],params['name'],unitsStr))
     buff.writeIndented("    filename=%(movie)s,\n" %(params))
     buff.writeIndented("    ori=%(ori)s, pos=%(pos)s, opacity=%(opacity)s,\n" %(params))
     if self.params['size'].val != '':
         buff.writeIndented("    size=%(size)s,\n"%(params))
     depth = -self.getPosInRoutine()
     buff.writeIndented("    depth=%.1f,\n" %depth)
     buff.writeIndented("    )\n")
Пример #3
0
 def writeInitCode(self, buff):
     # do we need units code?
     if self.params["units"].val == "from exp settings":
         unitsStr = ""
     else:
         unitsStr = "units=%(units)s, " % self.params
     # do writing of init
     inits = components.getInitVals(self.params)  # replaces variable params with sensible defaults
     if self.params["wrapWidth"].val in ["", "None", "none"]:
         inits["wrapWidth"] = "None"
     buff.writeIndented("%(name)s = visual.TextStim(win=win, ori=%(ori)s, name='%(name)s',\n" % (inits))
     buff.writeIndented("    text=%(text)s," % inits)
     buff.writeIndented("    font=%(font)s,\n" % inits)
     buff.writeIndented(
         "    " + unitsStr + "pos=%(pos)s, height=%(letterHeight)s, wrapWidth=%(wrapWidth)s,\n" % (inits)
     )
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s,\n" % (inits))
     flip = self.params["flip"].val.strip()
     if flip == "horiz":
         buff.writeIndented("    flipHoriz=%s," % bool(flip == "horiz"))
     elif flip == "vert":
         buff.writeIndented("    flipVert=%s," % bool(flip == "vert"))
     elif flip:
         raise ValueError(
             "flip value should be 'horiz' or 'vert' (no quotes) in component '%s'" % self.params["name"].val
         )
     depth = -self.getPosInRoutine()
     buff.writeIndented("    depth=%.1f)\n" % (depth))
Пример #4
0
 def writeInitCode(self,buff):
     #do we need units code?
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     inits = getInitVals(self.params)#replaces variable params with defaults
     if inits['size'].val=='1.0':
         inits['size'].val = '[1.0, 1.0]'
     if self.params['nVertices'].val == '2':
         buff.writeIndented("%s = visual.Line(win=win, name='%s',%s\n" %(inits['name'],inits['name'],unitsStr))
         buff.writeIndented("    start=(-%(size)s[0]/2.0, 0), end=(+%(size)s[0]/2.0, 0),\n" %(inits) )
     elif self.params['nVertices'].val == '3':
         buff.writeIndented("%s = visual.ShapeStim(win=win, name='%s',%s\n" %(inits['name'],inits['name'],unitsStr))
         buff.writeIndented("    vertices = [[-%(size)s[0]/2.0,-%(size)s[1]/2.0], [+%(size)s[0]/2.0,-%(size)s[1]/2.0], [0,%(size)s[1]/2.0]],\n" %(inits) )
     elif self.params['nVertices'].val == '4':
         buff.writeIndented("%s = visual.Rect(win=win, name='%s',%s\n" %(inits['name'],inits['name'],unitsStr))
         buff.writeIndented("    width=%(size)s[0], height=%(size)s[1],\n" %(inits) )
     else:
         buff.writeIndented("%s = visual.Polygon(win=win, name='%s',%s\n" %(inits['name'],inits['name'],unitsStr))
         buff.writeIndented("    edges = %s," % str(inits['nVertices'].val))
         buff.writeIndented(" size=%(size)s,\n" %(inits) )
     buff.writeIndented("    ori=%(ori)s, pos=%(pos)s,\n" %(inits) )
     buff.writeIndented("    lineWidth=%(lineWidth)s, lineColor=%(lineColor)s, lineColorSpace=%(lineColorSpace)s,\n" %(inits) )
     buff.writeIndented("    fillColor=%(fillColor)s, fillColorSpace=%(fillColorSpace)s,\n" %(inits) )
     buff.writeIndented("    opacity=%(opacity)s," %(inits) )
     depth = -self.getPosInRoutine()
     buff.write("depth=%.1f, \n" %depth)#finish with newline
     if self.params['interpolate'].val=='linear':
         buff.write("interpolate=True)\n")
     else: buff.write("interpolate=False)\n")
Пример #5
0
 def writeInitCode(self,buff):
     inits = components.getInitVals(self.params)#replaces variable params with sensible defaults
     if self.params['stopType'].val=='duration (s)' and len(self.params['stopVal'].val)>0:
         durationSetting=", secs=%(stopVal)s" %self.params
     else:
         durationSetting=""
     buff.writeIndented("%s = sound.Sound(%s%s)\n" %(inits['name'], inits['sound'], durationSetting))
     buff.writeIndented("%(name)s.setVolume(%(volume)s)\n" %(inits))
Пример #6
0
 def writeInitCode(self, buff):
     inits = components.getInitVals(self.params)  # replaces variable params with sensible defaults
     if self.params["stopType"] == "duration (s)":
         durationSetting = "secs=%(stopVal)s" % self.params
     else:
         durationSetting = ""
     buff.writeIndented("%s=sound.Sound(%s,%s)\n" % (inits["name"], inits["sound"], durationSetting))
     buff.writeIndented("%(name)s.setVolume(%(volume)s)\n" % (inits))
Пример #7
0
 def writeInitCode(self, buff):
     #do we need units code?
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     #do writing of init
     inits = components.getInitVals(self.params)
     buff.writeIndented("%(name)s = visual.Aperture(win=win, name='%(name)s',\n" % (inits))
     buff.writeIndented("    "+unitsStr+"size=%(size)s, pos=%(pos)s)\n" % (inits))
     buff.writeIndented("%(name)s.disable()  # disable until its actually used\n" %(inits))
Пример #8
0
 def writeInitCode(self,buff):
     #if the movie is constant then load it once at beginning of script.
     #if it changes each repeat then we should wait and creat the entire object at
     #Routine start
     if self.params['movie'].updates=='constant':
         initVals = getInitVals(self.params)
         buff.writeIndented("%(name)s=visual.MovieStim(win=win, filename=%(movie)s, name='%(name)s',\n" %(self.params))
         buff.writeIndented("    ori=%(ori)s, pos=%(pos)s" %(self.params))
         if self.params['size'].val != '': buff.writeIndented(", size=%(size)s"%(self.params))
         buff.writeIndented(")\n")
Пример #9
0
 def writeInitCode(self,buff):
     #do we need units code?
     if self.params['units'].val=='window units': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     #do writing of init
     inits = getInitVals(self.params)#replaces variable params with sensible defaults
     buff.writeIndented("%(name)s=visual.TextStim(win=win, ori=%(ori)s, name='%(name)s',\n" %(inits))
     buff.writeIndented("    text=%(text)s,\n" %inits)
     buff.writeIndented("    font=%(font)s,\n" %inits)
     buff.writeIndented("    "+unitsStr+"pos=%(pos)s, height=%(letterHeight)s,\n" %(inits))
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s)\n" %(inits))
Пример #10
0
 def writeInitCode(self,buff):
     inits = getInitVals(self.params)#replaces variable params with defaults
     buff.writeIndented("%(name)s=visual.PatchStim(win=win, name='%(name)s',\n" %(inits))
     buff.writeIndented("    tex=%(image)s, mask=%(mask)s,\n" %(inits))
     buff.writeIndented("    ori=%(ori)s, pos=%(pos)s, size=%(size)s, sf=%(sf)s, phase=%(phase)s,\n" %(inits) )
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s,\n" %(inits) )
     buff.writeIndented("    texRes=%(texture resolution)s" %(inits))# no newline - start optional parameters
     if self.params['units'].val!='window units': buff.write(", units=%(units)s" %(inits) )
     if self.params['interpolate']=='linear':
         buff.write(", interpolate=True")
     else: buff.write(", interpolate=False")
     buff.write(")\n")#finish with newline
Пример #11
0
 def writeInitCode(self,buff):
     #do we need units code?
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     #do writing of init
     inits = components.getInitVals(self.params)#replaces variable params with sensible defaults
     buff.writeIndented("%s=visual.DotStim(win=win, name='%s',%s\n" %(inits['name'], inits['name'],unitsStr))
     buff.writeIndented("    nDots=%(nDots)s, dotSize=%(dotSize)s,\n" %(inits))
     buff.writeIndented("    speed=%(speed)s, dir=%(dir)s, coherence=%(coherence)s,\n" %(inits))
     buff.writeIndented("    fieldPos=%(fieldPos)s, fieldSize=%(fieldSize)s,fieldShape=%(fieldShape)s,\n" %(inits))
     buff.writeIndented("    signalDots=%(signalDots)s, noiseDots=%(noiseDots)s,dotLife=%(dotLife)s,\n" %(inits))
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s)\n" %(inits))
Пример #12
0
 def writeInitCode(self,buff):
     #do we need units code?
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     inits = getInitVals(self.params)#replaces variable params with defaults
     buff.writeIndented("%s = visual.GratingStim(win=win, name='%s',%s\n" %(inits['name'],inits['name'],unitsStr))
     buff.writeIndented("    tex=%(tex)s, mask=%(mask)s,\n" %(inits))
     buff.writeIndented("    ori=%(ori)s, pos=%(pos)s, size=%(size)s, sf=%(sf)s, phase=%(phase)s,\n" %(inits) )
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s,\n" %(inits) )
     buff.writeIndented("    texRes=%(texture resolution)s" %(inits))# no newline - start optional parameters
     if self.params['interpolate'].val=='linear':
         buff.write(", interpolate=True")
     else: buff.write(", interpolate=False")
     depth = -self.getPosInRoutine()
     buff.write(", depth=%.1f)\n" %depth)#finish with newline
Пример #13
0
 def writeInitCode(self,buff):
     #do we need units code?
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     #do writing of init
     inits = components.getInitVals(self.params)#replaces variable params with sensible defaults
     if self.params['wrapWidth'].val in ['','None','none']:
         inits['wrapWidth']='None'
     buff.writeIndented("%(name)s=visual.TextStim(win=win, ori=%(ori)s, name='%(name)s',\n" %(inits))
     buff.writeIndented("    text=%(text)s,\n" %inits)
     buff.writeIndented("    font=%(font)s,\n" %inits)
     buff.writeIndented("    "+unitsStr+"pos=%(pos)s, height=%(letterHeight)s,wrapWidth=%(wrapWidth)s,\n" %(inits))
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s,\n" %(inits))
     depth=-self.getPosInRoutine()
     buff.writeIndented("    depth=%.1f)\n" %(depth))
Пример #14
0
 def writeInitCode(self, buff):
     # do we need units code?
     if self.params["units"].val == "from exp settings":
         unitsStr = ""
     else:
         unitsStr = "units=%(units)s, " % self.params
     # do writing of init
     inits = components.getInitVals(self.params)  # replaces variable params with sensible defaults
     if self.params["wrapWidth"].val in ["", "None", "none"]:
         inits["wrapWidth"] = "None"
     buff.writeIndented("%(name)s=visual.TextStim(win=win, ori=%(ori)s, name='%(name)s',\n" % (inits))
     buff.writeIndented("    text=%(text)s,\n" % inits)
     buff.writeIndented("    font=%(font)s,\n" % inits)
     buff.writeIndented(
         "    " + unitsStr + "pos=%(pos)s, height=%(letterHeight)s,wrapWidth=%(wrapWidth)s,\n" % (inits)
     )
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s)\n" % (inits))
Пример #15
0
 def writeInitCode(self,buff):
     #do we need units code?
     if self.params['units'].val=='from exp settings': unitsStr=""
     else: unitsStr="units=%(units)s, " %self.params
     #do writing of init
     inits = components.getInitVals(self.params)#replaces variable params with sensible defaults
     if self.params['wrapWidth'].val in ['','None','none']:
         inits['wrapWidth']='None'
     buff.writeIndented("%(name)s = visual.TextStim(win=win, ori=%(ori)s, name='%(name)s',\n" %(inits))
     buff.writeIndented("    text=%(text)s," %inits)
     buff.writeIndented("    font=%(font)s,\n" %inits)
     buff.writeIndented("    "+unitsStr+"pos=%(pos)s, height=%(letterHeight)s, wrapWidth=%(wrapWidth)s,\n" %(inits))
     buff.writeIndented("    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s,\n" %(inits))
     flip = self.params['flip'].val
     if flip == 'horiz':
         buff.writeIndented("    flipHoriz=%s," % bool(flip == 'horiz') )
     elif flip == 'vert':
         buff.writeIndented("    flipVert=%s," % bool(flip == 'vert') )
     elif '$' in flip and self.params['flip'].updates == 'constant':
         print 'Warning: %s Flip appears to be variable, but updates are constant' % self.params['name']
     depth=-self.getPosInRoutine()
     buff.writeIndented("    depth=%.1f)\n" %(depth))
Пример #16
0
 def writeInitCode(self, buff):
     #do we need units code?
     if self.params['units'].val == 'from exp settings': unitsStr = ""
     else: unitsStr = "units=%(units)s, " % self.params
     inits = getInitVals(
         self.params)  #replaces variable params with defaults
     buff.writeIndented("%s = visual.GratingStim(win=win, name='%s',%s\n" %
                        (inits['name'], inits['name'], unitsStr))
     buff.writeIndented("    tex=%(tex)s, mask=%(mask)s,\n" % (inits))
     buff.writeIndented(
         "    ori=%(ori)s, pos=%(pos)s, size=%(size)s, sf=%(sf)s, phase=%(phase)s,\n"
         % (inits))
     buff.writeIndented(
         "    color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s,\n"
         % (inits))
     buff.writeIndented("    texRes=%(texture resolution)s" %
                        (inits))  # no newline - start optional parameters
     if self.params['interpolate'].val == 'linear':
         buff.write(", interpolate=True")
     else:
         buff.write(", interpolate=False")
     depth = -self.getPosInRoutine()
     buff.write(", depth=%.1f)\n" % depth)  #finish with newline
Пример #17
0
 def _writeCreationCode(self, buff, useInits):
     #This will be called by either self.writeInitCode() or self.writeRoutineStartCode()
     #The reason for this is that moviestim is actually created fresh each time the
     #movie is loaded.
     #leave units blank if not needed
     if self.params['units'].val == 'from exp settings': unitsStr = ""
     else: unitsStr = "units=%(units)s, " % self.params
     #If we're in writeInitCode then we need to convert params to initVals
     #because some (variable) params haven't been created yet.
     if useInits:
         params = components.getInitVals(self.params)
     else:
         params = self.params
     buff.writeIndented("%s = visual.MovieStim(win=win, name='%s',%s\n" %
                        (params['name'], params['name'], unitsStr))
     buff.writeIndented("    filename=%(movie)s,\n" % (params))
     buff.writeIndented(
         "    ori=%(ori)s, pos=%(pos)s, opacity=%(opacity)s,\n" % (params))
     if self.params['size'].val != '':
         buff.writeIndented("    size=%(size)s,\n" % (params))
     depth = -self.getPosInRoutine()
     buff.writeIndented("    depth=%.1f,\n" % depth)
     buff.writeIndented("    )\n")
Пример #18
0
 def writeInitCode(self,buff):
     inits = components.getInitVals(self.params)#replaces variable params with sensible defaults
     buff.writeIndented("%s = sound.Sound(%s, secs=-1)\n" %(inits['name'], inits['sound']))
     buff.writeIndented("%(name)s.setVolume(%(volume)s)\n" %(inits))
Пример #19
0
 def writeRoutineStartCode(self, buff):
     inits = components.getInitVals(self.params)
     buff.writeIndented(
         "%s = microphone.AdvAudioCapture(name='%s', saveDir=wavDirName, stereo=%s)\n"
         % (inits['name'], inits['name'], inits['stereo']))
Пример #20
0
 def writeInitCode(self, buff):
     inits = components.getInitVals(self.params)
     #do writing of init
     buff.writeIndented("%(name)s=visual.Aperture(win=win, name='%(name)s',\n" % (inits))
     buff.writeIndented("    size=%(size)s, pos=%(pos)s, units='pix')\n" % (inits))
     buff.writeIndented("%(name)s.disable() # is enabled by default\n" %(inits))
 def writeRoutineStartCode(self,buff):
     inits = components.getInitVals(self.params) #replaces variable params with sensible defaults
     buff.writeIndented("%s = microphone.AudioCapture(name='%s', saveDir=wavDirName)\n" %(
         inits['name'], inits['name']))
Пример #22
0
 def writeInitCode(self, buff):
     inits = components.getInitVals(
         self.params)  #replaces variable params with sensible defaults
     buff.writeIndented("%s = sound.Sound(%s, secs=-1)\n" %
                        (inits['name'], inits['sound']))
     buff.writeIndented("%(name)s.setVolume(%(volume)s)\n" % (inits))
Пример #23
0
 def writeRoutineStartCode(self,buff):
     inits = components.getInitVals(self.params)
     buff.writeIndented("%s = microphone.AdvAudioCapture(name='%s', saveDir=wavDirName, stereo=%s)\n" %(
         inits['name'], inits['name'], inits['stereo']))
Пример #24
0
 def writeRoutineStartCode(self,buff):
     inits = components.getInitVals(self.params) #replaces variable params with sensible defaults
     buff.writeIndented("%s = microphone.SimpleAudioCapture(name='%s', saveDir=wavDirName)\n" %(
         inits['name'], inits['name']))