コード例 #1
0
ファイル: _test_suite.py プロジェクト: mutlusun/expyriment
def _audio_playback(exp):
    """Test the audio playback"""

    info = """This will test the audio playback. A test tone will be played.

[Press RETURN to continue]
"""
    text = stimuli.TextScreen("Audio playback test", info)
    text.present()
    exp.keyboard.wait([constants.K_RETURN])
    exp.screen.clear()
    exp.screen.update()
    a = stimuli.Tone(duration=1000)
    a.present()
    exp.clock.wait(1000)
    text = stimuli.TextScreen("Did you hear the tone?", "[Press Y or N]")
    text.present()
    key, _rt = exp.keyboard.wait([constants.K_y,
                                 constants.K_n])
    if key == constants.K_y:
        response = "Yes"
    elif key == constants.K_n:
        response = "No"

    return response
コード例 #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A very short example experiment in 16 lines of pure code.
Participants have to indicate the parity of digits by pressing 
the left arrow key for odd and the right arrow key for even numbers.
"""

from expyriment import control, stimuli, design, misc

digit_list = [1, 2, 3, 4, 6, 7, 8, 9] * 12
design.randomize.shuffle_list(digit_list)

exp = control.initialize()
exp.data_variable_names = ["digit", "btn", "rt", "error"]

control.start(exp)

for digit in digit_list:
    target = stimuli.TextLine(text=str(digit), text_size=80)
    exp.clock.wait(500 - stimuli.FixCross().present() - target.preload())
    target.present()
    button, rt = exp.keyboard.wait(
        [misc.constants.K_LEFT, misc.constants.K_RIGHT])
    error = (button == misc.constants.K_LEFT) == digit % 2
    if error: stimuli.Tone(duration=200, frequency=2000).play()
    exp.data.add([digit, button, rt, int(error)])
    exp.clock.wait(1000 - stimuli.BlankScreen().present() - target.unload())

control.end(goodbye_text="Thank you very much...", goodbye_delay=2000)
コード例 #3
0
PERIOD = 500
TONE_DURATION = 100
SQUARE_DURATION = 100  # should be 6 frames with a video refresh rate at 60Hz

exp = design.Experiment(name="Cross-modal-timing-test")
#control.set_develop_mode(True)  # commented because we need fullscreen

control.defaults.open_gl = 2
control.defaults.audiosystem_buffer_size = 256
control.initialize(exp)

##

bs = stimuli.BlankScreen()
square_top = stimuli.Rectangle((400, 400), position=(0, 300))
tone = stimuli.Tone(TONE_DURATION, 440)

bs.preload()
square_top.preload()
tone.preload()

##
control.start(skip_ready_screen=True)
clock = misc.Clock()

exp.screen.clear()
bs.present(update=True)
nframe = 0
t1 = clock.time
while clock.time - t1 <= 1000:
    bs.present(update=True)
FILLING TASK:
TWO dots, press LEFT
THREE dots, press RIGHT"""

exp = design.Experiment(name="Stoet's Multi-tasking experiment",
                        background_colour=WHITE,
                        foreground_colour=BLACK)
control.initialize(exp)
blankscreen = stimuli.BlankScreen(colour=WHITE)

#I added this because otherwise the transisition between trials was not obvious
fixcross = stimuli.FixCross()
fixcross.preload()
#I added this to make the error message stronger
error_beep = stimuli.Tone(duration=200, frequency=2000)
error_beep.preload()

rectangle = [["rectangle", "two_dots", "S_R_2.png"],
             ["rectangle", "three_dots", "S_R_3.png"]]
diamond = [["diamond", "two_dots", "S_D_2.png"],
           ["diamond", "three_dots", "S_D_3.png"]]
two_dots = [["rectangle", "two_dots", "F_R_2.png"],
            ["diamond", "two_dots", "F_D_2.png"]]
three_dots = [["rectangle", "three_dots", "F_D_3.png"],
              ["diamond", "three_dots", "F_D_3.png"]]

shapes_task = [rectangle, diamond]
fillings_task = [two_dots, three_dots]
mixed_task = [rectangle, diamond, two_dots, three_dots]