Esempio n. 1
0
    def __init__(self, default_config={}):
        self._load_config(default_config)
        design.defaults.experiment_text_size = self.config.getint('GENERAL', 'experiment_text_size')
        design.Experiment.__init__(self, _('title'))
        control.set_develop_mode(self._dev_mode)

        if self.config.has_option('GENERAL', 'window_size') and not self._dev_mode:
            control.defaults.window_size = self.config.gettuple(
                'GENERAL', 'window_size', assert_length=2)
        if self.config.has_option('GENERAL', 'fullscreen') and not self._dev_mode:
            control.defaults.window_mode = self.config.getboolean('GENERAL', 'fullscreen')
        control.initialize(self)
        if self._dev_mode:
            self.mouse.show_cursor()

        self.expyriment_version = expyriment_version
        self.python_version = python_version

        self.trialdata = None
        self.trial_log = None
        self.block_log = None
        self.by_block_vars = []
        self.experiment_log = None
        self.dev_log = None

        self.screen.dpi = self._get_dpi()
Esempio n. 2
0
def run_exp():
    #control.run_test_suite()
    #control.set_develop_mode(True)

    # init
    control.defaults.initialize_delay = 0
    gabor = expyriment.stimuli.extras.GaborPatch(size=1000,
                                                 lambda_=50,
                                                 theta=90,
                                                 sigma=150,
                                                 phase=0.25,
                                                 position=(1000, 0))

    exp = design.Experiment(background_colour=gabor._background_colour)
    control.initialize(exp)

    # stimuli
    stimulus = expyriment.stimuli.Rectangle((1000, 1000))
    blank = expyriment.stimuli.BlankScreen()

    # stimuli preload
    stimulus.preload()
    blank.preload()
    gabor.preload()

    # main loop
    mean = 0
    for k in range(1, 1000):
        t = gabor.present()
        # exp.clock.wait(500)
        t += blank.present()
        mean += t
        print(t, mean / k)
        exp.clock.wait(500)
    control.end()
Esempio n. 3
0
def run_exp():
    #control.run_test_suite()
    #control.set_develop_mode(True)

    # init
    control.defaults.initialize_delay = 0
    exp = design.Experiment(background_colour=(0, 0, 0))
    control.initialize(exp)

    # stimuli
    stimulus = expyriment.stimuli.Rectangle((1000, 1000))
    blank = expyriment.stimuli.BlankScreen()

    # stimuli preload
    stimulus.preload()
    blank.preload()

    # main loop
    mean = 0
    for k in range(1, 1000):
        t = stimulus.present()
        t += blank.present()
        mean += t
        print(t, mean / k)
        exp.clock.wait(500)
    control.end()
Esempio n. 4
0
def run_exp():
    #control.run_test_suite()
    #control.set_develop_mode(True)

    # init
    control.defaults.initialize_delay = 0
    exp = design.Experiment(background_colour=(0, 0, 0))
    control.initialize(exp)

    # stimuli
    stimulus = expyriment.stimuli.Rectangle((1000, 1000))
    blank = expyriment.stimuli.BlankScreen()

    # stimuli preload
    stimulus.preload()
    blank.preload()

    # main loop
    mean = 0
    for k in range(1, 1000):
        t = stimulus.present()
        t += blank.present()
        mean += t
        print(t, mean / k)
        exp.clock.wait(500)
    control.end()
def startTrial(NUMBER, OPERATOR):

    #fixcross.preload()
    exp = design.Experiment("MATH")
    control.initialize(exp)
    control.start()
    fixcross = stimuli.FixCross()
    txt_input = io.TextInput("= ")

    stimuli.TextScreen("MATH GAME",
                       "STARTING in 10 secs",
                       heading_size=40,
                       text_size=60).present()
    exp.clock.wait(2000)  #stim -1
    fixcross.preload()
    fixcross.present()
    exp.clock.wait(10000)
    b = design.Block()

    for i in range(0, 10):  #FOR 10 TRIALS
        b.clear_trials()
        b = design.Block()
        print(i)
        tr = atl.arithmetictriall1(NUMBER, OPERATOR)
        print(tr)

        for trel in tr[0]:
            t = design.Trial()
            s = stimuli.TextLine(text=str(trel),
                                 text_size=120,
                                 text_colour=misc.constants.C_GREEN)
            t.add_stimulus(s)
            b.add_trial(t)
        #print(b.trials)
        exp.add_block(b)

        #START TEST: ONSCREEN
        for b in exp.blocks:
            fixcross.present()
            exp.clock.wait(100)

            for t in b.trials:
                t.stimuli[0].present()
                exp.clock.wait(1000)

        print(b)
        exp.clock.reset_stopwatch()
        answer = txt_input.get()

        try:
            answer = int(answer)
            if answer == tr[1]:
                print("Correct")
            else:
                print("incorrect")
        except:
            print("incorrect")
Esempio n. 6
0
def run_exp():
    #control.run_test_suite()
    #control.set_develop_mode(True)

    # init
    control.defaults.initialize_delay = 0
    gabor1 = GaborPatch(size=500,
                        lambda_=10,
                        theta=45,
                        sigma=50,
                        phase=0.25,
                        position=(500, 0),
                        contrast=0.1)
    cross = expyriment.stimuli.FixCross()

    exp = design.Experiment(background_colour=gabor1._background_colour)
    control.initialize(exp)

    # stimuli
    stimulus = expyriment.stimuli.Rectangle((1000, 1000))
    blank = expyriment.stimuli.BlankScreen(colour=gabor1._background_colour)

    # stimuli preload
    stimulus.preload()
    blank.preload()
    gabor1.preload()
    cross.preload()

    # main loop
    mean = 0
    k = 0
    #for k in range(1, 1000):
    blank.present()
    while True:
        k += 1
        cross.present()
        t = gabor1.present(clear=False, update=False)
        t += cross.present(clear=False, update=True)
        #exp.clock.wait(5000)
        t += cross.present()
        mean += t
        print(t, mean / k)
        exp.clock.wait(500)
        gabor1.unload()
        gabor1 = expyriment.stimuli.extras.GaborPatch(size=500,
                                                      lambda_=5,
                                                      theta=45,
                                                      sigma=5,
                                                      phase=0.25,
                                                      position=(-500, 0),
                                                      contrast=0.5)
        gabor1.preload()

    control.end()
Esempio n. 7
0
def initialize(remote_control=None, filename=None):
    """returns remote_control and file

     If remote_control or filename is None, the function will ask it (user input)

     """

    global trakstar, udp_connection, exp
    trakstar = TrakSTARInterface()
    thr_init_trackstar = Thread(target = trakstar.initialize)
    thr_init_trackstar.start()

    screen_size = get_monitor_resolution()

    # expyriment
    control.defaults.initialize_delay = 0
    control.defaults.pause_key = None
    control.defaults.window_mode = True
    control.defaults.window_size = [screen_size[0] - screen_size[0] / 10,
                                    screen_size[1] - screen_size[1] / 10]
    control.defaults.fast_quit = True
    control.defaults.open_gl = False
    control.defaults.event_logging = 0
    exp = design.Experiment()
    exp.set_log_level(0)
    control.initialize(exp)
    exp.mouse.show_cursor()

    if remote_control is None:
        logo_text_line(text="Use remote control? (y/N)").present()
        key = exp.keyboard.wait([ord("z"), ord("y"), ord("n"),
                        misc.constants.K_SPACE, misc.constants.K_RETURN ])[0]
        if key == ord("y") or key == ord("z"):
            remote_control = True
        else:
            remote_control = False

    if filename is None:
        bkg = logo_text_line("")
        filename = io.TextInput("Filename", background_stimulus=bkg).get()
        filename = filename.replace(" ", "_")

    logo_text_line(text="Trakstar is initializing...").present()
    thr_init_trackstar.join() # wait finishing trackstar thread

    if trakstar.is_init:
        udp_connection = trakstar.udp
        logo_text_line(text="Trakstar initialized").present()
    else:
        logo_text_line(text="Trakstar failed to initialize").present()
        exp.keyboard.wait()
    return remote_control, filename
Esempio n. 8
0
 def update_protocol_state(self,
                           samples,
                           reward,
                           chunk_size=1,
                           is_half_time=False):
     if not self.exp.is_initialized:
         control.initialize(self.exp)
     else:
         return self.current_protocol.update_state(
             samples,
             reward,
             chunk_size=chunk_size,
             is_half_time=is_half_time)
Esempio n. 9
0
    def run_exp():
        control.defaults.initialize_delay = 0
        #control.defaults.window_mode = True
        exp_env = design.Experiment(background_colour=BLACK)
        control.initialize(exp_env)
        exp = PsyExperiment(exp_env, detection_task=True)
        exp.preload_stimuli()
        #sleep(5)

        while True:
            exp.run_trial()

        control.end()
Esempio n. 10
0
def perform_simon_task():
    """Performs a Simon Task experiment."""

    exp = design.Experiment("Simon Task")
    control.initialize(exp)

    exp = design_experiment(exp, POSITIONS, COLORS, PAIRINGS)

    exp.data_variable_names = [
        "pairing", "position", "color", "key", "reaction_time"
    ]

    control.start()
    execute_experiment(exp, INSTRUCTION_TEXT, KEY_MAPPING, PAIRINGS)
    control.end()
Esempio n. 11
0
def initialize(exp, remote_control=None):
    control.initialize(exp)
    exp.mouse.show_cursor()

    if remote_control is None:
        logo_text_line(text="Use remote control? (Y/n)").present()
        key = exp.keyboard.wait([ord("z"), ord("y"), ord("n"),
                                 misc.constants.K_SPACE,
                                 misc.constants.K_RETURN])[0]
        if key == ord("n"):
            remote_control = False
        else:
            remote_control = True

    return remote_control
Esempio n. 12
0
    def init_display(experiment):

        import pygame

        # Configure Expyriment
        io.defaults.mouse_track_button_events = False
        control.defaults.initialize_delay = 0
        control.defaults.event_logging = 0
        control.defaults.window_mode = experiment.var.fullscreen != u'yes'
        control.defaults.fast_quit = True
        control.defaults.window_size = experiment.resolution()
        control.defaults.auto_create_subject_id = True
        control.defaults.open_gl = experiment.var.get(
            u'expyriment_opengl',
            xpyriment.settings[u'expyriment_opengl'][u'default']) == u'yes'
        control.defaults.audiosystem_sample_rate = experiment.var.sound_freq
        control.defaults.audiosystem_bit_depth = \
         experiment.var.sound_sample_size
        control.defaults.audiosystem_channels = experiment.var.sound_channels
        control.defaults.audiosystem_buffer_size = \
         experiment.var.sound_buf_size

        # Initialize. If Expyriment jumps into interactive mode, it reads from
        # the stdin, and crashes. Thus we explicitly disable the interactive-
        # mode detection.
        control._experiment_control.is_interactive_mode = lambda: False
        exp = control.initialize()
        experiment.window = exp.screen._surface
        experiment.expyriment = exp

        # TODO: In order to set the window title and to allow mouse responses we
        # need to bypass expyriment for now
        pygame.display.set_caption(u'OpenSesame (Expyriment backend)')
        pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
        pygame.event.set_allowed(pygame.MOUSEBUTTONUP)
Esempio n. 13
0
	def init_display(experiment):

		import pygame

		# Configure Expyriment
		io.defaults.mouse_track_button_events = False
		control.defaults.initialize_delay = 0
		control.defaults.event_logging = 0
		control.defaults.window_mode = experiment.var.fullscreen != u'yes'
		control.defaults.fast_quit = True
		control.defaults.window_size = experiment.resolution()
		control.defaults.auto_create_subject_id = True
		control.defaults.open_gl = experiment.var.get(u'expyriment_opengl',
			xpyriment.settings[u'expyriment_opengl'][u'default']) == u'yes'
		control.defaults.audiosystem_sample_rate = experiment.var.sound_freq
		control.defaults.audiosystem_bit_depth = \
			experiment.var.sound_sample_size
		control.defaults.audiosystem_channels = experiment.var.sound_channels
		control.defaults.audiosystem_buffer_size = \
			experiment.var.sound_buf_size

		# Initialize. If Expyriment jumps into interactive mode, it reads from
		# the stdin, and crashes. Thus we explicitly disable the interactive-
		# mode detection.
		control._experiment_control.is_interactive_mode = lambda: False
		exp = control.initialize()
		experiment.window = exp.screen._surface
		experiment.expyriment = exp

		# TODO: In order to set the window title and to allow mouse responses we
		# need to bypass expyriment for now
		pygame.display.set_caption(u'OpenSesame (Expyriment backend)')
		pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
		pygame.event.set_allowed(pygame.MOUSEBUTTONUP)
Esempio n. 14
0
def init_display(experiment):

	import pygame

	# Configure Expyriment
	io.defaults.mouse_track_button_events = False
	control.defaults.initialize_delay = 0
	control.defaults.event_logging = 0
	control.defaults.window_mode = experiment.get(u'fullscreen') == u'no'
	control.defaults.fast_quit = True
	control.defaults.window_size = experiment.resolution()
	control.defaults.auto_create_subject_id = True
	control.defaults.open_gl = experiment.get_check(u'expyriment_opengl', \
		xpyriment.settings[u'expyriment_opengl'][u'default']) == u'yes'
	control.defaults.audiosystem_sample_rate = experiment.get(u'sound_freq')
	control.defaults.audiosystem_bit_depth = experiment.get(u'sound_sample_size')
	control.defaults.audiosystem_channels = experiment.get(u'sound_channels')
	control.defaults.audiosystem_buffer_size = experiment.get(u'sound_buf_size')

	# Initialize
	exp = control.initialize()
	experiment._time_func = pygame.time.get_ticks
	experiment._sleep_func = pygame.time.delay
	experiment.time = experiment._time_func
	experiment.sleep = experiment._sleep_func
	experiment.window = exp.screen._surface
	experiment.expyriment = exp

	# TODO: In order to set the window title and to allow mouse responses we
	# need to bypass expyriment for now
	pygame.display.set_caption(u'OpenSesame (Expyriment backend)')
	pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
	pygame.event.set_allowed(pygame.MOUSEBUTTONUP)
Esempio n. 15
0
def init_display(experiment):

	"""See openexp._canvas.legacy"""

	global exp
	
	# Configure Expyriment
	io.defaults.mouse_track_button_events = False	
	control.defaults.initialize_delay = 0
	control.defaults.event_logging = 0
	control.defaults.window_mode = experiment.get('fullscreen') == 'no'
	control.defaults.fast_quit = True
	control.defaults.window_size = experiment.resolution()
	control.defaults.auto_create_subject_id = True	
	control.defaults.open_gl = experiment.get_check('expyriment_opengl', \
		xpyriment.settings['expyriment_opengl']['default']) == 'yes'
	
	# Initialize
	exp = control.initialize()	
	experiment._time_func = _time
	experiment._sleep_func = exp.clock.wait
	experiment.time = experiment._time_func
	experiment.sleep = experiment._sleep_func
	experiment.window = exp.screen._surface
	experiment.expyriment = exp
	
	# TODO: In order to set the window title and to allow mouse responses we
	# need to bypass expyriment for now
	import pygame
	pygame.display.set_caption('OpenSesame (Expyriment backend)')
	pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
	pygame.event.set_allowed(pygame.MOUSEBUTTONUP)
Esempio n. 16
0
def init_display(experiment):

	"""See openexp._canvas.legacy"""

	import pygame

	# Configure Expyriment
	io.defaults.mouse_track_button_events = False
	control.defaults.initialize_delay = 0
	control.defaults.event_logging = 0
	control.defaults.window_mode = experiment.get(u'fullscreen') == u'no'
	control.defaults.fast_quit = True
	control.defaults.window_size = experiment.resolution()
	control.defaults.auto_create_subject_id = True
	control.defaults.open_gl = experiment.get_check(u'expyriment_opengl', \
		xpyriment.settings[u'expyriment_opengl'][u'default']) == u'yes'
	control.defaults.audiosystem_sample_rate = experiment.get(u'sound_freq')
	control.defaults.audiosystem_bit_depth = experiment.get(u'sound_sample_size')
	control.defaults.audiosystem_channels = experiment.get(u'sound_channels')
	control.defaults.audiosystem_buffer_size = experiment.get(u'sound_buf_size')

	# Initialize
	exp = control.initialize()
	experiment._time_func = pygame.time.get_ticks
	experiment._sleep_func = pygame.time.delay
	experiment.time = experiment._time_func
	experiment.sleep = experiment._sleep_func
	experiment.window = exp.screen._surface
	experiment.expyriment = exp

	# TODO: In order to set the window title and to allow mouse responses we
	# need to bypass expyriment for now
	pygame.display.set_caption(u'OpenSesame (Expyriment backend)')
	pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
	pygame.event.set_allowed(pygame.MOUSEBUTTONUP)
Esempio n. 17
0
def initialize(exp, remote_control=None):
    control.initialize(exp)
    exp.mouse.show_cursor()

    if remote_control is None:
        logo_text_line(text="Use remote control? (Y/n)").present()
        key = exp.keyboard.wait([
            ord("z"),
            ord("y"),
            ord("n"), misc.constants.K_SPACE, misc.constants.K_RETURN
        ])[0]
        if key == ord("n"):
            remote_control = False
        else:
            remote_control = True

    return remote_control
def client(server_ip):
    # t : test connect
    # q : quit client
    # space : enter

    control.set_develop_mode(True)
    control.defaults.audiosystem_autostart = False
    exp = control.initialize()

    udp_connection = UDPConnection()
    print(udp_connection)

    if not udp_connection.connect_peer(server_ip):
        print("error connecting to peer")
        exit()

    stimuli.TextScreen(
        "connected to " + udp_connection.peer_ip,
        "\nSPACE: send text\nT: trigger test\nQ: quit").present()

    c = Clock()

    while True:
        key = exp.keyboard.check()
        if key == ord("q"):
            break
        elif key == misc.constants.K_SPACE:
            text = io.TextInput().get()
            stimuli.BlankScreen().present()
            print("send: {} {}".format(c.time, text))
            udp_connection.send(text)
        elif key == ord("t"):
            times = []
            for cnt in range(20):
                stimuli.TextLine("ping test " + str(cnt)).present()
                c.reset_stopwatch()
                ok, time = udp_connection.ping(timeout=1)
                print("answer received in {} ms".format(c.stopwatch_time))
                times.append(time)
                c.wait(100)
            stimuli.BlankScreen().present()
            print(times)

        feedback = udp_connection.poll()
        if feedback is not None:
            print("received: {} {}".format(c.time, feedback))

    udp_connection.unconnect_peer()
Esempio n. 19
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)
Esempio n. 20
0
def startTrial(NUMBER,OPERATOR):

    w, h = 10, 3;
    Matrix = [[0 for x in range(w)] for y in range(h)]       # Define 2D array

    #fixcross.preload()
    exp = design.Experiment("MATH")
    control.initialize(exp)
    control.start()
    fixcross = stimuli.FixCross(size=(40,40),colour=misc.constants.C_WHITE,position=(0,200))
    txt_input=io.TextInput("= ")

    inputNAME=io.TextInput("ENTER NAME: ")
    VolunteerNAME = inputNAME.get() # First input by volunteer
    Matrix[2][1]=VolunteerNAME

    stimuli.TextScreen("MATH GAME -LEVEL 1",". . . RELAX . . .\n\n\n\n\n\n+\n\nlook at fixcross\n\n\nSTARTS IN 10 SECONDS",heading_size=40,text_size=20,heading_colour=misc.constants.C_WHITE,text_colour=misc.constants.C_WHITE).present()
    exp.clock.wait(10000) #stim -1                                               REMOVE # ON COMMISSION
    fixcross.preload()
    fixcross.present()
    exp.clock.wait(10000)                                                        # REMOVE # ON COMMISSION
    b = design.Block()

    for i in range (0,10):                                                       # cOMMISSION : 3->10 #FOR 10 TRIALS
        b.clear_trials()
        b = design.Block()
        print(i)
        tr=atl.arithmetictriall1(NUMBER,OPERATOR)
        print(tr)

        for trel in tr[0]:
            t=design.Trial()
            s = stimuli.TextLine(text=str(trel),text_size=200,text_colour=misc.constants.C_GREEN)
            t.add_stimulus(s)
            b.add_trial(t)
        #print(b.trials)
        exp.add_block(b)

        #START TEST: ONSCREEN
        #tx0=time.time()
        fixcross.present()
        exp.clock.wait(1000)
        #tx1=time.time()-tx0
        #print("ttt %d"%tx1)
        #xcount = 1                #debug fixcross timings (previously increasing time b=1)
        for b in exp.blocks:

            for t in b.trials:
                t.stimuli[0].present()
                exp.clock.wait(800) #>1000
            #xcount=0

        print(b)
        #exp.clock.reset_stopwatch()
        t0=time.time()
        answer = txt_input.get()
        responsetime=time.time()-t0     #response time

        try:
            answer=int(answer)
            if answer==tr[1]:
                print("Correct")
                Matrix[0][i]=5
                Matrix[1][i]=responsetime
            else:
                print("incorrect")
                Matrix[0][i]=-5
                Matrix[1][i]=responsetime
        except:
            print("incorrect")
            Matrix[0][i]=-5
            Matrix[1][i]=responsetime

    fixcross.present()
    exp.clock.wait(5000)
    control.end()
    #print(Matrix)
    return Matrix
Esempio n. 21
0
from expyriment import control, design, io, misc, stimuli
from expyriment.design.extras import StimulationProtocol


# SETTINGS
BLOCK_LENGTH = 8  # In volumes
NR_REPETITIONS = 6  # For each block (rest and imagery)
TR = 2.0
SCAN_TRIGGER = misc.constants.K_5
SCAN_TRIGGER_LTP_ADDRESS = None  # None = USB (keyboard emulation)


# DESIGN
exp = design.Experiment("Motor Imagery (Swimming)")
control.initialize(exp)
protocol = StimulationProtocol("time")

fixcross = stimuli.FixCross()
fixcross.preload()
blocks = {"rest":[stimuli.TextLine("REST",
                                   text_size=70,
                                   text_colour=misc.constants.C_RED,
                                   text_font="monospace"),
                  stimuli.Audio("stimuli/rest.wav")],
          "swim":[stimuli.TextLine("SWIM",
                                   text_size=70,
                                   text_colour=misc.constants.C_GREEN,
                                   text_font="monospace"),
                  stimuli.Audio("stimuli/swim.wav")]}
Esempio n. 22
0
    
    Press the space bar to start.
    To exit the experiment, press escape."""

EXPERIMENT_INSTRUCTIONS = """Report the shape of the frame of the figure if it appears in the top part of the screen labeled "shape". If the frame is a square, press L on the keyboard. If it is a diamond, press S. Report the number of circles inside of the frame, if the figure appears in the bottom part of the screen labeled "filling". If you see 2 circles, press S. If you see 3 circles, press L. Every time give an incorrect response, you will get a reminder of the instructions.

    Press the space bar to start.
    To exit the experiment, press escape."""

REMINDER_INSTRUCTIONS = """Your task is to report the shape of the frame of the figure if it appears in the top part of the screen labeled "shape". If the frame is a square, press L on the keyboard. If it is a diamond, press S.
    If the figure appears in the bottom part of the screen labeled "filling", you task is to report the number of circles inside of the frame. If you see 2 circles, press S on the keyboard. If you see 3 circles, press L.
    
    To exit the experiment, press escape."""

exp_1 = design.Experiment(name="Task Switching", text_size=40)
control.initialize(exp_1)


def training(N_TRIALS):
    training_instructions.present()
    kb.wait_char(' ')
    for i_trial in range(N_TRIALS):
        trial = mixed_block.get_random_trial()
        blankscreen.present()
        exp_1.clock.wait(INTER_TRIAL_INTERVAL)
        trial.stimuli[0].present(update=True, clear=True)
        key, rt = exp_1.keyboard.wait(duration=MAX_RESPONSE_DELAY)
        if key == None:
            is_correct = None
        elif trial.get_factor('task') == "shape":  #determine the task
            if trial.get_factor(
Esempio n. 23
0
        """

        if position is None:
            position = defaults.dot_position
        if colour is None:
            colour = defaults.dot_colour
        Circle.__init__(self, diameter=radius * 2, colour=colour, position=position)

    def is_overlapping(self, other, minimal_gap=0):
        """DEPRECATED METHOD: Please use 'overlapping_with_circle'"""
        return self.overlapping_with_circle(other, minimal_gap)

    def is_center_inside(self, other):
        """DEPRECATED METHOD: Please use 'center_inside_circle'"""
        return self.center_inside_circle(other)

    def is_inside(self, other):
        """DEPRECATED METHOD: Please use 'inside_circle'"""
        return self.inside_circle(other)


if __name__ == "__main__":
    from expyriment import control

    control.set_develop_mode(True)
    defaults.event_logging = 0
    exp = control.initialize()
    dot = Dot(radius=100)
    dot.present()
    exp.clock.wait(1000)
Esempio n. 24
0
breakText = '''Ovo je kraj prvog bloka miješanih zadataka.

Slobodno uzmite malu pauzu, a kad ste spremni, pritisnite ENTER kako biste\
 započeli posljednji blok zadataka.'''

# improting design
expDesign = pd.read_csv(join('task_switching', 'trials', 'design.csv'))

# generating experiment
experiment = design.Experiment(name='Task switching',
                               foreground_colour=(0, 0, 0),
                               background_colour=misc.constants.C_GREY,
                               text_font='Courier New', text_size=24)

control.initialize(experiment)

experiment.add_data_variable_names(['subjectNo',
                                    'subjectCode',
                                    'task',
                                    'reactionTime',
                                    'stimulus',
                                    'response',
                                    'isCorrect',
                                    'blockName',
                                    'isSwitchTrial'])

# creating blocks
experiment.clear_blocks()
for blockNo in expDesign.block_cnt.unique():
    rows = expDesign[expDesign.block_cnt == blockNo]
Esempio n. 25
0
'''
Custom settings
'''
# switch off opengl to avoid screen refresh sync
control.defaults.open_gl = False

# Fast open close and windowed; default: False
control.set_develop_mode(True)
io.defaults.outputfile_time_stamp = True
#control.defaults.initialize_delay = 0
'''
Prepare Training
'''
#Initialize experiment and load setup
exp = design.Experiment(name="MusicTraining")
control.initialize(exp)
setup = Setup(screen_size=exp.screen.size)
setup.make_selection(use_all_notes=False)
exp.mouse.show_cursor()

# Create list of musicsheet objects
musicsheet = dict()
for clef in setup.clef:
    musicsheet[clef] = MusicSheet(screen_size=exp.screen.size,
                                  pos_y=setup.pos_y,
                                  clef_name=clef)

# Create list of note objects
Notes = Notes()
Notes.appendnotes(setup.selection, setup.pos_y, setup.distance)
from expyriment import design, stimuli, control, io, misc
from expyriment.misc import constants
import pandas as pd
import os.path

### OPEN DATA FILE ###
Stim_Shape = pd.read_csv("Task_Stimuli_Shapes.csv")
Stim_Color = pd.read_csv("Task_Stimuli_Colors.csv")

### CREATE NEW DATA FILE FOR DEMOGRAPHIC INFORMATION IN DATA FOLDER ###
DEMO = 'Data/demographics.csv'

### EXPERIMENTAL DESIGN ####
exp = design.Experiment("Task")  #create and name new exp object
control.initialize(
    exp
)  #starts countdown, sets up experimental clock, creates the screen (exp.screen), creates and event file (exp.events) and presents the preparing expyriment screen_size
screen_size = exp.screen.surface.get_size()

### INSTRUCTIONS ###
General_Instructions = "This study has two parts. You will have to answer questions using the keyboard for both parts!"
Continue_Instructions = 'Press any key to continue...'
Demographic_Task_Instructions = "In PART 1, you will be asked to answer some general questions about yourself."
Image_Task_Instructions = "In PART 2, you will be asked to judge shapes and colors. Press any key to continue."
Instructions_Shape_Task = "You will be shown several shapes and you will be asked to evaluate each shape. Press any key to start."
Instructions_Color_Task = "You will be shown several colors and you will be asked to evaluate each color. Press any key to start."
Image_Task_Answer = "Please select between 1 and 5, with 1 = definitely yes, 2 = mostly yes, 3  = neither yes nor no,  4 = mostly no, 5 = definitely no."

Question_1 = "Press f if you are a female, m for male, o for other."
Question_2 = "How old are you?"
Answer_Q2 = io.TextInput(