def print_dt(state, *args): 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)
@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) PrintTraceback(name="bottom of body")
from smile.audio import Beep, SoundFile, init_audio_server import os 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)
from instructmovingdots import * from gen_movingdots import * """Chuiwen's experimental version""" exp = Experiment(background_color=[0.5, 0.5, 0.5, 0.5], name="RDMCW") #"gray") InputSubject(name="Random Dot Motion") Wait(.1) Instruct(config=config, lang="E") Wait(.1) with Loop(blocks) as block: with Loop(block.current) as ds: #dots set fixation_point = Label(text="+", duration=0.75, font_size=80, bold=False, color=[0, 0, 0, 1]) with Parallel(): md_white = MovingDots(radius=s(300), scale=s(2.5), color="white", num_dots=250, motion_props=ds.current['motion_props']) md_black = MovingDots(radius=s(300), scale=s(2.5), color="black",
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)
push_vals=[1.0], width=0.10, ) NIPulse( 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.)
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) Wait(1.0)
}, { "coherence": 0.25, "direction": 180, "direction_variance": 0 }, { "coherence": 0.25, "direction": 270, "direction_variance": 0 }]) with UntilDone(): KeyPress() with Meanwhile(): g.slide(color='red', duration=4.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,