CCA_align¶
- CCA_align(L_a, L_b)[source][source]¶
Canonical Correlation Analysis (CCA) alignment between 2 datasets.
From: https://www.nature.com/articles/s41593-019-0555-4#Sec11. Returns manifold directions to transform L_a and L_b into a common space (e.g. L_a_new.T = L_a.T @ M_a, L_b_new.T = L_b.T @ M_b). To transform into a specific patient space, for example putting everything in patient A’s space, use L_(b->a).T = L_b.T @ M_b @ (M_a)^-1, where L_a and L_(b->a) will be aligned in the same space.
- Parameters:
L_a (
ndarray) – Latent dynamics array for dataset A of shape (m, T), where m is the number of latent dimensions and T is the number of timepoints.L_b (
ndarray) – Latent dynamics array for dataset B of shape (m, T)
- Returns:
Tuple containing: M_a : ndarray
Manifold directions for dataset A of shape (m, m)
- M_bndarray
Manifold directions for dataset B of shape (m, m)
- Return type:
Examples
>>> import numpy as np >>> rand = np.random.RandomState(seed=0) >>> L_a = np.random.randn(5, 10) >>> L_b = np.random.randn(5, 10) >>> M_a, M_b = CCA_align(L_a, L_b) >>> M_a.shape (5, 5) >>> (L_b.T @ M_b).shape (10, 5)