spkit.eeg.rhythmic_powers

spkit.eeg.rhythmic_powers(X, fs=128.0, fBands=[[4], [8, 14]], Sum=True, Mean=False, SD=False, use_joblib=False, filter_kwargs={}, periodogram_kwargs={}, filter_warn=True, periodogram_warn=True, verbose=0)

Compute powers of different Rhythms of EEG Signal

Decompose EEG Signal(s)-all the channels in Rhythms and compute power in each band for each channel

Parameters:
X: array,
  • EEG segment of shape (n,ch) or (n,)

  • where ch is number of channels

fs: int,
  • sampling rate

fBands: list
  • list of frequency bands

  • if None: fBands =[[4],[4,8],[8,14],[14,30],[30,47],[47]]

  • default [[4],[8,14]], ‘delta’ and ‘alpha’

(Sum,Mean,SD): bool, default (True, False, False)
  • if Sum=True, then Total power spectrum in the band computed, default=True

  • if Mean=True, then Average power of the band is computed, default=False

  • if SD=True, then Standard Deviation, (variation) in power for band is computed, default=False

filter_kwargs: dict, default=dict()
  • arguments for filtering, check filter_X for details

  • default arguments setting is: dict(order=5,ftype=’SOS’,verbose=False)

  • To override any of the argument or suply additional argument based of filter_X, provide the in filter_kwargs.

  • For example, filter_kwargs = dict(ftype=’filtfilt’), will overide the ftype.

periodogram_kwargs:dict, default=dict()
  • arguments for periodogram, check periodogram for details

  • default arguments setting is: dict(method=’welch’,win=’hann’,scaling=’density’,nfft=None, average=’mean’,

    detrend=’constant’,nperseg=None,noverlap=None,show_plot=False)

  • To override any of the argument or suply additional argument based of periodogram, provide the in periodogram_kwargs.

  • For example, periodogram_kwargs = dict(win=’ham’), will overide the win.

filter_warn: bool, default=True
  • It will show warning, if any additional argument other than deafult setting for filter, is provided

  • To turn warning statement off, set filter_warn=False

periodogram_warn=True,
  • It will show warning, if any additional argument other than deafult setting for periodogram is provided

  • To turn warning statement off, set filter_warn=False

verbose: int, default=0
  • verbosity mode

Returns:
Px: 2d-array.
  • sum of the power in a band - shape (number of bands,nch)

Pm: 2d-array.
  • mean power in a band - shape (number of bands,nch)

Pd: 2d-array.
  • standard deviation of power in a band - shape (number of bands,nch)

References

Examples

#sp.eeg.rhythmic_powers
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
X,fs, ch_names = sp.data.eeg_sample_14ch()
X = sp.filterDC_sGolay(X, window_length=fs//3+1)

Px,Pm,Pd = sp.eeg.rhythmic_powers(X=X,fs=fs,fBands=[[4],[8,14]],Sum=True,Mean=True,SD =True)

bind = np.arange(len(ch_names))
plt.figure(figsize=(10,4))
plt.subplot(211)
plt.bar(bind*3,Px[0],label=r'$\delta$')
plt.bar(bind*3+1,Px[1],label=r'$\alpha$')
plt.xticks(bind*3+0.5,ch_names)
plt.legend()
plt.ylabel('Total Power')
plt.subplot(212)
plt.bar(bind*3,Pd[0],label=r'$\delta$')
plt.bar(bind*3+1,Pd[1],label=r'$\alpha$')
plt.xticks(bind*3+0.5,ch_names)
plt.legend()
plt.ylabel('Variation of Power \n within a band')
plt.show()
../../_images/spkit-eeg-rhythmic_powers-1.png

Examples using spkit.eeg.rhythmic_powers

EEG Data from EDF File

EEG Data from EDF File