BandPowerSpectralDensity¶
- class torcheeg.transforms.BandPowerSpectralDensity(sampling_rate: int = 128, fft_n: Optional[int] = None, num_window: int = 1, 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 power spectral density of EEG signals in several sub-bands with EEG signals as input.
transform = BandPowerSpectralDensity() transform(eeg=np.random.randn(32, 128))['eeg'].shape >>> (32, 4)
- Parameters
sampling_rate (int) – The sampling rate of EEG signals in Hz. (defualt:
128)fft_n (int) – Computes the one-dimensional n-point discrete Fourier Transform (DFT) with the efficient Fast Fourier Transform (FFT) algorithm. If set to None, it will automatically match sampling_rate. (defualt:
None)num_window (int) – Welch’s method computes an estimate of the power spectral density by dividing the data into non-overlapping segments, where the num_window denotes the number of windows. (defualt:
1)order (int) – The order of the filter. (defualt:
5)band_dict – (dict): Band name and the critical sampling rate or frequencies. By default, the power spectral density of the four sub-bands, theta, alpha, beta and gamma, is calculated. (defualt:
{...})apply_to_baseline – (bool): Whether to act on the baseline signal at the same time, if the baseline is passed in when calling. (defualt:
False)
- __call__(*args, eeg: ndarray, baseline: Optional[ndarray] = 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 power spectral density of several sub-bands for all electrodes.
- Return type
np.ndarray[number of electrodes, number of sub-bands]