brainmass.objectives.fcd_wasserstein

brainmass.objectives.fcd_wasserstein#

brainmass.objectives.fcd_wasserstein(window_size=30, step_size=5, midpoints=None, bw_method=None, n_diag=1)[source]#

Build a Wasserstein FCD-distribution loss (smooth, grad-friendly).

Compares the distribution of FCD off-diagonal values of the prediction and target – the standard FCD fitting target – rather than the FCD matrix correlation (fcd()). The wasserstein_1d() distance is smooth, so this is the recommended FCD objective for gradient-based fitting.

Parameters:
  • window_size (int) – Sliding-window length and stride (in samples) for braintools.metric.functional_connectivity_dynamics().

  • step_size (int) – Sliding-window length and stride (in samples) for braintools.metric.functional_connectivity_dynamics().

  • midpoints (array, optional) – FCD-value evaluation grid (default 100 points on [-0.99, 0.99]).

  • bw_method (optional) – KDE bandwidth forwarded to fcd_distribution().

  • n_diag (int, default 1) – Upper-triangle diagonal offset.

Returns:

loss(prediction, target) -> scalar Wasserstein-1 distance between the two FCD distributions (a quantity to minimise; 0 on identity).

Return type:

callable

See also

fcd_ks

the non-smooth KS counterpart.

fcd

FCD matrix correlation objective.

Examples

>>> import numpy as np, jax.numpy as jnp
>>> from brainmass import objectives
>>> rng = np.random.default_rng(0)
>>> x = jnp.asarray(rng.standard_normal((200, 6)))
>>> loss = objectives.fcd_wasserstein(window_size=30, step_size=5)
>>> float(loss(x, x))
0.0