Show
Ignore:
Timestamp:
01/15/08 17:44:22 (4 years ago)
Author:
LaurentPerrinet
Message:

Finished examples of use of NeuroTools: retina / renamd SpikeTrain.mean_firing_rate to SpikeTrain.mean_rate for consistency with SpikeList.mean_rate / bugfix in spikes.py for the definition of a range in SpikeTrain.mean_rate

Files:
1 modified

Legend:

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

    r97 r101  
    1717import retina as model 
    1818import NeuroTools.benchmark as benchmark 
    19  
    20  
    2119 
    2220 
     
    4341 
    4442    N, N_ret, simtime = params['N'], params['N_ret'], params['simtime'] 
    45     N_smooth = 100 # how many time bins 
     43    t_smooth = 100. #  smooting time (ms) 
    4644 
    4745    for experiment in experiment_list: 
     
    5048        except: 
    5149            print "Loading data for experiment " , experiment 
    52             out_ON_DATA = benchmark.get('out',experiment)['out_ON_DATA'] 
    53             # ON 
    54             temporal_ON , lower_edges = numpy.histogram(out_ON_DATA.as_list_id_list_time()[1], 
    55                                         bins=N_smooth, range=(out_ON_DATA.t_start,out_ON_DATA.t_stop)) 
    56             temporal_ON /= N**2 
    57             # OFF : noit very useful here 
    58             #out_OFF_DATA = benchmark.get('out',experiment)['out_OFF_DATA'] 
    59 ##            temporal_OFF , lower_edges = numpy.histogram(out_OFF_DATA.as_list_id_list_time()[1], 
    60 ##                                        bins=N_smooth, range=(out_ON_DATA.t_start,out_ON_DATA.t_stop)) 
    61 ##            temporal_OFF /= N**2 
     50            out_ON = benchmark.get('out',experiment)['out_ON_DATA'] 
     51 
    6252            # storing 
    6353            benchmark.put('firing_rate',{ 
    64                     'temporal_ON' : temporal_ON, 
    65 ##                    'temporal_OFF' : temporal_OFF, 
    66                     'lower_edges' : lower_edges, 
     54                    'temporal_ON' : sum(out_ON.firing_rate(t_smooth))/N, 
     55                    #'temporal_OFF' : out_OFF.firing_rate(t_smooth), 
     56                    'lower_edges' : out_ON.time_axis(t_smooth), 
    6757                    'firing_rate_ok' : True # a flag to do it once 
    6858                      }, experiment ) 
     
    8979    #pylab.legend() 
    9080 
    91     pylab.savefig(benchmark.filename + '/benchmark_linear.png') #, dpi=300) # 
     81    pylab.savefig(benchmark.filename + '/benchmark_linear.pdf') #, dpi=300) # 
    9282 
    9383 
    9484if __name__ == '__main__': 
    9585 
    96     # not working tag= '07-02-16' 
    97     # tag= '07-02-14' 
    98     # tag= '07-02-23' 
    99     tag= '07-02-27' 
    100     tag = '07-03-08' 
    101     tag = '07-05-09' 
    10286    tag = 'test' 
    10387 
     
    10690 
    10791    ret = model.Retina(21) 
    108     ret.params['simtime'] = 4000*0.1 
    109     ret.params['amplitude'] = numpy.ones((ret.params['N'],ret.params['N'] )) 
    110  
    111     run = benchmark.get_experiment_dict({'snr' : 10.**(numpy.linspace(-.50,.75,5))}) 
    112  
     92    #ret.params['simtime'] = 4000*0.1 
     93    ret.params['amplitude'] = numpy.ones(ret.params['N']) 
     94    N_exp = 15 
     95    snr  = ret.params['snr']* numpy.linspace(0.1,2.0,N_exp) 
     96    run = benchmark.get_experiment_dict({'snr':snr}) 
     97    print snr#,ret.params 
    11398    B = benchmark.Benchmark(filename,ret,run) 
    11499 
    115100    B.run_simulations() 
    116101    show(B) 
    117  
     102    #B.reset_all()