Quick Start Guide¶
This section demonstrates how to quickly set up a simulation for a simple E-I network of conductance based neurons using MIIND. A rudimentary level of python experience is needed to run the simulation. In most cases, MIIND can be installed via Python pip. The code for this example is given in full here but can also be found at https://github.com/dekamps/miind/tree/windows_pip_support/examples/quick_start. Once MIIND is installed, it can also be loaded into a working directory with the following command:
$ python -m miind.loadExamples
In the examples/quick_start directory, the generateCondFiles.py script can be run to generate the simulation files, cond.model and cond.tmat:
$ python generateCondFiles.py
The contents of generateCondFiles.py is given below. The two important parts of the script are the neuron model function, in this case named cond(), and the call to the MIIND function grid_generate.generate(). When run, the script generates two files, cond.model and cond.tmat.
import miind.grid_generate as grid_generate def cond(y,t): E_r = -65e-3 tau_m = 20e-3 tau_s = 5e-3 v = y; h = y; v_prime = ( -(v - E_r) - (h * v) ) / tau_m h_prime = -h / tau_s return [v_prime, h_prime] grid_generate.generate( func = cond, timestep = 1e-04, timescale = 1, tolerance = 1e-6, basename = 'cond', threshold_v = -55.0e-3, reset_v = -65e-3, reset_shift_h = 0.0, grid_v_min = -72.0e-3, grid_v_max = -54.0e-3, grid_h_min = -1.0, grid_h_max = 2.0, grid_v_res = 200, grid_h_res = 200, efficacy_orientation = 'h')
The cond() function should be familiar to those who have used Python numerical integration frameworks such as scipy.integrate. It takes the two time dependent variables defined by y and y and a placeholder t parameter for performing a numerical integration. In the function, the user may define how the derivatives of each variable are to be calculated. The generate() function requires a suitable time step, values for a threshold and reset if needed, and a description of the extent of the state space to be simulated. With this structure, the user may define any two dimensional neuron model. The generated files are then referenced in a second file which describes a network of populations to be simulated. The second file, cond.xml, describes an E-I network which uses the files generated by generateCondFiles.py.
<Simulation> <WeightType>CustomConnectionParameters</WeightType> <Algorithms> <Algorithm type="GridAlgorithm" name="COND" modelfile="cond.model" tau_refractive="0.0" transformfile="cond_0_0_0_0_.tmat" start_v="-0.065" start_w="0.0" > <TimeStep>1e-04</TimeStep> </Algorithm> <Algorithm type="RateFunctor" name="ExcitatoryInput"> <expression>800.</expression> </Algorithm> </Algorithms> <Nodes> <Node algorithm="ExcitatoryInput" name="INPUT_E" type="EXCITATORY_DIRECT" /> <Node algorithm="ExcitatoryInput" name="INPUT_I" type="EXCITATORY_DIRECT" /> <Node algorithm="COND" name="E" type="EXCITATORY_DIRECT" /> <Node algorithm="COND" name="I" type="INHIBITORY_DIRECT" /> </Nodes> <Connections> <Connection In="INPUT_E" Out="E" num_connections="1" efficacy="0.1" delay="0.0"/> <Connection In="INPUT_I" Out="I" num_connections="1" efficacy="0.1" delay="0.0"/> <Connection In="E" Out="I" num_connections="1" efficacy="0.1" delay="0.001"/> <Connection In="E" Out="E" num_connections="1" efficacy="0.1" delay="0.001"/> <Connection In="I" Out="E" num_connections="1" efficacy="-0.1" delay="0.001"/> <Connection In="I" Out="I" num_connections="1" efficacy="-0.1" delay="0.001"/> </Connections> <Reporting> <Display node="E" /> <Display node="I" /> <Rate node="E" t_interval="0.001" /> <Rate node="I" t_interval="0.001" /> </Reporting> <SimulationRunParameter> <SimulationName>EINetwork</SimulationName> <t_end>0.2</t_end> <t_step>1e-04</t_step> <name_log>einetwork.log</name_log> </SimulationRunParameter> </Simulation>
The Algorithms section is used to declare specific simulation methods for one or more populations in the network. In this case, a GridAlgorithm named COND is set up which references the cond.model and cond.tmat files. A RateFunctor algorithm produces a constant firing rate. In the Nodes section, two instances of COND are created: one for the excitatory and inhibitory populations respectively. Two ExcitatoryInput nodes are also defined. The Connections section allows us to connect the input nodes to the two conductance populations. The populations are connected to each other and to themselves with a 1ms transmission delay. The remaining sections are used to define how the output of the simulation is to be recorded, and to provide important simulation parameters such as the simulation time. By running the following python command, the simulation can be run:
$ python -m miind.run cond.xml
The probability density plots for both populations will be displayed in separate windows as the simulation progresses. The firing rate of the excitatory population can be plotted using the following commands:
$ python -m miind.miindio sim cond.xml $ python -m miind.miindio rate E
Finally, the density function of each population can be plotted as a heat map for a given time in the simulation:
$ python -m miind.miindio plot-density E 0.12