Shortcuts

ToGrid

class torcheeg.transforms.ToGrid(channel_location_dict: Dict[str, Tuple[int, int]], apply_to_baseline: bool = False)[source][source]

A transform method to project the EEG signals of different channels onto the grid according to the electrode positions to form a 3D EEG signal representation with the size of [number of data points, width of grid, height of grid]. For the electrode position information, please refer to constants grouped by dataset:

  • datasets.constants.emotion_recognition.deap.DEAP_CHANNEL_LOCATION_DICT

  • datasets.constants.emotion_recognition.dreamer.DREAMER_CHANNEL_LOCATION_DICT

  • datasets.constants.emotion_recognition.seed.SEED_CHANNEL_LOCATION_DICT

from torcheeg import transforms
from torcheeg.datasets.constants import DEAP_CHANNEL_LOCATION_DICT

t = transforms.ToGrid(DEAP_CHANNEL_LOCATION_DICT)
t(eeg=np.random.randn(32, 128))['eeg'].shape
>>> (128, 9, 9)
Parameters:
  • channel_location_dict (dict) – Electrode location information. Represented in dictionary form, where key corresponds to the electrode name and value corresponds to the row index and column index of the electrode on the grid.

  • apply_to_baseline – (bool): Whether to act on the baseline signal at the same time, if the baseline is passed in when calling. (default: False)

__call__(*args, eeg: ndarray, baseline: ndarray | None = None, **kwargs) Dict[str, ndarray][source][source]
Parameters:
  • eeg (np.ndarray) – The input EEG signals in shape of [number of electrodes, number of data points].

  • baseline (np.ndarray, optional) – The corresponding baseline signal, if apply_to_baseline is set to True and baseline is passed, the baseline signal will be transformed with the same way as the experimental signal.

Returns:

The projected results with the shape of [number of data points, width of grid, height of grid].

Return type:

np.ndarray

reverse(eeg: ndarray, **kwargs) ndarray[source][source]

The inverse operation of the converter is used to take out the electrodes on the grid and arrange them in the original order. :param eeg: The input EEG signals in shape of [number of data points, width of grid, height of grid]. :type eeg: np.ndarray

Returns:

The revered results with the shape of [number of electrodes, number of data points].

Return type:

np.ndarray

Read the Docs v: latest
Versions
latest
stable
v1.1.1
v1.1.0
v1.0.11
v1.0.10
v1.0.9
v1.0.8.post1
v1.0.8
v1.0.7
v1.0.6
v1.0.4
v1.0.3
v1.0.2
v1.0.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources