def _compute_ratemap(self, min_duration=None):
"""
min_duration is the min duration in seconds for a bin to be
considered 'valid'; if too few observations were made, then the
firing rate is kept at an estimate of 0. If min_duration == 0,
then all the spikes are used.
"""
if min_duration is None:
min_duration = self._min_duration
x, y = self.trans_func(self._extern, at=self._bst.bin_centers)
ext_bin_idx_x = np.digitize(x, self.xbins, True)
ext_bin_idx_y = np.digitize(y, self.ybins, True)
# make sure that all the events fit between extmin and extmax:
# TODO: this might rather be a warning, but it's a pretty serious warning...
if ext_bin_idx_x.max() > self.n_xbins:
raise ValueError("ext values greater than 'ext_xmax'")
if ext_bin_idx_x.min() == 0:
raise ValueError("ext values less than 'ext_xmin'")
if ext_bin_idx_y.max() > self.n_ybins:
raise ValueError("ext values greater than 'ext_ymax'")
if ext_bin_idx_y.min() == 0:
raise ValueError("ext values less than 'ext_ymin'")
ratemap = np.zeros((self.n_units, self.n_xbins, self.n_ybins))
for tt, (bidxx, bidxy) in enumerate(zip(ext_bin_idx_x, ext_bin_idx_y)):
ratemap[:,bidxx-1, bidxy-1] += self._bst.data[:,tt]
# apply minimum observation duration
for uu in range(self.n_units):
ratemap[uu][self.occupancy*self._bst.ds < min_duration] = 0
return ratemap / self._bst.ds
评论列表
文章目录