Show
Ignore:
Timestamp:
05/12/08 18:49:09 (4 years ago)
Author:
LaurentPerrinet
Message:

more polishing to allow easier copy/paste of code

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/retina/benchmark_noise.py

    r167 r172  
    55================== 
    66 
    7 Just studying how different background noise current is integrated by the neurons on one fiber. 
     7Just studying how different background noise current are integrated by the 
     8neurons on the retinal fibers. 
     9 
     10Illustrates how one many use parameters to explore one set of parameters and 
     11compute a CRF function. See benchmark_linear to store time varrying values. 
    812 
    913Laurent Perrinet, INCM, CNRS 
     
    1317""" 
    1418 
    15 import os, datetime, numpy, shelve 
     19import os, sys, numpy, shelve 
    1620 
    1721from NeuroTools.parameters import * 
     
    2529p.noise_std = ParameterRange(list(10.**(numpy.linspace(-.50,1.,N_exp_noise)))) 
    2630 
    27 results = shelve.open('results/benchmark_noise') 
     31import retina as model 
     32 
     33 
     34retina = model.Retina(N)  
     35retina.params['snr'] = 0 # no input 
     36 
     37 
     38name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part 
     39results = shelve.open('results/mat-' + name) 
    2840try: 
    2941    CRF = results['CRF'] 
    30     params = results['params'] 
     42except: 
    3143     
    32 except: 
    33     import retina as model 
    34  
    35  
    36     retina = model.Retina(N) 
    37     retina.params['snr'] = 0 
    3844    # calculates the dimension of the parameter space 
    3945    results_dim, results_label = p.parameter_space_dimension_labels() 
    4046 
    4147    # creates results array with size of parameter space dimension 
    42  
    4348    CRF = numpy.empty(results_dim) 
    4449 
    45     pbar=progressbar.ProgressBar(widgets=["calculating", " ", progressbar.Percentage(), ' ', 
     50    pbar=progressbar.ProgressBar(widgets=[name, " ", progressbar.Percentage(), ' ', 
    4651            progressbar.Bar(), ' ', progressbar.ETA()], maxval=numpy.prod(results_dim)) 
    4752    for i_exp,experiment in enumerate(p.iter_inner()): 
     
    5661        pbar.update(i_exp) 
    5762 
     63    results['CRF'] = CRF 
    5864 
    59  
    60  
    61     results['params'] = params 
    62     results['CRF'] = CRF 
    6365    pbar.finish() 
    6466 
     
    7577""" 
    7678 
    77  
    78 #params = retina.params 
    79 N, simtime = params['N'], params['simtime'] 
     79N, simtime = retina.params['N'], retina.params['simtime'] 
    8080 
    8181import pylab 
    8282 
    83 #pylab.rcParams.update(pylab_params(fig_width_pt =497.9/5, ratio = 1/1.2)) 
    84 pylab.figure(num = 1)#, dpi=200, facecolor='w', edgecolor='k') 
    85  
    86 #Lmargin, Rmargin, dmargin, umargin = 0.15, 0.05, 0.15,  0.05 
    87 #pylab.axes([Lmargin, dmargin , 1.0 - Rmargin- Lmargin,1.0-umargin-dmargin]) # [left, bottom, width, height] 
     83pylab.figure(num = 1) 
    8884 
    8985pylab.plot(p.noise_std._values,CRF,'go-', label='line 1', linewidth=2) 
    9086pylab.ylabel('Firing Frequency (Hz)') 
    9187pylab.xlabel('Noise amplitude') 
    92 #pylab.axis('tight') 
    93 pylab.savefig('results/benchmark_noise.pdf')#, dpi=300) # 
    94 #command = 'epstopdf  "%s" "%s"'% (pdffile, psfile) 
    95 #os.system(command) 
    9688 
    97 #TODO: make a plot showing it's the right point process with a histogram 
     89pylab.savefig('results/fig-' + name + '.pdf') 
     90pylab.savefig('results/fig-' + name + '.png', dpi = 300) 
     91