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)
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)
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 plt.ion() ea.plot_screen(screenshot)
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)