コード例 #1
0
def DoTheOtherThing(self):
    Debug(name="before the yield")
    with Serial():
        yield
    with Meanwhile():
        PrintTraceback(name="during the yield")
    Debug(name="after the yield")
コード例 #2
0
    print(args)


exp = Experiment(show_splash=True)

with Parallel():
    MouseRecord()
    MouseCursor()
with UntilDone():
    Wait(2.0)
    MouseCursor("smile/face-smile.png", (125, 125), duration=5.0)

    with Parallel():
        lbl1 = Label(text="Click me", blocking=False)
        with Loop(10):
            Debug(mw=MouseWithin(lbl1))
            Wait(1.0)

    Debug(name='Mouse Press Test')

    exp.last_pressed = ''

    with Loop(conditional=(exp.last_pressed != 'RIGHT')):
        kp = MousePress(buttons=['LEFT', 'RIGHT'], correct_resp='RIGHT')
        Debug(pressed=kp.pressed, rt=kp.rt, correct=kp.correct)
        exp.last_pressed = kp.pressed
        Log(pressed=kp.pressed, rt=kp.rt)

    kp = MousePress(buttons=['LEFT', 'RIGHT'], correct_resp='RIGHT')
    Debug(pressed=kp.pressed, rt=kp.rt, correct=kp.correct)
    Wait(1.0)
コード例 #3
0
ファイル: test_audio.py プロジェクト: npl2dq/smile
init_audio_server(sr=44100,
                  nchnls=1,
                  buffersize=256,
                  duplex=1,
                  audio='portaudio',
                  jackname='pyo',
                  input_device=None,
                  output_device=None)

exp = Experiment(debug=True)

Wait(1.0)
with Loop([440, 500, 600, 880]) as l:
    Beep(freq=l.current, volume=0.4, duration=1.0)
    Debug(freq=l.current)
Beep(freq=[440, 500, 600], volume=0.1, duration=1.0)
Debug(freq=[440, 500, 600])

Beep(freq=880, volume=0.1, duration=1.0)
Debug(freq=880)

with Parallel():
    Beep(freq=440, volume=0.1, duration=2.0)
    Debug(freq=440)

    with Serial():
        Wait(1.0)
        Beep(freq=880, volume=0.1, duration=2.0)
        Debug(freq=880)
コード例 #4
0
from smile.experiment import Experiment
from smile.state import Wait, Debug
from smile.video import Label
from smile.freekey import FreeKey

exp = Experiment()

Wait(.5)

fk = FreeKey(Label(text='XXXXXX', font_size=40), max_resp=1)
Debug(responses=fk.responses)

Label(text='Done', font_size=32, duration=2.0)

fk2 = FreeKey(Label(text='??????', font_size=30))
Debug(responses=fk2.responses)

Wait(1.0)

exp.run()
コード例 #5
0
def DoTheThing(self, a, b, c=7, d="ssdfsd"):
    PrintTraceback(name="inside DoTheThing")
    self.foo = c * 2
    Wait(1.0)
    Debug(a=a, b=b, c=c, d=d, foo=self.foo,
          screen_size=self.exp.screen.size, name="inside DoTheThing")
コード例 #6
0
          screen_size=self.exp.screen.size, name="inside DoTheThing")


@Subroutine
def DoTheOtherThing(self):
    Debug(name="before the yield")
    with Serial():
        yield
    with Meanwhile():
        PrintTraceback(name="during the yield")
    Debug(name="after the yield")


exp = Experiment(debug=True)

Debug(width=exp.screen.width, height=exp.screen.height)

with Loop(5) as loop:
    Log(a=1, b=2, c=loop.i, name="aaa")
Log({"q": loop.i, "w": loop.i}, x=4, y=2, z=1, name="bbb")
Log([{"q": loop.i, "w": n} for n in range(5)], x=4, y=2, z=1, name="ccc")

exp.for_the_thing = 3
dtt = DoTheThing(3, 4, name="first")
Debug(foo=dtt.foo, name="outside DoTheThing")
dtt = DoTheThing(3, 4, d="bbbbbbb", c=exp.for_the_thing)
Debug(foo=dtt.foo, name="outside DoTheThing")

with DoTheOtherThing():
    PrintTraceback(name="top of body")
    Wait(2.0)
コード例 #7
0
from smile.experiment import Experiment
from smile.state import Debug, Wait, Log, Loop
from smile.pulse import Pulse

# set up default experiment
exp = Experiment()

with Loop(15):
    pulse = Pulse(code='S1')
    Wait(duration=1.0, jitter=1.0)
    Log(name='pulse',
        pulse_on=pulse.pulse_on,
        pulse_code=pulse.code,
        pulse_off=pulse.pulse_off)

# print something
Debug(width=exp.screen.width, height=exp.screen.height)

# run the exp
exp.run(trace=False)
コード例 #8
0
    task2,
    push_vals=[.5],
    width=0.10,
)

# Wait for the experiment to start!
Wait(2.)

with Parallel():

    Label(text="We will now push 10 markers.", blocking=False)
    with Loop(10, blocking=False):

        ni1 = NIPulse(
            task1,
            push_vals=[1.0],
            width=0.10,
        )
        Wait(1.0)
        ni2 = NIPulse(
            task2,
            push_vals=[.5],
            width=0.10,
        )

        Wait(until=ni2.pulse_off)
        Wait(1.)
        Debug(a=ni1.pulse_on, b=ni2.pulse_off)

exp.run()
コード例 #9
0
from smile.experiment import Experiment
from smile.state import Wait, Debug, Loop, UntilDone, Log, Meanwhile
from smile.keyboard import Key, KeyRecord, KeyPress


exp = Experiment()

with Meanwhile():
    KeyRecord(name="record_all_key_presses")

Debug(name='Press T+G+D or SHIFT+Q+R')
Wait(until=((Key("T") & Key("G") & Key("D")) |
            (Key("SHIFT") & Key("Q") & Key("R"))))
Debug(name='Key Press Test')

exp.last_pressed = ''

with Loop(conditional=(exp.last_pressed != 'K')):
    kp = KeyPress(keys=['J', 'K'], correct_resp='K')
    Debug(pressed=kp.pressed, rt=kp.rt, correct=kp.correct)
    exp.last_pressed = kp.pressed
    Log(pressed=kp.pressed, rt=kp.rt)

KeyRecord()
with UntilDone():
    kp = KeyPress(keys=['J', 'K'], correct_resp='K')
    Debug(pressed=kp.pressed, rt=kp.rt, correct=kp.correct)
    Wait(1.0)

    kp = KeyPress()
    Debug(pressed=kp.pressed, rt=kp.rt, correct=kp.correct)
コード例 #10
0
Wait(.25)

with Loop(4):
    MovingDots()
    with UntilDone():
        KeyPress()

md = MovingDots(radius=300,
                scale=3,
                num_dots=200,
                motion_props=[
                    {
                        "coherence": 0.25,
                        "direction": 0,
                        "direction_variance": 0
                    },
                    {
                        "coherence": 0.25,
                        "direction": 180,
                        "direction_variance": 0
                    },
                ])
with UntilDone():
    with Loop(testing_set) as ts:
        Wait(3.)
        md.motion_props = ts.current
    Wait(5.)

Debug(rate=g.widget.refresh_rate)
exp.run(trace=False)