Changeset 349

Show
Ignore:
Timestamp:
11/16/08 01:08:04 (2 months ago)
Author:
JensKremkow
Message:

sfn examples

Files:

Legend:

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

    r347 r349  
    33 
    44Example to show off some capabilities of the parameters module. 
     5 
     6- creates a ParameterSpace of c and jitter for the example shown in sfn_example_stgen.py 
     7- the parameters c and jitter are scanned and the cc and the corrcoef are calculated 
     8- all the cc's are plotted 
     9-  
    510 
    611Performed at the NeuroTools demo session, INCF booth,  
     
    914import NeuroTools.stgen as stgen 
    1015sg = stgen.StGen() 
    11 duration = 10000. 
    12 nu = 20. 
    13 c = 0.1 # correlation 
    14 rate_independent = (1-c)*nu 
    15 rate_shared = c*nu 
    16  
    17 # example parameter space range etc. 
    18 # parameter scan, c vs. jitter 
    19  
     16# function of the example in sfn_example_stgen.py 
    2017def calc_cc(p): 
    2118    rate_independent = (1-p.c)*p.nu 
     
    2522    st2 = sg.poisson_generator(rate=rate_independent, t_stop = p.duration) 
    2623    if p.c > 0.: 
    27         st3 = sg.poisson_generator(rate=rate_shared, t_stop = duration)  
     24        st3 = sg.poisson_generator(rate=rate_shared, t_stop = p.duration)  
    2825        st1.merge(st3.jitter(p.jitter)) 
    2926        st2.merge(st3.jitter(p.jitter)) 
     
    3330    corrcoef = numpy.corrcoef(st1.time_histogram(time_bin = 1.0), 
    3431                              st2.time_histogram(time_bin = 1.)) 
    35     return cc, corrcoef[0][1] 
     32    time_axis_cc = numpy.linspace(-cc.shape[0]/2.,cc.shape[0]/2.,cc.shape[0]) 
     33    return cc, time_axis_cc, corrcoef[0][1] 
    3634 
    3735 
    38  
     36
    3937from NeuroTools.parameters import ParameterSpace 
    4038from NeuroTools.parameters import ParameterRange 
    4139from NeuroTools.sandbox import make_name 
    42  
     40# creating a ParameterSpace 
    4341p = ParameterSpace({}) 
     42# adding paramters 
    4443p.nu = 20. # Hz 
     44# adding a ParameterRange 
    4545p.c = ParameterRange([0.0,0.01,0.1,0.5]) 
    4646p.jitter = ParameterRange([0.0,1.0,5.0,]) 
    4747p.duration = 1000. 
    4848 
     49# calculation of the ParameterSpace dimension and the labels of the parameters containing a range 
    4950dims, labels = p.parameter_space_dimension_labels() 
    50  
     51# creating a results arry, with the dimensions of the ParameterSpace 
    5152corrcoef_results = numpy.empty(dims) 
    5253 
     54# scanning the Space 
    5355for experiment in p.iter_inner(): 
     56    # calculation of the index in the space 
    5457    index = p.parameter_space_index(experiment) 
    55     cc, corrcoef = calc_cc(experiment) 
    56     time_axis = numpy.linspace(-cc.shape[0]/2.,cc.shape[0]/2.,cc.shape[0]
     58    # perfomring the experiment 
     59    cc,time_axis_cc, corrcoef = calc_cc(experiment
    5760    corrcoef_results[index] = corrcoef 
     61    # plotting the cc's 
    5862    subplot_index = (dims[1]*index[0])+index[1] 
    5963    pylab.subplot(dims[0],dims[1],subplot_index+1) 
    60     pylab.plot(time_axis,cc) 
     64    pylab.plot(time_axis_cc,cc) 
    6165    pylab.title(make_name(experiment,p.range_keys())) 
    6266    pylab.xlim(-30,30.) 
    6367    pylab.ylim(0,130.) 
    64      
    6568 
    6669 
     70 
     71pylab.matshow(corrcoef_results) 
     72pylab.xticks(numpy.arange(0.5,dims[1]+0.5,1.0),[str(i) for i in p.jitter._values]) 
     73pylab.yticks(numpy.arange(0.5,dims[0]+0.5,1.0),[str(i) for i in p.c._values]) 
     74pylab.xlim(0,dims[1]) 
     75pylab.ylim(dims[0],0) 
     76pylab.xlabel('jitter (ms)') 
     77pylab.ylabel('correlation') 
     78ax = pylab.colorbar() 
     79ax.set_label('correlation') 
     80pylab.draw() 
     81 
  • trunk/examples/sfn2008/sfn_example_simulated_data.py

    r345 r349  
    11import NeuroTools.signals as signals 
     2""" 
     3Example to show off some capabilities of the signals module  
     4and the SpikeList and AnalogSignalList class. 
     5 
     6- loads spiking and voltage data simulated with pyNN 
     7- calculates various measurements (mean firing rate, cv...) 
     8- plot the signals 
     9- plots the spike-triggered-averages 
     10 
     11Performed at the NeuroTools demo session, INCF booth,  
     12SfN annual meeting 2008, Washington. DC. 
     13""" 
     14 
     15# loading spiking data 
     16s = signals.load_spikelist('spike_data') 
     17 
     18# raster plot 
     19s.raster_plot() 
     20 
     21# mean rate 
     22print 'mean rate: ',s.mean_rate() 
     23print 'mean rates: ',s.mean_rates() 
     24# fano factor of isi 
     25print 'fano factor of isi: ',s.fano_factors_isi() 
     26# cv of isi 
     27print 'cv of isi:',s.cv_isi() 
     28 
     29# isi distribution 
     30hs = s.isi_hist() 
     31pylab.plot(hs[1],hs[0]) 
    232 
    333 
    4 s = signals.load_spikelist('spike_data') 
     34# loading voltage data 
    535v = signals.load_vmlist('vm_data') 
    6 c = signals.load_conductancelist('c_data') 
     36 
     37# plot all the signals 
     38v.plot() 
     39# plot only one AnalogSignal 
     40v[1].plot() 
     41 
     42# spike triggered averages 
     43v.event_triggered_average(s,t_min=50.) 
     44 
  • trunk/examples/sfn2008/sfn_example_spike2.py

    r345 r349  
    11import NeuroTools.spike2.spike2channels as spike2 
    22import pylab, numpy 
     3""" 
     4Example to show off some capabilities of the spike2 module  
     5and the SpikeTrain and AnalogSignal class. 
     6 
     7- loads content from a CED Son file which contains data from a IF-curve experiment 
     8- then the data is processed and a IF-Curve is plotted 
     9 
     10Performed at the NeuroTools demo session, INCF booth,  
     11SfN annual meeting 2008, Washington. DC. 
     12""" 
    313 
    414# IF-curve 
     
    1525dc = all_channels[1] 
    1626dc_onset_marker = all_channels[32] 
     27 
     28pylab.close('all') 
     29# show original data 
     30# vm 
     31pylab.figure() 
     32pylab.plot(vm.time_axis(),vm.signal()) 
     33# currents 
     34pylab.figure() 
     35pylab.plot(dc.time_axis(),dc.signal()) 
     36# dc_onset_markers 
     37 
    1738 
    1839# cutout the dc and vm around a dc step, markers are in seconds, we need them in milliseonds