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()
Exemplo n.º 2
0
def spawn_pandas(save_path=None, port=5005):

    stimulation = stimuli.ClosedLoopStimChoice(window_size=(1024, 1024),
                                               gui=True,
                                               publisher_port=5008,
                                               live_update=True,
                                               save_path=save_path,
                                               debug=False)

    sub = utils.Subscriber(topic="stim", port=port)
    sub2 = utils.Subscriber(topic="stim",
                            port=5006,
                            ip=r"tcp://10.122.170.169:")
    sub3 = utils.Subscriber(topic="stim", port=5010)

    monitor = utils.MonitorDataPass(sub)
    monitor2 = utils.MonitorDataPass(sub2)
    monitor3 = utils.MonitorDataPass(sub3)

    stimulation.run()
Exemplo n.º 3
0
    def spawn_pandas(port=5005, anne=True):
        sve_pth = datetime.now().strftime("%d.%m.%Y__%H.%M.%S") + '_stims.txt'

        stimulation = stimuli.ClosedLoopStimChoice(gui=True,
                                                   live_update=True,
                                                   debug=True,
                                                   publisher_port=5008,
                                                   save_path=sve_pth)

        sub = utils.Subscriber(topic="stim", port=port)

        if anne:
            sub2 = utils.Subscriber(topic="stim",
                                    port=5006,
                                    ip=r"tcp://10.122.170.169:")
            sub3 = utils.Subscriber(topic="stim", port=5010)
            monitor2 = utils.MonitorDataPass(sub2)
            monitor3 = utils.MonitorDataPass(sub3)

        monitor = utils.MonitorDataPass(sub)

        stimulation.run()
Exemplo n.º 4
0
    def spawn_pandas(port=5005, freq_max=101):
        tex_size = (1024, 1024)
        freqs = np.arange(freq_max)

        input_textures = {
            'freq': {},
            'blank': textures.BlankTexXY(texture_size=tex_size)
        }
        for f in freqs:
            input_textures['freq'][f] = textures.GratingGrayTexXY(
                texture_size=tex_size, spatial_frequency=f)

        stimulation = stimuli.ClosedLoopStimChoice(textures=input_textures,
                                                   gui=True)

        sub = utils.Subscriber(topic="stim", port=port)
        monitor = utils.MonitorDataPass(sub)
        stimulation.run()
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
    save_dir = r'C:/Users/Eric/Desktop/tmp_stuff/pstim_data/'
    file_path = save_dir + filename
    toggle_show = stimuli.KeyboardToggleTex(tex_classes,
                                            stim_params,
                                            profile_on=False,
                                            fps=frame_rate,
                                            save_path=file_path)
    toggle_show.run()
    # close open file
    if toggle_show.filestream:
        toggle_show.filestream.close()


elif example_ind == 5:
    print("For this to work make sure you are running pub_class_toggle.py at same time.")
    sub = utils.Subscriber(topic="stim", port="1234")
    monitor = utils.Monitor(sub)

    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]
    current_dt = datetime.now()
    filename = current_dt.strftime(("toggle_%Y%m%d_%H%M%S.txt"))
    save_dir = r'C:/Users/Eric/Desktop/tmp_stuff/pstim_data/'
    file_path = save_dir + filename
Exemplo n.º 7
0
def stims(port="5005"):
    stimulation = stimuli.ClosedLoopStimChoice(textures=input_textures, save_path=svepath)

    sub = utils.Subscriber(topic="stim", port=port)
    monitor = utils.MonitorDataPass(sub)
    stimulation.run()
Exemplo n.º 8
0
import numpy as np

from pandastim import textures, stimuli, utils

svepath = r'C:\Soft_Kitty\Anaconda3\envs\clean_pstim\Lib\site-packages\pandastim\experiments\temp1.txt'

tex_size = (1024, 1024)
freqs = np.arange(101)

input_textures = {
    'freq': {},
    'blank': textures.BlankTexXY(texture_size=tex_size)
}
for f in freqs:
    input_textures['freq'][f] = textures.GratingGrayTexXY(
        texture_size=tex_size, spatial_frequency=f)

stimulation = stimuli.ClosedLoopStimChoice(textures=input_textures,
                                           save_path=svepath)

if __name__ == '__main__':

    sub = utils.Subscriber(topic="stim", port="5005")
    monitor = utils.MonitorDataPass(sub)
    stimulation.run()