torcheeg.utils

plot_raw_topomap

torcheeg.utils.plot_raw_topomap(tensor: ~torch.Tensor, channel_list: ~typing.List[str], sampling_rate: int, plot_second_list: ~typing.List[int] = [0.0, 0.25, 0.5, 0.75], montage: ~mne.channels.montage.DigMontage = <DigMontage | 0 extras (headshape), 0 HPIs, 3 fiducials, 94 channels>)[source]

Plot a topographic map of the input raw EEG signal as image.

eeg = torch.randn(32, 128)
img = plot_raw_topomap(eeg,
                 channel_list=DEAP_CHANNEL_LIST,
                 sampling_rate=128)
# If using jupyter, the output image will be drawn on notebooks.
The output image of plot_raw_topomap

Parameters
  • tensor (torch.Tensor) – The input EEG signal, the shape should be [number of channels, number of data points].

  • channel_list (list) – The channel name lists corresponding to the input EEG signal. If the dataset in TorchEEG is used, please refer to the CHANNEL_LIST related constants in the torcheeg.constants module.

  • sampling_rate (int) – Sample rate of the data.

  • plot_second_list (list) – The time (second) at which the topographic map is drawn. (default: [0.0, 0.25, 0.5, 0.75])

  • montage (any) – Channel positions and digitization points defined in obj:mne. (default: mne.channels.make_standard_montage('standard_1020'))

Returns

The output image in the form of np.ndarray.

Return type

np.ndarray

plot_feature_topomap

torcheeg.utils.plot_feature_topomap(tensor, channel_list: ~typing.List[str], feature_list: ~typing.Optional[~typing.List[str]] = None, montage: ~mne.channels.montage.DigMontage = <DigMontage | 0 extras (headshape), 0 HPIs, 3 fiducials, 94 channels>)[source]

Plot a topographic map of the input EEG features as image.

eeg = torch.randn(32, 4)
img = plot_feature_topomap(eeg,
                 channel_list=DEAP_CHANNEL_LIST,
                 feature_list=["theta", "alpha", "beta", "gamma"])
# If using jupyter, the output image will be drawn on notebooks.
The output image of plot_feature_topomap

Parameters
  • tensor (torch.Tensor) – The input EEG signal, the shape should be [number of channels, dimensions of features].

  • channel_list (list) – The channel name lists corresponding to the input EEG signal. If the dataset in TorchEEG is used, please refer to the CHANNEL_LIST related constants in the torcheeg.constants module.

  • feature_list (list) – . The names of feature dimensions displayed on the output image, whose length should be consistent with the dimensions of features. If set to None, the dimension index of the feature is used instead. (default: None)

  • montage (any) – Channel positions and digitization points defined in obj:mne. (default: mne.channels.make_standard_montage('standard_1020'))

Returns

The output image in the form of np.ndarray.

Return type

np.ndarray

plot_signal

torcheeg.utils.plot_signal(tensor, channel_list: ~typing.List[str], sampling_rate: int, montage: ~mne.channels.montage.DigMontage = <DigMontage | 0 extras (headshape), 0 HPIs, 3 fiducials, 94 channels>)[source]

Plot signal values of the input raw EEG as image.

eeg = torch.randn(32, 128)
img = plot_signal(eeg,
                  channel_list=DEAP_CHANNEL_LIST,
                  sampling_rate=128)
# If using jupyter, the output image will be drawn on notebooks.
The output image of plot_signal

Parameters
  • tensor (torch.Tensor) – The input EEG signal, the shape should be [number of channels, number of data points].

  • channel_list (list) – The channel name lists corresponding to the input EEG signal. If the dataset in TorchEEG is used, please refer to the CHANNEL_LIST related constants in the torcheeg.constants module.

  • sampling_rate (int) – Sample rate of the data.

  • montage (any) – Channel positions and digitization points defined in obj:mne. (default: mne.channels.make_standard_montage('standard_1020'))

Returns

The output image in the form of np.ndarray.

Return type

np.ndarray

plot_3d_tensor

torcheeg.utils.plot_3d_tensor(tensor, color: Union[Colormap, str] = 'hsv')[source]

Visualize a 3-D matrices in 3-D space.

eeg = torch.randn(128, 9, 9)
img = plot_3d_tensor(eeg)
# If using jupyter, the output image will be drawn on notebooks.
The output image of plot_3d_tensor

Parameters
  • tensor (torch.Tensor) – The input 3-D tensor.

  • color (colors.Colormap or str) – The color map used for the face color of the axes. (default: hsv)

Returns

The output image in the form of np.ndarray.

Return type

np.ndarray

plot_2d_tensor

torcheeg.utils.plot_2d_tensor(tensor, color='hsv')[source]

Visualize a 2-D matrices in 2-D space.

eeg = torch.randn(9, 9)
img = plot_2d_tensor(eeg)
# If using jupyter, the output image will be drawn on notebooks.
The output image of plot_2d_tensor

Parameters
  • tensor (torch.Tensor) – The input 2-D tensor.

  • color (colors.Colormap or str) – The color map used for the face color of the axes. (default: hsv)

Returns

The output image in the form of np.ndarray.

Return type

np.ndarray