Dear Miriam,
A NodeCollection can internally in NEST hold a metadata object, which can provide
additional information of the nodes. This object is only set internally in NEST and cannot
be manually added. If nodes are created with specified positions, the metadata object is a
spatial metadata object, holding the positions of the nodes. Node positions are thus
stored in the NodeCollection, not in the nodes themselves. So creating a new
NodeCollection from nodes selected within a given mask, or from a list of node ids, does
not preserve the spatial information of the nodes. When using a NodeCollection without any
spatial information about the nodes, it is therefore impossible to get node positions or
use functions such as PlotLayer(), leading to the errors you are getting.
There are some plans to make it possible to transfer the spatial information to
NodeCollections created in ways such as your example 1 and 2, but that has not been
implemented yet. See also the following related issue on GitHub:
https://github.com/nest/nest-simulator/issues/1992
As a workaround, you can pick out nodes from a NodeCollection while preserving the spatial
information by slicing the NodeCollection with nodes[i] to get a single node, nodes[i:j]
to get a range of nodes, or nodes[i:j:k] to get a range of every kth node.
Best,
Håkon
________________________________
From: Kempter, Miriam <miriam.kempter(a)rwth-aachen.de>
Sent: 21 March 2022 18:29
To: users(a)nest-simulator.org <users(a)nest-simulator.org>
Subject: [NEST Users] Creating a new NodeCollection from Mask or by global_ids
Some people who received this message don't often get email from
miriam.kempter(a)rwth-aachen.de. Learn why this is
important<http://aka.ms/LearnAboutSenderIdentification>
Dear Nest Team,
working with Python 3.8 and Nest 3.2 my goal is, after creating a spatial NodeCollection
"neurons", to create a new NodeCollection containing a selection of the node
from "neurons".
To achieve this I tried two different approaches:
1. Create a Mask object and use nest.SelectNodesByMask()
nodes_in_mask = nest.SelectNodesByMask(neurons, ctr_position, mask_obj)
2. Transform the NodeCollection into a list of node ids, pick 3 random ids, and create a
new NodeCollection containing those 3 Nodes
neurons_list = neurons.tolist()
for x in range(0, 3):
center = random.choice(neurons_list)
node_ids.append(center)
node_ids.sort()
new_collection = nest.NodeCollection(node_ids)
But with both approaches I get the same problems that some Information (of the positions)
seems to go missing. This shows in different ways.
First the new NodeCollections are no longer spatial (nodes_in_mask.spatial and
new_collection.spatial return none).
Second trying to get the node Positions results in an Error:
nest.GetPosition(nodes_in_mask)
-> Error #1 nest.lib.hl_api_exceptions.LayerExpected: LayerExpected in SLI
function GetPosition_g:
And last, trying to Plot the Layer also results in an Error:
fig = nest.PlotLayer(nodes_in_mask)
-> Error #2 TypeError: 'NoneType' object is not subscriptable
I attached a .txt file containing py code showing the problems.
Why do those Problems occur and what can I do to solve them?
Is there a way to create an empty NodeCollection s.t. I can add the wished nodes one by
one?
What exactly does the metadata of a Nodecollection represent? Is there a way to set it
manually for example to spatial?
Thank you in advance for your Answers,
Miriam