Пример #1
0
def main():
    groups = create_stim_sequence(BLOCK1, BLOCK2, BLOCK3, TRIALREPEATS)
    print groups

    disp = Window(size=SIZE,
                  monitor=MON,
                  units='deg',
                  color=BACKCOL,
                  screen=1,
                  fullscr=True)

    mouse = Mouse()

    fixmark = Circle(disp, radius=0.05, edges=32, pos=CENTER, lineColor=FIXCOL)

    images = []

    for item in CIRCLES.keys():
        image = ImageStim(disp,
                          image=CIRCLES[item][1],
                          pos=CIRCLES[item][0],
                          size=CIRCLES[item][3])
        images.append(image)

    fixmark.draw()
    draw_group(images)
    disp.flip()

    while True:
        button = mouse.getPressed()
        if button[0]:
            break

    for item in groups:
        flashes = []
        for i in item:
            flash = ImageStim(disp,
                              image=CIRCLES[i][2],
                              pos=CIRCLES[i][0],
                              size=CIRCLES[i][3])
            flashes.append(flash)
        fixmark.draw()
        draw_group(images)
        draw_group(flashes)
        disp.flip()
        wait(FLASH)
        fixmark.draw()
        draw_group(images)
        wait(PAUSE)
        disp.flip()

    disp.close()
Пример #2
0
    def __init__(self, output_str, output_dir=None, settings_file=None):
        """ Initializes base Session class.

        parameters
        ----------
        output_str : str
            Name (string) for output-files (e.g., 'sub-01_ses-post_run-1')
        output_dir : str
            Path to output-directory. Default: $PWD/logs.
        settings_file : str
            Path to settings file. If None, exptools2's default_settings.yml is used

        attributes
        ----------
        settings : dict
            Dictionary with settings from yaml
        clock : psychopy Clock
            Global clock (reset to 0 at start exp)
        timer : psychopy Clock
            Timer used to time phases
        exp_start : float
            Time at actual start of experiment
        log : psychopy Logfile
            Logfile with info about exp (level >= EXP)
        nr_frames : int
            Counter for number of frames for each phase
        win : psychopy Window
            Current window        
        default_fix : TextStim
            Default fixation stim (a TextStim with '+')
        actual_framerate : float
            Estimated framerate of monitor
        """
        self.output_str = output_str
        self.output_dir = op.join(os.getcwd(),
                                  'logs') if output_dir is None else output_dir
        self.settings_file = settings_file
        self.clock = core.Clock()
        self.timer = core.Clock()
        self.exp_start = None
        self.exp_stop = None
        self.current_trial = None
        self.global_log = pd.DataFrame(columns=[
            'trial_nr', 'onset', 'event_type', 'phase', 'response', 'nr_frames'
        ])
        self.nr_frames = 0  # keeps track of nr of nr of frame flips
        self.first_trial = True
        self.closed = False

        # Initialize
        self.settings = self._load_settings()
        self.monitor = self._create_monitor()
        self.win = self._create_window()
        self.mouse = Mouse(**self.settings['mouse'])
        self.logfile = self._create_logfile()
        self.default_fix = create_circle_fixation(self.win,
                                                  radius=0.075,
                                                  color=(1, 1, 1))
        self.mri_trigger = None  # is set below
        self.mri_simulator = self._setup_mri()
Пример #3
0
    def __init__(self, settings_file=None, eyetracker_on=False):
        """ Initializes base Session class.

        parameters
        ----------
        settings_file : str
            Path to settings file. If None, default_settings.yml is used
        eyetracker_on : bool
            Whether to enable eyetracker
        """
        self.settings_file = settings_file
        self.eyetracker_on=eyetracker_on
        self.clock = Clock()
        self.timer = Clock()
        self.start_exp = None
        self.current_trial = None
        self.log = []
        self.logfile = logging.LogFile(f='log.txt', filemode='w', level=logging.EXP)

        # Initialize
        self.settings = self._load_settings()
        self.monitor = self._create_monitor()
        self.win = self._create_window()
        self.mouse = Mouse(**self.settings['mouse'])
        self.default_fix = Circle(self.win, radius=0.3, fillColor='white', edges=1000)
        self.mri_simulator = self._setup_mri_simulator() if self.settings['mri']['simulate'] else None
        self.tracker = None
 def __init__(self,
              disp,
              width=None,
              height=None,
              margin=None,
              wait_time=0
              ):
     self.window = disp
     self.origin = (0, 0)
     self.wait_time = wait_time
     self.t0 = 0
     if width is not None:
         self.width = width
     else:
         self.width = self.window.hres
     if height is not None:
         self.height = height
     else:
         self.height = self.window.vres
     if margin is not None:
         self.margin = margin
     else:
         self.margin = self.window.margin
     self.continue_button = button.Button(
             window=self.window,
             pos=self.coords(((self.width - 2*self.margin),
                              (self.height - 2*self.margin)
                              ))
             )
     self.move_on_flag = Event()
     self.mouse = Mouse()
 def __init__(self, disp, text, end_event):
     super(EventInstructionsScreen, self).__init__(disp, text)
     self.move_on_flag = end_event
     self.indicator = Circle(self.window, radius=10)
     self.mouse = Mouse()
     self.ticker = 0
     self.ticker_unit = 2*pi/30
     self.ticker_max = 2*pi
     self.indicator_dist = 15
Пример #6
0
class WaitScreen(EventInstructionsScreen):
    
    def __init__(self, disp, text, end_event):
        super(EventInstructionsScreen, self).__init__(disp, text)
        self.move_on_flag = end_event
        self.indicator = Circle(self.window, radius=10)
        self.mouse = Mouse()
        self.ticker = 0
        self.ticker_unit = 2*pi/30
        self.ticker_max = 2*pi
        self.indicator_dist = 15
        
    def draw(self, debug_mode=False):
        self.instructions_text.draw()
        mouse_pos = self.mouse.getPos()
        x = mouse_pos[0] + self.indicator_dist*cos(self.ticker)
        y = mouse_pos[1] + self.indicator_dist*sin(self.ticker)
        self.indicator.pos = (x,y)
        self.indicator.draw()
        self.ticker += self.ticker_unit
        if self.ticker > self.ticker_max:
            self.ticker = 0
Пример #7
0
win = visual.Window(size=(1366, 768),
                    fullscr=True,
                    screen=0,
                    allowGUI=False,
                    allowStencil=False,
                    monitor='testMonitor',
                    color='black',
                    colorSpace='rgb',
                    blendMode='avg',
                    useFBO=True,
                    units='norm')

session, phases = 30, 120
R1, R2, score, phase, zeros, ones = 0, 0, 0, 0, 0, 0
lpressed, rpressed = False, False
mouse = Mouse()
stimuli_timer = CountdownTimer(0)
phase_timer = CountdownTimer(0)
global_time = Clock()
p_list = [0.25, 0.75]

data = []  #array for data
data.append(['time', 'R1', 'R2', 'score', 'number', 'zeros', 'ones',
             'p'])  #column names in csv file

#displayed text
text = TextStim(win=win, pos=(0, 0), text=' ')

#defines click boxes
lbox = Rect(win=win,
            width=0.3,
Пример #8
0
if int(
        info['ID']
) % 2 == 1:  #order of choice on or off (baseline = no aid, on = select an answer, off = agree/disagree with automation)
    a = [0, 1, 2]  # baseline, on, off
else:
    a = [2, 0, 1]  # off, baseline, on

#Equipment set-up:
win = Window([1028, 768],
             monitor="testMonitor",
             units='deg',
             allowGUI=False,
             color=(-.5, -.5, -.5),
             fullscr=True)
myMouse = Mouse()

#Output file set-up
filename = 'Mahoney_exp_' + info['ID'] + '.txt'
logClicks = logging.LogFile(
    filename,
    filemode='a',  #if you set this to 'a' it will append instead of overwriting
    level=logging.CRITICAL)
message = 'ID\tgender\torder\texperiment\tdifficulty\tfalseAlarm\ttrial\tcondition\ttrial.start.time\tsignal\thumanResp\thumanRT\tautoResp\tautoRT\tACC\tstimlength\tRTor\tRTand\n'
logClicks.write(message)

pracfilename = 'Mahoney_exp_practice_' + info['ID'] + '.txt'
logClicksPrac = logging.LogFile(pracfilename,
                                filemode='a',
                                level=logging.CRITICAL)
message2 = 'ID\tage\tgender\torder\texperiment\ttrial\ttrial.start.time\tsignal\thumanResp\thumanRT\tautoResp\tautoRT\ttrialACC\tstimlength\n'
class Screen(object):
    """ Base Screen class, contains methods and data members common to all screens.
    """

    __metaclass__ = abc.ABCMeta
    default_font_size = 40
    
    def __init__(self,
                 disp,
                 width=None,
                 height=None,
                 margin=None,
                 wait_time=0
                 ):
        self.window = disp
        self.origin = (0, 0)
        self.wait_time = wait_time
        self.t0 = 0
        if width is not None:
            self.width = width
        else:
            self.width = self.window.hres
        if height is not None:
            self.height = height
        else:
            self.height = self.window.vres
        if margin is not None:
            self.margin = margin
        else:
            self.margin = self.window.margin
        self.continue_button = button.Button(
                window=self.window,
                pos=self.coords(((self.width - 2*self.margin),
                                 (self.height - 2*self.margin)
                                 ))
                )
        self.move_on_flag = Event()
        self.mouse = Mouse()
        
    def run(self):
        self.t0 = getAbsTime()
        while not self.move_on_flag.is_set():
            if self.continue_button.clickable:
                if self.mouse.isPressedIn(self.continue_button.frame, [0]):
                    self.move_on_flag.set()
            elif self.wait_time > 0:
                if getAbsTime() - self.t0 > self.wait_time:
                    self.continue_button.clickable = True
                else:
                    self.continue_button.clickable = False
            elif self.wait_time == 0:
                self.continue_button.clickable = True
            
            self.draw()
            self.window.flip()
            wait(0.016666, 0.016666)
        self.cleanup()

    @abc.abstractmethod
    def draw(self, debug_mode=False):
        """To override!"""
        
    def cleanup(self):
        """To override!"""
        pass
    
    def _cfg_2_pix(self, dimension, cfg_val):
        if cfg_val < 0:
            return dimension + cfg_val
        elif cfg_val <= 1:
            return self.margin + cfg_val*(dimension - 2*self.margin)
        else:
            return cfg_val
    
    def x_cfg_2_pix(self, cfg_val):
        return self._cfg_2_pix(self.width, cfg_val)
    
    def y_cfg_2_pix(self, cfg_val):
        return self._cfg_2_pix(self.height, cfg_val)
    
    def w_cfg_2_pix(self, cfg_val):
        if cfg_val <= 1:
            return cfg_val*(self.width - 2*self.margin)
        else:
            return cfg_val
        
    def h_cfg_2_pix(self, cfg_val):
        if cfg_val <= 1:
            return cfg_val*(self.height - 2*self.margin)
        else:
            return cfg_val
        
    def dict2text_stim(self, cfg):
        if u'width' in cfg:
            width = self.w_cfg_2_pix(cfg[u'width'])
        else:
            width = None
        text_stim_to_return = TextStim(self.window,
                                       text=cfg[u'text'],
                                       pos=self.coords((self.x_cfg_2_pix(cfg[u'x']),
                                                        self.y_cfg_2_pix(cfg[u'y']))),
                                       height=cfg[u'font_size'],
                                       wrapWidth=width)
        return text_stim_to_return
    
    def coords(self, arg1, arg2=None):
        if arg2 is None:
            coords_tuple = arg1
        else:
            coords_tuple = (arg1, arg2)
        coords_tuple = (coords_tuple[0]+self.origin[0],
                        coords_tuple[1]+self.origin[1])
        return self.window.tl2c(coords_tuple)
Пример #10
0
def run_lextale():
    global trial_num, stim_text, stim_type, stim_status, incorrect, response, rt_start
    print("len(blck_itms):", len(lextale_items))
    maus = Mouse()
    instruction_page.setText(lextale_instructions)
    instruction_page.draw()
    ok_button.draw()
    ok_text.draw()
    win.flip()
    while not maus.isPressedIn(ok_button, buttons=[0]):
        pass

    stopwatch = Clock()
    for trial_num in range(
            len(lextale_items)):  # go through all stimuli of current block
        print("------- Trial number:", trial_num)
        stim_current = lextale_items[trial_num]
        stim_type = stim_current["dummy"]
        stim_text = stim_current["word"]
        stim_status = stim_current["wstatus"]

        center_disp.setText(stim_text)
        draw_labels()
        center_disp.draw()
        win.callOnFlip(stopwatch.reset)
        clearEvents()
        win.flip()
        while True:
            if maus.isPressedIn(right_bg, buttons=[0]):
                rt_start = stopwatch.getTime()
                response = 'yes'
                right_bg.fillColor = "darkgreen"
                draw_labels()
                center_disp.draw()
                win.flip()
                while maus.isPressedIn(right_bg, buttons=[0]):
                    pass
                right_bg.fillColor = "green"
                if stim_status == 1:
                    incorrect = 0
                    if stim_type == 0:
                        lextale_data[
                            'corr_word'] = lextale_data['corr_word'] + 1
                else:
                    incorrect = 1
                break
            elif maus.isPressedIn(left_bg, buttons=[0]):
                rt_start = stopwatch.getTime()
                response = 'no'
                left_bg.fillColor = "darkred"
                draw_labels()
                center_disp.draw()
                win.flip()
                while maus.isPressedIn(left_bg, buttons=[0]):
                    pass
                left_bg.fillColor = "red"
                if stim_status == 0:
                    incorrect = 0
                    if stim_type == 0:
                        lextale_data[
                            'corr_nonword'] = lextale_data['corr_nonword'] + 1
                else:
                    incorrect = 1
                break
            elif len(getKeys(keyList=[escape_key], timeStamped=stopwatch)) > 0:
                end_on_esc(escape_key)
                draw_labels()
                center_disp.draw()
                win.flip()
        add_resp()  # store trial data
Пример #11
0
def showCalibrationResults(logfiledir, calibration_result):
    """shows calibration results on control monitor (screen 0)"""

    DS = CONTROL_DISPSIZE  #(2048, 1152)

    win = visual.Window(size=DS,
                        fullscr=True,
                        winType='pyglet',
                        screen=1,
                        units='pix',
                        color='black')

    kb = Keyboard(keylist=['space', 'r'], timeout=0.1)

    # target points (calibration points) to draw clickable circles
    targetPoints = [
        tobii_norm_2_psy_px(p)
        for p in [(0.5, 0.5), (0.1, 0.9), (0.1, 0.1), (0.9, 0.9), (0.9, 0.1)]
    ]

    clickable_circles = []
    for i in range(len(targetPoints)):
        clickable_circles.append(
            visual.Circle(win,
                          lineColor='red',
                          pos=targetPoints[i],
                          radius=DS[0] / 120,
                          fillColor='green'))

    mouse = Mouse(visible=True, win=win)

    mousePressed = []
    for i in range(len(targetPoints)):
        mousePressed.append(False)

    # texts on screen
    infoText = visual.TextStim(
        win,
        text=
        "Press the \'r\' key to recalibrate or \'space\' to continue and start showing stimuli",
        pos=(0, -0.4 * DS[1]),
        color="white")
    infoText.autoDraw = True

    leftEyeText = visual.TextStim(win,
                                  "Left Eye",
                                  pos=(0, 0.45 * DS[1]),
                                  color="red")
    leftEyeText.autoDraw = True

    rightEyeText = visual.TextStim(win,
                                   "Right Eye",
                                   pos=(0, 0.47 * DS[1]),
                                   color="blue")
    rightEyeText.autoDraw = True

    recalibration_points = []

    # target calibration points and gaze sample points
    for point in calibration_result.calibration_points:

        target = visual.Circle(win,
                               lineColor='green',
                               pos=tobii_norm_2_psy_px(
                                   point.position_on_display_area),
                               radius=DS[0] / 200,
                               fillColor=None)
        target.autoDraw = True

        for sample in point.calibration_samples:
            if sample.left_eye.validity == tr.VALIDITY_VALID_AND_USED:
                leftGazePoint = visual.Circle(
                    win,
                    lineColor="red",
                    pos=tobii_norm_2_psy_px(
                        sample.left_eye.position_on_display_area),
                    radius=DS[0] / 450,
                    lineWidth=DS[0] / 450,
                    fillColor="red")
                leftGazePoint.autoDraw = True

            if sample.right_eye.validity == tr.VALIDITY_VALID_AND_USED:
                rightGazePoint = visual.Circle(
                    win,
                    lineColor="blue",
                    pos=tobii_norm_2_psy_px(
                        sample.right_eye.position_on_display_area),
                    radius=DS[0] / 450,
                    lineWidth=DS[0] / 450,
                    fillColor="blue")
                rightGazePoint.autoDraw = True

    key = kb.get_key()[0]
    k = 0
    while (not (key == 'space' or key == 'r')):

        key = kb.get_key()[0]

        for i in range(len(targetPoints)):
            if (mouse.isPressedIn(clickable_circles[i], buttons=[0])):
                if not mousePressed[i] and k == 0:
                    clickable_circles[i].autoDraw = True
                    mousePressed[i] = True
                    recalibration_points.append(
                        calibration_result.calibration_points[i].
                        position_on_display_area)
                    k = 20

                if mousePressed[i] and k == 0:
                    clickable_circles[i].autoDraw = False
                    mousePressed[i] = False
                    recalibration_points.remove(
                        calibration_result.calibration_points[i].
                        position_on_display_area)
                    k = 20

        win.flip()
        if k > 0:
            k -= 1

    if (key == 'space'):
        win.getMovieFrame(
        )  # Defaults to front buffer, I.e. what's on screen now.
        win.saveMovieFrames("{0}\{1}".format(logfiledir,
                                             "calibration_results.png"))
        win.close()
        return []

    elif (key == 'r'):
        win.close()
        if len(recalibration_points) == 0:
            return [1]
        else:
            return recalibration_points
Пример #12
0
        quit()

    # Also quit in case of invalid participant nr or age
    if exp_info['participant_nr'] > 99 or int(exp_info['age']) < 18:
        quit()
    else:  # let's star the experiment!
        print(
            f"Started experiment for participant {exp_info['participant_nr']} "
            f"with age {exp_info['age']}.")

# Initialize a fullscreen window with my monitor (HD format) size
# and my monitor specification called "samsung" from the monitor center
win = Window(size=(1920, 1080), fullscr=False, monitor='samsung')

# Also initialize a mouse, although we're not going to use it
mouse = Mouse(visible=False)

# Initialize a (global) clock
clock = Clock()

# Initialize Keyboard
kb = Keyboard()
kb.clearEvents()

### START BODY OF EXPERIMENT ###
#
# This is where we'll add stuff from the second
# Coder tutorial.
#
### END BODY OF EXPERIMENT ###
def move_target_at_random_pos(target):
    pos_x = randint(-700, 700)
    pos_y = randint(-400, 400)
    
    new_pos = (pos_x, pos_y)
    target.setPos(new_pos)
    
# I call out the objects I will use and define my DISP and BGC:
DISPSIZE = (1400,800)
BGC = (-1,-1,-1)
score = 0

win = Window(size=DISPSIZE, units='pix', fullscr=False, color=BGC)
target = ImageStim(win, 'target.png', size = (420, 420)) # i created this target in photoshop
mouse = Mouse(win)

mouse_click_clock = Clock()

# The game starts now by drawing the target at a random location:

move_target_at_random_pos(target)

while True:
    target.draw()  
    win.flip()
    
    # since I am still to develop the game, I give myself the option to stop it
    # at any time by pressing 'q' (avoiding the otherwise infinite loop)
    
    keys_pressed = getKeys()
def main():
    # I set up my siplay size and background colour
    DISPSIZE = (1400, 800)
    BGC = (-1, -1, -1)

    # for my game I need to create some variables:
    score = 0
    lives = 3
    level = 1
    mouse_x = 0
    mouse_y = 0

    # I create some objects:
    win = Window(size=DISPSIZE, units='pix', fullscr=False, color=BGC)

    mouse = Mouse(win)

    target = ImageStim(win, 'target.png', size=(420, 420))

    # I will display three text stimuli to the player while playing the game:
    lives_count = TextStim(
        win,
        text=f'Lives = {lives}',
        height=35,
        color=(1, 0.2, 0.6),
        pos=(100, 330),
    )

    score_count = TextStim(win,
                           text=f'Score = {score}',
                           height=35,
                           color=(0.2, 0.2, 0.8),
                           pos=(450, 330))

    level_count = TextStim(win,
                           text=f'Level = {level}',
                           height=35,
                           color=(1, -0.5, 1),
                           pos=(850, 330))

    # I define the messages to show the player the outcome of the game:
    you_have_lost = TextStim(
        win,
        text='Boo! Not a great game, pal... Get it together!',
        height=35,
        color=(0.2, 0.2, 0.8),
        pos=(250, 230))

    you_have_won = TextStim(win,
                            text='Yey! Well done, champ! Time to celebrate!',
                            height=35,
                            color=(0.2, 0.2, 0.8),
                            pos=(250, 230))

    # These are the images I use for the winning and loosing scenarios:
    looser = ImageStim(win, 'failed.jpg', pos=(0, -100), size=(420, 420))
    winner = ImageStim(win, 'tiny_trash.jpg', pos=(0, -100), size=(420, 420))

    # I introduce this dialog to save the user's ID:
    user_id_dialog = gui.Dlg(title="Target Game")
    user_id_dialog.addText('Please write your subject ID: a 4-digit code')
    user_id_dialog.addField('Subject ID:')
    ok_data = user_id_dialog.show()  # show dialog and wait for OK or Cancel

    if not user_id_dialog.OK:
        print('user cancelled')

    # NOW THE GAME WILL START:

    # If enabled, intro will play:
    enable_intro = True

    if enable_intro:
        show_intro(win)

    # We create this list to save our results into
    target_hits_per_level = [
        [],
        [],
        [],
        [],
    ]

    move_target_at_random_pos(
        target)  # first the target is shown on the screen

    lives_timer = CountdownTimer(
        5)  # Level 1 starts with 5 sec to hit the target
    mouse_click_clock = Clock()
    reaction_time_clock = Clock()
    change_target = False

    while level < 4 and lives > 0:
        target.draw()
        target_x, target_y = target.pos
        lives_count.draw()
        score_count.draw()
        level_count.draw()

        win.flip()

        keys_pressed = getKeys()
        if 'q' in keys_pressed:
            break
        mouse_is_pressed = mouse.getPressed()[0] == True

        mouse_x, mouse_y = mouse.getPos()
        level_count.setText(f'Level = {level}')

        #if the player does not click, the target moves and the player looses a life
        if lives_timer.getTime() <= 0:
            lives -= 1
            lives_count.setText(f'Lives = {lives}')
            mouse_in_target = None
            mouse_in_target_x = None
            mouse_in_target_y = None
            change_target = True

        # Check for a mouse click every 0.2s, so that we don't accept more than 1
        # press on mouse hold
        if mouse_is_pressed and mouse_click_clock.getTime() > 0.2:
            mouse_click_clock.reset()
            change_target = True

            if mouse_clicked_in_target(mouse, target):
                mouse_in_target = True
                mouse_in_target_x = mouse_x - target_x
                mouse_in_target_y = mouse_y - target_y
                score += 1
                score_count.setText(f'Score = {score}')

            else:
                lives -= 1
                lives_count.setText(f'Lives = {lives}')
                mouse_in_target = False
                mouse_in_target_x = None
                mouse_in_target_y = None

        if change_target:

            mouse_click = {
                'mouse_x': mouse_in_target_x,
                'mouse_y': mouse_in_target_y,
                'reaction_time': reaction_time_clock.getTime(),
                'mouse_in_target': mouse_in_target,
            }

            target_hits_per_level[level - 1].append(
                mouse_click)  # inddexes start from 0 --> level - 1

            if score == 5:
                lives_timer.reset(3)
                level = 2
            elif score == 10:
                lives_timer.reset(1)
                level = 3
            elif score == 15:
                level = 4

            move_target_at_random_pos(target)
            lives_timer.reset()
            reaction_time_clock.reset()
            change_target = False

    # Here we display the outcome of the game:
    if level == 4:
        you_have_won.draw()
        winner.draw()
    else:
        you_have_lost.draw()
        looser.draw()

    win.flip()
    wait(3)

    # Finally, we draw the overwivew for thr player

    draw_overview_target(
        win=win,
        level=1,
        target_pos=(-450, 0),
        text_pos=(50, 300),
        mouse_clicks_all_levels=target_hits_per_level,
    )

    draw_overview_target(
        win=win,
        level=2,
        target_pos=(0, 0),
        text_pos=(450, 300),
        mouse_clicks_all_levels=target_hits_per_level,
    )

    draw_overview_target(
        win=win,
        level=3,
        target_pos=(450, 0),
        text_pos=(850, 300),
        mouse_clicks_all_levels=target_hits_per_level,
    )

    win.flip()
    wait(4)

    # The user has not clicked Cancel on the subject ID window
    if ok_data is not None:
        write_results(target_hits_per_level, 'results-' + ok_data[0] + '.csv')

    win.close()
Пример #15
0
        'forceboard': False,
        'twochoice': True,
        'trial_table': 'tables/test.csv',
        'adaptive': False
    }  # NB: ignored in the MultiChoice example

    dialog = gui.DlgFromDict(dictionary=settings, title='Replanning')

    if not dialog.OK:
        core.quit()

    # could have a second menu, depending on the experiment
    if settings['twochoice']:
        experiment = TwoChoice(settings=settings)
    else:
        experiment = MultiChoice(settings=settings)

    mouse = Mouse(visible=False, win=experiment.win)
    experiment.coin.play()
    with experiment.device:
        while experiment.state is not 'cleanup':
            experiment.input()  # collect input
            experiment.draw_input()  # draw the input
            experiment.step()  # evaluate any transitions
            if any(mouse.getPressed()):
                experiment.to_cleanup()
            experiment.win.flip()  # flip frame buffer
    experiment.win.close()
    # experiment.win.saveFrameIntervals() # for debugging
    core.quit()
Пример #16
0
from psychopy.event import Mouse
from ctypes import *
from iViewXAPI import *


def trigger_signal():
    Beep(750, 800)  #frequency, HZ, duration, ms
    print 'SIGNAL WAS TRIGGERED'


disp = Window(size=DISPSIZE,
              units='pix',
              color=(-1, -1, -1),
              fullscr=True,
              screen=0)
mouse = Mouse()
stim = Rect(disp,
            pos=RECPOS,
            width=RECSIZE[0],
            height=RECSIZE[1],
            lineColor=(0, 0, 0),
            fillColor=(0, 0, 0),
            lineWidth=3)


def main():

    tracker = Eyetracker(debug=True)
    tracker.connect_to_iView()
    tracker.calibrate()
    tracker.validate()