def make_stimuli(self): size = self.viewport.get_size() width = max(size) self.grating1 = SinGrating2D( anchor='center', position=(size[0] / 2, size[1] / 2), size=(width, width), pedestal=self.parameters.ml[0], orientation=self.parameters.ori[0], spatial_freq=self.viewport.cycDeg2cycPix( self.parameters.sfreqCycDeg[0]), temporal_freq_hz=self.parameters.tfreqCycSec[0], max_alpha=0.5, ignore_time=True, on=True) self.grating2 = SinGrating2D( anchor='center', position=(size[0] / 2, size[1] / 2), size=(width, width), pedestal=self.parameters.ml[1], orientation=self.parameters.ori[1], spatial_freq=self.viewport.cycDeg2cycPix( self.parameters.sfreqCycDeg[1]), temporal_freq_hz=self.parameters.tfreqCycSec[1], max_alpha=0.5, ignore_time=True, on=True) self.stimuli = (self.grating1, self.grating2)
def make_stimuli(self): size = self.viewport.get_size() self.background = Target2D(position=(size[0]/2, size[1]/2), anchor='center', size=size, on=True) self.bgp = self.background.parameters #set background color before real sweep bgb = self.parameters.bgbrightness self.bgp.color = bgb, bgb, bgb, 1.0 nsinsamples = 1024 self.grating = SinGrating2D(anchor='center', pedestal=self.parameters.ml, contrast=self.parameters.contrast, ignore_time=True, num_samples=nsinsamples, max_alpha=1.0, on=False) self.gp = self.grating.parameters nmasksamples = 1024 radius = self.viewport.deg2pix(self.parameters.maskDiameterDeg) / 2.0 self.gp.size = [radius * 2] * 2 samplesperpix = nmasksamples / self.gp.size[0] self.grating_mask = Mask2D(function=self.parameters.mask, radius_parameter=radius*samplesperpix, num_samples=(nmasksamples,nmasksamples)) self.gp.mask = self.grating_mask self.gmp = self.grating_mask.parameters self.stimuli = (self.background, self.grating)
def make_stimuli(self): super(ManGrating, self).make_stimuli() nsinsamples = 512 self.grating = SinGrating2D(anchor='center', pedestal=self.parameters.ml, ignore_time=True, num_samples=nsinsamples, max_alpha=1.0, on=False) # opaque self.gp = self.grating.parameters self.nmasksamples = 256 self.grating_mask = Mask2D(function='circle', num_samples=(self.nmasksamples, self.nmasksamples)) # size of mask texture data (# of texels) self.gmp = self.grating_mask.parameters if self.parameters.mask: self.mask_on = True else: self.mask_on = False self.fixationspot = FixationSpot(anchor='center', color=(1.0, 0.0, 0.0, 0.0), size=(5, 5), on=False) self.fp = self.fixationspot.parameters self.centerspot = FixationSpot(anchor='center', color=(0.0, 1.0, 0.0, 0.0), size=(3, 3), on=False) self.cp = self.centerspot.parameters self.complete_stimuli = (self.background, self.grating, self.fixationspot, self.centerspot) + self.info self.essential_stimuli = (self.background, self.grating)
from VisionEgg.Gratings import SinGrating2D from VisionEgg.Text import Text import pygame import numpy as np if not hasattr(pygame.display, "set_gamma_ramp"): raise RuntimeError( "Need pygame 1.5 or greater for set_gamma_ramp function.") # Initialize OpenGL graphics screen. screen = get_default_screen() center_x = screen.size[0] / 2.0 # Create the instance SinGrating with appropriate parameters stimulus = SinGrating2D() text2 = Text(text="set_gamma_ramp(r,g,b):", position=(center_x, 0), anchor="bottom") text1 = Text(text="Press - to decrease luminance range, + to increase.", position=(center_x, text2.parameters.size[1] + 5), anchor="bottom") # Use viewport with pixel coordinate system for projection viewport = Viewport(screen=screen, stimuli=[stimulus, text1, text2]) def quit(event): global p # get presentation instance p.parameters.quit = 1
import Pyro Pyro.config.PYRO_MOBILE_CODE = True Pyro.config.PYRO_TRACELEVEL = 3 Pyro.config.PYRO_PICKLE_FORMAT = 1 from VisionEgg.PyroClient import PyroClient from VisionEgg.Gratings import SinGrating2D from VisionEgg.MoreStimuli import Target2D from StimControl.LightStim.Core import DefaultScreen dummy_screen = DefaultScreen(['control']) grating = SinGrating2D() target = Target2D() client = PyroClient(server_hostname='localhost') #quit_controller = client.get('quit_controller') #time.sleep(5.0) # show for 5 seconds # #quit_controller.set_between_go_value(1) #quit_controller.evaluate_now() stimulus_pool = client.get('stimulus_pool') stimulus_pool.add_stimulus(target) stimulus_pool.add_stimulus(grating)
gl.glLoadIdentity() # Clear the modelview matrix gl.glTranslate(viewport_with, 0, 0) gl.glRotate(180, 0, 1, 0) matrix = gl.glGetFloatv(gl.GL_MODELVIEW_MATRIX) gl.glPopMatrix() if matrix is None: # OpenGL wasn't started raise RuntimeError( "OpenGL matrix operations can only take place once OpenGL context started." ) matrix = np.asarray(matrix) # make sure it's numpy array VisionEgg.Core.ModelView.__init__(self, **{'matrix': matrix}) # Normal stuff (from grating demo): screen = VisionEgg.Core.get_default_screen() grating = SinGrating2D( position=(screen.size[0] / 2.0, screen.size[1] / 2.0), anchor='center', size=(400.0, 300.0), spatial_freq=10.0 / screen.size[0], # units of cycles/pixel temporal_freq_hz=5.0, orientation=45.0) viewport = Viewport(screen=screen, stimuli=[grating]) viewport.parameters.camera_matrix = HorizontalMirrorView(offset=screen.size[0]) p = Presentation(go_duration=(5.0, 'seconds'), viewports=[viewport]) # Go! p.go()
mask = Mask2D(function='circle', # also supports 'circle' radius_parameter=100, # sigma for gaussian, radius for circle (units: num_samples) num_samples=(256,256)) # this many texture elements in mask (covers whole size specified below) # NOTE: I am not a color scientist, and I am not familiar with the # needs of color scientists. Color interpolation is currently done in # RGB space, but I assume there are other interpolation methods that # people may want. Please submit any suggestions. stimulus = SinGrating2D(color1 = (0.5, 0.25, 0.5), # RGB (alpha ignored if given) color2 = (1.0, 0.5, 0.1), # RGB (alpha ignored if given) contrast = 0.2, pedestal = 0.1, mask = mask, # optional position = ( screen.size[0]/2.0, screen.size[1]/2.0 ), anchor = 'center', size = ( 300.0 , 300.0 ), spatial_freq = 20.0 / screen.size[0], # units of cycles/pixel temporal_freq_hz = 1.0, orientation = 270.0 ) def pedestal_func(t): # Calculate pedestal over time. (Pedestal range [0.1,0.9] and # contrast = 0.2 limits total range to [0.0,1.0]) temporal_freq_hz = 0.2 return 0.4 * sin(t*2*pi * temporal_freq_hz) + 0.5 ############################################################### # Create viewport - intermediary between stimuli and screen # ###############################################################
Text( text="Texture Mask", position=(x1, y2), anchor='center', color=warning_color, font_size=warning_font_size, )) print "Exception while trying to create circle_mask: %s: %s" % ( x.__class__, str(x)) color_grating = SinGrating2D( color1=(0.5, 0.25, 0.5), # RGB, Alpha ignored if given color2=(1.0, 0.5, 0.1), # RGB, Alpha ignored if given contrast=0.2, pedestal=0.1, mask=circle_mask, position=(x1, y2), anchor='center', size=(width, width), # must be square for circle shape spatial_freq=20.0 / screen.size[0], temporal_freq_hz=1.0, orientation=270.0) legends.append( Text( text="SinGrating2D (color)", position=(x1, y2 - height / 2 + 2), anchor='top', color=legend_color, font_size=legend_font_size, ))
########################################################## # Create sinusoidal grating object and gaussian window # ########################################################## mask = Mask2D( function='gaussian', # also supports 'circle' radius_parameter= 25, # sigma for gaussian, radius for circle (units: num_samples) num_samples=(256, 256) ) # this many texture elements in mask (covers whole size specified below) stimulus = SinGrating2D( mask=mask, position=(screen.size[0] / 2.0, screen.size[1] / 2.0), size=(300.0, 300.0), spatial_freq=10.0 / screen.size[0], # units of cycles/pixel temporal_freq_hz=1.0, orientation=45.0) ############################################################### # Create viewport - intermediary between stimuli and screen # ############################################################### viewport = Viewport(screen=screen, stimuli=[stimulus]) ######################################## # Create presentation object and go! # ######################################## p = Presentation(go_duration=(5.0, 'seconds'), viewports=[viewport])