summaryrefslogtreecommitdiff
path: root/pyspike/SpikeTrain.py
blob: d586fe0e2eb6b28edcd925d4f3f73c9bf146b4d9 (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
""" 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


class SpikeTrain(object):
    """ Class representing spike trains for the PySpike Module."""

    def __init__(self, spike_times, edges):
        """ Constructs the SpikeTrain
        :param spike_times: ordered array of spike times.
        :param edges: The edges of the spike train. Given as a pair of floats
        (T0, T1) or a single float T1, where then T0=0 is assumed.
        """

        # TODO: sanity checks
        self.spikes = np.array(spike_times, dtype=float)

        try:
            self.t_start = float(edges[0])
            self.t_end = float(edges[1])
        except:
            self.t_start = 0.0
            self.t_end = float(edges)