Indexing SpatialNeuron

Hi!

I’m working with Brian2 (2.4.2) for multi-compartment modelling. I’ve come across an oddity wrt. indexing the SpatialNeuron. The code below

from brian2 import *

eqs='''
gL : siemens/meter**2
Im = gL * (EL - v) : amp/meter**2
'''

morpho = Soma(diameter=30*um)
morpho.dendrite = Cylinder(length=10*um, diameter=1*um, n=2)

neuron = SpatialNeuron(morphology=morpho, model=eqs, Cm=1*uF/cm**2, Ri=100*ohm*cm)

gL = 1 * siemens/cm**2
neuron.gL = [1*gL, 2*gL, 3*gL]

print(neuron.gL)
print()

print(neuron.dendrite.gL)
print()

print(neuron.dendrite[0].gL)
print(neuron.dendrite[1].gL)

yields the output

<spatialneuron.gL: array([10000., 20000., 30000.]) * siemens / meter ** 2>

<spatialneuron_subgroup.gL: array([20000., 30000.]) * siemens / meter ** 2>

<spatialneuron_subgroup_1.gL: array([10000.]) * siemens / meter ** 2>
<spatialneuron_subgroup_1.gL: array([20000.]) * siemens / meter ** 2>

I would have expected the last two lines to give 20k and 30k respectively as I’m indexing the 0th and 1st compartment of the dendrite.

Anything wrong in the code or my mental model?

Thanks in advance,

Sebastian

Hmm, this looks indeed like a bug, but I’ll have a closer look.
In the meantime, you can always index the variable instead of the neuron, i.e. use:

print(neuron.dendrite.gL[0])
print(neuron.dendrite.gL[1])
1 Like

Thanks!

You are welcome. I just merged the PR, let us know if you come across any other issues. The multicompartmental module has a lot fewer users than the rest of Brian, so bugs can more easily go unnoticed.

1 Like