summaryrefslogtreecommitdiff
path: root/pyspike/SpikeTrain.py
diff options
context:
space:
mode:
authorMario Mulansky <mario.mulansky@gmx.net>2015-04-22 18:18:30 +0200
committerMario Mulansky <mario.mulansky@gmx.net>2015-04-22 18:18:30 +0200
commit27aa30d1fdb830a04b608c702cf7b616115eeb50 (patch)
tree531f9d08cd8f16f3ecadb3abace796d97670dfe7 /pyspike/SpikeTrain.py
parent1b9f4ec0aee1281464cfcab02bb4c7c302dbbb00 (diff)
added SpikeTrain class, changed isi_distance
spike trains are now represented as SpikeTrain objects consisting of the spike times and the interval edges. The implementation of the ISI-distance has been modified accordingly. The SPIKE-distance and SPIKE-Synchronization are still to be done.
Diffstat (limited to 'pyspike/SpikeTrain.py')
-rw-r--r--pyspike/SpikeTrain.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/pyspike/SpikeTrain.py b/pyspike/SpikeTrain.py
new file mode 100644
index 0000000..4760014
--- /dev/null
+++ b/pyspike/SpikeTrain.py
@@ -0,0 +1,34 @@
+""" Module containing the class representing spike trains for PySpike.
+
+Copyright 2015, Mario Mulansky <mario.mulansky@gmx.net>
+
+Distributed under the BSD License
+"""
+
+import numpy as np
+import collections
+
+
+class SpikeTrain:
+ """ Class representing spike trains for the PySpike Module."""
+
+ def __init__(self, spike_times, interval):
+ """ Constructs the SpikeTrain
+ :param spike_times: ordered array of spike times.
+ :param interval: interval defining the edges of the spike train.
+ Given as a pair of floats (T0, T1) or a single float T1, where T0=0 is
+ assumed.
+ """
+
+ # TODO: sanity checks
+ self.spikes = np.array(spike_times)
+
+ # check if interval is as sequence
+ if not isinstance(interval, collections.Sequence):
+ # treat value as end time and assume t_start = 0
+ self.t_start = 0.0
+ self.t_end = interval
+ else:
+ # extract times from sequence
+ self.t_start = interval[0]
+ self.t_end = interval[1]