Simple Examples

How to run these examples

Create a Leaky Neuron

Demonstrates use of Leaky Integrate and Fire (LeakyIaf class) in moose.

lif.setupmodel(modelpath, iaf_Rm, iaf_Cm, pulse_interval)[source]

Create a LeakyIaF neuron under modelpath and a synaptic channel (SynChan) in it. Create a spike generator stimulated by a pulse generator to give input to the synapse.

Create a Leaky Compartment

class lifcomp.LIFComp(*args)[source]

Leaky integrate and fire neuron using regular compartments, spikegen and Func.


Reset voltage. The cell's membrane potential is set to this value after spiking.


Threshold voltage. The cell spikes if its membrane potential goes above this value.


This is an example of how you can create a Leaky Integrate and Fire compartment using regular compartment and Func to check for thresold crossing and resetting the Vm.


Create two cells with leaky integrate and fire compartments. Each cell is a single compartment a1 and b2. a1 is stimulated by a step current injection.

The compartment a1 is connected to the compartment b2 through a synaptic channel.

Voltage Clamping


This snippet is to demonstrate modelling of voltage clamping.

vclamp.vclamp_demo(simtime=50.0, dt=0.01)[source]

Demonstration of voltage clamping in a neuron.

Generate Pulse


Demonstrates a pulsegen with multiple levels, delays and widths.


This example shows the full range of operations of PulseGen objects with a reimplementation of corresponding GENESIS demo.

A PulseGen object can be run in three modes: free running (trigMode=0), triggered (trigMode=1) and gated (trigMode=2).

In the free running mode it keeps repeating the pulse series indefinitely.

In triggered mode, it generates a pulse series on the leading edge of the trigger signal coming to its input field. The trigger can be the output of another PulseGen as in this example.

In gated mode, the PulseGen acts as if it was free-running as long as the input remains high.



This is an example of event messages from multiple SpikeGen objects into a synchan.

Create a SynChan element with 2 elements in synapse field.

Create 5 SpikeGen elements.

Connect alternet SpikeGen elements to synapse[0] and synapse[1]

... This is a minimal example. In real simulations the SpikeGens will be embedded in compartments representing axon terminals and the SynChans will be embedded in somatic/dendritic compartments.

Message transmission via synapse

Demonstrates connection between 2 IntFire neurons to observe spike generation.


Connect a SpikeGen object to an IntFire neuron such that spike events in spikegen get transmitted to the synapse of the IntFire neuron.


Connect two IntFire neurons so that spike events in one gets transmitted to synapse of the other.


Demonstrates connection between 2 IntFire neurons to observe spike generation.


Create an intfire object and create two synapses on it.

Gap Junction


Demonstration of medelling gap junction using MOOSE.


This example is to demonstrate, how gap junction can be modeled using MOOSE.

Insert Spine heads


This snippet illustrates how the Neuron class does the spine specification, without the rdesigneur intermediate.