def _poly_drift(order, frame_times): """Create a polynomial drift matrix Parameters ---------- order : int, Number of polynomials in the drift model. frame_times : array of shape(n_scans), Time stamps used to sample polynomials. Returns ------- pol : ndarray, shape(n_scans, order + 1) Estimated polynomial drifts plus a constant regressor. """ order = int(order) pol = np.zeros((np.size(frame_times), order + 1)) tmax = float(frame_times.max()) for k in range(order + 1): pol[:, k] = (frame_times / tmax)**k pol = _orthogonalize(pol) pol = np.hstack((pol[:, 1:], pol[:, :1])) return pol
def test_orthogonalize_trivial(): """ test that the orthogonalization is OK """ rng = np.random.RandomState(42) X = rng.standard_normal(size=100) Y = X.copy() X = _orthogonalize(X) assert_array_equal(Y, X)
def test_orthogonalize(): """ test that the orthogonalization is OK """ X = np.random.randn(100, 5) X = _orthogonalize(X) K = np.dot(X.T, X) K -= np.diag(np.diag(K)) assert_almost_equal((K ** 2).sum(), 0, 15)
def test_orthogonalize(): """ test that the orthogonalization is OK """ rng = np.random.RandomState(42) X = rng.standard_normal(size=(100, 5)) X = _orthogonalize(X) K = np.dot(X.T, X) K -= np.diag(np.diag(K)) assert_almost_equal((K**2).sum(), 0, 15)
def test_orthogonalize_trivial(): """ test that the orthogonalization is OK """ X = np.random.randn(100) Y = X.copy() X = _orthogonalize(X) assert_array_equal(Y, X)