Esempio n. 1
0
 def __call__(self, candidate: BrainModel):
     candidate.start_recording('IT', time_bins=self._time_bins)
     stimulus_set = place_on_screen(
         self._assembly.stimulus_set,
         target_visual_degrees=candidate.visual_degrees(),
         source_visual_degrees=self._visual_degrees)
     # Temporal recordings from large candidates take up a lot of memory and compute time.
     # In order to quickly reject recordings that are static over time,
     # we will show one image and check whether the recordings vary over time at all or not.
     # If they don't we can quickly score the candidate with a failure state
     # since it will not be able to predict temporal differences with the OST metric
     check_stimulus_set = stimulus_set[:1]
     check_stimulus_set.identifier = None  # unset identifier to avoid storing (interferes with actual stimulus_set)
     check_recordings = candidate.look_at(
         check_stimulus_set, number_of_trials=self._number_of_trials)
     if not temporally_varying(check_recordings):
         score = Score([np.nan, np.nan],
                       coords={'aggregation': ['center', 'error']},
                       dims=['aggregation'])
     else:
         recordings = candidate.look_at(
             stimulus_set, number_of_trials=self._number_of_trials)
         score = self._similarity_metric(recordings, self._assembly)
     score = ceil_score(score, self.ceiling)
     return score
Esempio n. 2
0
 def __call__(self, candidate: BrainModel, do_behavior=False):
     # Do brain region task
     candidate.start_recording(self.region, time_bins=self.timebins)
     source_assembly = candidate.look_at(self.assembly.stimulus_set)
     # Do behavior task
     if do_behavior:
         candidate.start_task(BrainModel.Task.probabilities,
                              self.assembly.stimulus_set)
         candidate.look_at(self.assembly.stimulus_set)
     raw_score = self._similarity_metric(source_assembly, self.assembly)
     return ceil_score(raw_score, self.ceiling)
Esempio n. 3
0
 def __call__(self, candidate: BrainModel, do_behavior=False):
     # Check neural recordings
     candidate.start_recording(self.region, time_bins=self.timebins)
     source_assembly = candidate.look_at(self.assembly.stimulus_set)
     # Check behavioral tasks
     if do_behavior:
         candidate.start_task(BrainModel.Task.probabilities,
                              self.assembly.stimulus_set)
         candidate.look_at(self.assembly.stimulus_set)
         candidate.start_task(BrainModel.Task.label, 'imagenet')
         candidate.look_at(self.assembly.stimulus_set)
     raw_score = self._similarity_metric(source_assembly, self.assembly)
     return ceil_score(raw_score, self.ceiling)
Esempio n. 4
0
 def __call__(self, candidate: BrainModel):
     candidate.start_task(BrainModel.Task.probabilities,
                          self._fitting_stimuli)
     probabilities = candidate.look_at(self._assembly.stimulus_set)
     score = self._metric(probabilities, self._assembly)
     score = self.ceil_score(score, self.ceiling)
     return score
Esempio n. 5
0
 def __call__(self, candidate: BrainModel):
     time_bins = [(time_bin_start, time_bin_start + 10)
                  for time_bin_start in range(70, 250, 10)]
     candidate.start_recording('IT', time_bins=time_bins)
     recordings = candidate.look_at(self._assembly.stimulus_set)
     score = self._similarity_metric(recordings, self._assembly)
     score = ceil_score(score, self.ceiling)
     return score
Esempio n. 6
0
 def __call__(self, candidate: BrainModel):
     time_bins = [(time_bin_start, time_bin_start + 10) for time_bin_start in range(70, 250, 10)]
     candidate.start_recording('IT', time_bins=time_bins)
     stimulus_set = place_on_screen(self._assembly.stimulus_set, target_visual_degrees=candidate.visual_degrees(),
                                    source_visual_degrees=self._visual_degrees)
     recordings = candidate.look_at(stimulus_set)
     score = self._similarity_metric(recordings, self._assembly)
     score = ceil_score(score, self.ceiling)
     return score
Esempio n. 7
0
 def __call__(self, candidate: BrainModel):
     candidate.start_recording(self.region, time_bins=self.timebins)
     stimulus_set = place_on_screen(self._assembly.stimulus_set, target_visual_degrees=candidate.visual_degrees(),
                                    source_visual_degrees=self._visual_degrees)
     source_assembly = candidate.look_at(stimulus_set, number_of_trials=self._number_of_trials)
     if 'time_bin' in source_assembly.dims:
         source_assembly = source_assembly.squeeze('time_bin')  # static case for these benchmarks
     raw_score = self._similarity_metric(source_assembly, self._assembly)
     return explained_variance(raw_score, self.ceiling)
 def __call__(self, candidate: BrainModel):
     fitting_stimuli = place_on_screen(self._fitting_stimuli, target_visual_degrees=candidate.visual_degrees(),
                                       source_visual_degrees=self._visual_degrees)
     candidate.start_task(BrainModel.Task.probabilities, fitting_stimuli)
     stimulus_set = place_on_screen(self._assembly.stimulus_set, target_visual_degrees=candidate.visual_degrees(),
                                    source_visual_degrees=self._visual_degrees)
     probabilities = candidate.look_at(stimulus_set, number_of_trials=self._number_of_trials)
     score = self._metric(probabilities, self._assembly)
     score = self.ceil_score(score, self.ceiling)
     return score
Esempio n. 9
0
def record_from_model(model: BrainModel, stimulus_identifier,
                      number_of_trials):
    stimulus_set = get_stimulus_set(stimulus_identifier)
    stimulus_set = place_on_screen(
        stimulus_set, target_visual_degrees=model.visual_degrees())
    activations = model.look_at(stimulus_set, number_of_trials)
    if 'time_bin' in activations.dims:
        activations = activations.squeeze(
            'time_bin')  # static case for these benchmarks
    if not activations.values.flags['WRITEABLE']:
        activations.values.setflags(write=1)
    return activations
Esempio n. 10
0
    def __call__(self, candidate: BrainModel):
        self._metric = ScanMatchPy.initialize()

        self._logger.info("## Starting visual search task...")
        candidate.start_task(BrainModel.Task.visual_search,
                             max_fix=self.max_fix,
                             data_len=self.data_len,
                             ior_size=self.ior_size)
        self.cumm_perf, self.saccades = candidate.look_at(self._stimuli)
        # in saccades the last index denotes the index at which the target was found
        fix_model = self.saccades[:, :self.max_fix + 1, :]  # first n saccades
        I_fix_model = self.saccades[:, self.max_fix + 1, :
                                    1]  # index at which the target was found
        fix1 = matlab.int32(fix_model.tolist())
        I_fix1 = matlab.int32(I_fix_model.tolist())
        self._logger.info("## Search task done...\n")

        self._logger.info("## Calculating score...")
        scores = []
        for sub_id in tqdm(range(self.num_sub),
                           desc="comparing with human data: "):
            data_human = self._assemblies.values[sub_id *
                                                 self.data_len:(sub_id + 1) *
                                                 self.data_len]
            fix_human = data_human[:, :self.max_fix + 1, :]
            I_fix_human = data_human[:, self.max_fix + 1, :1]
            fix2 = matlab.int32(fix_human.tolist())
            I_fix2 = matlab.int32(I_fix_human.tolist())
            score = self._metric.findScore(fix1, fix2, I_fix1, I_fix2)
            scores.append(score)

        scores = np.asarray(scores)

        self.raw_score = np.mean(scores)
        self.std = np.std(scores) / np.sqrt(scores.shape[0])

        self.model_score = Score([self.raw_score, self.std],
                                 coords={'aggregation': ['center', 'error']},
                                 dims=['aggregation'])

        self._metric.terminate()

        ceiled_score = ceil_score(self.model_score, self.ceiling)
        self._logger.info("## Score calculated...\n")

        return ceiled_score