medusa.local_activation package
Submodules
medusa.local_activation.nonlinear_parameters module
- medusa.local_activation.nonlinear_parameters.central_tendency_measure(signal, r)[source]
This method implements the central tendency measure (CTM). This parameter is useful to quantify the variability of a signal. It is based on calculating the second-order differences diagram of the time series and then counting the points within a radius “r”. CTM assigns higher values to less variable signals
REFERENCES: Cohen, M. E., Hudson, D. L., & Deedwania, P. C. (1996). Applying continuous chaotic modeling to cardiac signal analysis. IEEE Engineering in Medicine and Biology Magazine, 15(5), 97-102.
- Parameters
signal (numpy 2D array) – MEEG Signal. [n_samples x n_channels].
r (double) – Radius used to compute the CTM.
- Returns
ctm – CTM values for each channel in “signal”. [n_channels].
- Return type
numpy 2D array
- medusa.local_activation.nonlinear_parameters.lempelziv_complexity(signal)[source]
Calculate the signal binarisation and the Lempel-Ziv’s complexity. This version allows the algorithm to be used for signals with more than one channel at the same time.
- Parameters
signal (numpy 2D array) – Signal with shape [n_samples, n_channels]
- Returns
lz_channel_values – Lempel-Ziv values for each channel. [n_channels].
- Return type
numpy 1D matrix
- medusa.local_activation.nonlinear_parameters.lempelziv_complexity_fast(signal)[source]
Calculate the signal binarisation and the Lempel-Ziv’s complexity. This version allows the algorithm to be used for signals with more than one channel at the same time. Faster than the lempelziv_complexity function
as this version is implemented in C.
- Parameters
signal (numpy 2D array) – Signal with shape [n_samples, n_channels]
- Returns
lz_channel_values – Lempel-Ziv values for each channel. [n_channels].
- Return type
numpy 1D matrix
- medusa.local_activation.nonlinear_parameters.multiscale_entropy(signal, max_scale, m, r)[source]
This method implements the Multiscale Entropy (MSE). MSE is a measurement of complexity which measures the irregularity of a signal over multiple time scales. This is accomplished through estimation of the Sample Entropy (SampEn) on coarse-grained versions of the original signal. As a result of the these alculations, MSE curves are obtained and can be used to compare the complexity of time-series. The MSE curve whose entropy values are higher for the most of time scales is considered more complex
REFERENCES: Costa, M., Goldberger, A. L., & Peng, C. K. (2005). Multiscale entropy analysis of biological signals. Physical review E, 71(2), 021906.
- Parameters
signal (numpy 2D array) – MEEG Signal. [n_samples, n_channels].
max_scale (int) – Maximum scale value
m (int) – Sequence length
r (float) – Tolerance
- Returns
sampen – SampEn values for each scale for each channel in “signal” . [max_scale, n_channels].
- Return type
numpy 2D array
- medusa.local_activation.nonlinear_parameters.multiscale_lempelziv_complexity(signal, W)[source]
Calculate the multiscale signal binarisation and the Multiscale Lempel-Ziv’s complexity. This version allows the algorithm to be used for signals with more than one channel at the same time.
- Parameters
signal (numpy 2D array) – Signal with shape [n_samples x n_channels]
W (list or numpy 1D array) – Set of window length to consider at multiscale binarisation stage. Values must be odd.
- Returns
result – Matrix of results with shape [n_window_length, n_channels]
- Return type
numpy 2D array
References
- Ibáñez-Molina, A. J., Iglesias-Parro, S., Soriano, M. F., & Aznarte, J. I.
(2015). Multiscale Lempel-Ziv complexity for EEG measures. Clinical Neurophysiology, 126(3), 541–548. https://doi.org/10.1016/j.clinph.2014.07.012
- medusa.local_activation.nonlinear_parameters.sample_entropy(signal, m, r, dist_type='chebyshev')[source]
This method implements the sample entropy (SampEn). SampEn is an irregularity measure that assigns higher values to more irregular time sequences. It has two tuning parameters: the sequence length (m) and the tolerance (r)
REFERENCES: Richman, J. S., & Moorman, J. R. (2000). Physiological time-series analysis using approximate entropy and sample entropy. American Journal of Physiology-Heart and Circulatory Physiology.
- Parameters
signal (numpy 2D array) – MEEG Signal. [n_samples, 1].
m (double) – Sequence length
r (double) – Tolerance
dist_type (string) – Distance allowed by Scipy distance pdist function
- Returns
sampen – SampEn value.
- Return type
numpy 2D array
medusa.local_activation.spectral_parameteres module
- medusa.local_activation.spectral_parameteres.absolute_band_power(psd, fs, target_band)[source]
This method computes the absolute band power of the signal in the given band using the power spectral density (PSD).
- Parameters
psd (numpy array) – PSD signal with shape [n_epochs, n_samples, n_channels]. Some of these dimensions may not exist in advance. In these case, create new axis using np.newaxis. E.g., non-epoched single-channel signal with shape [n_samples] can be passed to this function with psd[numpy.newaxis, …, numpy.newaxis]. Afterwards, you may use numpy.squeeze to eliminate those axes.
fs (int) – Sampling frequency of the signal
target_band (numpy 2D array) – Frequency band where to calculate the power in Hz. E.g., [8, 13]
- Returns
powers – RP value for each band, epoch and channel. [n_bands, n_epochs, n_channels]
- Return type
numpy 2D array
- medusa.local_activation.spectral_parameteres.individual_alpha_frequency(psd, fs, target_band=(4, 15))[source]
This method computes the individual alpha frequency (IAF) of the signal in the given band. This is the another name for median frequency, usually used in MEEG studies.
- Parameters
psd (numpy array) – PSD of MEEG signal with shape [n_epochs, n_samples, n_channels]. Some of these dimensions may not exist in advance. In these case, create new axis using np.newaxis. E.g., non-epoched single-channel signal with shape [n_samples] can be passed to this function with psd[numpy.newaxis, …, numpy.newaxis]. Afterwards, you may use numpy.squeeze to eliminate those axes.
fs (int) – Sampling frequency of the signal
target_band (numpy array) – Frequency band where the IAF will be computed. [b1_start, b1_end]. Default [4, 15]
- Returns
iaf – IAF value for each epoch and channel with shape [n_epochs x n_channels].
- Return type
numpy 2D array
- medusa.local_activation.spectral_parameteres.median_frequency(psd, fs, target_band=(1, 70))[source]
This method computes the median frequency (MF) of the signal in the given band.
- Parameters
psd (numpy array) – PSD of MEEG signal with shape [n_epochs, n_samples, n_channels]. Some of these dimensions may not exist in advance. In these case, create new axis using np.newaxis. E.g., non-epoched single-channel signal with shape [n_samples] can be passed to this function with psd[numpy.newaxis, …, numpy.newaxis]. Afterwards, you may use numpy.squeeze to eliminate those axes.
fs (int) – Sampling frequency of the signal
target_band (numpy array) – Frequency band where the MF will be computed. [b1_start, b1_end]. Default [1, 70].
- Returns
median_freqs – MF value for each epoch and channel with shape [n_epochs x n_channels].
- Return type
numpy 2D array
- medusa.local_activation.spectral_parameteres.relative_band_power(psd, fs, target_band, baseline_band=None)[source]
This method computes the absolute band power of the signal in the given band using the power spectral density (PSD).
- Parameters
psd (numpy array) – PSD with shape [n_epochs, n_samples, n_channels]. Some of these dimensions may not exist in advance. In these case, create new axis using np.newaxis. E.g., non-epoched single-channel signal with shape [n_samples] can be passed to this function with psd[numpy.newaxis, …, numpy.newaxis]. Afterwards, you may use numpy.squeeze to eliminate those axes.
fs (int) – Sampling frequency of the signal
target_band (numpy 2D array) – Frequency band where to calculate the power in Hz. E.g., [8, 13]
- Returns
powers – RP value for each band, epoch and channel. [n_bands, n_epochs, n_channels]
- Return type
numpy 2D array
- medusa.local_activation.spectral_parameteres.relative_band_power_meeg(psd, fs, target_bands=((1, 4), (4, 8), (8, 13), (13, 19), (19, 30), (30, 70)))[source]
This method computes the relative power of the classical MEEG bands with respect to the total power using the power spectral density (PSD). By default, these bands are Delta: (1, 4), Theta: (4, 8), Alpha: (8, 13), Beta-1: (13, 19), Beta-2: (19, 30) and Gamma: (30, 70), but they may be customized.
- Parameters
psd (numpy array) – PSD with shape [n_epochs, n_samples, n_channels]. Some of these dimensions may not exist in advance. In these case, create new axis using np.newaxis. E.g., non-epoched single-channel signal with shape [n_samples] can be passed to this function with psd[numpy.newaxis, …, numpy.newaxis]. Afterwards, you may use numpy.squeeze to eliminate those axes.
fs (int) – Sampling frequency of the signal
target_bands (numpy 2D array) – Frequency bands where the RP will be computed. [[b1_start, b1_end], … [bn_start, bn_end]]
- Returns
powers – RP value for each band, epoch and channel. [n_bands, n_epochs, n_channels]
- Return type
numpy 2D array
- medusa.local_activation.spectral_parameteres.shannon_spectral_entropy(psd, fs, target_band=(1, 70))[source]
Computes the Shannon spectral entropy of the power spectral density (PSD) in the given band.
- Parameters
- psdnumpy array
PSD of MEEG signal with shape [n_epochs, n_samples, n_channels]. Some of these dimensions may not exist in advance. In these case, create new axis using np.newaxis. E.g., non-epoched single-channel signal with shape [n_samples] can be passed to this function with psd[numpy.newaxis, …, numpy.newaxis]. Afterwards, you may use numpy.squeeze to eliminate those axes.
- fsint
Sampling frequency of the signal
- target_bandnumpy array
Frequency band where the SE will be computed. [b1_start, b1_end]. Default [1, 70]
- sample_entropynumpy 2D array
SE value for each epoch and channel with shape [n_epochs x n_channels].
medusa.local_activation.statistics module
Created on Fri Dec 20 12:33:30 2019 Modified on Tue Jun 21 12:32:00 2022
@author: VICTOR
- medusa.local_activation.statistics.signed_r2(class1, class2, signed=True, axis=0)[source]
This function computes the basic form of the squared point biserial correlation coefficient (r2-value).
- Parameters
class1 (list or numpy.ndarray) – Data that belongs to the first class
class1 – Data that belongs to the second class
signed (bool (Optional, default=True)) – Controls if the sign should be mantained.
axis (int (Optional, default=0)) – Dimension along which the r2-value is computed. Therefore, if class1 and class2 has dimensions of [observations x samples] and dim=0, the r2-value will have dimensions [1 x samples].
- Returns
r2 – (Signed) r2-value.
- Return type
numpy.ndarray