PyG-based Transforms
transforms.ToG
- class torcheeg.transforms.ToG(adj: List[List], complete_graph: bool = False)[source]
Bases:
object
A transformation method for constructing a graph representation of EEG signals, the results of which are applied to the input of the
torch_geometric
model. In the graph, nodes correspond to electrodes, and edges correspond to associations between electrodes (eg, spatially adjacent or functionally connected)TorchEEG
provides some common graph structures. Consider using the following adjacency matrices depending on the dataset (with different EEG acquisition systems):datasets.constants.emotion_recognition.deap.DEAP_ADJACENCY_MATRIX
datasets.constants.emotion_recognition.dreamer.DREAMER_ADJACENCY_MATRIX
datasets.constants.emotion_recognition.seed.SEED_ADJACENCY_MATRIX
…
transform = ToG(adj=DEAP_ADJACENCY_MATRIX) transform(np.random.randn(32, 128)).shape >>> (32, 4)
- Parameters
adj (list) – An adjacency matrix represented by a 2D array, each element in the adjacency matrix represents the electrode-to-electrode edge weight. Please keep the order of electrodes in the rows and columns of the adjacency matrix consistent with the EEG signal to be transformed.
complete_graph (bool) – Whether to build as a complete graph. If False, only construct edges between electrodes based on non-zero elements; if True, construct variables between all electrodes and set the weight of non-existing edges to 0. (defualt:
False
)
- __call__(x: ndarray) Data [source]
- Parameters
x (np.ndarray) – The input EEG signals in shape of [number of electrodes, number of data points].
- Returns
The graph representation data types that torch_geometric can accept. Nodes correspond to electrodes, and edges are determined via the given adjacency matrix.
- Return type
torch_geometric.data.Data