[pointprocesses] imrpoved count and fano plots

This commit is contained in:
Jan Benda 2021-01-16 10:50:27 +01:00
parent c5d5d94d1b
commit bd610a9b1d
3 changed files with 19 additions and 12 deletions

View File

@ -5,8 +5,8 @@ from plotstyle import *
rate = 20.0
trials = 10
duration = 200.0
trials = 20
duration = 100.0
def hompoisson(rate, trials, duration) :
@ -28,7 +28,7 @@ def plot_count_hist(ax, spikes, win, pmax):
counts.extend(c)
cb = np.arange(0.0, 15.5, 1.0)
h, b = np.histogram(counts, cb, density=True)
ax.bar(b[:-1], h, bar_fac, **fsA)
ax.bar(b[:-1], h, bar_fac, align='center', **fsA)
ax.plot(cb, poisson.pmf(cb, rate*win), **lsBm)
ax.plot(cb, poisson.pmf(cb, rate*win), **psBm)
ax.text(0.9, 0.9, 'T=%.0fms' % (1000.0*win), transform=ax.transAxes, ha='right')
@ -44,6 +44,8 @@ if __name__ == "__main__":
fig, (ax1, ax2) = plt.subplots(1, 2)
fig.subplots_adjust(**adjust_fs(fig, top=0.5, right=1.5))
plot_count_hist(ax1, spikes, 0.02, 0.7)
plot_count_hist(ax2, spikes, 0.2, 0.25)
ax1.set_yticks(np.arange(0.0, 0.7, 0.2))
plot_count_hist(ax2, spikes, 0.2, 0.22)
ax2.set_yticks(np.arange(0.0, 0.25, 0.1))
plt.savefig('countexamples.pdf')
plt.close()

View File

@ -76,23 +76,27 @@ def plot_count_fano(ax1, ax2, spikes):
counts.extend(c)
mean_counts[k] = np.mean(counts)
var_counts[k] = np.var(counts)
ax1.plot(mean_counts, var_counts, **lsA)
ax1.plot(mean_counts, var_counts, zorder=100, **lsA)
ax1.set_xlabel('Mean count')
ax1.set_xlim(0.0, 20.0)
ax1.set_ylim(0.0, 20.0)
ax1.set_xticks(np.arange(0.0, 21.0, 10.0))
ax1.set_yticks(np.arange(0.0, 21.0, 10.0))
ax2.plot(1000.0*wins, var_counts/mean_counts, **lsB)
ax2.set_xlabel('Window', 'ms')
ax2.set_ylim(0.0, 1.2)
ax2.set_xscale('log')
ax2.set_xticks([10, 100, 1000])
ax2.set_xticklabels(['10', '100', '1000'])
ax2.xaxis.set_minor_locator(mpt.NullLocator())
ax2.set_yticks(np.arange(0.0, 1.2, 0.5))
if __name__ == "__main__":
homspikes = hompoisson(rate, trials, duration)
inhspikes = oupifspikes(rate, trials, duration, dt, 0.3, drate, tau)
fig, axs = plt.subplots(2, 2)
fig.subplots_adjust(**adjust_fs(fig, top=0.5, right=1.5))
fig.subplots_adjust(**adjust_fs(fig, top=0.5, right=2.0))
plot_count_fano(axs[0,0], axs[0,1], homspikes)
axs[0,0].text(0.1, 0.95, 'Poisson', transform=axs[0,0].transAxes)
axs[0,0].set_xlabel('')
@ -100,8 +104,9 @@ if __name__ == "__main__":
axs[0,0].xaxis.set_major_formatter(mpt.NullFormatter())
axs[0,1].xaxis.set_major_formatter(mpt.NullFormatter())
plot_count_fano(axs[1,0], axs[1,1], inhspikes)
axs[1,1].axhline(1.0, **lsGrid)
axs[1,0].text(0.1, 0.95, 'OU noise', transform=axs[1,0].transAxes)
fig.text(0.01, 0.58, 'Count variance', va='center', rotation='vertical')
fig.text(0.53, 0.58, 'Fano factor', va='center', rotation='vertical')
fig.text(0.51, 0.58, 'Fano factor', va='center', rotation='vertical')
plt.savefig('fanoexamples.pdf')
plt.close()

View File

@ -189,11 +189,11 @@ with itself and is always 1.
\begin{figure}[t]
\includegraphics{countexamples}
\titlecaption{\label{countstatsfig}Count statistics.}{The
distribution of the number of events $k$ (blue) counted within
windows of 20\,ms (left) or 200\,ms duration (right) of the
homogeneous Poisson spike train with a rate of 20\,Hz shown in
\figref{rasterexamplesfig}. For Poisson spike trains these
\titlecaption{\label{countstatsfig}Count statistics.}{Probability
distributions of counting $k$ events $k$ (blue) within windows of
20\,ms (left) or 200\,ms duration (right) of a homogeneous Poisson
spike train with a rate of 20\,Hz
(\figref{rasterexamplesfig}). For Poisson spike trains these
distributions are given by Poisson distributions (red).}
\end{figure}