osl_dynamics.models.base.nfindr_covariances#

osl_dynamics.models.base.nfindr_covariances(time_series, n_modes, window_length=20, n_restarts=10, eigenvalue_floor=0.01, random_seed=None)#

Estimate mode covariances for a soft mixture with N-FINDR.

Under C_t = sum_k alpha_tk C_k (zero mean), the second moment of a window is linear in the window-mean alpha, which lies on the simplex: E[S_w] = sum_k a_wk C_k. So the window second moments lie in a simplex whose vertices are the mode covariances (the linear mixing model of hyperspectral unmixing). This function:

  1. Computes second moments of non-overlapping windows.

  2. Projects them onto their top n_modes - 1 principal components.

  3. Finds the n_modes windows spanning the largest simplex (N-FINDR, Winter 1999).

  4. Computes each window’s non-negative, sum-to-one coordinates relative to those vertices and fits the covariances to all windows by least squares.

  5. Floors the eigenvalues so each covariance is positive definite.

Note, if no window is close to pure for a mode, the vertex found for it is a mixture; the covariances are then a denoised estimate of the purest windows rather than the pure modes.

Parameters:
time_serieslist of np.ndarray or np.ndarray

Time series for each session (or sequence). Each array has shape (n_samples, n_channels). Assumed to have zero mean.

n_modesint

Number of modes.

window_lengthint, optional

Number of samples in each window.

n_restartsint, optional

Number of random starts for N-FINDR.

eigenvalue_floorfloat, optional

Eigenvalues are floored at this fraction of their mean.

random_seedint, optional

Seed for the N-FINDR starts.

Returns:
covariancesnp.ndarray

Mode covariances. Shape is (n_modes, n_channels, n_channels).

References

M. E. Winter, “N-FINDR: an algorithm for fast autonomous spectral end-member determination in hyperspectral data”, Proc. SPIE 3753 (1999).