コード例 #1
0
ファイル: cmd_api.py プロジェクト: ratcave/vrlatency
def total(port, baudrate, trials, stimdistance, stimsize, screen, interval, jitter, rigid_body, allmodes):

    led = get_rigid_body(rigid_body)

    stim = vrl.Stimulus(size=stimsize)
    arduino = vrl.Arduino.from_experiment_type(experiment_type='Total', port=port, baudrate=baudrate)
    on_width = [interval, interval * 2] if jitter else interval
    exp = vrl.TotalExperiment(arduino=arduino, trials=trials, fullscreen=True, on_width=on_width, screen_ind=screen, stim=stim, rigid_body=led, stim_distance=stimdistance)
    exp.run()
    exp.save()
コード例 #2
0
def main():
    # connect to the device
    # arduino = vrl.Arduino(experiment_type='Display', port='COM9', baudrate=250000)

    # create a stimulation pattern
    mystim = vrl.Stimulus(position=(0, 0))

    # create an experiment app
    myexp = CustomExperiment(  # arduino=arduino,
        stim=mystim, bckgrnd_color=(.3, .3, .3))
    myexp.run()
コード例 #3
0
ファイル: custom_1.py プロジェクト: ratcave/vrlatency
def main():
    # connect to the device
    arduino = vrl.Arduino(experiment_type='Display',
                          port='COM9',
                          baudrate=250000)

    # create a stimulation pattern
    mystim = vrl.Stimulus(position=(0, 0))

    # create an experiment app
    myexp = CustomExperiment(arduino=arduino,
                             fullscreen=True,
                             screen_ind=1,
                             stim=mystim,
                             bckgrnd_color=(.2, .5, .2))
    myexp.run()
コード例 #4
0
ファイル: test_experiment.py プロジェクト: ratcave/vrlatency
def test_total_tracking():
    myarduino = vrl.Arduino.from_experiment_type(port='COM9', baudrate=250000, experiment_type='Total')
    mystim = vrl.Stimulus(position=(0, 0), color=(1, 1, 1))
    mystim.mesh.point_size = 5
    mystim.mesh.scale.xyz = .03, .2, 1
    client = natnet.NatClient()
    led = client.rigid_bodies['LED']
    trials = random.randint(5, 16)
    myexp = vrl.TotalExperiment(arduino=myarduino,
                                stim=mystim,
                                on_width=[.01, .3],
                                rigid_body=led,
                                trials=trials,
                                screen_ind=1,
                                fullscreen=True)
    myexp.run()
    assert trials == myexp.data.values[-2]
    assert len(myexp.data.values) == 5 * 500 * trials  # each trial, 500 packets, each packet 5 elements
コード例 #5
0
ファイル: cmd_api.py プロジェクト: ratcave/vrlatency
def display(port, baudrate, trials, stimsize, delay, screen, interval, jitter, allmodes, output, nsamples):

    arduino = vrl.Arduino.from_experiment_type(experiment_type='Display', port=port, baudrate=baudrate, nsamples=nsamples)

    stim = vrl.Stimulus(size=stimsize)
    on_width = [interval, interval * 2] if jitter else interval

    monitor = vrl.screens[screen]
    original_mode = monitor.get_mode()
    modes = monitor.get_modes() if allmodes else [original_mode]

    for mode in modes:
        if not arduino.is_connected:
            arduino.connect()

        if allmodes:
            monitor.set_mode(mode)
            time.sleep(10)

        exp = vrl.DisplayExperiment(arduino=arduino,
                                    trials=trials, fullscreen=True, on_width=on_width,
                                    trial_delay=delay, screen_ind=screen, stim=stim)
        exp.run()
        exp.save(filename=path.join(output, exp.filename))

        df = vrl.read_csv(path.join(output, exp.filename))
        df['TrialTime'] = df.groupby('Trial').Time.apply(lambda x: x - x.min())

        click.echo(df.head())
        latencies = vrl.get_display_latencies(df)

        fig, (ax1, ax2, ax3) = plt.subplots(ncols=3)
        sns.distplot(df['SensorBrightness'], bins=50, ax=ax1)
        ax2.scatter(df['TrialTime'] / 1000, df['SensorBrightness'], alpha=.1, s=.2)
        ax2.hlines([perc_range(df.SensorBrightness, .75)], *ax2.get_xlim())

        sns.distplot(latencies.iloc[1:] / 1000., bins=80, ax=ax3)
        ax3.set_xlim(0, 50)
        plt.show()
コード例 #6
0
ファイル: display_latency.py プロジェクト: ratcave/vrlatency
import vrlatency as vrl
from vrlatency.analysis import read_csv, get_display_latencies
import matplotlib.pyplot as plt
import seaborn as sns

path = "C:/Users/sirotalab/Desktop/Measurement/display_exp_test.csv"

# specify and connect to device
myarduino = vrl.Arduino.from_experiment_type(experiment_type='Display',
                                             port='COM9',
                                             baudrate=250000)

# create a stimulus
mystim = vrl.Stimulus(position=(0, 0), size=200)

# create an experiment
myexp = vrl.DisplayExperiment(arduino=myarduino,
                              trials=100,
                              fullscreen=True,
                              screen_ind=1,
                              stim=mystim,
                              on_width=[.05, .08])

myexp.run()
myexp.save(path)

df = read_csv(path)
print(df.head())

latencies = get_display_latencies(df)
コード例 #7
0
import vrlatency as vrl
import itertools
import pyglet
from time import sleep

# initialize a window
platform = pyglet.window.get_platform()
display = platform.get_default_display()
screen = display.get_screens()[1]
mywin = pyglet.window.Window(fullscreen=True, screen=screen)

# initialize a stimulus object
mypoint = vrl.Stimulus(position=(mywin.width//2, mywin.height//2), size=100)

pos_x = itertools.cycle([mywin.width//2 - 200, mywin.width//2 + 200])
colors = itertools.cycle([(255, 0, 0), (0, 255, 0)])

while not mywin.has_exit:
    mywin.dispatch_events()

    mypoint.position = next(pos_x), mywin.height//2
    mypoint.color = next(colors)
    mywin.clear()
    mypoint.draw()
    mywin.flip()
    sleep(.1)