def createstimuli(self): """Creates the VisionEgg stimuli objects for this Experiment subclass""" super(ForagingSweeps, self).createstimuli() # Create instances of the Mask2D class, one for each diameter if self.static.mask: print 'Generating masks', self.nmasksamples = 512 # number of samples in mask, must be power of 2, quality/performance tradeoff self.masks = {} # init a dictionary samplesperpix = self.nmasksamples / deg2pix(min(self.static.widthDeg, self.static.heightDeg)) for diameterDeg in toiter(self.dynamic.diameterDeg): radius = deg2pix(diameterDeg / 2) # in pix radiusSamples = samplesperpix * radius # in mask samples self.masks[diameterDeg] = Mask2D(function=self.static.mask, radius_parameter=radiusSamples, # sigma for gaussian, radius for circle, in units of mask samples num_samples=(self.nmasksamples, self.nmasksamples)) # size of mask texture data (# of texels) print '.', print else: self.masks = None self.nsinsamples = 2048 # number of samples of sine f'n, must be power of 2, quality/performance tradeoff self.grating = SinGrating2D(position=(self.xorig, self.yorig), # init to orig, anchor='center', size=(deg2pix(self.static.heightDeg), deg2pix(self.static.widthDeg)), # VE defines grating ori as direction of motion of grating, but we want it to be the orientation of the grating elements, so add 90 deg (this also makes grating ori def'n correspond to bar ori def'n). This means that width and height have to be swapped ignore_time=True, # don't use this class' own time f'n #mask=self.masks.values()[0], # init to a random mask in maskobjects num_samples=self.nsinsamples, max_alpha=1.0, # opaque on=False) # keep it off until first sweep starts self.gp = self.grating.parameters self.target = Target2D(anchor='center', anti_aliasing=False, color=(self.brightness, self.brightness, self.brightness, 1.0)) self.tp = self.target.parameters if self.static.syncsq: self.sync = Target2D(anchor='center', anti_aliasing=False, color=(0.0, 0.0, 0.0, 1.0), position = self.static.syncsqloc, on = True, size = (100,100)) self.sp = self.sync.parameters # Update target stimulus with initial values self.tp.position = self.x, self.y self.tp.size = deg2pix(self.terrain.objectwidthDeg),deg2pix(self.terrain.objectwidthDeg) self.tp.orientation = self.terrain.orientation self.updateTerrain() # Set stimuli tuple if self.static.syncsq: self.stimuli = (self.background, self.grating, self.target, self.sync) # last entry will be topmost layer in viewport else: self.stimuli = (self.background, self.grating, self.target)
def setgamma(self, gamma): """Set VisionEgg's gamma parameter""" vc = VisionEgg.config if gamma: # could be a single value or a sequence (preferably a tuple) vc.VISIONEGG_GAMMA_SOURCE = 'invert' # 'invert' in VE means that gamma correction is turned on if len(toiter(gamma)) == 1: # single value for all 3 guns vc.VISIONEGG_GAMMA_INVERT_RED = gamma vc.VISIONEGG_GAMMA_INVERT_GREEN = gamma vc.VISIONEGG_GAMMA_INVERT_BLUE = gamma elif len(toiter(gamma)) == 3: # separate value for each gun vc.VISIONEGG_GAMMA_INVERT_RED = gamma[0] vc.VISIONEGG_GAMMA_INVERT_GREEN = gamma[1] vc.VISIONEGG_GAMMA_INVERT_BLUE = gamma[2] else: raise ValueError, 'gamma cannot be of length %d' % len(toiter(gamma)) else: vc.VISIONEGG_GAMMA_SOURCE = 'None' # 'None' in VE means that gamma correction is turned off vc.VISIONEGG_GAMMA_INVERT_RED = 0 # set them all to 0 too, just to be thorough vc.VISIONEGG_GAMMA_INVERT_GREEN = 0 vc.VISIONEGG_GAMMA_INVERT_BLUE = 0
def build(self): """Builds the SweepTable and the Header for this Experiment, and loads movie frames""" super(Movie, self).build() self.load() assert max(toiter(self.dynamic.framei)) <= self.nframes-1, 'Frame indices exceed movie size of %d frames' % self.nframes self.header.NVS.data[C.STT_STS] = 16 # enter NVS stimulus code for movies