Part of pandastim package: https://github.com/EricThomson/pandastim """ import stimuli import textures import utils from datetime import datetime #Set up thread to monitor the publisher sub = utils.Subscriber(topic="stim", port="1234") monitor = utils.Monitor(sub) # Create list of textures, and parameter list for the two textures # Note parameters include a 'stim_type' ('s' for single texture, 'b' for binocular) tex0 = textures.RgbTex(rgb=(0, 0, 0)) params0 = {'stim_type': 's', 'angle': 0, 'velocity': 0} tex1 = textures.SinRgbTex(rgb=(255, 0, 0)) params1 = {'stim_type': 's', 'angle': 45, 'velocity': 0.1} tex2 = textures.GratingGrayTex(spatial_frequency=20) params2 = { 'stim_type': 'b', 'angles': (-40, -40), 'velocities': (-0.05, .05), 'position': (0.25, 0.25), 'strip_angle': -40, 'strip_width': 8 } stim_texts = [tex0, tex1, tex2] stim_params = [params0, params1, params2] # Set up filepath for saving current_dt = datetime.now()
#Set the scale on the card (note this is different from scaling the texture) self.card.setScale(np.sqrt(2)) if self.scale != 0: #Add task to taskmgr to translate texture self.taskMgr.add(self.scaleTextureTask, "scaleTextureTask") #Move the texture def scaleTextureTask(self, task): if task.time > 1: new_scale = task.time * (self.scale) self.card.setTexScale(self.textureStage, new_scale, new_scale) #u_scale, v #Set conditional so when it reaches 0 or some max it resets to 1 return Task.cont #%% if __name__ == '__main__': import textures sin_red_tex = textures.SinRgbTex(texture_size=512, spatial_frequency=20, rgb=(255, 0, 0)) sin_red_stim = TexMoving(sin_red_tex, angle=25, velocity=-0.05, window_name='red sin test stim', profile_on=False) sin_red_stim.run()
] em = Emitter(x, y, theta, period=.5, pause=2) binocular_show.run() em.kil() elif example_ind == 0: sin_grey_tex = textures.SinGrayTex(texture_size=512, spatial_frequency=20) sin_stim = stimuli.TexFixed(sin_grey_tex, angle=-30, profile_on=False, window_name='gray static sin example') sin_stim.run() elif example_ind == 1: sin_red_tex = textures.SinRgbTex(texture_size=512, spatial_frequency=30, rgb=(255, 0, 0)) sin_red_stim = stimuli.TexMoving(sin_red_tex, angle=33, velocity=-0.05, fps=30, window_name='red sin moving example', profile_on=True) sin_red_stim.run() elif example_ind == 2: stim = textures.SinRgbTex(rgb=(255, 0, 0), spatial_frequency=20) binocular_show = stimuli.BinocularMoving( stim, position=(-0.5, 0.25), stim_angles=(40, 40),
# -*- coding: utf-8 -*- """ pandastim/examples/fixed_binocular_sin.py For info about profiling and the profile_on keyword, see pandastim/readme.md Part of pandastim package: https://github.com/EricThomson/pandastim """ import textures import stimuli stim = textures.SinRgbTex(rgb=(0, 255, 0), spatial_frequency=20) binocular_fixed = stimuli.BinocularFixed(stim, position=(-0.5, 0.25), stim_angles=(-40, -40), strip_angle=50, strip_width=8, profile_on=True, window_name='green binocular example') binocular_fixed.run()
# -*- coding: utf-8 -*- """ pandastim/examples/keyboard_switcher.py This is not something you would use in an experiment, but is useful for showing the logic of input-driven stimuli. Part of pandastim package: https://github.com/EricThomson/pandastim """ import textures import stimuli from datetime import datetime # Create list of textures, and parameter list for the two textures tex1 = textures.SinRgbTex(rgb=(50, 255, 255)) tex2 = textures.SinRgbTex(rgb=(0, 0, 255)) tex_classes = [tex1, tex2] stim_params = [{ 'angle': 45, 'velocity': 0.1 }, { 'angle': -45, 'velocity': -0.1 }] # Set up file path current_dt = datetime.now() filename = current_dt.strftime(("ks_%Y%m%d_%H%M%S.txt")) save_dir = r'./examples/data/' file_path = save_dir + filename