| 5 | | This module is the core of the key functions that will allow manipulation and calculus |
|---|
| 6 | | on complex data structure like spike trains, spike lists, analog signals ... |
|---|
| 7 | | Despite the fact that those objects (described latter) are generic, it's strongly recommended |
|---|
| 8 | | to use the pyNN API to generate the data. The standard output format of the latter will be |
|---|
| 9 | | the one used by NeuroTools, and you'll have to make your own loader (very simple) if you |
|---|
| 10 | | have your own format. |
|---|
| | 5 | This module provides key functions to manipulate and perform calculations |
|---|
| | 6 | on data structures like spike trains, spike lists, analog signals. |
|---|
| | 7 | |
|---|
| | 8 | The import and export of these data structures is typically achieved using the NeuroTools :trac:`io` module. |
|---|
| 16 | | A spike train is a vector of spike times, sorted, which is the result of a simulation |
|---|
| 17 | | It has therefore some attribute, like t_start and t_stop, which must in a general case |
|---|
| 18 | | be specified by the user because they can't be infered from the data. Note that the standard time |
|---|
| 19 | | unit here is the millisecond. |
|---|
| 20 | | When several spikes train are gathered, it will be an object called a SpikeList, i.e a dictionnary |
|---|
| 21 | | of spike trains, the id of the cells being used as a key. See descriptions for more details. |
|---|
| | 14 | A spike train is a sorted vector of spike times, which is the result of a simulation or aquired by measurement. |
|---|
| | 15 | It has therefore some attributes, like t_start and t_stop, which must in general |
|---|
| | 16 | be specified by the user, as they can not be infered from the data. |
|---|
| | 17 | |
|---|
| | 18 | '''Note:''' the standard time unit used by NeuroTools is milliseconds. |
|---|
| | 19 | |
|---|
| | 20 | When several spikes train are gathered, they are collected in a so-called SpikeList, which is actually a dictionnary |
|---|
| | 21 | of spike trains, the id of the cells being used as a key. See the SpikeList_ class for more details. |
|---|
| 52 | | ``SpikeList`` objects, as we'll see later. |
|---|
| 53 | | Note that several methods can be applied to such a ``SpikeTrain`` object. Without being explicit, one |
|---|
| 54 | | can used ``mean_rate()``, ``copy()``, ``isi()``, ``cv_isi()``, ``raster_plot()``. See the documentation for more |
|---|
| 55 | | details. Here is an example of a current use of a SpikeTrain object:: |
|---|
| | 49 | ``SpikeList`` object, as we'll see later. |
|---|
| | 50 | |
|---|
| | 51 | The ``SpikeTrain`` object has many useful methods such as ``mean_rate()``, ``copy()``, ``isi()``, ``cv_isi()``, ``raster_plot()``. See the ``singals`` API documentation (:trac:`api:signals`) for more |
|---|
| | 52 | details. |
|---|
| | 53 | |
|---|
| | 54 | An example of basic use of a SpikeTrain object is as follows:: |
|---|
| 67 | | A SpikeList is a dictionnary of SpikeTrains. This is usally the common output of a simulation, |
|---|
| 68 | | when one has recorded the spikes of a whole population. What you get from this recording |
|---|
| 69 | | is a list of tuple (id, spike time), that is, in a SpikeList object, turn into a dictionary |
|---|
| 70 | | {'id' : SpikeTrain} |
|---|
| 71 | | |
|---|
| 72 | | Creation |
|---|
| 73 | | ~~~~~~~~ |
|---|
| 74 | | |
|---|
| 75 | | The constructor of a SpikeList is made as follows: it will accept a list of tuples (id, spike_time), |
|---|
| 76 | | and additional parameters like t_start, t_stop, and the list of all the recorded ids. The last three parameters |
|---|
| 77 | | can't be infered from the data safely, so it's better if they are specified by the user. Nevertheless, the most |
|---|
| 78 | | commmon way to create SpikeList in NeuroTools is to use the ``load_spikelist()`` or the ``load()`` functions, as |
|---|
| 79 | | explained below:: |
|---|
| | 68 | A SpikeList is actually a dictionary of SpikeTrains, and can be thought of conceptually as the output of a network simulation, |
|---|
| | 69 | when one records the spikes of a given population. The SpikeList is an object to organize such a recording |
|---|
| | 70 | as a tuple of key-value pairs ( spike_source_id, spike_train), that is, a SpikeList object acts as a dictionary created as follows: |
|---|
| | 71 | {'id' : SpikeTrain, ...} |
|---|
| | 72 | |
|---|
| | 73 | Creation |
|---|
| | 74 | ~~~~~~~~ |
|---|
| | 75 | |
|---|
| | 76 | The constructor of a SpikeList is works as follows: it will accepts a list of tuples (id, spike_time), |
|---|
| | 77 | parameters t_start and t_stop, and the list of all the recorded ids. The last three parameters |
|---|
| | 78 | can't be infered from the data safely, so it's better if they are specified by the user. Here is an simple example of how to create a SpikeList:: |
|---|
| 88 | | If you have generated your data with pyNN, you can used the loading functions made on purpose. For example if |
|---|
| 89 | | you have recorded the spikes of a population in a file "spikes.dat", then you just have to do:: |
|---|
| | 87 | Rather than calling the SpikeList constructor, a more commmon way to create a SpikeList in NeuroTools is to use the ``load_spikelist()`` or the ``load()`` functions. |
|---|
| | 88 | If you have generated your data with pyNN, you can used the loading functions made for this purpose. For example if |
|---|
| | 89 | you have recorded the spikes of a population in a file "spikes.dat", then one can load it as a SpikeList as follows:: |
|---|
| 93 | | With such a syntax, the headers informations willbe used to create the population, and t_start and t_stop will |
|---|
| 94 | | be infered automatically as the min and the max of all the SpikeTrains within the SpikeList |
|---|
| 95 | | If you want to keep the control on the parameters while creating the SpikeList:: |
|---|
| | 93 | Using this syntax, the header information contained in the file is used to create the population, and t_start and t_stop are |
|---|
| | 94 | infered automatically as the min and the max of all the SpikeTrains within the SpikeList. |
|---|
| | 95 | If you want to keep the control on the parameters while creating the SpikeList, do the following:: |
|---|
| 145 | | A lot of functions have the property of being able to generate plots. Those plots are generic and you can |
|---|
| 146 | | do yours with the raw results of the functions. Nevertheless, as you can see in the documentation of those |
|---|
| 147 | | functions, each time you have a display flag, you can pass either a boolean set to True if you wan to |
|---|
| 148 | | generate a new figure, either a subplot if you want to do more complicated plots. You can also provided additional |
|---|
| | 145 | Several signal object methods have the property of being able to generate plots. These plots are implemented to be generic and customizable. As can be seen in the API documentation, plotting functions accept a ``display`` flag, which you can set to ``True`` if you want to generate a new figure, or you can set it to a subplot if you want to do more complicated plots. You can also provided additional |
|---|
| 165 | | The other type of signals which is handled by NeuroTools.signals is the analog signals. They are indeed also |
|---|
| 166 | | recorded during a simulation, and it could be a Vm trace, a conductance or event a current. Such a signal is |
|---|
| 167 | | defined by a number of values between t_start and t_stop with a time step dt. |
|---|
| | 162 | NeuroTools.signals also handles analog signals. These are generally also |
|---|
| | 163 | recorded during a simulation or experiment, such as for example a Vm trace, a conductance or a current. Such a signal is |
|---|
| | 164 | definied by a number of values between t_start and t_stop with a time step dt. |
|---|