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:Computes second moments of non-overlapping windows.
Projects them onto their top
n_modes - 1principal components.Finds the
n_modeswindows spanning the largest simplex (N-FINDR, Winter 1999).Computes each window’s non-negative, sum-to-one coordinates relative to those vertices and fits the covariances to all windows by least squares.
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).