Example #1
0
 def automatic_buffering(self, stim):
     """
     Buffer visual object automatically.
     """
     temp_dict = {key: stim[key] for key in stim if key != 'position' and key != 'text' and key != 'vis_delay'}
     temp_dict.update({'screen_pos': chunks.Chunk(utilities.VISUALLOCATION, **{'screen_x': stim['position'][0], 'screen_y': stim['position'][1]}), 'value': stim['text']})
     new_chunk = chunks.Chunk(utilities.VISUAL, **temp_dict)
     
     if new_chunk:
         angle_distance = 2*utilities.calculate_visual_angle(self.current_focus, (stim['position'][0], stim['position'][1]), self.environment.size, self.environment.simulated_screen_size, self.environment.viewing_distance) #the stimulus has to be within 2 degrees from the focus (foveal region)
         encoding_time = utilities.calculate_delay_visual_attention(angle_distance=angle_distance, K=self.model_parameters["eye_mvt_scaling_parameter"], k=self.model_parameters['eye_mvt_angle_parameter'], emma_noise=self.model_parameters['emma_noise'], vis_delay=stim.get('vis_delay'))
     return new_chunk, encoding_time
Example #2
0
    def automatic_buffering(self, stim, model_parameters):
        """
        Buffer visual object automatically.
        """
        model_parameters = model_parameters.copy()
        model_parameters.update(self.model_parameters)

        temp_dict = {key: stim[key] for key in stim if key != 'position' and key != 'text' and key != 'vis_delay'}
        temp_dict.update({'screen_pos': chunks.Chunk(utilities.VISUALLOCATION, **{'screen_x': stim['position'][0], 'screen_y': stim['position'][1]}), 'value': stim['text']})
        new_chunk = chunks.Chunk(utilities.VISUAL, **temp_dict)
        
        if new_chunk:
            angle_distance = 2*utilities.calculate_visual_angle(self.environment.current_focus, (stim['position'][0], stim['position'][1]), self.environment.size, self.environment.simulated_screen_size, self.environment.viewing_distance) #the stimulus has to be within 2 degrees from the focus (foveal region)
            encoding_time = utilities.calculate_delay_visual_attention(angle_distance=angle_distance, K=model_parameters["eye_mvt_scaling_parameter"], k=model_parameters['eye_mvt_angle_parameter'], emma_noise=model_parameters['emma_noise'], vis_delay=stim.get('vis_delay'))
        return new_chunk, encoding_time
Example #3
0
    def shift(self, otherchunk, harvest=None, actrvariables=None):
        """
        Return a chunk, time needed to attend and shift eye focus to the chunk, and the landing site of eye mvt.
        """
        if actrvariables == None:
            actrvariables = {}
        try:
            mod_attr_val = {x[0]: utilities.check_bound_vars(actrvariables, x[1]) for x in otherchunk.removeunused()} #creates dict of attr-val pairs according to otherchunk
        except ACTRError as arg:
            raise ACTRError("The chunk '%s' is not defined correctly; %s" % (otherchunk, arg))

        vis_delay = None

        for each in self.environment.stimulus:
            try:
                if self.environment.stimulus[each]['position'] == (float(mod_attr_val['screen_pos'].screen_x), float(mod_attr_val['screen_pos'].screen_y)):
                    mod_attr_val['value'] = self.environment.stimulus[each]['text']
                    vis_delay = self.environment.stimulus[each].get('vis_delay')
            except (AttributeError, KeyError):
                raise ACTRError("The chunk in the visual buffer is not defined correctly. It is not possible to move attention.")

        new_chunk = chunks.Chunk(self._VISUAL, **mod_attr_val) #creates new chunk

        if new_chunk.cmd not in utilities.CMDVISUAL:
            raise ACTRError("Visual module received an invalid command: '%s'. The valid commands are: '%s'" % (new_chunk.cmd, utilities.CMDVISUAL))

        if new_chunk.cmd == utilities.CMDMOVEATTENTION and self.model_parameters['emma']:
            angle_distance = utilities.calculate_visual_angle(self.current_focus, [float(new_chunk.screen_pos.screen_x), float(new_chunk.screen_pos.screen_y)], self.environment.size, self.environment.simulated_screen_size, self.environment.viewing_distance)
            encoding_time = utilities.calculate_delay_visual_attention(angle_distance=angle_distance, K=self.model_parameters["eye_mvt_scaling_parameter"], k=self.model_parameters['eye_mvt_angle_parameter'], emma_noise=self.model_parameters['emma_noise'], vis_delay=vis_delay)
            preparation_time = utilities.calculate_preparation_time(emma_noise=self.model_parameters['emma_noise'])
            execution_time = utilities.calculate_execution_time(angle_distance, emma_noise=self.model_parameters['emma_noise'])
            landing_site = utilities.calculate_landing_site([float(new_chunk.screen_pos.screen_x), float(new_chunk.screen_pos.screen_y)], angle_distance, emma_landing_site_noise=self.model_parameters['emma_landing_site_noise'])
        elif new_chunk.cmd == utilities.CMDMOVEATTENTION and not self.model_parameters['emma']:
            encoding_time = 0.085
            preparation_time = 0
            execution_time = 0.085
            landing_site = (float(new_chunk.screen_pos.screen_x), float(new_chunk.screen_pos.screen_y))
        else:
            raise ACTRError("Visual module received an invalid command: '%s'. The only valid command currently is: %s" % (new_chunk.cmd, utilities.CMDMOVEATTENTION))
        return new_chunk, (encoding_time, preparation_time, execution_time), landing_site
    def shift(self, otherchunk, harvest=None, actrvariables=None, model_parameters=None):
        """
        Return a chunk, time needed to attend and shift eye focus to the chunk, and the landing site of eye mvt.
        """
        if model_parameters == None:
            model_parameters = {}
        model_parameters = model_parameters.copy()
        model_parameters.update(self.model_parameters)

        if actrvariables == None:
            actrvariables = {}
        try:
            mod_attr_val = {x[0]: utilities.check_bound_vars(actrvariables, x[1]) for x in otherchunk.removeunused()}
        except ACTRError as arg:
            raise ACTRError("Shifting towards the chunk '%s' is impossible; %s" % (otherchunk, arg))

        vis_delay = None

        for each in self.environment.stimulus:
            try:
                if self.environment.stimulus[each]['position'] == (float(mod_attr_val['screen_pos'].values.screen_x.values), float(mod_attr_val['screen_pos'].values.screen_y.values)):
                    mod_attr_val['value'] = self.environment.stimulus[each]['text']
                    vis_delay = self.environment.stimulus[each].get('vis_delay')
            except (AttributeError, KeyError):
                raise ACTRError("The chunk in the visual buffer is not defined correctly. It is not possible to move attention.")

        new_chunk = chunks.Chunk(self._VISUAL, **mod_attr_val) #creates new chunk

        if model_parameters['emma']:
            angle_distance = utilities.calculate_visual_angle(self.environment.current_focus, [float(new_chunk.screen_pos.values.screen_x.values), float(new_chunk.screen_pos.values.screen_y.values)], self.environment.size, self.environment.simulated_screen_size, self.environment.viewing_distance)
            encoding_time = utilities.calculate_delay_visual_attention(angle_distance=angle_distance, K=model_parameters["eye_mvt_scaling_parameter"], k=model_parameters['eye_mvt_angle_parameter'], emma_noise=model_parameters['emma_noise'], vis_delay=vis_delay)
            preparation_time = utilities.calculate_preparation_time(emma_noise=model_parameters['emma_noise'], emma_preparation_time=model_parameters['emma_preparation_time'])
            execution_time = utilities.calculate_execution_time(angle_distance, emma_noise=model_parameters['emma_noise'])
            landing_site = utilities.calculate_landing_site([float(new_chunk.screen_pos.values.screen_x.values), float(new_chunk.screen_pos.values.screen_y.values)], angle_distance, emma_landing_site_noise=model_parameters['emma_landing_site_noise'])
        elif not model_parameters['emma']:
            encoding_time = 0.085
            preparation_time = 0
            execution_time = 0.085
            landing_site = (float(new_chunk.screen_pos.values.screen_x.values), float(new_chunk.screen_pos.values.screen_y.values))
        return new_chunk, (encoding_time, preparation_time, execution_time), landing_site
Example #5
0
    def shift(self, otherchunk, harvest=None, actrvariables=None, model_parameters=None):
        """
        Return a chunk, time needed to attend and shift eye focus to the chunk, and the landing site of eye mvt.
        """
        if model_parameters == None:
            model_parameters = {}
        model_parameters = model_parameters.copy()
        model_parameters.update(self.model_parameters)

        if actrvariables == None:
            actrvariables = {}
        try:
            mod_attr_val = {x[0]: utilities.check_bound_vars(actrvariables, x[1]) for x in otherchunk.removeunused()}
        except ACTRError as arg:
            raise ACTRError("Shifting towards the chunk '%s' is impossible; %s" % (otherchunk, arg))

        vis_delay = None

        for each in self.environment.stimulus:
            try:
                if self.environment.stimulus[each]['position'] == (float(mod_attr_val['screen_pos'].values.screen_x.values), float(mod_attr_val['screen_pos'].values.screen_y.values)):
                    mod_attr_val['value'] = self.environment.stimulus[each]['text']
                    vis_delay = self.environment.stimulus[each].get('vis_delay')
            except (AttributeError, KeyError):
                raise ACTRError("The chunk in the visual buffer is not defined correctly. It is not possible to move attention.")

        new_chunk = chunks.Chunk(self._VISUAL, **mod_attr_val) #creates new chunk

        if model_parameters['emma']:
            angle_distance = utilities.calculate_visual_angle(self.environment.current_focus, [float(new_chunk.screen_pos.values.screen_x.values), float(new_chunk.screen_pos.values.screen_y.values)], self.environment.size, self.environment.simulated_screen_size, self.environment.viewing_distance)
            encoding_time = utilities.calculate_delay_visual_attention(angle_distance=angle_distance, K=model_parameters["eye_mvt_scaling_parameter"], k=model_parameters['eye_mvt_angle_parameter'], emma_noise=model_parameters['emma_noise'], vis_delay=vis_delay)
            preparation_time = utilities.calculate_preparation_time(emma_noise=model_parameters['emma_noise'])
            execution_time = utilities.calculate_execution_time(angle_distance, emma_noise=model_parameters['emma_noise'])
            landing_site = utilities.calculate_landing_site([float(new_chunk.screen_pos.values.screen_x.values), float(new_chunk.screen_pos.values.screen_y.values)], angle_distance, emma_landing_site_noise=model_parameters['emma_landing_site_noise'])
        elif not model_parameters['emma']:
            encoding_time = 0.085
            preparation_time = 0
            execution_time = 0.085
            landing_site = (float(new_chunk.screen_pos.values.screen_x.values), float(new_chunk.screen_pos.values.screen_y.values))
        return new_chunk, (encoding_time, preparation_time, execution_time), landing_site