osl_dynamics.data.processing
#
Functions to process data.
Module Contents#
Functions#
|
Standardizes a time series. |
|
Performs time embedding. |
|
Apply temporal filtering. |
Calculate amplitude envelope. |
|
|
Calculate a moving average. |
|
Downsample. |
- osl_dynamics.data.processing.standardize(x, axis=0, create_copy=True)[source]#
Standardizes a time series.
Returns a time series with zero mean and unit variance.
- Parameters:
x (np.ndarray) – Time series data. Shape must be (n_samples, n_channels).
axis (int, optional) – Axis on which to perform the transformation.
create_copy (bool, optional) – Should we return a new array containing the standardized data or modify the original time series array?
- Returns:
X – Standardized data.
- Return type:
np.ndarray
- osl_dynamics.data.processing.time_embed(x, n_embeddings)[source]#
Performs time embedding.
- Parameters:
x (np.ndarray) – Time series data. Shape must be (n_samples, n_channels).
n_embeddings (int) – Number of samples in which to shift the data.
- Returns:
X – Time embedded data. Shape is (n_samples - n_embeddings + 1, n_channels * n_embeddings).
- Return type:
sliding_window_view
- osl_dynamics.data.processing.temporal_filter(x, low_freq, high_freq, sampling_frequency, order=5)[source]#
Apply temporal filtering.
- Parameters:
x (np.ndarray) – Time series data. Shape must be (n_samples, n_channels).
low_freq (float) – Frequency in Hz for a high pass filter.
high_freq (float) – Frequency in Hz for a low pass filter.
sampling_frequency (float) – Sampling frequency in Hz.
order (int, optional) – Order for a butterworth filter.
- Returns:
X – Filtered time series. Shape is (n_samples, n_channels).
- Return type:
np.ndarray
- osl_dynamics.data.processing.amplitude_envelope(x)[source]#
Calculate amplitude envelope.
- Parameters:
x (np.ndarray) – Time series data. Shape must be (n_samples, n_channels).
- Returns:
X – Amplitude envelope data. Shape is (n_samples, n_channels).
- Return type:
np.ndarray
- osl_dynamics.data.processing.moving_average(x, n_window)[source]#
Calculate a moving average.
- Parameters:
x (np.ndarray) – Time series data. Shape must be (n_samples, n_channels).
n_window (int) – Number of data points in the sliding window. Must be odd.
- Returns:
X – Time series with sliding window applied. Shape is (n_samples - n_window + 1, n_channels).
- Return type:
np.ndarray
- osl_dynamics.data.processing.downsample(x, new_freq, old_freq)[source]#
Downsample.
- Parameters:
x (np.ndarray) – Time series data. Shape must be (n_samples, n_channels).
old_freq (float) – Old sampling frequency in Hz.
new_freq (float) – New sampling frequency in Hz.
- Returns:
X – Downsampled time series. Shape is (n_samples * new_freq / old_freq, n_channels).
- Return type:
np.ndarray