brainda.algorithms.feature_analysis package¶
Submodules¶
brainda.algorithms.feature_analysis.freq_analysis module¶
- class brainda.algorithms.feature_analysis.freq_analysis.FrequencyAnalysis(data, meta, event, srate, latency=0, channel='all')¶
Bases:
object- plot_topomap(data, ch_names, srate=-1, ch_types='eeg')¶
-author: Zhou hongzhan & He Jiatong -Create on:2022-8-9 -update log:
2022-8-31 by Zhou hongzhan
- Parameters:
data – np.array, 1D array eeg data. The default is [].
ch_names – list interested channels
srate – int sample rate. The default is -1.if set as default ,the initial sample ratio will be applied
ch_types – string Type of channels,default value=’eeg’
- power_spectrum_periodogram(x)¶
-author: Zhou hongzhan & He Jiatong -Create on:2022-8-9 -update log:
2022-8-31 by Zhou hongzhan
- Parameters:
x – np.array 1D data.
- Returns:
- np.array
An array of frequencies
- Pxx_dennp.array
The amplitude array respectively correspond to frequency array
- Return type:
f
- signal_noise_ratio(data=[], srate=-1, T=[], channel=[])¶
-author: Zhou hongzhan & He Jiatong -Create on:2022-8-9 -update log:
2022-8-31 by Zhou hongzhan
- Parameters:
data – np.array, 1D array eeg data. The default is [].
srate – int sample rate. The default is -1.if set as default ,the initial sample ratio will be applied
T – int, ms the during time of data. The default is [].
channel – string interested channels
- Returns:
- np.array
frequency sequece.
- snrnp.array
SNR sequence
- Return type:
X1
- stacking_average(data=[], _axis=0)¶
-author: Zhou hongzhan -Create on:2022-8-9 -update log:
2022-8-11 by Zhou hongzhan
- Parameters:
data – np.array (nTrials, nChannels, nTimes) EEG origin data. The default is [].
_axis – int The dimension need to be stacked. The default is 0.
- Returns:
- np.array
The data after stacked.
- Return type:
data_mean
- sum_y(x, y, x_inf, x_sup)¶
-author: Zhou hongzhan -Create on:2022-8-9 -update log:
2022-8-11 by Zhou hongzhan
- Parameters:
x – np.array(1D) An array of frequencies
y – np.array(1D,SAME TYPE WITH X) The amplitude array respectively correspond to frequency array
x_inf – int Infimum of freq.
x_sup – int Supremum of freq.
- Returns:
- int
freq parameter,topomap procedure needed
- Return type:
np.mean(sum_A)
brainda.algorithms.feature_analysis.time_analysis module¶
- class brainda.algorithms.feature_analysis.time_analysis.TimeAnalysis(data, meta, dataset, event, latency=0.0, channel=[0])¶
Bases:
object- Chan_Neuroscan = ['FP1', 'FPZ', 'FP2', 'AF3', 'AF4', 'F7', 'F5', 'F3', 'F1', 'FZ', 'F2', 'F4', 'F6', 'F8', 'FT7', 'FC5', 'FC3', 'FC1', 'FCZ', 'FC2', 'FC4', 'FC6', 'FT8', 'T7', 'C5', 'C3', 'C1', 'CZ', 'C2', 'C4', 'C6', 'T8', 'M1', 'TP7', 'CP5', 'CP3', 'CP1', 'CPZ', 'CP2', 'CP4', 'CP6', 'TP8', 'M2', 'P7', 'P5', 'P3', 'P1', 'PZ', 'P2', 'P4', 'P6', 'P8', 'PO7', 'PO5', 'PO3', 'POZ', 'PO4', 'PO6', 'PO8', 'CB1', 'O1', 'OZ', 'O2', 'CB2']¶
- Chan_Standard1020 = ['Fp1', 'Fpz', 'Fp2', 'AF3', 'AF4', 'F7', 'F5', 'F3', 'F1', 'Fz', 'F2', 'F4', 'F6', 'F8', 'FT7', 'FC5', 'FC3', 'FC1', 'FCz', 'FC2', 'FC4', 'FC6', 'FT8', 'T7', 'C5', 'C3', 'C1', 'Cz', 'C2', 'C4', 'C6', 'T8', 'M1', 'TP7', 'CP5', 'CP3', 'CP1', 'CPz', 'CP2', 'CP4', 'CP6', 'TP8', 'M2', 'P7', 'P5', 'P3', 'P1', 'Pz', 'P2', 'P4', 'P6', 'P8', 'PO7', 'PO5', 'PO3', 'POz', 'PO4', 'PO6', 'PO8', 'I1', 'O1', 'Oz', 'O2', 'I2']¶
- average_amplitude(data=[], time_start=0, time_end=1)¶
-author: Jiang Hanzhe -Created on: 2022-8-8 -updata log:
2022-8-15 by Jiang Hanzhe
- Parameters:
data (ndarray) – the EEG data, by default []
time_start (int) – beginning of peak seeking, by default 0
time_end (int) – end of peak seeking, by default 1
- Returns:
signal average amplitude within the specified time quantum
- Return type:
ave_amp(float)
- average_latency(data=[], time_start=0, time_end=1)¶
-author: Wu Jieyu -Created on: 2022-8-8 -updata log:
2022-8-15 by Wu Jieyu
- Parameters:
data (ndarray) – the EEG data, by default []
time_start (int) – beginning of peak seeking, by default 0
time_end (int) – end of peak seeking, by default 1
- Returns:
location of average amplitude ave_amp(float): signal average amplitude within the specified time quantum
- Return type:
ave_loc(int)
- get_chan_id(ch_name, channels)¶
-author: Wu Jieyu -Created on: 2022-8-8 -updata log:
2022-8-15 by Wu Jieyu
- Parameters:
ch_name (list) – selected channels
channels (list) – standard channel list
- Returns:
index of ch_name in channels
- Return type:
Chan_ID(list)
- peak_amplitude(data=[], time_start=0, time_end=1)¶
-author: Jiang Hanzhe -Created on: 2022-8-8 -updata log:
2022-8-15 by Jiang Hanzhe
- Parameters:
data (ndarray) – the EEG data, by default []
time_start (int) – beginning of peak seeking, by default 0
time_end (int) – end of peak seeking, by default 1
- Returns:
signal peak amplitude within the specified time quantum
- Return type:
peak_amp(float)
- peak_latency(data=[], time_start=0, time_end=1)¶
-author: Wu Jieyu -Created on: 2022-8-8 -updata log:
2022-8-15 by Wu Jieyu
- Parameters:
data (ndarray) – the EEG data, by default []
time_start (int) – beginning of peak seeking, by default 0
time_end (int) – end of peak seeking, by default 1
- Returns:
location of peak amplitude peak_amp(float): signal peak amplitude within the specified time quantum
- Return type:
peak_loc(int)
- plot_multi_trials(data, sample_num, axes=None)¶
-author: Wu Jieyu -Created on: 2022-8-8 -updata log:
2022-8-15 by Wu Jieyu
- Parameters:
data (ndarray) – the EEG data
sample_num (int) – total number of sampling points in data
axes (axessubplot) – drawing area
- Returns:
drawing area
- Return type:
ax(axessubplot)
- plot_single_trial(data, sample_num, axes=None, amp_mark=False, time_start=0, time_end=1)¶
-author: Wu Jieyu -Created on: 2022-8-8 -updata log:
2022-8-15 by Wu Jieyu
- Parameters:
data (ndarray) – the EEG data
sample_num (int) – total number of sampling points in data
axes (axessubplot) – drawing area
amp_mark (string) – ‘peak’ or ‘average’, call different peak marking methods, by default False (not marked)
time_start (int) – beginning of peak seeking, by default 0
time_end (int) – end of peak seeking, by default 1
- Returns:
location of amplitude amp(float): signal amplitude within the specified time quantum ax(axessubplot): drawing area
- Return type:
loc(int)
- plot_topomap(data, point, channels, fig, srate=-1, ch_types='eeg', axes=None)¶
-author: Wu Jieyu -Created on: 2022-8-8 -updata log:
2022-8-15 by Wu Jieyu
- Parameters:
data (ndarray) – the EEG data
point (int) – selected sampling point
channels (list) – selected channels
fig (figure) – figure
srate (int) – sampling rate, by dafault self.fs
ch_types (list of str | str) – channel types, by default ‘eeg’
axes (axessubplot) – drawing area, by default none
- Returns:
drawing area
- Return type:
aximage(axessubplot)
- stacking_average(data=[], _axis=[0])¶
-author: Jiang Hanzhe -Created on: 2022-8-8 -updata log:
2022-8-15 by Jiang Hanzhe
- Parameters:
data (ndarray) – the EEG data, by default []
_axis (list) – selected the dimensions, by default [0]
- Returns:
array of averaged signals
- Return type:
data_mean(ndarray)
brainda.algorithms.feature_analysis.time_freq_analysis module¶
- class brainda.algorithms.feature_analysis.time_freq_analysis.TimeFrequencyAnalysis(fs)¶
Bases:
object- fun_hilbert(X, N=None, axis=-1)¶
-author: Li Xiaoyu -Created on: 2022-8-8 -updata log:
2022-8-11 by Li Xiaoyu
- Parameters:
X (ndarray) – the input data
N (int) – length of the hilbert used.
- Returns:
discrete-time analytic signal realEnv(ndarray): the real part of the discrete-time analytic signal. imagEnv(ndarray): the imaginary part of the discrete-time analytical signal. angle(ndarray): the angle of the discrete-time analytical signal. envModu(ndarray): the envelope of the discrete-time analytical signal
- Return type:
analytic_signal(ndarray)
- fun_stft(data, fs=None, window='hann', nperseg=256, noverlap=None, nfft=None, detrend=False, return_onesided=True, boundary='zeros', padded=True, axis=-1)¶
-author: Xin Fengran -Created on: 2022-8-8 -updata log:
2022-8-11 by Xin Fengran
- Parameters:
data (but for complex) – the EEG data
fs (float) – the rasampling rate
window (str or tuple or ndarray) – desired window to use.
nperseg (int) – length of each segment.
noverlap (int) – number of points to overlap between segments.
nfft (int) – length of the FFT used.
detrend (str or function or False) – specifies how to detrend each segment.
return_onesided (bool) – If True, return a one-sided spectrum for real data. If False return a two-sided spectrum.
True (Defaults to) –
data –
returned. (a two-sided spectrum is always) –
boundary (str) – Specifies whether the input signal is extended at both ends, and how to generate the new values,
point. (in order to center the first windowed segment on the first input) –
padded (bool) – Specifies whether the input signal is zero-padded at the end.
axis (int) – axis along which the STFT is computed
- Returns:
array of sample frequencies t(ndarray): array of segment times Zxx(ndarray): the STFT of the EEG data
- Return type:
f(ndarray)
- fun_topoplot(X, chan_names, sfreq=None, ch_types='eeg')¶
-author: Li Xiaoyu -Created on: 2022-8-8 -updata log:
2022-8-11 by Li Xiaoyu
- Parameters:
X (ndarray) – the input data
chan_names (list) – the name of channels
sfreq (float) – the sampling rate
ch_types (str) – the type of channel
- func_morlet_wavelet(data, xtimes, omega, sigma, fs=None)¶
-author: Xin Fengran -Created on: 2022-8-8 -update log:
2022-8-11 by Xin Fengran
- Parameters:
data – ndarray(Nchannel, Ntimes), the EEG data
xtimes – ndarray(N,), timeline of the EEG data
omega – float.
sigma – float.
fs – float, the resampling rate
- Returns:
ndarray(Nchannel, N, nTimes), square amplitude of Morlet wavelet transform S: ndarray(Nchannel, N, nTimes), complex values of Morlet wavelet transform
- Return type:
P