diff options
author | Mario Mulansky <mario.mulansky@gmx.net> | 2014-10-10 17:23:28 +0200 |
---|---|---|
committer | Mario Mulansky <mario.mulansky@gmx.net> | 2014-10-10 17:23:28 +0200 |
commit | c1c5403b8274bd19aa1e71933cfaefe1ba622e59 (patch) | |
tree | 2eebc7482b29d734ff933b0ca2c32c2e3b50c8ca /examples/plot.py | |
parent | 7a8f12ab65ceea0211f6f24c26042768ef005302 (diff) |
added License note in headers
Diffstat (limited to 'examples/plot.py')
-rw-r--r-- | examples/plot.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/plot.py b/examples/plot.py new file mode 100644 index 0000000..d7e2173 --- /dev/null +++ b/examples/plot.py @@ -0,0 +1,42 @@ +""" plot.py + +Simple example showing how to load and plot spike trains and their distances. + +Copyright 2014, Mario Mulansky <mario.mulansky@gmx.net> + +Distributed under the MIT License (MIT) +""" + + +from __future__ import print_function + +import numpy as np +import matplotlib.pyplot as plt + +import pyspike as spk + +spike_trains = spk.load_spike_trains_from_txt("SPIKY_testdata.txt", + time_interval=(0,4000)) + +# plot the spike time +for (i,spikes) in enumerate(spike_trains): + plt.plot(spikes, i*np.ones_like(spikes), 'o') + +f = spk.isi_distance(spike_trains[0], spike_trains[1]) +x, y = f.get_plottable_data() + +plt.figure() +plt.plot(x, np.abs(y), '--k') + +print("Average: %.8f" % f.avrg()) +print("Absolute average: %.8f" % f.abs_avrg()) + + +f = spk.spike_distance(spike_trains[0], spike_trains[1]) +x, y = f.get_plottable_data() +print(x) +print(y) +#plt.figure() +plt.plot(x, y, '-b') + +plt.show() |