Changeset 139

Show
Ignore:
Timestamp:
03/11/08 14:56:59 (10 months ago)
Author:
LaurentPerrinet
Message:

Getting examples to work with the new Parameter class / still some work to do on benchmark class

Files:

Legend:

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

    r101 r139  
    2626in peripheral retina. 
    2727 
     28The data times outputted by the model are the input to the LGN ( 
     29http://en.wikipedia.org/wiki/Lateral_geniculate_nucleus ). Time for travelling 
     30through the retina being compensated : 
     31 
     32 
     33@article{Stanford87, 
     34        Author = {Stanford, L R}, 
     35        Journal = {Science}, 
     36        Month = {Oct}, 
     37        Number = {4825}, 
     38        Pages = {358-360}, 
     39        Title = {Conduction velocity variations minimize conduction time differences among retinal ganglion cell axons}, 
     40        Volume = {238}, 
     41        Year = {1987}} 
     42 
     43To remember (in the cat) 5° of visual angle ~ 1 mm of retina 
     44 
    2845See : 
    2946Data for parameters http://webvision.med.utah.edu/GCPHYS1.HTM (TODO LUP: define 
    3047different sets for different animals (cat, monkey, human)) 
    3148Morphology : http://webvision.med.utah.edu/GC1.html 
    32 Topics on http://homepages.inf.ed.ac.uk/cgi/rbf/CVONLINE/phase3entries.pl?TAG59 
     49Topics on CVonline http://homepages.inf.ed.ac.uk/cgi/rbf/CVONLINE/phase3entries.pl?TAG59 
    3350 
    3451TODO (LuP) : use Ringach 07 for setting the neurons centers 
  • trunk/src/analysis.py

    r106 r139  
    7676        stream.close() 
    7777        p.terminate() 
     78    except: 
     79        print "Error playing the SpikeTrain " 
    7880 
     81  
    7982    finally: 
    8083        os.remove(cfilename) 
  • trunk/src/benchmark.py

    r106 r139  
    6868class Benchmark(object): 
    6969 
    70     def __init__(self, filename, model, experiments): 
     70    def __init__(self, directory, model, experiments): 
    7171        """ Generates the benchmark files at the specified name 
    7272 
    7373        A benchmark is a list of experiments to test the effect of 
    7474        parameter changes on a model. It is defined by: 
    75         - filename is the folder where the benchmark is run 
     75        - directory is the folder where the benchmark files are stored 
    7676        - model is the Model object 
    7777        - params is its operating point (a dict) 
     
    8080 
    8181        """ 
    82         self.filename = filename 
    83         self.model = model 
     82        self.directory = directory 
    8483 
    8584        # first create directory 
    86         if not(os.path.isdir(self.filename)): 
    87             os.mkdir(self.filename) 
    88  
    89         if os.path.isfile(self.experiment_filename()): 
    90             print " * Directory exists at " , filename 
    91  
    92             # removing experiments not in the list 
    93             #if self.get('experiments')~= experiments: 
    94  
     85        if not(os.path.isdir(self.directory)): 
     86            os.mkdir(self.directory) 
    9587        else: 
    96             print " * Creating benchmark file at " , filename 
    97             # TODO duck typing on file type 
    98             data_root = shelve.open(self.experiment_filename()) 
    99             # operational parameters 
    100             data_root['params'] = model.params 
    101             # Different experiments 
    102             data_root['experiments'] = experiments 
    103             data_root.close() 
     88            print " * Directory exists at " , directory 
     89 
     90        try: 
     91            print " * Benchmark file exists at " , self.experiment_filename() 
     92            print self.get('params').pretty() 
     93 
     94        except: 
     95            print " * Creating benchmark file at " , directory 
     96            self.put('params', self.model.params) 
     97            self.put('experiments', experiments) 
    10498 
    10599 
     
    119113            experiment = 'default' 
    120114 
    121         return self.filename + '/' + experiment 
    122  
    123     def put(self,key,data,experiment): 
     115        return self.directory + '/' + experiment 
     116 
     117    def put(self,key,data,experiment = ''): 
    124118        """ Puts dict at key in experiment file. 
    125119 
     
    136130        """ 
    137131        dict = {} 
    138         if os.path.isfile(self.experiment_filename(experiment)): 
     132        try : #if os.path.isfile(self.experiment_filename(experiment)): 
    139133            exp_root = shelve.open(self.experiment_filename(experiment)) 
    140134            if key=='': 
     
    142136            else: 
    143137                dict = exp_root[key] 
    144  
    145138            exp_root.close() 
    146         # else raise an error 
     139 
     140        except : 
     141            print 'could not get item', key, 'in experiment ', experiment 
    147142        return dict 
    148143 
     
    219214            #os.remove(self.filename) 
    220215 
     216#TODO: def reset(self,list_experi#        if os.path.isfile(self.experiment_filename()): 
     217            # removing experiments not in the list 
     218            #if self.get('experiments')~= experiments: 
    221219 
    222220