Inputs (Brian 1 --> 2 conversion) ================================= .. sidebar:: Brian 2 documentation For the main documentation about adding external stimulation to a network, see the document :doc:`../../user/input`. .. contents:: :local: :depth: 1 Poisson Input ------------- Brian 2 provides the same two groups that Brian 1 provided: `PoissonGroup` and `PoissonInput`. The mechanism for inhomogoneous Poisson processes has changed: instead of providing a Python function of time, you'll now have to provide a string expression that is evaluated at every time step. For most use cases, this should allow a direct translation: +-------------------------------------------------+------------------------------------------+ | Brian 1 | Brian 2 | +=================================================+==========================================+ + .. code:: | .. code:: | + | | + rates = lambda t:(1+cos(2*pi*t*1*Hz))*10*Hz | rates = '(1 + cos(2*pi*t*1*Hz)*10*Hz)' | + group = PoissonGroup(100, rates=rates) | group = PoissonGroup(100, rates=rates) | + | | +-------------------------------------------------+------------------------------------------+ For more complex rate modulations, the expression can refer to :ref:`user_functions` and/or you can replace the `PoissonGroup` by a general `NeuronGroup` with a threshold condition ``rand()=15*ms``. Brian 2 will return ``0`` for ``t<10*ms``, ``1`` for ``10*ms<=t<20*ms``, and ``2`` for ``t>=20*ms``. +-----------------------------------------------------------+----------------------------------------------------+ | Brian 1 | Brian 2 | +===========================================================+====================================================+ | .. code:: | .. code:: | | | | | # same input for all neurons | # same input for all neurons | | eqs = ''' | I = TimedArray(linspace(0*mV, 20*mV, 100), | | dv/dt = (I - v)/tau : volt | dt=10*ms) | | I : volt | eqs = ''' | | ''' | dv/dt = (I(t) - v)/tau : volt | | group = NeuronGroup(1, model=eqs, | ''' | | reset=0*mV, threshold=15*mV) | group = NeuronGroup(1, model=eqs, | | group.I = TimedArray(linspace(0*mV, 20*mV, 100), | reset='v = 0*mV', | | dt=10*ms) | threshold='v > 15*mV') | | | | +-----------------------------------------------------------+----------------------------------------------------+ | .. code:: | .. code:: | | | | | # neuron-specific input | # neuron-specific input | | eqs = ''' | values = (linspace(0*mV, 20*mV, 100)[:, None] * | | dv/dt = (I - v)/tau : volt | linspace(0, 1, 5)) | | I : volt | I = TimedArray(values, dt=10*ms) | | ''' | eqs = ''' | | group = NeuronGroup(5, model=eqs, | dv/dt = (I(t, i) - v)/tau : volt | | reset=0*mV, threshold=15*mV) | ''' | | values = (linspace(0*mV, 20*mV, 100)[:, None] * | group = NeuronGroup(5, model=eqs, | | linspace(0, 1, 5)) | reset='v = 0*mV', | | group.I = TimedArray(values, dt=10*ms) | threshold='v > 15*mV') | | | | +-----------------------------------------------------------+----------------------------------------------------+