Changeset 310
- Timestamp:
- 11/10/08 10:47:23 (2 months ago)
- Files:
-
- trunk/doc/signals.txt (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/signals.txt
r308 r310 12 12 ------------ 13 13 14 A spike train is a sorted vector of spike times, which is the result of a simulation or a quired by measurement.15 It has therefore some attributes, like t_start and t_stop, which must in general16 be specified by the user, as they can not be infer ed from the data.14 A spike train is a sorted vector of spike times, which is the result of a simulation or acquired 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 inferred from the data. 17 17 18 18 **Note:** the standard time unit used by NeuroTools is milliseconds. 19 19 20 When several spike s train are gathered, they are collected in a so-called ``SpikeList``, which is actually a dictionnary21 of spike trains, the id of the cells being used as a key. See the SpikeList_class for more details.20 When several spike trains are gathered, they are collected in a ``SpikeList`` object, which is effectively a dictionary 21 of spike trains, the id of the cells being used as a key. See the ``SpikeList`` class for more details. 22 22 23 23 … … 33 33 >>> spk2 = SpikeTrain(arange(0,100,10)) 34 34 35 As you can see, defining t_start and t_stopis optional. If those attributes are not provided,36 they are infer ed from the data as the min and the max of the spike times::35 As you can see, defining ``t_start`` and ``t_stop`` is optional. If those attributes are not provided, 36 they are inferred from the data as the min and the max of the spike times:: 37 37 38 38 >>> spk1.t_stop … … 41 41 90 42 42 43 You can access the raw vector of the spike times bythe ``spike_times`` attribute::43 You can access the raw vector of the spike times with the ``spike_times`` attribute:: 44 44 45 45 >>> spk1.spike_times … … 49 49 ``SpikeList`` object, as we'll see later. 50 50 51 The ``SpikeTrain`` object has many useful methods such as ``mean_rate()``, ``copy()``, ``isi()``, ``cv_isi()``, ``raster_plot()``. See the ``si ngals`` API documentation (:trac:`api:signals`) for more51 The ``SpikeTrain`` object has many useful methods such as ``mean_rate()``, ``copy()``, ``isi()``, ``cv_isi()``, ``raster_plot()``. See the ``signals`` API documentation (:trac:`api:signals`) for more 52 52 details. 53 53 54 54 An example of basic use of a ``SpikeTrain`` object is as follows:: 55 55 56 >>> spk1.raster_plot() # Generates a raster_plot between t_start and t_stop56 >>> spk1.raster_plot() # Generates a raster plot between t_start and t_stop 57 57 >>> spk1.isi() 58 58 array([ 10., 10., 10., 10., 10., 10., 10., 10., 10.]) … … 66 66 ----------------------- 67 67 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 recording70 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 parameters78 can't be infer ed 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``::68 A ``SpikeList`` is effectively 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 inferred 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``:: 79 79 80 80 >>> list = [(numpy.random.random_integers(0,10,1)[0],1000*numpy.random.rand()) for i in xrange(1000)] 81 81 >>> spklist = SpikeList(list, range(11), t_start=0, t_stop=1000) 82 82 83 Here, range(11) is used to specify that in the lists we will have cells with id between 0 and 10 (it is needed,84 because we can have silent cells in the SpikeList), and that I will kept the spike only between t_start and t_stop.85 All the ``SpikeTrain s`` objects within the ``SpikeList`` will share the same t_start and t_stop86 87 Rather than calling the ``SpikeList`` constructor, a more comm mon 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 usedthe loading functions made for this purpose. For example if83 Here, ``range(11)`` is used to specify that in the lists we will have cells with ids between 0 and 10 (this is needed 84 because we can have silent cells in the ``SpikeList``), and that we will keep spikes only between ``t_start`` and ``t_stop``. 85 All the ``SpikeTrain`` objects within the ``SpikeList`` will share the same ``t_start`` and ``t_stop``. 86 87 Rather than calling the ``SpikeList`` constructor, a more common 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 use the loading functions made for this purpose. For example if 89 89 you have recorded the spikes of a population in a file "spikes.dat", then one can load it as a ``SpikeList`` as follows:: 90 90 91 91 >>> spklist = load("spikes.dat",'spikes') 92 92 93 Using this syntax, the header information contained in the file is used to create the population, and t_start and t_stopare94 infer ed 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::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 inferred 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:: 96 96 97 97 >>> spklist = load_spikelist("spikes.dat", range(11), t_start=0, t_stop=1000) … … 103 103 ~~~~~~~~~~ 104 104 105 You can access ``SpikeTrain`` objects within the ``Spikelist`` by the simple syntax spklist[id]::105 You can access ``SpikeTrain`` objects within the ``Spikelist`` with the simple syntax ``spklist[id]``:: 106 106 107 107 >>> spklist[0] … … 112 112 print spktrain.isi() 113 113 114 As you can see in the example, one can navig uate and iterate over a ``SpikeList`` object and have access to115 all the ``SpikeTrain s`` within the object. To have an explicite list of all the idcontained in the ``SpikeList``,114 As you can see in the example, one can navigate and iterate over a ``SpikeList`` object and have access to 115 all the ``SpikeTrain``\s within the object. To have an explicit list of all the ids contained in the ``SpikeList``, 116 116 use the function ``id_list()``:: 117 117 … … 127 127 ~~~~~~ 128 128 129 You can do slices of your ``SpikeList`` object, either according to the time axis or to selected ids .130 129 You can do slices of your ``SpikeList`` object, either according to the time axis or to selected ids:: 130 131 131 >>> subspklist = spklist.time_slice(500,1500) 132 >>> subspklist = spklist.id_slice(50) # Will select 50 random sid within spklist.id_list()132 >>> subspklist = spklist.id_slice(50) # Will select 50 random id within spklist.id_list() 133 133 >>> subspklist = spklist.id_slice([2,3,5,6]) 134 134 135 If you want to select only cells mat hcing a particular criteria within the ``SpikeList``, you can use the136 ``select_ids`` method 135 If you want to select only cells matching a particular criteria within the ``SpikeList``, you can use the 136 ``select_ids`` method:: 137 137 138 138 >>> subspklist = spklist.select_ids("cell.mean_rate() > 0") … … 161 161 -------------- 162 162 163 NeuroTools.signalsalso handles analog signals. These are generally also163 ``NeuroTools.signals`` also handles analog signals. These are generally also 164 164 recorded during a simulation or experiment, such as for example a Vm trace, a conductance or a current. Such a signal is 165 defin ied by a number of values between t_start and t_stop with a time step dt.165 defined by a number of values between ``t_start`` and ``t_stop`` with a time step ``dt``. 166 166 167 167 The ``AnalogSignal`` class … … 172 172 173 173 When we create an ``AnalogSignal``, we have to provide the list of the data, the time step of their acquisition, 174 and as an option the t_start and t_stop parameters. If None, t_start will be 0 and t_stop will be ``len(data)/dt``174 and as an option the ``t_start`` and ``t_stop`` parameters. If ``None``, ``t_start`` will be 0 and ``t_stop`` will be ``len(data)/dt``:: 175 175 176 176 >>> x = AnalogSignal(sin(arange(1000)),0.1) … … 183 183 500 184 184 185 You can access the raw data of the ``AnalogSignal`` by just using 185 You can access the raw data of the ``AnalogSignal`` by just using:: 186 186 187 187 >>> x.signal … … 198 198 ------------------------------ 199 199 200 As for the ``SpikeList``, the ``AnalogSignalList`` is a co ntainer of ``AnalogSignal`` objects. It has the same structure than201 the ``SpikeList``, meaning this is a diction nary containing ``AnalogSignals``with the key being the id of the cells.202 203 Creation 204 ~~~~~~~~ 205 206 The constructor of a ``AnalogSignalList`` is made as follows: it will accept an array with all the signals, the time step,207 and additional parameters like t_start, t_stop, and the list of all the recorded ids. The last three parameters208 can't be infer ed from the data safely, so it's better if they are specified by the user. Nevertheless, the most209 comm mon way to create ``SpikeList`` in NeuroTools is to use the ``load_analogsignal()`` or the``load()`` functions, as210 explained below. Currently, the constructor of the ``AnalogSignalList`` is mainly tun ned to be used with those load functions,211 and this is therefore not so simple to create one from a list of ``AnalogSignal``.200 As for the ``SpikeList``, the ``AnalogSignalList`` is a collection of ``AnalogSignal`` objects. It has the same structure as 201 the ``SpikeList``, meaning this is a dictionary containing ``AnalogSignal``\s with the key being the id of the cells. 202 203 Creation 204 ~~~~~~~~ 205 206 The constructor of an ``AnalogSignalList`` is made as follows: it will accept an array with all the signals, the time step, 207 and additional parameters like ``t_start``, ``t_stop``, and the list of all the recorded ids. The last three parameters 208 can't be inferred from the data safely, so it's better if they are specified by the user. Nevertheless, the most 209 common way to create ``AnalogSignal``\s in NeuroTools is to use the ``load_analogsignal()`` or ``load()`` functions, as 210 explained below. Currently, the constructor of the ``AnalogSignalList`` is mainly tuned to be used with these load functions, 211 and it is therefore not so simple to create one from a list of ``AnalogSignal``\s:: 212 212 213 213 >>> sig1 = AnalogSignal(sin(arange(10000),dt=0.1,t_start=0, t_stop=1000) 214 214 ... There seems to be something missing here? 215 215 216 216 … … 218 218 ~~~~~~~~~~ 219 219 220 You can access ``AnalogSignal`` object within the ``AnalogSignalList`` by the simple syntax spklist[id]:220 You can access an ``AnalogSignal`` object within the ``AnalogSignalList`` with the simple syntax ``aslist[id]``:: 221 221 222 222 >>> aslist[0] … … 227 227 print as.signal 228 228 229 As you can see in the example, one can navig uate and iterate over a``AnalogSignalList`` object and have access to230 all the ``AnalogSignal`` within the object. To have an explicite list of all the idcontained in the ``AnalogSignalList``,231 use the function ``id_list()`` 229 As you can see in the example, one can navigate and iterate over an ``AnalogSignalList`` object and have access to 230 all the ``AnalogSignal``\s within the object. To have an explicit list of all the ids contained in the ``AnalogSignalList``, 231 use the function ``id_list()``:: 232 232 233 233 >>> aslist.id_list() … … 236 236 <type 'exceptions.Exception'>: id 15 is not present in the AnalogSignalList. See id_list() 237 237 238 You can't access ``AnalogSignal`` of non recorded cells :-)238 You can't access ``AnalogSignal``\s of non recorded cells :-) 239 239 240 240 Viewing and saving 241 241 ~~~~~~~~~~~~~~~~~~ 242 242 243 Similarly to the ``SpikeList object``, some methods of the ``AnalogSignalList`` object havecan244 generate plots. Again, a plot can be either a new figure or a subplot 243 Similarly to the ``SpikeList object``, some methods of the ``AnalogSignalList`` object can 244 generate plots. Again, a plot can be either a new figure or a subplot:: 245 245 246 246 >>> vmlist.plot(1, display= subplot(221), kwargs={'color':'r'}) 247 247 248 Again, also, those ``AnalogSignalList`` objects can be saved to file. You just have to use the already implemented ``FileHandler`` (see io.py) ``StandardTextFile`` (default) or ``StandardPickleFile`` and use the ``save()`` method 248 Again, also, those ``AnalogSignalList`` objects can be saved to file. You just have to use the already implemented ``FileHandler`` (see io.py) ``StandardTextFile`` (default) or ``StandardPickleFile`` and use the ``save()`` method:: 249 249 250 250 >>> vmlist.save("vm.dat") # Will create a text file by default … … 254 254 255 255 Note that for the moment, there is a slight distinction for the conductance files, since the ``load`` function is 256 tun ned for pyNN. Since pyNN saves exc/inh conductances in the same file, the ``load`` function, called on a file257 generated by pyNN, will return two ``AnalogSignalList``256 tuned for PyNN. Since PyNN saves exc/inh conductances in the same file, the ``load`` function, called on a file 257 generated by PyNN, will return two ``AnalogSignalList`` :: 258 258 259 259 >>> ge, gi = load("conductance.dat",'g') 260 260 261 262 261 .. _PyNN: http://neuralensemble.org/PyNN/

