Hi Xavier,
I don’t quite understand what you mean. GetConnections() allows you to provide any NodeCollection as source or target argument and then you will get the connections from the given
sources to the given targets. But I guess you then would like to extract from the resulting SynapseCollection only those entries that have a given target i.
A first step would be as follows:
n = nest.Create('parrot_neuron', 5)
nest.Connect(n, n, {'rule': 'fixed_indegree', 'indegree': 2})
c = nest.GetConnections(n, n)
c2 = [cc for cc in c if cc.target == n[2]]
which will give you a list of single-element synapse collections which all have n[2] as their target. The problem is then that there currently is no way to turn this into a new SynapseCollection
you could to
c2.weight = 25
One way to fix this would be to change the SynapseCollection constructor (https://github.com/nest/nest-simulator/blob/8e85268ca512e0f509240fb5ef06f62a4e61a67e/pynest/nest/lib/hl_api_types.py#L603)
to allow a list of SynapseCollections as input and simply join their _datum elements into one new _datum element. Then you could pass c2 to that constructor and get new collection.
A slightly more complex fix would be to add a filtering capability to the SynapseCollection itself, i.e., a method returning a subset of connections fulfilling certain criteria.
Finally, one could created a "grouped” SynapseCollection from the start, where individual components could be addressed by a given criterion, e.g., by the target number. The return
value could for simplicity be a dict mapping the criterion key to the corresponding SynapseCollection, or the same again wrapped into a synapse collection to support pretty printing.
Do you want to explore this and then provide a pull request? Why not drop by our next open developer video conference on Monday 26 Feb at 11.30 CET (https://github.com/nest/nest-simulator/wiki/2024-02-26-Open-NEST-Developer-Video-Conference)?
Best,
Hans Ekkehard
--
Prof. Dr. Hans Ekkehard Plesser
Department of Data Science
Faculty of Science and Technology
Norwegian University of Life Sciences
PO Box 5003, 1432 Aas, Norway
Phone +47 6723 1560
Email hans.ekkehard.plesser@nmbu.no
Home http://arken.nmbu.no/~plesser