cedalion.sigdecomp.unimodal.spoc
Source Power Co-modulation (SPoC) algorithm.
Functions
|
Standardize x along dimension dim. |
Classes
|
Source Power Co-modulation (SPoC_lambda) algorithm based on Dähne et al. [DMH+14]. |
- class cedalion.sigdecomp.unimodal.spoc.SPoC(n_comp: int | None = None)[source]
Bases:
objectSource Power Co-modulation (SPoC_lambda) algorithm based on Dähne et al. [DMH+14].
Given a vector-valued time signal x(t) and a scalar target function z(t), SPoC finds spatial filters W that maximize the covariance between the bandpower of the projected x signal, P(W.T @ x), and z. Such a covariance defines the objective function of the problem, whose solution can be formulated as the one for a generalized eigenvalue problem. The reconstructed sources s are given by the backward model s = W.T @ x.
- Assumptions:
x(t) is of shape Nx x Nt, where Nx is the number of channels and Nt the number of time points, and it is band-pass filtered in the frequency band of interest. z(e) is a standardize vector (zero mean and unit variance) of shape 1 x Ne, where Ne < Nt is the number of “epochs”. The latter represent labels for intervals of the original time series. Bandpower of the projected signal W.T @ x is then approximated by its variance within epochs.
- Parameters:
n_comp (int) – Number of components the algorithm will find in decreasing
highest (order of scores/eigenvalue. n_comp=1 returns the component of the)
None (eigenvalue. If)
Nx (n_comp =)
components. (the maximum possible number of)
- fit(
- x: Annotated[DataArray, DataArraySchema(dims='time', coords='time', 'time', 'samples')],
- z: DataArray,
Fit the model on the (x, z) dataset.
Solve the generalized eigenvalue problem and store the trained spatial filters W as a local state of the class.
- Parameters:
x (
NDTimeSeries, (channel, time)) – Temporal signalNt. (with Ne <)
z (
DataArray, (time)) – Target (scalar) functionNe (of shape 1 x)
Nt.
n_comp (int) – Number of components the algorithm will find in decreasing order of scores/eigenvalue. n_comp=1 returns the component of the highest eigenvalue. If None, n_comp = Nx, the maximum possible number of components.
- Returns:
- Array of Nx eigenvalues. The latter also coincide with
the corresponding covariances between P(W.T @ x) and z.
- Return type:
scores
- transform(
- x: Annotated[DataArray, DataArraySchema(dims='time', coords='time', 'time', 'samples')],
- get_bandpower: bool = True,
- Ne: int | None = None,
Apply backward model to x to build reconstructed sources.
Get reconstructed sources s by projecting x along the spatial filtes. If get_bandpower = True, also estimate epoch-wise bandpower of the components via the per-epoch variance.
- Parameters:
x (
NDTimeSeries, (channel, time)) – Temporal signal of shape Nx x Nt.get_bandpower – Wether to return only the reconstructed sources or also the epoch-wise bandpower.
Ne – Number of epochs along which to estimate the bandpower.
- Returns:
Reconstructed sources (W.T @ x). s_power: standardized epoch-wise bandpower of s (Var(W.T @ x)).
- Return type:
s
- cedalion.sigdecomp.unimodal.spoc.standardize(
- x: Annotated[DataArray, DataArraySchema(dims='time', coords='time', 'time', 'samples')],
- dim: str = 'time',
Standardize x along dimension dim.