Show
Ignore:
Timestamp:
11/12/08 19:49:46 (4 years ago)
Author:
LaurentPerrinet
Message:

wiki:examples : reflect changes in the wiki:parameters API / polishing figures to give usable examples

Files:
1 modified

Legend:

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

    • Property svn:keywords set to Id
    r220 r326  
    1919 
    2020N, N_exp = 1000, 6 
    21 p = ParameterSet({}) 
    2221t_smooth = 100. # width (in ms) of the integration window 
    2322from retina import * 
    2423retina = Retina(N) 
     24retina.params['amplitude'] = 1 
     25snr  = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 
     26p =  ParameterSpace({'snr' : ParameterRange(list(snr))}) 
     27 
    2528 
    2629name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part 
     
    3336 
    3437except: 
    35     snr  = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 
    36     p.snr = ParameterRange(list(snr)) 
     38 
    3739    # calculates the dimension of the parameter space 
    3840    results_dim, results_label = p.parameter_space_dimension_labels() 
     
    7880 
    7981""" 
    80 pylab.close('all') 
    81 pylab.rcParams.update(pylab_params(fig_width_pt = 497.9/2., ratio = 1.)) 
    82 pylab.figure(num = 1, dpi=150, facecolor='w', edgecolor='k') 
    83 Lmargin, Rmargin, dmargin, umargin = 0.2, 0.05, 0.15,  0.05 
    84 pylab.axes([Lmargin, dmargin , 1.0 - Rmargin- Lmargin,1.0-umargin-dmargin]) # [left, bottom, width, height] 
     82#pylab.close('all') 
     83#pylab.rcParams.update(pylab_params(fig_width_pt = 497.9/2., ratio = 1.)) 
     84pylab.figure(1) 
     85fmax = numpy.max([numpy.max(temporal_OFF[:]),numpy.max(temporal_ON[:])]) 
    8586 
     87pylab.subplot(211) 
    8688for i_exp in range(N_exp): 
    87     pylab.plot(lower_edges,  # TODO add a half bin 
    88                     temporal_ON[i_exp])#, 
    89                        # label= 'snr=' + str(benchmark.get('experiments')[experiment]['snr'])) 
    90 #pylab.subplot(121) 
    91 #pylab.title('time course')# ON 
     89    pylab.plot(lower_edges[:-1] + t_smooth/2,  # TODO add a half bin 
     90                    temporal_ON[i_exp])# 
    9291pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 
    93 pylab.ylabel('Firing frequency (Hz)') 
     92pylab.ylabel('ON Firing frequency (Hz/neuron)') 
     93pylab.axis([0, retina.params.simtime, 0.0, fmax]) 
     94pylab.subplot(212) 
     95for i_exp in range(N_exp): 
     96    pylab.plot(lower_edges[:-1] + t_smooth/2,  # TODO add a half bin 
     97                    temporal_OFF[i_exp], 
     98                        label= 'snr= %5.3f' % p.snr._values[i_exp] ) 
     99pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 
     100pylab.ylabel('OFF Firing frequency (Hz/neuron)') 
    94101pylab.xlabel('time (ms)') 
    95 pylab.axis('tight') 
     102pylab.axis([0, retina.params.simtime, 0.0, fmax ]) 
    96103 
    97 #pylab.legend() 
     104pylab.legend(loc='upper right') 
    98105 
    99 #pylab.subplot(122) 
    100 #pylab.title('time course OFF') 
    101 #pylab.xticks( numpy.linspace(0, simtime, 5) ) 
    102 #pylab.ylabel('firing frequency (Hz)') 
    103 #pylab.axis('tight') 
    104 #pylab.xlabel('time (ms)') 
    105 #pylab.legend() 
    106106 
    107 pylab.savefig('results/fig-' + name + '.pdf') 
    108 pylab.savefig('results/fig-' + name + '.png', dpi = 300) 
     107if 0: 
     108    pylab.ion() 
     109    #pylab.show() 
     110else: 
     111    pylab.savefig('results/fig-' + name + '.pdf') 
     112    pylab.savefig('results/fig-' + name + '.png', dpi = 300) 
    109113 
    110 #TODO: make a plot showing it's the right point process with a histogram