def inputStimControlSimple(port="1234"):
    #Set up thread to monitor the publisher
    sub = utils.Subscriber(topic="stim", port=port)
    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)
    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': 's', 'angle': 80, 'velocity': -0.05}
    stim_texts = [tex1, tex2]
    stim_params = [params1, params2]

    # Set up filepath for saving
    current_dt = dt.now()
    filename = current_dt.strftime(("ics_%Y%m%d_%H%M%S.txt"))
    save_dir = r'./examples'
    file_path = save_dir + filename

    # Run the show!
    frame_rate = 30
    closed_loop = stimuli.InputControlStim(stim_texts,
                                           stim_params,
                                           profile_on=False,
                                           fps=frame_rate,
                                           save_path=file_path)
    closed_loop.run()

    # Stuff that will be run after you close the panda3d window
    monitor.kill()
    if closed_loop.filestream:
        closed_loop.filestream.close()
def inputStimControl(port='1234'):
    #Set up thread to monitor the publisher
    sub = utils.Subscriber(topic="stim", port=port)
    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 = dt.now()
    filename = current_dt.strftime(("ic_%Y%m%d_%H%M%S.txt"))
    save_dir = r'./examples'
    file_path = save_dir + filename

    frame_rate = 30
    closed_loop = stimuli.InputControlStim(stim_texts,
                                           stim_params,
                                           initial_tex_ind=0,
                                           profile_on=False,
                                           fps=frame_rate,
                                           save_path=file_path)
    closed_loop.run()
    monitor.kill()

    if closed_loop.filestream:
        closed_loop.filestream.close()
Example #3
0
# -*- coding: utf-8 -*-
"""
pandastim/examples/moving_red_sin.py

For info about profiling and the profile_on keyword, see pandastim/readme.md

Part of pandastim package: https://github.com/mattdloring/pandastim
"""
from pandastim import textures, stimuli

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 drifting sin example',
                                 profile_on=False)
sin_red_stim.run()
Example #4
0
    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/mattdloring/pandastim
"""
from pandastim import textures, 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/mattdloring/pandastim
"""
from pandastim import textures, 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'
file_path = save_dir + filename

# Run the show
toggle_show = stimuli.KeyboardToggleTex(tex_classes,
                                        stim_params,
                                        profile_on = False,
                                        save_path = file_path)