meegkit.tspca#
Time-shift PCA.
Functions
|
Time-shift PCA. |
|
Time-shift regression. |
- meegkit.tspca.tspca(X, shifts=None, keep=None, threshold=None, weights=None, demean=False)#
Time-shift PCA.
- Parameters:
X (array, shape=(n_times, n_chans[, n_trials])) – Data array.
shifts (array, shape=(n_shifts,)) – Array of shifts to apply.
keep (int) – Number of components (shifted regressor PCs) to keep (default=all).
threshold – Discard PCs with eigenvalues below this (default=1e-6).
weights (array) – Sample weights.
demean (bool) – If True, Epochs are centered before computing PCA (default=0).
- Returns:
comps (array) – Principal components array.
V (array, shape=(n_chans, n_comps)) – PCA weights.
idx (array) – X[idx] maps to principal comps.
- meegkit.tspca.tsr(X, R, shifts=None, wX=None, wR=None, keep=None, thresh=1e-12)#
Time-shift regression.
The basic idea is to project the signal X on a basis formed by the orthogonalized time-shifted R, and remove the projection. Supposing R gives a good observation of the noise that contaminates X, the noise is removed. By allowing time shifts, the algorithm finds the optimal FIR filter to apply to R so as to compensate for any convolutional mismatch between X and R.
- Parameters:
X (array, shape=(n_samples, n_chans[, n_trials])) – Data to denoise.
R (array, shape=(n_samples, n_comps[, n_trials])) – Reference data.
shifts (array, shape=(n_shifts,)) – Array of shifts to apply to R (default=[0]).
wX (array, shape=(n_samples, 1, n_trials)) – Weights to apply to X.
wR (array, shape=(n_samples, 1, n_trials)) – Weights to apply to R.
keep (int | None) – Number of shifted-R PCs to retain (default=all).
thresh (float) – Ignore shifted-R PCs smaller than thresh (default=1e-12).
- Returns:
y (array) – Denoised data.
idx (array) – X[idx] is aligned with y.
mean (array) – Channel means (removed by TSR).
weights (array) – Weights applied by TSR.