diff options
author | Mario Mulansky <mario.mulansky@gmx.net> | 2014-09-15 17:01:13 +0200 |
---|---|---|
committer | Mario Mulansky <mario.mulansky@gmx.net> | 2014-09-15 17:01:13 +0200 |
commit | f9529c78538882879a07cb67e342eade8d2153ab (patch) | |
tree | 33f54461ff5c37c57d6006117ff3a02f21624053 /examples/test_data.py | |
parent | e08c05f9bf121e272aadce4fc79e9499e662111e (diff) |
isi distance and basic example
Diffstat (limited to 'examples/test_data.py')
-rw-r--r-- | examples/test_data.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/test_data.py b/examples/test_data.py new file mode 100644 index 0000000..bddcb15 --- /dev/null +++ b/examples/test_data.py @@ -0,0 +1,28 @@ +# compute the isi distance of some test data +from __future__ import print_function + +import numpy as np +import matplotlib.pyplot as plt + +import pyspike as spk + +# first load the data +spike_trains = [] +spike_file = open("SPIKY_testdata.txt", 'r') +for line in spike_file: + spike_trains.append(spk.spike_train_from_string(line)) + +# 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], 4000) +x, y = f.get_plottable_data() + +plt.figure() +plt.plot(x, y, '-k') + +print("Average: %.8f" % f.avrg()) +print("Absolute average: %.8f" % f.abs_avrg()) + +plt.show() |