Esempio n. 1
0
def get_input(exp, i):
    global measurement_rate, max_range, report_rate, power_line, metric
    if i == 1:
        measurement_rate = int(io.TextInput("Measurement rate (20 Hz < rate < 255 Hz):", length=3,
                                            ascii_filter=range(ord("0"), ord("9") + 1)).get())
        if measurement_rate < 20 or measurement_rate > 255:
            measurement_rate = 80
            invalid_value()
        else:
            stimuli.TextLine(text="Measurement rate set to {0} Hz.".format(measurement_rate)).present()
            exp.clock.wait(t_wait)
        return
    elif i == 2:
        max_range = int(io.TextInput("Maximum range of transmitter (36, 72, 144 inches):", length=3,
                                     ascii_filter=range(ord("1"), ord("5")) + [ord("6"), ord("7")]).get())
        if max_range not in [36, 72, 144]:
            max_range = 36
            invalid_value()
        else:
            stimuli.TextLine(text="Maximum range of transmitter set to {0} inches.".format(max_range)).present()
            exp.clock.wait(t_wait)
        return
    elif i == 3:
        report_rate = int(io.TextInput("Report rate of the data (1 <= rate <= 127):", length=3,
                                       ascii_filter=range(ord("0"), ord("9") + 1)).get())
        if report_rate < 1 or report_rate > 127:
            report_rate = 1
            invalid_value()
        else:
            stimuli.TextLine(text="Report rate of incoming data set to {0}.".format(report_rate)).present()
            exp.clock.wait(t_wait)
        return
    elif i == 4:
        power_line = int(io.TextInput("Power line frequency of the AC power source (50 or 60 Hz):",
                                      length=2, ascii_filter=[ord("0"), ord("5"), ord("6")]).get())
        if power_line not in [50, 60]:
            power_line = 60
            invalid_value()
        else:
            stimuli.TextLine(
                text="Power line frequency of the AC power source set to {0} Hz.".format(power_line)).present()
            exp.clock.wait(t_wait)
        return
    elif i == 5:
        metric = int(io.TextInput("Switch metric data reporting on/off (1/0):",
                                  length=1, ascii_filter=[ord("0"), ord("1")]).get())
        if metric not in [0, 1]:
            metric = True
            invalid_value()
        else:
            stimuli.TextLine(text="Metric data reporting set to {0}.".format(metric)).present()
            exp.clock.wait(t_wait)
        return
Esempio n. 2
0
def textinput_thesholds(message="Enter thresholds"):
    thresholds = _text2number_array(io.TextInput(message=message).get())
    stimuli.BlankScreen().present()
    if thresholds is not None:
        if len(thresholds) != 2:
            thresholds = None
    return thresholds
 def user_answer(self, block, trial):
     reverse = block.get_factor('reverse')
     correct_answer = trial.get_factor('sequence')
     seq_length = trial.get_factor('sequence_length')
     input_method = self.exp.config.get('ANDROID', 'input_method')
     if android and input_method == 'keyboard':
         android.show_keyboard()
     self.exp.keyboard.clear()
     if not android or input_method == 'keyboard' or input_method == 'none':
         user_input = io.TextInput(_('remember_sequence_reverse') if
                                     reverse else _('remember_sequence'),
                                     length=seq_length,
                                     position=self.input_offset,
                                     user_text_size=self.input_text_size
                                 ).get().strip()
         android.hide_keyboard() if android else None
     else:
         pass
     answer = user_input[::-1] if reverse else user_input
     format = {'sequence': correct_answer,
               'sequence_length': seq_length,
               'sequence_reverse': correct_answer[::-1]}
     if answer.strip() == correct_answer:
         self.exp._show_message('', 'correct_trial', format=format)
     else:
         self.exp._show_message('', 'incorrect_trial_reverse' if reverse else 'incorrect_trial', format=format)
     return(answer == correct_answer, user_input)
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. 5
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
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. 7
0
    def process_key(self, key):
        if key == misc.constants.K_q or key == misc.constants.K_ESCAPE:
            self.quit_recording = True
        elif key == misc.constants.K_v:
            self.plot_indicator = not self.plot_indicator
            self.background.stimulus().present()

        elif key == misc.constants.K_p:
            # pause
            self.pause_recording = not self.pause_recording
        elif key == misc.constants.K_b and self.pause_recording:
            self.background.stimulus("Recording baseline").present()
            self.recorder.determine_biases(n_samples=500)
            self.background.stimulus("Paused").present()

        elif key == misc.constants.K_KP_MINUS:
            self.scaling_plotter.increase_data_range()
            self.scaling_indicator.increase_data_range()
            self.background.stimulus().present()
            self.clear_screen = True
        elif key == misc.constants.K_KP_PLUS:
            self.scaling_plotter.decrease_data_range()
            self.scaling_indicator.decrease_data_range()
            self.background.stimulus().present()
            self.clear_screen = True
        elif key == misc.constants.K_UP:
            self.scaling_plotter.data_range_up()
            self.scaling_indicator.data_range_up()
            self.background.stimulus().present()
            self.clear_screen = True
        elif key == misc.constants.K_DOWN:
            self.scaling_plotter.data_range_down()
            self.scaling_indicator.data_range_down()
            self.background.stimulus().present()
            self.clear_screen = True
        elif key == misc.constants.K_f:
            self.plot_filtered = not self.plot_filtered

        elif key == misc.constants.K_t:
            tmp = text2number_array(
                io.TextInput("Enter thresholds",
                             background_stimulus=logo_text_line("")).get())
            self.background.stimulus().present()
            if tmp is not None:
                self.thresholds = Thresholds(tmp, n_channels=self.n_sensors)
            else:
                self.thresholds = None
Esempio n. 8
0
def _font_viewer(exp):
    all_fonts = expyriment.misc.list_fonts().keys()

    def info_screen():
        stimuli.TextScreen(heading="Expyriment Font Viewer",
                           text="""
arrow keys left/right -- Switch font type
arrow keys up/down    -- Switch font size
                  i   -- Switch italic
                  b   -- Switch bold
                  c   -- Change text
                  h   -- Help
               return -- Quit


                 [Touch screen]
click left/right side --  Switch font type
click up/down side    --  Switch font size
click center          --  Quit
               """,
                           text_font="freemono",
                           text_bold=True,
                           text_justification=0).present()
        exp.keyboard.wait()

    default_text = u"""The quick brown fox jumps over the lazy dog.
ABCDEFGHIJKLMNOPQRSTUVWXYZ ÄÖÜ
abcdefghijklmnopqrstuvwxyz äöü
1234567890.:,;ßéèê(*!?')"""
    text = default_text
    size = 14
    font_id = 0
    italic = False
    bold = False
    quest = io.TextInput(
        message="Please enter text: (Keep empty for default text)", length=35)
    mouse = io.Mouse(show_cursor=True)

    bs = (exp.screen.size[0] / 3.5, exp.screen.size[1] / 3.5)

    # rects center, left, right, top, button]
    cl = (20, 20, 20)
    rects = [
        stimuli.Rectangle(size=bs, position=[0, 0], colour=cl),
        stimuli.Rectangle(size=bs,
                          position=[(bs[0] - exp.screen.size[0]) / 2.2, 0],
                          colour=cl),
        stimuli.Rectangle(size=bs,
                          position=[(exp.screen.size[0] - bs[0]) / 2.2, 0],
                          colour=cl),
        stimuli.Rectangle(size=bs,
                          position=[0, (bs[1] - exp.screen.size[1]) / 2.2],
                          colour=cl),
        stimuli.Rectangle(size=bs,
                          position=[0, (exp.screen.size[1] - bs[1]) / 2.2],
                          colour=cl)
    ]
    rect_key_mapping = [
        constants.K_RETURN, constants.K_LEFT, constants.K_RIGHT,
        constants.K_UP, constants.K_DOWN
    ]

    info_screen()
    while True:
        font_str = all_fonts[font_id]
        font_description = "font '{0}', size {1}".format(font_str, size)
        if italic:
            font_description += ", italic"
        if bold:
            font_description += ", bold"

        canvas = stimuli.BlankScreen()
        for r in rects:
            r.plot(canvas)
        try:
            stimuli.TextScreen(heading=font_description,
                               text=text,
                               text_font=font_str,
                               text_size=size,
                               text_justification=0,
                               text_italic=italic,
                               text_bold=bold,
                               text_colour=(255, 255, 255)).plot(canvas)
        except:
            stimuli.TextLine(
                text="Sorry, I can't display the text with " +
                "{0}".format(font_description),
                text_colour=constants.C_EXPYRIMENT_ORANGE).plot(canvas)
        canvas.present()
        mouse.clear()
        exp.keyboard.clear()
        while True:
            key = exp.keyboard.check()
            if mouse.get_last_button_down_event() is not None:
                for cnt, r in enumerate(rects):
                    if r.overlapping_with_position(mouse.position):
                        key = rect_key_mapping[cnt]
                        break
            if key is not None:
                break

        if (key == constants.K_RETURN):
            break
        elif key == constants.K_UP:
            size += 2
        elif key == constants.K_DOWN:
            size -= 2
        elif key == constants.K_LEFT:
            font_id -= 1
            if font_id < 0:
                font_id = len(all_fonts) - 1
        elif key == constants.K_RIGHT:
            font_id += 1
            if font_id >= len(all_fonts):
                font_id = 0
        elif key == constants.K_i:
            italic = not (italic)
        elif key == constants.K_b:
            bold = not (bold)
        elif key == constants.K_c:
            text = quest.get()
            if len(text) <= 0:
                text = default_text
        else:
            info_screen()
    mouse.hide_cursor()
Esempio n. 9
0
def _numeric_input(title, default=''):
    if android:
        return(str(_clickable_numeric_input(title, default)))
    else:
        return(io.TextInput(message=title, length=3).get(str(default)))
Esempio n. 10
0
    COLORS1 = n4b.n4back(rCOLORS)
    while type(
            COLORS1
    ) != list:  #BUG removal : since sometimes n2back returns Nonetype
        COLORS1 = n4b.n4back(rCOLORS)
        print(type(COLORS1))

    exp = design.Experiment(trialname)
    b1 = cB.createBlock(COLORS1, trialname, exp)
    fixcross = stimuli.FixCross(size=(40, 40), colour=misc.constants.C_WHITE)

    control.initialize(exp)

    control.start()

    inputNAME = io.TextInput("ENTER NAME: ")
    VolunteerNAME = inputNAME.get()  # First input by volunteer

    stimuli.TextScreen(
        "4-BACK GAME",
        ". . . 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
    fixcross.preload()
    fixcross.present()
    exp.clock.wait(10000)  #stim 0

    start_t0 = time.time()
Esempio n. 11
0
def start(remote_control,
          ask_filename,
          device_ids,
          sensor_names,
          calibration_folder,
          device_name_prefix="Dev",
          write_Fx=True,
          write_Fy=True,
          write_Fz=True,
          write_Tx=False,
          write_Ty=False,
          write_Tz=False,
          write_trigger1=True,
          write_trigger2=False,
          zip_data=False,
          reverse_scaling=None):
    """start gui
    remote_control should be None (ask) or True or False

    reverse scaling: dictionary with rescaling (see SensorSetting)
                key: device_id, value: list of parameter names (e.g., ["Fx"])

    returns False only if quited by key while waiting for remote control
    """

    if not isinstance(device_ids, (list, tuple)):
        device_ids = [device_ids]
    if not isinstance(sensor_names, (list, tuple)):
        sensor_names = [sensor_names]
    timer = Timer()
    sensors = []
    for d_id, sn in zip(device_ids, sensor_names):
        try:
            reverse_parameter_names = reverse_scaling[d_id]
        except:
            reverse_parameter_names = []

        sensors.append(
            SensorSettings(device_id=d_id,
                           device_name_prefix=device_name_prefix,
                           sensor_name=sn,
                           sync_timer=timer,
                           calibration_folder=calibration_folder,
                           reverse_parameter_names=reverse_parameter_names,
                           rate=config.sampling_rate))

    # expyriment
    control.defaults.initialize_delay = 0
    control.defaults.pause_key = None
    control.defaults.window_mode = True
    control.defaults.window_size = (1000, 700)
    control.defaults.fast_quit = True
    control.defaults.open_gl = False
    control.defaults.event_logging = 0
    exp = design.Experiment(text_font=config.window_font)
    exp.set_log_level(0)

    filename = "output.csv"
    remote_control = initialize(exp, remote_control=remote_control)
    logo_text_line("Initializing Force Recording").present()

    recorder = DataRecorder(sensors,
                            timer=timer,
                            poll_udp_connection=True,
                            write_deviceid=len(device_ids) > 1,
                            write_Fx=write_Fx,
                            write_Fy=write_Fy,
                            write_Fz=write_Fz,
                            write_Tx=write_Tx,
                            write_Ty=write_Ty,
                            write_Tz=write_Tz,
                            write_trigger1=write_trigger1,
                            write_trigger2=write_trigger2)

    sleep(0.2)  # wait for lib init
    recorder.determine_biases(n_samples=500)

    if remote_control:
        logo_text_line("Waiting to connect (my IP: {0})".format(
            recorder.udp.ip_address)).present()
        while not recorder.udp.event_is_connected.is_set():
            key = exp.keyboard.check(check_for_control_keys=False)
            if key == misc.constants.K_q or key == misc.constants.K_ESCAPE:
                recorder.quit()
                control.end()
                return False
            sleep(0.01)  #

        logo_text_line("Wait for filename").present()
        while True:
            try:
                x = recorder.udp.receive_queue.get_nowait()
                x = x.string
            except:
                x = None
            if x is not None and x.startswith(RcCmd.FILENAME):
                filename = x.replace(RcCmd.FILENAME, "")
                break
            exp.keyboard.check()
            sleep(0.01)
    else:
        if ask_filename:
            bkg = logo_text_line("")
            filename = io.TextInput("Filename", background_stimulus=bkg).get()
            filename = filename.replace(" ", "_")

    recorder.open_data_file(filename,
                            directory="data",
                            zipped=zip_data,
                            time_stamp_filename=False,
                            comment_line="")

    main_loop(exp, recorder=recorder, remote_control=remote_control)

    recorder.quit()
    control.end()
    return True
Esempio n. 12
0
##print "<-- ", c.time,  feedback
##c.wait(2000)
##
##print "--> ", c.time, "quit"
##udp.send("quit")
##feedback = udp.poll()
##while feedback is None:
##    feedback = udp.poll()
##print "<-- ", c.time,  feedback

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 "--> ", 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()
            print c.stopwatch_time
            times.append(time)
            c.wait(100)
        stimuli.BlankScreen().present()
        print times
        trial = design.Trial()
        trial.set_factor("word", row[0].strip())
        trial.set_factor("fragment", row[1].strip())
        block.add_trial(trial)
block.shuffle_trials()
exp.add_block(block)
exp.add_data_variable_names(["word", "fragment", "RT", "RT2", "answer"])

control.initialize(exp)

#prepare some stimuli
fixcross = stimuli.FixCross(line_width=1)
fixcross.preload()
blank = stimuli.BlankScreen()
blank.preload()
txt_input = io.TextInput("")
control.start(exp)

#run experiment
for trial in exp.blocks[0].trials:
    #present blank inter-trial-screen and prepare stimulus
    blank.present()
    fragment = ""
    for c in trial.get_factor("fragment").upper():
        fragment += c + " "
    target = stimuli.TextLine(fragment.strip())
    target.preload()
    exp.clock.wait(1000)
    #present fixcross
    fixcross.present()
    exp.clock.wait(500)
Esempio n. 14
0
def run_with_options(remote_control,
                     ask_filename,
                     device_ids,
                     sensor_names,
                     calibration_folder,
                     device_name_prefix="Dev",
                     write_Fx=True,
                     write_Fy=True,
                     write_Fz=True,
                     write_Tx=False,
                     write_Ty=False,
                     write_Tz=False,
                     write_trigger1=True,
                     write_trigger2=False,
                     zip_data=False,
                     reverse_scaling=None,
                     convert_to_forces=True,
                     polling_priority=None):
    """start gui
    remote_control should be None (ask) or True or False

    reverse scaling: dictionary with rescaling (see SensorSetting)
                key: device_id, value: list of parameter names (e.g., ["Fx"])

   polling_priority has to be types.PRIORITY_{HIGH}, {REALTIME} or
                        {NORMAL} or None

    returns False only if quited by key while waiting for remote control
    """
    #

    logging.info("New Recording with forceDAQ {}".format(forceDAQVersion))
    logging.info("Sensors {}".format(sensor_names))
    logging.info("Settings " + settings.recording_as_json())

    if not isinstance(device_ids, (list, tuple)):
        device_ids = [device_ids]
    if not isinstance(sensor_names, (list, tuple)):
        sensor_names = [sensor_names]

    sensors = []
    for d_id, sn in zip(device_ids, sensor_names):
        try:
            reverse_parameter_names = reverse_scaling[str(d_id)]
        except:
            reverse_parameter_names = []

        sensors.append(
            SensorSettings(device_id=d_id,
                           device_name_prefix=device_name_prefix,
                           sensor_name=sn,
                           calibration_folder=calibration_folder,
                           reverse_parameter_names=reverse_parameter_names,
                           rate=settings.gui.sampling_rate,
                           convert_to_FT=convert_to_forces))

    # expyriment
    control.defaults.initialize_delay = 0
    control.defaults.pause_key = None
    control.defaults.window_mode = True
    control.defaults.window_size = (1000, 700)
    control.defaults.fast_quit = True
    control.defaults.open_gl = False
    control.defaults.event_logging = 0
    control.defaults.audiosystem_autostart = False
    exp = design.Experiment(text_font=settings.gui.window_font)
    exp.set_log_level(0)

    filename = "output.csv"
    remote_control = _initialize(exp, remote_control=remote_control)
    logo_text_line("Initializing Force Recording").present()

    recorder = DataRecorder(sensors,
                            poll_udp_connection=True,
                            write_deviceid=len(device_ids) > 1,
                            write_Fx=write_Fx,
                            write_Fy=write_Fy,
                            write_Fz=write_Fz,
                            write_Tx=write_Tx,
                            write_Ty=write_Ty,
                            write_Tz=write_Tz,
                            write_trigger1=write_trigger1,
                            write_trigger2=write_trigger2,
                            polling_priority=polling_priority)

    app_timer.wait(200)  # wait for lib init
    recorder.determine_biases(n_samples=500)

    if remote_control:
        logo_text_line("Waiting to connect (my IP: {0})".format(
            recorder.udp.my_ip)).present()
        while not recorder.udp.event_is_connected.is_set():
            key = exp.keyboard.check(check_for_control_keys=False)
            if key == misc.constants.K_q or key == misc.constants.K_ESCAPE:
                recorder.quit()
                control.end()
                return False
            app_timer.wait(100)

        logo_text_line("Wait for filename").present()
        while True:
            try:
                x = recorder.udp.receive_queue.get_nowait()
            except:
                x = None

            if x is not None and x.startswith(RcCmd.FILENAME):
                filename = x.byte_string[len(RcCmd.FILENAME):].decode(
                    'utf-8', 'replace')
                break
            exp.keyboard.check()
            app_timer.wait(100)
    else:
        if ask_filename:
            bkg = logo_text_line("")
            filename = io.TextInput("Filename", background_stimulus=bkg).get()
            filename = filename.replace(" ", "_")

    recorder.open_data_file(filename,
                            subdirectory="data",
                            zipped=zip_data,
                            time_stamp_filename=False,
                            comment_line="")

    _main_loop(exp, recorder=recorder, remote_control=remote_control)

    recorder.quit()
    control.end()
    return True
Esempio n. 15
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. 16
0
pos = [(-300, 0), (300, 0), (0, 0)]
rect_b = stimuli.Rectangle((80, 80), colour=(255, 255, 255), position=pos[2])
blank = stimuli.BlankScreen()

c1 = stimuli.BlankScreen()
blank.plot(c1)
c1.preload()
c2 = stimuli.BlankScreen()
fix.plot(c2)
c2.preload()
c3 = stimuli.BlankScreen()
fix.plot(c3)
rect_b.plot(c3)
c3.preload()

txt_input = io.TextInput("")

# DESIGN
b = design.Block()
for trial in range(len(StimList)):
    t = design.Trial()

    # blank screen

    t.add_stimulus(c1)

    # fixation dot

    t.add_stimulus(c2)

    # rectangles
Esempio n. 17
0
        trial.add_stimulus(backBox)
        trial.preload_stimuli()

        block.add_trial(trial)

    experiment.add_block(block)

# preparing general stimuli

blank = stimuli.BlankScreen()
blank.preload()

# preparing instructions, feedback, subject code entry
subCodeInstr = stimuli.TextBox(text=subCodeText, size=(800, 400))
subCodeInput = io.TextInput(length=6, background_stimulus=subCodeInstr,
                            position=(0, -100))

feedbackCorrect = stimuli.TextLine(text='Točno!',
                                   text_colour=misc.constants.C_GREEN,
                                   text_bold=True)
feedbackCorrect.preload()

feedbackIncorrect = stimuli.TextLine(text='Pogrešno!',
                                     text_colour=misc.constants.C_RED,
                                     text_bold=True)
feedbackIncorrect.preload()

subCode = ''

# set to 1 after 1st mixed test block to initiate a break
testMixedCnt = 0
)  #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(
    ""
)  #participant inputs answer using all keyboard keys and presses enter to validate response
Question_3 = "What is you ethinicity?"
Answer_Q_3 = "Press 1 = white, 2 = Asian, 3 = Hispanic, 4 = Black, 5 = Other."
Question_4 = "Politically you consider yourself..."
Question_5 = "Concerning SOCIAL issues, you consider yourself..."
Question_6 = "Concerning ECONOMIC issues, you consider yourself..."
Answer_Q_456 = "Press 1 = extremely liberal, 2 = liberal, 3 = slightly liberal, 4 = moderate, 5 = slightly conservative, 6 = conservative, 7 = extremely conservative."
Question_7 = "What is your employement status?"
Answer_Q_7 = "1= employed, 2 = part-time, 3 = not employed, 4 = retiered, 5 = student."
Question_8 = "What is your highest degree of formal education?"
Answer_Q_8 = "1= Elementary/Primary School, 2 = High School, 3 = University/Undergraduate Degree, 4 = Graduate Degree (Masters, PhD, LLD, MD)."


#### FUNCTION ####
def create_trial(Stimulus, Type, Filenumber):