Changeset 310

Show
Ignore:
Timestamp:
11/10/08 10:47:23 (2 months ago)
Author:
apdavison
Message:

Editing and spellchecking of signals.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/doc/signals.txt

    r308 r310  
    1212------------ 
    1313 
    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.   
     14A spike train is a sorted vector of spike times, which is the result of a simulation or acquired by measurement. 
     15It has therefore some attributes, like ``t_start`` and ``t_stop``, which must in general 
     16be specified by the user, as they can not be inferred from the data.   
    1717 
    1818**Note:** the standard time unit used by NeuroTools is milliseconds. 
    1919 
    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. 
     20When several spike trains are gathered, they are collected in a ``SpikeList`` object, which is effectively a dictionary 
     21of spike trains, the id of the cells being used as a key. See the ``SpikeList`` class for more details. 
    2222 
    2323 
     
    3333    >>> spk2 = SpikeTrain(arange(0,100,10)) 
    3434 
    35 As you can see, defining t_start and t_stop is optional. If those attributes are not provided, 
    36 they are infered from the data as the min and the max of the spike times:: 
     35As you can see, defining ``t_start`` and ``t_stop`` is optional. If those attributes are not provided, 
     36they are inferred from the data as the min and the max of the spike times:: 
    3737 
    3838    >>> spk1.t_stop 
     
    4141        90 
    4242     
    43     You can access the raw vector of the spike times by the ``spike_times`` attribute:: 
     43You can access the raw vector of the spike times with the ``spike_times`` attribute:: 
    4444     
    4545    >>> spk1.spike_times 
     
    4949``SpikeList`` object, as we'll see later. 
    5050 
    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 
     51The ``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 
    5252details.  
    5353 
    5454An example of basic use of a ``SpikeTrain`` object is as follows:: 
    5555 
    56     >>> spk1.raster_plot() # Generates a raster_plot between t_start and t_stop 
     56    >>> spk1.raster_plot() # Generates a raster  plot between t_start and t_stop 
    5757    >>> spk1.isi() 
    5858        array([ 10.,  10.,  10.,  10.,  10.,  10.,  10.,  10.,  10.]) 
     
    6666----------------------- 
    6767 
    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``:: 
     68A ``SpikeList`` is effectively a dictionary of ``SpikeTrains``, and can be thought of conceptually as the output of a network simulation, 
     69when one records the spikes of a given population.  The ``SpikeList`` is an object to organize such a recording 
     70as 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 
     73Creation 
     74~~~~~~~~ 
     75 
     76The constructor of a ``SpikeList`` is works as follows: it will accepts a list of tuples ``(id, spike_time)``,  
     77parameters ``t_start`` and ``t_stop``, and the list of all the recorded ids. The last three parameters 
     78can'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``:: 
    7979 
    8080    >>> list = [(numpy.random.random_integers(0,10,1)[0],1000*numpy.random.rand()) for i in xrange(1000)] 
    8181    >>> spklist = SpikeList(list, range(11), t_start=0, t_stop=1000) 
    8282 
    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 ``SpikeTrains`` objects within the ``SpikeList`` will share the same t_start and t_stop 
    86  
    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  
     83Here, ``range(11)`` is used to specify that in the lists we will have cells with ids between 0 and 10 (this is needed 
     84because we can have silent cells in the ``SpikeList``), and that we will keep spikes only between ``t_start`` and ``t_stop``
     85All the ``SpikeTrain`` objects within the ``SpikeList`` will share the same ``t_start`` and ``t_stop``. 
     86 
     87Rather 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. 
     88If you have generated your data with PyNN_, you can use the loading functions made for this purpose. For example if  
    8989you have recorded the spikes of a population in a file "spikes.dat", then one can load it as a ``SpikeList`` as follows:: 
    9090     
    9191    >>> spklist = load("spikes.dat",'spikes') 
    9292 
    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:: 
     93Using this syntax, the header information contained in the file is used to create the population, and ``t_start`` and ``t_stop`` are 
     94inferred automatically as the min and the max of all the ``SpikeTrains`` within the ``SpikeList``. 
     95If you want to keep the control on the parameters while creating the ``SpikeList``, do the following:: 
    9696     
    9797    >>> spklist = load_spikelist("spikes.dat", range(11), t_start=0, t_stop=1000) 
     
    103103~~~~~~~~~~ 
    104104 
    105 You can access ``SpikeTrain`` objects within the ``Spikelist`` by the simple syntax spklist[id]:: 
     105You can access ``SpikeTrain`` objects within the ``Spikelist`` with the simple syntax ``spklist[id]``:: 
    106106 
    107107    >>> spklist[0] 
     
    112112            print spktrain.isi() 
    113113 
    114 As you can see in the example, one can naviguate and iterate over a ``SpikeList`` object and have access to 
    115 all the ``SpikeTrains`` within the object. To have an explicite list of all the id contained in the ``SpikeList``,  
     114As you can see in the example, one can navigate and iterate over a ``SpikeList`` object and have access to 
     115all the ``SpikeTrain``\s within the object. To have an explicit list of all the ids contained in the ``SpikeList``,  
    116116use the function ``id_list()``:: 
    117117 
     
    127127~~~~~~ 
    128128 
    129 You can do slices of your ``SpikeList`` object, either according to the time axis or to selected ids. 
    130      
     129You can do slices of your ``SpikeList`` object, either according to the time axis or to selected ids:: 
     130 
    131131    >>> subspklist = spklist.time_slice(500,1500) 
    132     >>> subspklist = spklist.id_slice(50) # Will select 50 randoms id within spklist.id_list() 
     132    >>> subspklist = spklist.id_slice(50) # Will select 50 random id within spklist.id_list() 
    133133    >>> subspklist = spklist.id_slice([2,3,5,6]) 
    134134 
    135 If you want to select only cells mathcing a particular criteria within the ``SpikeList``, you can use the 
    136 ``select_ids`` method 
     135If you want to select only cells matching a particular criteria within the ``SpikeList``, you can use the 
     136``select_ids`` method:: 
    137137 
    138138    >>> subspklist = spklist.select_ids("cell.mean_rate() > 0") 
     
    161161-------------- 
    162162 
    163 NeuroTools.signals also handles analog signals. These are generally also 
     163``NeuroTools.signals`` also handles analog signals. These are generally also 
    164164recorded during a simulation or experiment, such as for example a Vm trace, a conductance or a current. Such a signal is 
    165 definied by a number of values between t_start and t_stop with a time step dt
     165defined by a number of values between ``t_start`` and ``t_stop`` with a time step ``dt``
    166166 
    167167The ``AnalogSignal`` class 
     
    172172     
    173173When 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`` 
     174and 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``:: 
    175175 
    176176    >>> x = AnalogSignal(sin(arange(1000)),0.1) 
     
    183183        500 
    184184 
    185 You can access the raw data of the ``AnalogSignal`` by just using 
     185You can access the raw data of the ``AnalogSignal`` by just using:: 
    186186     
    187187    >>> x.signal 
     
    198198------------------------------ 
    199199 
    200 As for the ``SpikeList``, the ``AnalogSignalList`` is a container of ``AnalogSignal`` objects. It has the same structure than 
    201 the ``SpikeList``, meaning this is a dictionnary 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 parameters 
    208 can't be infered from the data safely, so it's better if they are specified by the user. Nevertheless, the most 
    209 commmon way to create ``SpikeList`` in NeuroTools is to use the ``load_analogsignal()`` or the ``load()`` functions, as 
    210 explained below. Currently, the constructor of the ``AnalogSignalList`` is mainly tunned to be used with those load functions,  
    211 and this is therefore not so simple to create one from a list of ``AnalogSignal``. 
     200As for the ``SpikeList``, the ``AnalogSignalList`` is a collection of ``AnalogSignal`` objects. It has the same structure as 
     201the ``SpikeList``, meaning this is a dictionary containing ``AnalogSignal``\s with the key being the id of the cells.  
     202 
     203Creation 
     204~~~~~~~~ 
     205 
     206The constructor of an ``AnalogSignalList`` is made as follows: it will accept an array with all the signals, the time step, 
     207and additional parameters like ``t_start``, ``t_stop``, and the list of all the recorded ids. The last three parameters 
     208can't be inferred from the data safely, so it's better if they are specified by the user. Nevertheless, the most 
     209common way to create ``AnalogSignal``\s in NeuroTools is to use the ``load_analogsignal()`` or ``load()`` functions, as 
     210explained below. Currently, the constructor of the ``AnalogSignalList`` is mainly tuned to be used with these load functions,  
     211and it is therefore not so simple to create one from a list of ``AnalogSignal``\s:: 
    212212 
    213213    >>> sig1 = AnalogSignal(sin(arange(10000),dt=0.1,t_start=0, t_stop=1000) 
    214  
     214    ... There seems to be something missing here? 
    215215 
    216216 
     
    218218~~~~~~~~~~ 
    219219 
    220 You can access ``AnalogSignal`` object within the ``AnalogSignalList`` by the simple syntax spklist[id]
     220You can access an ``AnalogSignal`` object within the ``AnalogSignalList`` with the simple syntax ``aslist[id]``:
    221221 
    222222    >>> aslist[0] 
     
    227227            print as.signal 
    228228 
    229 As you can see in the example, one can naviguate and iterate over a ``AnalogSignalList`` object and have access to 
    230 all the ``AnalogSignal`` within the object. To have an explicite list of all the id contained in the ``AnalogSignalList``,  
    231 use the function ``id_list()`` 
     229As you can see in the example, one can navigate and iterate over an ``AnalogSignalList`` object and have access to 
     230all the ``AnalogSignal``\s within the object. To have an explicit list of all the ids contained in the ``AnalogSignalList``,  
     231use the function ``id_list()``:: 
    232232 
    233233    >>> aslist.id_list() 
     
    236236        <type 'exceptions.Exception'>: id 15 is not present in the AnalogSignalList. See id_list() 
    237237 
    238 You can't access ``AnalogSignal`` of non recorded cells :-) 
     238You can't access ``AnalogSignal``\s of non recorded cells :-) 
    239239 
    240240Viewing and saving 
    241241~~~~~~~~~~~~~~~~~~ 
    242242 
    243 Similarly to the ``SpikeList object``, some methods of the ``AnalogSignalList`` object have can  
    244 generate plots. Again, a plot can be either a new figure or a subplot 
     243Similarly to the ``SpikeList object``, some methods of the ``AnalogSignalList`` object can  
     244generate plots. Again, a plot can be either a new figure or a subplot:: 
    245245 
    246246    >>> vmlist.plot(1, display= subplot(221), kwargs={'color':'r'}) 
    247247 
    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 
     248Again, 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:: 
    249249 
    250250    >>> vmlist.save("vm.dat") # Will create a text file by default 
     
    254254 
    255255Note that for the moment, there is a slight distinction for the conductance files, since the ``load`` function is 
    256 tunned 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``  
     256tuned for PyNN. Since PyNN saves exc/inh conductances in the same file, the ``load`` function, called on a file 
     257generated by PyNN, will return two ``AnalogSignalList`` :: 
    258258 
    259259    >>> ge, gi = load("conductance.dat",'g') 
    260260 
    261  
    262  
     261.. _PyNN: http://neuralensemble.org/PyNN/