macro_eeg_model.config.connectivity_model#
Classes#
A class to model the connectivity between brain nodes. It computes |
Module Contents#
- class macro_eeg_model.config.connectivity_model.ConnectivityModel(given_nodes, relay_station)[source]#
A class to model the connectivity between brain nodes. It computes distances and connectivity weights between nodes, with optional relay stations.
- nodes#
The processed list of nodes used in the model.
- Type:
list
- nr_nodes#
The total number of nodes in the model.
- Type:
int
- distances#
The matrix of distances between nodes.
- Type:
numpy.ndarray
- connectivity_weights#
The matrix of connectivity weights between nodes.
- Type:
numpy.ndarray
- _given_nodes#
The list of nodes provided for the connectivity model.
- Type:
list
- _relay_station#
The relay station node name, if any.
- Type:
str
- _relay_nodes#
The list of relay nodes derived from the relay station, if applicable.
- Type:
list
- _relay_indices#
The indices of the relay nodes in the connectivity model.
- Type:
list
- _nodes_indices#
A dictionary mapping each node to its corresponding indices.
- Type:
dict
- _avg_counts#
The average counts of connections between nodes.
- Type:
numpy.ndarray
- _avg_fc#
The average functional connectivity between nodes.
- Type:
numpy.ndarray
- _avg_lengths#
The average distances (lengths) between nodes.
- Type:
numpy.ndarray
- _relay_distances#
The dictionary of average distances between nodes and the relay station.
- Type:
dict
- __init__(given_nodes, relay_station)[source]#
Initializes the ConnectivityModel with given nodes and an optional relay station.
- Parameters:
given_nodes (list) – The list of nodes to be used in the connectivity model.
relay_station (str) – The relay station name (or None).
- set_connectivity(custom_connectivity)[source]#
Assigns streamline lengths to the distances matrix (relayed, if applicable) and weights to the connectivity matrix based on either custom-provided values or default calculations based on functional connectivity (FC).
The values for a pair of nodes are extracted from
_get_pair_stats().- Parameters:
custom_connectivity (bool) – If True, attempts to load and use custom connectivity weights from connectivity_weights.csv file in the configs path (see
src.utils.paths.Paths).- Raises:
AssertionError – If the shape of the custom connectivity matrix is incorrect or the matrix has been incorrectly constructed.
- _get_pair_stats(node1, node2)[source]#
Retrieves statistics for a pair of nodes, including counts, functional connectivity, and distances.
- Parameters:
node1 (str) – The name of the first node.
node2 (str) – The name of the second node.
- Returns:
A tuple containing lists of counts, functional connectivity values, and distances between the two nodes.
- Return type:
tuple
- _init_relay_distances()[source]#
Calculates and stores the average distance between each node and the relay station, if a relay station is specified.
- _init_nodes()[source]#
Initializes and processes nodes using
src.config.nodes_processor.NodesProcessor.get_nodes_indices().
- _init_connectivity()[source]#
Initializes the connectivity matrix and distances between nodes.
It creates matrices for distances and connectivity weights between nodes, initializing with zeros or tuples as appropriate (depending on whether there is a relay station) and NaNs on the diagonal.