Exemplo n.º 1
0
def test_plot_screen():
    """Test screen plotting function
    """
    tmp = np.ones((10, 20, 2))
    assert_raises(ValueError, ea.plot_screen, tmp)
    tmp = np.ones((10, 20, 3))
    ea.plot_screen(tmp)
Exemplo n.º 2
0
def test_plot_screen():
    """Test screen plotting function
    """
    tmp = np.ones((10, 20, 2))
    assert_raises(ValueError, ea.plot_screen, tmp)
    tmp = np.ones((10, 20, 3))
    ea.plot_screen(tmp)
Exemplo n.º 3
0
white = (255, 255, 255, 255)
# Text
one = ('This text can only have a single color, font, and size for the whole '
       'sentence, because it is specified as attr=False')
two = ('Additional calls to ec.screen_text() can have different formatting,'
       'but have to be manually positioned.')
thr = ('This text can have {{color {0}}}different {{color {1}}}colors '
       'speci{{color {2}}}fied inline, because it\'s {{color {0}}}attr '
       '{{color {2}}}argument is {{color {1}}}True. {{color {2}}}'
       'Specifying different typefaces or sizes inline is buggy and '
       'not recommended.').format(blue, pink, white)
fou = 'Press any key to change all the text to pink using .set_color().'
fiv = 'Press any key to quit.'

with ExperimentController('textDemo', participant='foo', session='001',
                          output_dir=None) as ec:
    ec.wait_secs(0.1)  # without this, first flip doesn't show on some systems
    txt_one = ec.screen_text(one, pos=[0, 0.5], attr=False)
    txt_two = ec.screen_text(two, pos=[0, 0.2], font_name='Times New Roman',
                             font_size=32, color='#00CEE9')
    txt_thr = ec.screen_text(thr, pos=[0, -0.2])
    screenshot = ec.screenshot()
    ec.screen_prompt(fou, pos=[0, -0.5])
    for txt in (txt_one, txt_two, txt_thr):
        txt.set_color('#FF97AF')
        txt.draw()
    ec.screen_prompt(fiv, pos=[0, -0.5], color='#FF97AF')

plt.ion()
analyze.plot_screen(screenshot)
Exemplo n.º 4
0
    ###########################################
    # listen_presses / while loop / get_presses(kind='both')
    instruction = ("Press and release some keys\n\nlisten_presses()"
                   "\nwhile loop {}\n"
                   "get_presses(kind='both', return_kinds=True)")
    disp_time = wait_dur
    countdown = ec.current_time + disp_time
    ec.call_on_next_flip(ec.listen_presses)
    ec.screen_text(instruction.format(disp_time))
    screenshot = ec.screenshot()
    ec.flip()
    while ec.current_time < countdown:
        cur_time = round(countdown - ec.current_time, 1)
        if cur_time != disp_time:
            disp_time = cur_time
            # redraw text with updated disp_time
            ec.screen_text(instruction.format(disp_time))
            ec.flip()
    events = ec.get_presses(kind='both', return_kinds=True)
    ec.write_data_line('listen / while / get_presses', events)
    if not len(events):
        message = 'no keys pressed'
    else:
        message = ['{} {} after {} secs\n'
                   ''.format(k, r, round(t, 4)) for k, t, r in events]
        message = ''.join(message)
    ec.screen_prompt(message, msg_dur)
    ec.wait_secs(isi)

ea.plot_screen(screenshot)
Exemplo n.º 5
0
                             line_color='white',
                             line_width=3.0)
    targ_circ = visual.Circle(ec,
                              targ_rad, (x_pos[0], y_pos[0]),
                              units='deg',
                              fill_color='red')
    fix_pos = (x_pos[0], y_pos[0])

    # start out by waiting for a 1 sec fixation at the start
    big_circ.draw()
    targ_circ.draw()
    screenshot = ec.screenshot()
    ec.identify_trial(ec_id='Circle', ttl_id=[0], el_id=[0])
    ec.start_stimulus()  # automatically stamps to EL
    if not el.wait_for_fix(fix_pos, 1., max_wait=5., units='deg'):
        print('Initial fixation failed')
    for ii, (x, y) in enumerate(zip(x_pos[1:], y_pos[1:])):
        targ_circ.set_pos((x, y), units='deg')
        big_circ.draw()
        targ_circ.draw()
        ec.flip()
        if not el.wait_for_fix([x, y], max_wait=5., units='deg'):
            print('Fixation {0} failed'.format(ii + 1))
    ec.trial_ok()
    el.stop()  # stop recording to save the file
    ec.screen_prompt('All done!', max_wait=1.0)
    # eyelink auto-closes (el.close()) because it gets registered with EC

plt.ion()
ea.plot_screen(screenshot)
Exemplo n.º 6
0
thr = ('This text can have {{color {0}}}different {{color {1}}}colors '
       'speci{{color {2}}}fied inline, because its {{color {0}}}attr '
       '{{color {2}}}argument is {{color {1}}}True. {{color {2}}}'
       'Specifying different typefaces or sizes inline is buggy and '
       'not recommended.').format(blue, pink, white)
fou = 'Press any key to change all the text to pink using .set_color().'
fiv = 'Press any key to quit.'
max_wait = float('inf') if not building_doc else 0.

with ExperimentController('textDemo',
                          participant='foo',
                          session='001',
                          output_dir=None,
                          version='dev') as ec:
    ec.wait_secs(0.1)  # without this, first flip doesn't show on some systems
    txt_one = ec.screen_text(one, pos=[0, 0.5], attr=False)
    txt_two = ec.screen_text(two,
                             pos=[0, 0.2],
                             font_name='Times New Roman',
                             font_size=32,
                             color='#00CEE9')
    txt_thr = ec.screen_text(thr, pos=[0, -0.2])
    screenshot = ec.screenshot()
    ec.screen_prompt(fou, pos=[0, -0.5], max_wait=max_wait)
    for txt in (txt_one, txt_two, txt_thr):
        txt.set_color('#FF97AF')
        txt.draw()
    ec.screen_prompt(fiv, pos=[0, -0.5], max_wait=max_wait)

analyze.plot_screen(screenshot)