Esempio n. 1
0
    def setup(self):

        # Stimulus sizes
        fixation_size = deg_to_px(0.32)
        fixation_thickness = deg_to_px(0.08)
        cue_size = deg_to_px(0.64)
        cue_thickness = deg_to_px(0.08)
        arrow_tail_len = deg_to_px(0.48)
        arrow_tail_width = deg_to_px(0.15)
        arrow_head_len = deg_to_px(0.25)
        arrow_head_width = deg_to_px(0.45, even=True)
        arrow_dimensions = [
            arrow_tail_len, arrow_tail_width, arrow_head_len, arrow_head_width
        ]

        # Stimuli
        self.warning_tone = Tone(50, 'sine', frequency=2000, volume=0.5)
        self.fixation = kld.FixationCross(fixation_size,
                                          fixation_thickness,
                                          fill=WHITE)
        self.cue = kld.Asterisk(cue_size,
                                thickness=cue_thickness,
                                fill=WHITE,
                                spokes=8)

        self.arrow_r = kld.Arrow(*arrow_dimensions, fill=WHITE)
        self.arrow_l = kld.Arrow(*arrow_dimensions, fill=WHITE, rotation=180)
        self.arrow_r.render()
        self.arrow_l.render()

        # Layout
        self.height_offset = deg_to_px(1.3)
        self.flanker_offset = arrow_tail_len + arrow_head_len + deg_to_px(0.16)
        self.above_loc = (P.screen_c[0], P.screen_c[1] - self.height_offset)
        self.below_loc = (P.screen_c[0], P.screen_c[1] + self.height_offset)
        self.cue_locations = {'above': self.above_loc, 'below': self.below_loc}

        # Insert practice block (when applicable)
        if P.run_practice_blocks:
            self.insert_practice_block(block_nums=1, trial_counts=24)

        self.instructions_presented = False
Esempio n. 2
0
    def setup(self):

        # Stimulus sizes

        fixation_size = deg_to_px(0.32)
        fixation_thickness = deg_to_px(0.08)
        cue_size = deg_to_px(0.64)
        cue_thickness = deg_to_px(0.08)
        arrow_tail_len = deg_to_px(0.48)
        arrow_tail_width = deg_to_px(0.15)
        arrow_head_len = deg_to_px(0.25)
        arrow_head_width = deg_to_px(0.45, even=True)
        arrow_dimensions = [
            arrow_tail_len, arrow_tail_width, arrow_head_len, arrow_head_width
        ]

        # Stimuli

        self.warning_tone = Tone(50.1, 'sine', frequency=2000, volume=0.5)
        self.fixation = kld.FixationCross(fixation_size,
                                          fixation_thickness,
                                          fill=BLACK)
        self.cue = kld.Asterisk(cue_size,
                                thickness=cue_thickness,
                                fill=BLACK,
                                spokes=8)
        self.arrow_r = kld.Arrow(*arrow_dimensions, fill=BLACK)
        self.arrow_l = kld.Arrow(*arrow_dimensions, fill=BLACK, rotation=180)
        self.arrow_r.render()
        self.arrow_l.render()

        # Layout

        self.height_offset = deg_to_px(1.3)
        self.height_jitter = deg_to_px(0.04)
        self.flanker_offset = arrow_tail_len + arrow_head_len + deg_to_px(0.16)
        self.ev_offsets = {
            'above': -(self.height_jitter * 4),
            'below': self.height_jitter * 4
        }

        self.above_loc = (P.screen_c[0], P.screen_c[1] - self.height_offset)
        self.below_loc = (P.screen_c[0], P.screen_c[1] + self.height_offset)

        self.cue_locations = {'above': self.above_loc, 'below': self.below_loc}

        # Add text styles for PVT and block messages

        self.txtm.add_style("PVT", '1.5deg', color=RED)
        self.txtm.add_style("block_msg", '0.6deg', color=BLACK)

        # If it's the first session, insert practice blocks with feedback

        if P.run_practice_blocks and P.session_number == 1:
            ANTI_only = ['ANTI-valid', 'ANTI-invalid', 'ANTI-none']
            ANTI_EV = copy(ANTI_only) * 2 + ['EV-above', 'EV-below'
                                             ] * 3  # 1/2 ANTI, 1/2 EV
            ANTI_EV_AV = copy(ANTI_EV) + ['AV'] * 6  # 1/3 ANTI, 1/3 EV, 1/3 AV
            self.insert_practice_block(1,
                                       trial_counts=16,
                                       factor_mask={'trial_type': ANTI_only})
            self.insert_practice_block(2,
                                       trial_counts=32,
                                       factor_mask={'trial_type': ANTI_EV})
            self.insert_practice_block(3,
                                       trial_counts=48,
                                       factor_mask={'trial_type': ANTI_EV_AV})
Esempio n. 3
0
    def setup(self):

        # Stimulus sizes

        fixation_size = deg_to_px(0.5)
        fixation_thickness = deg_to_px(0.05)
        cue_size = deg_to_px(0.5)
        cue_thickness = deg_to_px(0.05)
        arrow_tail_len = deg_to_px(0.35)
        arrow_tail_width = deg_to_px(0.1)
        arrow_head_len = deg_to_px(0.2)
        arrow_head_width = deg_to_px(0.3, even=True)

        # Stimuli

        self.fixation = kld.FixationCross(fixation_size,
                                          fixation_thickness,
                                          fill=BLACK)
        self.cue = kld.Asterisk(cue_size,
                                thickness=cue_thickness,
                                fill=BLACK,
                                spokes=8)
        self.arrow_l = kld.Arrow(arrow_tail_len,
                                 arrow_tail_width,
                                 arrow_head_len,
                                 arrow_head_width,
                                 fill=BLACK,
                                 rotation=180)
        self.arrow_r = kld.Arrow(arrow_tail_len,
                                 arrow_tail_width,
                                 arrow_head_len,
                                 arrow_head_width,
                                 fill=BLACK)
        self.line = kld.Rectangle(arrow_tail_len + arrow_head_len,
                                  arrow_tail_width,
                                  stroke=[0, BLACK, 1],
                                  fill=BLACK)
        self.arrow_l.render()
        self.arrow_r.render()

        # Layout

        height_offset = deg_to_px(1.06)
        flanker_offset = arrow_tail_len + arrow_head_len + deg_to_px(0.06)
        self.above_loc = (P.screen_c[0], P.screen_c[1] - height_offset)
        self.below_loc = (P.screen_c[0], P.screen_c[1] + height_offset)
        self.above_flanker_locs = []
        self.below_flanker_locs = []
        for offset in [-2, -1, 1, 2]:
            x_pos = P.screen_c[0] + (offset * flanker_offset)
            self.above_flanker_locs.append((x_pos, self.above_loc[1]))
            self.below_flanker_locs.append((x_pos, self.below_loc[1]))

        # Initialize feedback messages for practice block

        timeout_msg = message('Too slow! Please try to respond more quickly.',
                              blit_txt=False)
        incorrect_str = (
            "Incorrect response!\n"
            "Please respond to left arrows with the 'z' key and right arrows with the '/' key."
        )
        incorrect_msg = message(incorrect_str, align='center', blit_txt=False)

        self.feedback_msgs = {
            'incorrect': incorrect_msg,
            'timeout': timeout_msg
        }

        # Set up Response Collector to get keypress responses

        self.rc.uses(KeyPressResponse)
        self.rc.terminate_after = [1700, TK_MS
                                   ]  # response period times out after 1700ms
        self.rc.keypress_listener.interrupts = True
        self.rc.keypress_listener.key_map = {'z': 'left', '/': 'right'}

        # Add practice block of 24 trials to start of experiment

        if P.run_practice_blocks:
            self.insert_practice_block(1, trial_counts=24)
Esempio n. 4
0
    def setup(self):

        # Initialize text styles

        self.txtm.add_style('normal', '0.7deg')
        self.txtm.add_style('title', '1.0deg')
        self.txtm.add_style('stream', '1.5deg')

        # Stimulus sizes

        mask_size = deg_to_px(1.5)
        mask_thick = deg_to_px(0.25)
        acc_size = deg_to_px(0.5)
        acc_offset = deg_to_px(3.0)
        arrow_tail_l = deg_to_px(0.5)
        arrow_tail_w = deg_to_px(0.2)
        arrow_head_l = deg_to_px(0.3)
        arrow_head_w = deg_to_px(0.5, even=True)
        box_size = deg_to_px(2.0)
        box_stroke = deg_to_px(0.2)

        # Generate shape stimuli for instructions

        self.arrow = kld.Arrow(arrow_tail_l, arrow_tail_w, arrow_head_l,
                               arrow_head_w)
        self.arrow.fill = P.default_color
        self.target_box = kld.Rectangle(box_size,
                                        stroke=[box_stroke, P.default_color])

        # Generate shape stimuli for task

        self.accuracy_rect = kld.Rectangle(acc_offset,
                                           acc_offset + acc_size * 2,
                                           fill=P.default_color)
        self.accuracy_mask = kld.Rectangle(acc_offset + 2,
                                           acc_offset,
                                           fill=P.default_fill_color)
        self.mask = kld.Asterisk(mask_size, mask_thick, fill=P.default_color)

        # Select random letters from the alphabet and render for use in task

        alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
        random.shuffle(alphabet)
        self.letter_set = alphabet[:P.set_size]
        self.letters = {}
        for letter in self.letter_set:
            self.letters[letter] = message(letter,
                                           style='stream',
                                           blit_txt=False)

        # Initialize thought probes

        self.probe_condition = P.condition_map[P.condition]
        self.probe = self._init_probe(self.probe_condition)

        # Determine proportion of non-nback trials

        is_nback = self.trial_factory.exp_factors['is_target']
        self.nback_rate = sum(is_nback) / len(is_nback)

        # Determine order of difficulty levels (counterbalancing)

        self.first_nback = random.choice([1, 2])

        # Show task instructions and example thought probe

        self.instructions()

        # Add practice blocks to start of task

        if P.run_practice_blocks:
            self.insert_practice_block(1, trial_counts=48)
            self.insert_practice_block(2, trial_counts=48)