def test_tangent_and_untangent_space(get_covmats): """Test tangent space projection and retro-projection should be the same""" n_matrices, n_channels = 10, 3 covmats = get_covmats(n_matrices, n_channels) Xts = tangent_space(covmats, np.eye(n_channels)) covmats_ut = untangent_space(Xts, np.eye(n_channels)) assert covmats_ut == approx(covmats)
def test_untangent_space(rndstate): """Test untangent space projection""" n_matrices, n_channels = 10, 3 n_ts = (n_channels * (n_channels + 1)) // 2 T = rndstate.randn(n_matrices, n_ts) covmats = untangent_space(T, np.eye(n_channels)) assert covmats.shape == (n_matrices, n_channels, n_channels)
def inverse_transform(self, X, y=None): """Inverse transform. Project back a set of tangent space vector in the manifold. Parameters ---------- X : ndarray, shape (n_trials, n_ts) ndarray of SPD matrices. y : ndarray | None (default None) Not used, here for compatibility with sklearn API. Returns ------- cov : ndarray, shape (n_trials, n_channels, n_channels) the covariance matrices corresponding to each of tangent vector. """ self._check_reference_points(X) return untangent_space(X, self.reference_)
def test_tangent_and_untangent_space(): """Test tangent space projection and retro-projection should be the same""" C = generate_cov(10,3) T = tangent_space(C,np.eye(3)) covmats = untangent_space(T,np.eye(3)) assert_array_equal(C,covmats)
def test_untangent_space(): """Test untangent space projection""" T = np.random.randn(10,6) covmats = untangent_space(T,np.eye(3))