BandDifferentialEntropy¶
- class torcheeg.transforms.BandDifferentialEntropy(sampling_rate: int = 128, order: int = 5, band_dict: Dict[str, Tuple[int, int]] = {'alpha': [8, 14], 'beta': [14, 31], 'gamma': [31, 49], 'theta': [4, 8]}, apply_to_baseline: bool = False)[source][source]¶
A transform method for calculating the differential entropy of EEG signals in several sub-bands with EEG signals as input. It is a widely accepted differential entropy calculation method by the community, which is often applied to the DEAP and DREAMER datasets. It is relatively easy to understand and has a smaller scale and more gradual changes than the
BandDifferentialEntropyV1
calculated based on average power spectral density.Related Paper: Fdez J, Guttenberg N, Witkowski O, et al. Cross-subject EEG-based emotion recognition through neural networks with stratified normalization[J]. Frontiers in neuroscience, 2021, 15: 626277.
Related Project: https://github.com/javiferfer/cross-subject-eeg-emotion-recognition-through-nn/
Related Paper: Li D, Xie L, Chai B, et al. Spatial-frequency convolutional self-attention network for EEG emotion recognition[J]. Applied Soft Computing, 2022, 122: 108740.
Related Project: https://github.com/qeebeast7/SFCSAN/
In most cases, choosing
BandDifferentialEntropy
andBandDifferentialEntropyV1
does not make much difference. If you have other comments, please feel free to pull request.from torcheeg import transforms t = transforms.BandDifferentialEntropy() t(eeg=np.random.randn(32, 128))['eeg'].shape >>> (32, 4)
- Parameters:
sampling_rate (int) – The original sampling rate of EEG signals in Hz. (default:
128
)order (int) – The order of the filter. (default:
5
)band_dict – (dict): Band name and the critical sampling rate or frequencies. By default, the differential entropy of the four sub-bands, theta, alpha, beta and gamma, is calculated. (default:
{...}
)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 differential entropy of several sub-bands for all electrodes.
- Return type:
np.ndarray[number of electrodes, number of sub-bands]