本文整理汇总了Python中psychopy.experiment.components.getInitVals函数的典型用法代码示例。如果您正苦于以下问题:Python getInitVals函数的具体用法?Python getInitVals怎么用?Python getInitVals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getInitVals函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: writeInitCode
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
# replace variable params with defaults
inits = getInitVals(self.params, 'PsychoPy')
code = ("{inits[name]} = visual.ImageStim(\n"
" win=win,\n"
" name='{inits[name]}', {units}\n"
" image={inits[image]}, mask={inits[mask]},\n"
" ori={inits[ori]}, pos={inits[pos]}, size={inits[size]},\n"
" color={inits[color]}, colorSpace={inits[colorSpace]}, opacity={inits[opacity]},\n"
" flipHoriz={inits[flipHoriz]}, flipVert={inits[flipVert]},\n"
# no newline - start optional parameters
" texRes={inits[texture resolution]}"
.format(inits=inits,
units=unitsStr))
if self.params['interpolate'].val == 'linear':
code += ", interpolate=True"
else:
code += ", interpolate=False"
depth = -self.getPosInRoutine()
code += ", depth=%.1f)\n" % depth
buff.writeIndentedLines(code)
开发者ID:dgfitch,项目名称:psychopy,代码行数:28,代码来源:__init__.py
示例2: writeInitCode
def writeInitCode(self, buff):
self._noiseNewSample=""
# do we need units code?
if self.params['units'].val == 'from exp settings':
unitsStr = ""
else:
unitsStr = "units=%(units)s, " % self.params
#buff.writeIndented("from psychopy.visual.noise import NoiseStim\n")
# replaces variable params with defaults and sets sample updateing flag
inits = getInitVals(self.params)
#for myparam in inits:
# if ('noise' in myparam):
# if (inits[myparam].updates in ['set every frame']):
# self._forceRebuild=True
#if not (inits[myparam].updates in ['constant', None, 'None']):
# inits[myparam]='1'
#if not (self.params['A_noiseType'].updates in ['constant', None, 'None']):
# inits['A_noiseType']='Binary'
#if ('rebuild_frame' in self._noiseNewSample):
# print 'Warning: Rebuilding the noise sample every frame may be slow and could corrupt frame timing'
# noise sample updating set to every repeat or frame will override result of parameter settings
self._forceUpdateRepeat = False
self._forceUpdateFrames = False
self._forceUpdateSeconds = False
if inits['noiseNewSample'].val in ['Repeat']:
self._forceUpdateRepeat = True
elif inits['noiseNewSample'].val in ['N-frames']:
self._forceUpdateFrames = True
elif inits['noiseNewSample'].val in ['Seconds']:
self._forceUpdateSeconds = True
#self._when=float(inits['Z_when'].val)
#print self._when
#else whenIsVariale=false
#if (inits['carrier'].val in ['noise','Noise']):
# inits['carrier']="%(name)s.noiseTex" %inits
code = ("%s = visual.NoiseStim(\n" % inits['name'] +
" win=win, name='%s',%s\n" % (inits['name'], unitsStr) +
" noiseImage=%(noiseImage)s, mask=%(mask)s,\n" % inits +
" ori=%(ori)s, pos=%(pos)s, size=%(size)s, " % inits +
"sf=%(sf)s, phase=%(phase)s,\n" % inits +
" color=%(color)s, colorSpace=%(colorSpace)s, " % inits +
"opacity=%(opacity)s, blendmode=%(blendmode)s, contrast=%(contrast)s,\n" % inits +
# no newline - start optional parameters
" texRes=%(texture resolution)s,\n" % inits +
" noiseType=%(noiseType)s, noiseElementSize=%(noiseElementSize)s, noiseBaseSf=%(noiseBaseSf)s,\n" %inits+
" noiseBW=%(noiseBW)s, noiseBWO=%(noiseBWO)s, noiseFractalPower=%(noiseFractalPower)s,noiseFilterLower=%(noiseFilterLower)s, noiseFilterUpper=%(noiseFilterUpper)s, noiseFilterOrder=%(noiseFilterOrder)s, noiseClip=%(noiseClip)s" %inits)
if self.params['interpolate'].val == 'linear':
code += ", interpolate=True"
else:
code += ", interpolate=False"
depth = -self.getPosInRoutine()
code += ", depth=%.1f)\n" % depth
buff.writeIndentedLines(code)
if not(self.params['noiseType'] in ['none', 'None']):
buff.writeIndented("%(name)s.buildNoise()\n" %self.params)
开发者ID:flipphillips,项目名称:psychopy,代码行数:60,代码来源:__init__.py
示例3: writeInitCodeJS
def writeInitCodeJS(self, buff):
inits = getInitVals(self.params)
noAudio = '{}'.format(inits['No audio'].val).lower()
for param in inits:
if inits[param] in ['', None, 'None', 'none']:
inits[param] = 'undefined'
code = "{name}Clock = new util.Clock();\n".format(**inits)
buff.writeIndented(code)
code = ("{name} = new visual.MovieStim({{\n"
" win: psychoJS.window,\n"
" name: '{name}',\n"
" movie: {movie},\n"
" units: {units},\n"
" pos: {pos},\n"
" size: {size},\n"
" ori: {ori},\n"
" opacity: {opacity},\n"
" loop: false,\n"
" noAudio: {noAudio},\n"
" }});\n").format(name = inits['name'],
movie = inits['movie'],
units = inits['units'],
pos = inits['pos'],
size = inits['size'],
ori = inits['ori'],
opacity = inits['opacity'],
noAudio=noAudio)
buff.writeIndentedLines(code)
开发者ID:hoechenberger,项目名称:psychopy,代码行数:30,代码来源:__init__.py
示例4: writeRoutineStartCode
def writeRoutineStartCode(self, buff):
inits = getInitVals(self.params)
if inits['stopVal'] in [None, 'None', '']:
buff.writeIndented("%s.setSound(%s)\n" %
(inits['name'], inits['sound']))
else:
buff.writeIndented("%s.setSound(%s, secs=%s)\n" %
(inits['name'], inits['sound'],
inits['stopVal']))
开发者ID:shigeakinishina,项目名称:psychopy,代码行数:9,代码来源:__init__.py
示例5: writeInitCode
def writeInitCode(self, buff):
self._noiseNewSample=""
# do we need units code?
if self.params['units'].val == 'from exp settings':
unitsStr = ""
else:
unitsStr = "units=%(units)s, " % self.params
#buff.writeIndented("from psychopy.visual.noise import NoiseStim\n")
# replaces variable params with defaults and sets sample updating flag
inits = getInitVals(self.params)
self._forceUpdateRepeat = False
self._forceUpdateFrames = False
self._forceUpdateSeconds = False
if inits['noiseNewSample'].val in ['Repeat']:
self._forceUpdateRepeat = True
elif inits['noiseNewSample'].val in ['N-frames']:
self._forceUpdateFrames = True
elif inits['noiseNewSample'].val in ['Seconds']:
self._forceUpdateSeconds = True
code = ("%s = visual.NoiseStim(\n" % inits['name'] +
" win=win, name='%s',%s\n" % (inits['name'], unitsStr) +
" noiseImage=%(noiseImage)s, mask=%(mask)s,\n" % inits +
" ori=%(ori)s, pos=%(pos)s, size=%(size)s, sf=%(sf)s,\n" % inits +
" phase=%(phase)s,\n" % inits +
" color=%(color)s, colorSpace=%(colorSpace)s, " % inits +
" opacity=%(opacity)s, blendmode=%(blendmode)s, contrast=%(contrast)s,\n" % inits +
# no newline - start optional parameters
" texRes=%(texture resolution)s, filter=%(filter)s,\n" % inits +
" noiseType=%(noiseType)s, noiseElementSize=%(noiseElementSize)s, \n" %inits +
" noiseBaseSf=%(noiseBaseSf)s, noiseBW=%(noiseBW)s,\n" %inits +
" noiseBWO=%(noiseBWO)s, noiseOri=%(noiseOri)s,\n" %inits +
" noiseFractalPower=%(noiseFractalPower)s,noiseFilterLower=%(noiseFilterLower)s,\n" %inits +
" noiseFilterUpper=%(noiseFilterUpper)s, noiseFilterOrder=%(noiseFilterOrder)s,\n" %inits +
" noiseClip=%(noiseClip)s, imageComponent=%(imageComponent)s" %inits)
#if self.params['filter'].val == 'True':
# code += ", filter=True"
#else:
# code += ", filter=False"
if self.params['interpolate'].val == 'linear':
code += ", interpolate=True"
else:
code += ", interpolate=False"
depth = -self.getPosInRoutine()
code += ", depth=%.1f)\n" % depth
buff.writeIndentedLines(code)
if not(self.params['noiseType'] in ['none', 'None']):
buff.writeIndented("%(name)s.buildNoise()\n" %self.params)
开发者ID:schofiaj,项目名称:psychopy,代码行数:53,代码来源:__init__.py
示例6: writeInitCode
def writeInitCode(self, buff):
inits = getInitVals(self.params)
# build up an initialization string for Slider():
initStr = ("{name} = visual.Slider(win=win, name='{name}',\n"
" size={size}, pos={pos},\n"
" labels={labels}, ticks={ticks},\n"
" granularity={granularity}, style={styles},\n"
" color={color}, font={font},\n"
" flip={flip})\n"
.format(**inits))
buff.writeIndented(initStr)
开发者ID:mmagnuski,项目名称:psychopy,代码行数:12,代码来源:__init__.py
示例7: _writeCreationCodeJS
def _writeCreationCodeJS(self, buff, useInits):
# If we're in writeInitCode then we need to convert params to initVals
# because some (variable) params haven't been created yet.
if useInits:
inits = getInitVals(self.params)
else:
inits = self.params
if self.params['units'].val == 'from exp settings':
unitsStr = "'height'"
logging.warning("{units} not a valid screen unit for online studies. Switching {name} units to 'height'."
.format(units=self.params['units'],
name=self.params['name']))
else:
unitsStr = "%(units)s" % self.params
noAudio = '{}'.format(inits['No audio'].val).lower()
loop = '{}'.format(inits['loop'].val).lower()
if useInits:
for param in inits:
if inits[param] in ['', None, 'None', 'none']:
inits[param] = 'undefined'
code = "{name}Clock = new util.Clock();\n".format(**inits)
buff.writeIndented(code)
code = ("{name} = new visual.MovieStim({{\n"
" win: psychoJS.window,\n"
" name: '{name}',\n"
" movie: {movie},\n"
" units: {units},\n"
" pos: {pos},\n"
" size: {size},\n"
" ori: {ori},\n"
" opacity: {opacity},\n"
" loop: {loop},\n"
" noAudio: {noAudio},\n"
" }});\n").format(name=inits['name'],
movie=inits['movie'],
units=unitsStr,
pos=inits['pos'],
size=inits['size'],
ori=inits['ori'],
loop=loop,
opacity=inits['opacity'],
noAudio=noAudio)
buff.writeIndentedLines(code)
开发者ID:isolver,项目名称:psychopy,代码行数:50,代码来源:__init__.py
示例8: writeInitCodeJS
def writeInitCodeJS(self, buff):
# replaces variable params with sensible defaults
inits = getInitVals(self.params)
if '$' in inits['stopVal'].val:
inits['stopVal'].val = -1
elif inits['stopVal'].val in ['', None, 'None']:
inits['stopVal'].val = -1
elif float(inits['stopVal'].val) > 2:
inits['stopVal'].val = -1
buff.writeIndented("%s = new Sound({\n"
" win: psychoJS.window,\n"
" value: %s,\n"
" secs: %s,\n"
" });\n" % (inits['name'], inits['sound'], inits['stopVal']))
buff.writeIndented("%(name)s.setVolume(%(volume)s);\n" % (inits))
开发者ID:mmagnuski,项目名称:psychopy,代码行数:15,代码来源:__init__.py
示例9: _writeCreationCode
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 = getInitVals(self.params)
else:
params = self.params
if self.params['backend'].val == 'moviepy':
code = ("%s = visual.MovieStim3(\n" % params['name'] +
" win=win, name='%s',%s\n" % (params['name'], unitsStr) +
" noAudio = %(No audio)s,\n" % params)
elif self.params['backend'].val == 'avbin':
code = ("%s = visual.MovieStim(\n" % params['name'] +
" win=win, name='%s',%s\n" % (params['name'], unitsStr))
else:
code = ("%s = visual.MovieStim2(\n" % params['name'] +
" win=win, name='%s',%s\n" % (params['name'], unitsStr) +
" noAudio = %(No audio)s,\n" % params)
code += (" filename=%(movie)s,\n"
" ori=%(ori)s, pos=%(pos)s, opacity=%(opacity)s,\n"
" loop=%(loop)s,\n"
% params)
buff.writeIndentedLines(code)
if self.params['size'].val != '':
buff.writeIndented(" size=%(size)s,\n" % params)
depth = -self.getPosInRoutine()
code = (" depth=%.1f,\n"
" )\n")
buff.writeIndentedLines(code % depth)
开发者ID:isolver,项目名称:psychopy,代码行数:46,代码来源:__init__.py
示例10: writeInitCodeJS
def writeInitCodeJS(self, buff):
# do we need units code?
if self.params['units'].val == 'from exp settings':
unitsStr = " units : undefined, \n"
else:
unitsStr = " units : %(units)s, \n" % self.params
# do writing of init
# replaces variable params with sensible defaults
inits = getInitVals(self.params, 'PsychoJS')
# check for NoneTypes
for param in inits:
if inits[param] in [None, 'None', '']:
inits[param].val = 'undefined'
if param == 'text':
inits[param].val = "''"
code = ("%(name)s = new visual.TextStim({\n"
" win: psychoJS.window,\n"
" name: '%(name)s',\n"
" text: %(text)s,\n"
" font: %(font)s,\n" + unitsStr +
" pos: %(pos)s, height: %(letterHeight)s,"
" wrapWidth: %(wrapWidth)s, ori: %(ori)s,\n"
" color: new util.Color(%(color)s),"
" opacity: %(opacity)s,")
buff.writeIndentedLines(code % inits)
flip = self.params['flip'].val.strip()
if flip == 'horiz':
flipStr = 'flipHoriz : true, '
elif flip == 'vert':
flipStr = 'flipVert : true, '
elif flip:
msg = ("flip value should be 'horiz' or 'vert' (no quotes)"
" in component '%s'")
raise ValueError(msg % self.params['name'].val)
else:
flipStr = ''
depth = -self.getPosInRoutine()
code = (" %sdepth: %.1f \n"
"});\n\n" % (flipStr, depth))
buff.writeIndentedLines(code)
开发者ID:dgfitch,项目名称:psychopy,代码行数:43,代码来源:__init__.py
示例11: writeInitCode
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
# replaces variable params with sensible defaults
inits = getInitVals(self.params)
depth = -self.getPosInRoutine()
code = ("%s = visual.DotStim(\n" % inits['name'] +
" win=win, name='%s',%s\n" % (inits['name'], unitsStr) +
" nDots=%(nDots)s, dotSize=%(dotSize)s,\n" % inits +
" speed=%(speed)s, dir=%(dir)s, coherence=%(coherence)s,\n" % inits +
" fieldPos=%(fieldPos)s, fieldSize=%(fieldSize)s,fieldShape=%(fieldShape)s,\n" % inits +
" signalDots=%(signalDots)s, noiseDots=%(noiseDots)s,dotLife=%(dotLife)s,\n" % inits +
" color=%(color)s, colorSpace=%(colorSpace)s, opacity=%(opacity)s,\n" % inits +
" depth=%.1f)\n" % depth)
buff.writeIndentedLines(code)
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:20,代码来源:__init__.py
示例12: writeInitCode
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
#buff.writeIndented("from psychopy.visual.secondorder import EnvelopeGrating\n")
# replaces variable params with defaults and sets sample updating flag
inits = getInitVals(self.params)
code = ("%s = visual.EnvelopeGrating(\n" % inits['name'] +
" win=win, name='%s',%s\n" % (inits['name'], unitsStr) +
" carrier=%(carrier)s, mask=%(mask)s,\n" % inits +
" ori=%(ori)s, pos=%(pos)s, size=%(size)s,\n" % inits +
" sf=%(sf)s, phase=%(phase)s,\n" % inits +
" color=%(color)s, colorSpace=%(colorSpace)s,\n " % inits +
" opacity=%(opacity)s, contrast=%(contrast)s,\n" % inits +
" texRes=%(texture resolution)s, envelope=%(envelope)s,\n" % inits +
" envori=%(envori)s, envsf=%(envsf)s,\n" % inits +
" envphase=%(envphase)s, power=%(power)s,\n" % inits +
" moddepth=%(moddepth)s, blendmode=%(blendmode)s" %inits )
if self.params['beat'].val in ['Y','y','Yes', 'yes','True','true']:
code += ", beat=True"
elif self.params['beat'].val in ['N','n','No', 'no','False','false']:
code += ", beat=False"
else:
code += ", beat=%(beat)s" %inits
if self.params['interpolate'].val == 'linear':
code += ", interpolate=True"
else:
code += ", interpolate=False"
depth = -self.getPosInRoutine()
code += ", depth=%.1f)\n" % depth
code += "if sys.version[0]=='3' and np.min(win.gamma) == None:\n"
code += " logging.warning('Envelope grating in use with no gamma set. Unless you have hardware gamma correction the image will be distorted.')\n"
code += "elif np.min(win.gamma) < 1.01:\n"
code += " logging.warning('Envelope grating in use with window gamma <= 1.0 or no gamma set at all. Unless you have hardware gamma correction the image will be distorted.')\n"
buff.writeIndentedLines(code)
开发者ID:isolver,项目名称:psychopy,代码行数:41,代码来源:__init__.py
示例13: writeRoutineStartCode
def writeRoutineStartCode(self, buff):
inits = getInitVals(self.params)
code = ("%(name)s = microphone.AdvAudioCapture(name='%(name)s', "
"saveDir=wavDirName, stereo=%(stereo)s)\n")
buff.writeIndented(code % inits)
开发者ID:flipphillips,项目名称:psychopy,代码行数:5,代码来源:__init__.py
示例14: writeRoutineStartCode
def writeRoutineStartCode(self, buff):
inits = getInitVals(self.params)
if '$' in inits['stopVal'].val:
buff.writeIndented("%s.setSound(%s, secs=%s)\n" %
(inits['name'], inits['sound'], inits['stopVal']))
buff.writeIndented("%(name)s.setVolume(%(volume)s)\n" % (inits))
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:6,代码来源:__init__.py
注:本文中的psychopy.experiment.components.getInitVals函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论