osl_dynamics.data.processing#
Functions to process data.
Functions#
|
Standardizes a time series. |
|
Performs time embedding. |
|
Applies temporal filtering. |
Calculates amplitude envelope. |
|
|
Calculates a moving average over a sliding window along the time axis. |
|
Downsample. |
Module Contents#
- 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]#
Applies 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]#
Calculates 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]#
Calculates a moving average over a sliding window along the time axis.
This function uses a cumulative-sum trick for efficiency and returns only resulting values where the full window fits.
- 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