Created on Mon Nov 23 21:06:13 2020
@author: ide2704
Effective brain connectivity functions
Ivan De La Pava Panche, Automatics Research Group Universidad Tecnologica de Pereira, Pereira - Colombia email: ide@utp.edu.co
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.CFD_Ch(X, ch_pair, freq_ph, freq_amp, time, fs)[source]¶
Compute the cross-frequency directionality (CFD) between a pair channels
- Parameters
X (ndarray of shape (channels,samples)) – Input time series (number of channels x number of samples)
ch_pair (list) – Channel pair of interest
freq_ph (ndarray of shape (frequencies_ph,)) – Frequencies of interest for phase extraction, in Hz
freq_amp (ndarray of shape (frequencies_amp,)) – Frequencies of interest for amplitude extraction, in Hz
time (ndarray of shape (samples,)) – Time vector (must be sampled at the sampling frequency of X)
fs (float) – Sampling frequency
- Returns
CFD_pac – Cross frequency directionality
- Return type
ndarray of shape
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.GaussianKernel(X, sig_scale=1.0)[source]¶
Compute Gaussian Kernel matrix
- Parameters
X (ndarray of shape (samples,features)) – Input data
sig_scale (float) – Parameter to scale the kernel’s bandwidth
- Returns
K – Gaussian kernel matrix
- Return type
ndarray of shape (samples,samples)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.Morlet_Wavelet(data, time, freq)[source]¶
Morlet wavelet decomposition
- Parameters
data (ndarray of shape (samples,)) – Input signal
time (ndarray of shape (samples,)) – Time vector (must be sampled at the sampling frequency of data, best practice is to have time=0 at the center of the wavelet)
freq (ndarray of shape (frequencies,)) – Frequencies to evaluate in Hz
- Returns
dataW – Dictionary containing the Morlet wavelet decomposition of data ‘amp’: ndarray of shape (frequencies,num_samples) holding the amplitude envelopes at each freq ‘filt’: ndarray of shape (frequencies,num_samples) holding the filtered signals at each freq ‘phase’: ndarray of shape (frequencies,num_samples) holding the phase time series at each freq ‘f’: ndarray of shape (frequencies,) holding the evaluated frequencies in Hz (If samples is odd, num_samples = samples, otherwise num_samples = samples-1)
- Return type
dict of keys {‘amp’,’filt’,’phase’,’f’}
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.PSI(x, y, freq_range, fs)[source]¶
Compute the phase slope index (PSI) from channel x to channel y
- Parameters
x (ndarray of shape (samples,)) – Source time series
y (ndarray of shape (samples,)) – Target time series
freq_range (ndarray of shape (frequencies,)) – Frequencies of interest, in Hz
fs (float) – Sampling frequency
- Returns
psi – PSI(x->y) at the freq_range
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.Wavelet_Trial_Dec(data, time, freq, component='phase')[source]¶
Morlet wavelet decomposition for multiple channels
- Parameters
data (ndarray of shape (channels,samples)) – Input signals (number of channels x number of samples)
time (ndarray of shape (samples,)) – Time vector (must be sampled at the sampling frequency of data)
freq (ndarray of shape (frequencies,)) – Frequencies to evaluate in Hz
component ({'filt','amp','phase'}) – Component of interest from the wavelet decomposition at each frequency in freq (filt: filtered data, amp: amplitude envelope, phase: phase)
- Returns
wav_dec – Array containing the wavelet decomposition of data at the target frequencies (If samples is odd, num_samples = samples, otherwise num_samples = samples-1)
- Return type
ndarray of shape (channels,num_samples,frequencies)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.autocorr_decay_time(x, maxlag)[source]¶
Autocorrelation decay time (embedding delay)
- Parameters
x (ndarray of shape (samples,)) – Input time series
maxlag (int) – Maximum embedding delay
- Returns
act – Embedding delay
- Return type
int
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.autocorrelation(x)[source]¶
Autocorrelation of x
- Parameters
x (ndarray of shape (samples,)) – Input time series
- Returns
act – Autocorrelation
- Return type
ndarray of shape (samples,)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.cao_criterion(x, d_max, tau)[source]¶
Cao’s criterion (embedding dimension)
- Parameters
x (ndarray of shape (samples,)) – Input time series
d_max (int) – Maximum embedding dimension
tau (int) – Embedding delay
- Returns
dim – Embedding dimension
- Return type
int
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.compare_AlphaFz(sq_amp, sq_amp_baseline)[source]¶
Compare the baseline alpha squared amplitude with that of a single epoch.
- Parameters
sq_amp (float) – Alpha squared amplitude (Fz) from a single epoch
cnt_baseline (float) – Baseline alpha squared amplitude (Fz)
- Returns
feedback_val – Feedback value for stimulus presentation [-1,1]
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.compare_connectivity_CFD(cnt, cnt_baseline)[source]¶
Compare the baseline connectivity with the connectivity from a single epoch.
- Parameters
cnt (ndarray of shape (channels,channels)) – Connectivity data from a single epoch
cnt_baseline (ndarray of shape (channels,channels)) – Baseline connectivity
- Returns
feedback_val – Feedback value for stimulus presentation [-1,1]
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.compare_connectivity_kTE(cnt, cnt_baseline)[source]¶
Compare the baseline connectivity with the connectivity from a single epoch.
- Parameters
cnt (ndarray of shape (channels,channels)) – Connectivity data from a single epoch
cnt_baseline (ndarray of shape (channels,channels)) – Baseline connectivity
- Returns
feedback_val – Feedback value for stimulus presentation [-1,1]
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.embeddingX(x, tau, dim, u)[source]¶
Time-delay embbeding of the source time series x
- Parameters
x (ndarray of shape (samples,)) – Source time series
dim (int) – Embedding dimension
tau (int) – Embedding delay
u (int) – Interaction time
- Returns
X_emb – Time embedded source time series
- Return type
ndarray of shape (samples-(tau*(dim-1))-u,dim)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.embeddingY(y, tau, dim, u)[source]¶
Time-delay embbeding of the target time series y
- Parameters
y (ndarray of shape (samples,)) – Target time series
dim (int) – Embedding dimension
tau (int) – Embedding delay
u (int) – Interaction time
- Returns
Y_emb (ndarray of shape (samples-(tau*(dim-1))-u,dim)) – Time embedded target time series
y_t (ndarray of shape (samples-(tau*(dim-1))-u,1)) – Time shifted target time series
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.kernelRenyiEntropy(K_lst, alpha)[source]¶
Compute Renyi’s entropy from kernel matrices
- Parameters
K_lst (list) – List holding kernel matrices [ndarrays of shape (channels,channels)]
alpha (int or float) – Order of Renyi’s entropy
- Returns
h – Kernel-based Renyi’s transfer entropy, TE(x->y)
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.kernelTransferEntropy(x, y, dim, tau, u, alpha, sig_scale=1.0)[source]¶
Compute kernel-based Renyi’s transfer entropy from channel x to channel y
- Parameters
x (ndarray of shape (samples,)) – Source time series
y (ndarray of shape (samples,)) – Target time series
dim (int) – Embedding dimension
tau (int) – Embedding delay
u (int) – Interaction time
alpha (int or float) – Order of Renyi’s entropy
sig_scale (float) – Parameter to scale the kernel’s bandwidth
- Returns
TE – Kernel-based Renyi’s transfer entropy, TE(x->y)
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.kernelTransferEntropy_PAC_Ch(X, ch_pair, Dim, Tau, U, alpha, freq_ph, freq_amp, time, sig_scale=1.0)[source]¶
Compute directed phase-amplitude interactions through kernel-based Renyi’s phase transfer entropy between a pair channels
- Parameters
X (ndarray of shape (channels,samples)) – Input time series (number of channels x number of samples)
Dim (ndarray of shape (channels,)) – Embedding dimension for each channel
Tau (ndarray of shape (channels,)) – Embedding delay for each channel
U (ndarray of shape (channels,)) – Interaction times for each channel pair and direction of interaction
alpha (int or float) – Order of Renyi’s entropy
freq_ph (ndarray of shape (frequencies_ph,)) – Frequencies of interest for phase extraction, in Hz
freq_amp (ndarray of shape (frequencies_amp,)) – Frequencies of interest for amplitude extraction, in Hz
time (ndarray of shape (samples,)) – Time vector (must be sampled at the sampling frequency of X)
sig_scale (float) – Parameter to scale the kernel’s bandwidth
- Returns
TE_pac – Directed PAC estimated through kernel-based Renyi’s phase transfer entropy
- Return type
ndarray of shape (frequencies_ph,frequencies_amp)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.neurofeedback_AlphaFz(data, ch_labels, fs)[source]¶
Compute the average squared alpha amplitude (Fz) for a 1 second long EEG trial (epoch).
- Parameters
data (ndarray of shape (channels,samples)) – Input time series (number of channels x number of samples)
ch_labels (list) – EEG channel labels
fs (float) – Sampling frequency (Hz)
- Returns
mean_power – Average squared alpha amplitude (Fz)
- Return type
float
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.neurofeedback_CFD(data, ch_labels, fs)[source]¶
Compute the average CFD (Frontal/pre-frontal theta to parietal/occipital alpha) for a 1 second long EEG trial (epoch).
- Parameters
data (ndarray of shape (channels,samples)) – Input time series (number of channels x number of samples)
ch_labels (list) – EEG channel labels
fs (float) – Sampling frequency (Hz)
- Returns
CFD_mean – Average CFD for the channels and frequency bands of interest
- Return type
ndarray of shape (channels,channels)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.neurofeedback_kTE_PAC(data, ch_labels, fs)[source]¶
Compute the average PAC through kTE (Frontal/pre-frontal theta to parietal/occipital alpha) for a 1 second long EEG trial (epoch).
- Parameters
data (ndarray of shape (channels,samples)) – Input time series (number of channels x number of samples)
ch_labels (list) – EEG channel labels
fs (float) – Sampling frequency (Hz)
- Returns
kTE_mean – Average PAC kTE for the channels and frequency bands of interest
- Return type
ndarray of shape (channels,channels)
- bci_framework.default_extensions.Neuropathic_pain_Generator.NeuroFeedbackFunctions.win_segmentation(x, n_win, overlap)[source]¶
Segment time series x into windows of n_win points with an overlap of overlap
- Parameters
x (ndarray of shape (samples,)) – Time series
n_win (integer) – Number of data points per window
overlap (float) – Percentage of overlap among the segmentation windows
- Returns
seg_signal – Time series segmented into multiple windows
- Return type
ndarray of shape