def _set_bin_window(self, bin_size=None, window_size=None): """Set the bin and window sizes (in seconds).""" bin_size = bin_size or self.bin_size window_size = window_size or self.window_size bin_size = _clip(bin_size, 1e-6, 1e3) window_size = _clip(window_size, 1e-6, 1e3) assert 1e-6 <= bin_size <= 1e3 assert 1e-6 <= window_size <= 1e3 assert bin_size < window_size self.bin_size = bin_size self.window_size = window_size self.update_status()
def _compute_histogram(data, x_max=None, x_min=0, n_bins=None, normalize=True, ignore_zeros=False): """Compute the histogram of an array.""" assert x_min <= x_max assert n_bins >= 0 n_bins = _clip(n_bins, 2, 1000000) bins = np.linspace(float(x_min), float(x_max), int(n_bins)) if ignore_zeros: data = data[data != 0] histogram, _ = np.histogram(data, bins=bins) if not normalize: return histogram # Normalize by the integral of the histogram. hist_sum = histogram.sum() * bins[1] return histogram / (hist_sum or 1.)
def set_refractory_period(self, value): """Set the refractory period (in milliseconds).""" self.refractory_period = _clip(value, .1, 100) * 1e-3 self.plot()