Changeset 349
- Timestamp:
- 11/16/08 01:08:04 (2 months ago)
- Files:
-
- trunk/examples/sfn2008/sfn_example_parameterspace.py (modified) (4 diffs)
- trunk/examples/sfn2008/sfn_example_simulated_data.py (modified) (1 diff)
- trunk/examples/sfn2008/sfn_example_spike2.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/sfn2008/sfn_example_parameterspace.py
r347 r349 3 3 4 4 Example 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 - 5 10 6 11 Performed at the NeuroTools demo session, INCF booth, … … 9 14 import NeuroTools.stgen as stgen 10 15 sg = 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 20 17 def calc_cc(p): 21 18 rate_independent = (1-p.c)*p.nu … … 25 22 st2 = sg.poisson_generator(rate=rate_independent, t_stop = p.duration) 26 23 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) 28 25 st1.merge(st3.jitter(p.jitter)) 29 26 st2.merge(st3.jitter(p.jitter)) … … 33 30 corrcoef = numpy.corrcoef(st1.time_histogram(time_bin = 1.0), 34 31 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] 36 34 37 35 38 36 # 39 37 from NeuroTools.parameters import ParameterSpace 40 38 from NeuroTools.parameters import ParameterRange 41 39 from NeuroTools.sandbox import make_name 42 40 # creating a ParameterSpace 43 41 p = ParameterSpace({}) 42 # adding paramters 44 43 p.nu = 20. # Hz 44 # adding a ParameterRange 45 45 p.c = ParameterRange([0.0,0.01,0.1,0.5]) 46 46 p.jitter = ParameterRange([0.0,1.0,5.0,]) 47 47 p.duration = 1000. 48 48 49 # calculation of the ParameterSpace dimension and the labels of the parameters containing a range 49 50 dims, labels = p.parameter_space_dimension_labels() 50 51 # creating a results arry, with the dimensions of the ParameterSpace 51 52 corrcoef_results = numpy.empty(dims) 52 53 54 # scanning the Space 53 55 for experiment in p.iter_inner(): 56 # calculation of the index in the space 54 57 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) 57 60 corrcoef_results[index] = corrcoef 61 # plotting the cc's 58 62 subplot_index = (dims[1]*index[0])+index[1] 59 63 pylab.subplot(dims[0],dims[1],subplot_index+1) 60 pylab.plot(time_axis ,cc)64 pylab.plot(time_axis_cc,cc) 61 65 pylab.title(make_name(experiment,p.range_keys())) 62 66 pylab.xlim(-30,30.) 63 67 pylab.ylim(0,130.) 64 65 68 66 69 70 71 pylab.matshow(corrcoef_results) 72 pylab.xticks(numpy.arange(0.5,dims[1]+0.5,1.0),[str(i) for i in p.jitter._values]) 73 pylab.yticks(numpy.arange(0.5,dims[0]+0.5,1.0),[str(i) for i in p.c._values]) 74 pylab.xlim(0,dims[1]) 75 pylab.ylim(dims[0],0) 76 pylab.xlabel('jitter (ms)') 77 pylab.ylabel('correlation') 78 ax = pylab.colorbar() 79 ax.set_label('correlation') 80 pylab.draw() 81 trunk/examples/sfn2008/sfn_example_simulated_data.py
r345 r349 1 1 import NeuroTools.signals as signals 2 """ 3 Example to show off some capabilities of the signals module 4 and 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 11 Performed at the NeuroTools demo session, INCF booth, 12 SfN annual meeting 2008, Washington. DC. 13 """ 14 15 # loading spiking data 16 s = signals.load_spikelist('spike_data') 17 18 # raster plot 19 s.raster_plot() 20 21 # mean rate 22 print 'mean rate: ',s.mean_rate() 23 print 'mean rates: ',s.mean_rates() 24 # fano factor of isi 25 print 'fano factor of isi: ',s.fano_factors_isi() 26 # cv of isi 27 print 'cv of isi:',s.cv_isi() 28 29 # isi distribution 30 hs = s.isi_hist() 31 pylab.plot(hs[1],hs[0]) 2 32 3 33 4 s = signals.load_spikelist('spike_data') 34 # loading voltage data 5 35 v = signals.load_vmlist('vm_data') 6 c = signals.load_conductancelist('c_data') 36 37 # plot all the signals 38 v.plot() 39 # plot only one AnalogSignal 40 v[1].plot() 41 42 # spike triggered averages 43 v.event_triggered_average(s,t_min=50.) 44 trunk/examples/sfn2008/sfn_example_spike2.py
r345 r349 1 1 import NeuroTools.spike2.spike2channels as spike2 2 2 import pylab, numpy 3 """ 4 Example to show off some capabilities of the spike2 module 5 and 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 10 Performed at the NeuroTools demo session, INCF booth, 11 SfN annual meeting 2008, Washington. DC. 12 """ 3 13 4 14 # IF-curve … … 15 25 dc = all_channels[1] 16 26 dc_onset_marker = all_channels[32] 27 28 pylab.close('all') 29 # show original data 30 # vm 31 pylab.figure() 32 pylab.plot(vm.time_axis(),vm.signal()) 33 # currents 34 pylab.figure() 35 pylab.plot(dc.time_axis(),dc.signal()) 36 # dc_onset_markers 37 17 38 18 39 # cutout the dc and vm around a dc step, markers are in seconds, we need them in milliseonds

