Changeset 971 for trunk

Show
Ignore:
Timestamp:
05/27/11 23:46:00 (12 months ago)
Author:
emuller
Message:

Integrating Mike Hull's code for joining based on a Model built of heirarchical components

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/neuron/nineml.py

    r968 r971  
    2323import neuron 
    2424from pyNN.models import BaseCellType 
    25 from pyNN.nineml.cells import _build_nineml_celltype 
     25from pyNN.nineml.cells import _build_nineml_celltype, _mh_build_nineml_celltype 
     26from pyNN.nineml.cells import CoBaSyn  
    2627import logging 
    2728import os 
     
    8384 
    8485 
    85 def _compile_nmodl(nineml_component, weight_variables): # weight variables should really be within component 
     86def _compile_nmodl(nineml_component, weight_variables, hierarchical_mode=None): # weight variables should really be within component 
    8687    """ 
    8788    Generate NMODL code for the 9ML component, run "nrnivmodl" and then load 
     
    115116 
    116117 
     118 
     119 
     120 
     121 
     122 
     123def nineml_celltype_from_model(name, nineml_model, synapse_components): 
     124    """ 
     125    Return a new NineMLCellType subclass from a NineML model. 
     126    """ 
     127     
     128    dct = {'nineml_model':nineml_model, 
     129           'synapse_components':synapse_components, 
     130           'builder': _compile_nmodl}  
     131    return _mh_build_nineml_celltype(name, (NineMLCellType,), dct) 
     132 
  • trunk/src/nineml/cells.py

    r968 r971  
    366366 
    367367 
    368  
    369  
    370  
    371  
     368class _mh_build_nineml_celltype(type): 
     369    """ 
     370    Metaclass for building NineMLCellType subclasses 
     371    Called by nineml_celltype_from_model 
     372    """ 
     373    def __new__(cls, name, bases, dct): 
     374         
     375         
     376        #Extract Parameters Back out from Dict: 
     377        nineml_model = dct['nineml_model'] 
     378        synapse_components = dct['synapse_components'] 
     379 
     380        # Reduce the model:                     
     381        from nineml.abstraction_layer import models                
     382        reduction_process = models.ModelToSingleComponentReducer(nineml_model, componentname=name) 
     383        reduced_component = reduction_process.reducedcomponent 
     384         
     385        # New: 
     386        dct["combined_model"] = reduction_process.reducedcomponent 
     387        dct["default_parameters"] = dict( (name, 1.0) for name in reduced_component.parameters ) 
     388        dct["default_initial_values"] = dict((name, 0.0) for name in reduced_component.state_variables) 
     389        dct["synapse_types"] = [syn.namespace for syn in synapse_components]  
     390        dct["standard_receptor_type"] = (dct["synapse_types"] == ('excitatory', 'inhibitory')) 
     391        dct["injectable"] = True # need to determine this. How?? 
     392        dct["conductance_based"] = True # how to determine this?? 
     393        dct["model_name"] = name 
     394         
     395         
     396        dct["recordable"] = [port.name for port in reduced_component.analog_ports] + ['spikes', 'regime'] 
     397        dct["weight_variables"] = dict([ (syn.namespace,syn.namespace+'_'+syn.weight_connector ) 
     398                                         for syn in synapse_components ]) 
     399        #{'cobaInhib':'cobaInhib_q', 'cobaExcit':'cobaExcit_q',} 
     400         
     401         
     402        logger.debug("Creating class '%s' with bases %s and dictionary %s" % (name, bases, dct)) 
     403        # generate and compile NMODL code, then load the mechanism into NEUORN 
     404        dct["builder"](reduced_component, dct["weight_variables"], hierarchical_mode=True) 
     405        # TODO: weight variables should really be stored within combined_model 
     406         
     407        return type.__new__(cls, name, bases, dct) 
     408         
     409 
     410       
     411class CoBaSyn(object): 
     412    def __init__(self, namespace, weight_connector): 
     413        self.namespace = namespace 
     414        self.weight_connector = weight_connector 
     415 
     416 
     417 
     418 
     419