summaryrefslogtreecommitdiff
path: root/examples/test_data.py
blob: bddcb150cfebb660a6cfab3ed67b235a416a2026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()