draw(), should be fast: # self._updateList() # ie refresh display list self. Instead, simply defer the update to the # first. # Could potentially define a BaseGrating class without # updateListShaders code, and have GratingStim and RadialStim # inherit from it and add their own _updateList stuff. # So don't want to do the update here (= ALSO the init of RadialStim). glGenLists ( 1 ) # JRG: doing self._updateList() here means MRO issues for RadialStim, # which inherits from GratingStim but has its own _updateList code. _calcCyclesPerStim () # generate a displaylist ID self. blendmode = blendmode # fix scaling to window coords self. pos = val2array ( pos, False, False ) self. _origSize = None # updated if an image texture is loaded self. phase = val2array ( phase, False ) self. color = Color ( lms, 'lms' ) # set other parameters self. warning ( "Use of lms arguments to stimuli are deprecated." " Please use color and colorSpace args instead" ) self. color = Color ( dkl, 'dkl' ) elif lms != None : logging. warning ( "Use of dkl arguments to stimuli are deprecated." " Please use color and colorSpace args instead" ) self. color = Color ( rgb, 'rgb' ) elif dkl != None : logging. warning ( "Use of rgb arguments to stimuli are deprecated." " Please use color and colorSpace args instead" ) self. rgbPedestal = val2array ( rgbPedestal, False, length = 3 ) # No need to invoke decorator for color updating. interpolate = interpolate # NB Pedestal isn't currently being used during rendering - this is a # place-holder self. _dict_ = texRes # must be power of 2 self. _dict_ = maskParams # initialise textures and masks for stimulus self. # TO DO: postpone calls to _createTexture, setColor and # _calcCyclesPerStim whin initiating stimulus self. _init_ ( win, units = units, name = name, autoLog = False ) # UGLY HACK: Some parameters depend on each other for processing. remove ( unecess ) # initialise parent class super ( GratingStim, self ). _initParams = dir () for unecess in : self. All doc is in attributes # what local vars are defined (these are the init params) for use by # _repr_ self. """ def _init_ ( self, win, tex = "sin", mask = "none", units = None, anchor = "center", pos = ( 0.0, 0.0 ), size = None, sf = None, ori = 0.0, phase = ( 0.0, 0.0 ), texRes = 128, rgb = None, dkl = None, lms = None, color = ( 1.0, 1.0, 1.0 ), colorSpace = 'rgb', contrast = 1.0, opacity = None, depth = 0, rgbPedestal = ( 0.0, 0.0, 0.0 ), interpolate = False, blendmode = 'avg', name = None, autoLog = None, autoDraw = False, maskParams = None ): """ """ # Empty docstring. Be sure to get the aspect ratio the same as the image (if you don't want it stretched!). The size of the stimulus should be specified in the normal way using the appropriate units (deg, pix, cm. Any image that is not will be upscaled (with linear interpolation) to the nearest such texture by PsychoPy. )** Ideally texture images to be rendered should be square with 'power-of-2' dimensions e.g. **Using GratingStim with images from disk (jpg, tif, png. Also since transparency can be controlled two GratingStims can combine e.g. **Examples**:: myGrat = GratingStim(tex='sin', mask='circle') # circular grating myGabor = GratingStim(tex='sin', mask='gauss') # gives a 'Gabor' A GratingStim can be rotated scaled and shifted in position, its texture can be drifted in X and/or Y and it can have a spatial frequency in X and/or Y (for an image file that simply draws multiple copies in the patch). Both the texture and mask can be arbitrary bitmaps and their combination allows an enormous variety of stimuli to be drawn in realtime. Formally GratingStim is just a texture behind an optional transparency mask (an 'alpha mask'). class GratingStim ( BaseVisualStim, TextureMixin, ColorMixin, ContainerMixin ): """Stimulus object for drawing arbitrary bitmaps that can repeat (cycle) in either dimension. gl import psychopy # so we can get the _path_ from psychopy import logging from import val2array from import attributeSetter from import ( BaseVisualStim, ColorMixin, ContainerMixin, TextureMixin ) import numpy options = False import ctypes GL = pyglet. # Shaders will work but require OpenGL2.0 drivers AND PyOpenGå…ƒ.0+ import pyglet from lors import Color pyglet. # Ensure setting pyglet.options to False is done prior to any # other calls to pyglet or pyglet submodules, otherwise it may not get picked # up by the pyglet GL engine and have no effect. # Distributed under the terms of the GNU General Public License (GPL). """ # Part of the PsychoPy library # Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2022 Open Science Tools Ltd. #!/usr/bin/env python # -*- coding: utf-8 -*- """Stimulus object for drawing arbitrary bitmaps that can repeat (cycle) in either dimension.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |