Site navigation:

Elementary tutorial: Importing neuroscience models from NineML


PyDSTool now directly supports the importing of NineML model specifications via the Python API. Details of installing that software can be found in the link. The NineML toolbox is currently in development. Only "flat" models are currently importable, but support for the full feature set is being actively developed in collaboration with the authors of NineML. The interface is extremely easy to use. Just build a model in NineML, and export it as a "component" using the python interface. In the examples below, the simple single neuron models are built directly using the python-NineML API, but they could have been loaded first from NineML files. A warning will be generated about not providing initial conditions at the time of definition.

from PyDSTool import *
from PyDSTool.Toolbox.NineML import *

c = get_HH_component()

# Convert to PyDSTool.ModelSpec and create NonHybridModel object
# Provide extra parameter Isyn which is missing from component definition
# in absence of any synaptic inputs coupled to the model membrane
HHmodel = get_nineml_model(c, 'HH_9ML', extra_args=[Par('Isyn')])

HHmodel.set(pars={'C': 1.0,
                  'Isyn': 20.0,
                  'celsius': 20.0,
                  'ek': -90,
                  'el': -65,
                  'ena': 80,
                  'gkbar': 30.0,
                  'gl': 0.3,
                  'gnabar': 130.0,
                  'theta': -40.0},
            ics={'V': -70, 'm': 0.1, 'n': 0, 'h': 0.9},

HHmodel.compute('test', force=True)
pts = HHmodel.sample('test')
plt.plot(pts['t'], pts['V'],'k')
plt.title('Hodgkin-Huxley membrane potential')

ev_info = pts.labels.by_label['Event:spikeoutput']
for ev_ix, ev_tdata in ev_info.items():
    plt.plot(ev_tdata['t'], pts[ev_ix]['V'], 'ko')