本文整理汇总了Python中psychopy.tools.attributetools.logAttrib函数的典型用法代码示例。如果您正苦于以下问题:Python logAttrib函数的具体用法?Python logAttrib怎么用?Python logAttrib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了logAttrib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setRadius
def setRadius(self, radius, log=True):
"""Changes the radius of the Polygon. If radius is a 2-tuple or list, the values will be
interpreted as semi-major and semi-minor radii of an ellipse."""
self.radius = numpy.asarray(radius)
self._calcVertices()
self.setVertices(self.vertices, log=False)
logAttrib(self, log, 'radius', radius)
示例2: setFlipVert
def setFlipVert(self, newVal=True, log=None):
"""If set to True then the movie will be flipped vertically (top-to-bottom).
Note that this is relative to the original, not relative to the current state.
"""
self.flipVert = newVal
logAttrib(self, log, 'flipVert')
self._needVertexUpdate = True
示例3: setColors
def setColors(self, color, colorSpace=None, operation="", log=None):
"""See ``color`` for more info on the color parameter and
``colorSpace`` for more info in the colorSpace parameter.
"""
setColor(
self,
color,
colorSpace=colorSpace,
operation=operation,
rgbAttrib="rgbs", # or 'fillRGB' etc
colorAttrib="colors",
colorSpaceAttrib="colorSpace",
)
logAttrib(self, log, "colors", value="%s (%s)" % (self.colors, self.colorSpace))
# check shape
if self.rgbs.shape in ((), (1,), (3,)):
self.rgbs = numpy.resize(self.rgbs, [self.nElements, 3])
elif self.rgbs.shape in ((self.nElements,), (self.nElements, 1)):
self.rgbs.shape = (self.nElements, 1) # set to be 2D
self.rgbs = self.rgbs.repeat(3, 1) # repeat once on dim 1
elif self.rgbs.shape == (self.nElements, 3):
pass # all is good
else:
raise ValueError("New value for setRgbs should be either " "Nx1, Nx3 or a single value")
self._needColorUpdate = True
示例4: loadMovie
def loadMovie(self, filename, log=True):
"""Load a movie from file
:Parameters:
filename: string
The name of the file, including path if necessary
After the file is loaded MovieStim.duration is updated with the movie
duration (in seconds).
"""
self.reset() #set status and timestamps etc
# Create Video Stream stuff
if os.path.isfile(filename):
self._mov = VideoFileClip(filename, audio= (1-self.noAudio))
if (not self.noAudio) and (self._mov.audio is not None):
self._audioStream = sound.Sound(self._mov.audio.to_soundarray(),
sampleRate = self._mov.audio.fps)
else: #make sure we set to None (in case prev clip did have auido)
self._audioStream = None
else:
raise IOError("Movie file '%s' was not found" %filename)
#mov has attributes:
# size, duration, fps
#mov.audio has attributes
#duration, fps (aka sampleRate), to_soundarray()
self._frameInterval = 1.0/self._mov.fps
self.duration = self._mov.duration
self.filename = filename
self._updateFrameTexture()
logAttrib(self, log, 'movie', filename)
示例5: setSfs
def setSfs(self, value,operation='', log=True):
"""Set the spatial frequency for each element.
Should either be:
- a single value
- an Nx1 array/list
- an Nx2 array/list (spatial frequency of the element in X and Y).
If the units for the stimulus are 'pix' or 'norm' then the units of sf
are cycles per stimulus width. For units of 'deg' or 'cm' the units
are c/cm or c/deg respectively.
"""
#make into an array
if type(value) in [int, float, list, tuple]:
value = numpy.array(value, dtype=float)
#check shape
if value.shape in [(),(1,),(2,)]:
value = numpy.resize(value, [self.nElements,2])
elif value.shape in [(self.nElements,), (self.nElements,1)]:
value.shape=(self.nElements,1)#set to be 2D
value = value.repeat(2,1) #repeat once on dim 1
elif value.shape == (self.nElements,2):
pass#all is good
else:
raise ValueError("New value for setSfs should be either Nx1, Nx2 or a single value")
# Set value and log
setWithOperation(self, 'sfs', value, operation)
logAttrib(self, log, 'sfs', type(value))
示例6: setMask
def setMask(self,value, log=True):
"""Change the mask (all elements have the same mask). Avoid doing this
during time-critical points in your script. Uploading new textures to the
graphics card can be time-consuming."""
self.mask = value
self.createTexture(value, id=self._maskID, pixFormat=GL.GL_ALPHA, stim=self, res=self.texRes)
logAttrib(self, log, 'mask')
示例7: seek
def seek(self, timestamp, log=None):
"""Seek to a particular timestamp in the movie.
NB this does not seem very robust as at version 1.62, may crash!
"""
self._player.seek(float(timestamp))
logAttrib(self, log, 'seek', timestamp)
示例8: _set
def _set(self, attrib, val, op='', log=True):
"""Use this to set attributes of your stimulus after initialising it.
:Parameters:
attrib : a string naming any of the attributes of the stimulus (set during init)
val : the value to be used in the operation on the attrib
op : a string representing the operation to be performed (optional) most maths operators apply ('+','-','*'...)
examples::
myStim.set('rgb',0) #will simply set all guns to zero (black)
myStim.set('rgb',0.5,'+') #will increment all 3 guns by 0.5
myStim.set('rgb',(1.0,0.5,0.5),'*') # will keep the red gun the same and halve the others
"""
#format the input value as float vectors
if type(val) in [tuple,list]:
val=numpy.array(val,float)
#change the attribute as requested
setWithOperation(self, attrib, val, op)
#update the actual coherence for the requested coherence and nDots
if attrib in ['nDots','coherence']:
self.coherence=round(self.coherence*self.nDots)/self.nDots
logAttrib(self, log, attrib)
示例9: setPhases
def setPhases(self,value,operation='', log=True):
"""Set the phase for each element.
Should either be:
- a single value
- an Nx1 array/list
- an Nx2 array/list (for separate X and Y phase)
"""
#make into an array
if type(value) in [int, float, list, tuple]:
value = numpy.array(value, dtype=float)
#check shape
if value.shape in [(),(1,),(2,)]:
value = numpy.resize(value, [self.nElements,2])
elif value.shape in [(self.nElements,), (self.nElements,1)]:
value.shape=(self.nElements,1)#set to be 2D
value = value.repeat(2,1) #repeat once on dim 1
elif value.shape == (self.nElements,2):
pass#all is good
else:
raise ValueError("New value for setPhases should be either Nx1, Nx2 or a single value")
#set value and log
setWithOperation(self, 'phases', value, operation)
logAttrib(self, log, 'phases', type(value))
self._needTexCoordUpdate=True
示例10: setStart
def setStart(self, start, log=True):
"""Changes the start point of the line. Argument should be
- tuple, list or 2x1 array specifying the coordinates of the start point"""
self.start = start
self.setVertices([self.start, self.end], log=False)
logAttrib(self, log, 'start')
示例11: setFlipHoriz
def setFlipHoriz(self, newVal=True, log=None):
"""If set to True then the movie will be flipped horizontally (left-to-right).
Note that this is relative to the original, not relative to the current state.
"""
self.flipHoriz = newVal
logAttrib(self, log, 'flipHoriz')
self._needVertexUpdate = True
示例12: seek
def seek(self, timestamp, log=True):
"""Seek to a particular timestamp in the movie.
"""
if self.status in [PLAYING, PAUSED]:
if timestamp > 0.0:
if self.status == PLAYING:
self.pause()
player = self._audio_stream_player
if player and player.is_seekable():
player.set_time(int(timestamp * 1000.0))
self._audio_stream_clock.reset(-timestamp)
MSEC = cv2.CAP_PROP_POS_MSEC
FRAMES = cv2.CAP_PROP_POS_FRAMES
self._video_stream.set(MSEC, timestamp * 1000.0)
self._video_track_clock.reset(-timestamp)
self._next_frame_index = self._video_stream.get(FRAMES)
self._next_frame_sec = self._video_stream.get(MSEC)/1000.0
else:
self.stop()
self.loadMovie(self.filename)
if log:
logAttrib(self, log, 'seek', timestamp)
self.play()
示例13: loadMovie
def loadMovie(self, filename, log=None):
"""Load a movie from file
:Parameters:
filename: string
The name of the file, including path if necessary
Brings up a warning if avbin is not found on the computer.
After the file is loaded MovieStim.duration is updated with the movie
duration (in seconds).
"""
try:
self._movie = pyglet.media.load(filename, streaming=True)
except Exception as e:
# pyglet.media.riff is N/A if avbin is available, and then
# actual exception would get masked with a new one for unknown
# (sub)module riff, thus catching any exception and tuning msg
# up if it has to do anything with avbin
estr = str(e)
msg = ''
if "avbin" in estr.lower():
msg = ("\nIt seems that avbin was not installed correctly."
"\nPlease fetch/install it from "
"http://code.google.com/p/avbin/.")
emsg = "Caught exception '%s' while loading file '%s'.%s"
raise IOError(emsg % (estr, filename, msg))
self._player.queue(self._movie)
self.duration = self._movie.duration
while self._player.source != self._movie:
next(self._player)
self.status = NOT_STARTED
self._player.pause() # start 'playing' on the next draw command
self.filename = filename
logAttrib(self, log, 'movie', filename)
示例14: setPos
def setPos(self, pos, needReset=True, log=True):
"""Set the pos (centre) of the Aperture
"""
self.pos = numpy.array(pos)
self._shape.pos = self.pos
if needReset:
self._reset()
logAttrib(self, log, 'pos')
示例15: setOri
def setOri(self, ori, needReset=True, log=True):
"""Set the orientation of the Aperture
"""
self.ori = ori
self._shape.ori = ori
if needReset:
self._reset()
logAttrib(self, log, 'ori')