Skip to content

Brian2 back-end development for PyNN #632

@appukuttan-shailesh

Description

@appukuttan-shailesh

We finally have a very early stage prototype for Brian2 back-end for PyNN. See brian2_dev branch. The dev work basically involved using the existing Brian back-end and updating the source files as necessary to align with changes introduced in Brian2.

Some of the currently implemented features:

  • Various cell types
  • Current injection into single cell
  • All the electrode types
  • Recording cell and electrode parameters

Source Code:

import sys
from pyNN.utility import get_script_args

simulator_name = get_script_args(1)[0]
exec("from pyNN.%s import *" % simulator_name)

# setup(timestep=0.01, min_delay=0.1)
setup(min_delay=0.1)

cells = Population(1, IF_curr_exp(v_rest = -65.0, v_thresh=-55.0, tau_refrac=5.0))#, i_offset=-1.0*amp))

dc_source = DCSource(amplitude=0.5, start=25, stop=50)
ac_source = ACSource(start=75, stop=125, amplitude=0.5, offset=0.25, frequency=100.0, phase=0.0)
noisy_source = NoisyCurrentSource(mean=0.5, stdev=0.05, start=150, stop=175, dt=1.0)
step_source = StepCurrentSource(times=[200, 225, 250], amplitudes=[0.4, 0.6, 0.2])

cells[0].inject(dc_source)
cells[0].inject(ac_source)
cells[0].inject(noisy_source)
cells[0].inject(step_source)

dc_source.record()
ac_source.record()
noisy_source.record()
step_source.record()

cells.record(['v'])

run(275.0)

if '--plot-figure' in sys.argv:
    import matplotlib.pyplot as plt
    plt.ion()

    plt.figure(figsize=(8,8))

    plt.subplot(2,1,1)
    vm = cells.get_data().segments[0].filter(name="v")[0]
    plt.plot(vm.times, vm, 'r')
    plt.xlabel("time (ms)")
    plt.ylabel("Vm (mV)")

    plt.subplot(2,1,2)
    i_t_dc, i_amp_dc = dc_source._get_data()
    i_t_ac, i_amp_ac = ac_source._get_data()
    i_t_noisy, i_amp_noisy = noisy_source._get_data()
    i_t_step, i_amp_step = step_source._get_data()
    plt.plot(i_t_dc, i_amp_dc, 'k')
    plt.plot(i_t_ac, i_amp_ac, 'k')
    plt.plot(i_t_noisy, i_amp_noisy, 'k')
    plt.plot(i_t_step, i_amp_step, 'k')
    plt.xlabel("time (ms)")
    plt.ylabel("current (nA)")

    plt.suptitle(simulator_name, fontsize=15)
    plt.show(block=True)  # SA: changed
end()

image

Known issues:

  1. Handling current injection on population of size >1
  2. Handling current injection on multiple populations
  3. Errors described in NoisyCurrentSource bug in Brian #630 and Multiple electrodes current plot error in Brian #631
  4. Unable to print individual neuron parameters (e.g. v_thresh)
  5. i_offset having to be specified with units

(please add to this list)

Things to be checked/implemented/tested:

  1. Projections
  2. Synapes

(please add to this list)

If you wish to work on an issue/pending item listed above, create a new ticket for each item and provide details.

Note: Use a version of LazyArray that includes the following change:

NeuralEnsemble/lazyarray@38850fc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions