netneurotools.utils.get_triu
- netneurotools.utils.get_triu(data, k=1)[source]
Return vectorized version of upper triangle from data.
- Parameters:
data ((N, N) array_like) – Input data
k (int, optional) – Which diagonal to select from (where primary diagonal is 0). Default: 1
- Returns:
triu – Upper triangle of data
- Return type:
(N * N-1 / 2) numpy.ndarray
Examples
>>> from netneurotools import utils
>>> X = np.array([[1, 0.5, 0.25], [0.5, 1, 0.33], [0.25, 0.33, 1]]) >>> tri = utils.get_triu(X) >>> tri array([0.5 , 0.25, 0.33])