diff options
Diffstat (limited to 'examples/spike_sync.py')
-rw-r--r-- | examples/spike_sync.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/spike_sync.py b/examples/spike_sync.py new file mode 100644 index 0000000..13ca0ce --- /dev/null +++ b/examples/spike_sync.py @@ -0,0 +1,50 @@ +from __future__ import print_function + +import matplotlib.pyplot as plt + +import pyspike as spk + +spike_trains = spk.load_spike_trains_from_txt("../test/SPIKE_Sync_Test.txt", + edges=(0, 4000)) + +plt.figure() + +f = spk.spike_sync_profile(spike_trains[0], spike_trains[1]) +x, y = f.get_plottable_data() +plt.plot(x, y, '--ok', label="SPIKE-SYNC profile") +print(f.x) +print(f.y) +print(f.mp) + +print("Average:", f.avrg()) + + +f = spk.spike_profile(spike_trains[0], spike_trains[1]) +x, y = f.get_plottable_data() + +plt.plot(x, y, '-b', label="SPIKE-profile") + +plt.axis([0, 4000, -0.1, 1.1]) +plt.legend(loc="center right") + +plt.figure() + +plt.subplot(211) + +f = spk.spike_sync_profile(spike_trains) +x, y = f.get_plottable_data() +plt.plot(x, y, '-b', alpha=0.7, label="SPIKE-Sync profile") + +x1, y1 = f.get_plottable_data(averaging_window_size=50) +plt.plot(x1, y1, '-k', lw=2.5, label="averaged SPIKE-Sync profile") + +plt.subplot(212) + +f_psth = spk.psth(spike_trains, bin_size=50.0) +x, y = f_psth.get_plottable_data() +plt.plot(x, y, '-k', alpha=1.0, label="PSTH") + + +print("Average:", f.avrg()) + +plt.show() |