ToInterpolatedGrid¶
- class torcheeg.transforms.ToInterpolatedGrid(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 = ToInterpolatedGrid(DEAP_CHANNEL_LOCATION_DICT) t(eeg=np.random.randn(32, 128))['eeg'].shape >>> (128, 9, 9)
Especially, missing values on the grid are supplemented using cubic interpolation
- Parameters:
channel_location_dict (dict) – Electrode location information. Represented in dictionary form, where
key
corresponds to the electrode name andvalue
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