Skip to content

Problem injecting one DC_Source into 2 different cells in Brian #648

@AndreiMoise111

Description

@AndreiMoise111

Consider the code :

import sys
from pyNN.utility import get_script_args
import pdb
import matplotlib.pyplot as plt
simulator_name = get_script_args(1)[0]
exec("from pyNN.%s import *" % simulator_name)

setup(min_delay=0.1)

cells = Population(2, IF_curr_exp(v_rest = -65.0, v_thresh=-55.0, tau_refrac=5.0, i_offset=-1.0))
dc_source = DCSource(amplitude=0.5, start=25, stop=50)
cells[0].inject(dc_source)
cells[1].inject(dc_source)
cells.record(['v'])
run(100)

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

plt.subplot(2,1,2)
plt.plot(vm.times, vm[:, 1], 'r')
plt.xlabel("time (ms)")
plt.ylabel("Vm (mV)")
    
plt.show(block=True) 
end()

When I try to inject the same dc_source into cells[0] and cells[1]
I get and error :

/PyNN/pyNN/brian/standardmodels/electrodes.py", line 109, in _update_current
cell.parent.brian_group.i_inj[idx] += self.amplitudes[self.i] - self.prev_amp_dict[idx] #* ampere
KeyError: 0

However if I create another dc_source and inject it in cells[1], it works just fine.
This code works with neuron.

Metadata

Metadata

Assignees

No one assigned

    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