示例#1
0
 def plot(self):
     correlograms, bins = compute_correlograms(self.sorting, **self.compute_kwargs)
     bin_width = bins[1] - bins[0]
     unit_ids = self.sorting.unit_ids
     for i, unit_id in enumerate(unit_ids):
         ccg = correlograms[i, i]
         ax = self.axes.flatten()[i]
         color = 'g'
         ax.bar(x=bins[:-1], height=ccg, width=bin_width, color=color, align='edge')
         ax.set_title(str(unit_id))
def test_compute_correlograms():
    repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
    remote_path = 'mearec/mearec_test_10s.h5'
    local_path = download_dataset(repo=repo,
                                  remote_path=remote_path,
                                  local_folder=None)
    # ~ recording = se.MEArecRecordingExtractor(local_path)
    sorting = se.MEArecSortingExtractor(local_path)

    unit_ids = sorting.unit_ids
    sorting2 = sorting.select_units(unit_ids[:3])
    correlograms, bins = compute_correlograms(sorting2)
    def compute_correlograms(self):

        correlograms_1, bins = compute_correlograms(self.sorting1,
                                                    **self.compute_kwargs)
        correlograms_2, bins = compute_correlograms(self.sorting2,
                                                    **self.compute_kwargs)

        self.good_sorting = self.get_well_detected_units(
            self.well_detected_score)
        self.good_gt = self.hungarian_match_21[self.good_sorting].values
        self.good_idx_gt = self.sorting1.ids_to_indices(self.good_gt)
        self.good_idx_sorting = self.sorting2.ids_to_indices(self.good_sorting)

        #order = np.argsort(self.good_idx_gt)
        #self.good_idx_gt = self.good_idx_gt[order]

        if len(self.good_idx_gt) > 0:
            correlograms_1 = correlograms_1[self.good_idx_gt, :, :]
            self.correlograms['true'] = correlograms_1[:, self.good_idx_gt, :]

        if len(self.good_idx_sorting) > 0:
            correlograms_2 = correlograms_2[self.good_idx_sorting, :, :]
            self.correlograms[
                'estimated'] = correlograms_2[:, self.good_idx_sorting, :]

        if len(self.good_idx_gt) > 0:
            self.nb_cells = self.correlograms['true'].shape[0]
            self.nb_timesteps = self.correlograms['true'].shape[2]
        else:
            self.nb_cells = 0
            self.nb_timesteps = 11
            self.correlograms['true'] = np.zeros((0, 0, self.nb_timesteps))
            self.correlograms['estimated'] = np.zeros(
                (0, 0, self.nb_timesteps))

        self._center = self.nb_timesteps // 2
示例#4
0
    def plot(self):
        correlograms, bins = compute_correlograms(self.sorting, **self.compute_kwargs)
        bin_width = bins[1] - bins[0]
        unit_ids = self.sorting.unit_ids
        for i, unit_id1 in enumerate(unit_ids):
            for j, unit_id2 in enumerate(unit_ids):
                ccg = correlograms[i, j]
                ax = self.axes[i, j]
                if i == j:
                    color = 'g'
                else:
                    color = 'k'
                ax.bar(x=bins[:-1], height=ccg, width=bin_width, color=color, align='edge')

        for i, unit_id in enumerate(unit_ids):
            self.axes[0, i].set_title(str(unit_id))
            self.axes[-1, i].set_xlabel('CCG (ms)')