spacenet.helpers.get_nodes_and_labels#
- spacenet.helpers.get_nodes_and_labels(spatial_network, node_label_name='label')#
A function to extract node indices and labels from a spatial network. This can be used to get the node indices and corresponding labels (e.g. cell types or gene expression levels) for nodes in the network.
- Parameters:
- spatial_networknetworkx.Graph
The spatial network from which to extract node indices and labels. Nodes should be indexed by integers and have a node attribute corresponding to the labels.
- node_label_namestr, optional
The name of the node attribute corresponding to the labels to extract. Default is ‘label’.
- Returns:
- nodesnumpy.ndarray
An array of node indices for nodes in the spatial network that have the specified label attribute.
- labelsnumpy.ndarray
An array of labels corresponding to the specified label attribute for each node in the spatial network that has that attribute.