Пример #1
0
 def __init__(self, win, actors, duration_frames, attn_video_size):
     """
     Initialize class
     :param win: window to use
     :param actors: actors to show
     :param duration_frames: how long to show (in frames)
     """
     self.win = win
     self.actors = actors
     self.duration_frames = duration_frames
     self.left_roi=visual.Rect(self.win, width=550, height=750, units='pix')
     self.left_roi.pos=[deg2pix(-12,win.monitor),deg2pix(0,win.monitor)]
     self.left_roi.lineColor = [1, -1, -1]
     self.left_roi.lineWidth = 10
     self.right_roi=visual.Rect(self.win, width=550, height=750, units='pix')
     self.right_roi.pos=[deg2pix(12,win.monitor),deg2pix(0,win.monitor)]
     self.right_roi.lineColor = [1, -1, -1]
     self.right_roi.lineWidth = 10
     self.attn_video=MovieStimulus(self.win, '', '', 'attn.mpg', attn_video_size)
Пример #2
0
class PreferentialGaze:
    """
    Preferential gaze trial
    """

    def __init__(self, win, actors, duration_frames, attn_video_size):
        """
        Initialize class
        :param win: window to use
        :param actors: actors to show
        :param duration_frames: how long to show (in frames)
        """
        self.win = win
        self.actors = actors
        self.duration_frames = duration_frames
        self.left_roi=visual.Rect(self.win, width=550, height=750, units='pix')
        self.left_roi.pos=[deg2pix(-12,win.monitor),deg2pix(0,win.monitor)]
        self.left_roi.lineColor = [1, -1, -1]
        self.left_roi.lineWidth = 10
        self.right_roi=visual.Rect(self.win, width=550, height=750, units='pix')
        self.right_roi.pos=[deg2pix(12,win.monitor),deg2pix(0,win.monitor)]
        self.right_roi.lineColor = [1, -1, -1]
        self.right_roi.lineWidth = 10
        self.attn_video=MovieStimulus(self.win, '', '', 'attn.mpg', attn_video_size)

    def run(self, ns, eyetracker, mouse, gaze_debug, debug_sq):
        """
        Run trial
        :param ns: netstation connection
        :param eyetracker: eyetracker
        :return:
        """

        # Show actors on random sides of screen
        left_actor = None
        right_actor = None
        if np.random.rand() < 0.5:
            self.actors[0].stim.pos = [-12, 0]
            self.actors[1].stim.pos = [12, 0]
            left_actor = self.actors[0].actor
            right_actor = self.actors[1].actor
        else:
            self.actors[0].stim.pos = [12, 0]
            self.actors[1].stim.pos = [-12, 0]
            left_actor = self.actors[1].actor
            right_actor = self.actors[0].actor

        event.clearEvents()
        mouse.clickReset()
        resp=None
        self.attn_video.reload(self.win)
        self.win.callOnFlip(send_event, ns, eyetracker, 'pgat', 'pg attn', {'left': left_actor, 'rght': right_actor})
        while resp is None:
            while not self.attn_video.stim.status == visual.FINISHED and resp is None:
                self.attn_video.stim.draw()
                self.win.flip()
                buttons, times = mouse.getPressed(getTime=True)
                if buttons[0] and times[0]>0:
                    resp = 'l'
                elif buttons[2] and times[2]>0:
                    resp = 'r'
            self.attn_video.reload(self.win)

        # Draw images
        self.win.callOnFlip(send_event, ns, eyetracker, 'pgst', 'pg start', {'left': left_actor, 'rght': right_actor})
        for i in range(self.duration_frames):
            for actor in self.actors:
                actor.stim.draw()
            draw_eye_debug(gaze_debug, eyetracker, mouse)
            if gaze_debug is not None:
                self.left_roi.draw()
                self.right_roi.draw()
            if debug_sq is not None:
                debug_sq.draw()
            self.win.flip()
        send_event(ns, eyetracker, 'pgen', "pg end", {'left': left_actor, 'rght': right_actor})