@@ -0,0 +1,2157 @@
+from __future__ import print_function%0Afrom brian import *%0Aimport numpy as np%0Aimport spikerlib as sl%0Aimport itertools as itt%0Aimport matplotlib.pyplot as plt%0A%0A%0A# unit aliases%0Ams = msecond%0AHz = hertz%0AmV = mvolt%0A%0A# measure aliases%0Avictor_purpura = sl.metrics.victor_purpura%0Akreuz = sl.metrics.kreuz%0Amodulus = sl.metrics.modulus_metric%0Anpss = sl.tools.normalised_pre_spike_slopes%0A%0A# measure aliases%0Avictor_purpura = sl.metrics.victor_purpura%0Akreuz = sl.metrics.kreuz%0Amodulus = sl.metrics.modulus_metric%0Anpss = sl.tools.normalised_pre_spike_slopes%0A%0Anetw = Network()%0AVth = 20*mV%0Aneuron = NeuronGroup(2, %22dV/dt = 0*volt/second : volt%22,%0A                     threshold=%22V%3EVth%22, reset=%22V=0*mV%22,%0A                     refractory=5*ms)%0Aneuron.V = 0*mV%0Anetw.add(neuron)%0A%0ANin = 50%0Awide_packet = np.random.normal(0, 4.0*ms, 50)%0Anarrow_packet = np.random.normal(0, 0.1*ms, 50)%0Awide_narrow = (%5Bni+15*ms for ni in wide_packet%5D+%0A               %5Bni+40*ms for ni in narrow_packet%5D)%0Anarrow_wide = (%5Bni+15*ms for ni in narrow_packet%5D+%0A               %5Bni+40*ms for ni in wide_packet%5D)%0A%0Awn_trains = %5B%5B%5D for i in range(Nin)%5D%0Afor wn, t in zip(itt.cycle(wn_trains), wide_narrow):%0A    wn.append(t)%0Anw_trains = %5B%5B%5D for i in range(Nin)%5D%0Afor nw, t in zip(itt.cycle(nw_trains), narrow_wide):%0A    nw.append(t)%0A#for _idx, wn in enumerate(wn_trains):%0A#    plt.scatter(wn, np.ones(len(wn))*_idx, c='b')%0A#for _idx, nw in enumerate(nw_trains):%0A#    plt.scatter(nw, np.ones(len(nw))*_idx, c='r')%0A%0Adura = max(max(wide_narrow), max(narrow_wide), 50*ms)%0Awn_t, wn_kreuz = kreuz.pairwise_mp(wn_trains, 0, dura, 100)%0Anw_t, nw_kreuz = kreuz.pairwise_mp(nw_trains, 0, dura, 100)%0A%0A# random spike trains for comparison%0Arandspiketrains = %5Bnp.cumsum(np.random.random(10)) for i in range(50)%5D%0Arandspiketrains = %5Bst*dura/max(st) for st in randspiketrains%5D%0Arand_t, rand_kreuz = kreuz.pairwise_mp(randspiketrains, 0, dura, 100)%0A%0A# plot%0Aplt.plot(wn_t, wn_kreuz, 'b')%0Aplt.plot(nw_t, nw_kreuz, 'r')%0Aplt.plot(rand_t, rand_kreuz, 'k')%0Aplt.figure()%0Anorm_factor = max(rand_kreuz)%0Aplt.plot(wn_t, wn_kreuz/norm_factor, 'b')%0Aplt.plot(nw_t, nw_kreuz/norm_factor, 'r')%0Aplt.plot(rand_t, rand_kreuz/norm_factor, 'k')%0Aplt.show()%0A%0A

Take 2