.. currentmodule:: brian

.. index::
   pair: example usage; NeuronGroup
   pair: example usage; run
   pair: example usage; Connection
   pair: example usage; PoissonGroup
   pair: example usage; SpikeMonitor
   pair: example usage; StateMonitor

.. _example-misc_adaptive:

Example: adaptive (misc)
========================

An adaptive neuron model

::

    from brian import *
    
    PG = PoissonGroup(1, 500 * Hz)
    eqs = '''
    dv/dt = (-w-v)/(10*ms) : volt # the membrane equation
    dw/dt = -w/(30*ms) : volt # the adaptation current
    '''
    # The adaptation variable increases with each spike
    IF = NeuronGroup(1, model=eqs, threshold=20 * mV,
                     reset='''v  = 0*mV
                              w += 3*mV ''')
    
    C = Connection(PG, IF, 'v', weight=3 * mV)
    
    MS = SpikeMonitor(PG, True)
    Mv = StateMonitor(IF, 'v', record=True)
    Mw = StateMonitor(IF, 'w', record=True)
    
    run(100 * ms)
    
    plot(Mv.times / ms, Mv[0] / mV)
    plot(Mw.times / ms, Mw[0] / mV)
    
    show()
    

