diffusion_mapping#

hypercoil.functional.connectopy.diffusion_mapping(W: Array | ndarray, k: int = 10, alpha: float = 0.5, diffusion_time: int = 0) Tuple[Array | ndarray, Array | ndarray][source]#

Manifold coordinates estimated using diffusion mapping.

This functionality is adapted very closely from brainspace with some minor adaptations for differentiability.

Warning

Sparse inputs are currently unsupported because an implementation of a sparse extremal eigenvalue solver does not yet exist in JAX. For sparse inputs, use the generalised connectopic functional instead – once we implement VJP rules for elementary operations on sparse matrices, anyway.

Note

The anisotropic diffusion parameter determines the kind of diffusion map produced by the algorithm.

  • α=0 produces Laplacian eigenmaps, corresponding to a random walk-style diffusion operator.

  • α=0.5 (default) corresponds to Fokker-Planck diffusion.

  • α=1 corresponds to Laplace-Beltrami diffusion.

Dimension:
W : (,N,N) or (,E)

* denotes any number of preceding dimensions, N denotes number of vertices, and E denotes number of edges. The shape should be (,N,N) if edge_index is not provided and (,E) if edge_index is provided.

edge_index : (,2,E)

As above.

Q : (,N,k)

k denotes the number of diffusion maps.

L : (,k)

As above.

Parameters:
Wtensor

Edge weight tensor. This should be the graph adjacency (or affinity) matrix.

kint (default 10)

Number of eigenmaps to compute.

alphafloat [0,1] (default 0.5)

Anisotropic diffusion parameter.

diffusion_timeint (default 0)

Diffusion time parameter. A value of 0 indicates that a multi-scale diffusion map should be computed, which considers all valid times (1, 2, 3, etc.).

Returns:
Qtensor

Diffusion maps.

Ltensor

Eigenvalues corresponding to diffusion maps.