def trial(self):


        while self.evm.before('cue_on'):
            self.wait_time()

        self.display_refresh(cue=True)

        while self.evm.before('cue_off'):
            self.wait_time()


        self.display_refresh()

        while self.evm.before('target_on'):
            self.wait_time()

        flush()

        self.display_refresh(target=True)

        if P.saccade_response_cond:
            self.record_saccades()
            keypress_rt = 'NA'

        if P.keypress_response_cond:
            self.rc.collect()
            keypress_rt = self.rc.keypress_listener.response(rt=True, value=False)

        clear()
        smart_sleep(1000)

        if P.keypress_response_cond:
            if self.target_location == "catch" and keypress_rt != TIMEOUT:
                fill()
                message(self.err_msgs['early'], registration=5, location=P.screen_c)
                flip()
                any_key()
            elif self.moved_eyes_during_rc:
                fill()
                message("Moved eyes during response interval!", registration=5, location=P.screen_c)
                flip()
                any_key()

        return {
            "block_num": P.block_number,
            "trial_num": P.trial_number,
            'session_type': 'saccade' if P.saccade_response_cond else 'keypress',
            'box_alignment': self.box_alignment,
            'cue_location': self.cue_location,
            'target_location': self.target_location,
            'target_acquired': str(self.target_acquired).upper() if P.saccade_response_cond else NA,
            'keypress_rt': keypress_rt if P.keypress_response_cond else NA,
            'moved_eyes': str(self.moved_eyes_during_rc).upper() if P.keypress_response_cond else NA

        }
Exemplo n.º 2
0
    def present_feedback(self, rt, response):

        fill()

        if rt is not NA:
            # Round off decimals
            msg = int(rt)

        else:
            msg = "Respond faster!"

        style = "correct" if response == self.target_side else 'incorrect'

        message(msg, style=style, location=P.screen_c, registration=5, blit_txt=True)

        flip()

        smart_sleep(400)
Exemplo n.º 3
0
    def trial(self):

        while self.evm.before("cross fix end"):
            self.jc_wait_time()
            self.display_refresh(self.start_axis, self.cross_w)

        while self.evm.before("circle fix end"):
            self.jc_wait_time()
            self.display_refresh(self.start_axis, self.circle)

        while self.evm.before("cue end"):
            self.jc_wait_time()
            self.display_refresh(self.start_axis,
                                 self.circle,
                                 cue=self.cue_location)

        while self.evm.before("circle box end"):
            self.jc_wait_time()
            self.display_refresh(self.start_axis, self.circle)

        current_frame = 0
        while self.evm.before("animation end"):
            self.jc_wait_time()
            if self.animation_trial:
                if current_frame < self.animation_frames:
                    if self.evm.trial_time_ms > (
                            current_frame * self.frame_duration + 1600):
                        box_locs = self.frames[self.start_axis][
                            self.rotation_dir][current_frame]
                        self.display_refresh(box_locs, self.asterisk)
                        current_frame += 1
            else:
                self.display_refresh(self.start_axis, self.asterisk)

        while self.evm.before("asterisk end"):
            self.display_refresh(self.box_axis_during_target(), self.circle)
            self.jc_wait_time()

        flush()
        self.display_refresh(self.box_axis_during_target(),
                             self.circle,
                             target=self.target_location)

        if P.saccade_response_cond:
            self.jc_saccade_data()
            keypress_rt = NA

        if P.keypress_response_cond:
            self.rc.collect()
            keypress_rt = self.rc.keypress_listener.response(rt=True,
                                                             value=False)

        clear()
        smart_sleep(1000)

        if P.keypress_response_cond:
            if self.target_location == "none" and keypress_rt != TIMEOUT:
                fill()
                message(self.err_msgs['early'],
                        registration=5,
                        location=P.screen_c)
                flip()
                any_key()
            elif self.moved_eyes_during_rc:
                fill()
                message("Moved eyes during response interval!",
                        registration=5,
                        location=P.screen_c)
                flip()
                any_key()

        return {
            "block_num":
            P.block_number,
            "trial_num":
            P.trial_number,
            "session_type":
            'saccade' if P.saccade_response_cond else 'keypress',
            "cue_location":
            self.cue_location,
            "target_location":
            self.target_location,
            "start_axis":
            self.start_axis,
            "box_rotation":
            self.rotation_dir if self.animation_trial else NA,
            "animation_trial":
            str(self.animation_trial).upper(),
            "target_acquired":
            str(self.target_acquired).upper()
            if P.saccade_response_cond else NA,
            "keypress_rt":
            keypress_rt,
            "moved_eyes":
            str(self.moved_eyes_during_rc).upper()
            if P.keypress_response_cond else NA
        }
Exemplo n.º 4
0
    def present_instructions(self):

        msg = "During this experiment, each trial will begin with a cross centre-screen."

        self.anykey_msg(msg)

        fill()
        blit(self.fixation, location=P.screen_c, registration=5)
        flip()
        smart_sleep(1000)

        msg = ("When you see this, press spacebar to start the rest of the trial.\n" +
               "Once you do, four boxes will appear around it.")

        self.anykey_msg(msg)

        fill()
        blit(self.fixation, location=P.screen_c, registration=5)
        flip()

        smart_sleep(500)

        self.display_refresh()
        smart_sleep(1000)

        msg = ("Since you start each trial yourself, if your eyes get tired\n" +
               "you can take a moment before starting the next trial.")

        self.anykey_msg(msg)

        msg = "Shortly after the boxes appear, \nsome number of boxes may 'flash' and a tone might be played."

        self.anykey_msg(msg)

        self.cue_type = TEMP_CUE
        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(cue=True, tone=True)
        smart_sleep(50)
        self.display_refresh()
        smart_sleep(1000)

        msg = "Once the boxes return to normal, a white circle will appear shortly after in one of the boxes."

        self.anykey_msg(msg)

        msg = ("If only the left or right boxes flash, the circle will appear on that side.\n" +
               "If all, or none, of the boxes flash, then the circle could appear on either side."
               )

        self.anykey_msg(msg)

        self.cue_type = VIS_LEFT
        self.target_loc = TOP_LEFT

        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(cue=True, tone=True)
        smart_sleep(50)
        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(target=True)
        smart_sleep(600)

        fill()
        blit(self.fixation, location=P.screen_c, registration=5)
        flip()
        smart_sleep(500)

        self.cue_type = VIS_RIGHT
        self.target_loc = BOTTOM_RIGHT

        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(cue=True)
        smart_sleep(50)
        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(target=True)
        smart_sleep(600)

        fill()
        blit(self.fixation, location=P.screen_c, registration=5)
        flip()
        smart_sleep(500)

        self.cue_type = TEMP_CUE
        self.target_loc = TOP_RIGHT

        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(cue=True, tone=True)
        smart_sleep(50)
        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(target=True)
        smart_sleep(600)

        fill()
        blit(self.fixation, location=P.screen_c, registration=5)
        flip()
        smart_sleep(500)

        self.cue_type = TEMP_CUE
        self.target_loc = BOTTOM_LEFT

        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(cue=True, tone=True)
        smart_sleep(50)
        self.display_refresh()
        smart_sleep(250)
        self.display_refresh(target=True)
        smart_sleep(600)

        msg = ("Once the target appears, you task is to indicate on which side it appeared.\n" +
               "{0} key = left boxes, {1} key = right boxes"
               ).format(self.left_key.upper(), self.right_key.upper())

        self.anykey_msg(msg)

        msg = ("When you make a response, your reaction time will be provided to you.\n" +
               "Otherwise, you'll be asked to respond faster.\nTry to keep this number as" +
               " low as possible, while remaining accurate.")

        self.anykey_msg(msg)

        msg = ("Feedback for correct responses will be provided in white.\n" +
               "For incorrect responses, it will be in red.")

        self.anykey_msg(msg)

        msg = "The experiment will now begin with a few practice rounds to familiarize you with the task."

        self.anykey_msg(msg)
Exemplo n.º 5
0
    def trial(self):
        hide_mouse_cursor()

        # Begin with empty array...
        self.present_empty_array()

        smart_sleep(500)

        # 500ms later present prime array & record response
        self.prime_rc.collect()

        # If response, log, otherwise NA
        response_prime, rt_prime = 'NA', 'NA'

        if len(self.prime_rc.keypress_listener.response()):
            response_prime, rt_prime = self.prime_rc.keypress_listener.response(
            )

        # Reset to empty array following response
        self.present_empty_array()

        smart_sleep(300)

        # 300ms later present probe array
        self.probe_rc.collect()

        response_probe, rt_probe = 'NA', 'NA'

        if len(self.probe_rc.keypress_listener.response()):
            response_probe, rt_probe = self.probe_rc.keypress_listener.response(
            )

        # Determine accuracy of responses (i.e., whether target selected)
        prime_correct = response_prime == self.T_prime_loc[1]
        probe_correct = response_probe == self.T_probe_loc[1]

        # Present feedback on performance (mean RT for correct, 'WRONG' for incorrect)
        self.present_feedback(prime_correct, rt_prime, probe_correct, rt_probe)

        prime_choice, probe_choice = 'NA', 'NA'

        if response_prime == self.T_prime_loc[1]:
            prime_choice = 'target'
        elif response_prime == self.D_prime_loc[1]:
            prime_choice = 'distractor'
        else:
            prime_choice = "empty_cell"

        if response_probe == self.T_probe_loc[1]:
            probe_choice = 'target'
        elif response_probe == self.D_probe_loc[1]:
            probe_choice = 'distractor'
        else:
            probe_choice = "empty_cell"

        return {
            "block_num": P.block_number,
            "trial_num": P.trial_number,
            "practicing": str(P.practicing),
            "far_near": self.far_or_near,
            'trial_type': self.trial_type,
            'prime_rt': rt_prime,
            'probe_rt': rt_probe,
            'prime_correct': str(prime_correct),
            'probe_correct': str(probe_correct),
            't_prime_to_t_probe': self.T_prime_to_T_probe,
            't_prime_to_d_probe': self.T_prime_to_D_probe,
            'd_prime_to_t_probe': self.D_prime_to_T_probe,
            'd_prime_to_d_probe': self.D_prime_to_D_probe,
            'prime_choice': prime_choice,
            'probe_choice': probe_choice,
            'prime_response': response_prime,
            'probe_response': response_probe,
            't_prime_loc': self.T_prime_loc[1],
            'd_prime_loc': self.D_prime_loc[1],
            't_probe_loc': self.T_probe_loc[1],
            'd_probe_loc': self.D_probe_loc[1]
        }