[pointprocesses] imrpoved count and fano plots
This commit is contained in:
parent
c5d5d94d1b
commit
bd610a9b1d
@ -5,8 +5,8 @@ from plotstyle import *
|
|||||||
|
|
||||||
|
|
||||||
rate = 20.0
|
rate = 20.0
|
||||||
trials = 10
|
trials = 20
|
||||||
duration = 200.0
|
duration = 100.0
|
||||||
|
|
||||||
|
|
||||||
def hompoisson(rate, trials, duration) :
|
def hompoisson(rate, trials, duration) :
|
||||||
@ -28,7 +28,7 @@ def plot_count_hist(ax, spikes, win, pmax):
|
|||||||
counts.extend(c)
|
counts.extend(c)
|
||||||
cb = np.arange(0.0, 15.5, 1.0)
|
cb = np.arange(0.0, 15.5, 1.0)
|
||||||
h, b = np.histogram(counts, cb, density=True)
|
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), **lsBm)
|
||||||
ax.plot(cb, poisson.pmf(cb, rate*win), **psBm)
|
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')
|
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, (ax1, ax2) = plt.subplots(1, 2)
|
||||||
fig.subplots_adjust(**adjust_fs(fig, top=0.5, right=1.5))
|
fig.subplots_adjust(**adjust_fs(fig, top=0.5, right=1.5))
|
||||||
plot_count_hist(ax1, spikes, 0.02, 0.7)
|
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.savefig('countexamples.pdf')
|
||||||
plt.close()
|
plt.close()
|
||||||
|
@ -76,23 +76,27 @@ def plot_count_fano(ax1, ax2, spikes):
|
|||||||
counts.extend(c)
|
counts.extend(c)
|
||||||
mean_counts[k] = np.mean(counts)
|
mean_counts[k] = np.mean(counts)
|
||||||
var_counts[k] = np.var(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_xlabel('Mean count')
|
||||||
ax1.set_xlim(0.0, 20.0)
|
ax1.set_xlim(0.0, 20.0)
|
||||||
ax1.set_ylim(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.plot(1000.0*wins, var_counts/mean_counts, **lsB)
|
||||||
ax2.set_xlabel('Window', 'ms')
|
ax2.set_xlabel('Window', 'ms')
|
||||||
ax2.set_ylim(0.0, 1.2)
|
ax2.set_ylim(0.0, 1.2)
|
||||||
ax2.set_xscale('log')
|
ax2.set_xscale('log')
|
||||||
ax2.set_xticks([10, 100, 1000])
|
ax2.set_xticks([10, 100, 1000])
|
||||||
ax2.set_xticklabels(['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__":
|
if __name__ == "__main__":
|
||||||
homspikes = hompoisson(rate, trials, duration)
|
homspikes = hompoisson(rate, trials, duration)
|
||||||
inhspikes = oupifspikes(rate, trials, duration, dt, 0.3, drate, tau)
|
inhspikes = oupifspikes(rate, trials, duration, dt, 0.3, drate, tau)
|
||||||
fig, axs = plt.subplots(2, 2)
|
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)
|
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].text(0.1, 0.95, 'Poisson', transform=axs[0,0].transAxes)
|
||||||
axs[0,0].set_xlabel('')
|
axs[0,0].set_xlabel('')
|
||||||
@ -100,8 +104,9 @@ if __name__ == "__main__":
|
|||||||
axs[0,0].xaxis.set_major_formatter(mpt.NullFormatter())
|
axs[0,0].xaxis.set_major_formatter(mpt.NullFormatter())
|
||||||
axs[0,1].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)
|
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)
|
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.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.savefig('fanoexamples.pdf')
|
||||||
plt.close()
|
plt.close()
|
||||||
|
@ -189,11 +189,11 @@ with itself and is always 1.
|
|||||||
|
|
||||||
\begin{figure}[t]
|
\begin{figure}[t]
|
||||||
\includegraphics{countexamples}
|
\includegraphics{countexamples}
|
||||||
\titlecaption{\label{countstatsfig}Count statistics.}{The
|
\titlecaption{\label{countstatsfig}Count statistics.}{Probability
|
||||||
distribution of the number of events $k$ (blue) counted within
|
distributions of counting $k$ events $k$ (blue) within windows of
|
||||||
windows of 20\,ms (left) or 200\,ms duration (right) of the
|
20\,ms (left) or 200\,ms duration (right) of a homogeneous Poisson
|
||||||
homogeneous Poisson spike train with a rate of 20\,Hz shown in
|
spike train with a rate of 20\,Hz
|
||||||
\figref{rasterexamplesfig}. For Poisson spike trains these
|
(\figref{rasterexamplesfig}). For Poisson spike trains these
|
||||||
distributions are given by Poisson distributions (red).}
|
distributions are given by Poisson distributions (red).}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user