summaryrefslogtreecommitdiff
path: root/pyspike/SpikeTrain.py
diff options
context:
space:
mode:
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]