From e4f1c09672068e4778f7b5f3e27b47ff8986863c Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 29 Sep 2014 12:55:56 +0200 Subject: +mul_scalar, tests restructured and cosmetics --- pyspike/distances.py | 14 ++++++++++++++ pyspike/function.py | 15 +++++++++++++++ pyspike/spikes.py | 6 ++++++ 3 files changed, 35 insertions(+) (limited to 'pyspike') diff --git a/pyspike/distances.py b/pyspike/distances.py index 10b1d3c..f4be625 100644 --- a/pyspike/distances.py +++ b/pyspike/distances.py @@ -9,6 +9,10 @@ import numpy as np from pyspike import PieceWiseConstFunc, PieceWiseLinFunc + +############################################################ +# add_auxiliary_spikes +############################################################ def add_auxiliary_spikes( spike_train, T_end , T_start=0.0): """ Adds spikes at the beginning (T_start) and end (T_end) of the observation interval. @@ -29,6 +33,10 @@ def add_auxiliary_spikes( spike_train, T_end , T_start=0.0): spike_train = np.append(spike_train, T_end) return spike_train + +############################################################ +# isi_distance +############################################################ def isi_distance(spikes1, spikes2): """ Computes the instantaneous isi-distance S_isi (t) of the two given spike trains. The spike trains are expected to have auxiliary spikes at the @@ -95,6 +103,9 @@ def isi_distance(spikes1, spikes2): return PieceWiseConstFunc(spike_events[:index+1], isi_values[:index]) +############################################################ +# get_min_dist +############################################################ def get_min_dist(spike_time, spike_train, start_index=0): """ Returns the minimal distance |spike_time - spike_train[i]| with i>=start_index. @@ -111,6 +122,9 @@ def get_min_dist(spike_time, spike_train, start_index=0): return d +############################################################ +# spike_distance +############################################################ def spike_distance(spikes1, spikes2): """ Computes the instantaneous spike-distance S_spike (t) of the two given spike trains. The spike trains are expected to have auxiliary spikes at the diff --git a/pyspike/function.py b/pyspike/function.py index b705293..3a5a01c 100644 --- a/pyspike/function.py +++ b/pyspike/function.py @@ -109,6 +109,13 @@ class PieceWiseConstFunc: self.x = x_new[:index+2] self.y = y_new[:index+1] + def mul_scalar(self, fac): + """ Multiplies the function with a scalar value + Params: + - fac: Value to multiply + """ + self.y *= fac + ############################################################## # PieceWiseLinFunc @@ -236,3 +243,11 @@ class PieceWiseLinFunc: self.x = x_new[:index+2] self.y1 = y1_new[:index+1] self.y2 = y2_new[:index+1] + + def mul_scalar(self, fac): + """ Multiplies the function with a scalar value + Params: + - fac: Value to multiply + """ + self.y1 *= fac + self.y2 *= fac diff --git a/pyspike/spikes.py b/pyspike/spikes.py index 6b2eea3..70b48ff 100644 --- a/pyspike/spikes.py +++ b/pyspike/spikes.py @@ -7,6 +7,9 @@ Copyright 2014, Mario Mulansky import numpy as np +############################################################ +# spike_train_from_string +############################################################ def spike_train_from_string(s, sep=' '): """ Converts a string of times into an array of spike times. Params: @@ -18,6 +21,9 @@ def spike_train_from_string(s, sep=' '): return np.fromstring(s, sep=sep) +############################################################ +# merge_spike_trains +############################################################ def merge_spike_trains(spike_trains): """ Merges a number of spike trains into a single spike train. Params: -- cgit v1.2.3