print(__doc__) with ExperimentController('LevelTest', full_screen=True, noise_db=-np.inf, participant='s', session='0', output_dir=None, suppress_resamp=True, check_rms=None, stim_db=80, version='dev') as ec: tone = (0.01 * np.sqrt(2.) * np.sin(2 * np.pi * 1000. * np.arange(0, 10, 1. / ec.fs))) assert np.allclose(np.sqrt(np.mean(tone * tone)), 0.01) square = Rectangle(ec, (0, 0, 10, 10), units='deg', fill_color='r') cm = np.diff(ec._convert_units([[0, 5], [0, 5]], 'deg', 'pix'), axis=-1)[0] / ec.dpi / 0.39370 ec.load_buffer(tone) # RMS == 0.01 pressed = None screenshot = None while pressed != '8': # enable a clean quit if required square.draw() ec.screen_text('Width: {} cm'.format(np.round(2 * cm, 1)), wrap=False) ec.screen_text('Output level: {} dB'.format(ec.stim_db), wrap=True) screenshot = ec.screenshot() if screenshot is None else screenshot t1 = ec.start_stimulus(start_of_trial=False) # skip checks pressed = ec.wait_one_press(10)[0] ec.flip() ec.wait_one_press(0.5) ec.stop()
from expyfun import ExperimentController, building_doc from expyfun.visual import Rectangle import expyfun.analyze as ea print(__doc__) with ExperimentController('LevelTest', full_screen=True, noise_db=-np.inf, participant='s', session='0', output_dir=None, suppress_resamp=True, check_rms=None, stim_db=80, version='dev') as ec: tone = (0.01 * np.sqrt(2.) * np.sin(2 * np.pi * 1000. * np.arange(0, 10, 1. / ec.fs))) assert np.allclose(np.sqrt(np.mean(tone * tone)), 0.01) square = Rectangle(ec, (0, 0, 10, 10), units='deg', fill_color='r') cm = np.diff(ec._convert_units([[0, 5], [0, 5]], 'deg', 'pix'), axis=-1)[0] / ec.dpi / 0.39370 ec.load_buffer(tone) # RMS == 0.01 pressed = None screenshot = None while pressed != '8': # enable a clean quit if required square.draw() ec.screen_text('Width: {} cm'.format(np.round(2 * cm, 1)), wrap=False) ec.screen_text('Output level: {} dB'.format(ec.stim_db), wrap=True) screenshot = ec.screenshot() if screenshot is None else screenshot t1 = ec.start_stimulus(start_of_trial=False) # skip checks pressed = ec.wait_one_press(10)[0] if not building_doc else '8' ec.flip() ec.wait_one_press(0.5 if not building_doc else 0.) ec.stop()
########################### # get_mouse_position ec.screen_prompt('Move the mouse around...', max_wait=msg_dur, wrap=False) stop_time = ec.current_time + wait_dur while ec.current_time < stop_time: ec.screen_text('%i, %i' % tuple([p for p in ec.get_mouse_position()]), wrap=False) ec.check_force_quit() ec.flip() ########################### # wait_for_click_on ec.toggle_cursor(False) ec.wait_secs(1) c = Circle(ec, 150, units='pix') r = Rectangle(ec, (0.5, 0.5, 0.2, 0.2), units='norm', fill_color='r') cc = ConcentricCircles(ec, pos=[0.6, -0.4], colors=[[0.2, 0.2, 0.2], [0.6, 0.6, 0.6]]) d = Diamond(ec, (-0.5, 0.5, 0.4, 0.25), fill_color='b') dot = FixationDot(ec) objects = [c, r, cc, d, dot] ec.screen_prompt('Click on some objects...', max_wait=msg_dur, wrap=False) for ti in range(3): for o in objects: o.draw() screenshot = ec.screenshot() ec.flip() click, ind = ec.wait_for_click_on(objects, max_wait=max_wait) if ind is not None:
session='0', output_dir=None, suppress_resamp=True, check_rms=None, n_channels=n_channels, version='dev') as ec: click = np.r_[0.1, np.zeros(99)] # RMS = 0.01 data = np.zeros((n_channels, len(click))) data[click_idx] = click ec.load_buffer(data) pressed = None screenshot = None # Make a circle so that the photodiode can be centered on the screen circle = Circle(ec, 1, units='deg', fill_color='k', line_color='w') # Make a rectangle that is the standard credit card size rect = Rectangle(ec, [0, 0, 8.56, 5.398], 'cm', None, '#AA3377') while pressed != '8': # enable a clean quit if required ec.set_background_color('white') t1 = ec.start_stimulus(start_of_trial=False) # skip checks ec.set_background_color('black') t2 = ec.flip() diff = round(1000 * (t2 - t1), 2) ec.screen_text('IFI (ms): {}'.format(diff), wrap=True) circle.draw() rect.draw() screenshot = ec.screenshot() if screenshot is None else screenshot ec.flip() ec.stamp_triggers([2, 4, 8]) ec.refocus() pressed = ec.wait_one_press(0.5)[0] if not building_doc else '8' ec.stop()