blob: 041f89792a84daea3c67f1053d4a325abe241863 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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, dtype=float)
# 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 = float(interval)
else:
# extract times from sequence
self.t_start = float(interval[0])
self.t_end = float(interval[1])
|