diff options
author | Gard Spreemann <gspr@nonempty.org> | 2019-07-17 15:34:45 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2019-07-17 15:34:45 +0200 |
commit | 7dafdd4535f44a6946592f22ead74bb6dbec8952 (patch) | |
tree | 4723ffb85d6d18fb589db65eb08771433a735e87 /examples/plot.py | |
parent | d1f42d4be4676d76242e4148c06004cbf0b7cefa (diff) | |
parent | 34bd30415dd93a2425ce566627e24ee9483ada3e (diff) |
Merge tag '0.6.0' into debian/sid
Diffstat (limited to 'examples/plot.py')
-rw-r--r-- | examples/plot.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/plot.py b/examples/plot.py new file mode 100644 index 0000000..a0e04da --- /dev/null +++ b/examples/plot.py @@ -0,0 +1,45 @@ +""" plot.py + +Simple example showing how to load and plot spike trains and their distance +profiles. + +Copyright 2014, Mario Mulansky <mario.mulansky@gmx.net> + +Distributed under the BSD License +""" + + +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("PySpike_testdata.txt", + edges=(0, 4000)) + +# plot the spike times +for (i, spike_train) in enumerate(spike_trains): + plt.scatter(spike_train, i*np.ones_like(spike_train), marker='|') + +# profile of the first two spike trains +f = spk.isi_profile(spike_trains, indices=[0, 1]) +x, y = f.get_plottable_data() + +plt.figure() +plt.plot(x, np.abs(y), '--k', label="ISI-profile") + +print("ISI-distance: %.8f" % f.avrg()) + +f = spk.spike_profile(spike_trains, indices=[0, 1]) +x, y = f.get_plottable_data() + +plt.plot(x, y, '-b', label="SPIKE-profile") + +print("SPIKE-distance: %.8f" % f.avrg()) + +plt.legend(loc="upper left") + +plt.show() |