In [1]:
import sys
sys.path.insert(0, '../../')
import quantities as pq
import neo
import neo.io.blackrockio
import elephant.spike_train_generation
import elephant.spade
import matplotlib.pyplot as plt
import random
random.seed(1224)
/home/denker/anaconda/envs/stdpy2/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
In [3]:
print sts[0].times
[0.09629761 0.21441552 0.24384922 0.25423191 0.25945727 0.84680687
1.25767367 1.99719598 2.78085242 3.12067422 3.18944254 3.81541117
4.21305412 4.27678443 4.82348106 5.0301406 5.05442864 5.101868
5.15210488 5.22651125 5.49020742 5.79079191 6.07703772 6.16715908
6.27540632 6.443562 6.66410627 6.77478839 6.87097623 6.94764301
6.99396095 7.04323633 7.18897689 7.33294131 7.44070656 7.61369834
8.24096705 8.38424014 9.23644968 9.37369448 9.62584366 9.62621046] s
In [4]:
patterns = elephant.spade.spade(
data=sts, binsize=1*pq.ms, winlen=1, dither=5*pq.ms,
min_spikes=3, n_surr=10, psr_param=[0,0,3],
output_format='patterns')['patterns']
Time for data mining: 0.0507569313049
Time for pvalue spectrum computation: 0.557723999023
In [5]:
%matplotlib notebook
plot_pattern=patterns[0]
plt.figure()
# Raster plot of the data
for st_idx, st in enumerate(sts):
if st_idx == 0:
plt.plot(st.rescale(pq.ms), [st_idx] * len(st), 'k.', label='spikes')
else:
plt.plot(st.rescale(pq.ms), [st_idx] * len(st), 'k.')
labeled=False
for neu in plot_pattern['neurons']:
if labeled == False:
plt.plot(
plot_pattern['times'], [neu]*len(plot_pattern['times']), 'ro', label='pattern')
labeled=True
else:
plt.plot(
plot_pattern['times'], [neu] * len(plot_pattern['times']), 'ro')
plt.ylim([-1, len(sts)])
plt.xlabel('time (ms)')
plt.ylabel('neurons ids')
plt.yticks(range(0,10,1))
plt.legend()
plt.show()