fc_correlation_loss#
- class braintools.fit.losses.fc_correlation_loss(prediction, target)#
Compute one minus the correlation between two functional-connectivity matrices.
Both inputs are turned into Pearson functional-connectivity (FC) matrices with
functional_connectivity(); the loss is1 - rwhereris the Pearson correlation of their upper triangles (diagonal excluded), computed bymatrix_correlation().- Parameters:
- Returns:
Scalar loss in
[0, 2].- Return type:
Array- Raises:
ValueError – If an input is not 2-D, has fewer than 2 regions, or the region counts differ.
See also
Notes
Identical to
brainmass.objectives.fc_corr(as_loss=True). With 2 regions the upper triangle has one element and its correlation is undefined; it is taken to be 0 (loss 1). Works underjax.jitandjax.vmapand is differentiable.Examples
>>> import numpy as np >>> import jax.numpy as jnp >>> from braintools.fit import losses >>> x = jnp.asarray(np.random.default_rng(0).standard_normal((200, 5))) >>> round(float(losses.fc_correlation_loss(x, x)), 6) 0.0