Quickstart¶
Get EDEN¶
The easiest way to install EDEN is as a Python package, which contains EDEN along with helpful routines to use it with Python.
Note that EDEN can also be used fine with other programming languages such as MATLAB or Octave, R and even LabVIEW (examples are coming soon); in fact any language can be used, since EDEN is a as a stand-alone program communicating through files and data streams.
%pip install eden_simulator
import eden_simulator
Requirement already satisfied: eden_simulator in /home/docs/checkouts/readthedocs.org/user_builds/eden-simulator/envs/latest/lib/python3.10/site-packages (0.2.4a4)
Requirement already satisfied: numpy in /home/docs/checkouts/readthedocs.org/user_builds/eden-simulator/envs/latest/lib/python3.10/site-packages (from eden_simulator) (2.2.6)
Requirement already satisfied: lxml in /home/docs/checkouts/readthedocs.org/user_builds/eden-simulator/envs/latest/lib/python3.10/site-packages (from eden_simulator) (6.1.1)
Note: you may need to restart the kernel to use updated packages.
Get a NeuroML model¶
EDEN runs neural models described in the NeuroML 2 format. Users can acquire such models from many online sources, customise them and even build their own for their experiments.
To begin, let’s simulate a single neuron modelled classic Hodgkin-Huxley equations. We can get this from the OpenSourceBrain repository.
# Download the zip file with the model
import urllib.request
urllib.request.urlretrieve('https://codeload.github.com/OpenSourceBrain/hh-testing/zip/refs/heads/master', 'hh.zip')
# and unpack it
from zipfile import ZipFile
with ZipFile('hh.zip', 'r') as zipp: zipp.extractall()
# Check which files are present now
from os import listdir; # listdir() <-- unhide me !
hh-testing-master next to this notebook.NeuroML2 folder containing the description of our model. The reevant files are of types .nml and .xml:
nml_folder = 'hh-testing-master/NeuroML2/'
listdir(nml_folder)
['LEMS_hh_nostim.xml',
'hh.lems.nostim.omt',
'hh_nostim.nml',
'hh.nml',
'LEMS_hh.xml',
'hh.lems.omt']
Run the NeuroML model with EDEN¶
There is the following distinction between files:
.nmlfiles describe the modelled network, neurons and their parts;LEMS_<something>.xmlfiles describe meta-parameters about the simulation, such as how long to run it for, and which curves (or rasters) we want to keep from this simulation.
Let’s now run the LEMS_hh.xml file that specifies a simulation:
sim_filename = nml_folder+"LEMS_hh.xml"
sim_data = eden_simulator.runEden(sim_filename)
Show the results¶
From the last code cell that ran the simulation, we got a variable sim_data. What is it, what does it contain?
print(sim_data)
{'pop/0/hh/v': array([-0.065 , -0.06499997, -0.06499994, ..., -0.06663233,
-0.06662899, -0.06662564], shape=(500001,)), 't': array([0.00000e+00, 1.00000e-06, 2.00000e-06, ..., 4.99998e-01,
4.99999e-01, 5.00000e-01], shape=(500001,))}
It looks like it returned a dict with two entries, pop/0/hh/v and t. The latter represents time throughout the simulation, and the former seems to be a voltage of a HH cell – most likely the one we just simulated.
So then, we can plot membrane voltage versus time and get the classic waveform of the HH model:
from matplotlib import pyplot as plt
plt.figure(figsize=[10,7]); plt.plot(sim_data['t'], sim_data['pop/0/hh/v']);
plt.ylabel("Membrane voltage (V)"); plt.xlabel("Time (sec)"); plt.show()
Note that voltage is produced in volts and time in seconds. Unless specified otherwise, EDEN outputs results in SI units for compatibility with other NeuroML tools.
Done!¶
Following this tutorial, you may continue with a more in-depth introduction to NeuroML, and see more tutorials or the full list of examples.
Appendix¶
In the interest of curiosity, we can inspect these NeuroML files that gave us this nice electrical waveform of the classic HH cell. These files are made up of machine-readable text, in the XML format. They are a bit on the verbose side, but there is good reason:
The model’s description is explicit, complete and unambiguous; all equations, parameters, and interactions that define the model are included in the
.nmlfile.Descriptions being explicit allows for very diverse range of models to be expressed in NeuroML – from abstract integrate-and-fire neurons, to anatomically detailed Purkinje cells at the electrophysiological level.
The user guide explains how to construct NeuroML networks and custom mechanisms in further detail. More information about the NeuroML format can be found in NeuroML resources.
This is the .xml file that specified our simulation: (Note the target and <simulation> tags.)
from IPython.display import Code
Code(filename=f'{nml_folder}/LEMS_hh.xml', language='xml')
<Lems>
<!-- Simple cell with classical HH Sodium, Potassium and a
current clamp to make it spike -->
<Target component="sim1"/>
<Include file="Cells.xml"/>
<Include file="Networks.xml"/>
<Include file="Simulation.xml"/>
<Include file="hh.nml"/>
<!-- Simulation specifications -->
<Simulation id="sim1" length="500ms" step="0.001ms" target="net1">
<Display id="d1" title="Membrane Potential (mV)" timeScale="1ms" xmin="0" xmax="50" ymin="-80" ymax="40">
<Line id="V" quantity="pop/0/hh/v" scale="1mV" color="#ffffff" timeScale="1ms"/>
</Display>
<OutputFile id="of0" fileName="/tmp/lems_hh.dat">
<OutputColumn id="v" quantity="pop/0/hh/v"/>
</OutputFile>
</Simulation>
</Lems>
And this is the .nml model that we simulated, it contains the structure and biophysical parameters of the cell and the single-cell “network” to be simulated. (Note the <ionChannel>, <cell> and <network> tags.)
Code(filename=f'{nml_folder}/hh.nml', language='xml')
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2beta2.xsd"
id="simple_hh">
<ionChannel id="leak" type="ionChannelPassive" conductance="10pS" species="non_specific"/>
<ionChannel id="na_chan" type="ionChannelHH" conductance="10pS" species="na">
<gateHHrates id="m" instances="3">
<q10Settings type="q10ExpTemp" q10Factor="3" experimentalTemp="6.3 degC"/>
<forwardRate type="HHExpLinearRate" rate="1per_ms" midpoint="-40mV" scale="10mV"/>
<reverseRate type="HHExpRate" rate="4per_ms" midpoint="-65mV" scale="-18mV"/>
</gateHHrates>
<gateHHrates id="h" instances="1">
<q10Settings type="q10ExpTemp" q10Factor="3" experimentalTemp="6.3 degC"/>
<forwardRate type="HHExpRate" rate="0.07per_ms" midpoint="-65mV" scale="-20mV"/>
<reverseRate type="HHSigmoidRate" rate="1per_ms" midpoint="-35mV" scale="10mV"/>
</gateHHrates>
</ionChannel>
<ionChannel id="k_chan" type="ionChannelHH" conductance="10pS" species="k">
<gateHHrates id="n" instances="4">
<q10Settings type="q10ExpTemp" q10Factor="3" experimentalTemp="6.3 degC"/>
<forwardRate type="HHExpLinearRate" rate="0.1per_ms" midpoint="-55mV" scale="10mV"/>
<reverseRate type="HHExpRate" rate="0.125per_ms" midpoint="-65mV" scale="-80mV"/>
</gateHHrates>
</ionChannel>
<!-- Cellular properties -->
<cell id="hh">
<notes>Sample cell with classical HH Na+/K+ channels</notes>
<morphology id="just_a_cylinder">
<segment id="0" name="Soma">
<proximal x="0.0" y="0.0" z="0.0" diameter="500.0"/>
<distal x="0.0" y="0.0" z="100.0" diameter="500.0"/>
</segment>
<segmentGroup id="all">
<member segment="0"/>
</segmentGroup>
<segmentGroup id="soma_group">
<member segment="0"/>
</segmentGroup>
</morphology>
<biophysicalProperties id="biophys">
<membraneProperties>
<channelDensity condDensity="0.12 S_per_cm2" id="na_all" ionChannel="na_chan" erev="50.0 mV" ion="na"/>
<channelDensity condDensity="0.036 S_per_cm2" id="k_all" ionChannel="k_chan" erev="-77.0 mV" ion="k"/>
<channelDensity condDensity="0.0003 S_per_cm2" id="passive" ionChannel="leak" erev="-54.3 mV" ion="non_specific"/>
<spikeThresh value="0 mV"/>
<specificCapacitance value="1.0 uF_per_cm2"/>
<initMembPotential value="-65.0 mV"/>
</membraneProperties>
<intracellularProperties>
<resistivity value="0.1 kohm_cm"/>
</intracellularProperties>
</biophysicalProperties>
</cell>
<!-- Point process: Current clamp -->
<pulseGenerator id="IClamp" delay="1ms" duration="500ms" amplitude="61nA" />
<!-- Create a single-cell network -->
<network id="net1" type="networkWithTemperature" temperature = "6.3 degC">
<population id="pop" component="hh" type="populationList" size="1">
<instance id="0">
<location x="0" y="0" z="0"/>
</instance>
</population>
<inputList id="IClamp" component="IClamp" population="pop">
<input id="0" target="../pop/0/hh" destination="synapses"/>
</inputList>
</network>
</neuroml>