Show
Ignore:
Timestamp:
11/14/08 19:17:05 (3 years ago)
Author:
LaurentPerrinet
Message:

some polishing of the wiki:examples, the retina needs a bit more work...

Files:
1 modified

Legend:

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

    r333 r340  
    1616import os, sys, numpy, pylab, shelve 
    1717 
     18N, N_exp = 1000, 6 
     19t_smooth = 100. # width (in ms) of the integration window 
     20from NeuroTools.parameters import ParameterSpace, ParameterRange 
     21snr  = 2.0 * numpy.linspace(0.1,2.0,N_exp) 
     22p = ParameterSpace({'snr' : ParameterRange(list(snr))}) 
     23 
    1824 
    1925name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part 
     
    2834 
    2935except: 
    30     N, N_exp = 1000, 6 
    31     t_smooth = 100. # width (in ms) of the integration window 
    3236    from retina import * 
    3337    retina = Retina(N) 
    3438    retina.params['amplitude'] = numpy.ones(retina.params['amplitude'].shape) 
    35     snr  = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 
    36     from NeuroTools.parameters import ParameterSpace 
    37     p = ParameterSpace({'snr' : ParameterRange(list(snr))}) 
     39     
    3840 
    3941    # calculates the dimension of the parameter space 
     
    6567    results['temporal_ON'] = temporal_ON 
    6668    results['temporal_OFF'] = temporal_OFF 
    67     results['params'] = params 
     69    results['params'] = retina.params 
    6870 
    6971    pbar.finish() 
     
    8486#pylab.rcParams.update(pylab_params(fig_width_pt = 497.9/2., ratio = 1.)) 
    8587pylab.figure(1) 
    86 fmax = numpy.max([numpy.max(temporal_OFF[:]),numpy.max(temporal_ON[:])]) 
     88#fmax = numpy.max([numpy.max(temporal_OFF[:]),numpy.max(temporal_ON[:])]) 
    8789 
    8890pylab.subplot(211) 
    8991for i_exp in range(N_exp): 
    90     pylab.plot(lower_edges[:-1] + t_smooth/2,  # TODO add a half bin 
    91                     temporal_ON[i_exp])# 
    92 pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 
    93 pylab.ylabel('ON Firing frequency (Hz/neuron)') 
    94 pylab.axis([0, retina.params.simtime, 0.0, fmax]) 
     92    pylab.plot(lower_edges[:-1] + t_smooth/2, temporal_ON[i_exp], 
     93                        label= '%5.2f' % p.snr._values[i_exp]) 
     94pylab.xticks( numpy.round(numpy.linspace(0, params.simtime, 5),0) ) 
     95pylab.ylabel('ON Firing frequency (Hz)') 
     96pylab.axis([0, params.simtime, 0.0, numpy.max(temporal_ON[:])]) 
     97pylab.legend(loc='upper right') 
    9598pylab.subplot(212) 
    9699for i_exp in range(N_exp): 
    97     pylab.plot(lower_edges[:-1] + t_smooth/2,  # TODO add a half bin 
    98                     temporal_OFF[i_exp], 
    99                         label= 'snr= %5.3f' % p.snr._values[i_exp] ) 
    100 pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 
    101 pylab.ylabel('OFF Firing frequency (Hz/neuron)') 
     100    pylab.plot(lower_edges[:-1] + t_smooth/2, temporal_OFF[i_exp]) 
     101pylab.xticks( numpy.round(numpy.linspace(0, params.simtime, 5),0) ) 
     102pylab.ylabel('OFF Firing frequency (Hz)') 
    102103pylab.xlabel('time (ms)') 
    103 pylab.axis([0, retina.params.simtime, 0.0, fmax ]) 
    104  
    105 pylab.legend(loc='upper right') 
     104pylab.axis([0, params.simtime, 0.0, numpy.max(temporal_OFF[:]) ]) 
    106105 
    107106