Skip to content

Commit

Permalink
updated examples to use new unified interface
Browse files Browse the repository at this point in the history
removed all occasions of *multi functions from examples as they are considered
deprecated now. Uses unified interface everywhere.
  • Loading branch information
mariomulansky committed Mar 9, 2016
1 parent 9f00431 commit ee0e980
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/averages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pyspike as spk

spike_trains = spk.load_spike_trains_from_txt("PySpike_testdata.txt",
time_interval=(0, 4000))
edges=(0, 4000))

f = spk.isi_profile(spike_trains[0], spike_trains[1])

Expand Down
6 changes: 3 additions & 3 deletions examples/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

print(merged_spike_train.spikes)

plt.plot(spike_trains[0].spikes, np.ones_like(spike_trains[0].spikes), 'o')
plt.plot(spike_trains[1].spikes, np.ones_like(spike_trains[1].spikes), 'x')
plt.plot(spike_trains[0], np.ones_like(spike_trains[0]), 'o')
plt.plot(spike_trains[1], np.ones_like(spike_trains[1]), 'x')
plt.plot(merged_spike_train.spikes,
2*np.ones_like(merged_spike_train.spikes), 'o')
2*np.ones_like(merged_spike_train), 'o')

plt.show()
4 changes: 2 additions & 2 deletions examples/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def time_diff_in_ms(start, end):
print("Number of spikes: %d" % num_of_spikes)

# calculate the multivariate spike distance
f = spk.spike_profile_multi(spike_trains)
f = spk.spike_profile(spike_trains)

t_spike = time.clock()

Expand All @@ -39,7 +39,7 @@ def time_diff_in_ms(start, end):
t_avrg = time.clock()

# compute average distance directly, should give the same result as above
spike_dist = spk.spike_distance_multi(spike_trains)
spike_dist = spk.spike_distance(spike_trains)
print("Spike distance directly: %.8f" % spike_dist)

t_dist = time.clock()
Expand Down
27 changes: 15 additions & 12 deletions examples/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,41 @@
t_end = datetime.now()
runtime = (t_end-t_start).total_seconds()

sort_by = 'tottime'
# sort_by = 'cumtime'

print("Spike generation runtime: %.3fs" % runtime)
print()

print("================ ISI COMPUTATIONS ================")
print(" MULTIVARIATE DISTANCE")
cProfile.run('spk.isi_distance_multi(spike_trains)', 'performance.stat')
cProfile.run('spk.isi_distance(spike_trains)', 'performance.stat')
p = pstats.Stats('performance.stat')
p.strip_dirs().sort_stats('tottime').print_stats(5)
p.strip_dirs().sort_stats(sort_by).print_stats(5)

print(" MULTIVARIATE PROFILE")
cProfile.run('spk.isi_profile_multi(spike_trains)', 'performance.stat')
cProfile.run('spk.isi_profile(spike_trains)', 'performance.stat')
p = pstats.Stats('performance.stat')
p.strip_dirs().sort_stats('tottime').print_stats(5)
p.strip_dirs().sort_stats(sort_by).print_stats(5)

print("================ SPIKE COMPUTATIONS ================")
print(" MULTIVARIATE DISTANCE")
cProfile.run('spk.spike_distance_multi(spike_trains)', 'performance.stat')
cProfile.run('spk.spike_distance(spike_trains)', 'performance.stat')
p = pstats.Stats('performance.stat')
p.strip_dirs().sort_stats('tottime').print_stats(5)
p.strip_dirs().sort_stats(sort_by).print_stats(5)

print(" MULTIVARIATE PROFILE")
cProfile.run('spk.spike_profile_multi(spike_trains)', 'performance.stat')
cProfile.run('spk.spike_profile(spike_trains)', 'performance.stat')
p = pstats.Stats('performance.stat')
p.strip_dirs().sort_stats('tottime').print_stats(5)
p.strip_dirs().sort_stats(sort_by).print_stats(5)

print("================ SPIKE-SYNC COMPUTATIONS ================")
print(" MULTIVARIATE DISTANCE")
cProfile.run('spk.spike_sync_multi(spike_trains)', 'performance.stat')
cProfile.run('spk.spike_sync(spike_trains)', 'performance.stat')
p = pstats.Stats('performance.stat')
p.strip_dirs().sort_stats('tottime').print_stats(5)
p.strip_dirs().sort_stats(sort_by).print_stats(5)

print(" MULTIVARIATE PROFILE")
cProfile.run('spk.spike_sync_profile_multi(spike_trains)', 'performance.stat')
cProfile.run('spk.spike_sync_profile(spike_trains)', 'performance.stat')
p = pstats.Stats('performance.stat')
p.strip_dirs().sort_stats('tottime').print_stats(5)
p.strip_dirs().sort_stats(sort_by).print_stats(5)
5 changes: 3 additions & 2 deletions examples/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
for (i, spike_train) in enumerate(spike_trains):
plt.scatter(spike_train, i*np.ones_like(spike_train), marker='|')

f = spk.isi_profile(spike_trains[0], spike_trains[1])
# 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[0], spike_trains[1])
f = spk.spike_profile(spike_trains, indices=[0, 1])
x, y = f.get_plottable_data()

plt.plot(x, y, '-b', label="SPIKE-profile")
Expand Down
4 changes: 2 additions & 2 deletions examples/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
print()

# compute the multivariate ISI profile
f = spk.isi_profile_multi(spike_trains)
f = spk.isi_profile(spike_trains)

t = 1200
print("Multivariate ISI value at t =", t, ":", f(t))
Expand All @@ -56,7 +56,7 @@
print()

# compute the multivariate SPIKE profile
f = spk.spike_profile_multi(spike_trains)
f = spk.spike_profile(spike_trains)

# SPIKE values at certain points
t = 1200
Expand Down
2 changes: 1 addition & 1 deletion examples/spike_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

plt.subplot(211)

f = spk.spike_sync_profile_multi(spike_trains)
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")

Expand Down

0 comments on commit ee0e980

Please sign in to comment.