[deprecations] replace scipy.hist with np function ...

and deprecation of normed keyword in nphistogram
This commit is contained in:
2020-10-27 00:01:18 +01:00
parent 5be1c25187
commit 8ab483d3a8
5 changed files with 20 additions and 17 deletions

View File

@@ -11,7 +11,7 @@ def get_instantaneous_rate(times, max_t=30., dt=1e-4):
indices = np.asarray(times / dt, dtype=int)
intervals = np.diff(np.hstack(([0], times)))
inst_rate = np.zeros(time.shape)
for i, index in enumerate(indices[1:]):
inst_rate[indices[i-1]:indices[i]] = 1/intervals[i]
return time, inst_rate
@@ -20,16 +20,16 @@ def get_instantaneous_rate(times, max_t=30., dt=1e-4):
def plot_isi_rate(spike_times, max_t=30, dt=1e-4):
times = np.squeeze(spike_times[0][0])[:50000]
time, rate = get_instantaneous_rate(times, max_t=50000*dt)
rates = np.zeros((len(rate), len(spike_times)))
for i in range(len(spike_times)):
_, rates[:, i] = get_instantaneous_rate(np.squeeze(spike_times[i][0])[:50000],
max_t=50000*dt)
avg_rate = np.mean(rates, axis=1)
rate_std = np.std(rates, axis=1)
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=cm_size(figure_width, 1.2*figure_height))
ax1.vlines(times[times < (50000*dt)], ymin=0, ymax=1, color="dodgerblue", lw=1.5)
ax1.set_ylabel('Spikes')
ax1.set_xlim(0, 5)
@@ -43,7 +43,7 @@ def plot_isi_rate(spike_times, max_t=30, dt=1e-4):
ax3.set_ylabel('Firing rate', 'Hz')
ax3.legend()
ax3.set_ylim(0, 450)
fig.savefig("isimethod.pdf")
plt.close()
@@ -52,9 +52,9 @@ def get_binned_rate(times, bin_width=0.05, max_t=30., dt=1e-4):
time = np.arange(0., max_t, dt)
bins = np.arange(0., max_t, bin_width)
bin_indices = np.asarray(bins / dt, np.int)
hist, _ = sp.histogram(times, bins)
hist, _ = np.histogram(times, bins)
rate = np.zeros(time.shape)
for i, b in enumerate(bin_indices[1:]):
rate[bin_indices[i-1]:b] = hist[i-1]/bin_width
return time, rate
@@ -68,7 +68,7 @@ def plot_bin_rate(spike_times, bin_width, max_t=30, dt=1e-4):
_, rates[:, i] = get_binned_rate(np.squeeze(spike_times[i][0]))
avg_rate = np.mean(rates, axis=1)
rate_std = np.std(rates, axis=1)
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=cm_size(figure_width, 1.2*figure_height))
ax1.vlines(times[times < (100000*dt)], ymin=0, ymax=1, color="dodgerblue", lw=1.5)