Description of problem
I have a spatial neuron and the Extracellular space modeled as a NeuronGroup.
I’m trying to connect to the ECS only the variables from a particular compartment of the neuron.
I linked the variables and seemed ok, however I get the following error about no longer existing ecs variables I guess. But I really don’t know how to solve this.
Thanks to anyone will spend a minute to try to help me,
Minimal code to reproduce problem
ecs.IKAn = linked_var(neuro.L.IKA)
Full traceback of error (if relevant)
ReferenceError: weakly-referenced object no longer exists
Error encountered with object named “neurongroup_stateupdater”.
I will try to have a closer look at this soon. You should not get this kind of error, so this definitely counts as a bug. I somewhat understand why you get it, though. The normal use of
linked_var is with a full
SpatialNeuron) but here you are using it with a subgroup. To avoid memory issues (long story…), the link between the groups is stored as a so-called “weak reference” which means that it will not keep the target group “alive” if nothing else refers to it. This is a problem here, because your subgroup is
neuro.L, and this group is not permanently stored anywhere. It might work if you keep the subgroup alive by storing it to a variable, i.e.:
compartment = neuro.L
ecs.IKAn = linked_var(compartment.IKA)
I am not 100% sure whether it does work in this way, though. If it does not, you could try to instead link to the complete group and set the compartment you are interested in via the
This would look like this:
ecs.IKAn = linked_var(neuro.IKA, index=[neuro.L.indices])
(this assumes that the ecs is a
NeuronGroup of size 1).
Let us know whether it works!
I checked with an example and the workarounds appear to work. The issue is a bit tricky to fix, but I realized that there is another even simpler workaround. Instead of the line you used, try:
ecs.IKAn = linked_var(neuro.L, 'IKA')
thanks for the workarounds! And sorry for my late reply!
I tried and in my case only the first suggestion works. Still…a great victory since I thought I was making some mysterious huge mistake