Changeset 348

Show
Ignore:
Timestamp:
11/16/08 00:47:40 (2 months ago)
Author:
mschmucker
Message:

added more documentation on what the example is actually doing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/sfn2008/sfn_example_stgen.py

    r347 r348  
    55and the SpikeTrain class. 
    66 
     7- Creates two poisson spike trains with approx. rate of 100 Hz.  
     8- Calculates rate, coefficient of variance and fano factor using the  
     9  functions form SpikeTrain. 
     10- Calculates cross correlation between the two SpikeTrains. 
     11- generates a third SpikeTrain with rate ~10Hz and merges it into the  
     12  previous two, effectively injecting correlation. 
     13- Plots the cross correlation for the correlated and uncorrelated SpikeTrains. 
     14- Generates shot noise from one SpikeTrain using the StGEn class and plots it. 
     15- Calculates spike triggered average from shot noise to reconstruct the initial  
     16  shot noise kernel. 
     17 
    718Performed at the NeuroTools demo session, INCF booth,  
    819SfN annual meeting 2008, Washington. DC. 
    920""" 
    1021import NeuroTools.stgen as stgen 
     22import pylab 
    1123sg = stgen.StGen() 
    1224duration = 10000. 
     
    3244                     mode = 'same') 
    3345 
    34 import pylab 
    35 pylab.plot(cc) 
     46pylab.plot(cc, label = 'no correlation') 
    3647 
    37 # inject correlation into st1 and st2 (only if correlation is > 0) 
     48# inject correlation into st1 and st2  
    3849st3 = sg.poisson_generator(rate=rate_shared, t_stop = duration)  
    3950st1.merge(st3) 
     
    4455                      mode = 'same') 
    4556 
    46 import pylab 
    47 pylab.plot(cc2) 
     57pylab.plot(cc2, label = '10% correlation') 
     58pylab.legend() 
     59pylab.show() 
    4860 
    4961#generate shot noise from st1 
     
    5365                                      t_start = st1.t_start,  
    5466                                      t_stop = st1.t_stop) 
    55 pylab.figure() 
     67f = pylab.figure() 
    5668pylab.plot(st1_shot.signal) 
     69f.gca().set_title('shot noise') 
     70f.gca().set_xlabel('time [ms]') 
    5771 
    5872# spike triggered average reveals the original shot-noise kernel