Пример #1
0
def test_eyelink_methods():
    """Test EL methods."""
    with ExperimentController(*std_args, **std_kwargs) as ec:
        assert_raises(ValueError, EyelinkController, ec, fs=999)
        el = EyelinkController(ec)
        assert_raises(RuntimeError, EyelinkController, ec)  # can't have 2 open
        assert_raises(ValueError, el.custom_calibration, ctype='hey')
        el.custom_calibration('H3')
        el.custom_calibration('HV9')
        el.custom_calibration('HV13')
        assert_raises(ValueError, el.custom_calibration, ctype='custom',
                      coordinates='foo')
        assert_raises(ValueError, el.custom_calibration, ctype='custom',
                      coordinates=[[0, 1], 0])
        assert_raises(ValueError, el.custom_calibration, ctype='custom',
                      coordinates=[[0, 1], [0]])
        el._open_file()
        assert_raises(RuntimeError, el._open_file)
        el._start_recording()
        el.get_eye_position()
        assert_raises(ValueError, el.wait_for_fix, [1])
        x = el.wait_for_fix([-10000, -10000], max_wait=0.1)
        assert_true(x is False)
        assert el.eye_used
        print(el.file_list)
        assert_true(len(el.file_list) > 0)
        print(el.fs)
        x = el.maintain_fix([-10000, -10000], 0.1, period=0.01)
        assert_true(x is False)
        # run much of the calibration code, but don't *actually* do it
        el._fake_calibration = True
        el.calibrate(beep=False, prompt=False)
        el._fake_calibration = False
        # missing el_id
        assert_raises(KeyError, ec.identify_trial, ec_id='foo', ttl_id=[0])
        ec.identify_trial(ec_id='foo', ttl_id=[0], el_id=[1])
        ec.start_stimulus()
        ec.stop()
        ec.trial_ok()
        ec.identify_trial(ec_id='foo', ttl_id=[0], el_id=[1, 1])
        ec.start_stimulus()
        ec.stop()
        ec.trial_ok()
        assert_raises(ValueError, ec.identify_trial, ec_id='foo', ttl_id=[0],
                      el_id=[1, dict()])
        assert_raises(ValueError, ec.identify_trial, ec_id='foo', ttl_id=[0],
                      el_id=[0] * 13)
        assert_raises(TypeError, ec.identify_trial, ec_id='foo', ttl_id=[0],
                      el_id=dict())
        assert_raises(TypeError, el._message, 1)
        el.stop()
        el.transfer_remote_file(el.file_list[0])
        assert_true(not el._closed)
    # ec.close() auto-calls el.close()
    assert_true(el._closed)
Пример #2
0
def test_eyelink_methods():
    """Test EL methods
    """
    with ExperimentController(*std_args, **std_kwargs) as ec:
        assert_raises(ValueError, EyelinkController, ec, fs=999)
        el = EyelinkController(ec)
        assert_raises(RuntimeError, EyelinkController, ec)  # can't have 2 open
        assert_raises(ValueError, el.custom_calibration, ctype='hey')
        el.custom_calibration()
        el._open_file()
        assert_raises(RuntimeError, el._open_file)
        el._start_recording()
        el.get_eye_position()
        assert_raises(ValueError, el.wait_for_fix, [1])
        x = el.wait_for_fix([-10000, -10000], max_wait=0.1)
        assert_true(x is False)
        assert el.eye_used
        print(el.file_list)
        assert_true(len(el.file_list) > 0)
        print(el.fs)
        # run much of the calibration code, but don't *actually* do it
        el._fake_calibration = True
        el.calibrate(beep=False, prompt=False)
        el._fake_calibration = False
        # missing el_id
        assert_raises(KeyError, ec.identify_trial, ec_id='foo', ttl_id=[0])
        ec.identify_trial(ec_id='foo', ttl_id=[0], el_id=[1])
        ec.start_stimulus()
        ec.stop()
        ec.trial_ok()
        ec.identify_trial(ec_id='foo', ttl_id=[0], el_id=[1, 1])
        ec.start_stimulus()
        ec.stop()
        ec.trial_ok()
        assert_raises(ValueError,
                      ec.identify_trial,
                      ec_id='foo',
                      ttl_id=[0],
                      el_id=[1, dict()])
        assert_raises(ValueError,
                      ec.identify_trial,
                      ec_id='foo',
                      ttl_id=[0],
                      el_id=[0] * 13)
        assert_raises(TypeError,
                      ec.identify_trial,
                      ec_id='foo',
                      ttl_id=[0],
                      el_id=dict())
        assert_raises(TypeError, el._message, 1)
        el.stop()
        el.transfer_remote_file(el.file_list[0])
        assert_true(not el._closed)
    # ec.close() auto-calls el.close()
    assert_true(el._closed)
Пример #3
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)
                          'possible whenever the target speaker (only) says '
                          'the letter "O".' + dir_instr + '\n\n%s') %
                         (bi + 1, n_blocks, tstr, dstr, continue_msg),
                         color=fcolor)
        # start of each block
        ec.start_noise()
        ec.write_data_line('block', block_type)
        ec.system_beep()
        el.calibrate()
        ec.flip()
        fix.draw()
        ec.flip()
        ec.wait_for_presses(5.0)  # wait to settle

        # run each trial
        for ti in trials:
            run_trial(ti)

        # end of each block
        el.stop()
        ec.stop_noise()
        bi += 1
        if bi < len(p['block_trials']):
            ec.screen_prompt('You are done with block %s/%s.\n\nFeel free to '
                             'take a break, then press the button when you '
                             'are ready to continue.' % (bi, n_blocks),
                             color=fcolor)
    ec.screen_prompt('You are done, thanks for your participation!',
                     max_wait=5.,
                     color=fcolor)
Пример #5
0
    theta = np.linspace(np.pi / 2., 2.5 * np.pi, 200)
    x_pos, y_pos = radius * np.cos(theta), radius * np.sin(theta)
    big_circ = visual.Circle(ec, radius, (0, 0), units='deg',
                             fill_color=None, 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

ea.plot_screen(screenshot)
Пример #6
0
                pck.dump(block_ind, blockfile) # overwrites
                #elapsed_time = timeit.default_timer() - start_time
                #print 'save blockmat for each trial' + str(elapsed_time) + '\n'
                if (snum == 2):
                    cogLoadSurvey(gen_survey, mid_survey, rel_survey,
                            paradigm, edf_outputdir, tnum, ec)
                if (snum != 1):
                    # End trial text feedback
                    trial_end_key = 's' + str(snum) + '_' + 'end_trial'
                    ec.screen_prompt( instr[(trial_end_key)],
                            max_wait=wait_keys[trial_end_key])
            # train for the first section 
            if not skipTrain:
                if (snum == 0):
                    train(order, wheel_matrix_info, preblock, block_ind,
                            instr, ec, stimdir, final_datadir )

            # End block
            block_end_key = 's' + str(snum) + '_' + 'end_block'
            if (snum == 1):
                el.stop() # close edf file for each block in mid section
            if (snum != 2):
                ec.screen_prompt( instr[(block_end_key)],
                        max_wait=wait_keys[block_end_key])

        # End section
        section_end_key = 's' + str(snum) + '_' + 'end_sect'
        ec.screen_prompt( instr[(section_end_key)],
                max_wait=wait_keys[section_end_key])
    ec.stop_noise()