当前位置: 首页>>代码示例>>Python>>正文


Python arraytools.val2array函数代码示例

本文整理汇总了Python中psychopy.tools.arraytools.val2array函数的典型用法代码示例。如果您正苦于以下问题:Python val2array函数的具体用法?Python val2array怎么用?Python val2array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了val2array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: size

    def size(self, value):
        """
        :ref:`x,y-pair <attrib-xy>`, :ref:`scalar <attrib-scalar>` or None (resets to default). Supports :ref:`operations <attrib-operations>`.
            Units are inherited from the stimulus.
            Sizes can be negative and can extend beyond the window.

            Example::

                stim.size = 0.8  # Set size to (xsize, ysize) = (0.8, 0.8), quadratic.
                print stim.size  # Outputs array([0.8, 0.8])
                stim.size += (0,5, -0.5)  # make wider and flatter. Is now (1.3, 0.3)

            Tip: if you can see the actual pixel range this corresponds to by
            looking at stim._sizeRendered
        """
        value = val2array(value)  # Check correct user input
        self._requestedSize = value  #to track whether we're just using a default
        # None --> set to default
        if value == None:
            """Set the size to default (e.g. to the size of the loaded image etc)"""
            #calculate new size
            if self._origSize is None:  #not an image from a file
                value = numpy.array([0.5, 0.5])  #this was PsychoPy's original default
            else:
                #we have an image - calculate the size in `units` that matches original pixel size
                if self.units == 'pix': value = numpy.array(self._origSize)
                elif self.units == 'deg': value = pix2deg(numpy.array(self._origSize, float), self.win.monitor)
                elif self.units == 'cm': value = pix2cm(numpy.array(self._origSize, float), self.win.monitor)
                elif self.units == 'norm': value = 2 * numpy.array(self._origSize, float) / self.win.size
                elif self.units == 'height': value = numpy.array(self._origSize, float) / self.win.size[1]
        self.__dict__['size'] = value
        self._calcSizeRendered()
        if hasattr(self, '_calcCyclesPerStim'):
            self._calcCyclesPerStim()
        self._needUpdate = True
开发者ID:Gianluigi,项目名称:psychopy,代码行数:35,代码来源:basevisual.py

示例2: fieldPos

    def fieldPos(self, value):
        """:ref:`x,y-pair <attrib-xy>`.
        Set the centre of the array of elements.

        :ref:`Operations <attrib-operations>` are supported."""
        self.__dict__['fieldPos'] = val2array(value, False, False)
        self._needVertexUpdate = True
开发者ID:NSalem,项目名称:psychopy,代码行数:7,代码来源:elementarray.py

示例3: sf

    def sf(self, value):
        """Spatial frequency of the grating texture

        Should be a :ref:`x,y-pair <attrib-xy>` or
        :ref:`scalar <attrib-scalar>` or None.
        If `units` == 'deg' or 'cm' units are in
            cycles per deg or cm as appropriate.
        If `units` == 'norm' then sf units are in cycles per stimulus
            (and so SF scales with stimulus size).
        If texture is an image loaded from a file then sf=None
            defaults to 1/stimSize to give one cycle of the image.
        """

        # Recode phase to numpy array
        if value is None:
            # Set the sf to default (e.g. to the 1.0/size of the loaded image
            if (self.units in ('pix', 'pixels') or
                    self._origSize is not None and
                    self.units in ('deg', 'cm')):
                value = 1.0 / self.size  # default to one cycle
            else:
                value = numpy.array([1.0, 1.0])
        else:
            value = val2array(value)

        # Set value and update stuff
        self.__dict__['sf'] = value
        self._calcCyclesPerStim()
        self._needUpdate = True
开发者ID:flipphillips,项目名称:psychopy,代码行数:29,代码来源:grating.py

示例4: sf

    def sf(self, value):
        """
        :ref:`x,y-pair <attrib-xy>` or :ref:`scalar <attrib-scalar>`
        Where `units` == 'deg' or 'cm' units are in cycles per deg/cm.
        If `units` == 'norm' then sf units are in cycles per stimulus (so scale with stimulus size).
        If texture is an image loaded from a file then sf defaults to 1/stim size to give one cycle of the image.

        Spatial frequency.
        """

        # Recode phase to numpy array
        if value == None:
            """Set the sf to default (e.g. to the 1.0/size of the loaded image etc)"""
            if self.units in ['pix', 'pixels'] \
                or self._origSize is not None and self.units in ['deg', 'cm']:
                value = 1.0 / self.size  #default to one cycle
            else:
                value = numpy.array([1.0, 1.0])
        else:
            value = val2array(value)

        # Set value and update stuff
        self.__dict__['sf'] = value
        self._calcCyclesPerStim()
        self._needUpdate = True
开发者ID:GentBinaku,项目名称:psychopy,代码行数:25,代码来源:grating.py

示例5: envsf

    def envsf(self, value):
        """Spatial frequency of the envelope texture

        Should be a :ref:`x,y-pair <attrib-xy>` or
        :ref:`scalar <attrib-scalar>` or None.
        If `units` == 'deg' or 'cm' units are in cycles per deg or cm
        as appropriate.
        If `units` == 'norm' then sf units are in cycles per stimulus
        (and so envsf scales with stimulus size).
        If texture is an image loaded from a file then envsf=None defaults
        to 1/stimSize to give one cycle of the image.
        Note sf is inhertited from GratingStim and controls the spatial frequency of the carrier
        """

        # Recode phase to numpy array
        if value is None:
            # set the sf to default e.g. 1./size of the loaded image etc

            if (self.units in ['pix', 'pixels'] or
                    self._origSize is not None and
                    self.units in ['deg', 'cm']):
                value = 1.0/self.size  # default to one cycle
            else:
                value = numpy.array([1.0, 1.0])
        else:
            value = val2array(value)

        # Set value and update stuff
        self.__dict__['envsf'] = value
        self._calcEnvCyclesPerStim()
        self._needUpdate = True
开发者ID:bergwiesel,项目名称:psychopy,代码行数:31,代码来源:secondorder.py

示例6: pos

    def pos(self, value):
        """:ref:`x,y-pair <attrib-xy>` specifying the he centre of the image
        relative to the window center. Stimuli can be positioned off-screen,
        beyond the window!

        :ref:`operations <attrib-operations>` are supported."""
        self.__dict__['pos'] = val2array(value, withNone=False)
        self._calcPosRendered()
开发者ID:NSalem,项目名称:psychopy,代码行数:8,代码来源:simpleimage.py

示例7: fieldSize

    def fieldSize(self, value):
        """Scalar or :ref:`x,y-pair <attrib-xy>`.
        The size of the array of elements. This will be overridden by
        setting explicit xy positions for the elements.

        :ref:`Operations <attrib-operations>` are supported."""
        self.__dict__['fieldSize'] = val2array(value, False)
        self.setXYs(log=False)  # to reflect new settings, overriding individual xys
开发者ID:NSalem,项目名称:psychopy,代码行数:8,代码来源:elementarray.py

示例8: phase

    def phase(self, value):
        """Phase of the stimulus in each dimension of the texture.

        Should be an :ref:`x,y-pair <attrib-xy>` or :ref:`scalar <attrib-scalar>`

        **NB** phase has modulus 1 (rather than 360 or 2*pi)
        This is a little unconventional but has the nice effect
        that setting phase=t*n drifts a stimulus at n Hz
        """
        # Recode phase to numpy array
        value = val2array(value)
        self.__dict__['phase'] = value
        self._needUpdate = True
开发者ID:Dagiba,项目名称:psychopy,代码行数:13,代码来源:grating.py

示例9: vertices

    def vertices(self, newVerts):
        """A list of lists or a numpy array (Nx2) specifying xy positions of
        each vertex, relative to the center of the field.

        Assigning to vertices can be slow if there are many vertices.

        :ref:`Operations <attrib-operations>` supported with `.setVertices()`.
        """
        # Check shape
        self.__dict__['vertices'] = val2array(newVerts, withNone=True,
                                              withScalar=True, length=2)
        self._needVertexUpdate = True
        self._tesselate(self.vertices)
开发者ID:flipphillips,项目名称:psychopy,代码行数:13,代码来源:shape.py

示例10: envphase

    def envphase(self, value):
        """Phase of the modulation in each dimension of the envelope texture.

        Should be an :ref:`x,y-pair <attrib-xy>` or
        :ref:`scalar <attrib-scalar>`

        **NB** phase has modulus 1 (rather than 360 or 2*pi)
        This is a little unconventional but has the nice effect
        that setting phase=t*n drifts a stimulus at n Hz
        Note phase in inherited from GratingStim and controls the phase of the carrier
        """
        # Recode phase to numpy array
        value = val2array(value)
        self.__dict__['envphase'] = value
        self._needUpdate = True
开发者ID:bergwiesel,项目名称:psychopy,代码行数:15,代码来源:secondorder.py

示例11: size

    def size(self, value):
        """The size (w,h) of the stimulus in the stimulus :ref:`units <units>`

        Value should be :ref:`x,y-pair <attrib-xy>`, :ref:`scalar <attrib-scalar>` (applies to both dimensions)
        or None (resets to default). :ref:`Operations <attrib-operations>` are supported.

        Sizes can be negative (causing a mirror-image reversal) and can extend beyond the window.

        Example::

            stim.size = 0.8  # Set size to (xsize, ysize) = (0.8, 0.8), quadratic.
            print stim.size  # Outputs array([0.8, 0.8])
            stim.size += (0.5, -0.5)  # make wider and flatter. Is now (1.3, 0.3)

        Tip: if you can see the actual pixel range this corresponds to by
        looking at `stim._sizeRendered`
        """
        value = val2array(value)  # Check correct user input
        self._requestedSize = value  #to track whether we're just using a default
        # None --> set to default
        if value == None:
            """Set the size to default (e.g. to the size of the loaded image etc)"""
            #calculate new size
            if self._origSize is None:  #not an image from a file
                value = numpy.array([0.5, 0.5])  #this was PsychoPy's original default
            else:
                #we have an image - calculate the size in `units` that matches original pixel size
                if self.units == 'pix':
                    value = numpy.array(self._origSize)
                elif self.units in ['deg', 'degFlatPos', 'degFlat']:
                    #NB when no size has been set (assume to use orig size in pix) this should not
                    #be corrected for flat anyway, so degFlat==degFlatPos
                    value = pix2deg(numpy.array(self._origSize, float), self.win.monitor)
                elif self.units == 'norm':
                    value = 2 * numpy.array(self._origSize, float) / self.win.size
                elif self.units == 'height':
                    value = numpy.array(self._origSize, float) / self.win.size[1]
                elif self.units == 'cm':
                    value = pix2cm(numpy.array(self._origSize, float), self.win.monitor)
                else:
                    raise AttributeError, "Failed to create default size for ImageStim. Unsupported unit, %s" %(repr(self.units))
        self.__dict__['size'] = value
        self._needVertexUpdate=True
        self._needUpdate = True
        if hasattr(self, '_calcCyclesPerStim'):
            self._calcCyclesPerStim()
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:46,代码来源:basevisual.py

示例12: pos

    def pos(self, value):
        """The position of the center of the stimulus in the stimulus :ref:`units <units>`

        Value should be an :ref:`x,y-pair <attrib-xy>`. :ref:`Operations <attrib-operations>`
        are also supported.

        Example::

            stim.pos = (0.5, 0)  # Set slightly to the right of center
            stim.pos += (0.5, -1)  # Increment pos rightwards and upwards. Is now (1.0, -1.0)
            stim.pos *= 0.2  # Move stim towards the center. Is now (0.2, -0.2)

        Tip: if you can see the actual pixel range this corresponds to by
        looking at `stim._posRendered`
        """
        self.__dict__['pos'] = val2array(value, False, False)
        self._calcPosRendered()
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:17,代码来源:basevisual.py

示例13: vertices

    def vertices(self, newVerts):
        """A list of lists or a numpy array (Nx2) specifying xy positions of
        each vertex, relative to the center of the field.

        Assigning to vertices can be slow if there are many vertices.

        :ref:`Operations <attrib-operations>` supported with `.setVertices()`.
        """
        # check if this is a name of one of our known shapes
        if isinstance(newVerts, basestring) and newVerts in knownShapes:
            newVerts = knownShapes[newVerts]

        # Check shape
        self.__dict__['vertices'] = val2array(newVerts, withNone=True,
                                              withScalar=True, length=2)
        self._needVertexUpdate = True
        self._tesselate(self.vertices)
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:17,代码来源:shape.py

示例14: pos

    def pos(self, value):
        """
        :ref:`x,y-pair <attrib-xy>`. :ref:`operations <attrib-operations>` supported.
            Set the stimulus position in the `units` inherited from the stimulus.
            Either list [x, y], tuple (x, y) or numpy.ndarray ([x, y]) with two elements.

            Example::

                stim.pos = (0.5, 0)  # Slightly to the right
                stim.pos += (0.5, -1)  # Move right and up. Is now (1.0, -1.0)
                stim.pos *= 0.2  # Move towards the center. Is now (0.2, -0.2)

            Tip: if you can see the actual pixel range this corresponds to by
            looking at stim._posRendered
        """
        self.__dict__['pos'] = val2array(value, False, False)
        self._calcPosRendered()
开发者ID:Gianluigi,项目名称:psychopy,代码行数:17,代码来源:basevisual.py

示例15: _set

    def _set(self, attrib, val, op='', log=True):
        """
        Use this method when you want to be able to suppress logging (e.g., in
        tests). Typically better to use methods specific to the parameter, e.g. ::

             stim.pos = [3,2.5]
             stim.ori = 45
             stim.phase += 0.5

        NB this method does not flag the need for updates any more - that is
        done by specific methods as described above.
        """
        if op==None: op=''
        #format the input value as float vectors
        if type(val) in [tuple, list, numpy.ndarray]:
            val = val2array(val)
        # Handle operations
        setWithOperation(self, attrib, val, op)
开发者ID:BrainTech,项目名称:psychopy,代码行数:18,代码来源:basevisual.py


注:本文中的psychopy.tools.arraytools.val2array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。