Changeset 333

Show
Ignore:
Timestamp:
11/13/08 14:20:47 (2 months ago)
Author:
LaurentPerrinet
Message:

little clean-up in the wiki:examples scripts to get near to real-world scripts

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/retina/benchmark_linear.py

    r326 r333  
    1515 
    1616import os, sys, numpy, pylab, shelve 
    17 import progressbar # see http://projects.scipy.org/pipermail/scipy-dev/2008-January/008200.html 
    18 from NeuroTools.parameters import * 
    19  
    20 N, N_exp = 1000, 6 
    21 t_smooth = 100. # width (in ms) of the integration window 
    22 from retina import * 
    23 retina = Retina(N) 
    24 retina.params['amplitude'] = 1 
    25 snr  = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 
    26 p =  ParameterSpace({'snr' : ParameterRange(list(snr))}) 
    2717 
    2818 
     
    3424    temporal_OFF = results['temporal_OFF'] 
    3525    lower_edges = results['lower_edges'] 
     26    params = results['params'] 
     27    #if (params == retina.params): raise('Parameters have changed') 
    3628 
    3729except: 
     30    N, N_exp = 1000, 6 
     31    t_smooth = 100. # width (in ms) of the integration window 
     32    from retina import * 
     33    retina = Retina(N) 
     34    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))}) 
    3838 
    3939    # calculates the dimension of the parameter space 
     
    4646     
    4747    temporal_ON, temporal_OFF = [],[] 
    48  
     48    import progressbar # see http://projects.scipy.org/pipermail/scipy-dev/2008-January/008200.html 
    4949    pbar=progressbar.ProgressBar(widgets=[name, " ", progressbar.Percentage(), ' ', 
    5050            progressbar.Bar(), ' ', progressbar.ETA()], maxval=N_exp) 
     
    6565    results['temporal_ON'] = temporal_ON 
    6666    results['temporal_OFF'] = temporal_OFF 
     67    results['params'] = params 
    6768 
    6869    pbar.finish() 
  • trunk/examples/retina/benchmark_noise.py

    r326 r333  
    1919import os, sys, numpy, shelve 
    2020 
    21 from NeuroTools.parameters import * 
    22  
    23 # this is not mandatory but just a "easy_install progressbar" away 
    24 # else remove all corresponding lines in this code... 
    25 import progressbar # see http://projects.scipy.org/pipermail/scipy-dev/2008-January/008200.html 
    26  
    27 N, N_exp_noise = 1000, 22 
    28  
    29 p =  ParameterSpace({'noise_std' : ParameterRange(list(10.**(numpy.linspace(-.50,1.,N_exp_noise))))}) 
    30  
    31 import retina as model 
    32 retina = model.Retina(N)  
    3321retina.params['snr'] = 0 # no input 
    3422 
     
    3927    CRF = results['CRF'] 
    4028except: 
    41      
     29         
     30    from NeuroTools.parameters import * 
     31 
     32    # this is not mandatory but just a "easy_install progressbar" away 
     33    # else remove all corresponding lines in this code... 
     34    import progressbar # see http://projects.scipy.org/pipermail/scipy-dev/2008-January/008200.html 
     35 
     36    N, N_exp_noise = 1000, 22 
     37 
     38    p =  ParameterSpace({'noise_std' : ParameterRange(list(10.**(numpy.linspace(-.50,1.,N_exp_noise))))}) 
     39 
     40    import retina as model 
     41    retina = model.Retina(N)  
    4242    # calculates the dimension of the parameter space 
    4343    results_dim, results_label = p.parameter_space_dimension_labels() 
  • trunk/examples/retina/benchmark_retina.py

    r326 r333  
    2525import os, sys, numpy, pylab, shelve, progressbar 
    2626 
    27 from NeuroTools.parameters import * 
    28  
    29 N, N_snr, N_seeds = 1000, 5, 10 
    30 from retina import * 
    31 retina = Retina(N) 
    32  
    33 t_smooth = 100. # ms.  integration time to show fiber activity 
    34  
    35 p =  ParameterSpace({ 
    36                 'snr' : ParameterRange(list(numpy.linspace(0.1,2.0,N_snr))), 
    37                 'kernelseed' : ParameterRange(list([retina.params['kernelseed'] + k for k in range(N_seeds)]))}) 
    38  
    3927 
    4028name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part 
    41 #### MAKING THE SIMULATIONS ########## 
     29############## MAKING THE SIMULATIONS ############### 
    4230results = shelve.open('results/mat-' + name) 
    4331try: 
    4432    DATA = results['DATA'] 
    4533except: 
     34 
     35    from NeuroTools.parameters import * 
     36 
     37    N, N_snr, N_seeds = 1000, 5, 10 
     38    from retina import * 
     39    retina = Retina(N) 
     40 
     41    t_smooth = 100. # ms.  integration time to show fiber activity 
     42 
     43    p =  ParameterSpace({ 
     44                    'snr' : ParameterRange(list(numpy.linspace(0.1,2.0,N_snr))), 
     45                    'kernelseed' : ParameterRange(list([retina.params['kernelseed'] + k for k in range(N_seeds)]))}) 
    4646 
    4747    # calculates the dimension of the parameter space 
     
    6767############## PRE-PROCESSING ########################### 
    6868try: 
    69     #boing # uncomment to force recomputing 
     69    #boing # uncomment to force recomputing the pre-processing stage 
    7070    lower_edges = results['lower_edges'] 
    7171    temporal_ON = results['temporal_ON'] 
     
    9191    r2 = x**2 + y**2 
    9292    r = numpy.sqrt(r2) 
    93     id_center = [int(k) for k in numpy.where( r2 < N_ret**2)
     93    id_center = [int(k) for k in numpy.where( r2 < N_ret**2)[0]
    9494 
    9595    # mean activity accross kernelseeds as a function of SNR